当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_kses_post函数代码示例

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


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

示例1: display_ip_blockquote

 /**
  * Display the International Programs blockquote shortcode.
  *
  * @param array  $atts    Attributes assigned to the blockquote display.
  * @param string $content Content used in the blockquote element itself.
  *
  * @return string
  */
 public function display_ip_blockquote($atts, $content)
 {
     $default_atts = array('cite' => '', 'image' => '', 'image_placement' => '', 'wrapper' => '');
     $atts = wp_parse_args($atts, $default_atts);
     $content = '<blockquote><span class="blockquote-internal"><span class="blockquote-content">' . wp_kses_post($content) . '</span>';
     if (!empty($atts['cite'])) {
         $content .= '<cite>' . wp_kses_post($atts['cite']) . '</cite>';
     }
     $content .= '</span></blockquote>';
     $atts['wrapper'] = esc_attr($atts['wrapper']);
     $atts['wrapper'] = 'blockquote-container ' . $atts['wrapper'];
     if (isset($atts['image']) && 0 !== absint($atts['image'])) {
         if (empty($atts['image_placement'])) {
             $atts['wrapper'] .= ' blockquote-has-image blockquote-has-image-default';
             $content = '<div class="column one">' . $content . '</div><div class="column two">' . wp_get_attachment_image($atts['image'], 'thumbnail', false) . '</div>';
         } elseif ('together' === $atts['image_placement']) {
             $atts['wrapper'] .= ' blockquote-has-image blockquote-has-image-reverse';
             $content = '<div class="column one">' . $content . wp_get_attachment_image($atts['image'], 'thumbnail', false) . '</div>';
         } elseif ('reverse' === $atts['image_placement']) {
             $atts['wrapper'] .= ' blockquote-has-image blockquote-has-image-together';
             $content = '<div class="column one">' . wp_get_attachment_image($atts['image'], 'thumbnail', false) . '</div><div class="column two">' . $content . '</div>';
         }
     }
     $content = '<div class="' . esc_attr($atts['wrapper']) . '">' . $content . '</div>';
     return $content;
 }
开发者ID:ssheilah,项目名称:ip.wsu.edu,代码行数:34,代码来源:shortcode-blockquote.php

示例2: display

    /**
     * Display meta in a formatted list
     *
     * @access public
     * @param bool $flat (default: false)
     * @param bool $return (default: false)
     * @param string $hideprefix (default: _)
     * @return string
     */
    public function display($flat = false, $return = false, $hideprefix = '_')
    {
        $output = '';
        $formatted_meta = $this->get_formatted($hideprefix);
        if (!empty($formatted_meta)) {
            $meta_list = array();
            foreach ($formatted_meta as $meta_key => $meta) {
                if ($flat) {
                    $meta_list[] = wp_kses_post($meta['label'] . ': ' . $meta['value']);
                } else {
                    $meta_list[] = '
							<dt class="variation-' . sanitize_html_class(sanitize_text_field($meta_key)) . '">' . wp_kses_post($meta['label']) . ':</dt>
							<dd class="variation-' . sanitize_html_class(sanitize_text_field($meta_key)) . '">' . wp_kses_post(wpautop($meta['value'])) . '</dd>
						';
                }
            }
            if (!empty($meta_list)) {
                if ($flat) {
                    $output .= implode(", \n", $meta_list);
                } else {
                    $output .= '<dl class="variation">' . implode('', $meta_list) . '</dl>';
                }
            }
        }
        if ($return) {
            return $output;
        } else {
            echo $output;
        }
    }
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:39,代码来源:class-wc-order-item-meta.php

