本文整理汇总了PHP中shortcode_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP shortcode_exists函数的具体用法?PHP shortcode_exists怎么用?PHP shortcode_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shortcode_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Registers the shortcode hook.
*
* @uses \add_shortcode()
* @uses \shortcode_exists()
*/
public final function add()
{
if (\shortcode_exists($this->tag)) {
throw new \Exception("Shortcode `{$this->tag}` exists.");
}
\add_shortcode($this->tag, array($this, 'output'));
}
示例2: debug_bar_shortcodes_do_ajax
/**
* Verify validity of ajax request and pass it to the internal handler
*/
function debug_bar_shortcodes_do_ajax()
{
// Verify this is a valid ajax request
if (wp_verify_nonce($_POST['dbs-nonce'], 'debug-bar-shortcodes') === false) {
exit('-1');
}
// Verify we have received the data needed to do anything
if (!isset($_POST['shortcode']) || $_POST['shortcode'] === '') {
exit('-1');
}
include_once plugin_dir_path(__FILE__) . 'class-debug-bar-shortcodes-info.php';
$info = new Debug_Bar_Shortcodes_Info();
$shortcode = $_POST['shortcode'];
$shortcode = trim($shortcode);
// Exit early if this is a non-existent shortcode - shouldn't happen, but hack knows ;-)
if (shortcode_exists($shortcode) === false) {
$response = array('id' => 0, 'data' => '');
$info->send_ajax_response($response);
exit;
}
// Send the request to our handler
switch ($_POST['action']) {
case 'debug-bar-shortcodes-find':
$info->ajax_find_shortcode_uses($shortcode);
break;
case 'debug-bar-shortcodes-retrieve':
$info->ajax_retrieve_details($shortcode);
break;
}
/* No valid action received (redundancy, can't really happen as wp wouldn't then call this
function, but would return 0 and exit already */
exit('-1');
}
示例3: cases_display_todo_comments
function cases_display_todo_comments()
{
if (!is_singular('cases')) {
return;
}
if (!shortcode_exists('cp_todo_comments')) {
return;
}
global $post;
$args = array('post_id' => $post->ID, 'meta_query' => array(array('key' => 'cp_control', 'value' => 'yes')), 'meta_key' => 'cp_control_order', 'orderby' => 'meta_value_num', 'order' => 'ASC');
$comments_query = new WP_Comment_Query();
$comments = $comments_query->query($args);
if (empty($comments)) {
return;
}
?>
<section id="case_todo_comments_wrapper" class="cases-box">
<header class="cases-box-header">
<h1>Комментарии на контроле</h1>
<hr>
</header>
<article class="cases-box-content">
<?php
echo do_shortcode('[cp_todo_comments]');
?>
</article>
</section>
<?php
}
示例4: 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;
}
示例5: register_shortcode
public static function register_shortcode()
{
// backward compatible, but only load if no other plugin has registered this shortcode
if (!shortcode_exists('podlove-subscribe-button')) {
add_shortcode('podlove-subscribe-button', [__CLASS__, 'button']);
}
add_shortcode('podlove-podcast-subscribe-button', [__CLASS__, 'button']);
}
示例6: __construct
public function __construct()
{
add_shortcode('ultimate-recipe', array($this, 'recipe_shortcode'));
// Fallback after importing
if (!shortcode_exists('cooked-recipe')) {
add_shortcode('cooked-recipe', array($this, 'recipe_shortcode'));
}
}
示例7: __construct
public function __construct($settings)
{
$this->settings = $settings;
$this->shortcode = $this->settings['base'];
$this->addAction('admin_init', 'enqueueAssets');
if ($this->isAdmin() || !shortcode_exists($this->shortcode)) {
$this->addShortCode($this->shortcode, array($this, 'output'));
}
}
示例8: __construct
public function __construct($settings)
{
$settings = wp_parse_args($settings, array('id' => '', 'title' => __('Element Title', 'detheme_builder'), 'icon' => 'dashicons-admin-page', 'options' => array()));
$this->settings = $settings;
$this->shortcode = $this->settings['id'];
if (!shortcode_exists($this->shortcode)) {
add_shortcode($this->shortcode, array($this, 'output'));
}
}
示例9: next_saturday_audio_script
/**
* Audio helper script.
*
* If an audio shortcode exists we will enqueue javascript
* that replaces all non-supported audio player instances
* with text links.
*
* @uses shortcode_exists();
*/
function next_saturday_audio_script()
{
if (shortcode_exists('audio')) {
return;
}
if (!is_singular() || has_post_format('audio')) {
wp_enqueue_script('next-saturday-audio', get_template_directory_uri() . '/js/audio.js', array(), '20130521');
}
}
示例10: register_shortcodes
protected function register_shortcodes()
{
$this->shortcodes = array('wpqt-icon' => array('function' => 'the_custom_icon', 'description' => __('Rendering the custom icons', $this->domain_name), 'since' => '1.0.0'), 'wpqt-permalink' => array('function' => 'get_qiita_link', 'description' => __('Rendering the Qiita side permalink of specified post', $this->domain_name), 'since' => '1.0.0'), 'wpqt-post-stocks' => array('function' => 'get_post_stocks', 'description' => __('Rendering the number of stock of the specified post', $this->domain_name), 'since' => '1.0.0'));
foreach ($this->shortcodes as $shortcode_name => $shortcode_atts) {
if (false === shortcode_exists($shortcode_name)) {
add_shortcode($shortcode_name, array($this, $shortcode_atts['function']));
}
}
}
示例11: maybe_register_cpt
/**
* Registers the custom post types and adds action/filter handlers, but
* only if the site supports it
*/
function maybe_register_cpt()
{
// Add an option to enable the CPT
add_action('admin_init', array($this, 'settings_api_init'));
// Check on theme switch if theme supports CPT and setting is disabled
add_action('after_switch_theme', array($this, 'activation_post_type_support'));
$setting = get_option(self::OPTION_NAME, '0');
// Bail early if Testimonial option is not set and the theme doesn't declare support
if (empty($setting) && !$this->site_supports_custom_post_type()) {
return;
}
// Enable Omnisearch for CPT.
if (class_exists('Jetpack_Omnisearch_Posts')) {
new Jetpack_Omnisearch_Posts(self::CUSTOM_POST_TYPE);
}
// CPT magic
$this->register_post_types();
add_action(sprintf('add_option_%s', self::OPTION_NAME), array($this, 'flush_rules_on_enable'), 10);
add_action(sprintf('update_option_%s', self::OPTION_NAME), array($this, 'flush_rules_on_enable'), 10);
add_action(sprintf('publish_%s', self::CUSTOM_POST_TYPE), array($this, 'flush_rules_on_first_testimonial'));
add_action('after_switch_theme', array($this, 'flush_rules_on_switch'));
// Admin Customization
add_filter('enter_title_here', array($this, 'change_default_title'));
add_filter(sprintf('manage_%s_posts_columns', self::CUSTOM_POST_TYPE), array($this, 'edit_title_column_label'));
add_filter('post_updated_messages', array($this, 'updated_messages'));
add_action('customize_register', array($this, 'customize_register'));
// Only add the 'Customize' sub-menu if the theme supports it.
$num_testimonials = self::count_testimonials();
if (!empty($num_testimonials) && current_theme_supports(self::CUSTOM_POST_TYPE)) {
add_action('admin_menu', array($this, 'add_customize_page'));
}
if (defined('IS_WPCOM') && IS_WPCOM) {
// Track all the things
add_action(sprintf('add_option_%s', self::OPTION_NAME), array($this, 'new_activation_stat_bump'));
add_action(sprintf('update_option_%s', self::OPTION_NAME), array($this, 'update_option_stat_bump'), 11, 2);
add_action(sprintf('publish_%s', self::CUSTOM_POST_TYPE), array($this, 'new_testimonial_stat_bump'));
// Add to Dotcom XML sitemaps
add_filter('wpcom_sitemap_post_types', array($this, 'add_to_sitemap'));
} else {
// Add to Jetpack XML sitemap
add_filter('jetpack_sitemap_post_types', array($this, 'add_to_sitemap'));
}
// Adjust CPT archive and custom taxonomies to obey CPT reading setting
add_filter('pre_get_posts', array($this, 'query_reading_setting'), 20);
add_filter('infinite_scroll_settings', array($this, 'infinite_scroll_click_posts_per_page'));
// Register [jetpack_testimonials] always and
// register [testimonials] if [testimonials] isn't already set
add_shortcode('jetpack_testimonials', array($this, 'jetpack_testimonial_shortcode'));
if (!shortcode_exists('testimonials')) {
add_shortcode('testimonials', array($this, 'jetpack_testimonial_shortcode'));
}
// If CPT was enabled programatically and no CPT items exist when user switches away, disable
if ($setting && $this->site_supports_custom_post_type()) {
add_action('switch_theme', array($this, 'deactivation_post_type_support'));
}
}
示例12: __construct
function __construct()
{
parent::__construct(array('name' => __('Slider', 'themify'), 'slug' => 'slider'));
///////////////////////////////////////
// Load Post Type
///////////////////////////////////////
$this->meta_box = $this->set_metabox();
$this->initialize_cpt(array('plural' => __('Slides', 'themify'), 'singular' => __('Slide', 'themify'), 'supports' => array('title', 'editor', 'author', 'custom-fields'), 'menu_icon' => 'dashicons-slides'));
if (!shortcode_exists('themify_' . $this->slug . '_posts')) {
add_shortcode('themify_' . $this->slug . '_posts', array($this, 'do_shortcode'));
}
}
示例13: init
function init()
{
if (shortcode_exists('featured_products')) {
remove_shortcode('featured_products');
}
if (shortcode_exists('recent_products')) {
remove_shortcode('recent_products');
}
add_shortcode('featured_products', 'bs_featured_products');
add_shortcode('recent_products', 'bs_recent_products');
add_action('wp_enqueue_scripts', array(&$this, 'woocommerce_twitterbootstrap_setstylesheets'), 99);
add_action('shop_loop', array($this, 'bs_shop_loop'), 99);
add_action('woocommerce_before_single_product_summary', array(&$this, 'woocommerce_before_single_product_summary_bs'), 1);
add_action('woocommerce_before_single_product_summary', array(&$this, 'woocommerce_before_single_product_summary_bs_end'), 100);
add_action('woocommerce_after_single_product_summary', array(&$this, 'woocommerce_after_single_product_summary_bs'), 1);
/* thumbnails */
add_action('bs_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10);
add_action('bs_before_shop_loop_item_title', array(&$this, 'bs_get_product_thumbnail'), 10, 3);
add_action('woocommerce_after_shop_loop', array(&$this, 'endsetupgrid'), 1);
add_action('woocommerce_before_shop_loop', array(&$this, 'setupgrid'), 999);
/* the grid display */
/*
| columns | mobile | tablet | desktop |per page |
----------------------------------------------------|-----------|
| 1 | 1 | 1 | 1 | 10 |
|---------------------------------------------------|-----------|
| 2 | 1 | 2 | 2 | 10 |
|---------------------------------------------------|-----------|
| 3 | 1 | 1 | 3 | 9 |
|---------------------------------------------------|-----------|
| 3(1) | 1 | 2 | 3 | 12 |
|---------------------------------------------------|-----------|
| 4 | 1 | 2 | 4 | 12 |
|---------------------------------------------------|-----------|
| 5 | n/a | n/a | n/a | n/a |
|---------------------------------------------------|-----------|
| 6 | 2 | 4 | 6 | 12 |
|---------------------------------------------------|-----------|
| >=6 | n/a | n/a | n/a | n/a |
|---------------------------------------------------------------|
*/
// Store column count for displaying the grid
global $woocommerce_loop;
if (empty($woocommerce_loop['columns'])) {
$woocommerce_loop['columns'] = get_option('number_of_columns', 4);
}
if ($woocommerce_loop['columns'] == 3) {
add_filter('loop_shop_per_page', create_function('$cols', 'return 9;'), 10);
} elseif ($woocommerce_loop['columns'] > 2) {
add_filter('loop_shop_per_page', create_function('$cols', 'return 12;'), 10);
}
define('WooCommerce_Twitter_Bootstrap_grid_classes', $this->get_grid_classes($woocommerce_loop));
}
示例14: __construct
function __construct()
{
parent::__construct(array('name' => __('Testimonial', 'themify'), 'slug' => 'testimonial'));
///////////////////////////////////////
// Load Post Type
///////////////////////////////////////
$this->meta_box = $this->set_metabox();
$this->initialize_cpt(array('plural' => __('Testimonials', 'themify'), 'singular' => __('Testimonial', 'themify'), 'menu_icon' => 'dashicons-testimonial'));
if (!shortcode_exists('themify_' . $this->slug . '_posts')) {
add_shortcode('themify_' . $this->slug . '_posts', array($this, 'do_shortcode'));
}
}
示例15: __construct
function __construct()
{
parent::__construct(array('name' => __('Highlight', 'themify'), 'slug' => 'highlight'));
///////////////////////////////////////
// Load Post Type
///////////////////////////////////////
$this->meta_box = $this->set_metabox();
$this->initialize_cpt(array('plural' => __('Highlights', 'themify'), 'singular' => __('Highlight', 'themify'), 'menu_icon' => 'dashicons-welcome-write-blog'));
if (!shortcode_exists('themify_highlight_posts')) {
add_shortcode('themify_highlight_posts', array($this, 'do_shortcode'));
}
}