| @@ -1,9 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - die( 'You are not allowed to call this page directly.' ); | |
| 4 | -} | |
| 5 | - | |
| 6 | 2 | class FrmStylesHelper { |
| 7 | 3 | |
| 8 | 4 | public static function get_upload_base() { |
| 9 | 5 | $uploads = wp_upload_dir(); |
| @@ -13,18 +9,17 @@ | ||
| 13 | 9 | |
| 14 | 10 | return $uploads; |
| 15 | 11 | } |
| 16 | 12 | |
| 17 | - /** | |
| 18 | - * Called from the admin header. | |
| 19 | - * | |
| 20 | - * @since 4.0 | |
| 21 | - */ | |
| 22 | - public static function save_button() { | |
| 23 | - ?> | |
| 24 | - <input type="submit" name="submit" class="button button-primary frm-button-primary" value="<?php esc_attr_e( 'Update', 'formidable' ); ?>" /> | |
| 25 | - <?php | |
| 26 | - } | |
| 13 | + public static function style_menu( $active = '' ) { | |
| 14 | +?> | |
| 15 | + <h2 class="nav-tab-wrapper"> | |
| 16 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Edit Styles', 'formidable' ) ?></a> | |
| 17 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php esc_html_e( 'Manage Form Styles', 'formidable' ) ?></a> | |
| 18 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ); ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Custom CSS', 'formidable' ); ?></a> | |
| 19 | + </h2> | |
| 20 | +<?php | |
| 21 | + } | |
| 27 | 22 | |
| 28 | 23 | /** |
| 29 | 24 | * @since 2.05 |
| 30 | 25 | */ |
| @@ -78,33 +73,33 @@ | ||
| 78 | 73 | public static function arrow_icons() { |
| 79 | 74 | $minus_icons = self::minus_icons(); |
| 80 | 75 | |
| 81 | 76 | return array( |
| 82 | - 6 => array( | |
| 77 | + 6 => array( | |
| 83 | 78 | '-' => '62d', |
| 84 | 79 | '+' => '62a', |
| 85 | 80 | ), |
| 86 | - 0 => array( | |
| 81 | + 0 => array( | |
| 87 | 82 | '-' => '60d', |
| 88 | 83 | '+' => '609', |
| 89 | 84 | ), |
| 90 | - 1 => array( | |
| 85 | + 1 => array( | |
| 91 | 86 | '-' => '60e', |
| 92 | 87 | '+' => '60c', |
| 93 | 88 | ), |
| 94 | - 2 => array( | |
| 89 | + 2 => array( | |
| 95 | 90 | '-' => '630', |
| 96 | 91 | '+' => '631', |
| 97 | 92 | ), |
| 98 | - 3 => array( | |
| 93 | + 3 => array( | |
| 99 | 94 | '-' => '62b', |
| 100 | 95 | '+' => '628', |
| 101 | 96 | ), |
| 102 | - 4 => array( | |
| 97 | + 4 => array( | |
| 103 | 98 | '-' => '62c', |
| 104 | 99 | '+' => '629', |
| 105 | 100 | ), |
| 106 | - 5 => array( | |
| 101 | + 5 => array( | |
| 107 | 102 | '-' => '635', |
| 108 | 103 | '+' => '634', |
| 109 | 104 | ), |
| 110 | 105 | 'p0' => $minus_icons[0], |
| @@ -114,14 +109,14 @@ | ||
| 114 | 109 | 'p4' => $minus_icons[4], |
| 115 | 110 | ); |
| 116 | 111 | } |
| 117 | 112 | |
| 118 | - /** | |
| 119 | - * @since 2.0 | |
| 120 | - * @return string The class for this icon. | |
| 121 | - */ | |
| 113 | + /** | |
| 114 | + * @since 2.0 | |
| 115 | + * @return The class for this icon | |
| 116 | + */ | |
| 122 | 117 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
| 123 | - if ( 'arrow' === $type && is_numeric( $key ) ) { | |
| 118 | + if ( 'arrow' == $type && is_numeric( $key ) ) { | |
| 124 | 119 | //frm_arrowup6_icon |
| 125 | 120 | $arrow = array( |
| 126 | 121 | '-' => 'down', |
| 127 | 122 | '+' => 'up', |
| @@ -128,10 +123,10 @@ | ||
| 128 | 123 | ); |
| 129 | 124 | $class = 'frm_arrow' . $arrow[ $icon ]; |
| 130 | 125 | } else { |
| 131 | 126 | //frm_minus1_icon |
| 132 | - $key = str_replace( 'p', '', $key ); | |
| 133 | - $plus = array( | |
| 127 | + $key = str_replace( 'p', '', $key ); | |
| 128 | + $plus = array( | |
| 134 | 129 | '-' => 'minus', |
| 135 | 130 | '+' => 'plus', |
| 136 | 131 | ); |
| 137 | 132 | $class = 'frm_' . $plus[ $icon ]; |
| @@ -136,56 +131,56 @@ | ||
| 136 | 131 | ); |
| 137 | 132 | $class = 'frm_' . $plus[ $icon ]; |
| 138 | 133 | } |
| 139 | 134 | |
| 140 | - if ( $key ) { | |
| 141 | - $class .= $key; | |
| 142 | - } | |
| 143 | - $class .= '_icon'; | |
| 135 | + if ( $key ) { | |
| 136 | + $class .= $key; | |
| 137 | + } | |
| 138 | + $class .= '_icon'; | |
| 144 | 139 | |
| 145 | - return $class; | |
| 146 | - } | |
| 140 | + return $class; | |
| 141 | + } | |
| 147 | 142 | |
| 148 | - /** | |
| 149 | - * @param WP_Post $style | |
| 150 | - * @param FrmStyle $frm_style | |
| 151 | - * @param string $type | |
| 152 | - * @return void | |
| 153 | - */ | |
| 154 | 143 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
| 155 | 144 | $function_name = $type . '_icons'; |
| 156 | - $icons = self::$function_name(); | |
| 145 | + $icons = self::$function_name(); | |
| 157 | 146 | unset( $function_name ); |
| 158 | 147 | |
| 159 | - $name = 'arrow' === $type ? 'collapse_icon' : 'repeat_icon'; | |
| 160 | - ?> | |
| 161 | - <div class="btn-group" id="frm_<?php echo esc_attr( $name ); ?>_select"> | |
| 162 | - <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> | |
| 163 | - <?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ); ?> | |
| 164 | - <?php FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ); ?> | |
| 165 | - <b class="caret"></b> | |
| 166 | - </button> | |
| 167 | - <ul class="multiselect-container frm-dropdown-menu"> | |
| 168 | - <?php foreach ( $icons as $key => $icon ) { ?> | |
| 169 | - <li <?php echo ( $style->post_content['collapse_icon'] == $key ) ? 'class="active"' : ''; ?>> | |
| 170 | - <a href="javascript:void(0);"> | |
| 171 | - <label> | |
| 172 | - <input type="radio" value="<?php echo esc_attr( $key ); ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ); ?>" <?php checked( $style->post_content[ $name ], $key ); ?> /> | |
| 173 | - <span> | |
| 174 | - <?php | |
| 175 | - FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '+', $type ) ); | |
| 176 | - FrmAppHelper::icon_by_class( 'frmfont ' . self::icon_key_to_class( $key, '-', $type ) ); | |
| 177 | - ?> | |
| 178 | - </span> | |
| 179 | - </label> | |
| 180 | - </a> | |
| 181 | - </li> | |
| 182 | - <?php } ?> | |
| 183 | - </ul> | |
| 184 | - </div> | |
| 185 | - <?php | |
| 186 | - } | |
| 148 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; | |
| 149 | +?> | |
| 150 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ); ?>" id="frm_<?php echo esc_attr( $name ); ?>" class="frm_icon_font frm_multiselect hide-if-js"> | |
| 151 | + <?php foreach ( $icons as $key => $icon ) { ?> | |
| 152 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> | |
| 153 | + <?php echo '' . esc_html( $icon['+'] ) . '; ' . esc_html( $icon['-'] ) . ';'; ?> | |
| 154 | + </option> | |
| 155 | + <?php } ?> | |
| 156 | + </select> | |
| 187 | 157 | |
| 158 | + <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> | |
| 159 | + <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> | |
| 160 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> | |
| 161 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> | |
| 162 | + <b class="caret"></b> | |
| 163 | + </button> | |
| 164 | + <ul class="multiselect-container frm-dropdown-menu"> | |
| 165 | + <?php foreach ( $icons as $key => $icon ) { ?> | |
| 166 | + <li <?php echo ( $style->post_content['collapse_icon'] == $key ) ? 'class="active"' : '' ?>> | |
| 167 | + <a href="javascript:void(0);"> | |
| 168 | + <label> | |
| 169 | + <input type="radio" value="<?php echo esc_attr( $key ) ?>"/> | |
| 170 | + <span> | |
| 171 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $key, '+', $type ) ) ?>"></i> | |
| 172 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $key, '-', $type ) ) ?>"></i> | |
| 173 | + </span> | |
| 174 | + </label> | |
| 175 | + </a> | |
| 176 | + </li> | |
| 177 | + <?php } ?> | |
| 178 | + </ul> | |
| 179 | + </div> | |
| 180 | +<?php | |
| 181 | + } | |
| 182 | + | |
| 188 | 183 | public static function hex2rgb( $hex ) { |
| 189 | 184 | $hex = str_replace( '#', '', $hex ); |
| 190 | 185 | |
| 191 | 186 | list( $r, $g, $b ) = sscanf( $hex, '%02x%02x%02x' ); |
| @@ -190,64 +185,34 @@ | ||
| 190 | 185 | |
| 191 | 186 | list( $r, $g, $b ) = sscanf( $hex, '%02x%02x%02x' ); |
| 192 | 187 | |
| 193 | 188 | $rgb = array( $r, $g, $b ); |
| 194 | - | |
| 195 | 189 | return implode( ',', $rgb ); |
| 196 | 190 | } |
| 197 | 191 | |
| 198 | 192 | /** |
| 199 | - * @since 4.0 | |
| 200 | - */ | |
| 201 | - public static function hex2rgba( $hex, $a ) { | |
| 202 | - $rgb = self::hex2rgb( $hex ); | |
| 203 | - | |
| 204 | - return 'rgba(' . $rgb . ',' . $a . ')'; | |
| 205 | - } | |
| 206 | - | |
| 207 | - /** | |
| 208 | - * @since 6.0 | |
| 209 | - * | |
| 210 | - * @param string $rgba | |
| 211 | - * @return string | |
| 212 | - */ | |
| 213 | - private static function rgb_to_hex( $rgba ) { | |
| 214 | - if ( strpos( $rgba, '#' ) === 0 ) { | |
| 215 | - return $rgba; | |
| 216 | - } | |
| 217 | - preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $rgba, $by_color ); | |
| 218 | - return sprintf( '%02x%02x%02x', $by_color[1], $by_color[2], $by_color[3] ); | |
| 219 | - } | |
| 220 | - | |
| 221 | - /** | |
| 222 | 193 | * @param $hex string - The original color in hex format #ffffff |
| 223 | 194 | * @param $steps integer - should be between -255 and 255. Negative = darker, positive = lighter |
| 224 | - * | |
| 225 | 195 | * @since 2.3 |
| 226 | 196 | */ |
| 227 | 197 | public static function adjust_brightness( $hex, $steps ) { |
| 228 | - $steps = max( - 255, min( 255, $steps ) ); | |
| 198 | + $steps = max( -255, min( 255, $steps ) ); | |
| 229 | 199 | |
| 230 | - if ( 0 === strpos( $hex, 'rgba(' ) ) { | |
| 231 | - $rgba = str_replace( ')', '', str_replace( 'rgba(', '', $hex ) ); | |
| 232 | - list ( $r, $g, $b, $a ) = array_map( 'trim', explode( ',', $rgba ) ); | |
| 233 | - $r = max( 0, min( 255, $r + $steps ) ); | |
| 234 | - $g = max( 0, min( 255, $g + $steps ) ); | |
| 235 | - $b = max( 0, min( 255, $b + $steps ) ); | |
| 236 | - return 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $a . ')'; | |
| 237 | - } | |
| 238 | - | |
| 239 | 200 | // Normalize into a six character long hex string |
| 240 | 201 | $hex = str_replace( '#', '', $hex ); |
| 241 | - self::fill_hex( $hex ); | |
| 202 | + if ( strlen( $hex ) == 3 ) { | |
| 203 | + $hex = str_repeat( substr( $hex, 0, 1 ), 2 ); | |
| 204 | + $hex .= str_repeat( substr( $hex, 1, 1 ), 2 ); | |
| 205 | + $hex .= str_repeat( substr( $hex, 2, 1 ), 2 ); | |
| 206 | + } | |
| 242 | 207 | |
| 243 | 208 | // Split into three parts: R, G and B |
| 244 | 209 | $color_parts = str_split( $hex, 2 ); |
| 245 | - $return = '#'; | |
| 210 | + $return = '#'; | |
| 246 | 211 | |
| 247 | 212 | foreach ( $color_parts as $color ) { |
| 248 | - $color = hexdec( $color ); // Convert to decimal | |
| 249 | - $color = max( 0, min( 255, $color + $steps ) ); // Adjust color | |
| 213 | + $color = hexdec( $color ); // Convert to decimal | |
| 214 | + $color = max( 0, min( 255, $color + $steps ) ); // Adjust color | |
| 250 | 215 | $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code |
| 251 | 216 | } |
| 252 | 217 | |
| 253 | 218 | return $return; |
| @@ -253,113 +218,31 @@ | ||
| 253 | 218 | return $return; |
| 254 | 219 | } |
| 255 | 220 | |
| 256 | 221 | /** |
| 257 | - * @since 6.0 | |
| 258 | - * | |
| 259 | - * @param string $color | |
| 260 | - * @return int | |
| 261 | - */ | |
| 262 | - public static function get_color_brightness( $color ) { | |
| 263 | - if ( 0 === strpos( $color, 'rgb' ) ) { | |
| 264 | - $color = self::rgb_to_hex( $color ); | |
| 265 | - } | |
| 266 | - | |
| 267 | - self::fill_hex( $color ); | |
| 268 | - | |
| 269 | - $c_r = hexdec( substr( $color, 0, 2 ) ); | |
| 270 | - $c_g = hexdec( substr( $color, 2, 2 ) ); | |
| 271 | - $c_b = hexdec( substr( $color, 4, 2 ) ); | |
| 272 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; | |
| 273 | - | |
| 274 | - return $brightness; | |
| 275 | - } | |
| 276 | - | |
| 277 | - /** | |
| 278 | - * Change a 3 character hex color to a 6 character one. | |
| 279 | - * | |
| 280 | - * @since 6.0 | |
| 281 | - * | |
| 282 | - * @return array | |
| 283 | - */ | |
| 284 | - private static function fill_hex( &$color ) { | |
| 285 | - if ( 3 === strlen( $color ) ) { | |
| 286 | - $color = $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2]; | |
| 287 | - } | |
| 288 | - } | |
| 289 | - | |
| 290 | - /** | |
| 291 | - * @since 4.05.02 | |
| 292 | - */ | |
| 293 | - public static function get_css_vars( $vars = array() ) { | |
| 294 | - $vars = apply_filters( 'frm_css_vars', $vars ); | |
| 295 | - return array_unique( $vars ); | |
| 296 | - } | |
| 297 | - | |
| 298 | - /** | |
| 299 | - * @since 4.05.02 | |
| 300 | - */ | |
| 301 | - public static function output_vars( $settings, $defaults = array(), $vars = array() ) { | |
| 302 | - if ( empty( $vars ) ) { | |
| 303 | - $vars = self::get_css_vars( array_keys( $settings ) ); | |
| 304 | - } | |
| 305 | - $remove = array( 'remove_box_shadow', 'remove_box_shadow_active', 'theme_css', 'theme_name', 'theme_selector', 'important_style', 'submit_style', 'collapse_icon', 'center_form', 'custom_css', 'style_class', 'submit_bg_img', 'change_margin', 'repeat_icon' ); | |
| 306 | - $vars = array_diff( $vars, $remove ); | |
| 307 | - | |
| 308 | - foreach ( $vars as $var ) { | |
| 309 | - if ( ! isset( $settings[ $var ] ) ) { | |
| 310 | - continue; | |
| 311 | - } | |
| 312 | - if ( ! isset( $defaults[ $var ] ) ) { | |
| 313 | - $defaults[ $var ] = ''; | |
| 314 | - } | |
| 315 | - $show = empty( $defaults ) || ( $settings[ $var ] !== '' && $settings[ $var ] !== $defaults[ $var ] ); | |
| 316 | - if ( $show ) { | |
| 317 | - echo '--' . esc_html( str_replace( '_', '-', $var ) ) . ':' . ( $var === 'font' ? FrmAppHelper::kses( $settings[ $var ] ) : esc_html( $settings[ $var ] ) ) . ';'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 318 | - } | |
| 319 | - } | |
| 320 | - } | |
| 321 | - | |
| 322 | - /** | |
| 323 | 222 | * @since 2.3 |
| 324 | - * | |
| 325 | - * @param WP_Post $style | |
| 326 | - * @return array | |
| 327 | 223 | */ |
| 328 | 224 | public static function get_settings_for_output( $style ) { |
| 329 | 225 | if ( self::previewing_style() ) { |
| 330 | - $frm_style = new FrmStyle(); | |
| 331 | - if ( isset( $_POST['frm_style_setting'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 332 | - | |
| 333 | - // Sanitizing is done later. | |
| 334 | - $posted = wp_unslash( $_POST['frm_style_setting'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing | |
| 335 | - if ( ! is_array( $posted ) ) { | |
| 336 | - $posted = json_decode( $posted, true ); | |
| 337 | - FrmAppHelper::format_form_data( $posted ); | |
| 338 | - $settings = $frm_style->sanitize_post_content( $posted['frm_style_setting']['post_content'] ); | |
| 339 | - $style_name = sanitize_title( $posted['style_name'] ); | |
| 340 | - } else { | |
| 341 | - $settings = $frm_style->sanitize_post_content( $posted['post_content'] ); | |
| 342 | - $style_name = FrmAppHelper::get_post_param( 'style_name', '', 'sanitize_title' ); | |
| 343 | - } | |
| 226 | + if ( isset( $_POST['frm_style_setting'] ) && isset( $_POST['frm_style_setting']['post_content'] ) ) { | |
| 227 | + $settings = $_POST['frm_style_setting']['post_content']; | |
| 344 | 228 | } else { |
| 345 | - $settings = $frm_style->sanitize_post_content( wp_unslash( $_GET ) ); | |
| 346 | - $style_name = FrmAppHelper::get_param( 'style_name', '', 'get', 'sanitize_title' ); | |
| 229 | + $settings = $_GET; | |
| 347 | 230 | } |
| 348 | - | |
| 349 | 231 | FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings ); |
| 350 | 232 | |
| 233 | + $style_name = FrmAppHelper::get_param( 'style_name', '', 'get', 'sanitize_title' ); | |
| 351 | 234 | $settings['style_class'] = ''; |
| 352 | 235 | if ( ! empty( $style_name ) ) { |
| 353 | 236 | $settings['style_class'] = $style_name . '.'; |
| 354 | 237 | } |
| 355 | 238 | } else { |
| 356 | - $settings = $style->post_content; | |
| 239 | + $settings = $style->post_content; | |
| 357 | 240 | $settings['style_class'] = 'frm_style_' . $style->post_name . '.'; |
| 358 | 241 | } |
| 359 | 242 | |
| 360 | - $settings['style_class'] .= 'with_frm_style'; | |
| 361 | - $settings['font'] = stripslashes( $settings['font'] ); | |
| 243 | + $settings['style_class'] .= 'with_frm_style'; | |
| 244 | + $settings['font'] = stripslashes( $settings['font'] ); | |
| 362 | 245 | $settings['change_margin'] = self::description_margin_for_screensize( $settings['width'] ); |
| 363 | 246 | |
| 364 | 247 | $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' ); |
| 365 | 248 | foreach ( $checkbox_opts as $opt ) { |
| @@ -369,17 +252,8 @@ | ||
| 369 | 252 | } |
| 370 | 253 | |
| 371 | 254 | self::prepare_color_output( $settings ); |
| 372 | 255 | |
| 373 | - $settings['field_height'] = $settings['field_height'] === '' ? 'auto' : $settings['field_height']; | |
| 374 | - $settings['field_width'] = $settings['field_width'] === '' ? 'auto' : $settings['field_width']; | |
| 375 | - $settings['auto_width'] = $settings['auto_width'] ? 'auto' : $settings['field_width']; | |
| 376 | - $settings['box_shadow'] = ! empty( $settings['remove_box_shadow'] ) ? 'none' : '0 1px 1px rgba(0, 0, 0, 0.075) inset'; | |
| 377 | - | |
| 378 | - if ( ! isset( $settings['repeat_icon'] ) ) { | |
| 379 | - $settings['repeat_icon'] = 1; | |
| 380 | - } | |
| 381 | - | |
| 382 | 256 | return $settings; |
| 383 | 257 | } |
| 384 | 258 | |
| 385 | 259 | /** |
| @@ -398,32 +272,14 @@ | ||
| 398 | 272 | } |
| 399 | 273 | |
| 400 | 274 | /** |
| 401 | 275 | * @since 2.3 |
| 402 | - * | |
| 403 | - * @return array | |
| 404 | 276 | */ |
| 405 | 277 | private static function allow_color_override() { |
| 406 | 278 | $frm_style = new FrmStyle(); |
| 407 | - $colors = $frm_style->get_color_settings(); | |
| 279 | + $colors = $frm_style->get_color_settings(); | |
| 408 | 280 | |
| 409 | - $transparent = array( | |
| 410 | - 'fieldset_color', | |
| 411 | - 'fieldset_bg_color', | |
| 412 | - 'bg_color', | |
| 413 | - 'bg_color_active', | |
| 414 | - 'bg_color_disabled', | |
| 415 | - 'section_bg_color', | |
| 416 | - 'error_bg', | |
| 417 | - 'success_bg_color', | |
| 418 | - 'progress_bg_color', | |
| 419 | - 'progress_active_bg_color', | |
| 420 | - 'submit_border_color', | |
| 421 | - 'submit_hover_border_color', | |
| 422 | - 'submit_active_border_color', | |
| 423 | - 'submit_hover_bg_color', | |
| 424 | - 'submit_active_bg_color', | |
| 425 | - ); | |
| 281 | + $transparent = array( 'fieldset_color', 'fieldset_bg_color', 'bg_color', 'section_bg_color', 'error_bg', 'success_bg_color', 'progress_bg_color', 'progress_active_bg_color' ); | |
| 426 | 282 | |
| 427 | 283 | return array( |
| 428 | 284 | 'transparent' => $transparent, |
| 429 | 285 | '' => array_diff( $colors, $transparent ), |
| @@ -436,12 +292,9 @@ | ||
| 436 | 292 | private static function get_color_output( $default, &$color ) { |
| 437 | 293 | $color = trim( $color ); |
| 438 | 294 | if ( empty( $color ) ) { |
| 439 | 295 | $color = $default; |
| 440 | - } elseif ( false !== strpos( $color, 'rgb(' ) ) { | |
| 441 | - $color = str_replace( 'rgb(', 'rgba(', $color ); | |
| 442 | - $color = str_replace( ')', ',1)', $color ); | |
| 443 | - } elseif ( strpos( $color, '#' ) === false && false === strpos( $color, 'rgba(' ) ) { | |
| 296 | + } elseif ( strpos( $color, '#' ) === false ) { | |
| 444 | 297 | $color = '#' . $color; |
| 445 | 298 | } |
| 446 | 299 | } |
| 447 | 300 | |
| @@ -452,174 +305,33 @@ | ||
| 452 | 305 | * @since 2.3 |
| 453 | 306 | */ |
| 454 | 307 | private static function description_margin_for_screensize( $width ) { |
| 455 | 308 | $temp_label_width = str_replace( 'px', '', $width ); |
| 456 | - $change_margin = false; | |
| 309 | + $change_margin = false; | |
| 457 | 310 | if ( $temp_label_width >= 230 ) { |
| 458 | 311 | $change_margin = '800px'; |
| 459 | - } elseif ( $width >= 215 ) { | |
| 312 | + } else if ( $width >= 215 ) { | |
| 460 | 313 | $change_margin = '700px'; |
| 461 | - } elseif ( $width >= 180 ) { | |
| 314 | + } else if ( $width >= 180 ) { | |
| 462 | 315 | $change_margin = '650px'; |
| 463 | 316 | } |
| 464 | - | |
| 465 | 317 | return $change_margin; |
| 466 | 318 | } |
| 467 | 319 | |
| 468 | 320 | /** |
| 469 | 321 | * @since 2.3 |
| 470 | - * | |
| 471 | - * @return bool | |
| 472 | 322 | */ |
| 473 | 323 | public static function previewing_style() { |
| 474 | - $ajax_change = isset( $_POST['action'] ) && $_POST['action'] === 'frm_change_styling' && isset( $_POST['frm_style_setting'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 475 | - | |
| 324 | + $ajax_change = isset( $_POST['action'] ) && $_POST['action'] === 'frm_change_styling' && isset( $_POST['frm_style_setting'] ); | |
| 476 | 325 | return $ajax_change || isset( $_GET['flat'] ); |
| 477 | 326 | } |
| 478 | 327 | |
| 479 | 328 | /** |
| 480 | - * @since 5.5.1 | |
| 481 | - * @return void | |
| 482 | - */ | |
| 483 | - public static function maybe_include_font_icon_css() { | |
| 484 | - $signature_add_on_is_active = class_exists( 'FrmSigAppHelper', false ); | |
| 485 | - | |
| 486 | - if ( ! FrmAppHelper::pro_is_installed() && ! $signature_add_on_is_active ) { | |
| 487 | - // If Pro and Signatures are both not active, there is no need to include the font icon CSS in lite. | |
| 488 | - return; | |
| 489 | - } | |
| 490 | - | |
| 491 | - $pro_version_will_handle_loading = false; | |
| 492 | - | |
| 493 | - if ( class_exists( 'FrmProDb', false ) ) { | |
| 494 | - $pro_version_that_includes_font_icons_css = '5.5.1'; | |
| 495 | - | |
| 496 | - // Include font icons in Lite for backward compatibility with older version of Pro. | |
| 497 | - $pro_version_will_handle_loading = version_compare( FrmProDb::$plug_version, $pro_version_that_includes_font_icons_css, '>=' ); | |
| 498 | - } | |
| 499 | - | |
| 500 | - $load_it_here = false; | |
| 501 | - if ( ! $pro_version_will_handle_loading ) { | |
| 502 | - // If Pro is not handling it, we still need to include it for the Signature add on. | |
| 503 | - $load_it_here = $signature_add_on_is_active; | |
| 504 | - } | |
| 505 | - | |
| 506 | - if ( $load_it_here ) { | |
| 507 | - readfile( FrmAppHelper::plugin_path() . '/css/font_icons.css' ); | |
| 508 | - } | |
| 509 | - } | |
| 510 | - | |
| 511 | - /** | |
| 512 | - * Get the URL for the Styler page list view (where you can assign styles to a form and view style templates) for a target form. | |
| 513 | - * | |
| 514 | - * @since 6.0 | |
| 515 | - * | |
| 516 | - * @param string|int $form_id | |
| 517 | - * @return string | |
| 518 | - */ | |
| 519 | - public static function get_list_url( $form_id ) { | |
| 520 | - return admin_url( 'admin.php?page=formidable-styles&form=' . absint( $form_id ) ); | |
| 521 | - } | |
| 522 | - | |
| 523 | - /** | |
| 524 | - * Get a link to edit a target style post object in the visual styler. | |
| 525 | - * | |
| 526 | - * @param WP_Post|stdClass $style | |
| 527 | - * @param string|int $form_id Used for the back button and preview form target. | |
| 528 | - * @return string | |
| 529 | - */ | |
| 530 | - public static function get_edit_url( $style, $form_id = 0 ) { | |
| 531 | - $query_args = array( | |
| 532 | - 'page' => 'formidable-styles', | |
| 533 | - 'frm_action' => 'edit', | |
| 534 | - 'id' => $style->ID, | |
| 535 | - ); | |
| 536 | - | |
| 537 | - if ( $form_id ) { | |
| 538 | - // We include &form_id for the back button to know where to point to. | |
| 539 | - $query_args['form'] = $form_id; | |
| 540 | - } | |
| 541 | - | |
| 542 | - return add_query_arg( $query_args, admin_url( 'admin.php' ) ); | |
| 543 | - } | |
| 544 | - | |
| 545 | - /** | |
| 546 | - * Get a count of the number of forms assigned to a target style ID. | |
| 547 | - * All unassigned forms are included in the count for the default style. | |
| 548 | - * | |
| 549 | - * @since 6.0 | |
| 550 | - * | |
| 551 | - * @param string|int $style_id | |
| 552 | - * @param bool $is_default | |
| 553 | - * @return int | |
| 554 | - */ | |
| 555 | - public static function get_form_count_for_style( $style_id, $is_default ) { | |
| 556 | - $serialized = serialize( array( 'custom_style' => (string) $style_id ) ); | |
| 557 | - $substring = substr( $serialized, 5, -1 ); // Chop off the "a:1:{" from the front and the "}" from the back. | |
| 558 | - $number_of_forms = FrmDb::get_count( | |
| 559 | - 'frm_forms', | |
| 560 | - array( | |
| 561 | - 'status' => 'published', | |
| 562 | - 'options LIKE' => $substring, | |
| 563 | - ) | |
| 564 | - ); | |
| 565 | - | |
| 566 | - if ( ! $is_default ) { | |
| 567 | - // Exit early as the rest of the code is about including the default count. | |
| 568 | - return $number_of_forms; | |
| 569 | - } | |
| 570 | - | |
| 571 | - $conversational_style_id = FrmDb::get_var( 'posts', array( 'post_name' => 'lines-no-boxes' ), 'ID' ); | |
| 572 | - $number_of_forms += self::get_default_style_count( $style_id, $conversational_style_id ); | |
| 573 | - | |
| 574 | - return $number_of_forms; | |
| 575 | - } | |
| 576 | - | |
| 577 | - /** | |
| 578 | - * Get the number of forms that use the default style. | |
| 579 | - * | |
| 580 | - * @since 6.0 | |
| 581 | - * | |
| 582 | - * @param string|int $style_id | |
| 583 | - * @param mixed $conversational_style_id | |
| 584 | - * @return int | |
| 585 | - */ | |
| 586 | - private static function get_default_style_count( $style_id, $conversational_style_id ) { | |
| 587 | - $substrings = array_map( | |
| 588 | - function( $value ) { | |
| 589 | - $substring = serialize( array( 'custom_style' => $value ) ); | |
| 590 | - return substr( $substring, 5, -1 ); | |
| 591 | - }, | |
| 592 | - array( '1', 1 ) | |
| 593 | - ); | |
| 594 | - $where = array( | |
| 595 | - 'status' => 'published', | |
| 596 | - 0 => array( | |
| 597 | - 'options NOT LIKE' => 'custom_style', | |
| 598 | - 'or' => 1, | |
| 599 | - 'options LIKE' => $substrings, | |
| 600 | - ), | |
| 601 | - ); | |
| 602 | - | |
| 603 | - if ( $conversational_style_id ) { | |
| 604 | - // When a conversational style is set, check for it in the query by wrapping the where and adding a conversational option check. | |
| 605 | - $is_conversational_style = (int) $style_id === (int) $conversational_style_id; | |
| 606 | - $where[0] = array( | |
| 607 | - // The chat option doesn't exist if it isn't on. | |
| 608 | - ( $is_conversational_style ? 'options LIKE' : 'options NOT LIKE' ) => ';s:4:"chat";', | |
| 609 | - $where[0], | |
| 610 | - ); | |
| 611 | - } | |
| 612 | - | |
| 613 | - return FrmDb::get_count( 'frm_forms', $where ); | |
| 614 | - } | |
| 615 | - | |
| 616 | - /** | |
| 617 | 329 | * @deprecated 3.01 |
| 618 | 330 | * @codeCoverageIgnore |
| 619 | 331 | */ |
| 620 | 332 | public static function get_sigle_label_postitions() { |
| 621 | - return FrmDeprecated::get_sigle_label_postitions(); | |
| 333 | + return FrmDeprecated::get_single_label_positions(); | |
| 622 | 334 | } |
| 623 | 335 | |
| 624 | 336 | /** |
| 625 | 337 | * @deprecated 3.02.03 |
| @@ -650,52 +362,6 @@ | ||
| 650 | 362 | * @codeCoverageIgnore |
| 651 | 363 | */ |
| 652 | 364 | public static function get_form_for_page() { |
| 653 | 365 | return FrmDeprecated::get_form_for_page(); |
| 654 | - } | |
| 655 | - | |
| 656 | - /** | |
| 657 | - * @since 4.0 | |
| 658 | - * @deprecated 6.0 The style menu is no longer used in the styler. | |
| 659 | - * | |
| 660 | - * @param string $active | |
| 661 | - * @return string | |
| 662 | - */ | |
| 663 | - public static function get_style_menu( $active = '' ) { | |
| 664 | - _deprecated_function( __METHOD__, '6.0' ); | |
| 665 | - return ''; | |
| 666 | - } | |
| 667 | - | |
| 668 | - /** | |
| 669 | - * @deprecated 6.0 The style menu is no longer used in the styler. | |
| 670 | - * | |
| 671 | - * @param string $active | |
| 672 | - * @return void | |
| 673 | - */ | |
| 674 | - public static function style_menu( $active = '' ) { | |
| 675 | - _deprecated_function( __METHOD__, '6.0' ); | |
| 676 | - } | |
| 677 | - | |
| 678 | - /** | |
| 679 | - * Either get the heading or the style switcher. | |
| 680 | - * | |
| 681 | - * @since 4.0 | |
| 682 | - * @deprecated 6.0 The style switcher was replaced with a form switcher and is no longer used. | |
| 683 | - * | |
| 684 | - * @param array $atts | |
| 685 | - * @return void | |
| 686 | - */ | |
| 687 | - public static function styler_switcher( $atts ) { | |
| 688 | - _deprecated_function( __METHOD__, '6.0' ); | |
| 689 | - } | |
| 690 | - | |
| 691 | - /** | |
| 692 | - * @since 4.0 | |
| 693 | - * @deprecated 6.0 The styler now uses the Embed/Preview/Update header. It uses the same save button as other pages with Form tabs. | |
| 694 | - * | |
| 695 | - * @param array $atts | |
| 696 | - * @return void | |
| 697 | - */ | |
| 698 | - public static function styler_save_button( $atts ) { | |
| 699 | - _deprecated_function( __METHOD__, '6.0' ); | |
| 700 | 366 | } |
| 701 | 367 | } |