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


PHP c_ws_plugin__s2member_utils_strings::trim_html方法代码示例

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


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

示例1: sc_if_conditionals

 /**
  * Handles the Shortcode for: `[s2If /]`.
  *
  * These Shortcodes are also safe to use on a Multisite Blog Farm.
  *
  * Is Multisite Networking enabled? Please keep the following in mind.
  * ``current_user_can()``, will ALWAYS return true for a Super Admin!
  * 	*(this can be confusing when testing conditionals)*.
  *
  * If you're running a Multisite Blog Farm, you can Filter this array:
  * 	`ws_plugin__s2member_sc_if_conditionals_blog_farm_safe`
  * 	``$blog_farm_safe``
  *
  * @package s2Member\s2If
  * @since 3.5
  *
  * @attaches-to ``add_shortcode("s2If")`` + _s2If, __s2If, ___s2If for nesting.
  *
  * @param array $attr An array of Attributes.
  * @param str $content Content inside the Shortcode.
  * @param str $shortcode The actual Shortcode name itself.
  * @return str The ``$content`` if true, else an empty string.
  *
  * @todo Add support for nested AND/OR conditionals inside the ONE Shortcode.
  * @todo Address possible security issue on sites with multiple editors, some of which should not have access to this feature.
  */
 public static function sc_if_conditionals($attr = FALSE, $content = FALSE, $shortcode = FALSE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_sc_if_conditionals", get_defined_vars());
     unset($__refs, $__v);
     $blog_farm_safe = apply_filters("ws_plugin__s2member_sc_if_conditionals_blog_farm_safe", array("is_user_logged_in", "is_user_not_logged_in", "user_is", "user_is_not", "user_can", "user_cannot", "current_user_is", "current_user_is_not", "current_user_can", "current_user_cannot", "is_admin", "is_blog_admin", "is_user_admin", "is_network_admin", "is_404", "is_home", "is_front_page", "is_singular", "is_single", "is_page", "is_page_template", "is_attachment", "is_feed", "is_archive", "is_search", "is_category", "is_tax", "is_tag", "has_tag", "is_author", "is_date", "is_day", "is_month", "is_time", "is_year", "is_sticky", "is_paged", "is_preview", "is_comments_popup", "in_the_loop", "comments_open", "pings_open", "has_excerpt", "has_post_thumbnail"), get_defined_vars());
     $pro_is_installed = c_ws_plugin__s2member_utils_conds::pro_is_installed();
     // Has pro version?
     $sc_conds_allow_arbitrary_php = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sc_conds_allow_arbitrary_php"];
     if (!$pro_is_installed || is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) {
         $sc_conds_allow_arbitrary_php = FALSE;
     }
     // Always disallow on child blogs of a blog farm.
     $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr);
     $content_if = $content_else = NULL;
     // Initialize.
     $shortcode_depth = strspn($shortcode, '_');
     // Based on a zero index.
     $else_tag = "[" . str_repeat("_", $shortcode_depth) . "else]";
     // e.g. [else], [_else], [__else]
     if (strpos($content, $else_tag) !== FALSE && $pro_is_installed) {
         list($content_if, $content_else) = explode($else_tag, $content, 2);
     }
     # Arbitrary PHP code via the `php` attribute...
     if ($sc_conds_allow_arbitrary_php && isset($attr["php"])) {
         if ($condition_succeeded = c_ws_plugin__s2member_sc_if_conds_in::evl($attr["php"])) {
             $condition_content = isset($content_if) ? $content_if : $content;
         } else {
             $condition_content = isset($content_else) ? $content_else : "";
         }
         if ($condition_content) {
             $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
         }
         return do_shortcode(apply_filters("ws_plugin__s2member_sc_if_conditionals", $condition_content, get_defined_vars()));
     } else {
         if (isset($attr["php"])) {
             trigger_error("s2If syntax error. Simple Conditionals are not currently configured to allow arbitrary PHP code evaluation.", E_USER_ERROR);
             return "";
             // Return now; empty string in this case.
         }
     }
     # Default behavior otherwise...
     foreach ($attr as $attr_key => $attr_value) {
         // Detects and removes logical attributes.
         // It's NOT possible to mix logic. You MUST stick to one type of logic or another.
         // If both types of logic are needed, you MUST use two different Shortcodes.
         if (preg_match("/^(&&|&amp;&amp;|&#038;&#038;|AND|\\|\\||OR|[\\!\\=\\<\\>]+)\$/i", $attr_value)) {
             // Stick with AND/OR. Ampersands are corrupted by the Visual Editor.
             $logicals[] = strtolower($attr_value);
             // Place all logicals into an array here.
             unset($attr[$attr_key]);
             // ^ Detect logic here. We'll use the first key #0.
             if (preg_match("/^[\\!\\=\\<\\>]+\$/i", $attr_value)) {
                 trigger_error("s2If, invalid operator [ " . $attr_value . " ]. Simple Conditionals cannot process operators like ( == != <> ). Please use Advanced (PHP) Conditionals instead.", E_USER_ERROR);
                 return "";
                 // Return now; empty string in this case.
             }
         }
     }
     if (!empty($logicals) && is_array($logicals) && count(array_unique($logicals)) > 1) {
         trigger_error("s2If, AND/OR malformed conditional logic. It's NOT possible to mix logic using AND/OR combinations. You MUST stick to one type of logic or another. If both types of logic are needed, you MUST use two different Shortcode expressions. Or, use Advanced (PHP) Conditionals instead.", E_USER_ERROR);
         return "";
         // Return now; empty string in this case.
     }
     $conditional_logic = !empty($logicals) && is_array($logicals) && preg_match("/^(\\|\\||OR)\$/i", $logicals[0]) ? "OR" : "AND";
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_sc_if_conditionals_after_conditional_logic", get_defined_vars());
     unset($__refs, $__v);
     if ($conditional_logic === "AND") {
         foreach ($attr as $attr_value) {
//.........这里部分代码省略.........
开发者ID:donwea,项目名称:nhap.org,代码行数:101,代码来源:sc-if-conds-in.inc.php

示例2: sc_if_conditionals

 /**
  * Handles the Shortcode for: `[s2If /]`.
  *
  * These Shortcodes are also safe to use on a Multisite Blog Farm.
  *
  * Is Multisite Networking enabled? Please keep the following in mind.
  * ``current_user_can()``, will ALWAYS return true for a Super Admin!
  *   *(this can be confusing when testing conditionals)*.
  *
  * If you're running a Multisite Blog Farm, you can Filter this array:
  *   `ws_plugin__s2member_sc_if_conditionals_blog_farm_safe`
  *   ``$blog_farm_safe``
  *
  * @package s2Member\s2If
  * @since 3.5
  *
  * @attaches-to ``add_shortcode('s2If')`` + _s2If, __s2If, ___s2If for nesting.
  *
  * @param array  $attr An array of Attributes.
  * @param string $content Content inside the Shortcode.
  * @param string $shortcode The actual Shortcode name itself.
  *
  * @return string The ``$content`` if true, else an empty string.
  *
  * @todo Add support for nested AND/OR conditionals inside the ONE Shortcode.
  * @todo Address possible security issue on sites with multiple editors, some of which should not have access to this feature.
  */
 public static function sc_if_conditionals($attr = array(), $content = '', $shortcode = '')
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_sc_if_conditionals', get_defined_vars());
     unset($__refs, $__v);
     // Allows variables to be modified by reference.
     c_ws_plugin__s2member_no_cache::no_cache_constants(true);
     $blog_farm_safe = apply_filters('ws_plugin__s2member_sc_if_conditionals_blog_farm_safe', array('is_user_logged_in', 'is_user_not_logged_in', 'user_is', 'user_is_not', 'user_can', 'user_cannot', 'current_user_is', 'current_user_is_not', 'current_user_can', 'current_user_cannot', 'is_admin', 'is_blog_admin', 'is_user_admin', 'is_network_admin', 'is_404', 'is_home', 'is_front_page', 'is_singular', 'is_single', 'is_page', 'is_page_template', 'is_attachment', 'is_feed', 'is_archive', 'is_search', 'is_category', 'is_tax', 'is_tag', 'has_tag', 'is_author', 'is_date', 'is_day', 'is_month', 'is_time', 'is_year', 'is_sticky', 'is_paged', 'is_preview', 'is_comments_popup', 'in_the_loop', 'comments_open', 'pings_open', 'has_excerpt', 'has_post_thumbnail'), get_defined_vars());
     $pro_is_installed = c_ws_plugin__s2member_utils_conds::pro_is_installed();
     // Has pro version?
     $sc_conds_allow_arbitrary_php = $GLOBALS['WS_PLUGIN__']['s2member']['o']['sc_conds_allow_arbitrary_php'];
     if (!$pro_is_installed || is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && !is_main_site()) {
         $sc_conds_allow_arbitrary_php = FALSE;
     }
     // Always disallow on child blogs of a blog farm.
     $attr = c_ws_plugin__s2member_utils_strings::trim_qts_deep((array) $attr);
     $content_if = $content_else = NULL;
     // Initialize.
     $shortcode_depth = strspn($shortcode, '_');
     // Based on a zero index.
     $else_tag = '[' . str_repeat('_', $shortcode_depth) . 'else]';
     // e.g., [else], [_else], [__else]
     if (strpos($content, $else_tag) !== FALSE && $pro_is_installed) {
         list($content_if, $content_else) = explode($else_tag, $content, 2);
     }
     # Arbitrary PHP code via the `php` attribute...
     if ($sc_conds_allow_arbitrary_php && isset($attr['php'])) {
         if ($condition_succeeded = c_ws_plugin__s2member_sc_if_conds_in::evl($attr['php'])) {
             $condition_content = isset($content_if) ? $content_if : $content;
         } else {
             $condition_content = isset($content_else) ? $content_else : '';
         }
         if ($condition_content) {
             $condition_content = c_ws_plugin__s2member_utils_strings::trim_html($condition_content);
         }
         return do_shortcode(apply_filters('ws_plugin__s2member_sc_if_conditionals', $condition_content, get_defined_vars()));
     } else {
         if (isset($attr['php'])) {
             trigger_error('s2If syntax error. Simple Conditionals are not currently configured to allow arbitrary PHP code evaluation.', E_USER_ERROR);
             return '';
             // Return now; empty string in this case.
         }
     }
     # Default behavior otherwise...
     foreach ($attr as $attr_key => $attr_value) {
         // Detects and removes logical attributes.
         // It's NOT possible to mix logic. You MUST stick to one type of logic or another.
         // If both types of logic are needed, you MUST use two different Shortcodes.
         if (preg_match('/^(&&|&amp;&amp;|&#038;&#038;|AND|\\|\\||OR|[\\!\\=\\<\\>]+)$/i', $attr_value)) {
             // Stick with AND/OR. Ampersands are corrupted by the Visual Editor.
             $logicals[] = strtolower($attr_value);
             // Place all logicals into an array here.
             unset($attr[$attr_key]);
             // ^ Detect logic here. We'll use the first key #0.
             if (preg_match('/^[\\!\\=\\<\\>]+$/i', $attr_value)) {
                 trigger_error('s2If, invalid operator [ ' . $attr_value . ' ]. Simple Conditionals cannot process operators like ( == != <> ). Please use Advanced (PHP) Conditionals instead.', E_USER_ERROR);
                 return '';
                 // Return now; empty string in this case.
             }
         }
     }
     if (!empty($logicals) && is_array($logicals) && count(array_unique($logicals)) > 1) {
         trigger_error('s2If, AND/OR malformed conditional logic. It\'s NOT possible to mix logic using AND/OR combinations. You MUST stick to one type of logic or another. If both types of logic are needed, you MUST use two different Shortcode expressions. Or, use Advanced (PHP) Conditionals instead.', E_USER_ERROR);
         return '';
         // Return now; empty string in this case.
     }
     $conditional_logic = !empty($logicals) && is_array($logicals) && preg_match('/^(\\|\\||OR)$/i', $logicals[0]) ? 'OR' : 'AND';
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_sc_if_conditionals_after_conditional_logic', get_defined_vars());
//.........这里部分代码省略.........
开发者ID:codeforest,项目名称:s2member,代码行数:101,代码来源:sc-if-conds-in.inc.php


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