Plugin Directory

Changeset 1339644


Ignore:
Timestamp:
01/30/2016 01:41:15 PM (9 years ago)
Author:
andrewsauder
Message:

1.0.12

  • prevent featured image of a blog post with a database id=1 from displaying on Local Geo Search dynamically generated pages
Location:
local-geo-search/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • local-geo-search/trunk/classes/class.virtualpage.php

    r1312446 r1339644  
    8585            //add_action('template_redirect', array(&$this, 'template_redir'));
    8686            add_filter('the_posts', array(&$this, 'vtp_createdummypost'));
     87
     88            //remove post thumbnail (only shows up when there is a post with an id=1 that also has a featured image)
     89            add_filter('get_post_metadata', array(&$this,'remove_post_thumbnail'), true, 4);
    8790
    8891            // we also force comments removal; a comments box at the footer of
     
    114117        }
    115118
     119        function remove_post_thumbnail($metadata, $object_id, $meta_key, $single) {
     120
     121            //Return false if the current filter is that of a post thumbnail. Otherwise, return the original $content value.
     122            return ( isset($meta_key) && '_thumbnail_id' === $meta_key && $object_id==1 ) ? false : $metadata;
     123
     124        }
     125
    116126        // Setup a dummy post/page
    117127        // From the WP view, a post == a page
     
    128138            global $wp, $wp_query;
    129139
     140            //limit the virtual page to only show one post
    130141            $wp_query->posts_per_page = 1;
    131 
    132             //unset($wp_query->query['attachment']);
    133 
    134142
    135143            //create a fake post intance
    136144            $p = new stdClass;
     145
    137146            // fill $p with everything a page in the database would have
    138147            $p->ID = -1;
     
    169178            $wp_query->is_archive = FALSE;
    170179            $wp_query->is_category = FALSE;
     180            $wp_query->is_attachment = false;
     181
     182            //stop page from throwing 404 error
    171183            unset($wp_query->query['error']);
    172184            $wp->query = array();
     
    174186            $wp_query->is_404 = FALSE;
    175187
     188            //manage comment options
     189            $wp_query->comment_count = 0;
     190            // -1 for current_comment displays comment if not logged in!
     191            $wp_query->current_comment = null;
     192
     193            //tell wordpress a post exists
    176194            $wp_query->current_post = $p->ID;
    177195            $wp_query->found_posts = 1;
    178196            $wp_query->post_count = 1;
    179             $wp_query->comment_count = 0;
    180             // -1 for current_comment displays comment if not logged in!
    181             $wp_query->current_comment = null;
    182 
    183             //as
    184             $wp_query->is_attachment = false;
    185197
    186198            $wp_query->post = $p;
     
    189201            $wp_query->queried_object_id = $p->ID;
    190202            $wp_query->current_post = $p->ID;
    191             $wp_query->post_count = 1;
    192203
    193204            return array($p);
  • local-geo-search/trunk/readme.txt

    r1312446 r1339644  
    5050
    5151== Changelog ==
     52= 1.0.12 =
     53* prevent featured image of a blog post with a database id=1 from displaying on Local Geo Search dynamically generated pages
     54
    5255= 1.0.11 =
    5356* fixed plugin authentication when wordpress site url includes a path in addition to the domain
Note: See TracChangeset for help on using the changeset viewer.