示例3: get_media_item

    public static function get_media_item($item_data, $align = 'horizontal')
    {
        if (!is_object($item_data)) {
            return '';
        }
        $title = '';
        $caption = '';
        $link = '';
        $title_template = '<h4>%s</h4>';
        if (!empty($item_data->link)) {
            $link_url = $item_data->link;
            $link = '<a class="swiper-link" href="' . $link_url . '">' . __('Details', 'the7mk2') . '</a>';
            $title_template = '<h4><a href="' . $link_url . '">%s</a></h4>';
        }
        if (!empty($item_data->title)) {
            $title = sprintf($title_template, wp_kses($item_data->title, array()));
        }
        if (!empty($item_data->description)) {
            $caption = wpautop(wp_kses_post($item_data->description));
        }
        $image = dt_get_thumb_img(array('echo' => false, 'img_meta' => array($item_data->full, $item_data->width, $item_data->height), 'img_id' => $item_data->ID, 'alt' => $item_data->alt, 'wrap' => '<img %IMG_CLASS% %SRC% %SIZE% %ALT% />', 'prop' => false));
        $info = $title . $caption . $link;
        if ($info) {
            $info = sprintf('<span class="link show-content"></span>
				<div class="swiper-caption">
					%s
					<span class="close-link"></span>
				</div>', $info);
        }
        $html = sprintf('<div class="swiper-slide">
				%s
				%s
			</div>', $image, $info);
        return $html;
    }
开发者ID:10asfar,项目名称:WordPress-the7-theme-demo-,代码行数:35,代码来源:slider-swapper.class.php

示例4: sanitizeString

 /**
  * Sanitize the input string. HTML tags can be permitted.
  * The permitted tags can be supplied in an array.
  *
  * @TODO: Finish the code needed to support the $permittedTags array.
  *
  * @param string $string
  * @param bool $allowHTML [optional]
  * @param array $permittedTags [optional]
  * @return string
  */
 public function sanitizeString($string, $allowHTML = FALSE, $permittedTags = array())
 {
     // Strip all tags except the permitted.
     if (!$allowHTML) {
         // Ensure all tags are closed. Uses WordPress method balanceTags().
         $balancedText = balanceTags($string, TRUE);
         $strippedText = strip_tags($balancedText);
         // Strip all script and style tags.
         $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $strippedText);
         // Escape text using the WordPress method and then strip slashes.
         $escapedText = stripslashes(esc_attr($strippedText));
         // Remove line breaks and trim white space.
         $escapedText = preg_replace('/[\\r\\n\\t ]+/', ' ', $escapedText);
         return trim($escapedText);
     } else {
         // Strip all script and style tags.
         $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $string);
         $strippedText = preg_replace('/&lt;(script|style).*?&gt;.*?&lt;\\/\\1&gt;/si', '', stripslashes($strippedText));
         /*
          * Use WordPress method make_clickable() to make links clickable and
          * use kses for filtering.
          *
          * http://ottopress.com/2010/wp-quickie-kses/
          */
         return wptexturize(wpautop(make_clickable(wp_kses_post($strippedText))));
     }
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:38,代码来源:class.utility.php

示例5: display

    /**
     * Display meta in a formatted list.
     *
     * @param bool $flat (default: false)
     * @param bool $return (default: false)
     * @param string $hideprefix (default: _)
     * @param  string $delimiter Delimiter used to separate items when $flat is true
     * @return string|void
     */
    public function display($flat = false, $return = false, $hideprefix = '_', $delimiter = ", \n")
    {
        $output = '';
        $formatted_meta = $this->get_formatted($hideprefix);
        if (!empty($formatted_meta)) {
            $meta_list = array();
            foreach ($formatted_meta as $meta) {
                if ($flat) {
                    $meta_list[] = wp_kses_post($meta['label'] . ': ' . $meta['value']);
                } else {
                    $meta_list[] = '
						<dt class="variation-' . sanitize_html_class(sanitize_text_field($meta['key'])) . '">' . wp_kses_post($meta['label']) . ':</dt>
						<dd class="variation-' . sanitize_html_class(sanitize_text_field($meta['key'])) . '">' . wp_kses_post(wpautop(make_clickable($meta['value']))) . '</dd>
					';
                }
            }
            if (!empty($meta_list)) {
                if ($flat) {
                    $output .= implode($delimiter, $meta_list);
                } else {
                    $output .= '<dl class="variation">' . implode('', $meta_list) . '</dl>';
                }
            }
        }
        $output = apply_filters('woocommerce_order_items_meta_display', $output, $this);
        if ($return) {
            return $output;
        } else {
            echo $output;
        }
    }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:40,代码来源:class-wc-order-item-meta.php

示例6: qi_theme_api_call

function qi_theme_api_call($def, $action, $args)
{
    global $wp_version, $theme_base, $api_url, $theme_version;
    // Add check for 'slug' existence inside $args
    // to avoid WordPress.org server error message
    // in some screens
    if (!property_exists($args, 'slug')) {
        return false;
    }
    if ($args->slug != $theme_base) {
        return false;
    }
    // Get the current version
    $args->version = $theme_version;
    $request_string = array('body' => array('action' => $action, 'request' => json_encode($args), 'api-key' => md5(esc_url(home_url('/')))), 'user-agent' => 'WordPress/' . $wp_version . '; ' . esc_url(home_url('/')));
    $request = wp_remote_post($api_url, $request_string);
    if (is_wp_error($request)) {
        $res = new WP_Error('themes_api_failed', wp_kses_post(__('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>', 'quadro')), $request->get_error_message());
    } else {
        $res = unserialize($request['body']);
        if ($res === false) {
            $res = new WP_Error('themes_api_failed', esc_html__('An unknown error occurred', 'quadro'), $request['body']);
        }
    }
    return $res;
}
开发者ID:unsognoverde,项目名称:website,代码行数:26,代码来源:update.php

示例7: create_field

 function create_field($field)
 {
     // vars
     $o = array('id', 'class', 'name', 'value', 'placeholder');
     $e = '';
     // prepend
     if ($field['prepend'] !== "") {
         $field['class'] .= ' acf-is-prepended';
         $e .= '<div class="acf-input-prepend">' . wp_kses_post($field['prepend']) . '</div>';
     }
     // append
     if ($field['append'] !== "") {
         $field['class'] .= ' acf-is-appended';
         $e .= '<div class="acf-input-append">' . wp_kses_post($field['append']) . '</div>';
     }
     $e .= '<div class="acf-input-wrap">';
     $e .= '<input type="email"';
     foreach ($o as $k) {
         $e .= ' ' . $k . '="' . esc_attr($field[$k]) . '"';
     }
     $e .= ' />';
     $e .= '</div>';
     // return
     echo $e;
 }
开发者ID:ffffranklin,项目名称:cmarianiantiques,代码行数:25,代码来源:email.php

示例8: widget

 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
     echo $before_widget;
     echo '<div class="twitter-widget-wrapper">';
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if (function_exists('fw_ssd_twitter_feed')) {
         $tweets = fw_ssd_twitter_feed($instance['tweet_count'], $instance['username']);
         if (!is_wp_error($tweets) && !empty($tweets)) {
             $output = '';
             $output .= '<ul>';
             if (!empty($tweets['error'])) {
                 $output .= '<li><div class="tweet-content">' . $tweets['error'] . '</div></li>';
             } else {
                 foreach ($tweets as $tweet) {
                     if (!empty($tweet['tweet'])) {
                         $output .= '<li><div class="tweet-content">' . $tweet['tweet'] . '</div> <span class="tweet-time">' . $tweet['time'] . '</span></li>';
                     }
                 }
             }
             $output .= '</ul>';
         }
     }
     echo wp_kses_post($output);
     echo '</div><!-- end twitter-widget-wrapper -->';
     echo $after_widget;
 }
