本文整理汇总了PHP中wp_strip_all_tags函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_strip_all_tags函数的具体用法?PHP wp_strip_all_tags怎么用?PHP wp_strip_all_tags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_strip_all_tags函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates a patchchat post by
* creating a user,
* creating a new patchchat post,
* creating first comment to post,
* adding an 'instant reply' comment from admin,
* building a new transient,
* return new transient to new user
*
* @author caseypatrickdriscoll
*
* @edited 2015-08-03 16:32:16 - Adds user signon after creation
* @edited 2015-08-28 20:11:39 - Adds PatchChat_Settings::instant_reply
* @edited 2015-08-28 20:19:22 - Adds PatchChat_Settings::bot
*/
public static function create($patchchat)
{
$email = $patchchat['email'];
$text = $patchchat['text'];
$username = substr($email, 0, strpos($email, "@"));
$password = wp_generate_password(10, false);
$title = substr($text, 0, 40);
$time = current_time('mysql');
$text = wp_strip_all_tags($text);
/* Create User */
$user_id = wp_create_user($username, $password, $email);
// TODO: Add the user's name to the user
// TODO: Check to see if user logged in, no need to create again
wp_new_user_notification($user_id, $password);
$user = get_user_by('id', $user_id);
$creds = array('user_login' => $user->user_login, 'user_password' => $password, 'remember' => true);
$user_signon = wp_signon($creds, false);
/* Create PatchChat Post */
$post = array('post_title' => $title, 'post_type' => 'patchchat', 'post_author' => $user_id, 'post_status' => 'new', 'post_date' => $time);
$post_id = wp_insert_post($post);
/* Create First Comment */
$comment = array('comment_post_ID' => $post_id, 'user_id' => $user_id, 'comment_content' => $text, 'comment_date' => $time, 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_agent' => $_SERVER['HTTP_USER_AGENT']);
$comment_id = wp_insert_comment($comment);
/* Insert default action comment reply */
$options = array('chatid' => $post_id, 'displayname' => $user->display_name);
$comment = array('comment_post_ID' => $post_id, 'user_id' => PatchChat_Settings::bot(), 'comment_content' => PatchChat_Settings::instant_reply($options), 'comment_type' => 'auto', 'comment_date' => current_time('mysql'));
$comment_id = wp_insert_comment($comment);
// Will build the Transient
PatchChat_Transient::get($post_id);
return PatchChat_Controller::get_user_state($user_id);
}
示例2: fb_strip_and_format_desc
function fb_strip_and_format_desc($post)
{
$desc_no_html = "";
$desc_no_html = strip_shortcodes($desc_no_html);
// Strip shortcodes first in case there is HTML inside the shortcode
$desc_no_html = wp_strip_all_tags($desc_no_html);
// Strip all html
$desc_no_html = trim($desc_no_html);
// Trim the final string, we may have stripped everything out of the post so this will make the value empty if that's the case
// Check if empty, may be that the strip functions above made excerpt empty, doubhtful but we want to be 100% sure.
if (empty($desc_no_html)) {
$desc_no_html = $post->post_content;
// Start over, this time with the post_content
$desc_no_html = strip_shortcodes($desc_no_html);
// Strip shortcodes first in case there is HTML inside the shortcode
$desc_no_html = str_replace(']]>', ']]>', $desc_no_html);
// Angelo Recommendation, if for some reason ]]> happens to be in the_content, rare but We've seen it happen
$desc_no_html = wp_strip_all_tags($desc_no_html);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$desc_no_html = wp_trim_words($desc_no_html, $excerpt_length, $excerpt_more);
$desc_no_html = trim($desc_no_html);
// Trim the final string, we may have stripped everything out of the post so this will make the value empty if that's the case
}
$desc_no_html = str_replace(array("\r\n", "\r", "\n"), ' ', $desc_no_html);
// I take it Facebook doesn't like new lines?
return $desc_no_html;
}
示例3: sm_blockquotes_insert
function sm_blockquotes_insert($atts, $content = null)
{
$atts = shortcode_atts(array('cite' => 'Citation', 'type' => 'left', 'content' => !empty($content) ? $content : 'Content Goes Here'), $atts);
extract($atts);
$shape = '';
$cite = wp_strip_all_tags($cite);
$content = wp_strip_all_tags($content);
/*
* Blockquotes
*/
if (strtolower($type) == 'left') {
$shape .= "<div class = 'sm_blockquote left_text'> {$content} ";
$shape .= "<cite class = 'sm_blockquote_cite' >- {$cite}</cite></div>";
return $shape;
}
if (strtolower($type) == 'center') {
$shape .= "<div class = 'sm_blockquote center_text'> {$content} ";
$shape .= "<cite class = 'sm_blockquote_cite' >- {$cite}</cite></div>";
return $shape;
}
if (strtolower($type) == 'right') {
$shape .= "<div class = 'sm_blockquote right_text'> {$content} ";
$shape .= "<cite class = 'sm_blockquote_cite' >- {$cite}</cite></div>";
return $shape;
}
}
示例4: smart_excerpt
/**
* Smart Excerpt
*
* Returns an excerpt which is not longer than the given length and always
* ends with a complete sentence. If first sentence is longer than length,
* it will add the standard ellipsis… Length is the number of characters.
*
* Usage: <?php smart_excerpt(450); >
*
* http://www.distractedbysquirrels.com/blog/wordpress-improved-dynamic-excerpt
*/
function smart_excerpt($length, $postId = false)
{
if ($postId) {
$post = get_post($postId);
$text = $post->post_excerpt;
} else {
global $post;
$text = $post->post_excerpt;
}
if ('' == $text) {
if ($postId) {
$text = $post->post_content;
} else {
$text = get_the_content('');
}
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
}
$text = strip_shortcodes($text);
$text = wp_strip_all_tags($text, true);
if (empty($length)) {
$length = 300;
}
$text = substr($text, 0, $length);
$excerpt = nucleus_reverse_strrchr($text, '.', 1);
if ($excerpt) {
echo apply_filters('the_excerpt', $excerpt);
} else {
echo apply_filters('the_excerpt', $text . '…');
}
}
示例5: oxford_comment_form_defaults
/**
* Change the comment form defaults.
*
* @since 1.0.
*
* @param array $defaults The default values.
* @return array The modified defaults.
*/
function oxford_comment_form_defaults($defaults)
{
$input_size = 22;
// Comment form title
$defaults['title_reply'] = __('Leave a comment', 'oxford');
// Comment form notes
$defaults['comment_notes_before'] = '';
$defaults['comment_notes_after'] = '';
// Comment Author
$comment_author = isset($_POST['author']) ? wp_strip_all_tags($_POST['author'], true) : null;
$author_field = sprintf('<p class="comment-form-author"><input class="text-input respond-type" type="text" name="%1$s" id="%1$s" value="%3$s" size="%4$d" aria-required="true" tabindex="%5$d" placeholder="%2$s" /></p>', 'author', esc_attr_x('Name', 'comment field placeholder', 'oxford'), esc_attr($comment_author), $input_size, 1);
// Comment Author Email
$comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null;
$email_field = sprintf('<p class="comment-form-email"><input class="text-input respond-type" type="email" name="%1$s" id="%1$s" value="%3$s" size="%4$d" aria-required="true" tabindex="%5$d" placeholder="%2$s" /></p>', 'email', esc_attr_x('Email', 'comment field placeholder', 'oxford'), esc_attr($comment_author_email), $input_size, 2);
// Comment Author URL
$comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null;
$url_field = sprintf('<p class="comment-form-url"><input class="text-input respond-type" type="url" name="%1$s" id="%1$s" value="%3$s" size="%4$d" tabindex="%5$d" placeholder="%2$s" /></p>', 'url', esc_attr_x('Website', 'comment field placeholder', 'oxford'), esc_attr($comment_author_url), $input_size, 3);
// Set the fields in the $defaults array
$defaults['fields'] = array('author' => $author_field, 'email' => $email_field, 'url' => $url_field);
// Comment Form
$defaults['comment_field'] = sprintf('<p class="comment-form-comment"><textarea id="comment" class="blog-textarea respond-type" name="comment" cols="58" rows="10" aria-required="true" tabindex="4" placeholder="%s"></textarea></p>', esc_attr_x('Type reply here…', 'comment field placeholder', 'oxford'));
// Submit label
$defaults['label_submit'] = __('Post comment', 'oxford');
return $defaults;
}
示例6: crop_str
/**
* Truncates a string to be shorter than or equal to the length specified
* Attempts to truncate on word boundaries
*
* @param string $string
* @param int $length
* @return string
*/
function crop_str($string, $length = 256)
{
$string = wp_strip_all_tags((string) $string, true);
// true: collapse Linear Whitespace into " "
$length = absint($length);
if (mb_strlen($string, 'UTF-8') <= $length) {
return $string;
}
// @see wp_trim_words()
if ('characters' == _x('words', 'word count: words or characters?', 'jetpack')) {
return trim(mb_substr($string, 0, $length - 1, 'UTF-8')) . "…";
// ellipsis
}
$words = explode(' ', $string);
$return = '';
while (strlen($word = array_shift($words))) {
$new_return = $return ? "{$return} {$word}" : $word;
$new_return_length = mb_strlen($new_return, 'UTF-8');
if ($new_return_length < $length - 1) {
$return = $new_return;
continue;
} elseif ($new_return_length == $length - 1) {
$return = $new_return;
break;
}
if (!$return) {
$return = mb_substr($new_return, 0, $length - 1, 'UTF-8');
}
break;
}
return "{$return}…";
// ellipsis
}
示例7: ty_save_post_data
function ty_save_post_data()
{
if (empty($_POST) || !wp_verify_nonce($_POST['name_of_nonce_field'], 'name_of_my_action')) {
print 'Sorry, your nonce did not verify.';
exit;
} else {
// Do some minor form validation to make sure there is content
if (isset($_POST['title'])) {
$title = $_POST['title'];
} else {
echo 'Please enter a title';
exit;
}
if (isset($_POST['description'])) {
$description = $_POST['description'];
} else {
echo 'Please enter the content';
exit;
}
if (isset($_POST['post_tags'])) {
$tags = $_POST['post_tags'];
} else {
$tags = "";
}
// Add the content of the form to $post as an array
$post = array('post_title' => wp_strip_all_tags($title), 'post_content' => $description, 'post_category' => $_POST['cat'], 'tags_input' => $tags, 'post_status' => 'publish', 'post_type' => $_POST['post-type']);
wp_insert_post($post);
// http://codex.wordpress.org/Function_Reference/wp_insert_post
$location = home_url();
// redirect location, should be login page
echo "<meta http-equiv='refresh' content='0;url={$location}' />";
exit;
}
// end IF
}
示例8: wl_serialize_entity
/**
* Serialize an entity post.
*
* @param array $entity The entity post or the entity post id.
*
* @return array mixed The entity data array.
*/
function wl_serialize_entity($entity)
{
$entity = is_numeric($entity) ? get_post($entity) : $entity;
$type = wl_entity_type_taxonomy_get_type($entity->ID);
$images = wl_get_image_urls($entity->ID);
return array('id' => wl_get_entity_uri($entity->ID), 'label' => $entity->post_title, 'description' => wp_strip_all_tags($entity->post_content), 'sameAs' => wl_schema_get_value($entity->ID, 'sameAs'), 'mainType' => str_replace('wl-', '', $type['css_class']), 'types' => wl_get_entity_rdf_types($entity->ID), 'images' => $images);
}
示例9: update_collection
function update_collection($collectionId, $collection)
{
global $wplr;
$id = $wplr->get_meta("cosmothemes_gallery_id", $collectionId);
$post = array('ID' => $id, 'post_title' => wp_strip_all_tags($collection['name']));
wp_update_post($post);
}
示例10: import
/**
* import function.
*
* @access public
* @param array $array
* @param array $columns
* @return void
*/
function import($array = array(), $columns = array('post_title'))
{
$this->imported = $this->skipped = 0;
if (!is_array($array) || !sizeof($array)) {
$this->footer();
die;
}
$rows = array_chunk($array, sizeof($columns));
foreach ($rows as $row) {
$row = array_filter($row);
if (empty($row)) {
continue;
}
$meta = array();
foreach ($columns as $index => $key) {
$meta[$key] = sp_array_value($row, $index);
}
$name = sp_array_value($meta, 'post_title');
if (!$name) {
$this->skipped++;
continue;
}
$args = array('post_type' => 'sp_sponsor', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags($name));
$id = wp_insert_post($args);
// Update URL
update_post_meta($id, 'sp_url', sp_array_value($meta, 'sp_url'));
$this->imported++;
}
// Show Result
echo '<div class="updated settings-error below-h2"><p>
' . sprintf(__('Import complete - imported <strong>%s</strong> sponsors and skipped <strong>%s</strong>.', 'sportspress'), $this->imported, $this->skipped) . '
</p></div>';
$this->import_end();
}
示例11: trigger
/**
* Trigger the tickets email
*
* @param int $payment_id
*
* @return string
*/
public function trigger($payment_id = 0)
{
global $edd_options;
$payment_data = edd_get_payment_meta($payment_id);
$user_id = edd_get_payment_user_id($payment_id);
$user_info = maybe_unserialize($payment_data['user_info']);
$email = edd_get_payment_user_email($payment_id);
if (isset($user_id) && $user_id > 0) {
$user_data = get_userdata($user_id);
$name = $user_data->display_name;
} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
} else {
$name = $email;
}
$message = $this->get_content_html($payment_id);
$from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name');
$from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
$subject = !empty($edd_options['ticket_subject']) ? wp_strip_all_tags($edd_options['ticket_subject'], true) : $this->default_subject;
$subject = apply_filters('edd_ticket_receipt_subject', $subject, $payment_id);
$subject = edd_email_template_tags($subject, $payment_data, $payment_id);
$headers = 'From: ' . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
$headers .= 'Reply-To: ' . $from_email . "\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
$headers = apply_filters('edd_ticket_receipt_headers', $headers, $payment_id, $payment_data);
// Allow add-ons to add file attachments
$attachments = apply_filters('edd_ticket_receipt_attachments', array(), $payment_id, $payment_data);
if (apply_filters('edd_email_ticket_receipt', true)) {
wp_mail($email, $subject, $message, $headers, $attachments);
}
}
示例12: display
/**
* Display or return a formatted output for WP_Error object. For each error in WP_Error object a formatted
* output is done with code error and error data.
*
* @brief Display ot return output
*
* @param bool $echo TRUE to display or FALSE to get output
* @param WPDKWatchDog $log A WPDKWatchDog object to log the display
*
* @return string|void Formatted output if $echo is FALSE
*/
public function display($echo = true, $log = null)
{
$content = '<div class="wpdk-watchdog-wp-error">';
foreach ($this->errors as $code => $single) {
$content .= sprintf('<code>Code: 0x%x, Description: %s</code>', $code, $single[0]);
$error_data = $this->get_error_data($code);
if (!empty($error_data)) {
if (is_array($error_data)) {
foreach ($error_data as $key => $data) {
$content .= sprintf('<code>Key: %s, Data: %s</code>', $key, urldecode($data));
}
} else {
$content .= sprintf('<code>Data: %s</code>', urldecode($error_data));
}
}
}
// log to file if enabled
if (!is_null($log)) {
$log->log(esc_attr(wp_strip_all_tags($content)));
}
$content .= '</div>';
if ($echo) {
echo $content;
return true;
}
return $content;
}
示例13: buddyboss_global_search_reply_intro
/**
* Returns a trimmed reply content string.
* Works for replies as well as topics.
* Must be used while inside the loop
*/
function buddyboss_global_search_reply_intro($character_limit = 50)
{
$content = '';
switch (get_post_type(get_the_ID())) {
case 'topic':
$reply_content = bbp_get_topic_content(get_the_ID());
break;
case 'reply':
$reply_content = bbp_get_reply_content(get_the_ID());
break;
default:
$reply_content = get_the_content();
break;
}
if ($reply_content) {
$content = wp_strip_all_tags($reply_content, true);
$search_term = buddyboss_global_search()->search->get_search_term();
$search_term_position = strpos($content, $search_term);
if ($search_term_position !== false) {
$shortened_content = '...' . substr($content, $search_term_position, $character_limit);
//highlight search keyword
$shortened_content = str_replace($search_term, "<strong>" . $search_term . "</strong>", $shortened_content);
} else {
$shortened_content = substr($content, 0, $character_limit);
}
if (strlen($content) > $character_limit) {
$shortened_content .= '...';
}
$content = $shortened_content;
}
return apply_filters('buddyboss_global_search_reply_intro', $content);
}
示例14: get_shares
function get_shares()
{
global $post;
$perm = get_permalink($post->ID);
$title = wp_strip_all_tags(get_the_title($post->ID));
$thumb = has_post_thumbnail($post->ID) ? pl_the_thumbnail_url($post->ID) : '';
$desc = wp_strip_all_tags(pl_short_excerpt($post->ID, 10, ''));
$out = '';
if (ploption('share_google')) {
$out .= self::google(array('permalink' => $perm));
}
if (ploption('share_twitter')) {
$out .= self::twitter(array('permalink' => $perm, 'title' => $title));
}
if (ploption('share_facebook')) {
$out .= self::facebook(array('permalink' => $perm));
}
if (ploption('share_linkedin')) {
$out .= self::linkedin(array('permalink' => $perm, 'title' => $title));
}
if (ploption('share_pinterest')) {
$out .= self::pinterest(array('permalink' => $perm, 'image' => $thumb, 'desc' => $desc));
}
if (ploption('share_buffer')) {
$out .= self::buffer(array('permalink' => $perm, 'title' => $title));
}
if (ploption('share_stumble')) {
$out .= self::stumbleupon(array('permalink' => $perm, 'title' => $title));
}
return $out;
}
示例15: instant_articles_shortcode_handler_caption
/**
* Caption/WP-Caption Shortcode. Based on the built in caption shortcode
* @param array $attr Array of attributes passed to shortcode.
* @param string $content The content passed to the shortcode.
* @return string $output The generated content.
*/
function instant_articles_shortcode_handler_caption($attr, $content = null)
{
// New-style shortcode with the caption inside the shortcode with the link and image tags.
if (!isset($attr['caption'])) {
if (preg_match('#((?:<a [^>]+>\\s*)?<img [^>]+>(?:\\s*</a>)?)(.*)#is', $content, $matches)) {
$content = $matches[1];
$attr['caption'] = trim($matches[2]);
}
}
$atts = shortcode_atts(array('figcaptionclass' => '', 'caption' => '', 'cite' => '', 'subtitle' => ''), $attr, 'caption');
if (!strlen(trim($atts['caption']))) {
return '';
}
$output = '';
$content = do_shortcode($content);
$doc = new DOMDocument();
$doc->loadHTML('<html><body>' . $content . '</body></html>');
$imgs = $doc->getElementsByTagName('img');
if ($imgs->length > 0) {
$img_src = $imgs->item(0)->getAttribute('src');
if ($img_src) {
$alt = $imgs->item(0)->getAttribute('alt');
$classes = array();
$classes = trim($atts['figcaptionclass']);
$class_attr = strlen($classes) ? ' class="' . esc_attr($classes) . '"' : '';
$caption = wp_strip_all_tags($atts['caption'], true);
$subtitle = strlen($atts['subtitle']) ? '<h2>' . esc_html($atts['subtitle']) . '</h2>' : '';
$cite = strlen($atts['cite']) ? '<cite>' . esc_html($atts['cite']) . '</cite>' : '';
$output = '<figure><img src="' . esc_url($img_src) . '" alt="' . esc_attr($alt) . '"><figcaption' . $class_attr . '><h1>' . esc_html($caption) . '</h1>' . $subtitle . $cite . '</figcaption></figure>';
}
}
return $output;
}