@@ -18,7 +18,6 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Process and output the [gventry] shortcode. |
| 20 | 20 | * |
| 21 | - * @param array $passed_atts The attributes passed. |
|
| 22 | 21 | * @param string $content The content inside the shortcode. |
| 23 | 22 | * @param string $tag The shortcode tag. |
| 24 | 23 | * |
@@ -18,7 +18,6 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Process and output the [gvfield] shortcode. |
| 20 | 20 | * |
| 21 | - * @param array $passed_atts The attributes passed. |
|
| 22 | 21 | * @param string $content The content inside the shortcode. |
| 23 | 22 | * @param string $tag The shortcode tag. |
| 24 | 23 | * |
@@ -248,6 +248,8 @@ |
||
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * Process the attributes passed to the shortcode. Make sure they're valid |
| 251 | + * @param string $content |
|
| 252 | + * @param string $tag |
|
| 251 | 253 | * @return void |
| 252 | 254 | */ |
| 253 | 255 | private function parse_atts( $atts, $content, $tag ) { |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | $value = $this->get_value( $atts ); |
| 58 | 58 | |
| 59 | 59 | if ( false === $operator && is_null( $value ) ) { |
| 60 | - if ( false !== $atts['if'] ) { // Only-if test |
|
| 61 | - $match = $authed && ! in_array( strtolower( $atts['if'] ), array( '', '0', 'false', 'no' ) ); |
|
| 60 | + if ( false !== $atts[ 'if' ] ) { // Only-if test |
|
| 61 | + $match = $authed && ! in_array( strtolower( $atts[ 'if' ] ), array( '', '0', 'false', 'no' ) ); |
|
| 62 | 62 | } else { |
| 63 | 63 | $match = $authed; // Just login test |
| 64 | 64 | } |
| 65 | 65 | } else { // Regular test |
| 66 | - $match = $authed && \GVCommon::matches_operation( $atts['if'], $value, $operator ); |
|
| 66 | + $match = $authed && \GVCommon::matches_operation( $atts[ 'if' ], $value, $operator ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Output and get recursive! |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @return bool Yes, or no. |
| 82 | 82 | */ |
| 83 | 83 | private function authorized( $atts ) { |
| 84 | - if ( is_null( $needs_login = \GV\Utils::get( $atts, 'logged_in', null ) ) ) { |
|
| 84 | + if ( is_null( $needs_login = \GV\Utils::get( $atts, 'logged_in', null ) ) ) { |
|
| 85 | 85 | return true; // No auth requirements have been set |
| 86 | 86 | } |
| 87 | 87 | return ! $needs_login ^ is_user_logged_in(); // XNOR |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | * @return string The output. |
| 144 | 144 | */ |
| 145 | 145 | private function get_output( $match, $atts, $content ) { |
| 146 | - if ( ! $match && ! empty( $atts['else'] ) ) { |
|
| 147 | - return $atts['else']; // Attributized else is easy :) |
|
| 146 | + if ( ! $match && ! empty( $atts[ 'else' ] ) ) { |
|
| 147 | + return $atts[ 'else' ]; // Attributized else is easy :) |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $if = ''; |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | $atts = array_intersect_key( $supplied_atts, $atts ); |
| 268 | 268 | |
| 269 | 269 | // Strip whitespace if it's not default false |
| 270 | - if ( isset( $atts['if'] ) && is_string( $atts['if'] ) ) { |
|
| 271 | - $atts['if'] = trim( $atts['if'] ); |
|
| 270 | + if ( isset( $atts[ 'if' ] ) && is_string( $atts[ 'if' ] ) ) { |
|
| 271 | + $atts[ 'if' ] = trim( $atts[ 'if' ] ); |
|
| 272 | 272 | } else { |
| 273 | - $atts['if'] = false; |
|
| 273 | + $atts[ 'if' ] = false; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if ( isset( $atts['logged_in'] ) ) { |
|
| 276 | + if ( isset( $atts[ 'logged_in' ] ) ) { |
|
| 277 | 277 | // Truthy |
| 278 | - if ( in_array( strtolower( $atts['logged_in'] ), array( '0', 'false', 'no' ) ) ) { |
|
| 279 | - $atts['logged_in'] = false; |
|
| 278 | + if ( in_array( strtolower( $atts[ 'logged_in' ] ), array( '0', 'false', 'no' ) ) ) { |
|
| 279 | + $atts[ 'logged_in' ] = false; |
|
| 280 | 280 | } else { |
| 281 | - $atts['logged_in'] = true; |
|
| 281 | + $atts[ 'logged_in' ] = true; |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -57,12 +57,14 @@ discard block |
||
| 57 | 57 | $value = $this->get_value( $atts ); |
| 58 | 58 | |
| 59 | 59 | if ( false === $operator && is_null( $value ) ) { |
| 60 | - if ( false !== $atts['if'] ) { // Only-if test |
|
| 60 | + if ( false !== $atts['if'] ) { |
|
| 61 | +// Only-if test |
|
| 61 | 62 | $match = $authed && ! in_array( strtolower( $atts['if'] ), array( '', '0', 'false', 'no' ) ); |
| 62 | 63 | } else { |
| 63 | 64 | $match = $authed; // Just login test |
| 64 | 65 | } |
| 65 | - } else { // Regular test |
|
| 66 | + } else { |
|
| 67 | +// Regular test |
|
| 66 | 68 | $match = $authed && \GVCommon::matches_operation( $atts['if'], $value, $operator ); |
| 67 | 69 | } |
| 68 | 70 | |
@@ -153,11 +155,14 @@ discard block |
||
| 153 | 155 | $opens = 0; // inner opens |
| 154 | 156 | $found = false; // found split position |
| 155 | 157 | |
| 156 | - while ( $content ) { // scan |
|
| 158 | + while ( $content ) { |
|
| 159 | +// scan |
|
| 157 | 160 | if ( ! preg_match( '#(.*?)(\[\/?(gvlogic|else).*?])(.*)#', $content, $matches ) ) { |
| 158 | - if ( ! $found ) { // We're still iffing. |
|
| 161 | + if ( ! $found ) { |
|
| 162 | +// We're still iffing. |
|
| 159 | 163 | $if .= $content; |
| 160 | - } else { // We are elsing |
|
| 164 | + } else { |
|
| 165 | +// We are elsing |
|
| 161 | 166 | $else .= $content; |
| 162 | 167 | } |
| 163 | 168 | break; // No more shortcodes |
@@ -165,9 +170,11 @@ discard block |
||
| 165 | 170 | |
| 166 | 171 | list( $_, $before_shortcode, $shortcode, $_, $after_shortcode ) = $matches; |
| 167 | 172 | |
| 168 | - if ( ! $found ) { // We're still iffing. |
|
| 173 | + if ( ! $found ) { |
|
| 174 | +// We're still iffing. |
|
| 169 | 175 | $if .= $before_shortcode; |
| 170 | - } else { // We are elsing |
|
| 176 | + } else { |
|
| 177 | +// We are elsing |
|
| 171 | 178 | $else .= $before_shortcode; |
| 172 | 179 | } |
| 173 | 180 | |
@@ -191,9 +198,11 @@ discard block |
||
| 191 | 198 | } |
| 192 | 199 | |
| 193 | 200 | // Tack on the shortcode |
| 194 | - if ( ! $found ) { // We're still iffing. |
|
| 201 | + if ( ! $found ) { |
|
| 202 | +// We're still iffing. |
|
| 195 | 203 | $if .= $shortcode; |
| 196 | - } else { // We are elsing |
|
| 204 | + } else { |
|
| 205 | +// We are elsing |
|
| 197 | 206 | $else .= $shortcode; |
| 198 | 207 | } |
| 199 | 208 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | return self::$instance; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function shortcode( $atts, $content = '', $tag = '') { |
|
| 20 | + public function shortcode( $atts, $content = '', $tag = '' ) { |
|
| 21 | 21 | $shortcode = new \GV\Shortcodes\gvlogic(); |
| 22 | 22 | return $shortcode->callback( $atts, $content, $tag ); |
| 23 | 23 | } |