本文整理汇总了PHP中wp_check_invalid_utf8函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_check_invalid_utf8函数的具体用法?PHP wp_check_invalid_utf8怎么用?PHP wp_check_invalid_utf8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_check_invalid_utf8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _submit_admin_options
/**
* Submit processing for admin_options view
*
* @uses update_option()
* @uses wp_die()
* @uses wp_verify_nonce()
*/
private function _submit_admin_options()
{
$code_snippet = wp_check_invalid_utf8(htmlentities(stripslashes($_REQUEST['single_drop']), ENT_QUOTES, "UTF-8"));
$caching = "";
update_option($this->slug . '_single_drop', $code_snippet);
// Other cache sources
if (defined('WP_CACHE') && WP_CACHE == true) {
$caching = "other";
}
// Check for CloudFlare
if (defined('CLOUDFLARE_VERSION')) {
$caching = "cloudflare";
}
// Check for W3 Total Cache
if (defined('W3TC')) {
if (function_exists('w3tc_pgcache_flush_url')) {
w3tc_pgcache_flush_url("/");
$caching = "";
} else {
$caching = "w3-total-cache";
}
}
// Check for WP Super Cache
if (function_exists('wpsupercache_site_admin')) {
$caching = "wp-super-cache";
}
// Check for Quick Cache
if (class_exists('\\quick_cache\\plugin')) {
$caching = "quick-cache";
}
wp_redirect(admin_url('admin.php') . '?page=' . $this->slug . '&message=submit&caching=' . $caching);
exit;
}
示例2: sanitize
/**
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
*/
public function sanitize($input)
{
if (isset($input['widget_rememberme'])) {
$new_input['widget_rememberme'] = absint($input['widget_rememberme']);
}
if (isset($input['code_reset_email_text'])) {
$filtered = wp_check_invalid_utf8($input['code_reset_email_text']);
}
$new_input['code_reset_email_text'] = wp_strip_all_tags($filtered);
return $new_input;
}
示例3: of_sanitize_text_field
function of_sanitize_text_field($value, $option)
{
$defaults = array('html' => false);
$option = array_merge($defaults, $option);
if ($option['html']) {
// don't strip html tags
return wp_check_invalid_utf8($value);
} else {
return sanitize_text_field($value);
}
}
示例4: build_csp
public function build_csp()
{
$csp = $this->options['content_security_policy'];
if (!empty($this->options['csp_report_url'])) {
$csp .= "; report-uri ";
$csp .= $this->options['csp_report_url'];
}
$this->csp = _wp_specialchars(wp_check_invalid_utf8($csp), 'double');
if (!$this->options['enforce_csp']) {
$this->csp_type .= '-Report-Only';
}
}
示例5: wpcf7_sanitize_query_var
function wpcf7_sanitize_query_var($text)
{
$text = wp_unslash($text);
$text = wp_check_invalid_utf8($text);
if (false !== strpos($text, '<')) {
$text = wp_pre_kses_less_than($text);
$text = wp_strip_all_tags($text);
}
$text = preg_replace('/%[a-f0-9]{2}/i', '', $text);
$text = preg_replace('/ +/', ' ', $text);
$text = trim($text, ' ');
return $text;
}
示例6: validateInvoicePostFields
/**
* @return array
* @author Panagiotis Vagenas <pan.vagenas@gmail.com>
* @since 151229
*/
protected function validateInvoicePostFields()
{
if (!$this->isTimologioRequest()) {
return array();
}
$validated = array();
foreach ($this->fields as $fieldName) {
$value = isset($_POST[$fieldName]) ? wp_strip_all_tags(wp_check_invalid_utf8(stripslashes($_POST[$fieldName]))) : '';
if (!empty($value)) {
$validated[$fieldName] = $value;
}
}
return $validated;
}
示例7: si_print_js
/**
* Output any queued javascript code in the footer.
*/
function si_print_js()
{
global $si_queued_js;
if (!empty($si_queued_js)) {
// Sanitize.
$si_queued_js = wp_check_invalid_utf8($si_queued_js);
$si_queued_js = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", $si_queued_js);
$si_queued_js = str_replace("\r", '', $si_queued_js);
$js = "<!-- Social Icons JavaScript -->\n<script type=\"text/javascript\">\njQuery(function(\$) { {$si_queued_js} });\n</script>\n";
/**
* social_icons_queued_js filter.
* @param string $js JavaScript code.
*/
echo apply_filters('social_icons_queued_js', $js);
unset($si_queued_js);
}
}
示例8: sanitize_multiline_text_field
/**
* Filter a sanitized multi line text field string without removing linebreaks and tabs.
*
* @since 1.4.3
*
* @param string $filtered The sanitized string.
* @param string $str The string prior to being sanitized.
*/
function sanitize_multiline_text_field($str)
{
$filtered = wp_check_invalid_utf8($str);
if (strpos($filtered, '<') !== false) {
$filtered = wp_pre_kses_less_than($filtered);
// This will strip extra whitespace for us.
$filtered = wp_strip_all_tags($filtered, true);
}
$found = false;
while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
$filtered = str_replace($match[0], '', $filtered);
$found = true;
}
if ($found) {
// Strip out the whitespace that may now exist after removing the octets.
$filtered = trim(preg_replace('/ +/', ' ', $filtered));
}
return $filtered;
}
示例9: weaverii_validate_all_options
//.........这里部分代码省略.........
$val = weaverii_filter_code($value);
$in[$key] = $val;
if (stripos($val, '<style') !== false || stripos($val, '</style') !== false) {
$err_msg .= weaverii_t_('"Add CSS Rules" option must not contain <style> tags!') . weaverii_t_(' Please correct your entry.') . '<br />';
}
}
break;
case 'wii_last_option':
// check for wii_last_option...
if (!empty($value)) {
$wvr_last = $value;
}
break;
case 'hide_advanced_btn':
if (stripos($value, 'hide') === false) {
$in['hide_advanced'] = 'show';
} else {
$in['hide_advanced'] = 'hide';
}
break;
case 'hide_advanced':
$val = $value;
if (isset($in['hide_advanced_btn'])) {
if (stripos($in['hide_advanced_btn'], 'hide') === false) {
$val = 'show';
} else {
$val = 'hide';
}
}
$in[$key] = $val;
break;
case '_phpactions':
if (!empty($value)) {
$in[$key] = stripslashes(wp_check_invalid_utf8(addslashes($value)));
}
break;
default:
/* to here, then colors, _css, or checkbox/selectors */
$keylen = strlen($key);
if (strrpos($key, '_css') == $keylen - 4) {
// all _css settings
if (!empty($value)) {
$val = weaverii_filter_code($value);
$in[$key] = $val;
if (strpos($val, '{') === false || strpos($val, '}') === false) {
$opt_id = str_replace('_css', '', $key);
// kill _css
$opt_id = str_replace('wii_', '', $opt_id);
$opt_id = str_replace('_', ' ', $opt_id);
$err_msg .= weaverii_t_('CSS options must be enclosed in {}\'s: ') . '"' . $opt_id . '" = "' . $value . '".' . weaverii_t_(' Please correct your entry.') . '<br />';
}
}
break;
}
// _css
if (strrpos($key, '_insert') == $keylen - 7) {
// all _insert settings
if (!empty($value)) {
$val = weaverii_filter_code($value);
$in[$key] = $val;
}
break;
}
// _insert
if (strrpos($key, '_url') == $keylen - 4) {
// all _url settings
示例10: sanitize_text_field
/**
* Sanitize a string from user input or from the db
*
* check for invalid UTF-8,
* Convert single < characters to entity,
* strip all tags,
* remove line breaks, tabs and extra white space,
* strip octets.
*
* @since 2.9.0
*
* @param string $str
* @return string
*/
function sanitize_text_field($str)
{
$filtered = wp_check_invalid_utf8($str);
if (strpos($filtered, '<') !== false) {
$filtered = wp_pre_kses_less_than($filtered);
// This will strip extra whitespace for us.
$filtered = wp_strip_all_tags($filtered, true);
} else {
$filtered = trim(preg_replace('/[\\r\\n\\t ]+/', ' ', $filtered));
}
$found = false;
while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
$filtered = str_replace($match[0], '', $filtered);
$found = true;
}
if ($found) {
// Strip out the whitespace that may now exist after removing the octets.
$filtered = trim(preg_replace('/ +/', ' ', $filtered));
}
/**
* Filter a sanitized text field string.
*
* @since 2.9.0
*
* @param string $filtered The sanitized string.
* @param string $str The string prior to being sanitized.
*/
return apply_filters('sanitize_text_field', $filtered, $str);
}
示例11: esc_attr
function esc_attr($text)
{
$safe_text = wp_check_invalid_utf8($text);
$safe_text = _wp_specialchars($safe_text, ENT_QUOTES);
return apply_filters('attribute_escape', $safe_text, $text);
}
示例12: process_checkout
/**
* Process the checkout after the confirm order button is pressed
*
* @access public
* @return void
*/
public function process_checkout()
{
global $wpdb, $current_user;
wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-process_checkout');
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
// Prevent timeout
@set_time_limit(0);
do_action('woocommerce_before_checkout_process');
if (sizeof(WC()->cart->get_cart()) == 0) {
wc_add_notice(sprintf(__('Sorry, your session has expired. <a href="%s" class="wc-backward">Return to homepage</a>', 'woocommerce'), home_url()), 'error');
}
do_action('woocommerce_checkout_process');
// Checkout fields (not defined in checkout_fields)
$this->posted['terms'] = isset($_POST['terms']) ? 1 : 0;
$this->posted['createaccount'] = isset($_POST['createaccount']) ? 1 : 0;
$this->posted['payment_method'] = isset($_POST['payment_method']) ? stripslashes($_POST['payment_method']) : '';
$this->posted['shipping_method'] = isset($_POST['shipping_method']) ? $_POST['shipping_method'] : '';
$this->posted['ship_to_different_address'] = isset($_POST['ship_to_different_address']) ? true : false;
if (isset($_POST['shiptobilling'])) {
_deprecated_argument('WC_Checkout::process_checkout()', '2.1', 'The "shiptobilling" field is deprecated. THe template files are out of date');
$this->posted['ship_to_different_address'] = $_POST['shiptobilling'] ? false : true;
}
// Ship to billing only option
if (WC()->cart->ship_to_billing_address_only()) {
$this->posted['ship_to_different_address'] = false;
}
// Update customer shipping and payment method to posted method
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($this->posted['shipping_method']) && is_array($this->posted['shipping_method'])) {
foreach ($this->posted['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', $this->posted['payment_method']);
// Note if we skip shipping
$skipped_shipping = false;
// Get posted checkout_fields and do validation
foreach ($this->checkout_fields as $fieldset_key => $fieldset) {
// Skip shipping if not needed
if ($fieldset_key == 'shipping' && ($this->posted['ship_to_different_address'] == false || !WC()->cart->needs_shipping())) {
$skipped_shipping = true;
continue;
}
// Ship account if not needed
if ($fieldset_key == 'account' && (is_user_logged_in() || $this->must_create_account == false && empty($this->posted['createaccount']))) {
continue;
}
foreach ($fieldset as $key => $field) {
if (!isset($field['type'])) {
$field['type'] = 'text';
}
// Get Value
switch ($field['type']) {
case "checkbox":
$this->posted[$key] = isset($_POST[$key]) ? 1 : 0;
break;
case "multiselect":
$this->posted[$key] = isset($_POST[$key]) ? implode(', ', array_map('wc_clean', $_POST[$key])) : '';
break;
case "textarea":
$this->posted[$key] = isset($_POST[$key]) ? wp_strip_all_tags(wp_check_invalid_utf8(stripslashes($_POST[$key]))) : '';
break;
default:
$this->posted[$key] = isset($_POST[$key]) ? wc_clean($_POST[$key]) : '';
break;
}
// Hooks to allow modification of value
$this->posted[$key] = apply_filters('woocommerce_process_checkout_' . sanitize_title($field['type']) . '_field', $this->posted[$key]);
$this->posted[$key] = apply_filters('woocommerce_process_checkout_field_' . $key, $this->posted[$key]);
// Validation: Required fields
if (isset($field['required']) && $field['required'] && empty($this->posted[$key])) {
wc_add_notice('<strong>' . $field['label'] . '</strong> ' . __('is a required field.', 'woocommerce'), 'error');
}
if (!empty($this->posted[$key])) {
// Validation rules
if (!empty($field['validate']) && is_array($field['validate'])) {
foreach ($field['validate'] as $rule) {
switch ($rule) {
case 'postcode':
$this->posted[$key] = strtoupper(str_replace(' ', '', $this->posted[$key]));
if (!WC_Validation::is_postcode($this->posted[$key], $_POST[$fieldset_key . '_country'])) {
wc_add_notice(__('Please enter a valid postcode/ZIP.', 'woocommerce'), 'error');
} else {
$this->posted[$key] = wc_format_postcode($this->posted[$key], $_POST[$fieldset_key . '_country']);
}
break;
case 'phone':
$this->posted[$key] = wc_format_phone_number($this->posted[$key]);
if (!WC_Validation::is_phone($this->posted[$key])) {
wc_add_notice('<strong>' . $field['label'] . '</strong> ' . __('is not a valid phone number.', 'woocommerce'), 'error');
}
//.........这里部分代码省略.........
示例13: weaverii_filter_code
function weaverii_filter_code($text)
{
// Much option input from Weaver Xtreme can be code, and thus must not be
// content filtered - at least for admins. The utf8 check is about the extent of it, although even
// that is more restrictive than the standard text widget uses.
// Note: this check also works OK for simple checkboxes/radio buttons/selections,
// so it is ok to blindly pass those options in here, too.
$trimmed = trim($text);
$noslash = stripslashes($trimmed);
if ($trimmed == ' ') {
return '';
}
if (current_user_can('unfiltered_html')) {
return wp_check_invalid_utf8($noslash);
} else {
return wp_filter_post_kses($trimmed);
// wp_filter_post_kses() handles slashes
}
}
示例14: sanitize_text_field
/**
* Sanitize a string from user input or from the db
*
* check for invalid UTF-8,
* Convert single < characters to entity,
* strip all tags,
* remove line breaks, tabs and extra whitre space,
* strip octets.
*
* @since 2.9
*
* @param string $str
* @return string
*/
function sanitize_text_field($str)
{
$filtered = wp_check_invalid_utf8($str);
if (strpos($filtered, '<') !== false) {
$filtered = wp_pre_kses_less_than($filtered);
$filtered = wp_strip_all_tags($filtered, true);
} else {
$filtered = trim(preg_replace('/\\s+/', ' ', $filtered));
}
$match = array();
while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
$filtered = str_replace($match[0], '', $filtered);
}
return apply_filters('sanitize_text_field', $filtered, $str);
}
示例15: require_billing_information
public static function require_billing_information($post_id, $post)
{
// must be shop order
if ($post->post_type != 'shop_order') {
return;
}
// only perform this check if the associated option is on
if (self::$options->{'qsot-require-billing-information'} != 'yes') {
return;
}
// only when the past is being saved in the admin
if (!isset($_POST['action']) || $_POST['action'] != 'editpost') {
return;
}
// load the order
$order = wc_get_order($post_id);
if (!is_object($order) || !isset($order->id)) {
return;
}
// do not perform this check on cancelled orders, because they are irrelevant checks at that point
if ('cancelled' == $order->get_status()) {
return;
}
// ****** most of this is adapted from the checkout logic from WC2.3.x
// get all the fields that we should be validating. derived from checkout process
$fields = WC()->countries->get_address_fields(self::_get_value('_billing_country', $order), '_billing_');
$errors = array();
// cycle through each field, and validate the input
foreach ($fields as $key => $field) {
// make sure we have a field type
if (!isset($field['type'])) {
$field['type'] = 'text';
}
// find the submitted value of the field
switch ($field['type']) {
// checkboxes are on or off
case 'checkbox':
$value = isset($_POST[$key]) ? 1 : 0;
break;
// multiselect boxes have multiple values that need cleaning
// multiselect boxes have multiple values that need cleaning
case 'multiselect':
$value = isset($_POST[$key]) ? implode(', ', array_map('wc_clean', $_POST[$key])) : '';
break;
// textareas allow for lots of text, so clean that up
// textareas allow for lots of text, so clean that up
case 'textarea':
$value = isset($_POST[$key]) ? wp_strip_all_tags(wp_check_invalid_utf8(stripslashes($_POST[$key]))) : '';
break;
// all other fields should be cleaned as well
// all other fields should be cleaned as well
default:
$value = isset($_POST[$key]) ? is_array($_POST[$key]) ? array_map('wc_clean', $_POST[$key]) : wc_clean($_POST[$key]) : '';
break;
}
// allow modification of resulting value
$value = apply_filters('woocommerce_process_checkout_' . sanitize_title($field['type']) . '_field', $value);
$value = apply_filters('woocommerce_process_checkout_field_' . $key, $value);
// check required fields
if (isset($field['required']) && $field['required'] && empty($value)) {
$error[] = '<strong>' . $field['label'] . '</strong> ' . __('is a required field.', 'woocommerce');
}
// some non-empty fields need addtiional validation. handle that here
if (!empty($value)) {
// cycle through the rules
if (isset($field['validate'])) {
foreach ($field['validate'] as $rule) {
// process each rule if it is in the list
switch ($rule) {
// postcodes vary from country to country
case 'postcode':
$value = strtoupper(str_replace(' ', '', $value));
if (!WC_Validation::is_postcode($value, $_POST[$key])) {
$errors[] = __('Please enter a valid postcode/ZIP.', 'woocommerce');
}
break;
// phone digit count and format varies from country to country
// phone digit count and format varies from country to country
case 'phone':
$value = wc_format_phone_number($value);
if (!WC_Validation::is_phone($value)) {
$errors[] = '<strong>' . $field['label'] . '</strong> ' . __('is not a valid phone number.', 'woocommerce');
}
break;
// validate email addresses
// validate email addresses
case 'email':
$value = strtolower($value);
if (!is_email($value)) {
$errors[] = '<strong>' . $field['label'] . '</strong> ' . __('is not a valid email address.', 'woocommerce');
}
break;
// states cound be in different formats or have different values based on the country
// states cound be in different formats or have different values based on the country
case 'state':
$states = WC()->countries->get_states(self::_get_value('_billing_country', $order));
if (!empty($states) && is_array($states)) {
$states = array_flip(array_map('strtolower', $states));
// look up correct value if key exists
if (isset($states[strtolower($value)])) {
//.........这里部分代码省略.........