本文整理汇总了PHP中wp_filter_kses函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_filter_kses函数的具体用法?PHP wp_filter_kses怎么用?PHP wp_filter_kses使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_filter_kses函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:n-sane,项目名称:zaroka,代码行数:35,代码来源:bp-xprofile-filters.php
示例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;
}
开发者ID:arobbins,项目名称:iab,代码行数:73,代码来源:options-register.php
示例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;
}
开发者ID:evantbyrne,项目名称:trunk,代码行数:12,代码来源:trunk_post_comment.php
示例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;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:60,代码来源:options.php
示例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);
}
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:31,代码来源:bp-messages-notifications.php
示例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();
}
开发者ID:mahassan,项目名称:shellneverknow,代码行数:36,代码来源:affiliates-admin-affiliates-remove.php
示例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
}
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:59,代码来源:comments.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;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:9,代码来源:bp-forums-filters.php
示例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]);
}
}
}
}
}
}
}
}
}
}
开发者ID:tleonard2,项目名称:durablegbFeb,代码行数:63,代码来源:class-woocommerce-volume-discount-coupons-coupon.php
示例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'));
}
开发者ID:healthcommcore,项目名称:osnap,代码行数:13,代码来源:google-analytics-summary-widget.php
示例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;
}
开发者ID:silverbux,项目名称:smartmag-magazine-wordpress,代码行数:17,代码来源:widget-blocks.php
示例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);
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:52,代码来源:bp-messages-notifications.php
示例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;
}
开发者ID:w392807287,项目名称:FirstRepository,代码行数:55,代码来源:class-decent-comments-renderer.php
示例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);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:46,代码来源:bp-messages-notifications.php
示例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>";
}
开发者ID:laiello,项目名称:xiyoulinux,代码行数:18,代码来源:project_api.php
示例16: qa_buddypress_activity_post
function qa_buddypress_activity_post($args)
{
global $bp;
$defaults = array('content' => false, 'user_id' => $bp->loggedin_user->id);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
// Record this on the user's profile
$from_user_link = bp_core_get_userlink($user_id);
$activity_action = $action;
$activity_content = $content;
$primary_link = bp_core_get_userlink($user_id, false, true);
// Now write the values
$activity_id = bp_activity_add(array('user_id' => $user_id, 'action' => apply_filters('bp_activity_new_update_action', $activity_action), 'content' => apply_filters('bp_activity_new_update_content', $activity_content), 'primary_link' => apply_filters('bp_activity_new_update_primary_link', $primary_link), 'component' => $bp->activity->id, 'type' => $type));
// Add this update to the "latest update" usermeta so it can be fetched anywhere.
bp_update_user_meta($bp->loggedin_user->id, 'bp_latest_update', array('id' => $activity_id, 'content' => wp_filter_kses($content)));
do_action('bp_activity_posted_update', $content, $user_id, $activity_id);
return $activity_id;
}
开发者ID:NoahY,项目名称:q2a-buddypress,代码行数:18,代码来源:qa-plugin.php
示例17: messages_notification_new_message
function messages_notification_new_message( $args ) {
global $bp;
extract($args);
$sender_name = bp_core_get_user_displayname( $sender_id );
foreach( $recipients as $recipient ) {
if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) continue;
$ud = get_userdata( $recipient->user_id );
$message_link = bp_core_get_user_domain( $recipient->user_id ) . BP_MESSAGES_SLUG .'/';
$settings_link = bp_core_get_user_domain( $recipient->user_id ) . BP_SETTINGS_SLUG . '/notifications/';
$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_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
$email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name );
$email_content = sprintf( __(
'%s sent you a new message:
Subject: %s
"%s"
To view and read your messages please log in and visit: %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 );
wp_mail( $email_to, $email_subject, $email_content );
}
}
开发者ID:n-sane,项目名称:zaroka,代码行数:44,代码来源:bp-messages-notifications.php
示例18: bp_links_at_message_notification
function bp_links_at_message_notification($content, $poster_user_id, $link_id, $activity_id)
{
global $bp;
/* Scan for @username strings in an activity update. Notify each user. */
$pattern = '/[@]+([A-Za-z0-9-_]+)/';
preg_match_all($pattern, $content, $usernames);
/* Make sure there's only one instance of each username */
if (!($usernames = array_unique($usernames[1]))) {
return false;
}
$link = new BP_Links_Link($link_id);
foreach ((array) $usernames as $username) {
if (!($receiver_user_id = bp_core_get_userid($username))) {
continue;
}
if (!bp_links_is_link_visibile($link, $receiver_user_id)) {
continue;
}
// Now email the user with the contents of the message (if they have enabled email notifications)
if ('no' != get_usermeta($user_id, 'notification_activity_new_mention')) {
$poster_name = bp_core_get_user_displayname($poster_user_id);
$message_link = bp_activity_get_permalink($activity_id);
$settings_link = bp_core_get_user_domain($receiver_user_id) . 'settings/notifications/';
// Set up and send the message
$ud = bp_core_get_core_userdata($receiver_user_id);
$to = $ud->user_email;
$subject = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . '] ' . sprintf(__('%s mentioned you in the link "%s"', 'buddypress-links'), stripslashes($poster_name), wp_filter_kses(stripslashes($link->name)));
$message = sprintf(__('%s mentioned you in the link "%s":
"%s"
To view and respond to the message, log in and visit: %s
---------------------
', 'buddypress-links'), $poster_name, wp_filter_kses(stripslashes_deep($link->name)), wp_filter_kses(stripslashes_deep($content)), $message_link);
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
// Send it
wp_mail($to, $subject, $message);
}
}
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:41,代码来源:bp-links-notifications.php
示例19: cf_sanitize_values_on_save
public static function cf_sanitize_values_on_save($value)
{
if (current_user_can('unfiltered_html')) {
if (is_array($value)) {
foreach ($value as $val) {
$val = self::cf_sanitize_values_on_save($val);
}
} else {
$value = wp_filter_post_kses($value);
}
} else {
if (is_array($value)) {
foreach ($value as $val) {
$val = self::cf_sanitize_values_on_save($val);
}
} else {
$value = wp_filter_kses($value);
}
}
return $value;
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:21,代码来源:StaticClass.php
示例20: sanitize_option
/**
* Sanitises various option values based on the nature of the option.
*
* This is basically a switch statement which will pass $value through a number
* of functions depending on the $option.
*
* @since 2.0.5
*
* @param string $option The name of the option.
* @param string $value The unsanitised value.
* @return string Sanitized value.
*/
function sanitize_option($option, $value)
{
switch ($option) {
case 'admin_email':
$value = sanitize_email($value);
if (!is_email($value)) {
$value = get_option($option);
// Resets option to stored value in the case of failed sanitization
if (function_exists('add_settings_error')) {
add_settings_error('admin_email', 'invalid_admin_email', __('The email address entered did not appear to be a valid email address. Please enter a valid email address.'));
}
}
break;
case 'thumbnail_size_w':
case 'thumbnail_size_h':
case 'medium_size_w':
case 'medium_size_h':
case 'large_size_w':
case 'large_size_h':
case 'embed_size_h':
case 'default_post_edit_rows':
case 'mailserver_port':
case 'comment_max_links':
case 'page_on_front':
case 'page_for_posts':
case 'rss_excerpt_length':
case 'default_category':
case 'default_email_category':
case 'default_link_category':
case 'close_comments_days_old':
case 'comments_per_page':
case 'thread_comments_depth':
case 'users_can_register':
case 'start_of_week':
$value = absint($value);
break;
case 'embed_size_w':
if ('' !== $value) {
$value = absint($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':
$value = addslashes($value);
$value = wp_filter_post_kses($value);
// calls stripslashes then addslashes
$value = stripslashes($value);
$value = esc_html($value);
break;
case 'blog_charset':
$value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
// strips slashes
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 = addslashes($value);
$value = wp_filter_kses($value);
// calls stripslashes then addslashes
$value = stripslashes($value);
break;
case 'gmt_offset':
$value = preg_replace('/[^0-9:.-]/', '', $value);
// strips slashes
break;
case 'siteurl':
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:cartonbank,代码行数:101,代码来源:formatting.php
注:本文中的wp_filter_kses函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论