/home/altere25/infinet.finance/wp-content/plugins/formidable/classes/helpers
Edit: /home/altere25/infinet.finance/wp-content/plugins/formidable/classes/helpers/FrmAppHelper.php (112842B)
'WordPress',
'utm_medium' => $medium,
'utm_campaign' => 'liteplugin',
);
if ( isset( $content ) ) {
$query_args['utm_content'] = $content;
}
if ( is_array( $args ) && isset( $args['param'] ) ) {
$query_args['f'] = $args['param'];
}
if ( is_array( $args ) && ! empty( $args['plan'] ) ) {
$query_args['plan'] = $args['plan'];
}
$link = add_query_arg( $query_args, $page ) . $anchor;
return self::make_affiliate_url( $link );
}
/**
* Get the Formidable settings
*
* @since 2.0
*
* @param array $args - May include the form id when values need translation.
* @return FrmSettings $frm_setings
*/
public static function get_settings( $args = array() ) {
global $frm_settings;
if ( empty( $frm_settings ) ) {
$frm_settings = new FrmSettings( $args );
} elseif ( isset( $args['current_form'] ) ) {
// If the global has already been set, allow strings to be filtered.
$frm_settings->maybe_filter_for_form( $args );
}
return $frm_settings;
}
public static function get_menu_name() {
$frm_settings = self::get_settings();
return $frm_settings->menu;
}
/**
* @since 3.05
*/
public static function svg_logo( $atts = array() ) {
$defaults = array(
'height' => 18,
'width' => 18,
'fill' => '#4d4d4d',
'orange' => '#f05a24',
);
$atts = array_merge( $defaults, $atts );
return '
';
}
/**
* @since 4.0
*/
public static function show_logo( $atts = array() ) {
echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* @since 4.03.02
*/
public static function show_header_logo() {
$icon = self::svg_logo(
array(
'height' => 35,
'width' => 35,
)
);
$new_icon = apply_filters( 'frm_icon', $icon, true );
if ( $new_icon !== $icon ) {
if ( strpos( $new_icon, '
';
}
}
echo self::kses( $icon, 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* @since 2.02.04
*/
public static function ips_saved() {
$frm_settings = self::get_settings();
return ! $frm_settings->no_ips;
}
public static function pro_is_installed() {
return apply_filters( 'frm_pro_installed', false );
}
/**
* @since 4.06.02
*/
public static function pro_is_connected() {
global $frm_vars;
return self::pro_is_installed() && $frm_vars['pro_is_authorized'];
}
/**
* @since 4.06
*/
public static function is_form_builder_page() {
$action = self::simple_get( 'frm_action', 'sanitize_title' );
return self::is_admin_page( 'formidable' ) && ( $action === 'edit' || $action === 'settings' || $action === 'duplicate' );
}
public static function is_formidable_admin() {
$page = self::simple_get( 'page', 'sanitize_title' );
$is_formidable = strpos( $page, 'formidable' ) !== false;
if ( empty( $page ) ) {
$is_formidable = self::is_view_builder_page();
}
return $is_formidable;
}
/**
* Check for certain page in Formidable settings
*
* @since 2.0
*
* @param string $page The name of the page to check
*
* @return boolean
*/
public static function is_admin_page( $page = 'formidable' ) {
global $pagenow;
$get_page = self::simple_get( 'page', 'sanitize_title' );
if ( $pagenow ) {
// allow this to be true during ajax load i.e. ajax form builder loading
$is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page;
if ( $is_page ) {
return true;
}
}
return is_admin() && $get_page === $page;
}
/**
* If the current page is for editing or creating a view.
* Returns false for the views listing page.
*
* @since 4.0
*/
public static function is_view_builder_page() {
global $pagenow;
if ( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' && $pagenow !== 'edit.php' ) {
return false;
}
$post_type = self::simple_get( 'post_type', 'sanitize_title' );
if ( empty( $post_type ) ) {
$post_id = self::simple_get( 'post', 'absint' );
$post = get_post( $post_id );
$post_type = $post ? $post->post_type : '';
}
return $post_type === 'frm_display';
}
/**
* Check for the form preview page
*
* @since 2.0
*
* @param None
*
* @return boolean
*/
public static function is_preview_page() {
global $pagenow;
$action = self::simple_get( 'action', 'sanitize_title' );
return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
}
/**
* Check for ajax except the form preview page
*
* @since 2.0
*
* @param None
*
* @return boolean
*/
public static function doing_ajax() {
return wp_doing_ajax() && ! self::is_preview_page();
}
public static function js_suffix() {
return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
}
/**
* @since 2.0.8
*/
public static function prevent_caching() {
global $frm_vars;
return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
}
/**
* Check if on an admin page
*
* @since 2.0
*
* @return boolean
*/
public static function is_admin() {
$is_admin = is_admin() && ! wp_doing_ajax();
/**
* @since 6.0
* @param bool $is_admin
*/
return apply_filters( 'frm_is_admin', $is_admin );
}
/**
* Check if value contains blank value or empty array
*
* @since 2.0
*
* @param mixed $value - value to check
* @param string
*
* @return boolean
*/
public static function is_empty_value( $value, $empty = '' ) {
return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
}
public static function is_not_empty_value( $value, $empty = '' ) {
return ! self::is_empty_value( $value, $empty );
}
/**
* Get any value from the $_SERVER
*
* @since 2.0
*
* @param string $value
*
* @return string
*/
public static function get_server_value( $value ) {
return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : '';
}
/**
* Check for the IP address in several places (when custom headers are enabled).
* Used by [ip] shortcode.
*
* @return string The IP address of the current user
*/
public static function get_ip_address() {
$ip_options = self::should_use_custom_header_ip() ? self::get_custom_header_keys_for_ip() : array( 'REMOTE_ADDR' );
$ip = '';
foreach ( $ip_options as $key ) {
if ( ! isset( $_SERVER[ $key ] ) ) {
continue;
}
$key = self::get_server_value( $key );
foreach ( explode( ',', $key ) as $ip ) {
$ip = trim( $ip ); // Just to be safe.
if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
return sanitize_text_field( $ip );
}
}
}
return sanitize_text_field( $ip );
}
/**
* @since 6.1
*
* @return array
*/
public static function get_custom_header_keys_for_ip() {
return array(
'HTTP_CLIENT_IP',
'HTTP_CF_CONNECTING_IP',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_X_CLUSTER_CLIENT_IP',
'HTTP_X_REAL_IP',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'REMOTE_ADDR',
);
}
/**
* Check if we should check every HTTP header or just $_SERVER['REMOTE_ADDR'].
* The other HTTP headers can be spoofed so this isn't recommended.
* But in some cases (like reverse proxies), the IP may be empty if you use $_SERVER['REMOTE_ADDR'].
*
* @since 6.1
*
* @return bool
*/
private static function should_use_custom_header_ip() {
$settings = self::get_settings();
$should_use_custom_header_ip = ! $settings->no_ips && $settings->custom_header_ip;
/**
* Filter whether to check spoofable HTTP headers.
* This uses the custom_header_ip setting, but it is hidden if the GDPR option is also on.
* As the IP is still checked for blacklist checks, someone with the GDPR option may still want to enable this when behind a reverse proxy.
*
* @since 6.1
*
* @param bool $should_use_custom_header_ip
*/
return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip );
}
public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
if ( strpos( $param, '[' ) ) {
$params = explode( '[', $param );
$param = $params[0];
}
if ( $src === 'get' ) {
$value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
}
self::sanitize_value( $sanitize, $value );
} else {
$value = self::get_simple_request(
array(
'type' => $src,
'param' => $param,
'default' => $default,
'sanitize' => $sanitize,
)
);
}
if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
foreach ( $params as $k => $p ) {
if ( ! $k || ! is_array( $value ) ) {
continue;
}
$p = trim( $p, ']' );
$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
}
}
return $value;
}
public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) {
return self::get_simple_request(
array(
'type' => 'post',
'param' => $param,
'default' => $default,
'sanitize' => $sanitize,
'serialized' => $serialized,
)
);
}
/**
* @since 2.0
*
* @param string $param
* @param string $sanitize
* @param string $default
*
* @return string|array
*/
public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
return self::get_simple_request(
array(
'type' => 'get',
'param' => $param,
'default' => $default,
'sanitize' => $sanitize,
)
);
}
/**
* Get a GET/POST/REQUEST value and sanitize it
*
* @since 2.0.6
*
* @param array $args
*
* @return string|array
*/
public static function get_simple_request( $args ) {
$defaults = array(
'param' => '',
'default' => '',
'type' => 'get',
'sanitize' => 'sanitize_text_field',
'serialized' => false,
);
$args = wp_parse_args( $args, $defaults );
$value = $args['default'];
if ( $args['type'] == 'get' ) {
if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
$value = wp_unslash( $_GET[ $args['param'] ] );
}
} elseif ( $args['type'] == 'post' ) {
if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
$value = wp_unslash( $_POST[ $args['param'] ] );
if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
self::unserialize_or_decode( $value );
}
}
} else {
if ( isset( $_REQUEST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$value = wp_unslash( $_REQUEST[ $args['param'] ] );
}
}
self::sanitize_value( $args['sanitize'], $value );
return $value;
}
/**
* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
*
* @since 2.0.8
*
* @param string $value
*
* @return string $value
*/
public static function preserve_backslashes( $value ) {
// If backslashes have already been added, don't add them again
if ( strpos( $value, '\\\\' ) === false ) {
$value = addslashes( $value );
}
return $value;
}
public static function sanitize_value( $sanitize, &$value ) {
if ( ! empty( $sanitize ) ) {
if ( is_array( $value ) ) {
$temp_values = $value;
foreach ( $temp_values as $k => $v ) {
self::sanitize_value( $sanitize, $value[ $k ] );
}
} else {
$value = call_user_func( $sanitize, $value );
}
}
}
public static function sanitize_request( $sanitize_method, &$values ) {
$temp_values = $values;
foreach ( $temp_values as $k => $val ) {
if ( isset( $sanitize_method[ $k ] ) ) {
$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
}
}
}
/**
* @since 4.0.04
*/
public static function sanitize_with_html( &$value ) {
self::sanitize_value( 'wp_kses_post', $value );
self::decode_specialchars( $value );
}
/**
* Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&'
* this MUST be done, else we'll be back to the '& entity' problem.
*
* @since 4.0.04
*/
public static function decode_specialchars( &$value ) {
if ( is_array( $value ) ) {
$temp_values = $value;
foreach ( $temp_values as $k => $v ) {
self::decode_specialchars( $value[ $k ] );
}
} else {
self::decode_amp( $value );
}
}
/**
* The wp_specialchars_decode function changes too much.
* This will leave HTML as is, but still convert &.
* Adapted from wp_specialchars_decode().
*
* @since 4.03.01
*
* @param string $string The string to prep.
*/
private static function decode_amp( &$string ) {
// Don't bother if there are no entities - saves a lot of processing
if ( empty( $string ) || strpos( $string, '&' ) === false ) {
return;
}
$translation = array(
'"' => '"',
'"' => '"',
'"' => '"',
'< ' => '< ', // The space preserves the HTML.
'< ' => '< ', // The space preserves the HTML.
'>' => '>',
'>' => '>',
'&' => '&',
'&' => '&',
'&' => '&',
);
$translation_preg = array(
'/*34;/' => '"',
'/*22;/i' => '"',
'/*60;/' => '<',
'/*62;/' => '>',
'/*38;/' => '&',
'/*26;/i' => '&',
);
// Remove zero padding on numeric entities
$string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string );
// Replace characters according to translation table
$string = strtr( $string, $translation );
}
/**
* Sanitize the value, and allow some HTML
*
* @since 2.0
*
* @param string $value
* @param array|string $allowed 'all' for everything included as defaults
*
* @return string
*/
public static function kses( $value, $allowed = array() ) {
$allowed_html = self::allowed_html( $allowed );
return wp_kses( $value, $allowed_html );
}
/**
* The regular kses function strips [button_action] from submit button HTML.
*
* @since 5.0.13
*
* @param string $html
* @return string
*/
public static function kses_submit_button( $html ) {
$included_button_action = false !== strpos( $html, '[button_action]' );
$included_back_hook = false !== strpos( $html, '[back_hook]' );
$included_draft_hook = false !== strpos( $html, '[draft_hook]' );
add_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
$html = self::kses( $html, 'all' );
remove_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
if ( $included_button_action ) {
if ( false !== strpos( $html, '