本文整理汇总了PHP中wp_kses_allowed_html函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_kses_allowed_html函数的具体用法?PHP wp_kses_allowed_html怎么用?PHP wp_kses_allowed_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_kses_allowed_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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'));
}
示例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);
}
}
示例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;
}
示例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);
}
示例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>';
}
}
}