| @@ -3,19 +3,9 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmStyle { |
| 7 | - | |
| 8 | 7 | /** |
| 9 | - * The meta name of default template style. | |
| 10 | - * | |
| 11 | - * @since 6.14 | |
| 12 | - * | |
| 13 | - * @var string | |
| 14 | - */ | |
| 15 | - private $default_template_style_meta_name = 'frm_style_default'; | |
| 16 | - | |
| 17 | - /** | |
| 18 | 8 | * Unique ID number of the current instance. |
| 19 | 9 | * |
| 20 | 10 | * @var int |
| 21 | 11 | */ |
| @@ -28,9 +18,9 @@ | ||
| 28 | 18 | */ |
| 29 | 19 | public $id = 0; |
| 30 | 20 | |
| 31 | 21 | /** |
| 32 | - * @param int|string $id The id of the stylesheet or 'default'. | |
| 22 | + * @param int|string $id The id of the stylsheet or 'default'. | |
| 33 | 23 | */ |
| 34 | 24 | public function __construct( $id = 0 ) { |
| 35 | 25 | $this->id = $id; |
| 36 | 26 | } |
| @@ -43,9 +33,9 @@ | ||
| 43 | 33 | |
| 44 | 34 | $max_slug_value = 2147483647; |
| 45 | 35 | // We want to have at least 2 characters in the slug. |
| 46 | 36 | $min_slug_value = 37; |
| 47 | - $key = base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 37 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 48 | 38 | |
| 49 | 39 | $style = array( |
| 50 | 40 | 'post_type' => FrmStylesController::$post_type, |
| 51 | 41 | 'ID' => '', |
| @@ -60,9 +50,8 @@ | ||
| 60 | 50 | } |
| 61 | 51 | |
| 62 | 52 | /** |
| 63 | 53 | * @param array $settings |
| 64 | - * | |
| 65 | 54 | * @return int|WP_Error |
| 66 | 55 | */ |
| 67 | 56 | public function save( $settings ) { |
| 68 | 57 | return FrmDb::save_settings( $settings, 'frm_styles' ); |
| @@ -68,10 +57,8 @@ | ||
| 68 | 57 | return FrmDb::save_settings( $settings, 'frm_styles' ); |
| 69 | 58 | } |
| 70 | 59 | |
| 71 | 60 | /** |
| 72 | - * @param int|string $id The id of the stylesheet or 'default'. | |
| 73 | - * | |
| 74 | 61 | * @return void |
| 75 | 62 | */ |
| 76 | 63 | public function duplicate( $id ) { |
| 77 | 64 | // Duplicating is a pro feature. This is handled in FrmProStyle::duplicate instead. |
| @@ -80,27 +67,25 @@ | ||
| 80 | 67 | /** |
| 81 | 68 | * Handle save actions in the visual styler edit page. |
| 82 | 69 | * |
| 83 | 70 | * @param mixed $id |
| 84 | - * | |
| 85 | 71 | * @return array<int|WP_Error> |
| 86 | 72 | */ |
| 87 | 73 | public function update( $id = 'default' ) { |
| 88 | - $all_instances = $this->get_all(); | |
| 89 | - $css_scope_helper = new FrmCssScopeHelper(); | |
| 74 | + $all_instances = $this->get_all(); | |
| 90 | 75 | |
| 91 | 76 | if ( ! $id ) { |
| 92 | - $all_instances[] = (array) $this->get_new(); | |
| 77 | + $new_style = (array) $this->get_new(); | |
| 78 | + $all_instances[] = $new_style; | |
| 93 | 79 | } |
| 94 | 80 | |
| 95 | 81 | $action_ids = array(); |
| 96 | 82 | |
| 97 | - foreach ( $all_instances as $new_instance ) { | |
| 83 | + foreach ( $all_instances as $number => $new_instance ) { | |
| 98 | 84 | $new_instance = (array) $new_instance; |
| 99 | 85 | $this->id = $new_instance['ID']; |
| 100 | 86 | |
| 101 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing, Universal.Operators.StrictComparisons | |
| 102 | - if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { | |
| 87 | + if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 103 | 88 | // Don't continue if not saving this style. |
| 104 | 89 | continue; |
| 105 | 90 | } |
| 106 | 91 | |
| @@ -105,9 +90,9 @@ | ||
| 105 | 90 | } |
| 106 | 91 | |
| 107 | 92 | // Custom CSS is no longer used from the default style, but it is still checked if the Global Setting is missing. |
| 108 | 93 | // Preserve the previous value in case Custom CSS has not been saved as a Global Setting yet. |
| 109 | - $custom_css = $new_instance['post_content']['custom_css'] ?? ''; | |
| 94 | + $custom_css = isset( $new_instance['post_content']['custom_css'] ) ? $new_instance['post_content']['custom_css'] : ''; | |
| 110 | 95 | |
| 111 | 96 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 112 | 97 | if ( ! empty( $_POST['frm_style_setting']['post_title'] ) ) { |
| 113 | 98 | // The nonce check happens in FrmStylesController::save_style before this is called. |
| @@ -114,20 +99,15 @@ | ||
| 114 | 99 | // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 115 | 100 | $new_instance['post_title'] = sanitize_text_field( wp_unslash( $_POST['frm_style_setting']['post_title'] ) ); |
| 116 | 101 | } |
| 117 | 102 | |
| 118 | - $new_instance['post_content'] = isset( $_POST['frm_style_setting']['post_content'] ) ? $this->sanitize_post_content( wp_unslash( $_POST['frm_style_setting']['post_content'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 103 | + $new_instance['post_content'] = isset( $_POST['frm_style_setting']['post_content'] ) ? $this->sanitize_post_content( wp_unslash( $_POST['frm_style_setting']['post_content'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 119 | 104 | $new_instance['post_content']['custom_css'] = $custom_css; |
| 120 | 105 | unset( $custom_css ); |
| 121 | 106 | |
| 122 | - if ( ! empty( $new_instance['post_content']['single_style_custom_css'] ) ) { | |
| 123 | - $css_scope = 'frm_style_' . $new_instance['post_name']; | |
| 124 | - $new_instance['post_content']['single_style_custom_css'] = $css_scope_helper->nest( $new_instance['post_content']['single_style_custom_css'], $css_scope ); | |
| 125 | - } | |
| 107 | + $new_instance['post_type'] = FrmStylesController::$post_type; | |
| 108 | + $new_instance['post_status'] = 'publish'; | |
| 126 | 109 | |
| 127 | - $new_instance['post_type'] = FrmStylesController::$post_type; | |
| 128 | - $new_instance['post_status'] = 'publish'; | |
| 129 | - | |
| 130 | 110 | if ( ! $id ) { |
| 131 | 111 | $new_instance['post_name'] = $new_instance['post_title']; |
| 132 | 112 | } |
| 133 | 113 | |
| @@ -139,10 +119,9 @@ | ||
| 139 | 119 | } |
| 140 | 120 | |
| 141 | 121 | if ( $this->is_color( $setting ) ) { |
| 142 | 122 | $color_val = $new_instance['post_content'][ $setting ]; |
| 143 | - | |
| 144 | - if ( $color_val !== '' && str_contains( $color_val, 'rgb' ) ) { | |
| 123 | + if ( $color_val !== '' && false !== strpos( $color_val, 'rgb' ) ) { | |
| 145 | 124 | // Maybe sanitize if invalid rgba value is entered. |
| 146 | 125 | $this->maybe_sanitize_rgba_value( $color_val ); |
| 147 | 126 | } |
| 148 | 127 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $color_val ); |
| @@ -152,10 +131,9 @@ | ||
| 152 | 131 | $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
| 153 | 132 | } |
| 154 | 133 | } |
| 155 | 134 | |
| 156 | - $new_instance['post_content'] = FrmStylesHelper::update_base_font_size( $new_instance['post_content'], $this->get_defaults() ); | |
| 157 | - $action_ids[] = $this->save( $new_instance ); | |
| 135 | + $action_ids[] = $this->save( $new_instance ); | |
| 158 | 136 | }//end foreach |
| 159 | 137 | |
| 160 | 138 | $this->save_settings(); |
| 161 | 139 | |
| @@ -167,12 +145,11 @@ | ||
| 167 | 145 | * |
| 168 | 146 | * @since 5.3.2 |
| 169 | 147 | * |
| 170 | 148 | * @param string $color_val The color value, by reference. |
| 171 | - * | |
| 172 | 149 | * @return void |
| 173 | 150 | */ |
| 174 | - private function maybe_sanitize_rgba_value( &$color_val ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh | |
| 151 | + private function maybe_sanitize_rgba_value( &$color_val ) { | |
| 175 | 152 | if ( preg_match( '/(rgb|rgba)\(/', $color_val ) !== 1 ) { |
| 176 | 153 | return; |
| 177 | 154 | } |
| 178 | 155 | |
| @@ -179,9 +156,8 @@ | ||
| 179 | 156 | $color_val = trim( $color_val ); |
| 180 | 157 | // Remove leading braces so (rgba(1,1,1,1) doesn't cause inconsistent braces. |
| 181 | 158 | $color_val = ltrim( $color_val, '(' ); |
| 182 | 159 | $patterns = array( '/rgba\((\s*\d+\s*,){3}[[0-1]\.]+\)/', '/rgb\((\s*\d+\s*,){2}\s*[\d]+\)/' ); |
| 183 | - | |
| 184 | 160 | foreach ( $patterns as $pattern ) { |
| 185 | 161 | if ( preg_match( $pattern, $color_val ) === 1 ) { |
| 186 | 162 | return; |
| 187 | 163 | } |
| @@ -201,9 +177,9 @@ | ||
| 201 | 177 | foreach ( explode( ',', $color_rgba ) as $index => $value ) { |
| 202 | 178 | $new_value = null; |
| 203 | 179 | $value_is_empty_string = '' === trim( $value ) || '' === $value; |
| 204 | 180 | |
| 205 | - if ( 3 === $length_of_color_codes || $index !== $length_of_color_codes - 1 ) { | |
| 181 | + if ( 3 === $length_of_color_codes || ( $index !== $length_of_color_codes - 1 ) ) { | |
| 206 | 182 | // Insert a value for r, g, or b. |
| 207 | 183 | if ( $value < 0 ) { |
| 208 | 184 | $new_value = 0; |
| 209 | 185 | } elseif ( $value > 255 ) { |
| @@ -223,14 +199,13 @@ | ||
| 223 | 199 | $new_value = floatval( $value ); |
| 224 | 200 | } |
| 225 | 201 | }//end if |
| 226 | 202 | |
| 227 | - $new_color_values[] = $new_value; | |
| 203 | + $new_color_values[] = null === $new_value ? $value : $new_value; | |
| 228 | 204 | }//end foreach |
| 229 | 205 | |
| 230 | 206 | // add more 0s and 1 (if alpha position) if needed. |
| 231 | 207 | $missing_values = $length_of_color_codes - count( $new_color_values ); |
| 232 | - | |
| 233 | 208 | if ( $missing_values > 1 ) { |
| 234 | 209 | $insert_values = array_fill( 0, $missing_values - 1, 0 ); |
| 235 | 210 | $last_value = 4 === $length_of_color_codes ? 1 : 0; |
| 236 | 211 | array_push( $insert_values, $last_value ); |
| @@ -236,9 +211,8 @@ | ||
| 236 | 211 | array_push( $insert_values, $last_value ); |
| 237 | 212 | } elseif ( $missing_values === 1 ) { |
| 238 | 213 | $insert_values = 4 === $length_of_color_codes ? array( 1 ) : array( 0 ); |
| 239 | 214 | } |
| 240 | - | |
| 241 | 215 | if ( ! empty( $insert_values ) ) { |
| 242 | 216 | $new_color_values = array_merge( $new_color_values, $insert_values ); |
| 243 | 217 | } |
| 244 | 218 | |
| @@ -246,16 +220,31 @@ | ||
| 246 | 220 | $prefix = substr( $color_val, 0, strpos( $color_val, '(' ) + 1 ); |
| 247 | 221 | // Limit the number of opening braces after rgb/rgba. There should only be one. |
| 248 | 222 | $prefix = rtrim( $prefix, '(' ) . '('; |
| 249 | 223 | $new_color = $prefix . $new_color . ')'; |
| 224 | + | |
| 250 | 225 | $color_val = $new_color; |
| 251 | 226 | } |
| 252 | 227 | |
| 253 | 228 | /** |
| 229 | + * Unslash everything in post_content but custom_css | |
| 230 | + * | |
| 254 | 231 | * @since 5.0.13 |
| 255 | 232 | * |
| 256 | 233 | * @param array $settings |
| 234 | + * @return array | |
| 235 | + */ | |
| 236 | + private function unslash_post_content( $settings ) { | |
| 237 | + $custom_css = isset( $settings['custom_css'] ) ? $settings['custom_css'] : ''; | |
| 238 | + $settings = wp_unslash( $settings ); | |
| 239 | + $settings['custom_css'] = $custom_css; | |
| 240 | + return $settings; | |
| 241 | + } | |
| 242 | + | |
| 243 | + /** | |
| 244 | + * @since 5.0.13 | |
| 257 | 245 | * |
| 246 | + * @param array $settings | |
| 258 | 247 | * @return array |
| 259 | 248 | */ |
| 260 | 249 | public function sanitize_post_content( $settings ) { |
| 261 | 250 | $defaults = $this->get_defaults(); |
| @@ -260,17 +249,19 @@ | ||
| 260 | 249 | public function sanitize_post_content( $settings ) { |
| 261 | 250 | $defaults = $this->get_defaults(); |
| 262 | 251 | $valid_keys = array_keys( $defaults ); |
| 263 | 252 | $sanitized_settings = array(); |
| 264 | - | |
| 265 | 253 | foreach ( $valid_keys as $key ) { |
| 266 | - $sanitized_settings[ $key ] = isset( $settings[ $key ] ) ? sanitize_textarea_field( $settings[ $key ] ) : $defaults[ $key ]; | |
| 254 | + if ( isset( $settings[ $key ] ) ) { | |
| 255 | + $sanitized_settings[ $key ] = sanitize_textarea_field( $settings[ $key ] ); | |
| 256 | + } else { | |
| 257 | + $sanitized_settings[ $key ] = $defaults[ $key ]; | |
| 258 | + } | |
| 267 | 259 | |
| 268 | - if ( 'custom_css' !== $key && 'single_style_custom_css' !== $key ) { | |
| 260 | + if ( 'custom_css' !== $key ) { | |
| 269 | 261 | $sanitized_settings[ $key ] = $this->strip_invalid_characters( $sanitized_settings[ $key ] ); |
| 270 | 262 | } |
| 271 | 263 | } |
| 272 | - | |
| 273 | 264 | return $sanitized_settings; |
| 274 | 265 | } |
| 275 | 266 | |
| 276 | 267 | /** |
| @@ -278,9 +269,8 @@ | ||
| 278 | 269 | * |
| 279 | 270 | * @since 6.2.3 |
| 280 | 271 | * |
| 281 | 272 | * @param string $setting |
| 282 | - * | |
| 283 | 273 | * @return string |
| 284 | 274 | */ |
| 285 | 275 | private function strip_invalid_characters( $setting ) { |
| 286 | 276 | $characters_to_remove = array( '{', '}', ';', '[', ']' ); |
| @@ -285,9 +275,9 @@ | ||
| 285 | 275 | private function strip_invalid_characters( $setting ) { |
| 286 | 276 | $characters_to_remove = array( '{', '}', ';', '[', ']' ); |
| 287 | 277 | |
| 288 | 278 | // RGB is handled instead in self::maybe_sanitize_rgba_value. |
| 289 | - if ( ! str_starts_with( $setting, 'rgb' ) ) { | |
| 279 | + if ( 0 !== strpos( $setting, 'rgb' ) ) { | |
| 290 | 280 | $setting = $this->maybe_fix_braces( $setting, $characters_to_remove ); |
| 291 | 281 | } |
| 292 | 282 | |
| 293 | 283 | return str_replace( $characters_to_remove, '', $setting ); |
| @@ -297,9 +287,8 @@ | ||
| 297 | 287 | * @since 6.2.3 |
| 298 | 288 | * |
| 299 | 289 | * @param string $setting |
| 300 | 290 | * @param array $characters_to_remove |
| 301 | - * | |
| 302 | 291 | * @return string |
| 303 | 292 | */ |
| 304 | 293 | private function maybe_fix_braces( $setting, &$characters_to_remove ) { |
| 305 | 294 | $number_of_opening_braces = substr_count( $setting, '(' ); |
| @@ -321,28 +310,25 @@ | ||
| 321 | 310 | /** |
| 322 | 311 | * @since 6.2.3 |
| 323 | 312 | * |
| 324 | 313 | * @param string $input |
| 325 | - * | |
| 326 | 314 | * @return string |
| 327 | 315 | */ |
| 328 | 316 | private function trim_braces( $input ) { |
| 329 | 317 | $output = $input; |
| 330 | - | |
| 331 | 318 | // Remove any ( from the start of the string as no CSS values expect at the first character. |
| 332 | - if ( $output && in_array( $output[0], array( '(', ')' ), true ) ) { | |
| 333 | - $output = ltrim( $output, '()' ); | |
| 319 | + if ( $output ) { | |
| 320 | + if ( in_array( $output[0], array( '(', ')' ), true ) ) { | |
| 321 | + $output = ltrim( $output, '()' ); | |
| 322 | + } | |
| 334 | 323 | } |
| 335 | - | |
| 336 | 324 | // Remove extra braces from the end. |
| 337 | 325 | if ( in_array( substr( $output, -1 ), array( '(', ')' ), true ) ) { |
| 338 | 326 | $output = rtrim( $output, '()' ); |
| 339 | - | |
| 340 | - if ( str_contains( $output, '(' ) ) { | |
| 327 | + if ( false !== strpos( $output, '(' ) ) { | |
| 341 | 328 | $output .= ')'; |
| 342 | 329 | } |
| 343 | 330 | } |
| 344 | - | |
| 345 | 331 | return $output; |
| 346 | 332 | } |
| 347 | 333 | |
| 348 | 334 | /** |
| @@ -348,13 +334,12 @@ | ||
| 348 | 334 | /** |
| 349 | 335 | * @since 6.2.3 |
| 350 | 336 | * |
| 351 | 337 | * @param string $setting |
| 352 | - * | |
| 353 | 338 | * @return bool |
| 354 | 339 | */ |
| 355 | 340 | private function should_remove_every_brace( $setting ) { |
| 356 | - if ( str_starts_with( trim( $setting, '()' ), 'calc' ) ) { | |
| 341 | + if ( 0 === strpos( trim( $setting, '()' ), 'calc' ) ) { | |
| 357 | 342 | // Support calc() sizes. We do not want to remove all braces when calc is used. |
| 358 | 343 | return false; |
| 359 | 344 | } |
| 360 | 345 | |
| @@ -359,9 +344,8 @@ | ||
| 359 | 344 | } |
| 360 | 345 | |
| 361 | 346 | // Matches hex values but also checks for unexpected ( and ). |
| 362 | 347 | $looks_like_a_hex_value = preg_match( '/^(?:\()?(?!#?[a-fA-F0-9]*[^\(#\)\da-fA-F])[a-fA-F0-9\(\)]*(?:\))?$/', $setting ); |
| 363 | - | |
| 364 | 348 | if ( $looks_like_a_hex_value ) { |
| 365 | 349 | return true; |
| 366 | 350 | } |
| 367 | 351 | |
| @@ -367,9 +351,13 @@ | ||
| 367 | 351 | |
| 368 | 352 | // Matches size values but also checks for unexpected ( and ). |
| 369 | 353 | // This is case insensitive so it will catch PX, PT, etc, as well. |
| 370 | 354 | $looks_like_a_size = preg_match( '/\(?[+-]?\d*\.?\d+(?:px|%|em|rem|ex|pt|pc|mm|cm|in)\)?/i', $setting ); |
| 371 | - return (bool) $looks_like_a_size; | |
| 355 | + if ( $looks_like_a_size ) { | |
| 356 | + return true; | |
| 357 | + } | |
| 358 | + | |
| 359 | + return false; | |
| 372 | 360 | } |
| 373 | 361 | |
| 374 | 362 | /** |
| 375 | 363 | * @since 3.01.01 |
| @@ -374,17 +362,13 @@ | ||
| 374 | 362 | /** |
| 375 | 363 | * @since 3.01.01 |
| 376 | 364 | * |
| 377 | 365 | * @param string $setting |
| 378 | - * | |
| 379 | 366 | * @return bool |
| 380 | 367 | */ |
| 381 | 368 | private function is_color( $setting ) { |
| 382 | - if ( str_contains( $setting, 'color' ) ) { | |
| 383 | - return true; | |
| 384 | - } | |
| 385 | - | |
| 386 | - return in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ), true ); | |
| 369 | + $extra_colors = array( 'error_bg', 'error_border', 'error_text' ); | |
| 370 | + return strpos( $setting, 'color' ) !== false || in_array( $setting, $extra_colors, true ); | |
| 387 | 371 | } |
| 388 | 372 | |
| 389 | 373 | /** |
| 390 | 374 | * @since 3.01.01 |
| @@ -421,25 +405,26 @@ | ||
| 421 | 405 | ) |
| 422 | 406 | ); |
| 423 | 407 | $create_file->create_file( $css ); |
| 424 | 408 | |
| 425 | - update_option( 'frmpro_css', $css, false ); | |
| 409 | + update_option( 'frmpro_css', $css, 'no' ); | |
| 426 | 410 | set_transient( 'frmpro_css', $css, MONTH_IN_SECONDS ); |
| 427 | 411 | } |
| 428 | 412 | |
| 429 | 413 | /** |
| 430 | 414 | * @param string $filename |
| 431 | - * | |
| 432 | 415 | * @return string |
| 433 | 416 | */ |
| 434 | 417 | private function get_css_content( $filename ) { |
| 435 | - $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; | |
| 418 | + $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; | |
| 419 | + | |
| 436 | 420 | $saving = true; |
| 437 | 421 | $frm_style = $this; |
| 438 | 422 | |
| 439 | 423 | ob_start(); |
| 440 | 424 | include $filename; |
| 441 | - $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_clean() ) ); | |
| 425 | + $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); | |
| 426 | + ob_end_clean(); | |
| 442 | 427 | |
| 443 | 428 | return FrmStylesController::replace_relative_url( $css ); |
| 444 | 429 | } |
| 445 | 430 | |
| @@ -463,10 +448,9 @@ | ||
| 463 | 448 | /** |
| 464 | 449 | * Delete a style by its post ID. |
| 465 | 450 | * |
| 466 | 451 | * @param int $id |
| 467 | - * | |
| 468 | - * @return false|WP_Post|null | |
| 452 | + * @return WP_Post|false|null | |
| 469 | 453 | */ |
| 470 | 454 | public function destroy( $id ) { |
| 471 | 455 | if ( $id === $this->get_default_style()->ID ) { |
| 472 | 456 | return false; |
| @@ -474,16 +458,19 @@ | ||
| 474 | 458 | return wp_delete_post( $id ); |
| 475 | 459 | } |
| 476 | 460 | |
| 477 | 461 | /** |
| 478 | - * @return stdClass|WP_Post | |
| 462 | + * @return WP_Post|stdClass | |
| 479 | 463 | */ |
| 480 | 464 | public function get_one() { |
| 481 | 465 | if ( 'default' === $this->id ) { |
| 482 | 466 | $style = $this->get_default_style(); |
| 467 | + if ( $style ) { | |
| 468 | + $this->id = $style->ID; | |
| 469 | + } else { | |
| 470 | + $this->id = 0; | |
| 471 | + } | |
| 483 | 472 | |
| 484 | - $this->id = $style ? $style->ID : 0; | |
| 485 | - | |
| 486 | 473 | return $style; |
| 487 | 474 | } |
| 488 | 475 | |
| 489 | 476 | $style = get_post( $this->id ); |
| @@ -495,9 +482,9 @@ | ||
| 495 | 482 | $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
| 496 | 483 | |
| 497 | 484 | $default_values = $this->get_defaults(); |
| 498 | 485 | |
| 499 | - // Fill default values | |
| 486 | + // fill default values | |
| 500 | 487 | $style->post_content = $this->override_defaults( $style->post_content ); |
| 501 | 488 | $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
| 502 | 489 | |
| 503 | 490 | return $style; |
| @@ -506,9 +493,8 @@ | ||
| 506 | 493 | /** |
| 507 | 494 | * @param string $orderby |
| 508 | 495 | * @param string $order |
| 509 | 496 | * @param int $limit |
| 510 | - * | |
| 511 | 497 | * @return array |
| 512 | 498 | */ |
| 513 | 499 | public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
| 514 | 500 | $post_atts = array( |
| @@ -520,16 +506,16 @@ | ||
| 520 | 506 | ); |
| 521 | 507 | |
| 522 | 508 | $temp_styles = FrmDb::check_cache( json_encode( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); |
| 523 | 509 | |
| 524 | - if ( ! $temp_styles ) { | |
| 510 | + if ( empty( $temp_styles ) ) { | |
| 525 | 511 | global $wpdb; |
| 526 | - // Make sure there wasn't a conflict with the query | |
| 527 | - $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 512 | + // make sure there wasn't a conflict with the query | |
| 513 | + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); | |
| 528 | 514 | $temp_styles = FrmDb::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); |
| 529 | 515 | |
| 530 | - if ( ! $temp_styles ) { | |
| 531 | - // Create a new style if there are none | |
| 516 | + if ( empty( $temp_styles ) ) { | |
| 517 | + // create a new style if there are none | |
| 532 | 518 | $new = $this->get_new(); |
| 533 | 519 | $new->post_title = __( 'Formidable Style', 'formidable' ); |
| 534 | 520 | $new->post_name = $new->post_title; |
| 535 | 521 | $new->menu_order = 1; |
| @@ -536,25 +522,25 @@ | ||
| 536 | 522 | $new = $this->save( (array) $new ); |
| 537 | 523 | $this->update( 'default' ); |
| 538 | 524 | |
| 539 | 525 | $post_atts['include'] = $new; |
| 540 | - $temp_styles = get_posts( $post_atts ); | |
| 526 | + | |
| 527 | + $temp_styles = get_posts( $post_atts ); | |
| 541 | 528 | } |
| 542 | 529 | } |
| 543 | 530 | |
| 544 | 531 | $default_values = $this->get_defaults(); |
| 545 | 532 | $default_style = false; |
| 546 | - $styles = array(); | |
| 547 | 533 | |
| 534 | + $styles = array(); | |
| 548 | 535 | foreach ( $temp_styles as $style ) { |
| 549 | 536 | $this->id = $style->ID; |
| 550 | - | |
| 551 | 537 | if ( $style->menu_order ) { |
| 552 | 538 | if ( $default_style ) { |
| 553 | - // Only return one default | |
| 539 | + // only return one default | |
| 554 | 540 | $style->menu_order = 0; |
| 555 | 541 | } else { |
| 556 | - // Check for a default style | |
| 542 | + // check for a default style | |
| 557 | 543 | $default_style = $style->ID; |
| 558 | 544 | } |
| 559 | 545 | } |
| 560 | 546 | |
| @@ -559,17 +545,18 @@ | ||
| 559 | 545 | } |
| 560 | 546 | |
| 561 | 547 | $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
| 562 | 548 | |
| 563 | - // Fill default values | |
| 549 | + // fill default values | |
| 564 | 550 | $style->post_content = $this->override_defaults( $style->post_content ); |
| 565 | 551 | $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
| 566 | 552 | |
| 567 | 553 | $styles[ $style->ID ] = $style; |
| 568 | - }//end foreach | |
| 554 | + } | |
| 569 | 555 | |
| 570 | 556 | if ( ! $default_style ) { |
| 571 | - $default_style = reset( $styles ); | |
| 557 | + $default_style = reset( $styles ); | |
| 558 | + | |
| 572 | 559 | $styles[ $default_style->ID ]->menu_order = 1; |
| 573 | 560 | } |
| 574 | 561 | |
| 575 | 562 | return $styles; |
| @@ -576,10 +563,8 @@ | ||
| 576 | 563 | } |
| 577 | 564 | |
| 578 | 565 | /** |
| 579 | 566 | * @param array|null $styles |
| 580 | - * | |
| 581 | - * @return object|null | |
| 582 | 567 | */ |
| 583 | 568 | public function get_default_style( $styles = null ) { |
| 584 | 569 | if ( ! isset( $styles ) ) { |
| 585 | 570 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| @@ -589,15 +574,12 @@ | ||
| 589 | 574 | if ( $style->menu_order ) { |
| 590 | 575 | return $style; |
| 591 | 576 | } |
| 592 | 577 | } |
| 593 | - | |
| 594 | - return null; | |
| 595 | 578 | } |
| 596 | 579 | |
| 597 | 580 | /** |
| 598 | 581 | * @param mixed $settings |
| 599 | - * | |
| 600 | 582 | * @return mixed |
| 601 | 583 | */ |
| 602 | 584 | public function override_defaults( $settings ) { |
| 603 | 585 | if ( ! is_array( $settings ) ) { |
| @@ -603,9 +585,9 @@ | ||
| 603 | 585 | if ( ! is_array( $settings ) ) { |
| 604 | 586 | return $settings; |
| 605 | 587 | } |
| 606 | 588 | |
| 607 | - $settings['line_height'] = ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] === 'auto' ? 'normal' : $settings['field_height']; // phpcs:ignore Universal.Operators.StrictComparisons, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 589 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; | |
| 608 | 590 | |
| 609 | 591 | if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { |
| 610 | 592 | $settings['form_desc_size'] = $settings['description_font_size']; |
| 611 | 593 | $settings['form_desc_color'] = $settings['description_color']; |
| @@ -634,147 +616,142 @@ | ||
| 634 | 616 | * @return array |
| 635 | 617 | */ |
| 636 | 618 | public function get_defaults() { |
| 637 | 619 | $defaults = array( |
| 638 | - 'theme_css' => 'ui-lightness', | |
| 639 | - 'theme_name' => 'UI Lightness', | |
| 620 | + 'theme_css' => 'ui-lightness', | |
| 621 | + 'theme_name' => 'UI Lightness', | |
| 640 | 622 | |
| 641 | - 'center_form' => '', | |
| 642 | - 'form_width' => '100%', | |
| 643 | - 'form_align' => 'left', | |
| 644 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', | |
| 645 | - 'fieldset' => '0px', | |
| 646 | - 'fieldset_color' => '000000', | |
| 647 | - 'fieldset_padding' => '0px 0px 15px 0px', | |
| 648 | - 'fieldset_bg_color' => '', | |
| 623 | + 'center_form' => '', | |
| 624 | + 'form_width' => '100%', | |
| 625 | + 'form_align' => 'left', | |
| 626 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', | |
| 627 | + 'fieldset' => '0px', | |
| 628 | + 'fieldset_color' => '000000', | |
| 629 | + 'fieldset_padding' => '0 0 15px 0', | |
| 630 | + 'fieldset_bg_color' => '', | |
| 649 | 631 | |
| 650 | - 'title_size' => '40px', | |
| 651 | - 'title_color' => '444444', | |
| 652 | - 'title_margin_top' => '10px', | |
| 653 | - 'title_margin_bottom' => '60px', | |
| 654 | - 'form_desc_size' => '14px', | |
| 655 | - 'form_desc_color' => '98A2B3', | |
| 656 | - 'form_desc_margin_top' => '10px', | |
| 657 | - 'form_desc_margin_bottom' => '25px', | |
| 658 | - 'form_desc_padding' => '0px', | |
| 632 | + 'title_size' => '40px', | |
| 633 | + 'title_color' => '444444', | |
| 634 | + 'title_margin_top' => '10px', | |
| 635 | + 'title_margin_bottom' => '60px', | |
| 636 | + 'form_desc_size' => '14px', | |
| 637 | + 'form_desc_color' => '666666', | |
| 638 | + 'form_desc_margin_top' => '10px', | |
| 639 | + 'form_desc_margin_bottom' => '25px', | |
| 640 | + 'form_desc_padding' => '0', | |
| 659 | 641 | |
| 660 | - 'font' => '', | |
| 661 | - 'font_size' => '15px', | |
| 662 | - 'label_color' => '344054', | |
| 663 | - 'weight' => 'normal', | |
| 664 | - 'position' => 'none', | |
| 665 | - 'align' => 'left', | |
| 666 | - 'width' => '150px', | |
| 667 | - 'required_color' => 'F04438', | |
| 668 | - 'required_weight' => 'bold', | |
| 669 | - 'label_padding' => '0px 0px 5px 0px', | |
| 642 | + 'font' => '', | |
| 643 | + 'font_size' => '15px', | |
| 644 | + 'label_color' => '3f4b5b', | |
| 645 | + 'weight' => 'normal', | |
| 646 | + 'position' => 'none', | |
| 647 | + 'align' => 'left', | |
| 648 | + 'width' => '150px', | |
| 649 | + 'required_color' => 'B94A48', | |
| 650 | + 'required_weight' => 'bold', | |
| 651 | + 'label_padding' => '0 0 3px 0', | |
| 670 | 652 | |
| 671 | - 'description_font_size' => '12px', | |
| 672 | - 'description_color' => '667085', | |
| 673 | - 'description_weight' => 'normal', | |
| 674 | - 'description_style' => 'normal', | |
| 675 | - 'description_align' => 'left', | |
| 676 | - 'description_margin' => '0px', | |
| 653 | + 'description_font_size' => '12px', | |
| 654 | + 'description_color' => '666666', | |
| 655 | + 'description_weight' => 'normal', | |
| 656 | + 'description_style' => 'normal', | |
| 657 | + 'description_align' => 'left', | |
| 658 | + 'description_margin' => '0', | |
| 677 | 659 | |
| 678 | - 'field_font_size' => '14px', | |
| 679 | - 'field_height' => '36px', | |
| 680 | - 'line_height' => 'normal', | |
| 681 | - 'field_width' => '100%', | |
| 682 | - 'auto_width' => false, | |
| 683 | - 'field_pad' => '8px 12px', | |
| 684 | - 'field_margin' => '20px', | |
| 685 | - 'field_weight' => 'normal', | |
| 686 | - 'text_color' => '1D2939', | |
| 660 | + 'field_font_size' => '14px', | |
| 661 | + 'field_height' => '32px', | |
| 662 | + 'line_height' => 'normal', | |
| 663 | + 'field_width' => '100%', | |
| 664 | + 'auto_width' => false, | |
| 665 | + 'field_pad' => '6px 10px', | |
| 666 | + 'field_margin' => '20px', | |
| 667 | + 'field_weight' => 'normal', | |
| 668 | + 'text_color' => '555555', | |
| 687 | 669 | // 'border_color_hv' => 'cccccc', |
| 688 | - 'border_color' => 'D0D5DD', | |
| 689 | - 'field_border_width' => '1px', | |
| 690 | - 'field_border_style' => 'solid', | |
| 670 | + 'border_color' => 'BFC3C8', | |
| 671 | + 'field_border_width' => '1px', | |
| 672 | + 'field_border_style' => 'solid', | |
| 691 | 673 | |
| 692 | - 'bg_color' => 'ffffff', | |
| 674 | + 'bg_color' => 'ffffff', | |
| 693 | 675 | // 'bg_color_hv' => 'ffffff', |
| 694 | - 'remove_box_shadow' => '', | |
| 695 | - 'bg_color_active' => 'ffffff', | |
| 696 | - 'border_color_active' => '4199FD', | |
| 697 | - 'remove_box_shadow_active' => '', | |
| 698 | - 'text_color_error' => '444444', | |
| 699 | - 'bg_color_error' => 'ffffff', | |
| 700 | - 'border_color_error' => 'F04438', | |
| 701 | - 'border_width_error' => '1px', | |
| 702 | - 'border_style_error' => 'solid', | |
| 703 | - 'bg_color_disabled' => 'F9FAFB', | |
| 704 | - 'border_color_disabled' => 'D0D5DD', | |
| 705 | - 'text_color_disabled' => '667085', | |
| 676 | + 'remove_box_shadow' => '', | |
| 677 | + 'bg_color_active' => 'ffffff', | |
| 678 | + 'border_color_active' => '66afe9', | |
| 679 | + 'remove_box_shadow_active' => '', | |
| 680 | + 'text_color_error' => '444444', | |
| 681 | + 'bg_color_error' => 'ffffff', | |
| 682 | + 'border_color_error' => 'B94A48', | |
| 683 | + 'border_width_error' => '1px', | |
| 684 | + 'border_style_error' => 'solid', | |
| 685 | + 'bg_color_disabled' => 'ffffff', | |
| 686 | + 'border_color_disabled' => 'E5E5E5', | |
| 687 | + 'text_color_disabled' => 'A1A1A1', | |
| 706 | 688 | |
| 707 | - 'radio_align' => 'block', | |
| 708 | - 'check_align' => 'block', | |
| 709 | - 'check_font_size' => '14px', | |
| 710 | - 'check_label_color' => '1D2939', | |
| 711 | - 'check_weight' => 'normal', | |
| 689 | + 'radio_align' => 'block', | |
| 690 | + 'check_align' => 'block', | |
| 691 | + 'check_font_size' => '13px', | |
| 692 | + 'check_label_color' => '444444', | |
| 693 | + 'check_weight' => 'normal', | |
| 712 | 694 | |
| 713 | - 'section_font_size' => '18px', | |
| 714 | - 'section_color' => '344054', | |
| 715 | - 'section_weight' => 'bold', | |
| 716 | - 'section_pad' => '32px 0px 3px 0px', | |
| 717 | - 'section_mar_top' => '30px', | |
| 718 | - 'section_mar_bottom' => '30px', | |
| 719 | - 'section_bg_color' => '', | |
| 720 | - 'section_border_color' => 'EAECF0', | |
| 721 | - 'section_border_width' => '1px', | |
| 722 | - 'section_border_style' => 'solid', | |
| 723 | - 'section_border_loc' => '-top', | |
| 724 | - 'collapse_icon' => '6', | |
| 725 | - 'collapse_pos' => 'after', | |
| 726 | - 'repeat_icon' => '1', | |
| 727 | - 'repeat_icon_color' => 'ffffff', | |
| 695 | + 'section_font_size' => '18px', | |
| 696 | + 'section_color' => '444444', | |
| 697 | + 'section_weight' => 'bold', | |
| 698 | + 'section_pad' => '15px 0 3px 0', | |
| 699 | + 'section_mar_top' => '15px', | |
| 700 | + 'section_mar_bottom' => '30px', | |
| 701 | + 'section_bg_color' => '', | |
| 702 | + 'section_border_color' => 'e8e8e8', | |
| 703 | + 'section_border_width' => '2px', | |
| 704 | + 'section_border_style' => 'solid', | |
| 705 | + 'section_border_loc' => '-top', | |
| 706 | + 'collapse_icon' => '6', | |
| 707 | + 'collapse_pos' => 'after', | |
| 708 | + 'repeat_icon' => '1', | |
| 709 | + 'repeat_icon_color' => 'ffffff', | |
| 728 | 710 | |
| 729 | 711 | 'submit_style' => false, |
| 730 | - 'submit_font_size' => '14px', | |
| 712 | + 'submit_font_size' => '15px', | |
| 731 | 713 | 'submit_width' => 'auto', |
| 732 | 714 | 'submit_height' => 'auto', |
| 733 | - 'submit_bg_color' => '4199FD', | |
| 734 | - 'submit_border_color' => '4199FD', | |
| 715 | + 'submit_bg_color' => '579AF6', | |
| 716 | + 'submit_border_color' => '579AF6', | |
| 735 | 717 | 'submit_border_width' => '1px', |
| 736 | 718 | 'submit_text_color' => 'ffffff', |
| 737 | 719 | 'submit_weight' => 'normal', |
| 738 | - 'submit_border_radius' => '8px', | |
| 720 | + 'submit_border_radius' => '4px', | |
| 739 | 721 | 'submit_bg_img' => '', |
| 740 | 722 | 'submit_margin' => '10px', |
| 741 | - 'submit_padding' => '8px 16px', | |
| 723 | + 'submit_padding' => '10px 20px', | |
| 742 | 724 | 'submit_shadow_color' => 'eeeeee', |
| 743 | - 'submit_hover_bg_color' => '3680D3', | |
| 744 | - 'submit_hover_color' => 'ffffff', | |
| 745 | - 'submit_hover_border_color' => '3680D3', | |
| 746 | - 'submit_active_bg_color' => '3680D3', | |
| 747 | - 'submit_active_color' => 'ffffff', | |
| 748 | - 'submit_active_border_color' => '3680D3', | |
| 725 | + 'submit_hover_bg_color' => 'efefef', | |
| 726 | + 'submit_hover_color' => '444444', | |
| 727 | + 'submit_hover_border_color' => 'cccccc', | |
| 728 | + 'submit_active_bg_color' => 'efefef', | |
| 729 | + 'submit_active_color' => '444444', | |
| 730 | + 'submit_active_border_color' => 'cccccc', | |
| 749 | 731 | |
| 750 | - 'border_radius' => '8px', | |
| 751 | - 'error_bg' => 'FEE4E2', | |
| 752 | - 'error_border' => 'F5B8AA', | |
| 753 | - 'error_text' => 'F04438', | |
| 754 | - 'error_font_size' => '14px', | |
| 732 | + 'border_radius' => '4px', | |
| 733 | + 'error_bg' => 'F2DEDE', | |
| 734 | + 'error_border' => 'EBCCD1', | |
| 735 | + 'error_text' => 'B94A48', | |
| 736 | + 'error_font_size' => '14px', | |
| 755 | 737 | |
| 756 | - 'success_bg_color' => 'DFF0D8', | |
| 757 | - 'success_border_color' => 'D6E9C6', | |
| 758 | - 'success_text_color' => '468847', | |
| 759 | - 'success_font_size' => '14px', | |
| 738 | + 'success_bg_color' => 'DFF0D8', | |
| 739 | + 'success_border_color' => 'D6E9C6', | |
| 740 | + 'success_text_color' => '468847', | |
| 741 | + 'success_font_size' => '14px', | |
| 760 | 742 | |
| 761 | - 'important_style' => false, | |
| 743 | + 'important_style' => false, | |
| 762 | 744 | |
| 763 | - 'progress_bg_color' => 'EAECF0', | |
| 764 | - 'progress_color' => '1D2939', | |
| 765 | - 'progress_active_bg_color' => '4199FD', | |
| 766 | - 'progress_active_color' => 'ffffff', | |
| 767 | - 'progress_border_color' => 'EAECF0', | |
| 768 | - 'progress_border_size' => '1px', | |
| 769 | - 'progress_size' => '30px', | |
| 770 | - 'custom_css' => '', | |
| 771 | - 'use_base_font_size' => false, | |
| 772 | - 'base_font_size' => '15px', | |
| 773 | - 'field_shape_type' => 'rounded-corner', | |
| 745 | + 'progress_bg_color' => 'eaeaea', | |
| 746 | + 'progress_active_color' => 'ffffff', | |
| 747 | + 'progress_active_bg_color' => '579AF6', | |
| 748 | + 'progress_color' => '3f4b5b', | |
| 749 | + 'progress_border_color' => 'E5E5E5', | |
| 750 | + 'progress_border_size' => '2px', | |
| 751 | + 'progress_size' => '24px', | |
| 774 | 752 | |
| 775 | - 'enable_style_custom_css' => false, | |
| 776 | - 'single_style_custom_css' => '', | |
| 753 | + 'custom_css' => '', | |
| 777 | 754 | ); |
| 778 | 755 | |
| 779 | 756 | return apply_filters( 'frm_default_style_settings', $defaults ); |
| 780 | 757 | } |
| @@ -783,13 +760,12 @@ | ||
| 783 | 760 | * Get a name attribute value for a style setting input. |
| 784 | 761 | * |
| 785 | 762 | * @param string $field_name |
| 786 | 763 | * @param string $post_field |
| 787 | - * | |
| 788 | 764 | * @return string |
| 789 | 765 | */ |
| 790 | 766 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
| 791 | - return 'frm_style_setting' . ( $post_field ? '[' . $post_field . ']' : '' ) . '[' . $field_name . ']'; | |
| 767 | + return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; | |
| 792 | 768 | } |
| 793 | 769 | |
| 794 | 770 | /** |
| 795 | 771 | * @return array |
| @@ -795,17 +771,17 @@ | ||
| 795 | 771 | * @return array |
| 796 | 772 | */ |
| 797 | 773 | public static function get_bold_options() { |
| 798 | 774 | return array( |
| 799 | - 100 => __( 'Thin', 'formidable' ), | |
| 800 | - 200 => __( 'Extra Light', 'formidable' ), | |
| 801 | - 300 => __( 'Light', 'formidable' ), | |
| 802 | - 'normal' => __( 'Regular', 'formidable' ), | |
| 803 | - 500 => __( 'Medium', 'formidable' ), | |
| 804 | - 600 => __( 'Semi Bold', 'formidable' ), | |
| 805 | - 'bold' => __( 'Bold', 'formidable' ), | |
| 806 | - 800 => __( 'Extra Bold', 'formidable' ), | |
| 807 | - 900 => __( 'Black', 'formidable' ), | |
| 775 | + 100 => 100, | |
| 776 | + 200 => 200, | |
| 777 | + 300 => 300, | |
| 778 | + 'normal' => __( 'normal', 'formidable' ), | |
| 779 | + 500 => 500, | |
| 780 | + 600 => 600, | |
| 781 | + 'bold' => __( 'bold', 'formidable' ), | |
| 782 | + 800 => 800, | |
| 783 | + 900 => 900, | |
| 808 | 784 | ); |
| 809 | 785 | } |
| 810 | 786 | |
| 811 | 787 | /** |
| @@ -811,17 +787,15 @@ | ||
| 811 | 787 | /** |
| 812 | 788 | * Don't let imbalanced font families ruin the whole stylesheet. |
| 813 | 789 | * |
| 814 | 790 | * @param string $value |
| 815 | - * | |
| 816 | 791 | * @return string |
| 817 | 792 | */ |
| 818 | 793 | public function force_balanced_quotation( $value ) { |
| 819 | 794 | $balanced_characters = array( '"', "'" ); |
| 820 | - | |
| 821 | 795 | foreach ( $balanced_characters as $char ) { |
| 822 | 796 | $char_count = substr_count( $value, $char ); |
| 823 | - $is_balanced = $char_count % 2 === 0; | |
| 797 | + $is_balanced = $char_count % 2 == 0; | |
| 824 | 798 | |
| 825 | 799 | if ( $is_balanced ) { |
| 826 | 800 | continue; |
| 827 | 801 | } |
| @@ -831,27 +805,7 @@ | ||
| 831 | 805 | } else { |
| 832 | 806 | $value .= $char; |
| 833 | 807 | } |
| 834 | 808 | } |
| 835 | - | |
| 836 | 809 | return $value; |
| 837 | - } | |
| 838 | - | |
| 839 | - /** | |
| 840 | - * Get the default template style | |
| 841 | - * | |
| 842 | - * @since 6.14 | |
| 843 | - * | |
| 844 | - * @param int|string $style_id The post type "frm_styles" ID. | |
| 845 | - * | |
| 846 | - * @return string The json encoded template data | |
| 847 | - */ | |
| 848 | - public function get_default_template_style( $style_id ) { | |
| 849 | - $default_template = get_post_meta( (int) $style_id, $this->default_template_style_meta_name, true ); | |
| 850 | - | |
| 851 | - if ( ! $default_template ) { | |
| 852 | - return FrmAppHelper::prepare_and_encode( $this->get_defaults() ); | |
| 853 | - } | |
| 854 | - | |
| 855 | - return $default_template; | |
| 856 | 810 | } |
| 857 | 811 | } |