예제 #1
0
파일: Tweet.php 프로젝트: twitter/wordpress
 /**
  * Filter the_content, possibly adding Tweet button(s)
  *
  * @since 1.0.0
  *
  * @param string $content content of the current post
  *
  * @return string $content content of the current post, possibly with Tweet button markup added
  */
 public static function contentFilter($content)
 {
     // do not include Tweet button(s) in an autogenerated excerpt
     // get_the_excerpt filter calls wp_trim_excerpt() at priority 10 which triggers the_content filter on an empty excerpt string
     if (doing_filter('get_the_excerpt')) {
         return $content;
     }
     $options = static::getOption();
     if (isset($options['position'])) {
         $position = $options['position'];
         unset($options['position']);
         $tweet_button = \Twitter\WordPress\Shortcodes\Share::shortcodeHandler($options);
         if ($tweet_button) {
             // wrap in newlines to preserve content scanners looking for adjacent content on its own line
             $tweet_button = "\n" . $tweet_button . "\n";
             if ('before' === $position) {
                 return $tweet_button . $content;
             } else {
                 if ('after' === $position) {
                     return $content . $tweet_button;
                 } else {
                     if ('both' === $position) {
                         return $tweet_button . $content . $tweet_button;
                     }
                 }
             }
         }
     }
     return $content;
 }
 /**
  * Add short code.
  * Recommend you don't use this short code registering your own post data.
  *
  * @param array $atts Short code parameter.
  *
  * @return null|string
  */
 public function add_shortcode($atts = [])
 {
     $output = null;
     $tmp_wrapper = self::_tmp_wrapper();
     $show_in_like = apply_filters(VA_SOCIALBUZZ_PREFIX . 'show_in_like', true);
     $show_in_share = apply_filters(VA_SOCIALBUZZ_PREFIX . 'show_in_share', true);
     $show_in_notification = apply_filters(VA_SOCIALBUZZ_PREFIX . 'show_in_notification', true);
     $show_in_follow = apply_filters(VA_SOCIALBUZZ_PREFIX . 'show_in_follow', true);
     $doing = apply_filters(VA_SOCIALBUZZ_PREFIX . 'show_in_doing', doing_filter(VA_SOCIALBUZZ_PREFIX . 'doing_show_in'));
     $atts = shortcode_atts(array('box' => '', 'mode' => '', 'likebox_text1' => '', 'likebox_text2' => ''), $atts, 'socialbuzz');
     if (true !== $doing) {
         return $output;
     }
     switch ($atts['box']) {
         case 'like':
             $output = self::_shortcode_likeblock($atts['likebox_text1'], $atts['likebox_text2'], $atts['mode']);
             break;
         case 'share':
             $output = self::_shortcode_shareblock();
             break;
         case 'notification':
             $output = self::_shortcode_notificationblock();
             break;
         case 'follow':
             $output = self::_shortcode_followblock();
             break;
         case 'select':
             if (true === $show_in_like) {
                 $output[] = self::_shortcode_likeblock($atts['likebox_text1'], $atts['likebox_text2'], $atts['mode']);
             }
             if (true === $show_in_share) {
                 $output[] = self::_shortcode_shareblock();
             }
             if (true === $show_in_notification) {
                 $output[] = self::_shortcode_notificationblock();
             }
             if (true === $show_in_follow) {
                 $output[] = self::_shortcode_followblock();
             }
             break;
         default:
             $output[] = self::_shortcode_likeblock($atts['likebox_text1'], $atts['likebox_text2'], $atts['mode']);
             $output[] = self::_shortcode_shareblock();
             $output[] = self::_shortcode_notificationblock();
             $output[] = self::_shortcode_followblock();
             break;
     }
     if (is_array($output)) {
         $output = implode('', $output);
     }
     if (!empty($output) && 'widget' !== $atts['mode']) {
         $output = str_replace('{{content}}', $output, $tmp_wrapper);
     }
     return $output;
 }
 /**
  * Gets the title. Main function.
  * Always use this function for the title unless you're absolutely sure what you're doing.
  *
  * This function is used for all these: Taxonomies and Terms, Posts, Pages, Blog, front page, front-end, back-end.
  *
  * @since 1.0.0
  *
  * Params required wp_title filter :
  * @param string $title The Title to return
  * @param string $sep The Title sepeartor
  * @param string $seplocation The Title sepeartor location ( accepts 'left' or 'right' )
  *
  * @since 2.4.0:
  * @param array $args : accepted args : {
  * 		@param int term_id The Taxonomy Term ID when taxonomy is also filled in. Else post ID.
  * 		@param string taxonomy The Taxonomy name.
  * 		@param bool page_on_front Page on front condition for example generation.
  * 		@param bool placeholder Generate placeholder, ignoring options.
  * 		@param bool notagline Generate title without tagline.
  * 		@param bool meta Ignore doing_it_wrong. Used in og:title/twitter:title
  * 		@param bool get_custom_field Do not fetch custom title when false.
  * 		@param bool description_title Fetch title for description.
  * 		@param bool is_front_page Fetch front page title.
  * }
  * @return string $title Title
  */
 public function title($title = '', $sep = '', $seplocation = '', $args = array())
 {
     //* Use WordPress default feed title.
     if ($this->is_feed()) {
         return trim($title);
     }
     $args = $this->reparse_title_args($args);
     /**
      * Return early if the request is the Title only (without tagline/blogname).
      */
     if ($args['notagline']) {
         return $this->build_title_notagline($args);
     }
     /**
      * Add doing it wrong notice for better SEO consistency.
      * Only when in wp_title.
      *
      * @since 2.2.5
      */
     if (false === $args['meta'] && false === $this->is_admin()) {
         if (false === $this->current_theme_supports_title_tag() && doing_filter('wp_title')) {
             if ($seplocation || $sep) {
                 //* Set doing it wrong parameters.
                 $this->set_tell_title_doing_it_wrong($title, $sep, $seplocation, false);
                 //* And echo them.
                 add_action('wp_footer', array($this, 'tell_title_doing_it_wrong'), 20);
                 //* Notify cache.
                 $this->title_doing_it_wrong = true;
                 //* Notify transients
                 $this->set_theme_dir_transient(false);
                 //* Title is empty.
                 if (empty($seplocation) && $sep) {
                     $args['empty_title'] = true;
                 }
                 return $this->build_title_doingitwrong($title, $sep, $seplocation, $args);
             }
         }
     }
     //* Notify cache to keep using the same output. We're doing it right :).
     if (!isset($this->title_doing_it_wrong)) {
         $this->title_doing_it_wrong = false;
     }
     //* Set transient to true if the theme is doing it right.
     if (false === $this->title_doing_it_wrong) {
         $this->set_theme_dir_transient(true);
     }
     //* Empty title and rebuild it.
     return $this->build_title($title = '', $seplocation, $args);
 }
