Plugin Directory

Changeset 1738911


Ignore:
Timestamp:
09/30/2017 05:37:34 PM (9 years ago)
Author:
dineshc
Message:

Shortcode as argument support added for another shortcodes.

Location:
bkc-wp-shortcodes/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bkc-wp-shortcodes/trunk/bkc-wp-shortcodes.php

    r1738641 r1738911  
    33 * Plugin Name: Shortcodes
    44 * Description: This Plugin provides multiple wordpress core shortcodes.
    5  * Version: 1.0.1
     5 * Version: 1.0.2
    66 * Author: Dinesh Chouhan
    77 * Author URI: http://dineshchouhan.com
  • bkc-wp-shortcodes/trunk/classes/class-bkc-wp-shortcodes-loader.php

    r1738641 r1738911  
    5555        public function __construct() {
    5656
    57             define( 'BKC_WP_SHORTCODES_VER', '1.0.1' );
     57            define( 'BKC_WP_SHORTCODES_VER', '1.0.2' );
    5858            define( 'BKC_WP_SHORTCODES_FILE', trailingslashit( dirname( dirname( __FILE__ ) ) ) . 'bkc-wp-shortcodes.php' );
    5959            define( 'BKC_WP_SHORTCODES_BASE', plugin_basename( BKC_WP_SHORTCODES_FILE ) );
  • bkc-wp-shortcodes/trunk/classes/class-bkc-wp-shortcodes.php

    r1738641 r1738911  
    785785                            $func_args = [];
    786786                            foreach ( $args as $key => $value ) {
     787                                if ( 0 === strpos( $value, '{{' ) ) {
     788                                    $value = get_shortcode_from_attr( $value );
     789                                }
    787790                                array_push( $func_args , $value );
    788791                            }
     
    801804
    802805        /**
     806         * Gets the shortcode from attribute.
     807         *
     808         * @since 1.0.2
     809         * @param  string  $value  The value.
     810         * @return string
     811         */
     812        public function get_shortcode_from_attr( $value ) {
     813            $shortcode = str_replace( '}}', '', str_replace( '{{', '', $value ) );
     814            $shortcode = explode( ' ', $shortcode );
     815            $shortcode = $shortcode[0];
     816            if ( shortcode_exists( $shortcode ) ) {
     817                $actual_shortcode = str_replace( '}}', ']', str_replace( '{{', '[', $value ) );
     818                $value = do_shortcode( $actual_shortcode, true );
     819            }
     820            return $value;
     821        }
     822
     823        /**
    803824         * wp_get_option shortcode callback.
    804825         *
  • bkc-wp-shortcodes/trunk/readme.txt

    r1738641 r1738911  
    24244. [wp_get_the_thumbnail]
    2525Ex. [wp_get_the_thumbnail]
     26
     275. Use of shortcode as parameter of another shortcode.
     28Ex. [wp_get_the_post_thumbnail post={{wp_get_the_ID}} size="medium" ]
     29"wp_get_the_ID" is a shortcode to get current post id which is is passed to post parameter of "wp_get_the_post_thumbnail" shortcode. To pass shortcode as parameter value you need to use {{shortcode}} syntax instead of [shortcode].
    2630== Installation ==
    2731
     
    3842= 1.0.1 =
    3943* Shortcodes generator array updated.
     44
     45= 1.0.2 =
     46* Added support for shortcode as parameter of another shortcode.
Note: See TracChangeset for help on using the changeset viewer.