array( $this, 'block_editor_click_to_tweet' ), ) ); } /** * Click to Tweet Block block editor support. * * @param array $attributes Block attributes. * @since 1.0.0 */ public function block_editor_click_to_tweet( $attributes ) { ob_start(); $shortcode = '[ss_click_to_tweet'; if ( isset( $attributes['content'] ) && '' !== $attributes['content'] ) { $shortcode .= ' content="' . wp_kses_post( htmlentities( $attributes['content'], ENT_QUOTES ) ) . '"'; } if ( isset( $attributes['tweet'] ) && '' !== $attributes['tweet'] ) { $shortcode .= ' tweet="' . wp_kses_post( htmlentities( $attributes['tweet'] ), ENT_QUOTES ) . '"'; } if ( isset( $attributes['style'] ) ) { $shortcode .= ' style="' . sanitize_text_field( $attributes['style'] ) . '"'; } if ( isset( $attributes['link'] ) ) { $shortcode .= ' link="' . sanitize_text_field( $attributes['link'] ) . '"'; } if ( isset( $attributes['via'] ) ) { $shortcode .= ' via="' . sanitize_text_field( $attributes['via'] ) . '"'; } $shortcode .= ']'; echo do_shortcode( $shortcode ); return ob_get_clean(); } /** * Register shortcode for click to tweet module. * * @param array $atts Shortcode attributes. * @since 1.0.0 */ public function register_shortcodes( $atts ) { // Default Settings. $ctt = array( 'tweet' => '', 'content' => __( 'Enter Tweet Content here...', 'socialsnap' ), 'style' => 'default', 'link' => '', 'via' => '', 'related' => '', 'hide_on_mobile' => '', ); // Apply settings from settings panel. $ctt = apply_filters( 'socialsnap_ctt_settings', $ctt ); $ctt = shortcode_atts( $ctt, $atts ); if ( '' == $ctt['tweet'] ) { $ctt['tweet'] = $ctt['content']; } if ( '' == $ctt['content'] ) { $ctt['content'] = $ctt['tweet']; } if ( isset( $ctt['hide_on_mobile'] ) && $ctt['hide_on_mobile'] ) { $ctt['hide_on_mobile'] = ' ss-hide-on-mobile'; } else { $ctt['hide_on_mobile'] = ''; } if ( '' !== $ctt['link'] && '0' !== $ctt['link'] && 'false' !== $ctt['link'] ) { $ctt['link'] = socialsnap_get_shared_permalink( array( 'network' => 'twitter' ) ); $ctt['link'] = apply_filters( 'socialsnap_complete_shared_permalink', $ctt['link'], 'twitter' ); } if ( '' === $ctt['via'] || '0' === $ctt['via'] || 'false' === $ctt['via'] ) { $ctt['via'] = ''; } else { $ctt['via'] = apply_filters( 'socialsnap_sanitize_username', socialsnap_settings( 'ss_twitter_username' ) ); } if ( 'default' === $ctt['style'] || ! $ctt['style'] ) { $ctt['style'] = socialsnap_settings( 'ss_ctt_preview_style' ); } // Generate tweet URL. $tweet_url = socialsnap_twitter_share_url( wp_strip_all_tags( html_entity_decode( $ctt['tweet'], ENT_QUOTES, get_bloginfo( 'charset' ) ) ), $ctt['link'], $ctt['via'], $ctt['related'] ); // Enqueue assets. socialsnap_enqueue_assets(); ob_start(); ?>
icons->get_svg( 'twitter' ); // phpcs:ignore ?>
$ctt_count ) ); } /** * Render settings preview screen. * * @since 1.0.0 */ public function preview_settings() { ?>