/home/altere25/infinet.finance/wp-content/plugins/formidable/classes/helpers
Edit: /home/altere25/infinet.finance/wp-content/plugins/formidable/classes/helpers/FrmStylesHelper.php (19655B)
__( 'top', 'formidable' ),
'left' => __( 'left', 'formidable' ),
'right' => __( 'right', 'formidable' ),
'no_label' => __( 'none', 'formidable' ),
'inside' => __( 'inside', 'formidable' ),
);
}
public static function get_single_label_positions() {
return array(
'top' => __( 'Top', 'formidable' ),
'left' => __( 'Left', 'formidable' ),
'right' => __( 'Right', 'formidable' ),
'inline' => __( 'Inline (left without a set width)', 'formidable' ),
'none' => __( 'None', 'formidable' ),
'hidden' => __( 'Hidden (but leave the space)', 'formidable' ),
'inside' => __( 'Placeholder inside the field', 'formidable' ),
);
}
public static function minus_icons() {
return array(
0 => array(
'-' => '62e',
'+' => '62f',
),
1 => array(
'-' => '600',
'+' => '602',
),
2 => array(
'-' => '604',
'+' => '603',
),
3 => array(
'-' => '633',
'+' => '632',
),
4 => array(
'-' => '613',
'+' => '60f',
),
);
}
public static function arrow_icons() {
$minus_icons = self::minus_icons();
return array(
6 => array(
'-' => '62d',
'+' => '62a',
),
0 => array(
'-' => '60d',
'+' => '609',
),
1 => array(
'-' => '60e',
'+' => '60c',
),
2 => array(
'-' => '630',
'+' => '631',
),
3 => array(
'-' => '62b',
'+' => '628',
),
4 => array(
'-' => '62c',
'+' => '629',
),
5 => array(
'-' => '635',
'+' => '634',
),
'p0' => $minus_icons[0],
'p1' => $minus_icons[1],
'p2' => $minus_icons[2],
'p3' => $minus_icons[3],
'p4' => $minus_icons[4],
);
}
/**
* @since 2.0
* @return string The class for this icon.
*/
public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) {
if ( 'arrow' === $type && is_numeric( $key ) ) {
//frm_arrowup6_icon
$arrow = array(
'-' => 'down',
'+' => 'up',
);
$class = 'frm_arrow' . $arrow[ $icon ];
} else {
//frm_minus1_icon
$key = str_replace( 'p', '', $key );
$plus = array(
'-' => 'minus',
'+' => 'plus',
);
$class = 'frm_' . $plus[ $icon ];
}
if ( $key ) {
$class .= $key;
}
$class .= '_icon';
return $class;
}
/**
* @param WP_Post $style
* @param FrmStyle $frm_style
* @param string $type
* @return void
*/
public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) {
$function_name = $type . '_icons';
$icons = self::$function_name();
unset( $function_name );
$name = 'arrow' === $type ? 'collapse_icon' : 'repeat_icon';
?>
sanitize_post_content( $posted['frm_style_setting']['post_content'] );
$style_name = sanitize_title( $posted['style_name'] );
} else {
$settings = $frm_style->sanitize_post_content( $posted['post_content'] );
$style_name = FrmAppHelper::get_post_param( 'style_name', '', 'sanitize_title' );
}
} else {
$settings = $frm_style->sanitize_post_content( wp_unslash( $_GET ) );
$style_name = FrmAppHelper::get_param( 'style_name', '', 'get', 'sanitize_title' );
}
FrmAppHelper::sanitize_value( 'sanitize_text_field', $settings );
$settings['style_class'] = '';
if ( ! empty( $style_name ) ) {
$settings['style_class'] = $style_name . '.';
}
} else {
$settings = $style->post_content;
$settings['style_class'] = 'frm_style_' . $style->post_name . '.';
}
$settings['style_class'] .= 'with_frm_style';
$settings['font'] = stripslashes( $settings['font'] );
$settings['change_margin'] = self::description_margin_for_screensize( $settings['width'] );
$checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' );
foreach ( $checkbox_opts as $opt ) {
if ( ! isset( $settings[ $opt ] ) ) {
$settings[ $opt ] = 0;
}
}
self::prepare_color_output( $settings );
$settings['field_height'] = $settings['field_height'] === '' ? 'auto' : $settings['field_height'];
$settings['field_width'] = $settings['field_width'] === '' ? 'auto' : $settings['field_width'];
$settings['auto_width'] = $settings['auto_width'] ? 'auto' : $settings['field_width'];
$settings['box_shadow'] = ! empty( $settings['remove_box_shadow'] ) ? 'none' : '0 1px 1px rgba(0, 0, 0, 0.075) inset';
if ( ! isset( $settings['repeat_icon'] ) ) {
$settings['repeat_icon'] = 1;
}
return $settings;
}
/**
* @since 2.3
*/
public static function prepare_color_output( &$settings, $allow_transparent = true ) {
$colors = self::allow_color_override();
foreach ( $colors as $css => $opts ) {
if ( $css === 'transparent' && ! $allow_transparent ) {
$css = '';
}
foreach ( $opts as $opt ) {
self::get_color_output( $css, $settings[ $opt ] );
}
}
}
/**
* @since 2.3
*/
private static function allow_color_override() {
$frm_style = new FrmStyle();
$colors = $frm_style->get_color_settings();
$transparent = array(
'fieldset_color',
'fieldset_bg_color',
'bg_color',
'bg_color_active',
'bg_color_disabled',
'section_bg_color',
'error_bg',
'success_bg_color',
'progress_bg_color',
'progress_active_bg_color',
'submit_border_color',
'submit_hover_border_color',
'submit_active_border_color',
'submit_hover_bg_color',
'submit_active_bg_color',
'success_bg_color',
);
return array(
'transparent' => $transparent,
'' => array_diff( $colors, $transparent ),
);
}
/**
* @since 2.3
*/
private static function get_color_output( $default, &$color ) {
$color = trim( $color );
if ( empty( $color ) ) {
$color = $default;
} elseif ( false !== strpos( $color, 'rgb(' ) ) {
$color = str_replace( 'rgb(', 'rgba(', $color );
$color = str_replace( ')', ',1)', $color );
} elseif ( strpos( $color, '#' ) === false && false === strpos( $color, 'rgba(' ) ) {
$color = '#' . $color;
}
}
/**
* If left/right label is over a certain size,
* adjust the field description margin at a different screen size
*
* @since 2.3
*/
private static function description_margin_for_screensize( $width ) {
$temp_label_width = str_replace( 'px', '', $width );
$change_margin = false;
if ( $temp_label_width >= 230 ) {
$change_margin = '800px';
} elseif ( $width >= 215 ) {
$change_margin = '700px';
} elseif ( $width >= 180 ) {
$change_margin = '650px';
}
return $change_margin;
}
/**
* @since 2.3
*
* @return bool
*/
public static function previewing_style() {
$ajax_change = isset( $_POST['action'] ) && $_POST['action'] === 'frm_change_styling' && isset( $_POST['frm_style_setting'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
return $ajax_change || isset( $_GET['flat'] );
}
/**
* @since 5.5.1
* @return void
*/
public static function maybe_include_font_icon_css() {
$signature_add_on_is_active = class_exists( 'FrmSigAppHelper', false );
if ( ! FrmAppHelper::pro_is_installed() && ! $signature_add_on_is_active ) {
// If Pro and Signatures are both not active, there is no need to include the font icon CSS in lite.
return;
}
$pro_version_will_handle_loading = false;
if ( class_exists( 'FrmProDb', false ) ) {
$pro_version_that_includes_font_icons_css = '5.5.1';
// Include font icons in Lite for backward compatibility with older version of Pro.
$pro_version_will_handle_loading = version_compare( FrmProDb::$plug_version, $pro_version_that_includes_font_icons_css, '>=' );
}
$load_it_here = false;
if ( ! $pro_version_will_handle_loading ) {
// If Pro is not handling it, we still need to include it for the Signature add on.
$load_it_here = $signature_add_on_is_active;
}
if ( $load_it_here ) {
readfile( FrmAppHelper::plugin_path() . '/css/font_icons.css' );
}
}
/**
* 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.
*
* @since 6.0
*
* @param string|int $form_id
* @return string
*/
public static function get_list_url( $form_id ) {
return admin_url( 'admin.php?page=formidable-styles&form=' . absint( $form_id ) );
}
/**
* Get a link to edit a target style post object in the visual styler.
*
* @param WP_Post|stdClass $style
* @param string|int $form_id Used for the back button and preview form target.
* @return string
*/
public static function get_edit_url( $style, $form_id = 0 ) {
$query_args = array(
'page' => 'formidable-styles',
'frm_action' => 'edit',
'id' => $style->ID,
);
if ( $form_id ) {
// We include &form_id for the back button to know where to point to.
$query_args['form'] = $form_id;
}
return add_query_arg( $query_args, admin_url( 'admin.php' ) );
}
/**
* Get a count of the number of forms assigned to a target style ID.
* All unassigned forms are included in the count for the default style.
*
* @since 6.0
*
* @param string|int $style_id
* @param bool $is_default
* @return int
*/
public static function get_form_count_for_style( $style_id, $is_default ) {
$serialized = serialize( array( 'custom_style' => (string) $style_id ) );
$substring = substr( $serialized, 5, -1 ); // Chop off the "a:1:{" from the front and the "}" from the back.
$number_of_forms = FrmDb::get_count(
'frm_forms',
array(
'status' => 'published',
'options LIKE' => $substring,
)
);
if ( ! $is_default ) {
// Exit early as the rest of the code is about including the default count.
return $number_of_forms;
}
$conversational_style_id = FrmDb::get_var( 'posts', array( 'post_name' => 'lines-no-boxes' ), 'ID' );
$number_of_forms += self::get_default_style_count( $style_id, $conversational_style_id );
return $number_of_forms;
}
/**
* Get the number of forms that use the default style.
*
* @since 6.0
*
* @param string|int $style_id
* @param mixed $conversational_style_id
* @return int
*/
private static function get_default_style_count( $style_id, $conversational_style_id ) {
$substrings = array_map(
function( $value ) {
$substring = serialize( array( 'custom_style' => $value ) );
return substr( $substring, 5, -1 );
},
array( '1', 1 )
);
$where = array(
'status' => 'published',
0 => array(
'options NOT LIKE' => 'custom_style',
'or' => 1,
'options LIKE' => $substrings,
),
);
if ( $conversational_style_id ) {
// When a conversational style is set, check for it in the query by wrapping the where and adding a conversational option check.
$is_conversational_style = (int) $style_id === (int) $conversational_style_id;
$where[0] = array(
// The chat option doesn't exist if it isn't on.
( $is_conversational_style ? 'options LIKE' : 'options NOT LIKE' ) => ';s:4:"chat";',
$where[0],
);
}
return FrmDb::get_count( 'frm_forms', $where );
}
/**
* @deprecated 3.01
* @codeCoverageIgnore
*/
public static function get_sigle_label_postitions() {
return FrmDeprecated::get_sigle_label_postitions();
}
/**
* @deprecated 3.02.03
* @codeCoverageIgnore
*/
public static function jquery_themes() {
return FrmDeprecated::jquery_themes();
}
/**
* @deprecated 3.02.03
* @codeCoverageIgnore
*/
public static function jquery_css_url( $theme_css ) {
return FrmDeprecated::jquery_css_url( $theme_css );
}
/**
* @deprecated 3.02.03
* @codeCoverageIgnore
*/
public static function enqueue_jquery_css() {
FrmDeprecated::enqueue_jquery_css();
}
/**
* @deprecated 3.02.03
* @codeCoverageIgnore
*/
public static function get_form_for_page() {
return FrmDeprecated::get_form_for_page();
}
/**
* @since 4.0
* @deprecated 6.0 The style menu is no longer used in the styler.
*
* @param string $active
* @return string
*/
public static function get_style_menu( $active = '' ) {
_deprecated_function( __METHOD__, '6.0' );
return '';
}
/**
* @deprecated 6.0 The style menu is no longer used in the styler.
*
* @param string $active
* @return void
*/
public static function style_menu( $active = '' ) {
_deprecated_function( __METHOD__, '6.0' );
}
/**
* Either get the heading or the style switcher.
*
* @since 4.0
* @deprecated 6.0 The style switcher was replaced with a form switcher and is no longer used.
*
* @param array $atts
* @return void
*/
public static function styler_switcher( $atts ) {
_deprecated_function( __METHOD__, '6.0' );
}
/**
* @since 4.0
* @deprecated 6.0 The styler now uses the Embed/Preview/Update header. It uses the same save button as other pages with Form tabs.
*
* @param array $atts
* @return void
*/
public static function styler_save_button( $atts ) {
_deprecated_function( __METHOD__, '6.0' );
}
}