开发者ID:chrisuehlein,项目名称:couponsite,代码行数:30,代码来源:class-widget-twitter.php

示例9: shortcode_ui_dev_shortcode

function shortcode_ui_dev_shortcode($attr, $content = '')
{
    //Parse the attribute of the shortcode
    $attr = wp_parse_args($attr, array('source' => '', 'attachment' => 0));
    ob_start();
    ?>

	<section class="pullquote" style="padding: 20px; background: rgba(0,0,0,0.1);">
	    <p style="margin:0; padding: 0;">
		<b>Content:</b> <?php 
    echo wpautop(wp_kses_post($content));
    ?>
</br>
		<b>Source:</b> <?php 
    echo esc_html($attr['source']);
    ?>
</br>
		<b>Image:</b> <?php 
    echo wp_kses_post(wp_get_attachment_image($attr['attachment'], array(50, 50)));
    ?>
</br>
	    </p>
	</section>

	<?php 
    return ob_get_clean();
}
开发者ID:scherii,项目名称:Shortcake,代码行数:27,代码来源:dev.php

示例10: theshop_section_cta

    /**
     * Call to action section
     *
     */
    function theshop_section_cta()
    {
        if (!get_theme_mod('cta_activate', 1)) {
            return;
        }
        $text = get_theme_mod('cta_text', 'Are you ready to see more?');
        $button_title = get_theme_mod('cta_button_title', 'VISIT OUR SHOP');
        $button_url = get_theme_mod('cta_button_url', '#');
        ?>

	<section class="home-section cta-section">
		<div class="container">
			<p class="cta-text"><?php 
        echo wp_kses_post($text);
        ?>
</p>
			<a class="button" href="<?php 
        echo esc_url($button_url);
        ?>
"><?php 
        echo esc_html($button_title);
        ?>
</a>
		</div>
	</section>

	<?php 
    }
