• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_kses_allowed_html函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_kses_allowed_html函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_kses_allowed_html函数的具体用法?PHP wp_kses_allowed_html怎么用?PHP wp_kses_allowed_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_kses_allowed_html函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: bp_groups_filter_kses

/**
 * Filter output of Group Description through WordPress's KSES API.
 *
 * @since BuddyPress (1.1.0)
 *
 * @param string $content
 * @return string
 */
function bp_groups_filter_kses($content = '')
{
    /**
     * Note that we don't immediately bail if $content is empty. This is because
     * WordPress's KSES API calls several other filters that might be relevant
     * to someone's workflow (like `pre_kses`)
     */
    // Get allowed tags using core WordPress API allowing third party plugins
    // to target the specific `buddypress-groups` context.
    $allowed_tags = wp_kses_allowed_html('buddypress-groups');
    // Add our own tags allowed in group descriptions
    $allowed_tags['a']['class'] = array();
    $allowed_tags['img'] = array();
    $allowed_tags['img']['src'] = array();
    $allowed_tags['img']['alt'] = array();
    $allowed_tags['img']['class'] = array();
    $allowed_tags['img']['width'] = array();
    $allowed_tags['img']['height'] = array();
    $allowed_tags['img']['class'] = array();
    $allowed_tags['img']['id'] = array();
    $allowed_tags['code'] = array();
    /**
     * Filter HTML elements allowed for a given context.
     *
     * @since BuddyPress (1.1.0)
     *
     * @param string $allowed_tags Allowed tags, attributes, and/or entities.
     */
    $tags = apply_filters('bp_groups_filter_kses', $allowed_tags);
    // Return KSES'ed content, allowing the above tags
    return wp_kses($content, $tags);
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:40,代码来源:bp-groups-filters.php


示例2: __construct

 /**
  * The enhanced default constructor, ends up setting all parameters via the set_ functions
  *  
  * @param string $title (optional) The title of the breadcrumb
  * @param string $template (optional) The html template for the breadcrumb
  * @param string $type (optional) The breadcrumb type
  * @param string $url (optional) The url the breadcrumb links to
  */
 public function __construct($title = '', $template = '', array $type = array(), $url = NULL, $id = NULL)
 {
     //Filter allowed_html array to allow others to add acceptable tags
     $this->allowed_html = apply_filters('bcn_allowed_html', wp_kses_allowed_html('post'));
     //The breadcrumb type
     $this->type = $type;
     //Set the resource id
     $this->set_id($id);
     //Set the title
     $this->set_title($title);
     //Assign the breadcrumb template, need strict comparison as we only want to enter if we had a blank URL, not NULL URL
     if ($template == NULL || $url === '') {
         if ($url == NULL || $url === '') {
             $template = __('<span typeof="v:Breadcrumb"><span property="v:title">%htitle%</span></span>', 'breadcrumb-navxt');
         } else {
             $template = __('<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" title="Go to %title%." href="%link%" class="%type%">%htitle%</a></span>', 'breadcrumb-navxt');
         }
     }
     //Loose comparison, evaluates to true if URL is '' or NULL
     if ($url == NULL) {
         $this->template_no_anchor = wp_kses(apply_filters('bcn_breadcrumb_template_no_anchor', $template, $this->type, $this->id), $this->allowed_html);
     } else {
         $this->set_template($template);
     }
     //Always NULL if unlinked
     $this->set_url($url);
 }
开发者ID:pwsclau,项目名称:kurastar_dev,代码行数:35,代码来源:class.bcn_breadcrumb.php


示例3: __construct

 /**
  * The enhanced default constructor, ends up setting all parameters via the set_ functions
  *  
  * @param string $title (optional) The title of the breadcrumb
  * @param string $template (optional) The html template for the breadcrumb
  * @param string $type (optional) The breadcrumb type
  * @param string $url (optional) The url the breadcrumb links to
  */
 public function __construct($title = '', $template = '', array $type = array(), $url = '', $id = NULL)
 {
     //Filter allowed_html array to allow others to add acceptable tags
     $this->allowed_html = apply_filters('bcn_allowed_html', wp_kses_allowed_html('post'));
     //The breadcrumb type
     $this->type = $type;
     //Set the resource id
     $this->set_id($id);
     //Set the title
     $this->set_title($title);
     //Set the default anchorless templates value
     $this->template_no_anchor = bcn_breadcrumb::default_template_no_anchor;
     //If we didn't get a good template, use a default template
     if ($template == NULL) {
         $this->set_template(bcn_breadcrumb::get_default_template());
     } else {
         //Loose comparison, evaluates to true if URL is '' or NULL
         if ($url == NULL) {
             $this->template_no_anchor = wp_kses(apply_filters('bcn_breadcrumb_template_no_anchor', $template, $this->type, $this->id), $this->allowed_html);
             $this->set_template(bcn_breadcrumb::get_default_template());
         } else {
             $this->set_template($template);
         }
     }
     //Always NULL if unlinked
     $this->set_url($url);
 }
开发者ID:KJaddoe,项目名称:CSCMRA-Project,代码行数:35,代码来源:class.bcn_breadcrumb.php


示例4: formatData

 private function formatData($data, $section)
 {
     if (!isset($data['elements'])) {
         $data['elements'] = array();
     }
     $data = wp_parse_args($data, $section->getDefaults());
     // Get around id being a reserved keyword. This way we can still use it in render methods for elements
     if (isset($data['custom_id'])) {
         $data['id'] = $data['custom_id'];
     }
     // Format data before rendering
     foreach ($data as $key => $item) {
         if (is_array($item) && count($item) == 5 && ($item[4] == 'linked' || $item[4] == 'unlinked')) {
             $data[$key . '_linked'] = array_pop($item);
             $data[$key] = array_map('esc_html', array($item[0], $item[1], $item[2], $item[3]));
             continue;
         }
         // Convert boolean to string
         if ($item === true) {
             $data[$key] = 'true';
             continue;
         }
         if ($item === false) {
             $data[$key] = 'false';
             continue;
         }
         if (is_string($item) && !current_user_can('unfiltered_html')) {
             $data[$key] = wp_kses($item, wp_kses_allowed_html('post'));
             continue;
         }
     }
     return $data;
 }
开发者ID:datracka,项目名称:datalook.io,代码行数:33,代码来源:class-setting-sections-manager.php


示例5: sgPopupDataSanitize

 public static function sgPopupDataSanitize($sgPopupData)
 {
     $allowedHtmltags = wp_kses_allowed_html('post');
     $allowedHtmltags['input'] = array('name' => true, 'class' => true, 'id' => true, 'placeholder' => true, 'title' => true, 'value' => true, 'type' => true);
     $allowedHtmltags['iframe'] = array('name' => true, 'class' => true, 'id' => true, 'title' => true, 'src' => true, 'height' => true, 'width' => true);
     return wp_kses($sgPopupData, $allowedHtmltags);
 }
开发者ID:ronal2do,项目名称:openshift-wordpress-developer-quickstart,代码行数:7,代码来源:sg_popup_pro.php


示例6: bcn_breadcrumb

 /**
  * The enhanced default constructor, ends up setting all parameters via the set_ functions
  *  
  * @param string $title (optional) The title of the breadcrumb
  * @param string $template (optional) The html template for the breadcrumb
  * @param string $type (optional) The breadcrumb type
  * @param string $url (optional) The url the breadcrumb links to
  */
 public function bcn_breadcrumb($title = '', $template = '', $type = '', $url = NULL, $id = NULL)
 {
     //Filter allowed_html array to allow others to add acceptable tags
     $this->allowed_html = apply_filters('bcn_allowed_html', wp_kses_allowed_html('post'));
     //The breadcrumb type
     $this->type = $type;
     //Set the resource id
     $this->set_id($id);
     //Set the title
     $this->set_title($title);
     //Assign the breadcrumb template
     if ($template == NULL) {
         if ($url == NULL) {
             $template = $this->template = __('%htitle%', 'breadcrumb-navxt');
         } else {
             $template = __('<a title="Go to %ftitle%." href="%link%" class="%type%">%htitle%</a>', 'breadcrumb-navxt');
         }
     }
     if ($url == NULL) {
         $this->template_no_anchor = wp_kses($template, $this->allowed_html);
     } else {
         $this->set_template($template);
     }
     //Always NULL if unlinked
     $this->set_url($url);
 }
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:34,代码来源:breadcrumb_navxt_class.php


示例7: value

 /**
  * Sanitize editor
  *
  * @param mixed $new
  * @param mixed $old
  * @param int   $post_id
  * @param array $field
  *
  * @return string
  */
 static function value($new, $old, $post_id, $field)
 {
     $prefix = 'wppf-';
     $the_field_id = $prefix . $field['id'];
     $allowed_html = apply_filters('wppf_editor_field_allowed_html', wp_kses_allowed_html('post'));
     return wp_kses($_POST[$the_field_id], $allowed_html);
 }
开发者ID:devd123,项目名称:wpaam,代码行数:17,代码来源:editor.php


示例8: create_feedback

 public function create_feedback($params)
 {
     global $un_settings;
     if (isset($params['title']) && $params['title']) {
         $title = $params['title'];
     }
     $content = $params['description'];
     if (empty($params['title'])) {
         $title = substr($content, 0, 150) . (strlen($content) < 150 ? '' : "…");
     }
     $id = wp_insert_post(array('post_type' => FEEDBACK, 'post_title' => wp_kses(apply_filters('un_feedback_title', $title, $params), wp_kses_allowed_html()), 'post_content' => wp_kses(apply_filters('un_feedback_content', $content, $params), wp_kses_allowed_html()), 'post_status' => un_get_option(UN_PUBLISH_DIRECTLY) ? 'publish' : 'pending', 'post_author' => 0));
     $email = isset($params['email']) ? trim($params['email']) : '';
     if ($email) {
         add_post_meta($id, '_email', $email);
     }
     if (is_user_logged_in()) {
         add_post_meta($id, '_author', get_current_user_id());
     }
     if (isset($params['name']) && trim($params['name'])) {
         add_post_meta($id, '_name', wp_kses(trim($params['name']), wp_kses_allowed_html()));
     }
     wp_set_post_terms($id, $params['type'], FEEDBACK_TYPE);
     do_action('un_feedback_created', $id, $params);
     $this->send_admin_message($id, $params);
 }
开发者ID:congtrieu112,项目名称:anime,代码行数:25,代码来源:model.php


示例9: __construct

 /**
  * The enhanced default constructor, ends up setting all parameters via the set_ functions
  *  
  * @param string $title (optional) The title of the breadcrumb
  * @param string $template (optional) The html template for the breadcrumb
  * @param string $type (optional) The breadcrumb type
  * @param string $url (optional) The url the breadcrumb links to
  */
 public function __construct($title = '', $template = '', $type = '', $url = NULL, $id = NULL)
 {
     //Filter allowed_html array to allow others to add acceptable tags
     $this->allowed_html = apply_filters('bcn_allowed_html', wp_kses_allowed_html('post'));
     //The breadcrumb type
     $this->type = $type;
     //Set the resource id
     $this->set_id($id);
     //Set the title
     $this->set_title($title);
     //Assign the breadcrumb template
     if ($template == NULL) {
         if ($url == NULL) {
             $template = __('<span typeof="v:Breadcrumb"><span property="v:title">%htitle%</span></span>', 'breadcrumb-navxt');
         } else {
             $template = __('<span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" title="Go to %title%." href="%link%" class="%type%">%htitle%</a></span>', 'breadcrumb-navxt');
         }
     }
     if ($url == NULL) {
         $this->template_no_anchor = wp_kses(apply_filters('bcn_breadcrumb_template_no_anchor', $template, $this->type, $this->id), $this->allowed_html);
     } else {
         $this->set_template($template);
     }
     //Always NULL if unlinked
     $this->set_url($url);
 }
开发者ID:crazyyy,项目名称:octagram,代码行数:34,代码来源:class.bcn_breadcrumb.php


示例10: prepare_for_set

 /**
  * removes all tags which a WP Post wouldn't allow in its content normally
  * @param string $value
  * @return string
  */
 function prepare_for_set($value)
 {
     if (!current_user_can('unfiltered_html')) {
         $value = wp_kses("{$value}", wp_kses_allowed_html('post'));
     }
     return parent::prepare_for_set($value);
 }
开发者ID:aaronfrey,项目名称:PepperLillie-GSP,代码行数:12,代码来源:EE_Post_Content_Field.php


示例11: carbon_pagination

/**
 * A lazy way to build, configure and display a new pagination.
 *
 * @param string $pagination The pagination type, can be one of the following:
 *    - Posts
 *    - Post
 *    - Comments
 *    - Custom
 * @param array $args Configuration options to modify the pagination settings.
 * @param bool $echo Whether to display or return the output. True will display, false will return.
 */
function carbon_pagination($pagination, $args = array(), $echo = true)
{
    $output = Carbon_Pagination_Presenter::display($pagination, $args, false);
    if (!$echo) {
        return $output;
    }
    echo wp_kses($output, wp_kses_allowed_html('post'));
}
开发者ID:2createstudio,项目名称:carbon-pagination,代码行数:19,代码来源:functions.php


示例12: sanitize_settings

 public function sanitize_settings()
 {
     parent::sanitize_settings();
     if (is_multisite() || !current_user_can('manage_options')) {
         $allowed_tags = wp_kses_allowed_html('post');
         $this->content = wp_kses($this->content, $allowed_tags);
     }
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:8,代码来源:class-gf-field-html.php


示例13: phn_sanitize_content

 /**
  * Allow <input> and <script> tags
  *
  */
 function phn_sanitize_content($content)
 {
     $wp_allowed_html = wp_kses_allowed_html('post');
     $custom_allowed_html = array('input' => array('name' => array(), 'id' => array(), 'value' => array(), 'class' => array(), 'type' => array(), 'onblur' => array(), 'onfocus' => array()), 'script' => array('type' => array(), 'src' => array()));
     $allowed_html = $wp_allowed_html + $custom_allowed_html;
     $sanitized_content = wp_kses($content, $allowed_html);
     return $sanitized_content;
 }
开发者ID:andy-j-d,项目名称:hover-notification,代码行数:12,代码来源:options.php


示例14: sanitize_output

 public static function sanitize_output($content)
 {
     $allowed = wp_kses_allowed_html('post');
     $options = get_option('iwt_options');
     if (array_key_exists('contentelements', $options) && json_decode($options['contentelements']) != null) {
         $allowed = json_decode($options['contentelements'], true);
     }
     return wp_kses((string) $content, $allowed);
 }
开发者ID:davidized,项目名称:wp-indieweb-post-kinds,代码行数:9,代码来源:class-kind-view.php


示例15: admin_notices

 /**
  * Display the admin notices
  */
 public function admin_notices()
 {
     if (!empty($notices)) {
         foreach ($notices as $notice) {
             echo '<div class="' . esc_attr($notice['type']) . '">
       <p>' . wp_kses($notice['message'], wp_kses_allowed_html('post')) . '</p>
       </div>';
         }
     }
 }
开发者ID:kilbot,项目名称:WooCommerce-Software-License-Manager,代码行数:13,代码来源:notices.php


示例16: admin_notices

    /**
     * Display the admin notices
     */
    public function admin_notices()
    {
        if (!empty($this->notices)) {
            foreach ($this->notices as $notice) {
                echo '<div class="' . $notice['msg_type'] . '">
          <p>' . wp_kses($notice['msg'], wp_kses_allowed_html('post')) . '</p>
				</div>';
            }
        }
    }
开发者ID:bostondv,项目名称:WooCommerce-POS,代码行数:13,代码来源:class-wc-pos-admin.php


示例17: update

 function update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['ci_title'] = sanitize_text_field($new_instance['ci_title']);
     $instance['ci_image'] = esc_url_raw($new_instance['ci_image']);
     $instance['ci_align'] = sanitize_key($new_instance['ci_align']);
     $instance['ci_about'] = wp_kses($new_instance['ci_about'], wp_kses_allowed_html('post'));
     ci_register_string_translation('About Me - Title', $instance['ci_title'], 'Widgets');
     ci_register_string_translation('About Me - Text', $instance['ci_about'], 'Widgets');
     return $instance;
 }
开发者ID:nickolasnikolic,项目名称:wordpress-heroku-php,代码行数:11,代码来源:ci_widget_about.php


示例18: test_add_allowed_html

 /**
  * Test that we add extra attributes to our allowed html for wp_kses_post
  *
  * @since 1.0.0
  *
  * @param null
  * @return null
  */
 public function test_add_allowed_html()
 {
     // Now we should have added some extra attributes
     $after = wp_kses_allowed_html('post');
     // Ensure we can use 'data-toggle' attributes for anchors
     $a_data_toggle_exists_after = isset($after['a']['data-toggle']);
     $this->assertTrue($a_data_toggle_exists_after);
     // Ensure we can use data-category attributes for divs
     $div_data_category_exists_after = isset($after['div']['data-category']);
     $this->assertTrue($div_data_category_exists_after);
 }
开发者ID:Juliandra,项目名称:ubc-use-template-shortcode,代码行数:19,代码来源:test-ubc-use-template-shortcode.php


示例19: kses_html

 public static function kses_html($html)
 {
     if (function_exists('wp_kses_allowed_html')) {
         $allowed_post_html = wp_kses_allowed_html('post');
     } else {
         global $allowedposttags;
         $allowed_post_html = $allowedposttags;
     }
     $allow = array_merge($allowed_post_html, array('link' => array('href' => true, 'rel' => true, 'type' => true), 'style' => array('type' => true)));
     return wp_kses($html, $allow);
 }
开发者ID:rku4er,项目名称:vafpress-wp,代码行数:11,代码来源:util.php


示例20: pix_sanitize_editor

function pix_sanitize_editor($content)
{
    if ('' === $content) {
        return '';
    }
    if (current_user_can('unfiltered_html')) {
        return wp_kses($content, wp_kses_allowed_html('post'));
    } else {
        return stripslashes(wp_filter_post_kses(addslashes($content)));
    }
}
开发者ID:pixedelic,项目名称:twentyfifteen-child,代码行数:11,代码来源:sanitize.php



注:本文中的wp_kses_allowed_html函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_kses_array_lc函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_kses函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap