Пример #1
0
function ccb_chapter_shortcode_register()
{
    add_shortcode('ccb_chapter', function ($attr) {
        $attr = wp_parse_args($attr, array('title' => '', 'background_image' => ''));
        ob_start();
        $title = $attr['title'];
        $bg_id = $attr['background_image'];
        $bg = '';
        $class = 'ccb ccb-chapter';
        if ($bg_id) {
            $bg = wp_get_attachment_image_src($bg_id, 'large');
            $class .= ' ccb-chapter-has-image';
        }
        ?>
		<?php 
        do_action('ccb_chapter_outside_before');
        ?>
		<section class="<?php 
        echo $class;
        ?>
" data-chapter-title="<?php 
        echo esc_attr($title);
        ?>
">
			<?php 
        do_action('ccb_chapter_inside_before');
        ?>
            <?php 
        if ($bg_id) {
            echo '<div class="ccb-chapter-image" style="background-image: url(' . $bg[0] . ');"><h1 class="chapter-title">' . $title . '</h1></div>';
        } else {
            echo '<h1 class="chapter-title">' . $title . '</h1>';
        }
        ?>
			<?php 
        do_action('ccb_chapter_inside_after');
        ?>
            <?php 
        if (is_admin()) {
            echo '<style>.ccb-chapter-has-image .chapter-title{height: 400px!important;}</style>';
        }
        ?>
		</section>
		<?php 
        do_action('ccb_chapter_outside_after');
        ?>

		<?php 
        return ob_get_clean();
    });
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        add_action('admin_notices', function () {
            if (current_user_can('activate_plugins')) {
                echo '<div class="error message"><p>You need Shortcake (Shortcode UI) in order to use CAP Content Blocks.</p></div>';
            }
        });
        return;
    }
    shortcode_ui_register_for_shortcode('ccb_chapter', array('label' => 'Chapter', 'listItemImage' => 'dashicons-editor-ol', 'post_type' => array('reports'), 'attrs' => array(array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'meta' => array('placeholder' => 'Chapter #', 'data-test' => 1)), array('label' => 'Chapter Background', 'attr' => 'background_image', 'type' => 'attachment', 'libraryType' => array('image'), 'addButton' => 'Select Image', 'frameTitle' => 'Select Image'))));
}
Пример #2
0
function sandwich_myshortcode()
{
    // TODO: Does your Shortcake require additional functions for rendering?
    // Most existing plugins using shortcodes can be rendered by shortcake itself.
    // However, plugins created from scratch will require the following add_shortcode module below.
    // Delete this TODO message along with the following function below if it is not needed, and
    // DO NOT FORGET TO DELETE THE SHORTCODE INITIALIZATION BELOW THIS!
    // Register shortcode for <FRIENDLY_PLUGIN_NAME>
    add_shortcode('pbs_myshortcode', 'sandwich_myshortcode_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    // Ensure plugin runs only in admin mode. Do not continue if that's not the case.
    if (!is_admin()) {
        return;
    }
    // TODO: If creating a Shortcake for a particular plugin, find its class and use it as basis of activation.
    // This module must terminate the moment it determines that the dependency is not established.
    // Calling undefined classes and functions will result in errors, so this must be handled.
    // Delete this TODO module when done and the dependency check has been written and tested working.
    // Insert the dependency check below this line.
    // Register Shortcake UI for <FRIENDLY_PLUGIN_NAME>
    shortcode_ui_register_for_shortcode('pbs_myshortcode', array('label' => __('<FRIENDLY_PLUGIN_NAME>', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Some Text', 'pbsandwich'), 'attr' => 'some_text', 'type' => 'text'), array('label' => __('Some Color', 'pbsandwich'), 'attr' => 'some_color', 'type' => 'color', 'value' => '#333333')), 'inner_content' => array('label' => __('Content', 'pbsandwich'), 'value' => '', 'type' => 'textarea')));
    // TODO: If the rendered shortcode in the editor NEEDS to be previewed in a logged out state (e.g. login forms)
    // uncomment this and add in your shortcode here.
    // sandwich_add_logged_out_shortcode( 'pbs_myshortcode' );
}
Пример #3
0
 /**
  * Register a Shortcake ui if we can
  */
 public function admin_init()
 {
     if (!function_exists('shortcode_ui_register_for_shortcode')) {
         return;
     }
     shortcode_ui_register_for_shortcode('chart', array('label' => esc_html__('Charts', 'm-chart'), 'listItemImage' => 'dashicons-chart-pie', 'attrs' => array(array('label' => esc_html__('Chart', 'm-chart'), 'attr' => 'id', 'type' => 'post_select', 'query' => array('post_type' => m_chart()->slug, 'post_status' => 'publish')))));
 }
function sandwich_myshortcode()
{
    // No need to register our shortcode since it already exists
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    // Only create the UI when in the admin
    if (!is_admin()) {
        return;
    }
    // Register Shortcake UI
    shortcode_ui_register_for_shortcode('myshortcode', array('label' => __('Some Existing Shortcode', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Content', 'pbsandwich'), 'attr' => 'content', 'type' => 'textarea'), array('label' => __('Some Text', 'pbsandwich'), 'attr' => 'some_text', 'type' => 'text'), array('label' => __('Some Color', 'pbsandwich'), 'attr' => 'some_color', 'type' => 'color', 'value' => '#333333'))));
    // TODO: If the rendered shortcode in the editor NEEDS to be previewed in a logged out state (e.g. login forms)
    // uncomment this and add in your shortcode here.
    // sandwich_add_logged_out_shortcode( 'myshortcode' );
    // Make sure Jetpack is activated
    if (!class_exists('Jetpack')) {
        add_action('print_media_templates', 'sandwich_jetpack_myshortcode_disabled');
        return;
    }
    // Make sure our required Jetpack module is turned on
    if (!Jetpack::is_module_active('some-jetpack-module')) {
        add_action('print_media_templates', 'sandwich_jetpack_myshortcode_disabled');
        return;
    }
}
Пример #5
0
 /**
  * Register the shortcode UI handler function with WordPress.
  *
  * @since 0.1.0
  *
  * @param mixed $context Data about the context in which the call is made.
  * @return void
  */
 public function register($context = null)
 {
     if (!$this->is_needed()) {
         return;
     }
     \shortcode_ui_register_for_shortcode($this->shortcode_tag, $this->config);
 }
function sandwich_events_manager()
{
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    // Ensure plugin runs only in admin mode. Do not continue if that's not the case.
    if (!is_admin()) {
        return;
    }
    // Dependency check for Events Manager. Do not proceed if not found.
    if (!defined('EM_VERSION')) {
        return;
    }
    // Register Shortcake UI for Events Manager Events List
    shortcode_ui_register_for_shortcode('events_list', array('label' => __('Events Manager Events List', 'pbsandwich'), 'listItemImage' => 'dashicons-calendar', 'attrs' => array(array('label' => __('Event listing limit', 'pbsandwich'), 'attr' => 'limit', 'type' => 'text', 'value' => '10', 'description' => __('Show up to the specified amount of events.', 'pbsandwich'))), 'inner_content' => array('label' => __('Event List caption', 'pbsandwich'), 'value' => '', 'type' => 'textarea', 'description' => __('The Event List can be customized to include customized description. The following variables will be replaced with the actual relevant details:<br />#_EVENTNAME<br />#_EVENTLINK<br />#_LOCATIONLINK<br />#_EVENTDATES<br />#_EVENTTIMES', 'pbsandwich'))));
    // Register Shortcake UI for Events Manager Grouped Events List
    shortcode_ui_register_for_shortcode('events_list_grouped', array('label' => __('Events Manager Grouped Events List', 'pbsandwich'), 'listItemImage' => 'dashicons-calendar', 'attrs' => array(array('label' => __('Event listing mode', 'pbsandwich'), 'attr' => 'mode', 'type' => 'select', 'options' => sandwich_events_manager_mode_selection(), 'description' => __('Show events by these selections.', 'pbsandwich'))), 'inner_content' => array('label' => __('Grouped Event List caption', 'pbsandwich'), 'value' => '', 'type' => 'textarea', 'description' => __('The Grouped Events List can be customized to include customized description. The following variables will be replaced with the actual relevant details:<br />#_EVENTDATES<br />#_EVENTLINK<br />#_EVENTTIMES', 'pbsandwich'))));
    // Register Shortcake UI for Events Manager Event Display
    shortcode_ui_register_for_shortcode('event', array('label' => __('Events Manager Event Display', 'pbsandwich'), 'listItemImage' => 'dashicons-calendar', 'attrs' => array(array('label' => __('Show Event', 'pbsandwich'), 'attr' => 'post_id', 'type' => 'select', 'options' => sandwich_functions_posttype_list('event'))), 'inner_content' => array('label' => __('Event caption', 'pbsandwich'), 'value' => '#_EVENTNAME', 'type' => 'textarea', 'description' => __('The Event display can be customized to include elements like description. The #_EVENTNAME  variable will be replaced with the actual content.', 'pbsandwich'))));
    // Register Shortcake UI for Events Manager Event Form
    shortcode_ui_register_for_shortcode('event_form', array('label' => __('Events Manager Event Submission Form', 'pbsandwich'), 'listItemImage' => 'dashicons-calendar', 'attrs' => array()));
    // Register Shortcake UI for Events Manager Event Search Form
    shortcode_ui_register_for_shortcode('event_search_form', array('label' => __('Events Manager Event Search Form', 'pbsandwich'), 'listItemImage' => 'dashicons-calendar', 'attrs' => array()));
    // Register Shortcake UI for Events Manager Events Calendar
    shortcode_ui_register_for_shortcode('events_calendar', array('label' => __('Events Manager Events Calendar', 'pbsandwich'), 'listItemImage' => 'dashicons-calendar', 'attrs' => array(array('label' => __('Show Full-sized Calendar', 'pbsandwich'), 'attr' => 'full', 'type' => 'checkbox', 'value' => '0'), array('label' => __('Show long events', 'pbsandwich'), 'attr' => 'long_events', 'type' => 'checkbox', 'value' => '0'), array('label' => __('Category List', 'pbsandwich'), 'attr' => 'category', 'type' => 'select', 'options' => sandwich_functions_term_list('event-categories'), 'description' => __('Show events in the specified category.', 'pbsandwich')))));
}
Пример #7
0
function pp_passreset_shortcode_shortcake()
{
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    shortcode_ui_register_for_shortcode('user-login', array('label' => 'Password Reset Form: Username / Email field', 'listItemImage' => 'dashicons-admin-users', 'attrs' => array(array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the field.'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the field.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the input field.'), array('label' => 'Placeholder', 'attr' => 'placeholder', 'type' => 'text', 'description' => 'Placeholder attribute for the input field.'), array('label' => 'Value', 'attr' => 'value', 'type' => 'text', 'description' => 'Value attribute (default field text).'))));
    shortcode_ui_register_for_shortcode('reset-submit', array('label' => 'Password Reset Form: Submit Button', 'listItemImage' => 'dashicons-cart', 'attrs' => array(array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the field.'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the field.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the input field.'), array('label' => 'Value', 'attr' => 'value', 'type' => 'text', 'description' => 'Submit button text.'))));
}
Пример #8
0
 /**
  * Configure support for the blockquote shortcode with Shortcode UI.
  */
 public function setup_shortcode_ui()
 {
     if (!function_exists('shortcode_ui_register_for_shortcode')) {
         return;
     }
     $args = array('label' => 'Blockquote', 'listItemImage' => 'dashicons-editor-quote', 'post_type' => array('post', 'page'), 'inner_content' => array('label' => 'Blockquote text'), 'attrs' => array(array('label' => 'Source', 'attr' => 'cite', 'type' => 'text'), array('label' => 'Image (Optional)', 'attr' => 'image', 'type' => 'attachment', 'libraryType' => array('image'), 'addButton' => 'Select Image', 'frameTitle' => 'Select Image'), array('label' => 'Image placement', 'attr' => 'image_placement', 'type' => 'select', 'description' => 'Choose where the image, if one is provided, should be displayed.', 'options' => array('' => 'Text in column one, image in column two', 'reverse' => 'Image in column one, text in column two', 'together' => 'Image and text in a single column')), array('label' => 'Wrapper class', 'attr' => 'wrapper', 'type' => 'text', 'description' => 'If provided, a class will be added to the wrapping container. Classes blockquote-container and blockquote-has-image are aready placed automatically.')));
     shortcode_ui_register_for_shortcode('ip_blockquote', $args);
 }
 public function register_shortcode()
 {
     add_shortcode(self::$shortcode_tag, array($this, 'callback'));
     // If Shortcake is installed and activated, add support for a post element
     if (function_exists('shortcode_ui_register_for_shortcode')) {
         shortcode_ui_register_for_shortcode(self::$shortcode_tag, self::get_shortcode_ui_args());
     }
 }
Пример #10
0
 /**
  * Describe shortcode for Shortcake UI
  *
  * @since 1.1.0
  *
  * @link https://github.com/fusioneng/Shortcake Shortcake UI
  *
  * @return void
  */
 public static function shortcodeUI()
 {
     // Shortcake required
     if (!function_exists('shortcode_ui_register_for_shortcode')) {
         return;
     }
     shortcode_ui_register_for_shortcode(static::SHORTCODE_TAG, array('label' => esc_html(__('Follow Button', 'twitter')), 'listItemImage' => 'dashicons-twitter', 'attrs' => array(array('attr' => 'screen_name', 'label' => esc_html(__('Twitter @username', 'twitter')), 'type' => 'text', 'meta' => array('placeholder' => 'WordPress', 'pattern' => '[A-Za-z0-9_]{1,20}')), array('attr' => 'size', 'label' => esc_html(__('Button size:', 'twitter')), 'type' => 'radio', 'value' => '', 'options' => array('' => esc_html(_x('medium', 'medium size button', 'twitter')), 'large' => esc_html(_x('large', 'large size button', 'twitter')))))));
 }
Пример #11
0
 /**
  * Describe shortcode for Shortcake UI
  *
  * @since 1.1.0
  *
  * @link https://github.com/fusioneng/Shortcake Shortcake UI
  *
  * @return void
  */
 public static function shortcodeUI()
 {
     // Shortcake required
     if (!function_exists('shortcode_ui_register_for_shortcode')) {
         return;
     }
     shortcode_ui_register_for_shortcode(static::SHORTCODE_TAG, array('label' => esc_html(__('Tweet Button', 'twitter')), 'listItemImage' => 'dashicons-twitter', 'attrs' => array(array('attr' => 'text', 'label' => esc_html(_x('Text', 'Share / Tweet text', 'twitter')), 'type' => 'text'), array('attr' => 'url', 'label' => 'URL', 'type' => 'url'), array('attr' => 'size', 'label' => esc_html(__('Button size:', 'twitter')), 'type' => 'radio', 'value' => '', 'options' => array('' => esc_html(_x('medium', 'medium size button', 'twitter')), 'large' => esc_html(_x('large', 'large size button', 'twitter')))))));
 }
 /**
  * Register the [img] shortcode and the UI for it..
  *
  */
 private function register_shortcode()
 {
     add_shortcode('img', 'Img_Shortcode::callback');
     if (function_exists('shortcode_ui_register_for_shortcode')) {
         shortcode_ui_register_for_shortcode('img', Img_Shortcode::get_shortcode_ui_args());
     } else {
         add_action('admin_notices', array($this, 'action_admin_notices_warning'));
     }
 }
Пример #13
0
/**
 * An example shortcode with many editable attributes (and more complex UI)
 */
function shortcode_ui_dev_advanced_example()
{
    /**
     * Register UI for your shortcode
     *
     * @param string $shortcode_tag
     * @param array $ui_args
     */
    shortcode_ui_register_for_shortcode('shortcake_dev', array('label' => esc_html__('Shortcake Dev', 'shortcode-ui'), 'listItemImage' => 'dashicons-editor-quote', 'post_type' => array('post'), 'inner_content' => array('label' => esc_html__('Quote', 'shortcode-ui'), 'description' => esc_html__('Include a statement from someone famous.', 'shortcode-ui')), 'attrs' => array(array('label' => esc_html__('Attachment', 'shortcode-ui'), 'attr' => 'attachment', 'type' => 'attachment', 'libraryType' => array('image'), 'addButton' => esc_html__('Select Image', 'shortcode-ui'), 'frameTitle' => esc_html__('Select Image', 'shortcode-ui ')), array('label' => esc_html__('Citation Source', 'shortcode-ui'), 'attr' => 'source', 'type' => 'text', 'encode' => true, 'meta' => array('placeholder' => esc_html__('Test placeholder', 'shortcode-ui'), 'data-test' => 1)), array('label' => esc_html__('Select Page', 'shortcode-ui'), 'attr' => 'page', 'type' => 'post_select', 'query' => array('post_type' => 'page'), 'multiple' => true))));
}
Пример #14
0
 /**
  * Describe shortcode for Shortcake UI
  *
  * @since 1.1.0
  *
  * @link https://github.com/fusioneng/Shortcake Shortcake UI
  *
  * @return void
  */
 public static function shortcodeUI()
 {
     // Shortcake required
     if (!function_exists('shortcode_ui_register_for_shortcode')) {
         return;
     }
     // id only
     // avoids an unchecked Shortcake input checkbox requiring a shortcode output
     shortcode_ui_register_for_shortcode(self::SHORTCODE_TAG, array('label' => __('Embedded Tweet Video', 'twitter'), 'listItemImage' => 'dashicons-twitter', 'attrs' => array(array('attr' => 'id', 'label' => 'ID', 'type' => 'text', 'meta' => array('required' => true, 'pattern' => '[0-9]+', 'placeholder' => '560070183650213889')))));
 }
Пример #15
0
function pp_login_shortcode_shortcake()
{
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    shortcode_ui_register_for_shortcode('login-username', array('label' => 'Login form: Username field', 'listItemImage' => 'dashicons-admin-users', 'attrs' => array(array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the field.'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the field.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the input field.'), array('label' => 'Placeholder', 'attr' => 'placeholder', 'type' => 'text', 'description' => 'Placeholder attribute for the input field.'), array('label' => 'Value', 'attr' => 'value', 'type' => 'text', 'description' => 'Value attribute (default field text).'))));
    shortcode_ui_register_for_shortcode('login-password', array('label' => 'Login form: Password field', 'listItemImage' => 'dashicons-no-alt', 'attrs' => array(array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the field.'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the field.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the input field.'), array('label' => 'Placeholder', 'attr' => 'placeholder', 'type' => 'text', 'description' => 'Placeholder attribute for the input field.'), array('label' => 'Value', 'attr' => 'value', 'type' => 'text', 'description' => 'Value attribute (default field text).'))));
    shortcode_ui_register_for_shortcode('login-remember', array('label' => 'Login form: Remember Login Checkbox', 'listItemImage' => 'dashicons-editor-removeformatting', 'attrs' => array(array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the field.'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the field.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the input field.'))));
    shortcode_ui_register_for_shortcode('login-submit', array('label' => 'Login form: Submit Button', 'listItemImage' => 'dashicons-cart', 'attrs' => array(array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the field.'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the field.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the input field.'), array('label' => 'Value', 'attr' => 'value', 'type' => 'text', 'description' => 'Submit button text.'))));
}
Пример #16
0
function sandwich_pages_widget()
{
    add_shortcode('pbs_pages_widget', 'sandwich_pages_widget_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_pages_widget', array('label' => __('Widget - Pages', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Title', 'pbsandwich'), 'attr' => 'title', 'type' => 'text', 'value' => __('Pages', 'pbsandwich'), 'description' => __('The title to display for this widget', 'pbsandwich')), array('label' => __('Sort by', 'pbsandwich'), 'attr' => 'sortby', 'type' => 'select', 'value' => 'post_title', 'options' => array('post_title' => __('Page title', 'default'), 'menu_order' => __('Page order', 'default'), 'ID' => __('Page ID', 'default'))), array('label' => __('Exclude pages', 'pbsandwich'), 'attr' => 'exclude', 'type' => 'text', 'value' => '', 'description' => __('Page IDs, separated by commas', 'default')), array('label' => __('Hide widget title', 'pbsandwich'), 'attr' => 'hide_title', 'type' => 'checkbox', 'value' => false))));
}
Пример #17
0
function sandwich_rss_widget()
{
    add_shortcode('pbs_rss_widget', 'sandwich_rss_widget_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_rss_widget', array('label' => __('Widget - RSS', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Title', 'pbsandwich'), 'attr' => 'title', 'type' => 'text', 'value' => __('RSS', 'pbsandwich'), 'description' => __('The title to display for this widget', 'pbsandwich')), array('label' => __('RSS feed URL', 'pbsandwich'), 'attr' => 'url', 'type' => 'text', 'value' => ''), array('label' => __('How many items would you like to display?', 'default'), 'attr' => 'items', 'type' => 'select', 'value' => '10', 'options' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20')), array('label' => __('Display item content?', 'default'), 'attr' => 'show_summary', 'type' => 'checkbox', 'value' => false), array('label' => __('Display item author if available?', 'default'), 'attr' => 'show_author', 'type' => 'checkbox', 'value' => false), array('label' => __('Display item date?', 'default'), 'attr' => 'show_date', 'type' => 'checkbox', 'value' => false), array('label' => __('Hide widget title', 'pbsandwich'), 'attr' => 'hide_title', 'type' => 'checkbox', 'value' => false))));
}
function sandwich_archives_widget()
{
    add_shortcode('pbs_archives_widget', 'sandwich_archives_widget_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_archives_widget', array('label' => __('Widget - Archives', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Title', 'pbsandwich'), 'attr' => 'title', 'type' => 'text', 'value' => __('Archives', 'pbsandwich'), 'description' => __('The title to display for this widget', 'pbsandwich')), array('label' => __('Display as dropdown ', 'default'), 'attr' => 'dropdown', 'type' => 'checkbox', 'value' => false), array('label' => __('Show post counts', 'default'), 'attr' => 'count', 'type' => 'checkbox', 'value' => false), array('label' => __('Hide widget title', 'pbsandwich'), 'attr' => 'hide_title', 'type' => 'checkbox', 'value' => false))));
}
Пример #19
0
function sandwich_toggle()
{
    add_shortcode('pbs_toggle', 'sandwich_toggle_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_toggle', array('label' => __('Toggle', 'pbsandwich'), 'listItemImage' => 'dashicons-plus', 'attrs' => array(array('label' => __('Title', 'pbsandwich'), 'attr' => 'title', 'type' => 'text')), 'inner_content' => array('value' => 'CHANGE ME NOW', 'type' => 'textarea', 'description' => __('Toggled Content', 'pbsandwich'))));
}
Пример #20
0
function sandwich_progressbar()
{
    add_shortcode('pbs_progressbar', 'sandwich_progressbar_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_progressbar', array('label' => __('Progress Bar', 'pbsandwich'), 'listItemImage' => 'dashicons-plus', 'attrs' => array(array('label' => __('Progress Bar Design', 'pbsandwich'), 'attr' => 'type', 'type' => 'select', 'options' => sandwich_progressbar_style_selection(), 'description' => __('Choose the type of Progress Bar to use.', 'pbsandwich')), array('label' => __('Progress Bar Color', 'pbsandwich'), 'attr' => 'color', 'type' => 'color', 'value' => ''), array('label' => __('Striped Progress Bar', 'pbsandwich'), 'attr' => 'stripe', 'type' => 'checkbox', 'value' => 'false'), array('label' => __('Animated Stripes', 'pbsandwich'), 'attr' => 'animated', 'type' => 'checkbox', 'value' => 'false'), array('label' => __('Percentage', 'pbsandwich'), 'attr' => 'percentage', 'type' => 'text', 'value' => '50', 'description' => __('Enter the percentage filled in the progress bar. Value should be from 0 to 100.', 'pbsandwich')), array('label' => __('Label', 'pbsandwich'), 'attr' => 'label', 'type' => 'text', 'value' => '', 'description' => __('Enter text to go along beside the progress bar percentage.', 'pbsandwich')))));
}
function sandwich_recent_comments_widget()
{
    add_shortcode('pbs_recent_comments_widget', 'sandwich_recent_comments_widget_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_recent_comments_widget', array('label' => __('Widget - Recent Comments', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Title', 'pbsandwich'), 'attr' => 'title', 'type' => 'text', 'value' => __('Recent Comments', 'pbsandwich'), 'description' => __('The title to display for this widget', 'pbsandwich')), array('label' => __('Number of comments to show ', 'pbsandwich'), 'attr' => 'number', 'type' => 'text', 'value' => '5'), array('label' => __('Hide widget title', 'pbsandwich'), 'attr' => 'hide_title', 'type' => 'checkbox', 'value' => false))));
}
function sandwich_tag_cloud_widget()
{
    add_shortcode('pbs_tag_cloud_widget', 'sandwich_tag_cloud_widget_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_tag_cloud_widget', array('label' => __('Widget - Tag Cloud', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Title', 'pbsandwich'), 'attr' => 'title', 'type' => 'text', 'value' => __('Tag Cloud', 'pbsandwich'), 'description' => __('The title to display for this widget', 'pbsandwich')), array('label' => __('Taxonomy', 'pbsandwich'), 'attr' => 'taxonomy', 'type' => 'select', 'value' => '', 'options' => sandwich_functions_taxonomy_list('tag')))));
}
Пример #23
0
 public function register_shortcode()
 {
     add_shortcode($this->handle, array($this, 'shortcode'));
     if (function_exists('shortcode_ui_register_for_shortcode')) {
         $shortcode_args = array();
         $shortcode_args['label'] = $this->label;
         $shortcode_args['listItemImage'] = $this->icon;
         $shortcode_args['attrs'] = $this->fields;
         $shortcode_args['inner_content'] = array('label' => 'Content');
         shortcode_ui_register_for_shortcode($this->handle, $shortcode_args);
     }
 }
Пример #24
0
function sandwich_buttons()
{
    add_shortcode('pbs_button', 'sandwich_buttons_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    shortcode_ui_register_for_shortcode('pbs_button', array('label' => __('Button', 'pbsandwich'), 'listItemImage' => 'dashicons-plus', 'attrs' => array(array('label' => __('Button Label', 'pbsandwich'), 'attr' => 'label', 'type' => 'text', 'value' => __('Click Here', 'pbsandwich')), array('label' => __('Button Design', 'pbsandwich'), 'attr' => 'design', 'type' => 'select', 'options' => sandwich_buttons_button_type(), 'description' => __('Choose the design to use. Ghost type renders the background color of the button transparent with a colored border.', 'pbsandwich')), array('label' => __('Button Color Scheme', 'pbsandwich'), 'attr' => 'style', 'type' => 'select', 'options' => sandwich_buttons_style_selection(), 'description' => __('Choose the color scheme of the button.', 'pbsandwich')), array('label' => __('Custom Button Background Color', 'pbsandwich'), 'attr' => 'button_color', 'type' => 'color', 'description' => __('You can override the button color here. Leave this blank to use the default color scheme above.', 'pbsandwich')), array('label' => __('Custom Button Border Color', 'pbsandwich'), 'attr' => 'border_color', 'type' => 'color', 'description' => __('You can override the button border color here. Leave this blank to use the default color scheme above.', 'pbsandwich')), array('label' => __('Text Color', 'pbsandwich'), 'attr' => 'text_color', 'type' => 'color', 'value' => '', 'description' => __('The color of the label of the button. Leave this blank to use the default color', 'pbsandwich')), array('label' => __('Button Hover Color', 'pbsandwich'), 'attr' => 'button_hover_color', 'type' => 'color', 'description' => __('The color of the button when hovered over by the mouse cursor. Leave this blank to use the default color scheme above.', 'pbsandwich')), array('label' => __('Button Border Hover Color', 'pbsandwich'), 'attr' => 'border_hover_color', 'type' => 'color', 'description' => __('The color of the border when hovered over by the mouse cursor. Leave this blank to use the default color scheme above.', 'pbsandwich')), array('label' => __('Text Hover Color', 'pbsandwich'), 'attr' => 'text_hover_color', 'type' => 'color', 'value' => '', 'description' => __('The color of the label of the button when hovered over by the mouse cursor. Leave this blank to use the default color', 'pbsandwich')), array('label' => __('Button Size', 'pbsandwich'), 'attr' => 'size', 'type' => 'select', 'options' => sandwich_buttons_size_selection(), 'description' => __('The size of the button.', 'pbsandwich')), array('label' => __('Border Thickness', 'pbsandwich'), 'attr' => 'border', 'type' => 'text', 'value' => '', 'description' => __('Enter a number in pixels. Borders are only applicable for ghost buttons.', 'pbsandwich')), array('label' => __('Border Radius', 'pbsandwich'), 'attr' => 'radius', 'type' => 'text', 'value' => '', 'description' => __('Enter a number in pixels.', 'pbsandwich')), array('label' => __('Link URL', 'pbsandwich'), 'attr' => 'url', 'type' => 'url', 'value' => '#'), array('label' => __('Open link in a new window?', 'pbsandwich'), 'attr' => 'target', 'type' => 'checkbox', 'value' => 'false'), array('label' => __('Alignment', 'pbsandwich'), 'attr' => 'align', 'type' => 'select', 'options' => sandwich_buttons_align(), 'value' => 'center'), array('label' => __('Full-width Button', 'pbsandwich'), 'attr' => 'full_width', 'type' => 'checkbox', 'value' => 'false'))));
}
function sandwich_get_more_shortcodes()
{
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    // Only create the UI when in the admin
    if (!is_admin()) {
        return;
    }
    // Create our UI
    shortcode_ui_register_for_shortcode('pbs_get_more_shortcodes', array('label' => '_' . __('Get More Shortcodes', 'pbsandwich'), 'listItemImage' => 'dashicons-external', 'attrs' => array()));
}
Пример #26
0
function pp_global_shortcode_shortcake()
{
    if (is_singular()) {
        return;
    }
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    shortcode_ui_register_for_shortcode('link-registration', array('label' => 'Registration Link', 'listItemImage' => 'dashicons-admin-links', 'attrs' => array(array('label' => 'Label', 'attr' => 'label', 'type' => 'text', 'description' => 'The anchor text for the link'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the HTML registration link.'), array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the HTML registration link.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the HTML link'))));
    shortcode_ui_register_for_shortcode('link-lost-password', array('label' => 'Password Reset Link', 'listItemImage' => 'dashicons-admin-links', 'attrs' => array(array('label' => 'Label', 'attr' => 'label', 'type' => 'text', 'description' => 'The anchor text for the link'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the password reset link.'), array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the password reset link.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the link'))));
    shortcode_ui_register_for_shortcode('link-login', array('label' => 'Login Link', 'listItemImage' => 'dashicons-admin-links', 'attrs' => array(array('label' => 'Label', 'attr' => 'label', 'type' => 'text', 'description' => 'The anchor text for the link'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the password reset link.'), array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the password reset link.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the link'))));
    shortcode_ui_register_for_shortcode('link-logout', array('label' => 'Logout Link', 'listItemImage' => 'dashicons-admin-links', 'attrs' => array(array('label' => 'Label', 'attr' => 'label', 'type' => 'text', 'description' => 'The anchor text for the link'), array('label' => 'CSS ID', 'attr' => 'id', 'type' => 'text', 'description' => 'CSS id for the password reset link.'), array('label' => 'CSS class', 'attr' => 'class', 'type' => 'text', 'description' => 'CSS class for the password reset link.'), array('label' => 'Title', 'attr' => 'title', 'type' => 'text', 'description' => 'Title attribute for the link'))));
}
Пример #27
0
function shortcode_ui_dev_advanced_example()
{
    /**
     * Register your shortcode as you would normally.
     * This is a simple example for a pullquote with a citation.
     */
    add_shortcode('shortcake_dev', 'shortcode_ui_dev_shortcode');
    /**
     * Register a UI for the Shortcode.
     * Pass the shortcode tag (string)
     * and an array or args.
     */
    shortcode_ui_register_for_shortcode('shortcake_dev', array('label' => 'Shortcake Dev', 'listItemImage' => 'dashicons-editor-quote', 'inner_content' => array('label' => 'Quote'), 'post_type' => array('post'), 'attrs' => array(array('label' => __('Attachment', 'your-text-domain'), 'attr' => 'attachment', 'type' => 'attachment', 'libraryType' => array('image'), 'addButton' => __('Select Image', 'your-text-domain'), 'frameTitle' => __('Select Image', 'your-text-domain ')), array('label' => __('Citation Source', 'your-text-domain'), 'attr' => 'source', 'type' => 'text', 'meta' => array('placeholder' => 'Test placeholder', 'data-test' => 1)), array('label' => 'Select Page', 'attr' => 'page', 'type' => 'post_select', 'query' => array('post_type' => 'page'), 'multiple' => true))));
}
 /**
  * Register all of the shortcodes
  */
 public function action_init_register_shortcodes()
 {
     $this->registered_shortcode_classes = apply_filters('shortcake_bakery_shortcode_classes', $this->internal_shortcode_classes);
     foreach ($this->registered_shortcode_classes as $class) {
         $shortcode_tag = $class::get_shortcode_tag();
         $this->registered_shortcodes[$shortcode_tag] = $class;
         add_shortcode($shortcode_tag, array($this, 'do_shortcode_callback'));
         $class::setup_actions();
         $ui_args = $class::get_shortcode_ui_args();
         if (!empty($ui_args) && function_exists('shortcode_ui_register_for_shortcode')) {
             shortcode_ui_register_for_shortcode($shortcode_tag, $ui_args);
         }
     }
 }
function sandwich_external_html5video()
{
    // Register shortcode
    add_shortcode('pbs_external_html5video', 'sandwich_external_html5video_shortcode');
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    if (!is_admin()) {
        return;
    }
    // Register Shortcake UI
    shortcode_ui_register_for_shortcode('pbs_external_html5video', array('label' => __('HTML5 Video (Remote)', 'pbsandwich'), 'listItemImage' => 'dashicons-video-alt2', 'attrs' => array(array('label' => __('Video Webm Format', 'pbsandwich'), 'attr' => 'webm', 'type' => 'url', 'description' => __('The URL of the WEBM video to be embedded.', 'pbsandwich')), array('label' => __('Video OGV Format', 'pbsandwich'), 'attr' => 'ogv', 'type' => 'url', 'description' => __('The URL of the OGV video to be embedded.', 'pbsandwich')), array('label' => __('Video MP4 Format', 'pbsandwich'), 'attr' => 'mp4', 'type' => 'url', 'description' => __('The URL of the MP4 video to be embedded.', 'pbsandwich')), array('label' => __('Video Poster', 'pbsandwich'), 'attr' => 'poster', 'type' => 'attachment', 'description' => __("Choose an image that will serve as the video's poster while the video has not been played.", 'pbsandwich')), array('label' => __('Autoplay Video', 'pbsandwich'), 'attr' => 'autoplay', 'type' => 'checkbox', 'description' => __("Check this to let videos play right after they load.", 'pbsandwich'), 'value' => "true"), array('label' => __('Preload Video', 'pbsandwich'), 'attr' => 'preload', 'type' => 'checkbox', 'description' => __("Check this to let videos buffer while the page loads.", 'pbsandwich'), 'value' => "auto"), array('label' => __('Hide video controls', 'pbsandwich'), 'attr' => 'controls', 'type' => 'checkbox', 'description' => __("Check this to disable control of video playback.", 'pbsandwich'), 'value' => 'disabled'))));
}
Пример #30
0
 public function test_filter_shortcode_atts_decode_encoded()
 {
     $shortcode = 'shortcake_encoding_test';
     // Add test Shortcode.
     add_shortcode($shortcode, '__return_null');
     // Register test Shortcode UI.
     shortcode_ui_register_for_shortcode($shortcode, array('attrs' => array(array('attr' => 'test', 'type' => 'text', 'encode' => true))));
     $encoded = '%3Cb%20class%3D%22foo%22%3Ebar%3C%2Fb%3E';
     $decoded = '<b class="foo">bar</b>';
     // Parse shortcode attributes.
     $attr = shortcode_atts(array('test' => null), array('test' => $encoded), $shortcode);
     // Expect value of $attr['test'] to be decoded.
     $this->assertEquals($attr['test'], $decoded);
 }