Skip to content

Commit

Permalink
Rename hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Nov 22, 2024
1 parent 53bbd7a commit 8d84b92
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions THEMES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Friends Themes

Here you can find themes that have been created for the Friends plugin.

- [Mastodon-like interface](https://github.com/akirk/friends-mastodon-like-interface)

If you want to create your own theme, take a look at the [wiki page on Writing Themes](https://github.com/akirk/friends/wiki/Writing-Themes).
10 changes: 5 additions & 5 deletions includes/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private function register_hooks() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'template_redirect', array( $this, 'load_theme' ) );
add_action( 'customize_loaded_components', array( $this, 'ensure_widget_editing' ) );
add_action( 'friends_activate_theme_default', array( $this, 'default_theme' ) );
add_action( 'friends_load_theme_default', array( $this, 'default_theme' ) );
add_action( 'friends_template_paths', array( $this, 'friends_template_paths' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'dequeue_scripts' ), 99999 );
add_action( 'wp_footer', array( $this, 'dequeue_scripts' ) );
Expand Down Expand Up @@ -253,17 +253,17 @@ public function load_theme() {
$theme = $post_type_theme;
}
}
if ( ! has_action( 'friends_activate_theme_' . $theme ) ) {
if ( ! has_action( 'friends_load_theme_' . $theme ) ) {
$theme = 'default';
}
$this->theme = $theme;
do_action( 'friends_activate_theme_' . $theme );
do_action( 'friends_load_theme_' . $theme );
}

public function friends_template_paths( $file_paths ) {
$backup_file_paths = $file_paths;
if ( has_filter( 'friends_theme_template_paths_' . $this->theme ) ) {
$file_paths = apply_filters( 'friends_theme_template_paths_' . $this->theme, $file_paths );
if ( has_filter( 'friends_template_paths_theme_' . $this->theme ) ) {
$file_paths = apply_filters( 'friends_template_paths_theme_' . $this->theme, $file_paths );
}
if ( empty( $file_paths ) ) {
return $backup_file_paths;
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
<select name="friends_frontend_theme_<?php echo esc_attr( $post_type_slug ); ?>" id="frontend-theme-<?php echo esc_attr( $post_type_slug ); ?>">
<option value=""><?php esc_html_e( 'Main Theme', 'friends' ); ?></option>
<?php foreach ( Friends\Frontend::get_themes() as $theme => $theme_name ) : ?>
<option value="<?php echo esc_attr( $theme ); ?>"<?php selected( $args[ 'frontend_theme_' . $post_type ], $theme ); ?>><?php echo esc_html( $theme_name ); ?></option>
<option value="<?php echo esc_attr( $theme ); ?>"<?php selected( $args[ 'frontend_theme_' . $post_type_slug ], $theme ); ?>><?php echo esc_html( $theme_name ); ?></option>
<?php endforeach; ?>
</select>
</td>
Expand Down

0 comments on commit 8d84b92

Please sign in to comment.