From fac0bccfd9da8bebaa40f17534d18aca31c5d1e3 Mon Sep 17 00:00:00 2001 From: joelworsham Date: Sat, 28 Feb 2015 00:51:58 -0500 Subject: [PATCH] Allow args in post_list template. Build --- README.md | 2 +- build/core/functions.php | 4 +--- build/core/modal.php | 16 ++++++++++++++-- build/core/shortcodes/core/query.php | 2 ++ src/core/functions.php | 5 +---- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a077acc..87f4b97 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Simply download the master zip (the button on the right that says "Download ZIP" * UPDATE: Force require at least PHP 5.3. * DEVELOPERS: Improve shortcode attribute template functionality, especially the post list template. -### [1.0.2](https://github.com/brashrebel/render/releases/tag/v1.0.2) +### [1.1-beta-2](https://github.com/brashrebel/render/releases/tag/v1.0.2) * FIX: Content in shortcodes disappearing when adding one shortcode into the entire content of another. * FIX: Potential PHP notice of defining a licensing constant. * UPDATE: Improved TinyMCE shortcode tooltip usability. diff --git a/build/core/functions.php b/build/core/functions.php index 4f346b5..e8486ae 100644 --- a/build/core/functions.php +++ b/build/core/functions.php @@ -463,8 +463,6 @@ function render_sc_attr_template( $template, $extra = array(), $args = array() ) case 'link': - // FIXME Allow args to be passed through to render_sc_post_list which allows choosing what's used as the value and name in the options list - $output = array( 'label' => __( 'Link', 'Render' ), 'description' => __( 'Links to a post / page.', 'Render' ), @@ -472,9 +470,9 @@ function render_sc_attr_template( $template, $extra = array(), $args = array() ) 'properties' => array( 'placeholder' => __( 'Select a post / page, or type a link', 'Render' ), 'allowCustomInput' => true, - 'groups' => array(), 'callback' => array( 'function' => 'render_sc_post_list', + 'args' => $args, ), ), ); diff --git a/build/core/modal.php b/build/core/modal.php index 8ce5f4b..4fde8b9 100644 --- a/build/core/modal.php +++ b/build/core/modal.php @@ -535,8 +535,20 @@ private static function att_type_selectbox( $att_id, $att, $properties = array() if ( ! empty( $options ) ) { - // We need to merge our arrays, but we need to do it with either groups or options (whichever is in use) - $which = ! empty( $properties['groups'] ) ? 'groups' : 'options'; + // Figure out if groups or not + $which = 'options'; + foreach ( $options as $option_value ) { + if ( is_array( $option_value ) ) { + $which = 'groups'; + break; + } + } + + // Icons are different + if ( $properties['allowIcons'] ) { + $which = 'options'; + } + if ( ! empty( $properties[ $which ] ) ) { $properties[ $which ] = array_merge( $options, $properties[ $which ] ); } else { diff --git a/build/core/shortcodes/core/query.php b/build/core/shortcodes/core/query.php index c4326df..78d1629 100644 --- a/build/core/shortcodes/core/query.php +++ b/build/core/shortcodes/core/query.php @@ -84,6 +84,7 @@ 'label' => __( 'Include', 'Render' ), 'properties' => array( 'multi' => true, + 'placeholder' => 'Select an option', ), 'conditional' => array( 'populate' => array( @@ -98,6 +99,7 @@ 'label' => __( 'Exclude', 'Render' ), 'properties' => array( 'multi' => true, + 'placeholder' => 'Select an option', ), 'conditional' => array( 'populate' => array( diff --git a/src/core/functions.php b/src/core/functions.php index bc70ee8..e8486ae 100644 --- a/src/core/functions.php +++ b/src/core/functions.php @@ -463,8 +463,6 @@ function render_sc_attr_template( $template, $extra = array(), $args = array() ) case 'link': - // FIXME Allow args to be passed through to render_sc_post_list which allows choosing what's used as the value and name in the options list - $output = array( 'label' => __( 'Link', 'Render' ), 'description' => __( 'Links to a post / page.', 'Render' ), @@ -472,10 +470,9 @@ function render_sc_attr_template( $template, $extra = array(), $args = array() ) 'properties' => array( 'placeholder' => __( 'Select a post / page, or type a link', 'Render' ), 'allowCustomInput' => true, - 'groups' => array(), 'callback' => array( - 'groups' => true, 'function' => 'render_sc_post_list', + 'args' => $args, ), ), );