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


PHP get_shortcode_regex函数代码示例

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


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

示例1: parse_shortcode_id

 /**
  * Parse the CF7 shortcode ID in single or nested shortcodes
  * @return (array) of CF7 id(s)
  * @since 1.0.2
  */
 function parse_shortcode_id($content)
 {
     $tag = 'contact-form-7';
     // Return if there is no CF7 shortcode in post content
     if (!has_shortcode($content, $tag)) {
         return false;
     }
     // Get all the CF7 form shortcodes in the post content
     // Use similar approach as wp-includes\shortcodes.php has_shortcode() function
     preg_match_all('/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER);
     if (empty($matches)) {
         return false;
     }
     // Loop through shortcodes, parse shortcode attributes and get the CF7 form ID
     foreach ($matches as $shortcode) {
         if ($tag === $shortcode[2]) {
             $atts = shortcode_parse_atts($shortcode[3]);
             $ids[] = $atts['id'];
             // Add the CF7 form ID
             // Nested shortcode
         } elseif (!empty($shortcode[5]) && has_shortcode($shortcode[5], $tag)) {
             // nested shortcodes
             $shortcode = $this->parse_shortcode_id($shortcode[5]);
         }
     }
     // Return all the CF7 form ID
     if (isset($ids)) {
         return $ids;
     }
 }
开发者ID:pabloe01,项目名称:Rawsonenmovimiento,代码行数:35,代码来源:contact.php

示例2: paragraph_not_contains_element

 public function paragraph_not_contains_element($paragraph)
 {
     if (preg_match_all('/' . get_shortcode_regex() . '/s', $paragraph, $matches, PREG_SET_ORDER)) {
         return false;
     }
     return true;
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:7,代码来源:class-shortcode.php

示例3: PGP_ShortCodeDetect

/**
* Short Code Detach Function To UpLoad JS And CSS
*/
function PGP_ShortCodeDetect()
{
    global $wp_query;
    $Posts = $wp_query->posts;
    $Pattern = get_shortcode_regex();
    foreach ($Posts as $Post) {
        if (strpos($Post->post_content, 'PGP')) {
            /**
             * js scripts
             */
            wp_enqueue_script('jquery');
            /**
             * Load Light Box 3 Swipebox JS CSS
             */
            wp_enqueue_style('PGP-swipe-css1', PGP_PLUGIN_URL . 'lightbox/swipebox/swipebox.css');
            wp_enqueue_script('PGP-swipe-js1', PGP_PLUGIN_URL . 'lightbox/swipebox/jquery.swipebox.min.js', array('jquery'));
            /**   
             * css scripts
             */
            wp_enqueue_style('PGP-boot-strap-css', PGP_PLUGIN_URL . 'css/bootstrap.css');
            wp_enqueue_style('PGP-Main-css', PGP_PLUGIN_URL . 'css/main.css');
            /**
             * font awesome css
             */
            wp_enqueue_style('PGP-font-awesome-4', PGP_PLUGIN_URL . 'css/font-awesome-latest/css/font-awesome.min.css');
            break;
        }
        //end of if
    }
    //end of foreach
}
开发者ID:xxf1995,项目名称:alphaV,代码行数:34,代码来源:photo-video-link-gallery.php

示例4: do_shortcode_media

 /**
  * WordPress has a few shortcodes for handling embedding media:  [audio], [video], and [embed].  This
  * method figures out the shortcode used in the content.  Once it's found, the appropriate method for
  * the shortcode is executed.
  *
  * @return 	void
  * @access 	public
  * @since  	1.0.0
  */
 public function do_shortcode_media()
 {
     /* Finds matches for shortcodes in the content. */
     preg_match_all('/' . get_shortcode_regex() . '/s', $this->content, $matches, PREG_SET_ORDER);
     /* If matches are found, loop through them and check if they match one of WP's media shortcodes. */
     if (!empty($matches)) {
         foreach ($matches as $shortcode) {
             if (!in_array($shortcode[2], $this->valid_shortcodes)) {
                 continue;
             }
             /* Call the method related to the specific shortcode found and break out of the loop. */
             if (in_array($shortcode[2], array('playlist', 'embed', $this->type))) {
                 call_user_func(array($this, "do_{$shortcode[2]}_shortcode_media"), $shortcode);
                 break;
             }
             /* Check for Jetpack audio/video shortcodes. */
             if (in_array($shortcode[2], array('blip.tv', 'dailymotion', 'flickr', 'ted', 'vimeo', 'vine', 'youtube', 'wpvideo', 'soundcloud', 'bandcamp'))) {
                 $this->do_jetpack_shortcode_media($shortcode);
                 break;
             }
             /* Call shortcode handler for shortcode not handled before. */
             $callback = apply_filters('hybrid_media_grabber_do_shortcode_callback', array($this, 'do_default_shortcode_media'), $shortcode[2]);
             call_user_func($callback, $shortcode);
         }
     }
 }
开发者ID:Charitable,项目名称:Reach,代码行数:35,代码来源:class-reach-media-grabber.php

示例5: pl_get_attachment_ids_from_gallery

function pl_get_attachment_ids_from_gallery()
{
    global $post;
    if ($post != null) {
        $attachment_ids = array();
        $pattern = get_shortcode_regex();
        $ids = array();
        //finds the "gallery" shortcode, puts the image ids in an associative array: $matches[3]
        if (preg_match_all('/' . $pattern . '/s', $post->post_content, $matches)) {
            $count = count($matches[3]);
            //in case there is more than one gallery in the post.
            for ($i = 0; $i < $count; $i++) {
                $atts = shortcode_parse_atts($matches[3][$i]);
                if (isset($atts['ids'])) {
                    $attachment_ids = explode(',', $atts['ids']);
                    $ids = array_merge($ids, $attachment_ids);
                }
            }
        }
        return $ids;
    } else {
        $ids = array();
        return $ids;
    }
}
开发者ID:taeche,项目名称:SoDoEx,代码行数:25,代码来源:lib.posts.php

示例6: prefetch_items

 /**
  * Loop over all the content in the main loop and do a request for all the items present so that we're only getting
  * a few API hits instead of all of them. Then, when anything else calls `easyazon_get_item` it will get the cached
  * data and not have to hit the API.
  */
 public static function prefetch_items()
 {
     global $wp_query;
     $identifiers = array_fill_keys(array_keys(easyazon_get_locales()), array());
     $preparsed = array();
     $shortcodes = easyazon_get_shortcodes();
     foreach ($wp_query->posts as $post) {
         preg_match_all('/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER);
         foreach ($matches as $match) {
             $shortcode = trim($match[2]);
             if (in_array($shortcode, $shortcodes)) {
                 $attributes = shortcode_parse_atts($match[3]);
                 $locale = isset($attributes['locale']) ? $attributes['locale'] : false;
                 $identifier = isset($attributes['identifier']) ? $attributes['identifier'] : false;
                 if (!is_array($preparsed[$shortcode])) {
                     $preparsed[$shortcode] = array();
                 }
                 $preparsed[$shortcode][] = $attributes;
                 if ($locale && $identifier) {
                     $identifiers[$locale][] = $identifier;
                 }
             }
         }
     }
     foreach ($identifiers as $locale => $queryable) {
         $cached_items = easyazon_get_items($queryable, $locale);
     }
     self::$preparsed_shortcodes = $preparsed;
 }
开发者ID:sushant-chaudhari-sp,项目名称:easyazon,代码行数:34,代码来源:performance.php

示例7: curly_tabs_vc

function curly_tabs_vc($atts, $content = null)
{
    $GLOBALS['tabsID'] = isset($GLOBALS['tabsID']) ? $GLOBALS['tabsID'] + 1 : 0;
    $GLOBALS['tabsSlideID'] = $GLOBALS['tabsID'] * 100;
    $pattern = get_shortcode_regex();
    preg_match_all("/{$pattern}/", $content, $shortcodes);
    $shortcodes_array = $shortcodes[2];
    $shortcodes_values_array = $shortcodes[3];
    $shortcodes_content_array = $shortcodes[5];
    extract(shortcode_atts(array(), $atts));
    if (has_shortcode($content, 'curly_tab')) {
        $html = '<div class="tabs-container">';
        $html .= '<ul class="nav nav-tabs">';
        $tabs_keys = array_keys($shortcodes_array, 'curly_tab');
        $index = 0;
        foreach ($tabs_keys as $key => $tab) {
            extract(shortcode_atts(array('title' => null), shortcode_parse_atts($shortcodes_values_array[$tab]), 'curly_tab'));
            $html .= '<li class="' . ($index === 0 ? 'active' : '') . '"><a href="#tab' . (100 * $GLOBALS['tabsID'] + 1) . '" data-toggle="tab">' . $title . '</a></li>';
            $index++;
        }
        $html .= '</ul>';
        $html .= '<div class="tab-content">';
        $html .= do_shortcode($content);
        $html .= '</div>';
        $html .= '</div>';
        return $html;
    }
}
开发者ID:raducretu,项目名称:curly-extension,代码行数:28,代码来源:tabs.php

示例8: get_post_gallery_images_gpgi

/**
 * Get Image from Post core file
 *
 * This file contains all the logic required for the plugin
 *
 * @package         Get Post Gallery Images
 * @copyright       Copyright (c) 2013, Sierj Khaletski
 * @license         http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
 *
 * @since           Get Post Gallery Images 0.1
 */
function get_post_gallery_images_gpgi()
{
    $attachment_ids = array();
    $pattern = get_shortcode_regex();
    $images = array();
    if (preg_match_all('/' . $pattern . '/s', get_the_content(), $matches)) {
        //finds the "gallery" shortcode and puts the image ids in an associative array at $matches[3]
        $count = count($matches[3]);
        //in case there is more than one gallery in the post.
        for ($i = 0; $i < $count; $i++) {
            $atts = shortcode_parse_atts($matches[3][$i]);
            if (isset($atts['ids'])) {
                $attachment_ids = explode(',', $atts['ids']);
                $attachementsCount = count($attachment_ids);
                if ($attachementsCount > 0) {
                    for ($j = 0; $j < $attachementsCount; $j++) {
                        $image = array();
                        $attachmentId = intval($attachment_ids[$j]);
                        $image['id'] = $attachmentId;
                        $image['full'] = wp_get_attachment_image_src($attachmentId, 'full');
                        $image['medium'] = wp_get_attachment_image_src($attachmentId, 'medium');
                        $image['thumbnail'] = wp_get_attachment_image_src($attachmentId, 'thumbnail');
                        array_push($images, $image);
                    }
                }
            }
        }
    }
    return $images;
}
开发者ID:TheML9I,项目名称:get-post-gallery-images,代码行数:41,代码来源:get-post-gallery-images.php

示例9: find_ids

 /**
  * Search a string for ingot shortcodes and return ids used
  *
  * @since 1.1.0
  *
  * @param string $content String to search
  *
  * @return array Array of group IDs
  */
 public static function find_ids($content)
 {
     $ids = [];
     $tag = 'ingot';
     if (!has_shortcode($content, $tag) || false === strpos($content, '[')) {
         return $ids;
     }
     if (shortcode_exists($tag)) {
         preg_match_all('/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER);
         if (empty($matches)) {
             return $ids;
         }
         foreach ($matches as $shortcode) {
             if ($tag === $shortcode[2] && isset($shortcode[3])) {
                 $_id = self::find_id($shortcode);
                 if (is_numeric($_id)) {
                     $ids[] = $_id;
                 }
             } elseif (!empty($shortcode[5]) && has_shortcode($shortcode[5], $tag)) {
                 $_id = self::find_id($shortcode);
                 if (is_numeric($_id)) {
                     $ids[] = $_id;
                 }
             }
         }
     }
     return $ids;
 }
开发者ID:rene-hermenau,项目名称:ingot,代码行数:37,代码来源:posts.php

示例10: lidd_mc_detect_shortcode

function lidd_mc_detect_shortcode()
{
    global $post;
    $pattern = get_shortcode_regex();
    // Check the content.
    return preg_match_all('/' . $pattern . '/s', $post->post_content, $matches) && array_key_exists(2, $matches) && (in_array('mortgagecalculator', $matches[2]) || in_array('rmc', $matches[2])) || strpos($post->post_content, 'lidd_mc_form') !== false;
}
开发者ID:Juni4567,项目名称:mycashflow,代码行数:7,代码来源:load_scripts.php

示例11: WRGF_ShortCodeDetect

/**
 * Weblizar Image Gallery Shortcode Detect Function
 */
function WRGF_ShortCodeDetect()
{
    global $wp_query;
    $Posts = $wp_query->posts;
    $Pattern = get_shortcode_regex();
    /**
     * js scripts
     */
    wp_enqueue_script('jquery');
    wp_enqueue_script('wrgf-hover-pack-js', WRGF_PLUGIN_URL . 'js/hover-pack.js', array('jquery'));
    /**
     * Load Light Box 4 Swipebox JS CSS
     */
    wp_enqueue_style('wl-wrgf-swipe-css', WRGF_PLUGIN_URL . 'lightbox/swipebox/swipebox.css');
    wp_enqueue_script('wl-wrgf-swipe-js', WRGF_PLUGIN_URL . 'lightbox/swipebox/jquery.swipebox.js');
    /**   
     * css scripts
     */
    wp_enqueue_style('wrgf-hover-pack-css', WRGF_PLUGIN_URL . 'css/hover-pack.css');
    wp_enqueue_style('wrgf-boot-strap-css', WRGF_PLUGIN_URL . 'css/bootstrap.css');
    wp_enqueue_style('wrgf-img-gallery-css', WRGF_PLUGIN_URL . 'css/img-gallery.css');
    /**
     * font awesome css
     */
    wp_enqueue_style('wrgf-font-awesome-4', WRGF_PLUGIN_URL . 'css/font-awesome-latest/css/font-awesome.min.css');
    /**
     * envira & isotope js
     */
    wp_enqueue_script('wrgf_masonry', WRGF_PLUGIN_URL . 'js/masonry.pkgd.min.js', array('jquery'));
    wp_enqueue_script('wrgf_imagesloaded', WRGF_PLUGIN_URL . 'js/imagesloaded.pkgd.min.js', array('jquery'));
}
开发者ID:nazarmak,项目名称:wp-content,代码行数:34,代码来源:responsive-gallery-with-lightbox.php

示例12: shortcodesOnPost

function shortcodesOnPost()
{
    // get the post data
    global $post;
    // get the shortcode regex
    $pattern = get_shortcode_regex();
    // run regex on the content to find all the shortcodes being used
    preg_match_all('/' . $pattern . '/s', $post->post_content, $matches);
    // only if there are matches
    if (!empty($matches)) {
        //loop through the results
        //$matches[3] contains the atts
        //$matches[2] contains the shortcode name
        //$matches[5] contains the shortcode Data
        foreach ($matches[3] as $key => $arg) {
            $shortcode = $matches[2][$key];
            //check to see if the found code is mine :)
            if ($shortcode == 'myShortCode') {
                // Parse the attributes to an array
                $data = shortcode_parse_atts($arg);
                // get the shortcode content
                $content = $matches[5][$key];
                // wp_enqueue_script
                // wp_enqueue_style
                // for the specific shortcodes used
            }
        }
    }
}
开发者ID:routexl,项目名称:DB-Toolkit,代码行数:29,代码来源:actions.php

示例13: callback

 function callback($path = '', $blog_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     if (!current_user_can('edit_posts')) {
         return new WP_Error('unauthorized', 'Your token must have permission to post on this blog.', 403);
     }
     $args = $this->query_args();
     $shortcode = trim($args['shortcode']);
     // Quick validation - shortcodes should always be enclosed in brackets []
     if (!wp_startswith($shortcode, '[') || !wp_endswith($shortcode, ']')) {
         return new WP_Error('invalid_shortcode', 'The shortcode parameter must begin and end with square brackets.', 400);
     }
     // Make sure only one shortcode is being rendered at a time
     $pattern = get_shortcode_regex();
     preg_match_all("/{$pattern}/s", $shortcode, $matches);
     if (count($matches[0]) > 1) {
         return new WP_Error('invalid_shortcode', 'Only one shortcode can be rendered at a time.', 400);
     }
     $render = $this->process_render(array($this, 'do_shortcode'), $shortcode);
     // if nothing happened, then the shortcode does not exist.
     if ($shortcode == $render['result']) {
         return new WP_Error('invalid_shortcode', 'The requested shortcode does not exist.', 400);
     }
     // our output for this endpoint..
     $return['shortcode'] = $shortcode;
     $return['result'] = $render['result'];
     $return = $this->add_assets($return, $render['loaded_scripts'], $render['loaded_styles']);
     return $return;
 }
开发者ID:shazadmaved,项目名称:vizblog,代码行数:32,代码来源:class.wpcom-json-api-render-shortcode-endpoint.php

示例14: content

 public static function content($content)
 {
     global $post;
     if (!self::allowed($post)) {
         return $content;
     }
     self::setup_links($post);
     if (!self::$links) {
         return $content;
     }
     $header_replacements = array();
     $link_replacements = array();
     $other_replacements = array();
     $shortcode_replacements = array();
     $filtered = $content;
     preg_match_all('/' . get_shortcode_regex() . '/', $filtered, $scodes);
     if (!empty($scodes[0])) {
         $shortcode_replacements = self::gen_replacements($scodes[0], 'shortcode');
         $filtered = self::replace($shortcode_replacements, $filtered);
     }
     preg_match_all('/<h[1-6][^>]*>.+?<\\/h[1-6]>/iu', $filtered, $headers);
     if (!empty($headers[0])) {
         $header_replacements = self::gen_replacements($headers[0], 'header');
         $filtered = self::replace($header_replacements, $filtered);
     }
     preg_match_all('/<(img|input)(.*?) \\/?>/iu', $filtered, $others);
     if (!empty($others[0])) {
         $other_replacements = self::gen_replacements($others[0], 'others');
         $filtered = self::replace($other_replacements, $filtered);
     }
     foreach (self::$links as $count => $l) {
         if (apply_filters('seoal_should_continue', false, $l, $count)) {
             continue;
         }
         preg_match_all('/<a(.*?)href="(.*?)"(.*?)>(.*?)<\\/a>/iu', $filtered, $links);
         if (!empty($links[0])) {
             $start = count($link_replacements);
             $tmp = self::gen_replacements($links[0], 'links', $start);
             $filtered = self::replace($tmp, $filtered);
             $link_replacements = array_merge($link_replacements, $tmp);
         }
         $regex = self::get_kw_regex($l);
         $url = self::get_link_url($l);
         $max = self::get_link_max($l);
         if (!$regex || !$url || !$max || $url == self::$permalink && !self::self_links_allowed($l)) {
             continue;
         }
         $cls = apply_filters('seoal_link_class', 'auto-link', $l);
         $target = self::get_link_target($l);
         $replace = sprintf('$1<a href="%1$s" title="$2" target="%2$s" %3$s %4$s>$2</a>$3', esc_url($url), esc_attr($target), $cls ? 'class="' . esc_attr($cls) . '"' : '', self::is_nofollow($l) ? 'rel="nofollow"' : '');
         $filtered = preg_replace($regex, $replace, $filtered, absint($max));
     }
     $filtered = apply_filters('seoal_pre_replace', $filtered, $post);
     $filtered = self::replace_bak($shortcode_replacements, $filtered);
     $filtered = self::replace_bak($header_replacements, $filtered);
     $filtered = self::replace_bak($link_replacements, $filtered);
     $filtered = self::replace_bak($other_replacements, $filtered);
     return apply_filters('seoal_post_replace', $filtered, $post);
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:59,代码来源:front.php

示例15: argent_get_gallery

/**
 * Get the gallery shortcode from the project content.
 */
function argent_get_gallery()
{
    global $post;
    $pattern = get_shortcode_regex();
    if (preg_match_all('/' . $pattern . '/s', $post->post_content, $matches) && array_key_exists(2, $matches) && in_array('gallery', $matches[2])) {
        return $matches;
    }
}
开发者ID:nitaibezerra,项目名称:Argent-Neue,代码行数:11,代码来源:extras.php


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