예제 #4
0
파일: plugin.php 프로젝트: nstungxd/F2CA5
/**
 * Retrieve the name of an action currently being processed.
 *
 * @since 3.9.0
 *
 * @param string|null $action Optional. Action to check. Defaults to null, which checks
 *                            if any action is currently being run.
 * @return bool Whether the action is currently in the stack.
 */
function doing_action($action = null)
{
    return doing_filter($action);
}
예제 #5
0
 /**
  * Filters an array of image `sizes` values, using $content_width instead of image's full size.
  *
  * @since 4.0.4
  * @since 4.1.0 Returns early for images not within the_content.
  * @param array $sizes An array of media query breakpoints.
  * @param array $size  Width and height of the image
  * @uses Jetpack::get_content_width
  * @return array An array of media query breakpoints.
  */
 public function filter_sizes($sizes, $size)
 {
     if (!doing_filter('the_content')) {
         return $sizes;
     }
     $content_width = Jetpack::get_content_width();
     if (!$content_width) {
         $content_width = 1000;
     }
     if (is_array($size) && $size[0] < $content_width) {
         return $sizes;
     }
     return sprintf('(max-width: %1$dpx) 100vw, %1$dpx', $content_width);
 }
예제 #6
0
 /**
  * Register stylesheets on front pages.
  *
  * @since 1.0.0
  */
 public static function register_styles()
 {
     if (!class_exists('Cherry_Framework') || doing_filter('cherry_shortcodes/generator/preview/before')) {
         wp_register_style('cherry-shortcodes-grid', plugins_url('assets/css/grid.css', CHERRY_SHORTCODES_FILE), false, CHERRY_SHORTCODES_VERSION, 'all');
     }
     // Magnific Popup.
     wp_register_style('magnific-popup', plugins_url('assets/css/magnific-popup.css', CHERRY_SHORTCODES_FILE), false, CHERRY_SHORTCODES_VERSION, 'all');
     // Font Awesome.
     wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css', false, '4.4.0', 'all');
     // Swiper.
     wp_register_style('swiper', plugins_url('assets/css/swiper.css', CHERRY_SHORTCODES_FILE), false, CHERRY_SHORTCODES_VERSION, 'all');
     // Shortcodes style.
     wp_register_style('cherry-shortcodes-all', plugins_url('assets/css/shortcodes.css', CHERRY_SHORTCODES_FILE), false, CHERRY_SHORTCODES_VERSION, 'all');
     /**
      * Hook to deregister stylesheets or add custom.
      *
      * @since 1.0.0
      */
     do_action('cherry_shortcodes/assets/register_styles');
 }
예제 #7
0
 function apply_testing_nested_filter()
 {
     $this->apply_testing_nested_filter = true;
     $this->assertTrue(doing_filter());
     $this->assertTrue(doing_filter('testing'));
     $this->assertTrue(doing_filter('testing_nested'));
     $this->assertFalse(doing_filter('something_else'));
 }
예제 #8
0
function enlightenment_theme_settings_override_value($args)
{
    global $pagenow;
    if ('themes.php' == $pagenow && isset($_GET['page']) && current_theme_supports('enlightenment-theme-settings', 'menu_slug') == $_GET['page']) {
        if (false === strpos($args['name'], '[')) {
            if (doing_filter('enlightenment_checkbox_args') && empty($args['checked'])) {
                $checkbox = enlightenment_theme_option($args['name']);
                $args['checked'] = !empty($checkbox);
            } elseif (empty($args['value'])) {
                $args['value'] = enlightenment_theme_option($args['name']);
            }
        }
    }
    return $args;
}
예제 #9
0
 function did_action($tag)
 {
     return did_action($tag) - (int) doing_filter($tag);
 }
예제 #10
0
 /**
  * Make sure content is valid for processing/activation
  * 
  * @param string $content Content to validate
  * @return bool TRUE if content is valid (FALSE otherwise)
  */
 protected function is_content_valid($content)
 {
     // Invalid hooks
     if (doing_filter('get_the_excerpt')) {
         return false;
     }
     // Non-string value
     if (!is_string($content)) {
         return false;
     }
     // Empty string
     $content = trim($content);
     if (empty($content)) {
         return false;
     }
     // Content is valid
     return $this->util->apply_filters('is_content_valid', true, $content);
 }
예제 #11
0
 private function doing_filter($filter = null)
 {
     if (function_exists('doing_filter')) {
         return doing_filter($filter);
     }
     global $wp_current_filter;
     if (null === $filter) {
         return !empty($wp_current_filter);
     }
     return in_array($filter, $wp_current_filter);
 }
예제 #12
0
 /**
  * Cache current Title in static variable
  * Must be called inside the loop
  *
  * @param string $title The Title to return
  * @param string $sep The Title sepeartor
  * @param string $seplocation The Title sepeartor location ( accepts 'left' or 'right' )
  * @param bool $meta Ignore theme doing it wrong.
  *
  * @staticvar array $title_cache
  *
  * @since 2.2.2
  * @return string The title
  */
 public function title_from_cache($title = '', $sep = '', $seplocation = '', $meta = false)
 {
     /**
      * Cache the inputs, for when the title is doing it right.
      * Use those values to fetch the cached title.
      *
      * @since 2.4.0
      */
     static $setup_cache = null;
     static $title_param_cache = null;
     static $sep_param_cache = null;
     static $seplocation_param_cache = null;
     if (!isset($setup_cache)) {
         if (doing_filter('pre_get_document_title') || doing_filter('wp_title')) {
             $title_param_cache = $title;
             $sep_param_cache = $sep;
             $seplocation_param_cache = $seplocation;
             $setup_cache = 'I like turtles.';
         }
     }
     /**
      * If the theme is doing it right, override parameters to speed things up.
      *
      * @since 2.4.0
      */
     if (isset($this->title_doing_it_wrong) && false === $this->title_doing_it_wrong) {
         $title = $title_param_cache;
         $sep = $sep_param_cache;
         $seplocation = $seplocation_param_cache;
         $meta = false;
     }
     static $title_cache = array();
     if (isset($title_cache[$title][$sep][$seplocation][$meta])) {
         return $title_cache[$title][$sep][$seplocation][$meta];
     }
     return $title_cache[$title][$sep][$seplocation][$meta] = $this->title($title, $sep, $seplocation, array('meta' => $meta));
 }
