Skip to content

Commit

Permalink
Frontend: Support Jetpack's alternate sharing button display modes.
Browse files Browse the repository at this point in the history
Now supports 'Icon only' and 'Text only' as well.

See #17.
  • Loading branch information
r-a-y committed Dec 17, 2021
1 parent 7e354d7 commit 863b8f9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
12 changes: 9 additions & 3 deletions classes/bpModDefaultContentTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,18 +310,24 @@ public static function blog_post_delete($id, $id2)
}

/**
* Add blog post moderate link to Jetpack's Sharedaddy row, if available.
* Add blog post moderate link to Jetpack's Sharing Buttons row, if available.
*
* @param string $retval Current markup for the Sharedaddy buttons.
* @param string $retval Current markup.
* @return string
*/
public static function blog_post_append_link_with_jetpack( $retval ) {
$jetpack = get_option( 'sharing-options' );
$display_type = $jetpack['global']['button_style'];

$link = bpModFrontend::get_link(array(
'type' => 'blog_post',
'author_id' => $GLOBALS['post']->post_author,
'id' => get_current_blog_id(),
'id2' => $GLOBALS['post']->ID,
'custom_class' => 'sd-button'
'custom_class' => 'sd-button',
'flagged_text' => 'icon' === $display_type ? false : null,
'unflagged_text' => 'icon' === $display_type ? false : null,
'dashicons' => 'text' === $display_type ? false : true
));

if ( empty( $link ) ) {
Expand Down
7 changes: 6 additions & 1 deletion classes/bpModFrontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function generate_link($args = '')
'is_main_content' => false, // if this content is the main content of the current page, used in future features
'custom_class' => '', // custom css class of the link, use the class bpm-no-images if you do not want flag icon
'context' => 'called', // internal arg, place a css class depending where and how the link is called
'dashicons' => true, // whether to use dashicons in the link
);

$params = wp_parse_args($args, $defaults);
Expand Down Expand Up @@ -178,7 +179,11 @@ function generate_link($args = '')
$link .= $flagged ? 'bpm-flagged ' : 'bpm-unflagged ';
$link .= (empty($text) ? 'bpm-no-text ' : '');
$link .= "bpm-context-$context $custom_class' >";
$link .= "<span class='dashicons dashicons-flag'></span>";

if ( $dashicons ) {
$link .= "<span class='dashicons dashicons-flag'></span>";
}

$link .= "<span class='bpm-inner-text' >" . ($text ? $text : '&nbsp;') . "</span>";
$link .= "</a>";

Expand Down
11 changes: 9 additions & 2 deletions css/bp-moderation.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
.bpm-report-link .dashicons-flag::before {
font-size: 16px;
padding-right: 4px;
vertical-align: bottom;
vertical-align: inherit;
}

.bpm-flagged .dashicons-flag::before {
Expand Down Expand Up @@ -81,4 +81,11 @@ p.bp-mod-pm-thread-links {
}
p.bp-mod-pm-thread-links span.bpm-inner-text {
text-decoration: none;
}
}

.sharedaddy .share-moderation .bpm-no-text .bpm-inner-text {
display: none;
}
.sharedaddy .share-moderation .bpm-no-text .dashicons-flag::before {
padding-right: 0;
}

0 comments on commit 863b8f9

Please sign in to comment.