| @@ -18,15 +18,14 @@ | ||
| 18 | 18 | * @return array |
| 19 | 19 | */ |
| 20 | 20 | public static function get_shortcode_attribute_array( $text ) { |
| 21 | 21 | $atts = array(); |
| 22 | - | |
| 23 | 22 | if ( $text !== '' ) { |
| 24 | 23 | $atts = shortcode_parse_atts( $text ); |
| 25 | 24 | } |
| 26 | 25 | |
| 27 | 26 | if ( ! is_array( $atts ) ) { |
| 28 | - return array(); | |
| 27 | + $atts = array(); | |
| 29 | 28 | } |
| 30 | 29 | |
| 31 | 30 | return $atts; |
| 32 | 31 | } |
| @@ -34,9 +33,8 @@ | ||
| 34 | 33 | /** |
| 35 | 34 | * Returns shortcodes that are shown/hidden based on the context. |
| 36 | 35 | * |
| 37 | 36 | * @since 6.16.3 |
| 38 | - * | |
| 39 | 37 | * @return array |
| 40 | 38 | */ |
| 41 | 39 | public static function get_contextual_shortcodes() { |
| 42 | 40 | return array( |
| @@ -74,13 +72,11 @@ | ||
| 74 | 72 | */ |
| 75 | 73 | public static function get_contextual_codes() { |
| 76 | 74 | $contextual_shortcodes = self::get_contextual_shortcodes(); |
| 77 | 75 | $result = array(); |
| 78 | - | |
| 79 | 76 | foreach ( $contextual_shortcodes as $type => $shortcodes ) { |
| 80 | 77 | $result[ $type ] = array_keys( $shortcodes ); |
| 81 | 78 | } |
| 82 | - | |
| 83 | 79 | return $result; |
| 84 | 80 | } |
| 85 | 81 | |
| 86 | 82 | /** |
| @@ -102,15 +98,13 @@ | ||
| 102 | 98 | 'conditional_check' => false, |
| 103 | 99 | 'foreach' => false, |
| 104 | 100 | ) |
| 105 | 101 | ); |
| 106 | - | |
| 107 | 102 | if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
| 108 | 103 | $args['conditional_check'] = true; |
| 109 | 104 | } |
| 110 | 105 | |
| 111 | 106 | $prefix = ''; |
| 112 | - | |
| 113 | 107 | if ( $args['conditional_check'] ) { |
| 114 | 108 | if ( $args['conditional'] ) { |
| 115 | 109 | $prefix = 'if '; |
| 116 | 110 | } elseif ( $args['foreach'] ) { |
| @@ -118,29 +112,23 @@ | ||
| 118 | 112 | } |
| 119 | 113 | } |
| 120 | 114 | |
| 121 | 115 | $with_tags = $args['conditional_check'] ? 3 : 2; |
| 122 | - | |
| 123 | - if ( empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { | |
| 124 | - return $shortcodes[ $with_tags - 1 ][ $short_key ]; | |
| 116 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { | |
| 117 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); | |
| 118 | + $tag = str_replace( ']', '', $tag ); | |
| 119 | + $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag ); | |
| 120 | + $tags = preg_split( '/\s+/', $tag, 2 ); | |
| 121 | + if ( is_array( $tags ) ) { | |
| 122 | + $tag = $tags[0]; | |
| 123 | + } | |
| 124 | + } else { | |
| 125 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; | |
| 125 | 126 | } |
| 126 | 127 | |
| 127 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); | |
| 128 | - $tag = str_replace( ']', '', $tag ); | |
| 129 | - $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag ); | |
| 130 | - $tags = preg_split( '/\s+/', $tag, 2 ); | |
| 131 | - | |
| 132 | - return is_array( $tags ) ? $tags[0] : $tag; | |
| 128 | + return $tag; | |
| 133 | 129 | } |
| 134 | 130 | |
| 135 | - /** | |
| 136 | - * @param bool $no_vars | |
| 137 | - * @param string $code | |
| 138 | - * @param string $replace_with | |
| 139 | - * @param string $html | |
| 140 | - * | |
| 141 | - * @return void | |
| 142 | - */ | |
| 143 | 131 | public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
| 144 | 132 | if ( $no_vars ) { |
| 145 | 133 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 146 | 134 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |