From 4a6e5914bf9b4d4098678833d0761e935571f209 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:02:28 +0200 Subject: [PATCH] Replace _share-buttons-php partial --- includes/functions/_setup-shortcodes.php | 30 +++----- includes/functions/hooks/_chapter_hooks.php | 3 +- includes/functions/hooks/_post_hooks.php | 4 +- includes/functions/hooks/_story_hooks.php | 2 +- partials/_share-buttons.php | 81 --------------------- 5 files changed, 14 insertions(+), 106 deletions(-) delete mode 100644 partials/_share-buttons.php diff --git a/includes/functions/_setup-shortcodes.php b/includes/functions/_setup-shortcodes.php index 3100dcdc..54a438e4 100644 --- a/includes/functions/_setup-shortcodes.php +++ b/includes/functions/_setup-shortcodes.php @@ -1646,11 +1646,8 @@ add_shortcode( 'fictioneer_story_section', 'fictioneer_shortcode_story_section' */ function fictioneer_shortcode_story_actions( $attr ) { - global $post; - // Setup $story_id = absint( $attr['story_id'] ?? 0 ); - $post = get_post( $story_id ); $story_data = fictioneer_get_story_data( $story_id ); $classes = wp_strip_all_tags( $attr['class'] ?? '' ); $follow = filter_var( $attr['follow'] ?? 1, FILTER_VALIDATE_BOOLEAN ); @@ -1661,6 +1658,8 @@ function fictioneer_shortcode_story_actions( $attr ) { $share = filter_var( $attr['share'] ?? 1, FILTER_VALIDATE_BOOLEAN ); $hook_args = array( + 'post_id' => $story_id, + 'post_type' => 'fcn_story', 'story_id' => $story_id, 'story_data' => $story_data, 'follow' => $follow, @@ -1698,34 +1697,23 @@ function fictioneer_shortcode_story_actions( $attr ) { // Add filter for buttons add_filter( 'fictioneer_filter_story_buttons', 'fictioneer_shortcode_remove_story_buttons', 99, 2 ); - // Buffer - ob_start(); - - // Setup post data - setup_postdata( $post ); - - // Start HTML ---> ?> -
- -
-
- '; + $html .= fictioneer_get_media_buttons( $hook_args ); + $html .= '
' . fictioneer_get_story_buttons( $hook_args ) . '
'; // Remove filter for buttons remove_filter( 'fictioneer_shortcode_remove_story_buttons', 99, 2 ); - // Reset post data - wp_reset_postdata(); + // Minify HTML + $html = fictioneer_minify_html( $html ); // Cache in Transient if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) { set_transient( $transient_key, $html, FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION ); } - // Return minified buffer + // Return minified HTML return $html; } add_shortcode( 'fictioneer_story_actions', 'fictioneer_shortcode_story_actions' ); diff --git a/includes/functions/hooks/_chapter_hooks.php b/includes/functions/hooks/_chapter_hooks.php index 7ed6973e..8287e7ff 100644 --- a/includes/functions/hooks/_chapter_hooks.php +++ b/includes/functions/hooks/_chapter_hooks.php @@ -436,7 +436,8 @@ function fictioneer_chapter_media_buttons() { return; } - get_template_part( 'partials/_share-buttons' ); + // Render media buttons + echo fictioneer_get_media_buttons(); } add_action( 'fictioneer_chapter_actions_bottom_left', 'fictioneer_chapter_media_buttons', 10 ); diff --git a/includes/functions/hooks/_post_hooks.php b/includes/functions/hooks/_post_hooks.php index 3c70ebfc..c41c44ce 100644 --- a/includes/functions/hooks/_post_hooks.php +++ b/includes/functions/hooks/_post_hooks.php @@ -124,8 +124,8 @@ function fictioneer_post_media_buttons() { return; } - // Render template - get_template_part( 'partials/_share-buttons' ); + // Render media buttons + echo fictioneer_get_media_buttons(); } add_action( 'fictioneer_post_footer_left', 'fictioneer_post_media_buttons', 10 ); diff --git a/includes/functions/hooks/_story_hooks.php b/includes/functions/hooks/_story_hooks.php index 811679e4..e08fb30e 100644 --- a/includes/functions/hooks/_story_hooks.php +++ b/includes/functions/hooks/_story_hooks.php @@ -253,7 +253,7 @@ function fictioneer_story_actions( $args ) { // Start HTML ---> ?>
- +
- - - -
- - - - - - - - - - - - - - - - - - - -