| @@ -67,9 +67,8 @@ | ||
| 67 | 67 | * @since 6.0 |
| 68 | 68 | * |
| 69 | 69 | * @param stdClass|WP_Post $style |
| 70 | 70 | * @param bool $hidden Used for pagination. |
| 71 | - * | |
| 72 | 71 | * @return void |
| 73 | 72 | */ |
| 74 | 73 | private function echo_style_card( $style, $hidden = false ) { |
| 75 | 74 | $params = $this->get_params_for_style_card( $style, $hidden ); |
| @@ -86,9 +85,8 @@ | ||
| 86 | 85 | * @since 6.0 |
| 87 | 86 | * |
| 88 | 87 | * @param stdClass|WP_Post $style |
| 89 | 88 | * @param bool $hidden |
| 90 | - * | |
| 91 | 89 | * @return array |
| 92 | 90 | */ |
| 93 | 91 | private function get_params_for_style_card( $style, $hidden = false ) { |
| 94 | 92 | if ( ! empty( $style->post_content['position'] ) ) { |
| @@ -109,17 +107,14 @@ | ||
| 109 | 107 | 'data-label-position' => $label_position, |
| 110 | 108 | ); |
| 111 | 109 | |
| 112 | 110 | $is_active_style = $style->ID === $this->active_style->ID; |
| 113 | - | |
| 114 | 111 | if ( $is_active_style ) { |
| 115 | 112 | $params['class'] .= ' frm-active-style-card frm-currently-set-style-card'; |
| 116 | 113 | } |
| 117 | - | |
| 118 | 114 | if ( $hidden ) { |
| 119 | 115 | $params['class'] .= ' frm_hidden'; |
| 120 | 116 | } |
| 121 | - | |
| 122 | 117 | if ( self::has_dark_background( $style ) ) { |
| 123 | 118 | $params['class'] .= ' frm-dark-style'; |
| 124 | 119 | } |
| 125 | 120 | |
| @@ -129,9 +124,8 @@ | ||
| 129 | 124 | * @since 6.0 |
| 130 | 125 | * |
| 131 | 126 | * @param array $params |
| 132 | 127 | * @param array $args { |
| 133 | - * | |
| 134 | 128 | * @type WP_Post $style |
| 135 | 129 | * } |
| 136 | 130 | */ |
| 137 | 131 | return apply_filters( 'frm_style_card_params', $params, compact( 'style' ) ); |
| @@ -138,9 +132,8 @@ | ||
| 138 | 132 | } |
| 139 | 133 | |
| 140 | 134 | /** |
| 141 | 135 | * @param stdClass|WP_Post $style |
| 142 | - * | |
| 143 | 136 | * @return bool |
| 144 | 137 | */ |
| 145 | 138 | private static function has_dark_background( $style ) { |
| 146 | 139 | $key = 'fieldset_bg_color'; |
| @@ -156,9 +149,8 @@ | ||
| 156 | 149 | |
| 157 | 150 | if ( isset( $matches[1][3] ) && is_numeric( $matches[1][3] ) ) { |
| 158 | 151 | // Consider a faded out rgba value as light even when the color is dark. |
| 159 | 152 | $color_opacity = floatval( $matches[1][3] ); |
| 160 | - | |
| 161 | 153 | if ( $color_opacity < 0.5 ) { |
| 162 | 154 | return false; |
| 163 | 155 | } |
| 164 | 156 | } |
| @@ -177,11 +169,9 @@ | ||
| 177 | 169 | * @type array $settings |
| 178 | 170 | * @type string $name |
| 179 | 171 | * @type string $slug |
| 180 | 172 | * } |
| 181 | - * | |
| 182 | 173 | * @param bool $hidden |
| 183 | - * | |
| 184 | 174 | * @return bool True if the template was valid and echoed. |
| 185 | 175 | */ |
| 186 | 176 | private function echo_card_template( $style, $hidden = false ) { |
| 187 | 177 | if ( empty( $style['settings'] ) || ! is_array( $style['settings'] ) ) { |
| @@ -205,12 +195,10 @@ | ||
| 205 | 195 | * Set up a locked style card for the upgrade modal. |
| 206 | 196 | * |
| 207 | 197 | * @param array $params |
| 208 | 198 | * @param array $args { |
| 209 | - * | |
| 210 | 199 | * @type stdClass|WP_Post $style |
| 211 | 200 | * } |
| 212 | - * | |
| 213 | 201 | * @param stdClass $style_object |
| 214 | 202 | * @param array $style |
| 215 | 203 | */ |
| 216 | 204 | $param_filter = function ( $params, $args ) use ( $style_object, $style ) { |
| @@ -234,9 +222,8 @@ | ||
| 234 | 222 | * Include the template key for the preview in Pro. |
| 235 | 223 | * |
| 236 | 224 | * @param array $params |
| 237 | 225 | * @param array $style |
| 238 | - * | |
| 239 | 226 | * @return array |
| 240 | 227 | */ |
| 241 | 228 | $param_filter = function ( $params ) use ( $style ) { |
| 242 | 229 | $params['data-template-key'] = $style['slug']; |
| @@ -260,9 +247,8 @@ | ||
| 260 | 247 | * @since 6.0 |
| 261 | 248 | * |
| 262 | 249 | * @param stdClass|WP_Post $style A new style (including duplicated styles) is not a WP_Post object. |
| 263 | 250 | * Template cards also use an stdClss instead of a WP_Post object. |
| 264 | - * | |
| 265 | 251 | * @return string |
| 266 | 252 | */ |
| 267 | 253 | public static function get_style_param_for_card( $style ) { |
| 268 | 254 | $styles = array(); |
| @@ -293,9 +279,8 @@ | ||
| 293 | 279 | |
| 294 | 280 | $value = $style->post_content[ $key ]; |
| 295 | 281 | |
| 296 | 282 | $is_hex = in_array( $key, $color_settings, true ) && $value && '#' !== $value[0] && false === strpos( $value, 'rgb' ) && $value !== 'transparent'; |
| 297 | - | |
| 298 | 283 | if ( $is_hex ) { |
| 299 | 284 | $value = '#' . $value; |
| 300 | 285 | } |
| 301 | 286 | |
| @@ -349,9 +334,8 @@ | ||
| 349 | 334 | 'id' => $id, |
| 350 | 335 | 'class' => 'frm-style-card-wrapper with_frm_style', |
| 351 | 336 | 'style' => $wrapper_style, |
| 352 | 337 | ); |
| 353 | - | |
| 354 | 338 | if ( $this->enabled ) { |
| 355 | 339 | $card_wrapper_params['class'] .= ' frm-styles-enabled'; |
| 356 | 340 | } |
| 357 | 341 | |
| @@ -398,9 +382,8 @@ | ||
| 398 | 382 | /** |
| 399 | 383 | * @since 6.0 |
| 400 | 384 | * |
| 401 | 385 | * @param array<array> $styles |
| 402 | - * | |
| 403 | 386 | * @return void |
| 404 | 387 | */ |
| 405 | 388 | private function echo_template_cards( $styles ) { |
| 406 | 389 | array_walk( |
| @@ -410,9 +393,8 @@ | ||
| 410 | 393 | * |
| 411 | 394 | * @param array|string $style |
| 412 | 395 | * @param string $key The key for the API data. It may be a numeric ID, or a key like "active_sub" or "expires". |
| 413 | 396 | * @param int $count Used for pagination. |
| 414 | - * | |
| 415 | 397 | * @return void |
| 416 | 398 | */ |
| 417 | 399 | function ( $style, $key ) { |
| 418 | 400 | if ( ! is_numeric( $key ) ) { |
| @@ -426,9 +408,8 @@ | ||
| 426 | 408 | } |
| 427 | 409 | |
| 428 | 410 | /** |
| 429 | 411 | * @param array<WP_Post> $styles |
| 430 | - * | |
| 431 | 412 | * @return void |
| 432 | 413 | */ |
| 433 | 414 | private function echo_custom_cards( $styles ) { |
| 434 | 415 | $count = 0; |
| @@ -439,9 +420,8 @@ | ||
| 439 | 420 | * Echo a style card for a single style in the $styles array. |
| 440 | 421 | * |
| 441 | 422 | * @param WP_Post $style |
| 442 | 423 | * @param int $count Used for pagination. |
| 443 | - * | |
| 444 | 424 | * @return void |
| 445 | 425 | */ |
| 446 | 426 | function ( $style ) use ( &$count ) { |
| 447 | 427 | $hidden = $count > self::PAGE_SIZE - 1; |
| @@ -456,9 +436,8 @@ | ||
| 456 | 436 | /** |
| 457 | 437 | * @since 6.0 |
| 458 | 438 | * |
| 459 | 439 | * @param int $count |
| 460 | - * | |
| 461 | 440 | * @return void |
| 462 | 441 | */ |
| 463 | 442 | private function maybe_echo_card_pagination( $count ) { |
| 464 | 443 | if ( $count <= self::PAGE_SIZE ) { |
| @@ -495,9 +474,8 @@ | ||
| 495 | 474 | /** |
| 496 | 475 | * Remove the default style from an array of styles. |
| 497 | 476 | * |
| 498 | 477 | * @param array $styles |
| 499 | - * | |
| 500 | 478 | * @return array |
| 501 | 479 | */ |
| 502 | 480 | public function filter_custom_styles( $styles ) { |
| 503 | 481 | return array_filter( |
| @@ -503,9 +481,8 @@ | ||
| 503 | 481 | return array_filter( |
| 504 | 482 | $styles, |
| 505 | 483 | /** |
| 506 | 484 | * @param WP_Post $style |
| 507 | - * | |
| 508 | 485 | * @return bool |
| 509 | 486 | */ |
| 510 | 487 | function ( $style ) { |
| 511 | 488 | return $this->default_style->ID !== $style->ID; |