开发者ID:sammykumar,项目名称:goodbeads,代码行数:32,代码来源:sections.php

示例11: add_cat_to_db

function add_cat_to_db()
{
    global $wpdb, $current_user;
    if ($_REQUEST['action'] == 'add') {
        $category_name = isset($_REQUEST['category_name']) && !empty($_REQUEST['category_name']) ? esc_html($_REQUEST['category_name']) : '';
        $category_identifier = isset($_REQUEST['category_identifier']) && !empty($_REQUEST['category_identifier']) ? $category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier']) : ($category_identifier = sanitize_title_with_dashes($category_name . '-' . time()));
        $category_desc = isset($_REQUEST['category_desc']) && !empty($_REQUEST['category_desc']) ? wp_kses_post($_REQUEST['category_desc']) : '';
        $display_category_desc = isset($_REQUEST['display_desc']) && !empty($_REQUEST['display_desc']) ? $_REQUEST['display_desc'] : '';
        if (!function_exists('espresso_member_data')) {
            $current_user->ID = 1;
        }
        $category_meta['use_pickers'] = isset($_REQUEST['use_pickers']) && !empty($_REQUEST['use_pickers']) ? $_REQUEST['use_pickers'] : '';
        $category_meta['event_background'] = isset($_REQUEST['event_background']) && !empty($_REQUEST['event_background']) ? $_REQUEST['event_background'] : '';
        $category_meta['event_text_color'] = isset($_REQUEST['event_text_color']) && !empty($_REQUEST['event_text_color']) ? $_REQUEST['event_text_color'] : '';
        $category_meta = serialize($category_meta);
        $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc, 'category_meta' => $category_meta, 'wp_user' => $current_user->ID);
        $sql_data = array('%s', '%s', '%s', '%s', '%s', '%d');
        if ($wpdb->insert(EVENTS_CATEGORY_TABLE, $sql, $sql_data)) {
            ?>
		<div id="message" class="updated fade"><p><strong><?php 
            _e('The category has been added.', 'event_espresso');
            ?>
</strong></p></div>
	<?php 
        } else {
            ?>
		<div id="message" class="error"><p><strong><?php 
            _e('The category   was not saved.', 'event_espresso');
            ?>
 </strong></p></div>

<?php 
        }
    }
}
开发者ID:HandsomeDogStudio,项目名称:peanutbutterplan,代码行数:35,代码来源:add_cat_to_db.php

