Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.76k stars 886 forks source link

Conflict with myContest plugin #97

Closed highergroundstudio closed 11 years ago

highergroundstudio commented 11 years ago

Upon updating to Wordpress SEO Version 1.4.13 the custom post type that I use on myContest (hooked via filter into the_content) double posting of the plugin content directly below the Body.

If I disable Wordpress SEO the problem no longer happens.

What was changed that would affect this so severely from the previous to 1.4.13 version?

I can always change my plugin to work with it but I am not sure what the problem is. The plugin is a premium plugin sold on codecanyon (link). I can send you a development version if need be.

Attached is a screenshot of the problem. double_post_mycontest

jrfnl commented 11 years ago

Without access to your code, I'm just guessing in the dark. However, AFAICS the WP SEO plugin does not hook into the the_content filter, so there is little chance that it has something to do with this.

My guess is that you are echo-ing the result of the function which you have hooked onto the_content instead of returning it as you should. That would explain the double content.

highergroundstudio commented 11 years ago

@jrfnl If it helps the function to display the custom post type is

    function mc_content_display($content = null){
        //Remove our filter so there is no problems
        remove_filter( 'the_content', array($this, 'mc_content_display'));

        // Only show on single page
        // If this is not our post type or if is home,archive, or category page just exit out
        //  return out content
        if( !is_single() || get_post_type() !== 'my_contest' || is_home() || is_archive() || is_category() ){ 
            // Add our filter back in
            add_filter('the_content', array($this, 'mc_content_display'), 8);
            return $content; //exit out
        }

        // just grabbing the global variable for use
        global $post;

        echo $content;

        $this->get_content($post->ID); // This is mainly html set outside php tags

        if($this->mycontest_powered){ 
            ?><a href="http://goo.gl/ty3UM" id="mycontestpowered" ><img src="<?php echo $this->pluginUrl . "/inc/images/contest-icon32.png";?>" alt="Powered by myContest"></a><?php
        }

        // Add our filter back in
        add_filter('the_content', array($this, 'mc_content_display'), 8);

        return;
    }
jrfnl commented 11 years ago

My guess is that you are echo-ing the result of the function which you have hooked onto the_content instead of returning it as you should. That would explain the double content.

My guess was right. This has absolutely nothing whatsoever to do with the WP SEO plugin. This is you doing it wrong. As your function clearly shows you are echo-ing the output, instead of returning the filtered output. That is the reason for the double content.

Change your code to something along the lines of the below and please have a careful look at my notes marked "DANGER ZONE":

    function mc_content_display($content = null){
        //Remove our filter so there is no problems
        remove_filter( 'the_content', array($this, 'mc_content_display'));

        // Only show on single page
        // If this is not our post type or if is home,archive, or category page just exit out
        //  return out content
        if( !is_single() || get_post_type() !== 'my_contest' || is_home() || is_archive() || is_category() ){ 
            // Add our filter back in
            add_filter('the_content', array($this, 'mc_content_display'), 8);
            return $content; //exit out
        }

        // just grabbing the global variable for use
        global $post;

        // DANGER ZONE: I don't know what this function does - does it output anything ??? If so, that function will need to be changed as well - make sure the function returns the html instead of echo-ing it.
        $content .= $this->get_content($post->ID); // This is mainly html set outside php tags

        if($this->mycontest_powered){
            $content .= '<a href="http://goo.gl/ty3UM" id="mycontestpowered" ><img src="' . $this->pluginUrl . '"/inc/images/contest-icon32.png" alt="Powered by myContest"></a>';
        }

        // Add our filter back in
        add_filter('the_content', array($this, 'mc_content_display'), 8);

        return $content;
    }

Oh and please close this issue as it is not a WP SEO issue.

Smile, Juliette

highergroundstudio commented 11 years ago

Thanks @jrfnl!

highergroundstudio commented 11 years ago

Is this the problem how I do the HTML outside the php tags? The get_content function looks like this:

