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