本文整理汇总了PHP中wp_filter_kses函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_filter_kses函数的具体用法?PHP wp_filter_kses怎么用?PHP wp_filter_kses使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_filter_kses函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xprofile_sanitize_data_value_before_save
/**
* xprofile_sanitize_data_value_before_save ( $field_value, $field_id )
*
* Safely runs profile field data through kses and force_balance_tags.
*
* @param string $field_value
* @param int $field_id
* @return string
*/
function xprofile_sanitize_data_value_before_save ( $field_value, $field_id ) {
// Return if empty
if ( empty( $field_value ) )
return;
// Value might be serialized
$field_value = maybe_unserialize( $field_value );
// Filter single value
if ( !is_array( $field_value ) ) {
$kses_field_value = wp_filter_kses( $field_value );
$filtered_field_value = force_balance_tags( $kses_field_value );
// Filter each array item independently
} else {
foreach ( (array)$field_value as $value ) {
$kses_field_value = wp_filter_kses( $value );
$filtered_values[] = force_balance_tags( $kses_field_value );
}
$filtered_field_value = serialize( $filtered_values );
}
return $filtered_field_value;
}
示例2: cbnetdppp_options_validate
/**
* Plugin register_setting() sanitize callback
*
* Validate and whitelist user-input data before updating Plugin
* Options in the database. Only whitelisted options are passed
* back to the database, and user-input data for all whitelisted
* options are sanitized.
*
* @link http://codex.wordpress.org/Data_Validation Codex Reference: Data Validation
*
* @param array $input Raw user-input data submitted via the Plugin Settings page
* @return array $input Sanitized user-input data passed to the database
*/
function cbnetdppp_options_validate($input)
{
// This is the "whitelist": current settings
$valid_input = cbnetdppp_get_options();
// Get the array of option parameters
$option_parameters = cbnetdppp_get_option_parameters();
// Get the array of option defaults
$option_defaults = cbnetdppp_get_option_defaults();
// Determine what type of submit was input
$submittype = !empty($input['reset']) ? 'reset' : 'submit';
// Loop through each setting
foreach ($option_defaults as $setting => $value) {
// If no option is selected, set the default
//$valid_input[$setting] = ( ! isset( $input[$setting] ) ? $option_defaults[$setting] : $input[$setting] );
// If submit, validate/sanitize $input
if ('submit' == $submittype) {
// Get the setting details from the defaults array
$optiondetails = $option_parameters[$setting];
// Get the array of valid options, if applicable
$valid_options = isset($optiondetails['valid_options']) ? $optiondetails['valid_options'] : false;
// Validate checkbox fields
if ('checkbox' == $optiondetails['type']) {
// If input value is set and is true, return true; otherwise return false
$valid_input[$setting] = isset($input[$setting]) && true == $input[$setting] ? true : false;
} else {
if ('radio' == $optiondetails['type']) {
// Only update setting if input value is in the list of valid options
$valid_input[$setting] = array_key_exists($input[$setting], $valid_options) ? $input[$setting] : $valid_input[$setting];
} else {
if ('select' == $optiondetails['type']) {
// Only update setting if input value is in the list of valid options
$valid_input[$setting] = array_key_exists($input[$setting], $valid_options) ? $input[$setting] : $valid_input[$setting];
} else {
if ('text' == $optiondetails['type'] || 'textarea' == $optiondetails['type']) {
// Validate no-HTML content
if ('nohtml' == $optiondetails['sanitize']) {
// Pass input data through the wp_filter_nohtml_kses filter
$valid_input[$setting] = wp_filter_nohtml_kses($input[$setting]);
}
// Validate HTML content
if ('html' == $optiondetails['sanitize']) {
// Pass input data through the wp_filter_kses filter
$valid_input[$setting] = wp_filter_kses($input[$setting]);
}
// Validate integer content
if ('integer' == $optiondetails['sanitize']) {
// Verify value is an integer
$valid_input[$setting] = is_int((int) $input[$setting]) ? $input[$setting] : $valid_input[$setting];
}
}
}
}
}
} elseif ('reset' == $submittype) {
// Set $setting to the default value
$valid_input[$setting] = $option_defaults[$setting];
}
}
return $valid_input;
}
示例3: content
/**
* Returns HTML formatted comment content. Cleans returned content of any XSS.
*
* @return string
*/
public function content()
{
if ($this->content === null) {
$this->content = stripcslashes(apply_filters('comment_text', wp_filter_kses($this->c->comment_content)));
}
return $this->content;
}
示例4: sanitize_option
function sanitize_option($option, $value) {
switch ($option) {
case 'admin_email':
$value = sanitize_email($value);
break;
case 'default_post_edit_rows':
case 'mailserver_port':
case 'comment_max_links':
$value = abs((int) $value);
break;
case 'posts_per_page':
case 'posts_per_rss':
$value = (int) $value;
if ( empty($value) ) $value = 1;
if ( $value < -1 ) $value = abs($value);
break;
case 'default_ping_status':
case 'default_comment_status':
// Options that if not there have 0 value but need to be something like "closed"
if ( $value == '0' || $value == '')
$value = 'closed';
break;
case 'blogdescription':
case 'blogname':
if (current_user_can('unfiltered_html') == false)
$value = wp_filter_post_kses( $value );
break;
case 'blog_charset':
$value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
break;
case 'date_format':
case 'time_format':
case 'mailserver_url':
case 'mailserver_login':
case 'mailserver_pass':
case 'ping_sites':
case 'upload_path':
$value = strip_tags($value);
$value = wp_filter_kses($value);
break;
case 'gmt_offset':
$value = preg_replace('/[^0-9:.-]/', '', $value);
break;
case 'siteurl':
case 'home':
$value = clean_url($value);
break;
}
return $value;
}
示例5: messages_notification_new_message
function messages_notification_new_message($args)
{
global $bp;
extract($args);
$message = new BP_Messages_Message($item_id);
$sender_name = bp_fetch_user_fullname($message->sender_id, false);
for ($i = 0; $i < count($recipient_ids); $i++) {
if ($message->sender_id == $recipient_ids[$i] || 'no' == get_userdata($recipient_ids[$i], 'notification-messages-new-message')) {
continue;
}
$ud = get_userdata($recipient_ids[$i]);
$message_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/messages/view/' . $message->id;
$settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
// Set up and send the message
$to = $ud->user_email;
$subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('New message from %s', 'buddypress'), stripslashes($sender_name));
$content = sprintf(__('%s sent you a new message:
Subject: %s
"%s"
To view the message: %s
---------------------
', 'buddypress'), $sender_name, stripslashes(wp_filter_kses($message->subject)), stripslashes(wp_filter_kses($message->message)), $message_link);
$content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
// Send it
wp_mail($to, $subject, $content);
}
}
示例6: affiliates_admin_affiliates_remove
/**
* Show form to remove an affiliate.
* @param int $affiliate_id affiliate id
*/
function affiliates_admin_affiliates_remove($affiliate_id)
{
global $wpdb;
if (!current_user_can(AFFILIATES_ADMINISTER_AFFILIATES)) {
wp_die(__('Access denied.', AFFILIATES_PLUGIN_DOMAIN));
}
$affiliate = affiliates_get_affiliate(intval($affiliate_id));
if (empty($affiliate)) {
wp_die(__('No such affiliate.', AFFILIATES_PLUGIN_DOMAIN));
}
$affiliates_users_table = _affiliates_get_tablename('affiliates_users');
$affiliate_user = null;
$affiliate_user_edit = '';
$affiliate_user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$affiliates_users_table} WHERE affiliate_id = %d", intval($affiliate_id)));
if ($affiliate_user_id !== null) {
$affiliate_user = get_user_by('id', intval($affiliate_user_id));
if ($affiliate_user) {
if (current_user_can('edit_user', $affiliate_user->ID)) {
$affiliate_user_edit = sprintf(__('Edit %s', AFFILIATES_PLUGIN_DOMAIN), '<a target="_blank" href="' . esc_url("user-edit.php?user_id={$affiliate_user->ID}") . '">' . $affiliate_user->user_login . '</a>');
} else {
$affiliate_user_edit = $affiliate_user->user_login;
}
}
}
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('affiliate_id', $current_url);
$output = '<div class="manage-affiliates">' . '<div>' . '<h2>' . __('Remove an affiliate', AFFILIATES_PLUGIN_DOMAIN) . '</h2>' . '</div>' . '<form id="remove-affiliate" action="' . $current_url . '" method="post">' . '<div class="affiliate remove">' . '<input id="affiliate-id-field" name="affiliate-id-field" type="hidden" value="' . esc_attr(intval($affiliate_id)) . '"/>' . '<ul>' . '<li>' . sprintf(__('Name : %s', AFFILIATES_PLUGIN_DOMAIN), wp_filter_kses($affiliate['name'])) . '</li>' . '<li>' . sprintf(__('Email : %s', AFFILIATES_PLUGIN_DOMAIN), wp_filter_kses($affiliate['email'])) . '</li>' . '<li>' . sprintf(__('Username : %s', AFFILIATES_PLUGIN_DOMAIN), wp_filter_kses($affiliate_user_edit)) . '</li>' . '<li>' . sprintf(__('From : %s', AFFILIATES_PLUGIN_DOMAIN), wp_filter_kses($affiliate['from_date'])) . '</li>' . '<li>' . sprintf(__('Until : %s', AFFILIATES_PLUGIN_DOMAIN), wp_filter_kses($affiliate['from_date'])) . '</li>' . '</ul> ' . wp_nonce_field('affiliates-remove', AFFILIATES_ADMIN_AFFILIATES_NONCE, true, false) . '<input class="button" type="submit" value="' . __('Remove', AFFILIATES_PLUGIN_DOMAIN) . '"/>' . '<input type="hidden" value="remove" name="action"/>' . '<a class="cancel" href="' . $current_url . '">' . __('Cancel', AFFILIATES_PLUGIN_DOMAIN) . '</a>' . '</div>' . '</div>' . '</form>' . '</div>';
// .manage-affiliates
echo $output;
affiliates_footer();
}
示例7: dsq_render_single_comment
function dsq_render_single_comment($comment, $args, $depth)
{
$GLOBALS['comment'] = $comment;
?>
<li id="dsq-comment-<?php
echo (int) get_comment_ID();
?>
">
<div id="dsq-comment-header-<?php
echo (int) get_comment_ID();
?>
" class="dsq-comment-header">
<cite id="dsq-cite-<?php
echo (int) get_comment_ID();
?>
">
<?php
if (comment_author_url()) {
?>
<a id="dsq-author-user-<?php
echo (int) get_comment_ID();
?>
" href="<?php
echo esc_url(get_comment_author_url());
?>
" target="_blank" rel="nofollow"><?php
echo esc_html(get_comment_author());
?>
</a>
<?php
} else {
?>
<span id="dsq-author-user-<?php
echo (int) get_comment_ID();
?>
"><?php
echo esc_html(get_comment_author());
?>
</span>
<?php
}
?>
</cite>
</div>
<div id="dsq-comment-body-<?php
echo (int) get_comment_ID();
?>
" class="dsq-comment-body">
<div id="dsq-comment-message-<?php
echo (int) get_comment_ID();
?>
" class="dsq-comment-message"><?php
wp_filter_kses(comment_text());
?>
</div>
</div>
</li>
<?php
}
示例8: bp_forums_filter_decode
function bp_forums_filter_decode($content)
{
$content = str_replace('/amp/', '&', $content);
$content = @html_entity_decode($content, ENT_COMPAT, "UTF-8");
$content = str_replace('[', '<', $content);
$content = str_replace(']', '>', $content);
$content = stripslashes(wp_filter_kses($content));
return $content;
}
示例9: wp_init
/**
* Automatically apply coupons.
*
* Also removes auto-apply coupons (although that should happen
* automatically, it seems we're on the safer side doing that as well
* here).
*/
public static function wp_init()
{
global $wpdb, $woocommerce;
if (isset($woocommerce) && isset($woocommerce->cart) && $woocommerce->cart->coupons_enabled()) {
$coupons = $wpdb->get_results("SELECT DISTINCT ID, post_title FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id WHERE {$wpdb->posts}.post_status = 'publish' AND {$wpdb->postmeta}.meta_key = '_vd_auto'");
if ($coupons && count($coupons) > 0) {
foreach ($coupons as $coupon) {
$coupon_code = $coupon->post_title;
$coupon = new WC_Coupon($coupon_code);
if ($coupon->id) {
if ($coupon->is_valid()) {
if (!$woocommerce->cart->has_discount($coupon_code)) {
$woocommerce->cart->add_discount($coupon_code);
$msg = '';
$message = get_post_meta($coupon->id, '_vd_auto_message_display', true);
$show_description = get_post_meta($coupon->id, '_vd_auto_description_display', true) == 'yes';
$show_info = get_post_meta($coupon->id, '_vd_auto_info_display', true) == 'yes';
if (!empty($message)) {
$msg .= sprintf('<div class="coupon display message %s">', wp_strip_all_tags($coupon->code));
$msg .= stripslashes(wp_filter_kses($message));
$msg .= '</div>';
}
if ($show_description) {
if ($post = get_post($coupon->id)) {
if (!empty($post->post_excerpt)) {
$msg .= sprintf('<div class="coupon display description %s">', wp_strip_all_tags($coupon->code));
$msg .= stripslashes(wp_filter_kses($post->post_excerpt));
$msg .= '</div>';
}
}
}
if ($show_info) {
$msg .= sprintf('<div class="coupon display volume-discount %s">', wp_strip_all_tags($coupon->code));
$msg .= WooCommerce_Volume_Discount_Coupons_Shortcodes::get_volume_discount_info($coupon);
$msg .= '</div>';
}
if (!empty($msg)) {
$woocommerce->add_message($msg);
}
}
} else {
if ($woocommerce->cart->has_discount($coupon_code)) {
if (!empty($woocommerce->cart->applied_coupons)) {
foreach ($woocommerce->cart->applied_coupons as $index => $code) {
if ($coupon_code == $code) {
unset($woocommerce->cart->applied_coupons[$index]);
}
}
}
}
}
}
}
}
}
}
示例10: GoogleAnalyticsSummary
/**
* Start the process of including the widget
**/
function GoogleAnalyticsSummary()
{
add_action('wp_dashboard_setup', array($this, 'addDashboardWidget'));
add_action('admin_footer', array($this, 'addJavascript'));
add_action('admin_footer-index.php', array($this, 'addTopJs'));
$this->qa_selecteddate = isset($_REQUEST['qa_selecteddate']) ? wp_filter_kses($_REQUEST['qa_selecteddate']) : '31';
$this->date_before = date('Y-m-d', strtotime('-' . $this->qa_selecteddate . ' days', strtotime(current_time('mysql'))));
$this->date_yesterday = date('Y-m-d', strtotime('-1 days', strtotime(current_time('mysql'))));
add_action('wp_ajax_ga_stats_widget', array($this, 'ajaxWidget'));
}
示例11: update
/**
* Save the widget data'
*
* @see WP_Widget::update()
*/
public function update($new, $old)
{
foreach ($new as $key => $val) {
if (is_array($val)) {
foreach ($val as $key => $value) {
$val[$key] = wp_filter_kses($val);
}
}
$new[$key] = wp_filter_kses($val);
}
return $new;
}
示例12: messages_notification_new_message
function messages_notification_new_message($args = array())
{
// These should be extracted below
$recipients = array();
$email_subject = $email_content = '';
extract($args);
$sender_name = bp_core_get_user_displayname($sender_id);
// Bail if no recipients
if (!empty($recipients)) {
foreach ($recipients as $recipient) {
if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
continue;
}
// User data and links
$ud = get_userdata($recipient->user_id);
// Bail if user cannot be found
if (empty($ud)) {
continue;
}
$message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
// Sender info
$sender_name = stripslashes($sender_name);
$subject = stripslashes(wp_filter_kses($subject));
$content = stripslashes(wp_filter_kses($content));
// Set up and send the message
$email_to = $ud->user_email;
$email_subject = bp_get_email_subject(array('text' => sprintf(__('New message from %s', 'buddypress'), $sender_name)));
$email_content = sprintf(__('%1$s sent you a new message:
Subject: %2$s
"%3$s"
To view and read your messages please log in and visit: %4$s
---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
// Only show the disable notifications line if the settings component is enabled
if (bp_is_active('settings')) {
$email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
}
// Send the message
$email_to = apply_filters('messages_notification_new_message_to', $email_to);
$email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
$email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
wp_mail($email_to, $email_subject, $email_content);
}
}
do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
示例13: get_comment
/**
* Renders a comment according to the $options given.
*
* @param int $comment_ID the comment ID
* @param array $options used to specify rendering settings, defaults apply if none given
* @return rendered comment
* @see Decent_Comments_Renderer::$defaults
*/
static function get_comment($comment_ID = 0, $options = array())
{
$ellipsis = self::$defaults['ellipsis'];
if (isset($options["ellipsis"])) {
$ellipsis = wp_filter_kses(addslashes($options["ellipsis"]));
}
$excerpt = self::$defaults['excerpt'];
if (isset($options["excerpt"])) {
$excerpt = $options["excerpt"] !== false;
}
$max_excerpt_words = self::$defaults['max_excerpt_words'];
if (isset($options["max_excerpt_words"])) {
$max_excerpt_words = intval($options["max_excerpt_words"]);
}
$strip_tags = self::$defaults['strip_tags'];
if (isset($options["strip_tags"])) {
$strip_tags = $options["strip_tags"] !== false;
}
$output = "";
$comment = get_comment($comment_ID);
if ($comment) {
if ($strip_tags) {
$content = strip_tags($comment->comment_content);
} else {
$content = $comment->comment_content;
}
// guard against shortcodes in comments
$content = str_replace("[", "[", $content);
$content = str_replace("]", "]", $content);
if ($excerpt) {
$content = preg_replace("/\\s+/", " ", $content);
$words = explode(" ", $content);
$nwords = count($words);
for ($i = 0; $i < $max_excerpt_words && $i < $nwords; $i++) {
$output .= $words[$i];
if ($i < $max_excerpt_words - 1) {
$output .= " ";
} else {
$output .= $ellipsis;
}
}
} else {
$output = $content;
}
}
return $output;
}
示例14: messages_notification_new_message
function messages_notification_new_message($args = array())
{
// These should be extracted below
$recipients = array();
$email_subject = $email_content = '';
extract($args);
$sender_name = bp_core_get_user_displayname($sender_id);
// Bail if no recipients
if (!empty($recipients)) {
foreach ($recipients as $recipient) {
if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
continue;
}
// User data and links
$ud = get_userdata($recipient->user_id);
$message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
// Sender info
$sender_name = stripslashes($sender_name);
$subject = stripslashes(wp_filter_kses($subject));
$content = stripslashes(wp_filter_kses($content));
// Set up and send the message
$email_to = $ud->user_email;
$sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
$email_subject = '[' . $sitename . '] ' . sprintf(__('New message from %s', 'buddypress'), $sender_name);
$email_content = sprintf(__('%1$s sent you a new message:
Subject: %2$s
"%3$s"
To view and read your messages please log in and visit: %4$s
---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
$email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
// Send the message
$email_to = apply_filters('messages_notification_new_message_to', $email_to);
$email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
$email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
wp_mail($email_to, $email_subject, $email_content);
}
}
do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
示例15: print_feed
function print_feed($myfeed = 'http://code.google.com/feeds/p/xiyoulinux/updates/basic', $feedtitle = '西邮Linux小组网站更新', $shownumber = '3')
{
require_once ABSPATH . WPINC . '/rss-functions.php';
$rss = @fetch_rss($myfeed);
if (isset($rss->items) && 0 != count($rss->items)) {
echo '<h3>' . $feedtitle . '</h3><ul>';
$rss->items = array_slice($rss->items, 0, $shownumber);
foreach ($rss->items as $item) {
$title = wp_specialchars($item['title']);
$url = wp_filter_kses($item['link']);
//echo $title;
//echo $url;
echo "<li><a href={$url}>{$title}</a></li>";
//echo $item['description'];
}
}
echo "</ul>";
}