/**
     * Get our contest content
     *
     * @author  Kyle King <kyle.king@highergroundstudio.com>
     *
     * @since 1.3.1 (moved from include file)
     *
     * @param string $id  Post (contest) id.
     * @return string Contest html.
     */
    function get_content($id){

        // Get our contest data
        $meta = get_post_meta($id, '_myContest', TRUE);

        // If the setting registered user can vote only is true and user is not logged in
        // Do not go any further and show the html
        // @since 1.2.0
        if ( isset($meta['settings']['regvoteonly']) & !is_user_logged_in() ){
            echo $meta['settings']['regvoteonlyhtml']; // print out html
            if (isset($meta['settings']['regvoteonlyshow'])) return; //exit out
        }

        // exit out if no entries
        if( empty($meta['entries']) ) return;//exit out! 

        // Setup our start and end dates
        if(isset( $meta['settings']['s_date'] )  & !empty($meta['settings']['s_date'])){
            list($month, $day, $year) = explode('/', $meta['settings']['s_date']);
            // check if hours are set if not set to 00
            if(!isset($meta['settings']['s_h']) || empty($meta['settings']['s_h'])) $meta['settings']['s_h'] = '00';
            // check if minutes are set if not set to 00
            if(!isset($meta['settings']['s_mn']) || empty($meta['settings']['s_mn'])) $meta['settings']['s_mn'] = '00';
            $start_date = mktime( $meta['settings']['s_h'], $meta['settings']['s_mn'], '00', $month, $day, $year );
        }
        if( isset( $meta['settings']['e_date'] ) & !empty($meta['settings']['e_date']) ){
            list($month, $day, $year) = explode('/', $meta['settings']['e_date']);
            // check if hours are set if not set to 00
            if(!isset($meta['settings']['e_h']) || empty($meta['settings']['e_h'])) $meta['settings']['e_h'] = "00";
            // check if minutes are set if not set to 00
            if(!isset($meta['settings']['e_mn']) || empty($meta['settings']['e_mn'])) $meta['settings']['e_mn'] = "00";
            $exp_date = mktime( $meta['settings']['e_h'], $meta['settings']['e_mn'], '00', $month, $day, $year );
        }

        //get todays date
        $todays_date = date("Y-m-d h:i");
        // convert to time
        $todays_date = strtotime($todays_date);

        //setup voting ended var
        $votingend = false;
        $votingstart = true;

        // compare if before expiration date
        if(isset($start_date)){
            if ($start_date > $todays_date) {
                // print out start message if it is set
                if( isset( $meta['settings']['s_txt'] ) & !empty($meta['settings']['s_txt']) ) echo $meta['settings']['s_txt'];
                // just exit out of here if not showing entries
                if( isset( $meta['settings']['s_entries'] ) ) return;
                $votingstart = false;
            }
        }

        // compare if past expiration date
        if(isset($exp_date)){
            if ($exp_date < $todays_date) {
                // Sort to high
                $meta['settings']['sort'] = "high";
                // print out start message if it is set
                if( isset( $meta['settings']['e_txt'] ) & !empty($meta['settings']['e_txt']) ) echo $meta['settings']['e_txt'];
                // just exit out of here if not showing entries
                if( isset( $meta['settings']['e_entries'] ) ) return;
                $votingend = true;
            }
        }

        // lets loop through the entries
        foreach($meta['entries'] as $entry){
            // Votes are 0 if not set
            if(empty($entry['votes']) || !isset($entry['votes'])) $entry['votes'] = 0;
        }

        // Sorting the votes
        switch ($meta['settings']['sort']):
            case "high":
                // Sort by votes (higher first)
                $newfunc = create_function('$a,$b', 'return $a["votes"] < $b["votes"];');
                uasort($meta['entries'], $newfunc);
            break;
            case "low":
                // Sort by votes (lower first)
                $newfunc = create_function('$a,$b', 'return $a["votes"] > $b["votes"];');
                uasort($meta['entries'], $newfunc);
            break;
            case "aztitle":
                // Sort title a to z
                $newfunc = create_function('$a,$b', 'return $a["entryTitle"] > $b["entryTitle"];');
                uasort($meta['entries'], $newfunc);
            break;
            case "zatitle":
                // Sort title z to a
                $newfunc = create_function('$a,$b', 'return $a["entryTitle"] < $b["entryTitle"];');
                uasort($meta['entries'], $newfunc);
            break;
            case "azauthor":
                // Sort author a to z
                $newfunc = create_function('$a,$b', 'return $a["author"] > $b["author"];');
                uasort($meta['entries'], $newfunc);
            break;
            case "zaauthor":
                // Sort author z to a
                $newfunc = create_function('$a,$b', 'return $a["author"] < $b["author"];');
                uasort($meta['entries'], $newfunc);
            break;
            case "rand":
                // Random

                // Get the array keys
                $keys = array_keys($meta['entries']);

                // Shuffle the keys
                shuffle($keys);

                // Reattach to the entries
                foreach($keys as $key) {
                    $new[$key] = $meta['entries'][$key];
                }
                $meta['entries'] = $new;
            break;
            default:
            // do nothing
            break;
        endswitch;

        ?>
        <div id="myContest-entries" class="<?php echo(isset($meta['settings']['votenoshow']) & $meta['settings']['votenoshow']  ? "votenoshow":"voteshow") ?>">
        <?php
        //number of entries
        $entriesnumb = 0;
        // lets loop through the entries
        foreach($meta['entries'] as $entry):
            // add one
            $entriesnumb++;
            // Break (end) the foreach if greater than the number of entries to show
            if(!empty($meta['settings']['e_showentries']) & $entriesnumb > $meta['settings']['e_showentries']) break;

            // Don't do this if there is no img_url
            if(!empty($entry['img_url'])){
                // change image size
                $image = $this->aq_resize( $url = $entry['img_url'], $width = 250, $height = null, $crop = true, $single = false );
                $retinaImage = $this->aq_resize( $url = $entry['img_url'], $width = 500, $height = null, $crop = true, $single = false );
            }

            // Votes are 0 if not set
            if(empty($entry['votes']) || !isset($entry['votes'])) $entry['votes'] = 0;
        ?>
            <div class="myContest-entry" style="width:250px;">
                <?php 
                // Show winner ribbons
                if($votingend & isset($meta['settings']['entry_ribbons']) & $entriesnumb <= 3) {
                    echo '<div class="ribbon-wrapper-green"><div class="ribbon-green">';
                    switch ($entriesnumb){
                        case 1:
                        echo '1st';
                        break;
                        case 2:
                        echo '2nd';
                        break;
                        case 3:
                        echo '3rd';
                        break;
                    }
                    echo '</div></div>';
                }
                ?>

                <?php 
                // Don't do this if there is no img_url
                if(!empty($entry['img_url']) || !isset($entry['img_url'])):
                ?>
                <a href="<?php echo $entry['img_url']; ?>" rel="myContest-gallery" class="mycontestbox" data-title="<?php echo $entry['entryTitle']; ?>" data-title-id="caption<?php echo $entry['entryID'] ?>" >

                    <div class="cn" style="width:<?php echo $image[1]; ?>px;height:<?php echo $image[2]; ?>px;display:none;">
                            <div class="icon-zoomin" style="top:<?php echo ($image[2] / 2) - 16; ?>px;left:<?php echo ($image[1] / 2) - 16; ?>px;"></div>
                    </div>

                    <img src="<?php echo $image[0]; ?>" data-retina="<?php echo $retinaImage[0]; ?>" alt="<?php echo $entry['entryTitle']; ?>" class="retina" width="<?php echo $image[1]; ?>px" height="<?php echo $image[2]; ?>px" />

                </a>

                <?php endif; ?>

        <?php 
            // if the entry title OR author name are not empty
            if(!empty($entry['entryTitle']) || !empty($entry['author']) || !empty($entry['descr'])): 
        ?>
                <div class="caption">
                    <?php 
                    // if the title is not empty
                    if(!empty($entry['entryTitle'])): 
                    ?>
                        <h3 class="entrytitle">
                    <?php
                        if(!empty($entry['url'])){
                    ?>
                        <a target="_blank" href="<?php echo $entry['url']; ?>"><?php echo $entry['entryTitle']; ?></a>
                    <?php 
                        }else{
                    ?>
                        <?php echo $entry['entryTitle']; ?>
                    <?php 
                        }
                        ?></h3><?php
                    endif; // if the title is not empty

                    // if the author is not empty
                    if(!empty($entry['author'])):
                        ?><h4 class="entryauthor"><?php 
                        echo __('by','mycontest');
                        // Check if the author url is set
                        if(isset($entry['authorurl']) & !empty($entry['authorurl'])){
                    ?>
                        <a target="_blank" href="<?php echo $entry['authorurl']; ?>">
                        <?php echo $entry['author']; ?>
                        </a>                
                    <?php 
                        // if the author url is not set
                        }else{
                            echo '&nbsp;' . $entry['author'];
                        }
                        ?></h4><?php
                    endif; //end if the author is not empty 

                    // if the description is not empty
                    if(!empty($entry['descr'])):
                    ?>
                        <p><?php echo $entry['descr']; ?></p>
                    <?php 
                    endif; //end if the descr is not empty 
                    ?>
                </div>
            <?php 
            endif; // end if the entry title OR author name are not empty
            if ( isset($meta['settings']['regvoteonly']) & !is_user_logged_in() ){/* do nothing */}else{

                // Social share setting
                if(isset($meta['settings']['socialshare'])):

                // Setup 0 counts
                $count = array(
                    'twitter' => 0,
                    'facebook' => 0,
                    'googleplus' => 0,
                    'pinterest' => 0
                );

                // Build the url for the entry
                $entryURL = get_permalink( $id ) . "?entryid=" . $entry['entryID'];
                // $entryURL = 'http://google.com'; // testing
                //Encode url for use on some api's
                $entryURLencoded = urlencode($entryURL);
                $shortenedURL = $entryURL;

                // make sure that cURL is enabeled
                if  ( in_array('curl', get_loaded_extensions()) ):
                    // ==================================================
                    // ---------------- General cURL --------------------
                    // ==================================================
                    $curlObj = curl_init();
                    curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
                    curl_setopt($curlObj, CURLOPT_HEADER, 0);
                    curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
                    curl_setopt($curlObj, CURLOPT_POST, 1);
                    curl_setopt($curlObj,CURLOPT_CONNECTTIMEOUT, 5);

                    // ==================================================
                    // ------------ Get shortened url -------------------
                    // ==================================================
                    if(isset($meta['settings']['ssshortenedlink'])):

                        $apiKey = 'AIzaSyApBUGmbUj5tYojIzL-Nep7fS9JoDQOMLM';
                        $postData = array('longUrl' => $entryURL, 'key' => $apiKey);
                        $jsonData = json_encode($postData);
                        curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
                        curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);

                        $response = curl_exec($curlObj);
                        //change the response json string to object
                        $json = json_decode($response);
                        // Set out variable
                        if(isset($json->id)) $shortenedURL = $json->id;

                    endif; // end shortened link

                    // Setup for rest of requests
                    curl_setopt($curlObj, CURLOPT_POSTFIELDS, "");
                    curl_setopt($curlObj, CURLOPT_POST, 0);

                    // ==================================================
                    // ------------ Get twitter count -------------------
                    // ==================================================
                    if(isset($meta['settings']['sstwitter'])):

                        curl_setopt($curlObj, CURLOPT_URL, 'http://urls.api.twitter.com/1/urls/count.json?url=' . $entryURLencoded);

                        $response = curl_exec($curlObj);
                        $json = json_decode($response);

                        if(isset($json->count)) $count['twitter'] = $json->count;

                    endif; // end twitter

                    // ==================================================
                    // ------------ Get facebook count ------------------
                    // ==================================================
                    if(isset($meta['settings']['ssfacebook'])):
                        curl_setopt($curlObj, CURLOPT_URL, "http://graph.facebook.com/fql?q=SELECT%20url,%20total_count%20FROM%20link_stat%20WHERE%20url='".$entryURLencoded."'");

                        $response = curl_exec($curlObj);
                        $json = json_decode($response);

                        if(isset($json->data[0]->total_count)) $count['facebook'] = $json->data[0]->total_count;
                    endif; // end facebook

                    // ==================================================
                    // ------------ Get pinterest count -----------------
                    // ==================================================
                    if(isset($meta['settings']['sspinterest'])):
                        curl_setopt($curlObj, CURLOPT_URL, 'http://api.pinterest.com/v1/urls/count.json?url='.$entryURLencoded);

                        $response = curl_exec($curlObj);
                        $json_string = preg_replace('/^receiveCount\((.*)\)$/', "\\1", $response);
                        $json = json_decode($json_string);

                        if(isset($json->count)) $count['pinterest'] = intval($json->count);
                    endif; // end pinterest

                    // ==================================================
                    // ------------ Get google+ count ------------------
                    // ==================================================
                    if(isset($meta['settings']['ssgoogleplus'])):
                        curl_setopt($curlObj, CURLOPT_URL, "https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ");
                        curl_setopt($curlObj, CURLOPT_POST, 1);
                        curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($curlObj, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $entryURL . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');

                        $response = curl_exec($curlObj);
                        $json = json_decode($response, true);

                        if(isset($json[0]['result']['metadata']['globalCounts']['count'])) $count['googleplus'] = intval($json[0]['result']['metadata']['globalCounts']['count']);

                    endif; // end google+

                    // Close cURL
                    curl_close($curlObj);

                endif; // end cURL check

                // Format numbers
                foreach($count as $s => $n){
                    if ($n < 1000) {
                        // Anything less than a million
                        $n_format = number_format($n);
                    }else if ($n < 1000000){
                        // Anthing less than a thousand
                        if($n > 10000){
                            $n_format = number_format($n / 10000, 0) . 'K';
                        }else{
                            $n_format = number_format($n / 10000, 1) . 'K';
                        }

                    } else if ($n < 1000000000) {
                        // Anything less than a billion
                        if($n < 10000000){
                            $n_format = number_format($n / 1000000, 1) . 'M';
                        }else{
                            $n_format = number_format($n / 1000000, 0) . 'M';
                        }
                    } else {
                        // At least a billion
                        $n_format = number_format($n / 1000000000, 0) . 'B';
                    }
                    $count[$s] = $n_format;
                }

                // Share vars
                if( !empty($entry['img_url']) ){
                    $shareImage = urlencode($entry['img_url']);
                }elseif( is_numeric($thumbID = get_post_thumbnail_id($id)) ){
                    $shareImage = urlencode(wp_get_attachment_url( $thumbID ));
                }else{
                    $shareImage = "";
                }
                // Set the title
                if( !empty($entry['entryTitle']) ){
                    $shareTitle = urlencode($entry['entryTitle']);
                }else{
                    $shareTitle = urlencode(get_the_title($id));
                }
                // Share summary message
                if(isset($meta['settings']['sharedesc']) & !empty($meta['settings']['sharedesc'])){
                    $shareSummary = urlencode($meta['settings']['sharedesc']);
                }else{
                    $shareSummary = "";
                }

            ?>

                <div class="meta-act">
                    <div class="meta-share">
                        <a href="#" class="share-button"><span class="share-icons social-share-icon-share"></span>Share</a>
                    </div>
                    <div class="share-links">
                        <div class="group">         
                            <?php if(isset($meta['settings']['sstwitter'])): ?>
                            <?php
                                $twitterShareJS = "http://twitter.com/intent/tweet?url={$entryURLencoded}&text={$shareTitle}";
                            ?>
                            <a href="javascript:void(0)" onclick="window.open('<?php echo $twitterShareJS; ?>','Tweet','toolbar=0,status=0,width=600,height=275')" alt="Tweet" class="share-button-twitter meta-share-wrap">
                                <span class="share-icons social-share-icon-twitter" aria-hidden="true"></span><span class="social-count"><?php echo $count['twitter']; ?></span>
                            </a>
                            <?php endif; ?>
                            <?php if(isset($meta['settings']['ssfacebook'])): ?>
                            <?php 
                                $fbShareJS = "http://www.facebook.com/sharer.php?s=100&amp;";
                                $fbShareJS .= "p[title]={$shareTitle}&amp;";
                                $fbShareJS .= "p[summary]={$shareSummary}&amp;";
                                $fbShareJS .= "p[url]={$entryURLencoded}&amp;";
                                $fbShareJS .= "p[images][0]={$shareImage}";
                            ?>
                            <a href="javascript:void(0)" onclick="window.open('<?php echo $fbShareJS; ?>','sharer','toolbar=0,status=0,resizable=1,width=626,height=436')" alt="Share on Facebook" class="share-button-fb meta-share-wrap">
                                <span class="share-icons social-share-icon-facebook"></span><span class="social-count"><?php echo $count['facebook']; ?></span>
                            </a>
                            <?php endif; ?>
                            <?php if(isset($meta['settings']['ssgoogleplus'])): ?>
                            <?php
                                $gplusShareJS = "https://plus.google.com/share?url={$entryURLencoded}";
                            ?>
                            <a href="javascript:void(0)" onclick="window.open('<?php echo $gplusShareJS; ?>','Plus One',menubar=0,toolbar=0,resizable=1,scrollbars=1,'width=700,height=500')"  alt="Share on Google+" class="share-button-gp meta-share-wrap">
                                <span class="share-icons social-share-icon-google-plus"></span><span class="social-count"><?php echo $count['googleplus']; ?></span>
                            </a>
                            <?php endif; ?>
                            <?php if(isset($meta['settings']['sspinterest'])): ?>
                            <?php
                                $pinShareJS = "http://pinterest.com/pin/create/button/?url={$entryURLencoded}&media={$shareImage}";
                            ?>
                            <a href="javascript:void(0)" onclick="window.open('<?php echo $pinShareJS; ?>','Pinterest',toolbar=0,'width=630,height=270')" alt="Pin it" class="share-button-pin meta-share-wrap">
                                <span class="share-icons social-share-icon-pinterest"></span><span class="social-count"><?php echo $count['pinterest']; ?></span>
                            </a>
                            <?php endif; ?>
                            <?php if(isset($meta['settings']['ssshortenedlink'])): ?>
                            <div class="meta-link" style="float: left;">
                                <span class="share-icons social-share-icon-link"></span>
                                <input type="url" class="share-form-url" value="<?php echo $shortenedURL; ?>" readonly="">
                                <a class="meta-short-url meta-link-text" href="<?php echo $shortenedURL; ?>" ><?php echo $shortenedURL; ?></a>
                            </div>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            <?php endif; // end social share setting ?>

            <?php 
                // Parameters for the link
                $linkparams = 'class="myContest-votes-button ' . ($votingend ? "disabled" : "active ".$entry['entryID']) . '" ' .
                                ($votingend ? "disabled='disabled'" : "data-entry-id='".$entry['entryID']."' ");
            ?>

                <a href="#vote" <?php echo $linkparams; ?>>
                    <span class="myContest-count">
                        <?php 
                        if($meta['settings']['votenoshow']){
                            _e('Vote for this', 'mycontest');
                        }else{
                            echo $entry['votes'] . '&nbsp;' . __('votes','mycontest');
                        }
                        //style="display:none;"
                        ?>
                    </span>
                    <!-- <img src="<?php echo $this->pluginUrl . '/inc/images/159.gif'; ?>" class="myContestloading"/> -->
                </a>
            <?php } // end else ?>

                <div id="caption<?php echo $entry['entryID'] ?>" style="display:none;">
                    <?php if ( !isset($meta['settings']['regvoteonly']) & is_user_logged_in() ): ?>
                    <a href="#vote" class="myContest-votes-button <?php echo ($votingend ? "disabled" : "active") . " " . $entry['entryID']; ?>" 
                        <?php echo ($votingend ? "disabled='disabled'" : ""); ?> 
                        data-entry-id="<?php echo $entry['entryID']; ?>">
                        <span class="myContest-count">
                            <?php if($meta['settings']['votenoshow']){
                            _e('Vote for this', 'mycontest');
                        }else{
                            echo $entry['votes'] . '&nbsp;' . __('votes','mycontest');
                        }
                        ?>
                        </span>
                        <img src="<?php echo $this->pluginUrl . '/inc/images/loading.gif'; ?>" class="myContestloading" style="display:none;"/>
                    </a>
                    <?php endif; ?>
                </div>
            </div>          
        <?php
        endforeach;
        ?>

        </div> <!--end .myContest-entries-->
        <?php
        return;
    } // end get_content function
