Changeset 1152503
- Timestamp:
- 05/03/2015 11:30:07 PM (11 years ago)
- Location:
- get-post-content-shortcode
- Files:
-
- 2 added
- 4 edited
- 1 copied
-
tags/0.3.1 (copied) (copied from get-post-content-shortcode/trunk)
-
tags/0.3.1/.editorconfig (added)
-
tags/0.3.1/get-post-content-shortcode.php (modified) (4 diffs)
-
tags/0.3.1/readme.txt (modified) (3 diffs)
-
trunk/.editorconfig (added)
-
trunk/get-post-content-shortcode.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
get-post-content-shortcode/tags/0.3.1/get-post-content-shortcode.php
r1152267 r1152503 5 5 Plugin URI: http://phplug.in/ 6 6 Description: This plugin provides a shortcode to get the content of a post based on ID number. 7 Version: 0.3. 07 Version: 0.3.1 8 8 Author: Eric King 9 9 Author URI: http://webdeveric.com/ 10 10 */ 11 11 12 if ( ! function_exists('is_yes')): 13 function is_yes($arg) 12 if ( ! function_exists('is_yes') ): 13 14 function is_yes( $arg ) 14 15 { 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 ); 18 20 } 21 19 22 endif; 20 23 21 function wde_get_post_content_shortcode($atts, $shortcode_content = null, $code = '') 24 if ( ! function_exists('split_comma') ): 25 26 function split_comma( $csv ) 27 { 28 return array_map( 'trim', explode( ',', $csv ) ); 29 } 30 31 endif; 32 33 function wde_get_post_content_shortcode( $atts, $shortcode_content = null, $code = '' ) 22 34 { 23 35 global $post; … … 27 39 'id' => 0, 28 40 'autop' => true, 29 'shortcode' => true 41 'shortcode' => true, 42 'status' => 'publish' 30 43 ), 31 44 $atts … … 33 46 34 47 $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'] ); 37 51 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'] ) ) { 39 53 40 54 $original_post = $post; … … 48 62 $content = $post->post_content; 49 63 50 if ($atts['shortcode']) 64 if ($atts['shortcode']) { 51 65 $content = do_shortcode($content); 66 } 52 67 53 if ($atts['autop']) 68 if ($atts['autop']) { 54 69 $content = wpautop($content); 70 } 55 71 56 72 } -
get-post-content-shortcode/tags/0.3.1/readme.txt
r1152267 r1152503 4 4 Requires at least: 3.0.0 5 5 Tested up to: 4.2.0 6 Stable tag: 0.3. 06 Stable tag: 0.3.1 7 7 8 8 This plugin provides a shortcode to get the content of a post based on ID number. … … 27 27 This gets the content of post 42 and does not call wpautop or do_shortcode on the content. 28 28 29 `[post-content id="42" status="publish,future"]` 30 This gets the content of post 42 only if the post_status is "publish" or "future". 31 If you omit the status, it will default to "publish". 32 33 The possible statuses are: publish, pending, draft, auto-draft, future, private, inherit, trash 34 29 35 **Note:** 30 36 The containing post may still have wpautop called on it's content. … … 38 44 == Changelog == 39 45 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 = 41 50 * I updated the code to temporarily switch to the other post so that shortcodes in the other post will work as expected. 42 51 43 = 0.2 =52 = 0.2.0 = 44 53 * I updated the code to use the `get_post_field` function instead of `get_post`. 45 54 46 = 0.1 =55 = 0.1.0 = 47 56 * Initial build -
get-post-content-shortcode/trunk/get-post-content-shortcode.php
r1152267 r1152503 5 5 Plugin URI: http://phplug.in/ 6 6 Description: This plugin provides a shortcode to get the content of a post based on ID number. 7 Version: 0.3. 07 Version: 0.3.1 8 8 Author: Eric King 9 9 Author URI: http://webdeveric.com/ 10 10 */ 11 11 12 if ( ! function_exists('is_yes')): 13 function is_yes($arg) 12 if ( ! function_exists('is_yes') ): 13 14 function is_yes( $arg ) 14 15 { 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 ); 18 20 } 21 19 22 endif; 20 23 21 function wde_get_post_content_shortcode($atts, $shortcode_content = null, $code = '') 24 if ( ! function_exists('split_comma') ): 25 26 function split_comma( $csv ) 27 { 28 return array_map( 'trim', explode( ',', $csv ) ); 29 } 30 31 endif; 32 33 function wde_get_post_content_shortcode( $atts, $shortcode_content = null, $code = '' ) 22 34 { 23 35 global $post; … … 27 39 'id' => 0, 28 40 'autop' => true, 29 'shortcode' => true 41 'shortcode' => true, 42 'status' => 'publish' 30 43 ), 31 44 $atts … … 33 46 34 47 $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'] ); 37 51 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'] ) ) { 39 53 40 54 $original_post = $post; … … 48 62 $content = $post->post_content; 49 63 50 if ($atts['shortcode']) 64 if ($atts['shortcode']) { 51 65 $content = do_shortcode($content); 66 } 52 67 53 if ($atts['autop']) 68 if ($atts['autop']) { 54 69 $content = wpautop($content); 70 } 55 71 56 72 } -
get-post-content-shortcode/trunk/readme.txt
r1152267 r1152503 4 4 Requires at least: 3.0.0 5 5 Tested up to: 4.2.0 6 Stable tag: 0.3. 06 Stable tag: 0.3.1 7 7 8 8 This plugin provides a shortcode to get the content of a post based on ID number. … … 27 27 This gets the content of post 42 and does not call wpautop or do_shortcode on the content. 28 28 29 `[post-content id="42" status="publish,future"]` 30 This gets the content of post 42 only if the post_status is "publish" or "future". 31 If you omit the status, it will default to "publish". 32 33 The possible statuses are: publish, pending, draft, auto-draft, future, private, inherit, trash 34 29 35 **Note:** 30 36 The containing post may still have wpautop called on it's content. … … 38 44 == Changelog == 39 45 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 = 41 50 * I updated the code to temporarily switch to the other post so that shortcodes in the other post will work as expected. 42 51 43 = 0.2 =52 = 0.2.0 = 44 53 * I updated the code to use the `get_post_field` function instead of `get_post`. 45 54 46 = 0.1 =55 = 0.1.0 = 47 56 * Initial build
Note: See TracChangeset
for help on using the changeset viewer.