Viewing 6 replies - 1 through 6 (of 6 total)
  • Have you tried installing the plugin and just trying it???

    Not possible at the moment!

    Thread Starter Patrice Poliquin

    (@poliquinp)

    @boomba123, the plugin works perfectly on Single pages.. My customer wanted THIS plugin and he WANTS to get the plugin on archives pages.

    Thx @rene, i’ll try to figure out a way to do it.

    Does your customer want to have it on top of such a archive page or within every excerpt or title of multiplied posts on one site?

    If first case: You can write do_action(‘mashshare’); directly on top or bottom of this page and its working fine.

    Thread Starter Patrice Poliquin

    (@poliquinp)

    No they really want to get the shares on every articles.

    I understand a little more your functions and it seems that the script is executed on load page instead in the while > call of the function.

    because you urlencode(get_permalink($post->ID) returns the page url instead of the destination url (in scripts.php)

    EDIT

    And I see that the code does not seems to take muliple instance of the PHP function since they is no foreach in the main javascript file.

    You can overwrite the way Mashshare is currently creating the Share buttons.
    Ate the moment script.php writes all the necessary information for sharing into var mashsb (look at the html source at <CDATA> part within the header)

    You can write a new function and just put it in a separate plugin or into functions.php:

    function overwriteGetNetworks ( $output) {
        if (!empty($enablednetworks)) {
            foreach ($enablednetworks as $key => $network):
                if($mashsb_options['visible_services'] !== 'all' && $maxcounter != count($enablednetworks) && $mashsb_options['visible_services'] < count($enablednetworks)){
                    //if ($startcounter > $maxcounter){$hiddenclass = 'mashsb-hide';} else {$hiddenclass = '';}
                    if ($startcounter === $maxcounter ){
                        $onoffswitch = onOffSwitch();
                        //$onoffswitch2 = onOffSwitch2();
                        $startsecondaryshares   = '<div class="secondary-shares" style="display:none;">';} else {$onoffswitch = ''; $onoffswitch2 = ''; $startsecondaryshares   = '';}
                    if ($startcounter === (count($enablednetworks))){
                        //$onoffswitch2 = onOffSwitch2();
                        $endsecondaryshares     = '</div>'; } else { ;$endsecondaryshares = '';}</p>
                  //echo " Debug: Startcounter " . $startcounter . " Hello: " . $maxcounter+1 .
                     //" Debug: Enabled services: " . count($enablednetworks) . "";
                }
                if ($enablednetworks[$key]['name'] !='') {
                    /* replace all spaces with $nbsp; prevents css content: error on text-intend */
                    $name = preg_replace('/40{1,}/','?',$enablednetworks[$key]['name']);
                } else {
                    $name = ucfirst($enablednetworks[$key]['id']);
                }</p>
                $output .= '<a href="void(0);"><span class="icon"></span><span class="text">' . $name . '</span></a>';
                $output .= $onoffswitch;
                $output .= $startsecondaryshares;</p>
                $startcounter++;
            endforeach;
            $output .= onOffSwitch2();
            $output .= $endsecondaryshares;
        }
    }
    
    add_filter( 'return_networks', 'overwriteGetNetworks ' );

    This is not a ready to use code, you have to do some changes here:

    $output .= '<a class="mashicon-' . $enablednetworks[$key]['id'] . '" href="javascript:void(0);"><span class="icon"></span><span class="text">' . $name . '</span></a>';

    Build the share links and fill page title and page url into some vars and than create an array which contains the href share links like

    $shareurl = array(
    'Twitter' => 'https://twitter.com/intent/tweet?text=Mashshare+%E2%80%93+A+Mashable+inspired+share+button%20&via=Mashshare&url=https://www.mashshare.net/',
    'Facebook' => 'https://www.facebook.com/sharer/sharer.php?s=100&p[title]=EXAMPLE&p[summary]=EXAMPLE&p[url]=EXAMPLE&p[images][0]=EXAMPLE'
    )

    Change the href part to something like:

    $output .= '<a class="mashicon-' . $enablednetworks[$key]['id'] . '" href="'.$shareurl[$key]['id'].'"><span class="icon"></span><span class="text">' . $name . '</span></a>';

    Hope this brings you on the right track. Its not complicated but is a whole rewrite of the current function. Let me know if you need more help. You can reach me info [at] mashshare.net

    Edit: With this approach we use href for building the share links and use js only for generating the popup window.

    If you find some time to work on this i can create a git hup repository for Mashshare and will later merge this new function into the Mashare core.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add the plugin on a archive page with posts’ is closed to new replies.