jrfnl commented 11 years ago

The problem is that your functions are sending output to the screen while they should return the information.

Read this page in the Codex and take special note of the following taken from that page:

A filter function takes as input the unmodified data, and returns modified data (or in some cases, a null value to indicate the data should be deleted or disregarded). If the data is not modified by your filter, then the original data must be returned so that subsequent plugins can continue to modify the value if necessary.

A filter should never ever send anything to the screen. An action may.

Is this the problem how I do the HTML outside the php tags? The get_content function looks like this:

So, yes, the way you do HTML outside the php tags is effectively sending data to the screen and is the wrong way to do it.

highergroundstudio commented 11 years ago

Duh (hit head)! I totally did this wrong and knew this. Thank you sooooo much for the help! I guess I have a lot of changing to do to make the output go to a var. Thanks again! Let me know if you want a free version of my contest for your trouble.

jrfnl commented 11 years ago

You're welcome! And no freebies needed, I'm just glad there will be one (a little) less buggy plugin on the market... Feel free to credit me for helping you fix this though. I am for hire ;-)

highergroundstudio commented 11 years ago

Will do. Thanks again.

raamdev commented 10 years ago

@jrfnl Thank you for taking the time to explain @highergroundstudio's issue. I was debugging some old and really bad code (embarrassingly my own) and this saved me some time!

jrfnl commented 10 years ago

@raamdev You're welcome. Always nice to hear info like this is still found & found useful ;-)