d_name] ) ? $_POST[$field_name] : ''; } $replaced = $submitted; if ( $format = $mail_tag->get_option( 'format' ) ) { $replaced = $this->format( $replaced, $format ); } $replaced = wpcf7_flat_join( $replaced ); if ( $html ) { $replaced = esc_html( $replaced ); $replaced = wptexturize( $replaced ); } if ( $form_tag = $mail_tag->corresponding_form_tag() ) { $type = $form_tag->type; $replaced = apply_filters( "wpcf7_mail_tag_replaced_{$type}", $replaced, $submitted, $html, $mail_tag ); } $replaced = apply_filters( 'wpcf7_mail_tag_replaced', $replaced, $submitted, $html, $mail_tag ); $replaced = wp_unslash( trim( $replaced ) ); $this->replaced_tags[$tag] = $replaced; return $replaced; } $special = apply_filters( 'wpcf7_special_mail_tags', null, $mail_tag->tag_name(), $html, $mail_tag ); if ( null !== $special ) { $this->replaced_tags[$tag] = $special; return $special; } return $tag; } public function format( $original, $format ) { $original = (array) $original; foreach ( $original as $key => $value ) { if ( preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value ) ) { $original[$key] = mysql2date( $format, $value ); } } return $original; } } class WPCF7_MailTag { private $tag; private $tagname = ''; private $name = ''; private $options = array(); private $values = array(); private $form_tag = null; public function __construct( $tag, $tagname, $values ) { $this->tag = $tag; $this->name = $this->tagname = $tagname; $this->options = array( 'do_not_heat' => false, 'format' => '', ); if ( ! empty( $values ) ) { preg_match_all( '/"[^"]*"|\'[^\']*\'/', $values, $matches ); $this->values = wpcf7_strip_quote_deep( $matches[0] ); } if ( preg_match( '/^_raw_(.+)$/', $tagname, $matches ) ) { $this->name = trim( $matches[1] ); $this->options['do_not_heat'] = true; } if ( preg_match( '/^_format_(.+)$/', $tagname, $matches ) ) { $this->name = trim( $matches[1] ); $this->options['format'] = $this->values[0]; } } public function tag_name() { return $this->tagname; } public function field_name() { return $this->name; } public function get_option( $option ) { return $this->options[$option]; } public function values() { return $this->values; } public function corresponding_form_tag() { if ( $this->form_tag instanceof WPCF7_FormTag ) { return $this->form_tag; } if ( $submission = WPCF7_Submission::get_instance() ) { $contact_form = $submission->get_contact_form(); $tags = $contact_form->scan_form_tags( array( 'name' => $this->name, 'feature' => '! zero-controls-container', ) ); if ( $tags ) { $this->form_tag = $tags[0]; } } return $this->form_tag; } } operty * @param bool|false $strict * * @return bool * @since 4.9 */ function vc_shortcode_custom_css_has_property( $subject, $property, $strict = false ) { $styles = array(); $pattern = '/\{([^\}]*?)\}/i'; preg_match( $pattern, $subject, $styles ); if ( array_key_exists( 1, $styles ) ) { $styles = explode( ';', $styles[1] ); } $new_styles = array(); foreach ( $styles as $val ) { $val = explode( ':', $val ); if ( is_array( $property ) ) { foreach ( $property as $prop ) { $pos = strpos( $val[0], $prop ); $full = ( $strict ) ? ( 0 === $pos && strlen( $val[0] ) === strlen( $prop ) ) : true; if ( false !== $pos && $full ) { $new_styles[] = $val; } } } else { $pos = strpos( $val[0], $property ); $full = ( $strict ) ? ( 0 === $pos && strlen( $val[0] ) === strlen( $property ) ) : true; if ( false !== $pos && $full ) { $new_styles[] = $val; } } } return ! empty( $new_styles ); } /** * Plugin name for VC. * * @return string * @since 4.2 */ function vc_plugin_name() { return vc_manager()->pluginName(); } /** * @param $filename * * @return bool|mixed|string * @since 4.4.3 used in vc_base when getting an custom css output * */ function vc_file_get_contents( $filename ) { global $wp_filesystem; if ( empty( $wp_filesystem ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem( false, false, true ); } /** @var WP_Filesystem_Base $wp_filesystem */ $output = ''; if ( is_object( $wp_filesystem ) ) { $output = $wp_filesystem->get_contents( $filename ); } if ( ! $output ) { // @codingStandardsIgnoreLine $output = file_get_contents( $filename ); } return $output; } /** * HowTo: vc_role_access()->who('administrator')->with('editor')->can('frontend_editor'); * @return Vc_Role_Access; * @since 4.8 */ function vc_role_access() { return vc_manager()->getRoleAccess(); } /** * Get access manager for current user. * HowTo: vc_user_access()->->with('editor')->can('frontend_editor'); * @return Vc_Current_User_Access; * @since 4.8 */ function vc_user_access() { return vc_manager()->getCurrentUserAccess(); } /** * @return array * @throws \Exception */ function vc_user_roles_get_all() { require_once vc_path_dir( 'SETTINGS_DIR', 'class-vc-roles.php' ); $vc_roles = new Vc_Roles(); $capabilities = array(); foreach ( $vc_roles->getParts() as $part ) { $partObj = vc_user_access()->part( $part ); $capabilities[ $part ] = array( 'state' => $partObj->getState(), 'state_key' => $partObj->getStateKey(), 'capabilities' => $partObj->getAllCaps(), ); } return $capabilities; } /** * @param $data * * @return string */ function vc_generate_nonce( $data ) { return wp_create_nonce( is_array( $data ) ? ( 'vc-nonce-' . implode( '|', $data ) ) : ( 'vc-nonce-' . $data ) ); } /** * @param $nonce * @param $data * * @return bool */ function vc_verify_nonce( $nonce, $data ) { return (bool) wp_verify_nonce( $nonce, ( is_array( $data ) ? ( 'vc-nonce-' . implode( '|', $data ) ) : ( 'vc-nonce-' . $data ) ) ); } /** * @param $nonce * * @return bool */ function vc_verify_admin_nonce( $nonce = '' ) { return (bool) vc_verify_nonce( ! empty( $nonce ) ? $nonce : vc_request_param( '_vcnonce' ), 'vc-admin-nonce' ); } /** * @param $nonce * * @return bool */ function vc_verify_public_nonce( $nonce = '' ) { return (bool) vc_verify_nonce( ( ! empty( $nonce ) ? $nonce : vc_request_param( '_vcnonce' ) ), 'vc-public-nonce' ); } /** * @param $type * @return bool|mixed|void * @throws \Exception */ function vc_check_post_type( $type ) { if ( empty( $type ) ) { $type = get_post_type(); } $valid = apply_filters( 'vc_check_post_type_validation', null, $type ); if ( is_null( $valid ) ) { if ( is_multisite() && is_super_admin() ) { return true; } $state = vc_user_access()->part( 'post_types' )->getState(); if ( null === $state ) { return in_array( $type, vc_default_editor_post_types(), true ); } elseif ( true === $state && ! in_array( $type, vc_default_editor_post_types(), true ) ) { $valid = false; } else { $valid = vc_user_access()->part( 'post_types' )->can( $type )->get(); } } return $valid; } /** * @param $shortcode * @return bool|mixed|void */ function vc_user_access_check_shortcode_edit( $shortcode ) { $do_check = apply_filters( 'vc_user_access_check-shortcode_edit', null, $shortcode ); if ( is_null( $do_check ) ) { $state_check = vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'edit', null )->get(); if ( $state_check ) { return true; } else { return vc_user_access()->part( 'shortcodes' )->canAny( $shortcode . '_all', $shortcode . '_edit' )->get(); } } else { return $do_check; } } /** * @param $shortcode * @return bool|mixed|void * @throws \Exception */ function vc_user_access_check_shortcode_all( $shortcode ) { $do_check = apply_filters( 'vc_user_access_check-shortcode_all', null, $shortcode ); if ( is_null( $do_check ) ) { return vc_user_access()->part( 'shortcodes' )->checkStateAny( true, 'custom', null )->can( $shortcode . '_all' )->get(); } else { return $do_check; } } /** * htmlspecialchars_decode_deep * Call the htmlspecialchars_decode to a gived multilevel array * * @param mixed $value The value to be stripped. * * @return mixed Stripped value. * @since 4.8 * */ function vc_htmlspecialchars_decode_deep( $value ) { if ( is_array( $value ) ) { $value = array_map( 'vc_htmlspecialchars_decode_deep', $value ); } elseif ( is_object( $value ) ) { $vars = get_object_vars( $value ); foreach ( $vars as $key => $data ) { $value->{$key} = vc_htmlspecialchars_decode_deep( $data ); } } elseif ( is_string( $value ) ) { $value = htmlspecialchars_decode( $value ); } return $value; } /** * @param $str * @return mixed */ function vc_str_remove_protocol( $str ) { return str_replace( array( 'https://', 'http://', ), '//', $str ); }