Replace _share-buttons-php partial
This commit is contained in:
parent
19e7ba5619
commit
4a6e5914bf
@ -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 ---> ?>
|
||||
<section class="story__after-summary <?php echo esc_attr( $classes ); ?>">
|
||||
<?php get_template_part( 'partials/_share-buttons', null, $hook_args ); ?>
|
||||
<div class="story__actions"><?php echo fictioneer_get_story_buttons( $hook_args ); ?></div>
|
||||
</section>
|
||||
<?php // <--- End HTML
|
||||
|
||||
// Store buffer
|
||||
$html = fictioneer_minify_html( ob_get_clean() );
|
||||
// Build HTML
|
||||
$html = '<section class="story__after-summary ' . esc_attr( $classes ) . '">';
|
||||
$html .= fictioneer_get_media_buttons( $hook_args );
|
||||
$html .= '<div class="story__actions">' . fictioneer_get_story_buttons( $hook_args ) . '</div></section>';
|
||||
|
||||
// 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' );
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -253,7 +253,7 @@ function fictioneer_story_actions( $args ) {
|
||||
|
||||
// Start HTML ---> ?>
|
||||
<section class="story__after-summary padding-left padding-right">
|
||||
<?php get_template_part( 'partials/_share-buttons' ); ?>
|
||||
<?php echo fictioneer_get_media_buttons(); ?>
|
||||
<div class="story__actions"><?php echo fictioneer_get_story_buttons( $args ); ?></div>
|
||||
</section>
|
||||
<?php // <--- End HTML
|
||||
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Partial: Share Buttons
|
||||
*
|
||||
* Renders a button to open the sharing modal and shows links to
|
||||
* Feedly, InoReader, and the RSS feed.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.7.0
|
||||
* @since 5.14.0 - Added option to disable share and rss buttons.
|
||||
* @see partials/_modal-sharing.php
|
||||
*
|
||||
* @internal $args['rss'] Optional. Whether to show the RSS links if enabled. Default true.
|
||||
* @internal $args['share'] Optional. Whether to show the Share buttons if enabled. Default true.
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
// No direct access!
|
||||
defined( 'ABSPATH' ) OR exit;
|
||||
|
||||
// Setup
|
||||
$post_type = get_post_type();
|
||||
$post_id = get_the_ID();
|
||||
$feed = fictioneer_get_rss_link( $post_type );
|
||||
$rss = $args['rss'] ?? 1;
|
||||
$share = $args['share'] ?? 1;
|
||||
$show_feed = $post_type !== 'fcn_story' ||
|
||||
( $post_type === 'fcn_story' && get_post_meta( $post_id, 'fictioneer_story_status', true ) !== 'Oneshot' );
|
||||
|
||||
?>
|
||||
|
||||
<div class="media-buttons">
|
||||
<?php if ( $share ) : ?>
|
||||
<label
|
||||
for="modal-sharing-toggle"
|
||||
class="tooltipped media-buttons__item"
|
||||
data-tooltip="<?php esc_attr_e( 'Share', 'fictioneer' ); ?>"
|
||||
tabindex="0"
|
||||
><i class="fa-solid fa-share-nodes"></i></label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $feed && $show_feed ) : ?>
|
||||
|
||||
<?php $feed_url = urlencode( $feed ); ?>
|
||||
|
||||
<?php if ( $rss && $post_type === 'fcn_story' && ! get_post_meta( $post_id, 'fictioneer_story_hidden', true ) ) : ?>
|
||||
<a
|
||||
href="<?php echo $feed; ?>"
|
||||
class="rss-link tooltipped media-buttons__item"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
data-tooltip="<?php esc_attr_e( 'Story RSS Feed', 'fictioneer' ); ?>"
|
||||
aria-label="<?php esc_attr_e( 'Story RSS Feed', 'fictioneer' ); ?>"
|
||||
><?php fictioneer_icon( 'fa-rss' ); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $rss ) : ?>
|
||||
<a
|
||||
href="https://feedly.com/i/subscription/feed/<?php echo $feed_url; ?>"
|
||||
class="feedly tooltipped hide-below-640 media-buttons__item"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
data-tooltip="<?php esc_attr_e( 'Follow on Feedly', 'fictioneer' ); ?>"
|
||||
aria-label="<?php esc_attr_e( 'Follow on Feedly', 'fictioneer' ); ?>"
|
||||
><?php fictioneer_icon( 'feedly' ); ?></a>
|
||||
|
||||
<a
|
||||
href="https://www.inoreader.com/?add_feed=<?php echo $feed_url; ?>"
|
||||
class="inoreader tooltipped hide-below-640 media-buttons__item"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
data-tooltip="<?php esc_attr_e( 'Follow on Inoreader', 'fictioneer' ); ?>"
|
||||
aria-label="<?php esc_attr_e( 'Follow on Inoreader', 'fictioneer' ); ?>"
|
||||
><?php fictioneer_icon( 'inoreader' ); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user