예제 #13
0
function rcl_get_link_group_tag($content)
{
    global $post, $user_ID, $rcl_group;
    if ($post->post_type != 'post-group') {
        return $content;
    }
    $group_data = get_the_terms($post->ID, 'groups');
    foreach ((array) $group_data as $data) {
        if ($data->parent == 0) {
            $group_id = $data->term_id;
        } else {
            $tag = $data;
        }
    }
    if (!$tag) {
        return $content;
    }
    if (doing_filter('the_excerpt')) {
        if (!$rcl_group) {
            $rcl_group = rcl_get_group($group_id);
        }
        if ($rcl_group->group_status == 'closed') {
            if ($rcl_group->admin_id != $user_ID) {
                $user_status = rcl_get_group_user_status($user_ID, $rcl_group->term_id);
                if (!$user_status) {
                    $content = rcl_close_group_post_content();
                }
            }
        }
    }
    $cat = '<p><i class="fa fa-folder"></i>' . __('Category in the group', 'wp-recall') . ': <a href="' . get_term_link((int) $group_id, 'groups') . '?group-tag=' . $tag->slug . '">' . $tag->name . '</a></p>';
    return $cat . $content;
}
 function __call($method, $args)
 {
     $params = array_shift($args);
     $inner_content = array_shift($args);
     $parts = explode('____', $method);
     $shortcode = array_shift($parts);
     if (doing_filter('the_content')) {
         return $this->replace_with_placeholder($shortcode, $params, $inner_content);
     } else {
         $callback = $this->_shortcodes[$shortcode];
         return call_user_func($callback, $params, $inner_content);
     }
 }
 /**
  * Restrict (post) content based on content restriction rules
  *
  * @since 1.0.0
  * @param string $content The content
  * @return string
  */
 public function restrict_content($content)
 {
     // Check if content is restricted - and this function is not being recursively called
     // from `get_the_excerpt`, which internally applies `the_content` to the excerpt, which
     // then calls this function, ... until the stack is full and I want to go home and not
     // deal with this anymore...
     if (wc_memberships_is_post_content_restricted() && !doing_filter('get_the_excerpt')) {
         global $post;
         // Check if user has access to restricted content
         if (!current_user_can('wc_memberships_view_restricted_post_content', $post->ID)) {
             // User does not have access, filter the content
             $content = '';
             if (!in_array($post->ID, $this->content_restriction_applied)) {
                 if ('yes' == get_option('wc_memberships_show_excerpts')) {
                     $content = get_the_excerpt();
                 }
                 $content .= '<div class="woocommerce"><div class="woocommerce-info wc-memberships-restriction-message wc-memberships-message wc-memberships-content-restricted-message">' . wc_memberships()->frontend->get_content_restricted_message($post->ID) . '</div></div>';
             }
         } else {
             if (!current_user_can('wc_memberships_view_delayed_post_content', $post->ID)) {
                 // User does not have access, filter the content
                 $content = '';
                 if (!in_array($post->ID, $this->content_restriction_applied)) {
                     if ('yes' == get_option('wc_memberships_show_excerpts')) {
                         $content = get_the_excerpt();
                     }
                     $content .= '<div class="woocommerce"><div class="woocommerce-info wc-memberships-restriction-message wc-memberships-content-delayed-message">' . wc_memberships()->frontend->get_content_delayed_message(get_current_user_id(), $post->ID) . '</div></div>';
                 }
             }
         }
         // Indicates that the content for this post has already been filtered
         $this->content_restriction_applied[] = $post->ID;
     }
     return $content;
 }
예제 #16
0
function rcl_post_content_rating($content)
{
    global $post;
    if (doing_filter('get_the_excerpt')) {
        return $content;
    }
    $content .= rcl_get_html_post_rating($post->ID, $post->post_type);
    return $content;
}