示例12: widget

 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('PhoenixTeam_Widget_Twitter', $instance['title']);
     $username = $instance['username'] ? $instance['username'] : null;
     $number = isset($instance['qty']) ? $instance['qty'] : null;
     static $counter = 1;
     // IDs for Widget;
     // echo $args['before_widget']; // It's the right way, but doesn't work with VC :(
     echo '<div id="' . THEME_SLUG . '-twitter-' . esc_attr($counter) . '" class="footer-twitter widget_' . THEME_SLUG . '-twitter">';
     if ($title) {
         echo '<h4 class="widget-title">' . esc_html($title) . '</h4>';
     }
     // $tweets = $this->get_tweets($args['widget_id'], $instance); // Good old, but doesn't work with VC
     $tweets = $this->get_tweets(THEME_SLUG . '-twitter-' . $counter, $instance);
     if (!empty($tweets['tweets']) && empty($tweets['tweets']->errors)) {
         $user = current($tweets['tweets']);
         if (is_object($user)) {
             $user = $user->user;
         }
         echo '<ul class="tweet_list">';
         $checker = 0;
         foreach ($tweets['tweets'] as $tweet) {
             if ($checker <= $number) {
                 if (isset($tweet->text)) {
                     if (is_object($tweet)) {
                         $avatar = $user->profile_image_url;
                         $username = $user->screen_name;
                         $user_url = 'https://twitter.com/' . $username;
                         $tweet_text = htmlentities($tweet->text, ENT_QUOTES, 'UTF-8');
                         $tweet_text = make_clickable($tweet_text);
                         $tweet_text = popuplinks($tweet_text);
                         if ($tweet_text) {
                             echo '<li>
                           <a class="tweet_avatar" href="' . esc_url($user_url) . '">
                             <img src="' . esc_url($avatar) . '" alt="' . esc_attr($username) . '" title="' . esc_attr($username) . '">
                           </a>
                           <span class="tweet_text">' . wp_kses_post($tweet_text) . '</span>
                         </li>';
                             $checker++;
                         }
                     }
                 } else {
                     if ($checker == 0) {
                         echo '<li><span class="content">' . __("There's no tweets in your feed...", 'grandway') . '</span></li>';
                         break;
                     }
                     break;
                 }
             }
         }
         echo '</ul>';
     } elseif ($tweets['tweets']->errors) {
         _e('Authentication failed! Please check your Twitter app data.', 'grandway');
     } elseif (!$tweets['tweets']) {
         _e("There's no tweets there", 'grandway');
     }
     echo $args['after_widget'];
     $counter++;
 }
开发者ID:WillLin,项目名称:CS-SC-Front-End,代码行数:60,代码来源:widget-twitter.php

示例13: get_login_options

 private static function get_login_options()
 {
     $login_options = array();
     $targets = array();
     if (wskl_is_option_enabled('fb_login')) {
         $targets[] = 'fb';
     }
     if (wskl_is_option_enabled('naver_login')) {
         $targets[] = 'naver';
     }
     foreach ($targets as $prefix) {
         $login_link_text = get_option(wskl_get_option_name($prefix . '_login_link_text'), '[icon]');
         if ($login_link_text && !empty($login_link_text)) {
             switch ($prefix) {
                 case 'fb':
                     $img_url = plugin_dir_url(WSKL_MAIN_FILE) . "assets/image/social-login/facebook.png";
                     $alt = __('페이스북으로 로그인', 'wskl');
                     break;
                 case 'naver':
                     $img_url = plugin_dir_url(WSKL_MAIN_FILE) . "assets/image/social-login/naver.png";
                     $alt = __('네이버 아이디로 로그인', 'wskl');
                     break;
                 default:
                     $img_url = '';
                     $alt = '';
             }
             $login_link_text = str_replace('[icon]', sprintf('<img src="%s" class="%s" alt="%s" title="%3$s">', esc_attr($img_url), esc_attr('auth-provider-icon '), esc_attr($alt)), $login_link_text);
             $login_link_text = wp_kses_post($login_link_text);
             $login_options[$prefix] = array('href' => esc_url("/index.php?sym-api=service-social-login-{$prefix}"), 'link_title' => $login_link_text, 'alt' => $alt);
         }
     }
     return $login_options;
 }
