Plugin Directory

Changeset 1152503


Ignore:
Timestamp:
05/03/2015 11:30:07 PM (11 years ago)
Author:
webdeveric
Message:

tagging version 0.3.1

Location:
get-post-content-shortcode
Files:
2 added
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • get-post-content-shortcode/tags/0.3.1/get-post-content-shortcode.php

    r1152267 r1152503  
    55Plugin URI: http://phplug.in/
    66Description: This plugin provides a shortcode to get the content of a post based on ID number.
    7 Version: 0.3.0
     7Version: 0.3.1
    88Author: Eric King
    99Author URI: http://webdeveric.com/
    1010*/
    1111
    12 if ( ! function_exists('is_yes')):
    13     function is_yes($arg)
     12if ( ! function_exists('is_yes') ):
     13
     14    function is_yes( $arg )
    1415    {
    15         if (is_string($arg))
    16             $arg = strtolower($arg);
    17         return in_array($arg, array(true, 'true', 'yes', 'y', '1', 1), true);
     16        if ( is_string($arg ) ) {
     17            $arg = strtolower( $arg );
     18        }
     19        return in_array( $arg, array( true, 'true', 'yes', 'y', '1', 1 ), true );
    1820    }
     21
    1922endif;
    2023
    21 function wde_get_post_content_shortcode($atts, $shortcode_content = null, $code = '')
     24if ( ! function_exists('split_comma') ):
     25
     26    function split_comma( $csv )
     27    {
     28        return array_map( 'trim', explode( ',', $csv ) );
     29    }
     30
     31endif;
     32
     33function wde_get_post_content_shortcode( $atts, $shortcode_content = null, $code = '' )
    2234{
    2335    global $post;
     
    2739            'id'        => 0,
    2840            'autop'     => true,
    29             'shortcode' => true
     41            'shortcode' => true,
     42            'status'    => 'publish'
    3043        ),
    3144        $atts
     
    3346
    3447    $atts['id']        = (int)$atts['id'];
    35     $atts['autop']     = is_yes($atts['autop']);
    36     $atts['shortcode'] = is_yes($atts['shortcode']);
     48    $atts['autop']     = is_yes( $atts['autop'] );
     49    $atts['shortcode'] = is_yes( $atts['shortcode'] );
     50    $atts['status']    = split_comma( $atts['status'] );
    3751
    38     if ( isset($post, $post->ID) && $post->ID != $atts['id'] ) {
     52    if ( isset( $post, $post->ID ) && $post->ID != $atts['id'] && in_array( get_post_status( $atts['id'] ), $atts['status'] ) ) {
    3953
    4054        $original_post = $post;
     
    4862            $content = $post->post_content;
    4963
    50             if ($atts['shortcode'])
     64            if ($atts['shortcode']) {
    5165                $content = do_shortcode($content);
     66            }
    5267
    53             if ($atts['autop'])
     68            if ($atts['autop']) {
    5469                $content = wpautop($content);
     70            }
    5571
    5672        }
  • get-post-content-shortcode/tags/0.3.1/readme.txt

    r1152267 r1152503  
    44Requires at least: 3.0.0
    55Tested up to: 4.2.0
    6 Stable tag: 0.3.0
     6Stable tag: 0.3.1
    77
    88This plugin provides a shortcode to get the content of a post based on ID number.
     
    2727This gets the content of post 42 and does not call wpautop or do_shortcode on the content.
    2828
     29`[post-content id="42" status="publish,future"]`
     30This gets the content of post 42 only if the post_status is "publish" or "future".
     31If you omit the status, it will default to "publish".
     32
     33The possible statuses are: publish, pending, draft, auto-draft, future, private, inherit, trash
     34
    2935**Note:**
    3036The containing post may still have wpautop called on it's content.
     
    3844== Changelog ==
    3945
    40 = 0.3 =
     46= 0.3.1 =
     47* By default, this shortcode will only get content of published posts, unless you specify the status attribute.
     48
     49= 0.3.0 =
    4150* I updated the code to temporarily switch to the other post so that shortcodes in the other post will work as expected.
    4251
    43 = 0.2 =
     52= 0.2.0 =
    4453* I updated the code to use the `get_post_field` function instead of `get_post`.
    4554
    46 = 0.1 =
     55= 0.1.0 =
    4756* Initial build
  • get-post-content-shortcode/trunk/get-post-content-shortcode.php

    r1152267 r1152503  
    55Plugin URI: http://phplug.in/
    66Description: This plugin provides a shortcode to get the content of a post based on ID number.
    7 Version: 0.3.0
     7Version: 0.3.1
    88Author: Eric King
    99Author URI: http://webdeveric.com/
    1010*/
    1111
    12 if ( ! function_exists('is_yes')):
    13     function is_yes($arg)
     12if ( ! function_exists('is_yes') ):
     13
     14    function is_yes( $arg )
    1415    {
    15         if (is_string($arg))
    16             $arg = strtolower($arg);
    17         return in_array($arg, array(true, 'true', 'yes', 'y', '1', 1), true);
     16        if ( is_string($arg ) ) {
     17            $arg = strtolower( $arg );
     18        }
     19        return in_array( $arg, array( true, 'true', 'yes', 'y', '1', 1 ), true );
    1820    }
     21
    1922endif;
    2023
    21 function wde_get_post_content_shortcode($atts, $shortcode_content = null, $code = '')
     24if ( ! function_exists('split_comma') ):
     25
     26    function split_comma( $csv )
     27    {
     28        return array_map( 'trim', explode( ',', $csv ) );
     29    }
     30
     31endif;
     32
     33function wde_get_post_content_shortcode( $atts, $shortcode_content = null, $code = '' )
    2234{
    2335    global $post;
     
    2739            'id'        => 0,
    2840            'autop'     => true,
    29             'shortcode' => true
     41            'shortcode' => true,
     42            'status'    => 'publish'
    3043        ),
    3144        $atts
     
    3346
    3447    $atts['id']        = (int)$atts['id'];
    35     $atts['autop']     = is_yes($atts['autop']);
    36     $atts['shortcode'] = is_yes($atts['shortcode']);
     48    $atts['autop']     = is_yes( $atts['autop'] );
     49    $atts['shortcode'] = is_yes( $atts['shortcode'] );
     50    $atts['status']    = split_comma( $atts['status'] );
    3751
    38     if ( isset($post, $post->ID) && $post->ID != $atts['id'] ) {
     52    if ( isset( $post, $post->ID ) && $post->ID != $atts['id'] && in_array( get_post_status( $atts['id'] ), $atts['status'] ) ) {
    3953
    4054        $original_post = $post;
     
    4862            $content = $post->post_content;
    4963
    50             if ($atts['shortcode'])
     64            if ($atts['shortcode']) {
    5165                $content = do_shortcode($content);
     66            }
    5267
    53             if ($atts['autop'])
     68            if ($atts['autop']) {
    5469                $content = wpautop($content);
     70            }
    5571
    5672        }
  • get-post-content-shortcode/trunk/readme.txt

    r1152267 r1152503  
    44Requires at least: 3.0.0
    55Tested up to: 4.2.0
    6 Stable tag: 0.3.0
     6Stable tag: 0.3.1
    77
    88This plugin provides a shortcode to get the content of a post based on ID number.
     
    2727This gets the content of post 42 and does not call wpautop or do_shortcode on the content.
    2828
     29`[post-content id="42" status="publish,future"]`
     30This gets the content of post 42 only if the post_status is "publish" or "future".
     31If you omit the status, it will default to "publish".
     32
     33The possible statuses are: publish, pending, draft, auto-draft, future, private, inherit, trash
     34
    2935**Note:**
    3036The containing post may still have wpautop called on it's content.
     
    3844== Changelog ==
    3945
    40 = 0.3 =
     46= 0.3.1 =
     47* By default, this shortcode will only get content of published posts, unless you specify the status attribute.
     48
     49= 0.3.0 =
    4150* I updated the code to temporarily switch to the other post so that shortcodes in the other post will work as expected.
    4251
    43 = 0.2 =
     52= 0.2.0 =
    4453* I updated the code to use the `get_post_field` function instead of `get_post`.
    4554
    46 = 0.1 =
     55= 0.1.0 =
    4756* Initial build
Note: See TracChangeset for help on using the changeset viewer.