Support » Plugin: Shared Counts - Social Media Share Buttons » Doesn’t display on WooCommerce products if using a Genesis theme

  • Resolved ZeroGravity

    (@zerogravity)


    If you are using a Genesis theme the plugin uses the genesis_entry_header and genesis_entry_footer actions. I gather these are not fired when the page is a WooCommerce product so the sharing icons are not displayed.

    I’m sure there is probably a better way to do this but I added the following code to the theme_location() funstion at line #54 in class-shared-counts-front.php.

    // WooCommerce Hooks.
    if ( is_woocommerce() ) {
    
    	$locations = [
    		'before' => [
    			'hook'     => 'woocommerce_before_single_product',
    			'filter'   => false,
    			'priority' => 13,
    			'style'    => false,
    		],
    		'after'  => [
    			'hook'     => 'woocommerce_after_single_product',
    			'filter'   => false,
    			'priority' => 8,
    			'style'    => false,
    		],
    	];
    
    // Genesis Hooks.
    } elseif ( 'genesis' === get_template() ) {
    • This topic was modified 2 months, 2 weeks ago by ZeroGravity. Reason: formatting
Viewing 1 replies (of 1 total)
  • Thread Starter ZeroGravity

    (@zerogravity)

    I should have kept reading. The plugin provides a filter so you can change the action hook that is used to display the icons. I added this to my core functionality plugin.

    /**
     * Move Shared Counts
     * @see http://sharedcountsplugin.com/2019/03/27/change-the-theme-location-for-share-buttons/
     *
     * @param array $locations
     * @return array
     */
    function be_shared_counts_location( $locations ) {
    	if ( is_woocommerce() ) {
    		// Before WC Product
    		$locations['before']['hook'] = 'woocommerce_before_single_product';
    		$locations['before']['filter'] = false;
    	
    		// After WC Product
    		$locations['after']['hook'] = 'woocommerce_after_single_product';
    		$locations['after']['filter'] = false;
    	}
    
    	return $locations;
    }
    add_filter( 'shared_counts_theme_locations', 'be_shared_counts_location' );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.