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'))))); }
/** * Create our shortcode for BBPress */ public function sandwich_bbp_shortcodes() { // Check if Shortcake exists if (!function_exists('shortcode_ui_register_for_shortcode')) { return; } // Check if bbPress is active. Terminate if not. if (!class_exists('bbPress')) { return; } // Force bbPress to enqueue styles so we can add them in the editor if (class_exists('BBP_Default')) { $o = new BBP_Default(); $o->enqueue_styles(); } // Register Shortcake UI for BBPress Forum Index shortcode_ui_register_for_shortcode('bbp-forum-index', array('label' => __('BBPress Forum Index', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Forum Form shortcode_ui_register_for_shortcode('bbp-forum-form', array('label' => __('BBPress Forum Form', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Single Forum Display shortcode_ui_register_for_shortcode('bbp-single-forum', array('label' => __('BBPress Single Forum Display', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo', 'attrs' => array(array('label' => __('Select Forum to display', 'pbsandwich'), 'attr' => 'id', 'type' => 'select', 'options' => sandwich_functions_posttype_list('forum'))))); // Register Shortcake UI for BBPress Topic Index shortcode_ui_register_for_shortcode('bbp-topic-index', array('label' => __('BBPress Topic Index', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Topic Form shortcode_ui_register_for_shortcode('bbp-topic-form', array('label' => __('BBPress Topic Form', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo', 'attrs' => array(array('label' => __('Select Forum to display the New Topic form in', 'pbsandwich'), 'attr' => 'forum_id', 'type' => 'select', 'options' => sandwich_functions_posttype_list('forum'))))); // Register Shortcake UI for BBPress Single Topic shortcode_ui_register_for_shortcode('bbp-single-topic', array('label' => __('BBPress Single Topic display', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo', 'attrs' => array(array('label' => __('Select the Topic to display', 'pbsandwich'), 'attr' => 'id', 'type' => 'select', 'options' => sandwich_functions_posttype_list('topic'))))); // Register Shortcake UI for BBPress Reply Form shortcode_ui_register_for_shortcode('bbp-reply-form', array('label' => __('BBPress Reply Form', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Single Reply shortcode_ui_register_for_shortcode('bbp-single-reply', array('label' => __('BBPress Single Reply display', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo', 'attrs' => array(array('label' => __('Select the Reply to display', 'pbsandwich'), 'attr' => 'id', 'type' => 'select', 'options' => sandwich_functions_posttype_list('reply'))))); // Register Shortcake UI for BBPress Topic Tags shortcode_ui_register_for_shortcode('bbp-topic-tags', array('label' => __('BBPress Topic Tags', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Single Tag shortcode_ui_register_for_shortcode('bbp-single-tag', array('label' => __('BBPress Single Tag display', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo', 'attrs' => array(array('label' => __('Select the Tag to display topics associated with it', 'pbsandwich'), 'attr' => 'id', 'type' => 'select', 'options' => sandwich_functions_term_list('topic-tag'))))); // Register Shortcake UI for BBPress Single View shortcode_ui_register_for_shortcode('bbp-single-view', array('label' => __('BBPress Single View', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo', 'attrs' => array(array('label' => __('Select the viewing type to display topics according to a certain attribute.', 'pbsandwich'), 'attr' => 'id', 'type' => 'select', 'options' => array('popular' => __('Popular', 'pbsandwich'), 'no-replies' => __('No Replies', 'pbsandwich')))))); // Register Shortcake UI for BBPress Search Input Form shortcode_ui_register_for_shortcode('bbp-search', array('label' => __('BBPress Search Input Form', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Search Input Form Template shortcode_ui_register_for_shortcode('bbp-search-form', array('label' => __('BBPress Search Input Template', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Login Form sandwich_add_logged_out_shortcode('bbp-login'); shortcode_ui_register_for_shortcode('bbp-login', array('label' => __('BBPress Login Form', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Register Form sandwich_add_logged_out_shortcode('bbp-register'); shortcode_ui_register_for_shortcode('bbp-register', array('label' => __('BBPress Registration Screen', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Lost Password Form sandwich_add_logged_out_shortcode('bbp-lost-pass'); shortcode_ui_register_for_shortcode('bbp-lost-pass', array('label' => __('BBPress Lost Password Form', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); // Register Shortcake UI for BBPress Statistics shortcode_ui_register_for_shortcode('bbp-stats', array('label' => __('BBPress Statistics', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress dashicons-bbpress-logo')); }
function testReturns() { // replace this with some actual testing code $this->assertInternalType('array', sandwich_functions_display_order()); $this->assertInternalType('array', sandwich_functions_display_dir()); $this->assertInternalType('array', sandwich_functions_posttype_list('post')); $this->assertCount(1, sandwich_functions_posttype_list('post'), 'Should have the first element as the "select one" element'); $this->factory->post->create(); $this->assertCount(2, sandwich_functions_posttype_list('post')); $this->factory->post->create_many(8); $this->assertCount(10, sandwich_functions_posttype_list('post')); $this->assertInternalType('array', sandwich_functions_taxonomy_list()); $this->assertInternalType('array', sandwich_functions_term_list('invalid_term'), 'Invalid taxonomy should not error'); $this->assertInternalType('array', sandwich_functions_term_list('post_tag')); $this->assertCount(1, sandwich_functions_term_list('post_tag')); }