Plugin Directory

Changeset 1840367


Ignore:
Timestamp:
03/14/2018 10:58:03 PM (8 years ago)
Author:
cswaim
Message:

add filter process

Location:
tpg-get-posts/trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • tpg-get-posts/trunk/inc/class-tpg-get-posts.php

    r771200 r1840367  
    3434            "freeze"=>false,
    3535            "active-in-backend"=>false,
    36             "updt-sec"=>360,
     36            "updt-sec"=>99999999,
    3737            );
    3838
  • tpg-get-posts/trunk/inc/class-tpg-gp-factory.php

    r1081975 r1840367  
    2727     */
    2828    public static function create_process($_opts,$_paths) {
    29        
     29
     30        require_once("class-tpg-gp-process.php");
    3031        if ($_opts['valid-lic'] && file_exists($_paths['dir']."ext/class-tpg-gp-process-ext.php")){
    31         //if (file_exists($_paths['dir']."inc/class-tpg-gp-process-ext.php")){
    32             require_once("class-tpg-gp-process.php");
    3332            require_once($_paths['ext']."class-tpg-gp-process-ext.php");
    3433            $obj = new tpg_gp_process_ext($_opts,$_paths);
    3534        }else {
    36             require_once("class-tpg-gp-process.php");
    3735            $obj = new tpg_gp_process($_opts,$_paths);
    3836        }
     
    7472     */
    7573    public static function create_lic_validation($_opts,$_paths,$module_data) {
    76         require_once("class-tpg-lic-validation.php");
     74        if (!class_exists("tpg_lic_validation")) {
     75            require_once("class-tpg-lic-validation.php");
     76        }
    7777        $obj = new tpg_lic_validation($_opts,$_paths,$module_data);
    7878        return $obj;
  • tpg-get-posts/trunk/inc/class-tpg-gp-process.php

    r1359321 r1840367  
    3838          'show_fi_error'    => 'false',
    3939          'more_link_text'   => '(read more...)',
     40          'filter_title'     => '',
     41          'filter_byline'    => '',
     42          'filter_content'   => '',
     43          'filter_metadata'  => '',
     44          'filter_thumbnail' => '',
    4045          'fields'           => 'title, byline, content, metadata',
    4146          'field_classes'    => '',
     
    271276
    272277    /**
     278     * register filters
     279     *
     280     * @package WordPress
     281     * @subpackage tpg_get_posts
     282     * @since 3.5
     283     *
     284     * if a filter function name has been passed in the parameters
     285     * then register the filter for the shortcode
     286     *
     287     * all filters have 2 parms: string & post obj
     288     *
     289     * @param    void
     290     * @return   void
     291     *
     292     */
     293    public function register_filters() {
     294        // register title filter
     295        if ($this->r['filter_title'] != '') {
     296            add_filter ( 'tgp_filter_title', $this->r['filter_title'], 15, 2 );
     297        }
     298
     299        // register byine filter
     300        if ($this->r['filter_byline'] != '') {
     301            add_filter ( 'tgp_filter_byline', $this->r['filter_byline'], 15, 2 );
     302        }
     303
     304        // register content filter
     305        if ($this->r['filter_content'] != '') {
     306            add_filter ( 'tgp_filter_content', $this->r['filter_content'], 15, 2 );
     307        }
     308
     309        // register metadata filter
     310        if ($this->r['filter_metadata'] != '') {
     311            add_filter ( 'tgp_filter_metadata', $this->r['filter_metadata'], 15, 2 );
     312        }
     313
     314        // register thumbnail filter
     315        if ($this->r['filter_thumbnail'] != '') {
     316            add_filter ( 'tgp_filter_thumbnail', $this->r['filter_thumbnail'], 15, 2 );
     317        }
     318    }
     319
     320    /**
     321     * remove filters
     322     *
     323     * @package WordPress
     324     * @subpackage tpg_get_posts
     325     * @since 3.5
     326     *
     327     * if a filter function name has been passed in the parameters
     328     * then remove the filter when shortcode terminates
     329     *
     330     * all filters have 2 parms: string & post obj
     331     *
     332     * @param    void
     333     * @return   void
     334     *
     335     */
     336    public function remove_filters() {
     337        // register title filter
     338        if ($this->r['filter_title'] != '') {
     339            remove_filter ( 'tgp_filter_title', $this->r['filter_title'], 15 );
     340        }
     341
     342        // register byine filter
     343        if ($this->r['filter_byline'] != '') {
     344            remove_filter ( 'tgp_filter_byline', $this->r['filter_byline'], 15 );
     345        }
     346
     347        // register content filter
     348        if ($this->r['filter_content'] != '') {
     349            remove_filter ( 'tgp_filter_content', $this->r['filter_content'], 15 );
     350        }
     351
     352        // register metadata filter
     353        if ($this->r['filter_metadata'] != '') {
     354            remove_filter ( 'tgp_filter_metadata', $this->r['filter_metadata'], 15 );
     355        }
     356
     357        // register thumbnail filter
     358        if ($this->r['filter_thumbnail'] != '') {
     359            remove_filter ( 'tgp_filter_thumbnail', $this->r['filter_thumbnail'], 15 );
     360        }
     361    }
     362
     363    /**
    273364     * get the posts
    274365     *
     
    342433            }
    343434        }
     435
     436        // register filter functions if set
     437        $this->register_filters();
    344438
    345439        //setup parms for query
     
    443537       
    444538        $post = $tmp_post;            //restore current page/post settings
     539        $this->remove_filters();      //remove the shortcode filters
    445540        return $content;
    446541           
     
    463558                case "title":
    464559                    $wkcontent = $this->fmt_post_title($post);
    465                     $wkcontent = $this->filter_post_title($wkcontent);
     560                    $wkcontent = $this->filter_post_title($wkcontent,$post);
    466561                    break;
    467562                case "byline":
    468563                    $wkcontent = $this->fmt_post_byline($post);
    469                     $wkcontent = $this->filter_post_byline($wkcontent);
     564                    $wkcontent = $this->filter_post_byline($wkcontent,$post);
    470565                    break;
    471566                case "content":
     
    476571                    }
    477572                    //wrap content in div tag
    478                     $wkcontent = $this->filter_post_content($wkcontent);
     573                    $wkcontent = $this->filter_post_content($wkcontent,$post);
    479574                    break;
    480575                case "metadata":
    481576                    $wkcontent = $this->fmt_post_metadata($post);
    482                     $wkcontent = $this->filter_post_metadata($wkcontent);   
     577                    $wkcontent = $this->filter_post_metadata($wkcontent,$post);
    483578                    break;
    484579            }
     
    555650            }
    556651        }
     652        $t_content = apply_filters('tgp_filter_thumbnail',$t_content,$post);
    557653        return $t_content; 
    558654    }
     
    693789     * @return  string  $wkcontent
    694790     */
    695     function filter_post_title($wkcontent) {
     791    function filter_post_title($wkcontent,$post) {
    696792        //apply custom filter
    697793        if (method_exists($this,'pst_title_filter') && $this->cf_t ) {
    698794            $wkcontent = $this->pst_title_filter($wkcontent,$this->cfp);
    699         }   
     795        }
     796        $wkcontent = apply_filters('tgp_filter_title',$wkcontent,$post);
    700797        return $wkcontent;
    701798    }
     
    710807     * @return  string  $wkcontent
    711808     */
    712     function filter_post_byline($wkcontent) {
     809    function filter_post_byline($wkcontent,$post) {
    713810        //apply custom filter
    714811        if (method_exists($this,'pst_byline_filter') && $this->cf_b ) {
    715812            $wkcontent = $this->pst_byline_filter($wkcontent,$this->cfp);
    716         }   
     813        }
     814        $wkcontent = apply_filters('tgp_filter_byline',$wkcontent,$post);
    717815        return $wkcontent;
    718816    }
     
    727825     * @return  string  $wkcontent
    728826     */
    729     function filter_post_content($wkcontent) {
     827    function filter_post_content($wkcontent,$post) {
    730828        if (strlen($wkcontent) > 0) {                   
    731829            $wkcontent = '<div class="'.$this->classes_arr['post_content'].'">'.$wkcontent.'</div>';
     
    737835        if (method_exists($this,'pst_content_filter') && $this->cf_c ) {
    738836            $wkcontent = $this->pst_content_filter($wkcontent,$this->cfp);
    739         }
     837        }
     838        $wkcontent = apply_filters('tgp_filter_content',$wkcontent,$post);
    740839        return $wkcontent;
    741840    }
     
    749848     * @return  string  $wkcontent
    750849     */
    751     function filter_post_metadata($wkcontent) {
     850    function filter_post_metadata($wkcontent,$post) {
    752851        //apply custom filter
    753852        if (method_exists($this,'pst_metadata_filter') && $this->cf_m ) {
    754853            $wkcontent = $this->pst_metadata_filter($wkcontent,$this->cfp);
    755         }   
     854        }
     855        $wkcontent = apply_filters('tgp_filter_metadata',$wkcontent,$post);
    756856        return $wkcontent;
    757857    }
  • tpg-get-posts/trunk/inc/doc-text.php

    r1590381 r1840367  
    1111            <li><a href="#gp-options"><? _e('Options','tpg-get-posts')?></a></li>
    1212            <li><a href="#gp-styling"><? _e('Styling','tpg-get-posts')?></a></li>
     13            <li><a href="#gp-filters"><? _e('Filters','tpg-get-posts')?></a></li>
    1314            <li><a href="#gp-examples"><? _e('Examples','tpg-get-posts')?></a></li>
    1415            <li><a href="#gp-settings"><? _e('Settings','tpg-get-posts')?></a></li>
     
    174175            <dt>ul-class</dt><dd><? _e('This is the class assigned to the bullet list. When this class is provided, the output is returned as an unordered list.','tpg-get-posts')?></dd>
    175176
    176             <dt class="tpg-prem">cf</dt><dd><? _e("Invoke the user Custom Functions by passing the codes for each exit to be invoked, ie cf='ppre,ppst,pre,pst,t,b,c,m'. The model function php file is provided in the /ext files folder and instructions are in the comments.",'tpg-get-posts')?>
    177             ppre => <? _e('before the invoking of the plugin','tpg-get-posts')?>
    178             ppst => <? _e('upon completion of plugin, just before returning results','tpg-get-posts')?>
    179             pre  => <? _e('before each post','tpg-get-posts')?>
    180             pst  => <? _e('after each post','tpg-get-posts')?>
    181             t,b,c,m => <? _e('after title,byline,content,metadata -- this allows final editing
    182             ','tpg-get-posts')?></dd>
    183             <dt class="tpg-prem">cfp</dt><dd><? _e('Custom functions parameters.  This is an optional string that is passed to the custom functions routine.  It must be parsed by the custom function and is defined by the user.','tpg-get-posts')?></dd>
     177            <p><? _e('To exclude posts, see examples.','tpg-get-posts')?></p>
     178
     179            <div class="deprecated" style="background:yellow;">
     180                <h4 ><? _e('Deprecated - use filters','tpg-get-posts')?></h4>
     181                <dt class="tpg-prem">cf</dt><dd><? _e("Invoke the user Custom Functions by passing the codes for each exit to be invoked, ie cf='ppre,ppst,pre,pst,t,b,c,m'. The model function php file is provided in the /ext files folder and instructions are in the comments.",'tpg-get-posts')?>
     182                ppre => <? _e('before the invoking of the plugin','tpg-get-posts')?>
     183                ppst => <? _e('upon completion of plugin, just before returning results','tpg-get-posts')?>
     184                pre  => <? _e('before each post','tpg-get-posts')?>
     185                pst  => <? _e('after each post','tpg-get-posts')?>
     186                t,b,c,m => <? _e('after title,byline,content,metadata -- this allows final editing
     187                ','tpg-get-posts')?></dd>
     188                <dt class="tpg-prem">cfp</dt><dd><? _e('Custom functions parameters.  This is an optional string that is passed to the custom functions routine.  It must be parsed by the custom function and is defined by the user.','tpg-get-posts')?></dd>
     189            </div>
     190
    184191        </dl>
    185192
    186         <p><? _e('To exclude posts, see examples.','tpg-get-posts')?></p>
    187193
    188194    </div>
     
    241247
    242248    </div>
    243     <div id="gp-examples">
     249    <div id="gp-filters">
     250        <h3><?php _e('Filters:','tpg-get-posts')?></h3>
     251        <p><?php _e('The filter process allows for the filters to be implemented in 2 ways:','tpg-get-posts') ?></p>
     252        <p><ol><?php _e('
     253                <li>Globally as a standard filter</li>
     254                <li>Individual call in tpg_get_posts</li>
     255            </ol>','tpg-get-posts') ?></p>
     256        <p><?php _e('The global filter is given a priority value of 10 and the call through the short-code is given a priority value of 15.  This allows the short-code call to override the global call, it that it is called after the global call.','tpg-get-posts') ?></p>
     257        <h4><?php _e('Example code','tpg-get-posts') ?></h4>
     258        <p><?php _e('Create a custom function.  This can be placed in the theme functions file or it can be put in a file named <br /><b>"user-get-posts-custom-functions"</b> which is placed in the root of the theme.','tpg-get-posts') ?></p>
     259        <p><pre><code>function my_custom_title_filter( $title, $post) {
     260        $title = "Custom Title Filter Works";
     261        return $title;
     262    }</code></pre></p>
     263        <p>To set the function to process on all titles (global title filter) use the following code and add below the function definition: <br /><code>'add_filter( "tgp_filter_title", "my_custom_title_filter", 10, 2 );</code></p>
     264        <p>To run the filter for a specific call of tpg_get_posts add the filter parameter to the short-code: <br /><code>&#91;tpg_get_posts filter_title="my_custom_title_filter"&#93;></code></p>
     265
     266        <p><?php _e('The available filters are:<br /> (replace &lt;function_name&gt; with your custom function name)','tpg-get-posts') ?></p>
     267        <ul>
     268            <dt class="tpg-prem">filter_title</dt><dd><?php _e('filter_title="&lt;function_name&gt;"','tpg-get-posts')?></dd>
     269            <dt class="tpg-prem">filter_byline</dt><dd><?php _e('filter_byline="&lt;function_name&gt;"','tpg-get-posts')?></dd>
     270            <dt class="tpg-prem">filter_content</dt><dd><?php _e('filter_content="&lt;function_name&gt;"','tpg-get-posts')?></dd>
     271            <dt class="tpg-prem">filter_metadata</dt><dd><?php _e('filter_metadata="&lt;function_name&gt;"','tpg-get-posts')?></dd>
     272            <dt class="tpg-prem">filter_thumbnail</dt><dd><?php _e('filter_thumbnail="&lt;function_name&gt;"','tpg-get-posts')?></dd>
     273        </ul>
     274    </div>
     275
     276    <div id="gp-examples">
    244277        <h3><? _e('Examples:','tpg-get-posts')?></h3>
    245278
     
    301334        <li><? _e('Select the Keep Options on uninstall checkbox','tpg-get-posts')?></li>
    302335        <li><? _e('Click the Update Options to save the options','tpg-get-posts')?></li>
    303         <li><? _e('Click the Validate Lic to register and receive new update notices','tpg-get-posts')?></li>
    304         <br />
    305         </ol>
    306         <ol><? _e('To manually load the extension:','tpg-get-posts')?>
    307         <li><? _e('Click the download link in the email','tpg-get-posts')?></li>
    308         <li><? _e('FTP the contents of the /ext folder to your site','tpg-get-posts')?></li>
    309         <li><? _e('Activate by following instructions above ','tpg-get-posts')?></li>
    310         </ol>
    311 
    312 
    313     </div>
     336        <li><? _e('Click the Validate Lic to register.  You should see a message "The license opts have been validated - thank you." below the License email box.  If not, verify you have the correct key & email.','tpg-get-posts')?></li>
     337        <p><?php _e('That should be it.','tpg-get-posts')?></p>
     338
     339
     340    </div>
    314341  </div>
    315342</div>
  • tpg-get-posts/trunk/readme.txt

    r1835772 r1840367  
    55Requires at least: 2.8
    66Tested up to: 4.9
    7 Stable tag: 3.4.3
     7Stable tag: 3.5.1
    88License: GPLv2 or later
    99
     
    133133
    134134== Changelog ==
     135= 3.5.1 +
     136* add filter processing for title, byline, content, metadata & image
     137* change download procedure for premium version
     138
    135139= 3.4.3 =
    136140* updated documentation
  • tpg-get-posts/trunk/tpg-get-posts.php

    r1590381 r1840367  
    44Plugin URI: http://www.tpginc.net/wordpress-plugins/
    55Description: Adds a shortcode tag to display posts on static page.
    6 Version: 3.4.3
     6Version: 3.5.1
    77Author: Criss Swaim
    88Author URI: http://www.tpginc.net/
Note: See TracChangeset for help on using the changeset viewer.