當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_Customize_Setting::sanitize方法代碼示例

本文整理匯總了PHP中WP_Customize_Setting::sanitize方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Customize_Setting::sanitize方法的具體用法?PHP WP_Customize_Setting::sanitize怎麽用?PHP WP_Customize_Setting::sanitize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_Customize_Setting的用法示例。


在下文中一共展示了WP_Customize_Setting::sanitize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: post_value

 /**
  * Returns the sanitized value for a given setting from the request's POST data.
  *
  * @since 3.4.0
  * @since 4.1.1 Introduced the `$default` parameter.
  * @since 4.6.0 `$default` is now returned early when the setting post value is invalid.
  * @access public
  *
  * @see WP_REST_Server::dispatch()
  * @see WP_Rest_Request::sanitize_params()
  * @see WP_Rest_Request::has_valid_params()
  *
  * @param WP_Customize_Setting $setting A WP_Customize_Setting derived object.
  * @param mixed                $default Value returned $setting has no post value (added in 4.2.0)
  *                                      or the post value is invalid (added in 4.6.0).
  * @return string|mixed $post_value Sanitized value or the $default provided.
  */
 public function post_value($setting, $default = null)
 {
     $post_values = $this->unsanitized_post_values();
     if (!array_key_exists($setting->id, $post_values)) {
         return $default;
     }
     $value = $post_values[$setting->id];
     $valid = $setting->validate($value);
     if (is_wp_error($valid)) {
         return $default;
     }
     $value = $setting->sanitize($value);
     if (is_null($value) || is_wp_error($value)) {
         return $default;
     }
     return $value;
 }
開發者ID:inpsyde,項目名稱:wordpress-dev,代碼行數:34,代碼來源:class-wp-customize-manager.php

示例2: post_value

 /**
  * Return the sanitized value for a given setting from the request's POST data.
  *
  * @since 3.4.0
  * @since 4.1.1 Introduced 'default' parameter.
  *
  * @param WP_Customize_Setting $setting A WP_Customize_Setting derived object
  * @param mixed $default value returned $setting has no post value (added in 4.2.0).
  * @return string|mixed $post_value Sanitized value or the $default provided
  */
 public function post_value($setting, $default = null)
 {
     $post_values = $this->unsanitized_post_values();
     if (array_key_exists($setting->id, $post_values)) {
         return $setting->sanitize($post_values[$setting->id]);
     } else {
         return $default;
     }
 }
開發者ID:RA2WP,項目名稱:RA2WP,代碼行數:19,代碼來源:class-wp-customize-manager.php

示例3: post_value

 /**
  * Decode the $_POST['customized'] values for a specific Customize Setting.
  *
  * @since 3.4.0
  *
  * @param WP_Customize_Setting $setting A WP_Customize_Setting derived object
  * @return string $post_value Sanitized value
  */
 public function post_value($setting)
 {
     if (!isset($this->_post_values)) {
         if (isset($_POST['customized'])) {
             $this->_post_values = json_decode(wp_unslash($_POST['customized']), true);
         } else {
             $this->_post_values = false;
         }
     }
     if (isset($this->_post_values[$setting->id])) {
         return $setting->sanitize($this->_post_values[$setting->id]);
     }
 }
開發者ID:hachi4,項目名稱:WordPress,代碼行數:21,代碼來源:class-wp-customize-manager.php


注:本文中的WP_Customize_Setting::sanitize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。