本文整理汇总了PHP中has_shortcode函数的典型用法代码示例。如果您正苦于以下问题:PHP has_shortcode函数的具体用法?PHP has_shortcode怎么用?PHP has_shortcode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_shortcode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: enqueue_scripts
public function enqueue_scripts($posts)
{
if (empty($posts)) {
return $posts;
}
// false because we have to search through the posts first
$found = false;
// search through each post
foreach ($posts as $post) {
if (has_shortcode($post->post_content, self::slug)) {
// we have found a post with the short code
$found = true;
// stop the search
break;
}
}
if ($found) {
if ($this->load_css) {
wp_enqueue_style('avca-google-map', AVCA_URL . 'modules/avca-google-map/assets/css/avca-google-map.css');
}
if ($this->load_map_api_js) {
wp_enqueue_script('googlemap', '//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.0', false);
}
if ($this->load_infobox_js) {
wp_enqueue_script('infobox', AVCA_URL . 'modules/avca-google-map/assets/js/infobox.js', array(), '3.0', false);
}
wp_enqueue_script('avca-google-map', AVCA_URL . 'modules/avca-google-map/assets/js/avca-google-map.js', array('jquery'), '3.0', false);
}
return $posts;
}
开发者ID:prosenjit-itobuz,项目名称:Advanced-Visual-Composer-Addons,代码行数:30,代码来源:avca-google-map.php
示例3: drstk_video_shortcode_scripts
function drstk_video_shortcode_scripts()
{
global $post;
if (has_shortcode($post->post_content, 'drstk_collection_playlist')) {
wp_enqueue_script('drstk_jwplayer');
}
}
开发者ID:sarahjeansweeney,项目名称:drs-toolkit-wp-plugin,代码行数:7,代码来源:video_shortcode.php
示例4: wp_head
/**
* Head.
*
* @return string
*/
public function wp_head()
{
global $post;
if (isset($post) && isset($post->post_content) && has_shortcode($post->post_content, 'gmaps')) {
Wabbr::view('maps/head');
}
}
开发者ID:gizburdt,项目名称:wabbr,代码行数:12,代码来源:class-wabbr-gmaps.php
示例5: list_event_shortcode
/**
* Shortcode stuff!
*/
public static function list_event_shortcode($atts)
{
global $post;
if (is_home() || is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'list-events') || is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'list_events') || is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'list-event') || is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'list_event')) {
$event_list_attributes = shortcode_atts(array('event_id' => null, 'client_id' => null, 'event-id' => null, 'client-id' => null), $atts);
$localized_variables = array('ajaxurl' => admin_url('admin-ajax.php'), 'bptNonce' => wp_create_nonce('bpt-event-list-nonce'), 'postID' => $post->ID);
$purchase_options = get_option('_bpt_purchase_settings');
if (isset($purchase_options['enable_sales'])) {
$localized_variables['enableSales'] = $purchase_options['enable_sales'];
}
if ($event_list_attributes['event_id']) {
$localized_variables['eventID'] = $event_list_attributes['event_id'];
}
if ($event_list_attributes['event-id']) {
$localized_variables['eventID'] = $event_list_attributes['event-id'];
}
if ($event_list_attributes['client-id']) {
$localized_variables['clientID'] = $event_list_attributes['client-id'];
}
if ($event_list_attributes['client_id']) {
$localized_variables['clientID'] = $event_list_attributes['client_id'];
}
wp_enqueue_style('bpt_event_list_css', plugins_url('/assets/css/bpt-event-list-shortcode.css', __FILE__), array(), plugin::get_plugin_version());
wp_register_script('event_feed_js_' . $post->ID, plugins_url('/assets/js/event-feed.js', __FILE__), array('jquery', 'underscore', 'ractive_js', 'ractive_transitions_slide_js', 'moment_with_langs_min'), null, true);
wp_enqueue_script('event_feed_js_' . $post->ID);
wp_localize_script('event_feed_js_' . $post->ID, 'bptEventFeedAjaxPost' . $post->ID, $localized_variables);
}
return require __DIR__ . '/assets/templates/event-list.php';
}
开发者ID:razordaze,项目名称:brown-paper-tickets-wordpress,代码行数:32,代码来源:event-list-shortcode.php
示例6: _base_scripts
function _base_scripts()
{
global $post;
// remove version
add_filter('script_loader_src', 'remove_src_version');
// global styles
wp_enqueue_style('bootstrap-min', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), '');
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css', array(), '');
if (class_exists('bbPress')) {
if (is_bbpress()) {
wp_enqueue_style('bbpress-custom', get_template_directory_uri() . '/assets/css/bbpress.css', array(), '');
}
}
wp_enqueue_style('custom', get_template_directory_uri() . '/assets/css/customs.css', array(), '');
wp_enqueue_style('custom-style', get_template_directory_uri() . '/style.css', array(), '');
// global scripts
wp_enqueue_script('jquery');
wp_enqueue_script('bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '', true);
if (is_single() && get_post_type() == 'course_unit') {
wp_enqueue_script('froogaloop2', get_template_directory_uri() . '/assets/js/froogaloop2.min.js', array(), '', true);
}
if (is_page_template('page-templates/tpl-webinars.php')) {
wp_enqueue_style('fancybox', get_template_directory_uri() . '/assets/lib/fancybox/jquery.fancybox.css', array(), '');
wp_enqueue_script('fancybox', get_template_directory_uri() . '/assets/lib/fancybox/jquery.fancybox.pack.js', array(), '', true);
wp_enqueue_script('fancybox-media', get_template_directory_uri() . '/assets/lib/fancybox/helpers/jquery.fancybox-media.js', array(), '', true);
}
if (has_shortcode($post->post_content, 'iard_table')) {
wp_enqueue_script('angular', get_template_directory_uri() . '/assets/js/angular.min.js', array(), '', true);
wp_enqueue_script('angular-sanitize', get_template_directory_uri() . '/assets/js/angular-sanitize.js', array(), '', true);
wp_enqueue_script('table-app', get_template_directory_uri() . '/assets/js/tables.js', array(), '', true);
}
wp_enqueue_script('main', get_template_directory_uri() . '/assets/js/main.js', array(), '', true);
}
开发者ID:jhipwell6,项目名称:iard,代码行数:33,代码来源:functions.php
示例7: hoo_api
public function hoo_api()
{
global $post;
// /if the page contains the hoo-api shortcode send json and exit :}
if (is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'hoo-api')) {
$locations_repo = $this->entity_manager->getRepository('Hoo\\Model\\Location');
$json_response = array();
$date = isset($_GET['date']) ? new \DateTime($_GET['date']) : new \DateTime(date('Y-m-d'));
if (isset($_GET['location_id'])) {
$location = Location::get_location_by_id_or_shortname($_GET['location_id'], $this->entity_manager);
if (!$location) {
return wp_send_json_error('Not Found');
}
$hours = $location->get_hours_for_date($date);
$json_response['location'] = $location->to_api_response();
$json_response['location']['address'] = $location->address->to_api_response();
$json_response['hours'] = $hours ? $hours->to_api_response() : null;
$json_response['weekly'] = $location->get_weekly_hours();
} else {
$locations_repo = $this->entity_manager->getRepository('Hoo\\Model\\Location');
foreach ($locations_repo->findBy(array('is_visible' => true)) as $location) {
$hours = $location->get_hours_for_date($date);
$json_response[]['location'] = $location->to_api_response();
$json_response[]['location']['address'] = $location->address->to_api_response();
$json_response[]['hours'] = $hours ? $hours->to_api_response() : null;
$json_response[]['weekly'] = $location->get_weekly_hours();
}
}
wp_send_json($json_response);
exit;
}
}
开发者ID:UNC-Libraries,项目名称:Hours-of-Operation,代码行数:32,代码来源:Shortcode.php
示例8: ecf_enqueue_on_the_fly
function ecf_enqueue_on_the_fly()
{
global $post;
if (function_exists('has_shortcode')) {
if (has_shortcode($post->post_content, 'easy-contactform')) {
wp_enqueue_script('ecf-ladda-spin');
wp_enqueue_script('ecf-notify');
wp_enqueue_script('ecf-ladda-js');
global $is_IE;
if ($is_IE) {
wp_enqueue_script('ecf-placeholder');
}
}
} else {
if (emg_old_has_shortcode('easy-contactform')) {
wp_enqueue_script('ecf-ladda-spin');
wp_enqueue_script('ecf-notify');
wp_enqueue_script('ecf-ladda-js');
global $is_IE;
if ($is_IE) {
wp_enqueue_script('ecf-placeholder');
}
}
}
}
开发者ID:RuslanKononov,项目名称:israel-taxi24-com,代码行数:25,代码来源:ecf-frontend.php
示例9: hasShortCode
/**
* Check if the content contains the shortcode. Will use WP 3.6+ has_shortcode if available, otherwise
* fall back to string matching.
*
* @param $content
*
* @return bool
* @since 2.4
*/
protected function hasShortCode($content)
{
if (function_exists('has_shortcode')) {
return has_shortcode($content, 'utcw');
}
return strpos($content, '[utcw') !== false;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:16,代码来源:ShortCode.php
示例10: 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
示例11: ccb_video_script
/**
* @param checks to see if the current post has a [video] shortcode.
* @return script that will autoplay an HTML5 video player when in viewport, pauses when exits viewport.
* @extends https://codex.wordpress.org/Video_Shortcode
*/
function ccb_video_script()
{
global $post;
if (is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'video')) {
?>
<script type="text/javascript">
// Add :in-viewport jQuery detection
(function($){$.belowthefold=function(element,settings){var fold=$(window).height()+$(window).scrollTop();return fold<=$(element).offset().top-settings.threshold;};$.abovethetop=function(element,settings){var top=$(window).scrollTop();return top>=$(element).offset().top+$(element).height()-settings.threshold;};$.rightofscreen=function(element,settings){var fold=$(window).width()+$(window).scrollLeft();return fold<=$(element).offset().left-settings.threshold;};$.leftofscreen=function(element,settings){var left=$(window).scrollLeft();return left>=$(element).offset().left+$(element).width()-settings.threshold;};$.inviewport=function(element,settings){return!$.rightofscreen(element,settings)&&!$.leftofscreen(element,settings)&&!$.belowthefold(element,settings)&&!$.abovethetop(element,settings);};$.extend($.expr[':'],{"below-the-fold":function(a,i,m){return $.belowthefold(a,{threshold:0});},"above-the-top":function(a,i,m){return $.abovethetop(a,{threshold:0});},"left-of-screen":function(a,i,m){return $.leftofscreen(a,{threshold:0});},"right-of-screen":function(a,i,m){return $.rightofscreen(a,{threshold:0});},"in-viewport":function(a,i,m){return $.inviewport(a,{threshold:0});}});})(jQuery);
// Autplay video elements that are WP shortcodes.
jQuery(window).bind("load",function(){
jQuery(function() {
jQuery(window).scroll(function() {
jQuery('.wp-video-shortcode').each(function() {
var str = jQuery(this).attr('id');
var arr = str.split('_');
typecheck = arr[0];
if (jQuery(this).is(":in-viewport( 400 )") && typecheck == "mep") {
mejs.players[jQuery(this).attr('id')].media.play();
} else if (typecheck == "mep") {
mejs.players[jQuery(this).attr('id')].media.pause();
}
});
});
});
});
</script>
<?php
}
}
开发者ID:amprog,项目名称:cap-content-blocks,代码行数:35,代码来源:video.php
示例12: wp_rss_retriever_css
function wp_rss_retriever_css()
{
global $post;
if (has_shortcode($post->post_content, 'wp_rss_retriever')) {
wp_enqueue_style('rss-retriever', plugin_dir_url(__FILE__) . 'inc/css/rss-retriever.css');
}
}
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:7,代码来源:wp-rss-retriever.php
示例13: cfs_clear_css
function cfs_clear_css()
{
global $post;
if (has_shortcode($post->post_content, 'clear')) {
echo "\n<style>\n/*\n * Clear Floats Shortcode CSS\n */\n.cfs-clearfix:before,\n.cfs-clearfix:after {\n\tcontent: \" \";\n\tdisplay: table;\n}\n.cfs-clearfix:after {\n\tclear: both;\n}\n\n.cfs-both {\n\tclear: both;\n}\n\n.cfs-right {\n\tclear: right;\n}\n\n.cfs-left {\n\tclear: left;\n}\n</style>";
}
}
开发者ID:JulienMelissas,项目名称:clear-floats-shortcode,代码行数:7,代码来源:clear-floats-shortcode.php
示例14: fep_enqueue_files
/**
* Enqueue scripts and stylesheets
*
* @param array $posts WordPress posts to check for the shortcode
* @return array $posts Checked WordPress posts
*
*/
function fep_enqueue_files($posts)
{
if (empty($posts)) {
return $posts;
}
$found = false;
foreach ($posts as $post) {
if (has_shortcode($post->post_content, 'fep_article_list') || has_shortcode($post->post_content, 'fep_submission_form')) {
$found = true;
break;
}
}
if ($found) {
wp_enqueue_style('fep-style', plugins_url('static/css/style.css', __FILE__), array(), '1.0', 'all');
wp_enqueue_script("fep-script", plugins_url('static/js/scripts.js', __FILE__), array('jquery'));
wp_localize_script('fep-script', 'fepajaxhandler', array('ajaxurl' => admin_url('admin-ajax.php')));
$fep_rules = get_option('fep_post_restrictions');
$fep_roles = get_option('fep_role_settings');
$fep_rules['check_required'] = isset($fep_roles['no_check']) && $fep_roles['no_check'] && current_user_can($fep_roles['no_check']) ? 0 : 1;
wp_localize_script('fep-script', 'fep_rules', $fep_rules);
$enable_media = isset($fep_roles['enable_media']) && $fep_roles['enable_media'] ? current_user_can($fep_roles['enable_media']) : 1;
if ($enable_media) {
wp_enqueue_media();
}
}
return $posts;
}
开发者ID:sivaanil,项目名称:classifiedsgnt,代码行数:34,代码来源:fepublishing.php
示例15: 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
示例16: device_mockups_script
/**
* Enqueue script when gallery shortcode is used.
*/
function device_mockups_script()
{
global $post;
if (is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'gallery')) {
wp_enqueue_script('device-mockups-scripts', DEVICE_MOCKUPS_URL . 'js/device-mockups.js', array(), DEVICE_MOCKUPS_VERSION, true);
}
}
开发者ID:vrundakansara,项目名称:device-mockups,代码行数:10,代码来源:device-mockups.php
示例17: google_map_block_enqueue_scripts
function google_map_block_enqueue_scripts()
{
if (has_shortcode($GLOBALS['post']->post_content, 'map')) {
wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?sensor=false');
wp_enqueue_script('google-maps-map', plugins_url('front.js', __FILE__));
}
}
开发者ID:Merick359,项目名称:editor-experiments,代码行数:7,代码来源:google-maps-block.php
示例18: print_scripts
/**
* Output the styles and scripts necessary
*
* @param boolean $force Will be empty string when passed by `wp_enqueue_scripts`, but will be `true` when passed by `wunderground_print_scripts`
* @return [type] [description]
*/
function print_scripts($force = false)
{
global $post, $pagenow;
// Is the widget active?
$widget = is_active_widget(false, false, 'wunderground_forecast_widget') ? true : false;
// Check if the content has the shortcode
$content = false;
if (!empty($post->post_content) && function_exists('has_shortcode') && has_shortcode($post->post_content, 'wunderground')) {
$content = true;
}
$admin = is_admin() && in_array($pagenow, array('widgets.php', 'customize.php'));
if ($admin || $widget || $content || $force === true) {
// Only show the front-end display on the front-end
if (!$admin) {
wp_enqueue_style('wunderground', plugins_url('assets/css/wunderground.css', Wunderground_Plugin::$file), array('dashicons'), Wunderground_Plugin::version);
} else {
// And the backend on the backend
wp_enqueue_style('wunderground-admin', plugins_url('assets/css/admin.css', Wunderground_Plugin::$file));
}
// If using SCRIPT_DEBUG, don't use the minified version.
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script('wunderground-widget', plugins_url('assets/js/widget' . $min . '.js', Wunderground_Plugin::$file), array('jquery-ui-autocomplete'), Wunderground_Plugin::version);
wp_localize_script('wunderground-widget', 'WuWidget', array('apiKey' => esc_attr(Wunderground_Plugin::$api_key), '_wpnonce' => wp_create_nonce('wunderground-aq'), 'ajaxurl' => admin_url('admin-ajax.php'), 'is_admin' => is_admin(), 'subdomain' => wunderground_get_subdomain()));
}
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:31,代码来源:class-display.php
示例19: frontend_scripts_register
public static function frontend_scripts_register()
{
global $post;
global $contact_people_page_id;
if (is_admin()) {
return;
}
global $is_IE;
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
$_upload_dir = wp_upload_dir();
wp_register_style('people_contact_style', PEOPLE_CONTACT_CSS_URL . '/style' . $suffix . '.css');
if (file_exists($_upload_dir['basedir'] . '/sass/wp_contact_people' . $suffix . '.css')) {
wp_register_style('wp_contact_people', str_replace(array('http:', 'https:'), '', $_upload_dir['baseurl']) . '/sass/wp_contact_people' . $suffix . '.css');
}
if ($is_IE) {
wp_register_script('respondjs', PEOPLE_CONTACT_JS_URL . '/respond-ie.js');
}
if ($post && ($contact_people_page_id == $post->ID || has_shortcode($post->post_content, 'people_contacts'))) {
self::add_google_fonts();
wp_enqueue_style('people_contact_style');
wp_enqueue_style('wp_contact_people');
wp_enqueue_script('jquery');
wp_enqueue_script('respondjs');
add_action('wp_head', array('People_Contact_Hook_Filter', 'fix_window_console_ie'));
add_action('wp_head', array('People_Contact_Hook_Filter', 'frontend_footer_scripts'));
}
}
开发者ID:jep-heroes,项目名称:wp,代码行数:27,代码来源:class-people-contact-hook.php
示例20: acf_contact_display_form_head
function acf_contact_display_form_head()
{
global $post;
if (has_shortcode($post->post_content, 'acf_contact')) {
acf_form_head();
}
}
开发者ID:philbraun,项目名称:acf-contact-form,代码行数:7,代码来源:acf-contact-shortcode.php
注:本文中的has_shortcode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论