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


PHP WPSEO_Utils::strip_shortcode方法代码示例

本文整理汇总了PHP中WPSEO_Utils::strip_shortcode方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Utils::strip_shortcode方法的具体用法?PHP WPSEO_Utils::strip_shortcode怎么用?PHP WPSEO_Utils::strip_shortcode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WPSEO_Utils的用法示例。


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

示例1: get_body

 /**
  * Retrieve the body from the post.
  *
  * @param object $post The post object.
  *
  * @return string The post content.
  */
 function get_body($post)
 {
     // This filter allows plugins to add their content to the content to be analyzed.
     $post_content = apply_filters('wpseo_pre_analysis_post_content', $post->post_content, $post);
     // Strip shortcodes, for obvious reasons, if plugins think their content should be in the analysis, they should
     // hook into the above filter.
     $post_content = WPSEO_Utils::trim_nbsp_from_string(WPSEO_Utils::strip_shortcode($post_content));
     if (trim($post_content) == '') {
         return '';
     }
     $htmdata3 = preg_replace('`<(?:\\x20*script|script).*?(?:/>|/script>)`', '', $post_content);
     if ($htmdata3 == null) {
         $htmdata3 = $post_content;
     } else {
         unset($post_content);
     }
     $htmdata4 = preg_replace('`<!--.*?-->`', '', $htmdata3);
     if ($htmdata4 == null) {
         $htmdata4 = $htmdata3;
     } else {
         unset($htmdata3);
     }
     $htmdata5 = preg_replace('`<(?:\\x20*style|style).*?(?:/>|/style>)`', '', $htmdata4);
     if ($htmdata5 == null) {
         $htmdata5 = $htmdata4;
     } else {
         unset($htmdata4);
     }
     return $htmdata5;
 }
开发者ID:Nisha318,项目名称:p3edtech,代码行数:37,代码来源:class-metabox.php

示例2: wpseo_strip_shortcode

/**
 * Strip out the shortcodes with a filthy regex, because people don't properly register their shortcodes.
 *
 * @deprecated 1.6.1
 * @deprecated use WPSEO_Utils::strip_shortcode()
 * @see WPSEO_Utils::strip_shortcode()
 *
 * @param string $text input string that might contain shortcodes
 * @return string $text string without shortcodes
 */
function wpseo_strip_shortcode($text)
{
    _deprecated_function(__FUNCTION__, 'WPSEO 1.6.1', 'WPSEO_Utils::strip_shortcode()');
    return WPSEO_Utils::strip_shortcode($text);
}
开发者ID:presteege,项目名称:presteege.fr,代码行数:15,代码来源:wpseo-functions.php

示例3: replace

 /**
  * Replace `%%variable_placeholders%%` with their real value based on the current requested page/post/cpt/etc
  *
  * @param string $string the string to replace the variables in.
  * @param array  $args   the object some of the replacement values might come from,
  *                       could be a post, taxonomy or term.
  * @param array  $omit   variables that should not be replaced by this function.
  *
  * @return string
  */
 public function replace($string, $args, $omit = array())
 {
     $string = strip_tags($string);
     // Let's see if we can bail super early.
     if (strpos($string, '%%') === false) {
         return WPSEO_Utils::standardize_whitespace($string);
     }
     $args = (array) $args;
     if (isset($args['post_content']) && !empty($args['post_content'])) {
         $args['post_content'] = WPSEO_Utils::strip_shortcode($args['post_content']);
     }
     if (isset($args['post_excerpt']) && !empty($args['post_excerpt'])) {
         $args['post_excerpt'] = WPSEO_Utils::strip_shortcode($args['post_excerpt']);
     }
     $this->args = (object) wp_parse_args($args, $this->defaults);
     // Clean $omit array.
     if (is_array($omit) && $omit !== array()) {
         $omit = array_map(array(__CLASS__, 'remove_var_delimiter'), $omit);
     }
     $replacements = array();
     if (preg_match_all('`%%([^%]+(%%single)?)%%?`iu', $string, $matches)) {
         $replacements = $this->set_up_replacements($matches, $omit);
     }
     /**
      * Filter: 'wpseo_replacements' - Allow customization of the replacements before they are applied
      *
      * @api array $replacements The replacements
      */
     $replacements = apply_filters('wpseo_replacements', $replacements);
     // Do the actual replacements.
     if (is_array($replacements) && $replacements !== array()) {
         $string = str_replace(array_keys($replacements), array_values($replacements), $string);
     }
     /**
      * Filter: 'wpseo_replacements_final' - Allow overruling of whether or not to remove placeholders
      * which didn't yield a replacement
      *
      * @example <code>add_filter( 'wpseo_replacements_final', '__return_false' );</code>
      *
      * @api     bool $final
      */
     if (apply_filters('wpseo_replacements_final', true) === true && (isset($matches[1]) && is_array($matches[1]))) {
         // Remove non-replaced variables.
         $remove = array_diff($matches[1], $omit);
         // Make sure the $omit variables do not get removed.
         $remove = array_map(array(__CLASS__, 'add_var_delimiter'), $remove);
         $string = str_replace($remove, '', $string);
     }
     // Undouble separators which have nothing between them, i.e. where a non-replaced variable was removed.
     if (isset($replacements['%%sep%%']) && (is_string($replacements['%%sep%%']) && $replacements['%%sep%%'] !== '')) {
         $q_sep = preg_quote($replacements['%%sep%%'], '`');
         $string = preg_replace('`' . $q_sep . '(?:\\s*' . $q_sep . ')*`u', $replacements['%%sep%%'], $string);
     }
     // Remove superfluous whitespace.
     $string = WPSEO_Utils::standardize_whitespace($string);
     return trim($string);
 }
开发者ID:ramiy,项目名称:wordpress-seo,代码行数:67,代码来源:class-wpseo-replace-vars.php


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