开发者ID:EricKim65,项目名称:woosym-korean-localization,代码行数:33,代码来源:class-social-login.php

示例14: update_event_category

function update_event_category()
{
    global $wpdb;
    $category_id = $_REQUEST['category_id'];
    $category_name = esc_html($_REQUEST['category_name']);
    $category_identifier = $_REQUEST['category_identifier'] == '' ? $category_identifier = sanitize_title_with_dashes($category_name . '-' . time()) : ($category_identifier = sanitize_title_with_dashes($_REQUEST['category_identifier']));
    $category_desc = wp_kses_post($_REQUEST['category_desc']);
    $display_category_desc = $_REQUEST['display_desc'];
    $category_meta['use_pickers'] = isset($_REQUEST['use_pickers']) && !empty($_REQUEST['use_pickers']) ? $_REQUEST['use_pickers'] : '';
    $category_meta['event_background'] = isset($_REQUEST['event_background']) && !empty($_REQUEST['event_background']) ? $_REQUEST['event_background'] : '';
    $category_meta['event_text_color'] = isset($_REQUEST['event_text_color']) && !empty($_REQUEST['event_text_color']) ? $_REQUEST['event_text_color'] : '';
    //echo "<pre>".print_r($_POST,true)."</pre>";
    $category_meta = serialize($category_meta);
    $sql = array('category_name' => $category_name, 'category_identifier' => $category_identifier, 'category_desc' => $category_desc, 'display_desc' => $display_category_desc, 'category_meta' => $category_meta);
    $update_id = array('id' => $category_id);
    $sql_data = array('%s', '%s', '%s', '%s', '%s');
    if ($wpdb->update(EVENTS_CATEGORY_TABLE, $sql, $update_id, $sql_data, array('%d'))) {
        ?>
	<div id="message" class="updated fade"><p><strong><?php 
        _e('The category has been updated.', 'event_espresso');
        ?>
 </strong></p></div>
<?php 
    } else {
        ?>
	<div id="message" class="error"><p><strong><?php 
        _e('The category was not updated.', 'event_espresso');
        ?>
</strong></p></div>

<?php 
    }
}
开发者ID:HandsomeDogStudio,项目名称:peanutbutterplan,代码行数:33,代码来源:update_event_category.php

示例15: widget

    public function widget($args, $instance)
    {
        echo wp_kses_post($args['before_widget']);
        if (!empty($instance['title'])) {
            echo wp_kses_post($args['before_title']) . esc_html($instance['title']) . wp_kses_post($args['after_title']);
        }
        $barcelona_image = is_numeric($instance['image']) ? barcelona_get_thumbnail_url('barcelona-sq', $instance['image'], true, true) : '';
        ?>
		<div class="about-me">

			<?php 
        if (!empty($barcelona_image)) {
            echo '<p class="about-image"><img src="' . esc_url($barcelona_image[0]) . '" alt="' . esc_attr($instance['name']) . '" /></p>';
        }
        if (!empty($instance['name'])) {
            echo '<h2 class="about-name">' . esc_html($instance['name']) . '</h2>';
        }
        if (!empty($instance['job_title'])) {
            echo '<h4 class="about-job-title">' . esc_html($instance['job_title']) . '</h4>';
        }
        ?>
			<p class="description">
				<?php 
        echo wp_kses(nl2br($instance['description']), array('br' => array()));
        ?>
			</p>

		</div>
		<?php 
        echo wp_kses_post($args['after_widget']);
    }
开发者ID:yalmaa,项目名称:little-magazine,代码行数:31,代码来源:barcelona-about-me.php


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