| @@ -23,13 +23,9 @@ | ||
| 23 | 23 | if ( $text !== '' ) { |
| 24 | 24 | $atts = shortcode_parse_atts( $text ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( ! is_array( $atts ) ) { | |
| 28 | - $atts = array(); | |
| 29 | - } | |
| 30 | - | |
| 31 | - return $atts; | |
| 27 | + return is_array( $atts ) ? $atts : array(); | |
| 32 | 28 | } |
| 33 | 29 | |
| 34 | 30 | /** |
| 35 | 31 | * Returns shortcodes that are shown/hidden based on the context. |
| @@ -72,12 +68,11 @@ | ||
| 72 | 68 | * |
| 73 | 69 | * @return array |
| 74 | 70 | */ |
| 75 | 71 | public static function get_contextual_codes() { |
| 76 | - $contextual_shortcodes = self::get_contextual_shortcodes(); | |
| 77 | - $result = array(); | |
| 72 | + $result = array(); | |
| 78 | 73 | |
| 79 | - foreach ( $contextual_shortcodes as $type => $shortcodes ) { | |
| 74 | + foreach ( self::get_contextual_shortcodes() as $type => $shortcodes ) { | |
| 80 | 75 | $result[ $type ] = array_keys( $shortcodes ); |
| 81 | 76 | } |
| 82 | 77 | |
| 83 | 78 | return $result; |
| @@ -119,22 +114,18 @@ | ||
| 119 | 114 | } |
| 120 | 115 | |
| 121 | 116 | $with_tags = $args['conditional_check'] ? 3 : 2; |
| 122 | 117 | |
| 123 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { | |
| 124 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); | |
| 125 | - $tag = str_replace( ']', '', $tag ); | |
| 126 | - $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag ); | |
| 127 | - $tags = preg_split( '/\s+/', $tag, 2 ); | |
| 118 | + if ( empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { | |
| 119 | + return $shortcodes[ $with_tags - 1 ][ $short_key ]; | |
| 120 | + } | |
| 128 | 121 | |
| 129 | - if ( is_array( $tags ) ) { | |
| 130 | - $tag = $tags[0]; | |
| 131 | - } | |
| 132 | - } else { | |
| 133 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; | |
| 134 | - } | |
| 122 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); | |
| 123 | + $tag = str_replace( ']', '', $tag ); | |
| 124 | + $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag ); | |
| 125 | + $tags = preg_split( '/\s+/', $tag, 2 ); | |
| 135 | 126 | |
| 136 | - return $tag; | |
| 127 | + return is_array( $tags ) ? $tags[0] : $tag; | |
| 137 | 128 | } |
| 138 | 129 | |
| 139 | 130 | /** |
| 140 | 131 | * @param bool $no_vars |