From 89171aaef5ce06f23fc8df294b7dee8eff7d767f Mon Sep 17 00:00:00 2001 From: Geoffrey de Vlugt Date: Thu, 8 Oct 2015 00:14:57 +0200 Subject: [PATCH 1/2] Adds 'display only child posts' to shortcodes. --- .../shortcodes/my_mini_posts_grid.js | 9 +++++ .../shortcodes/my_mini_posts_list.js | 9 +++++ admin/shortcodes/shortcodes/my_posts_grid.js | 9 +++++ admin/shortcodes/shortcodes/my_posts_list.js | 9 +++++ includes/shortcodes/mini-posts-grid.php | 25 ++++++++----- includes/shortcodes/mini-posts-list.php | 25 ++++++++----- includes/shortcodes/posts-grid.php | 37 +++++++++++-------- includes/shortcodes/posts-list.php | 31 +++++++++------- 8 files changed, 105 insertions(+), 49 deletions(-) diff --git a/admin/shortcodes/shortcodes/my_mini_posts_grid.js b/admin/shortcodes/shortcodes/my_mini_posts_grid.js index 14364a1..0ce3f6d 100644 --- a/admin/shortcodes/shortcodes/my_mini_posts_grid.js +++ b/admin/shortcodes/shortcodes/my_mini_posts_grid.js @@ -71,6 +71,15 @@ frameworkShortcodeAtts={ defaultText: 'left', help:"Alignment of grid - left, right, or center." }, + { + label:"Display only child posts", + id:"only_child_posts", + controlType:"select-control", + selectValues:['yes', 'no'], + defaultValue: 'no', + defaultText: 'no', + help:"Display only child posts of the current post." + }, { label:"Custom class", id:"custom_class", diff --git a/admin/shortcodes/shortcodes/my_mini_posts_list.js b/admin/shortcodes/shortcodes/my_mini_posts_list.js index 8f75c14..e7610ee 100644 --- a/admin/shortcodes/shortcodes/my_mini_posts_list.js +++ b/admin/shortcodes/shortcodes/my_mini_posts_list.js @@ -61,6 +61,15 @@ frameworkShortcodeAtts={ id:"excerpt_count", help:"How many words are displayed in the excerpt?" }, + { + label:"Display only child posts", + id:"only_child_posts", + controlType:"select-control", + selectValues:['yes', 'no'], + defaultValue: 'no', + defaultText: 'no', + help:"Display only child posts of the current post." + }, { label:"Custom class", id:"custom_class", diff --git a/admin/shortcodes/shortcodes/my_posts_grid.js b/admin/shortcodes/shortcodes/my_posts_grid.js index 5c5bb9f..4a4017f 100644 --- a/admin/shortcodes/shortcodes/my_posts_grid.js +++ b/admin/shortcodes/shortcodes/my_posts_grid.js @@ -89,6 +89,15 @@ frameworkShortcodeAtts={ id:"tag", help:"Enter tags for posts filtering. Leave blank to pull all tags" }, + { + label:"Display only child posts", + id:"only_child_posts", + controlType:"select-control", + selectValues:['yes', 'no'], + defaultValue: 'no', + defaultText: 'no', + help:"Display only child posts of the current post." + }, { label:"Custom class", id:"custom_class", diff --git a/admin/shortcodes/shortcodes/my_posts_list.js b/admin/shortcodes/shortcodes/my_posts_list.js index 933beec..d9c8248 100644 --- a/admin/shortcodes/shortcodes/my_posts_list.js +++ b/admin/shortcodes/shortcodes/my_posts_list.js @@ -75,6 +75,15 @@ frameworkShortcodeAtts={ id:"tag", help:"Enter tags for posts filtering. Leave blank to pull all tags" }, + { + label:"Display only child posts", + id:"only_child_posts", + controlType:"select-control", + selectValues:['yes', 'no'], + defaultValue: 'no', + defaultText: 'no', + help:"Display only child posts of the current post." + }, { label:"Tags", id:"tags", diff --git a/includes/shortcodes/mini-posts-grid.php b/includes/shortcodes/mini-posts-grid.php index 2c5d3ae..ce9d5f7 100644 --- a/includes/shortcodes/mini-posts-grid.php +++ b/includes/shortcodes/mini-posts-grid.php @@ -6,18 +6,19 @@ if (!function_exists('mini_posts_grid_shortcode')) { function mini_posts_grid_shortcode( $atts, $content = null, $shortcodename = '' ) { extract(shortcode_atts(array( - 'type' => 'post', + 'type' => 'post', 'category' => '', 'custom_category' => '', - 'numb' => '8', - 'thumbs' => '', - 'thumb_width' => '', - 'thumb_height' => '', - 'lightbox' => 'yes', - 'order_by' => 'date', - 'order' => 'DESC', - 'align' => '', - 'custom_class' => '' + 'numb' => '8', + 'thumbs' => '', + 'thumb_width' => '', + 'thumb_height' => '', + 'lightbox' => 'yes', + 'order_by' => 'date', + 'order' => 'DESC', + 'align' => '', + 'custom_class' => '', + 'only_child_posts' => '' ), $atts)); $template_url = get_stylesheet_directory_uri(); @@ -88,6 +89,10 @@ function mini_posts_grid_shortcode( $atts, $content = null, $shortcodename = '' 'suppress_filters' => $suppress_filters ); + if ($only_child_posts == 'yes') { + $args['post_parent'] = $post->ID; + } + $posts = get_posts($args); $i = 0; diff --git a/includes/shortcodes/mini-posts-list.php b/includes/shortcodes/mini-posts-list.php index f5426d0..dd0ad21 100644 --- a/includes/shortcodes/mini-posts-list.php +++ b/includes/shortcodes/mini-posts-list.php @@ -7,16 +7,17 @@ function mini_posts_list_shortcode( $atts, $content = null, $shortcodename = '' ) { extract(shortcode_atts(array( - 'type' => 'post', - 'numb' => '3', - 'thumbs' => '', - 'thumb_width' => '', - 'thumb_height' => '', - 'meta' => '', - 'order_by' => '', - 'order' => '', - 'excerpt_count' => '0', - 'custom_class' => '' + 'type' => 'post', + 'numb' => '3', + 'thumbs' => '', + 'thumb_width' => '', + 'thumb_height' => '', + 'meta' => '', + 'order_by' => '', + 'order' => '', + 'excerpt_count' => '0', + 'custom_class' => '', + 'only_child_posts' => '' ), $atts)); $template_url = get_template_directory_uri(); @@ -85,6 +86,10 @@ function mini_posts_list_shortcode( $atts, $content = null, $shortcodename = '' 'suppress_filters' => $suppress_filters ); + if ($only_child_posts == 'yes') { + $args['post_parent'] = $post->ID; + } + $posts = get_posts($args); $i = 0; diff --git a/includes/shortcodes/posts-grid.php b/includes/shortcodes/posts-grid.php index 0d846c8..dce53c2 100644 --- a/includes/shortcodes/posts-grid.php +++ b/includes/shortcodes/posts-grid.php @@ -7,22 +7,23 @@ function posts_grid_shortcode( $atts, $content = null, $shortcodename = '' ) { extract(shortcode_atts(array( - 'type' => 'post', - 'category' => '', - 'custom_category' => '', - 'tag' => '', - 'columns' => '3', - 'rows' => '3', - 'order_by' => 'date', - 'order' => 'DESC', - 'thumb_width' => '370', - 'thumb_height' => '250', - 'lightbox' => 'yes', - 'meta' => '', - 'excerpt_count' => '15', - 'link' => 'yes', - 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), - 'custom_class' => '' + 'type' => 'post', + 'category' => '', + 'custom_category' => '', + 'tag' => '', + 'columns' => '3', + 'rows' => '3', + 'order_by' => 'date', + 'order' => 'DESC', + 'thumb_width' => '370', + 'thumb_height' => '250', + 'lightbox' => 'yes', + 'meta' => '', + 'excerpt_count' => '15', + 'link' => 'yes', + 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), + 'custom_class' => '', + 'only_child_posts' => '' ), $atts)); $spans = $columns; @@ -102,6 +103,10 @@ function posts_grid_shortcode( $atts, $content = null, $shortcodename = '' ) { 'suppress_filters' => $suppress_filters ); + if ($only_child_posts == 'yes') { + $args['post_parent'] = $post->ID; + } + $posts = get_posts( $args ); if ( empty( $posts ) ) { diff --git a/includes/shortcodes/posts-list.php b/includes/shortcodes/posts-list.php index 5e3ac18..5eab158 100644 --- a/includes/shortcodes/posts-list.php +++ b/includes/shortcodes/posts-list.php @@ -7,19 +7,20 @@ function posts_list_shortcode( $atts, $content = null, $shortcodename = '' ) { extract(shortcode_atts(array( - 'type' => 'post', - 'thumbs' => '', - 'thumb_width' => '', - 'thumb_height' => '', - 'post_content' => '', - 'numb' => '5', - 'order_by' => '', - 'order' => '', - 'link' => '', - 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), - 'tag' => '', - 'tags' => '', - 'custom_class' => '' + 'type' => 'post', + 'thumbs' => '', + 'thumb_width' => '', + 'thumb_height' => '', + 'post_content' => '', + 'numb' => '5', + 'order_by' => '', + 'order' => '', + 'link' => '', + 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), + 'tag' => '', + 'tags' => '', + 'custom_class' => '', + 'only_child_posts' => '', ), $atts)); // check what order by method user selected @@ -64,6 +65,10 @@ function posts_list_shortcode( $atts, $content = null, $shortcodename = '' ) { 'suppress_filters' => $suppress_filters ); + if ($only_child_posts == 'yes') { + $args['post_parent'] = $post->ID; + } + $posts = get_posts($args); $i = 0; From 02d3ff5837d3e649b38570c8ce5a320d4cf5a1ef Mon Sep 17 00:00:00 2001 From: Geoffrey de Vlugt Date: Thu, 8 Oct 2015 00:19:12 +0200 Subject: [PATCH 2/2] Fixes layout in my_posts_list.js --- admin/shortcodes/shortcodes/my_posts_list.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/admin/shortcodes/shortcodes/my_posts_list.js b/admin/shortcodes/shortcodes/my_posts_list.js index d9c8248..3aed25d 100644 --- a/admin/shortcodes/shortcodes/my_posts_list.js +++ b/admin/shortcodes/shortcodes/my_posts_list.js @@ -75,15 +75,15 @@ frameworkShortcodeAtts={ id:"tag", help:"Enter tags for posts filtering. Leave blank to pull all tags" }, - { - label:"Display only child posts", - id:"only_child_posts", - controlType:"select-control", - selectValues:['yes', 'no'], - defaultValue: 'no', - defaultText: 'no', - help:"Display only child posts of the current post." - }, + { + label:"Display only child posts", + id:"only_child_posts", + controlType:"select-control", + selectValues:['yes', 'no'], + defaultValue: 'no', + defaultText: 'no', + help:"Display only child posts of the current post." + }, { label:"Tags", id:"tags", @@ -102,4 +102,4 @@ frameworkShortcodeAtts={ defaultContent:"", shortcode:"posts_list", shortcodeType: "text-replace" -}; \ No newline at end of file +};