function test_output()
 {
     // Create a post.
     $post_id = $this->factory->post->create();
     $meta = $this->utils->additional1;
     // Add additional post meta to the post.
     update_post_meta($post_id, '_ac_additional_content', array($meta));
     $meta['additional_content'] = 'new_content';
     // The following functions should not output anything.
     ob_start();
     $sort = sort_by_priority(array($meta));
     $string = is_empty_string('string');
     $defaults = get_defaults();
     $update = update_additional_meta($post_id, array($meta));
     // Uses the AC_Public class.
     $content = get_content('content', $post_id);
     // post-new screen
     set_current_screen('post-new.php');
     $this->utils->setup_post_screen();
     $classes = metabox_classes();
     $text = metabox_text();
     $metabox = metabox_defaults();
     $label = label_text(array($meta));
     $out = ob_get_clean();
     $this->assertEquals('', $out);
 }
Beispiel #2
0
function wowslider_set_screen_id()
{
    $screen = get_current_screen();
    if ('toplevel_page_wowslider/admin' == $screen->id) {
        set_current_screen('wowslider_sliders');
    }
}
 public function setUp()
 {
     parent::setUp();
     // Create a new user then add 'edit_theme_options' capability
     $user_id = $this->factory->user->create();
     $user = wp_set_current_user($user_id);
     $user->add_cap('edit_theme_options');
     // Pretending in customize page.
     if (!isset($_REQUEST['wp_customize'])) {
         $_REQUEST['wp_customize'] = 'on';
     }
     if (!class_exists('WP_Customize_Manager')) {
         require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
     }
     // Init Customize class.
     if (!isset($GLOBALS['wp_customize'])) {
         $GLOBALS['wp_customize'] = new WP_Customize_Manager();
     }
     // Removes any registered actions (in which some themes use) and re-register action
     // from this plugin.
     remove_all_actions('customize_register');
     add_action('customize_register', array('Widget_Customizer', 'customize_register'));
     set_current_screen('customize');
     do_action('customize_register', $GLOBALS['wp_customize']);
 }
 function setUp()
 {
     parent::setUp();
     set_current_screen('edit-page');
     $GLOBALS['hook_suffix'] = '';
     $this->table = _get_list_table('WP_Posts_List_Table');
 }
Beispiel #5
0
 function setUp()
 {
     global $wp_rewrite;
     parent::setUp();
     set_current_screen('front');
     $GLOBALS['wp_the_query'] = new WP_Query();
     $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     create_initial_taxonomies();
     register_taxonomy('testtax', 'post', array('public' => true));
     $wp_rewrite->flush_rules();
     $this->tag_id = $this->factory->tag->create(array('slug' => 'tag-slug'));
     $this->cat_id = $this->factory->category->create(array('slug' => 'cat-slug'));
     $this->tax_id = $this->factory->term->create(array('taxonomy' => 'testtax', 'slug' => 'tax-slug'));
     $this->tax_id2 = $this->factory->term->create(array('taxonomy' => 'testtax', 'slug' => 'tax-slug2'));
     $this->post_id = $this->factory->post->create();
     wp_set_object_terms($this->post_id, $this->cat_id, 'category');
     wp_set_object_terms($this->post_id, array($this->tax_id, $this->tax_id2), 'testtax');
     $this->cat = get_term($this->cat_id, 'category');
     _make_cat_compat($this->cat);
     $this->tag = get_term($this->tag_id, 'post_tag');
     $this->uncat = get_term_by('slug', 'uncategorized', 'category');
     _make_cat_compat($this->uncat);
     add_action('pre_get_posts', array($this, 'pre_get_posts_tax_category_tax_query'));
 }
 /**
  * Sets up the move tickets dialog.
  */
 public function dialog()
 {
     if (!$this->is_move_tickets_dialog()) {
         return;
     }
     if (!wp_verify_nonce($_GET['check'], 'move_tickets')) {
         return;
     }
     $event_id = isset($_GET['event_id']) ? absint($_GET['event_id']) : absint($_GET['post']);
     $attendee_ids = array_map('intval', explode('|', @$_GET['ticket_ids']));
     $this->build_attendee_list($attendee_ids, $event_id);
     /**
      * Provides an opportunity to modify the template variables used in the
      * move tickets dialog.
      *
      * @param array $template_vars
      */
     $template_vars = (array) apply_filters('tribe_tickets_move_tickets_template_vars', array('title' => __('Move Attendees', 'event-tickets'), 'mode' => 'move_tickets', 'check' => wp_create_nonce('move_tickets'), 'event_name' => get_the_title($event_id), 'attendees' => $this->attendees, 'multiple_providers' => $this->has_multiple_providers));
     set_current_screen();
     define('IFRAME_REQUEST', true);
     $this->dialog_assets();
     iframe_header($template_vars['title']);
     extract($template_vars);
     include EVENT_TICKETS_DIR . '/src/admin-views/move-tickets.php';
     iframe_footer();
     exit;
 }
 /**
  * Test context calculations for submenus.
  */
 public function test_submenu_contexts()
 {
     $screen = get_current_screen();
     $self = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : null;
     $page = isset($_GET['page']) ? $_GET['page'] : null;
     $submenus = _fieldmanager_registry('submenus');
     _fieldmanager_registry('submenus', array());
     // Spoof is_admin().
     set_current_screen('dashboard-user');
     // Submenu of a default WordPress menu.
     $options_submenu = rand_str();
     fm_register_submenu_page($options_submenu, 'options-general.php', 'Options');
     $_SERVER['PHP_SELF'] = '/options-general.php';
     $_GET['page'] = $options_submenu;
     $this->assertEquals(array('submenu', $options_submenu), fm_calculate_context());
     // Submenu of a custom menu.
     $custom_menu_submenu = rand_str();
     fm_register_submenu_page($custom_menu_submenu, rand_str(), 'Custom');
     $_SERVER['PHP_SELF'] = '/admin.php';
     $_GET['page'] = $custom_menu_submenu;
     $this->assertEquals(array('submenu', $custom_menu_submenu), fm_calculate_context());
     // Submenu that Fieldmanager didn't register.
     $_SERVER['PHP_SELF'] = '/themes.php';
     $_GET['page'] = rand_str();
     $this->assertEquals(array(null, null), fm_calculate_context());
     $GLOBALS['current_screen'] = $screen;
     $_SERVER['PHP_SELF'] = $self;
     $_GET['page'] = $page;
     _fieldmanager_registry('submenus', $submenus);
 }
Beispiel #8
0
 public function setUp()
 {
     parent::setUp();
     set_current_screen('dashboard');
     //$this->factory = new EDD_UnitTest_Factory;
     //require_once dirname(__FILE__) . '/../subclasses/test_shortcode.php';
 }
Beispiel #9
0
function wowslider_set_screen_id()
{
    $screen = get_current_screen();
    if ('toplevel_page_wow-slider-wordpress-image-slider-plugin/admin' == $screen->id) {
        set_current_screen('wowslider_sliders');
    }
}
 /**
  * Performs WordPress setup and pre test cleanup. add to this method as needed. 
  */
 function setUp()
 {
     parent::setUp();
     $GLOBALS['wp_tests_options'] = array('active_plugins' => array('wolfnet-idx-for-wordpress/wolfnet.php'));
     // we need to be admin to test the admin views
     wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
     set_current_screen('index.php');
     // a new instance with active admin user
     $this->wolfnet = new Wolfnet();
     $GLOBALS['wolfnet'] =& $this->wolfnet;
     // // protected reflection class needed
     // $key = $this->wolfnet->setJsonProductKey($GLOBALS['wnt_tests_options']['api_key_good1']);
     // $option = $wolfnet_productKey->wolfnet->productKeyOptionKey;
     // update_option($key);
     // set a product key in the wordpress setting.
     // there is a test for this in test-wolfnet.php
     $this->wolfnet_reflection = new ReflectionClass("wolfnet");
     $method = $this->wolfnet_reflection->getMethod("setJsonProductKey");
     $method->setAccessible(true);
     $productKeyOptionKey = $this->wolfnet_reflection->getProperty('productKeyOptionKey');
     $productKeyOptionKey->setAccessible(true);
     $key = $productKeyOptionKey->getValue($this->wolfnet);
     $key_json = $method->invoke($this->wolfnet, $GLOBALS['wnt_tests_options']['api_key_good1']);
     update_option($key, $key_json);
     // this will match any <tag>.
     $this->wnt_html_regex = '/<[^>]*>/';
     $this->wnt_html_msg = "Method returned nothing that looks like an HTML tag";
 }
 function test_plugin_option_insert_and_delete()
 {
     //setting up subscriber user with admin permission
     $user = new WP_User($this->factory->user->create(array('role' => 'administrator')));
     wp_set_current_user($user->ID);
     $this->auxClass->set_up_post_data();
     set_current_screen('edit-page');
     $plugin_admin = wp_tutorial_maker_Admin::get_instance();
     //define new term
     $tid = $this->generate_tid();
     //getting the number of current base decider
     $base_decider_count = $this->auxClass->get_option_array_count();
     //submitting data!
     $plugin_admin->wp_tutorial_maker_option_update($tid);
     //getting the current count
     $wp_tutorial_maker_decider_options_count = $this->auxClass->get_option_array_count();
     //should achieve successfull submission and increase the base data by 1, since we have permission
     $this->assertEquals($wp_tutorial_maker_decider_options_count, $base_decider_count + 1);
     //delete
     $plugin_admin->wp_tutorial_maker_option_delete($tid);
     //getting the current count
     $wp_tutorial_maker_decider_options_count = $this->auxClass->get_option_array_count();
     //should achieve successfull submission and increase the base data by 1, since we have permission
     $this->assertEquals($wp_tutorial_maker_decider_options_count, $base_decider_count);
 }
 public function setUp()
 {
     parent::setUp();
     // Spoof is_admin() for fm_add_script().
     $this->screen = get_current_screen();
     set_current_screen('dashboard-user');
     // Re-init scripts. @see Tests_Dependencies_Scripts.
     $this->old_wp_scripts = isset($GLOBALS['wp_scripts']) ? $GLOBALS['wp_scripts'] : null;
     remove_action('wp_default_scripts', 'wp_default_scripts');
     $GLOBALS['wp_scripts'] = new WP_Scripts();
     $GLOBALS['wp_scripts']->default_version = get_bloginfo('version');
     // Media will only try to register a script once, so hack around that.
     Fieldmanager_Media::$has_registered_media = false;
     // Instantiate field classes that register scripts.
     new Fieldmanager_Autocomplete('Test', array('datasource' => new Fieldmanager_Datasource_Post()));
     new Fieldmanager_Datepicker('Test');
     new Fieldmanager_DraggablePost('Test');
     new Fieldmanager_Grid('Test');
     new Fieldmanager_Group('Test', array('tabbed' => 'horizontal'));
     new Fieldmanager_Media('Test');
     new Fieldmanager_Select('Test');
     new Fieldmanager_RichTextArea('Test');
     do_action('wp_enqueue_scripts');
     do_action('admin_enqueue_scripts');
 }
Beispiel #13
0
 /**
  * Load gmedia pages in wpless interface
  */
 function gmedia_blank_page()
 {
     set_current_screen('GrandMedia_Settings');
     global $gmCore;
     $gmediablank = $gmCore->_get('gmediablank', '');
     /*
     add_filter('admin_body_class', function(){
     	$gmediablank = isset($_GET['gmediablank'])? $_GET['gmediablank'] : '';
     	return "gmedia-blank $gmediablank"; });
     */
     add_filter('admin_body_class', create_function('', '$gmediablank = isset($_GET["gmediablank"])? $_GET["gmediablank"] : ""; return "gmedia-blank $gmediablank";'));
     define('IFRAME_REQUEST', true);
     iframe_header('GmediaGallery');
     switch ($gmediablank) {
         case 'update_plugin':
             require_once dirname(dirname(__FILE__)) . '/update.php';
             gmedia_do_update();
             break;
         case 'image_editor':
             require_once dirname(dirname(__FILE__)) . '/inc/image-editor.php';
             gmedia_image_editor();
             break;
     }
     iframe_footer();
     exit;
 }
Beispiel #14
0
 function test_post_type_metabox()
 {
     $type = uix()->ui->post_type['employee'];
     $_POST['uix-text-textuix-section-one_sectionuix-metabox-myboxuix-post-employee'] = 'saved';
     $metabox = $type->metabox('mybox', array('name' => 'my box', 'description' => 'my meta box', 'template' => __DIR__ . '/ui/box/include_template.php', 'chromeless' => true, 'section' => array('one_section' => array('label' => 'test', 'control' => array('text' => array('type' => 'text', 'value' => 'demo'), 'no_update' => array('type' => 'text', 'value' => null))))));
     $screen = set_current_screen('employee');
     $this->assertTrue($metabox->is_active());
     $screen = convert_to_screen('edit-employee');
     //$_POST[ $metabox->id() ] = array
     $data = $metabox->get_data();
     $test_data = array('one_section' => array('text' => 'saved', 'no_update' => null));
     //$this->assertSame( $data, $test_data );
     $post_id = $this->factory->post->create_object(array('post_type' => 'employee'));
     update_post_meta($post_id, 'no_update', 'remove me');
     $update_post = $this->factory->post->update_object($post_id, array('post_title' => 'updated'));
     $post = get_post($post_id);
     do_action('add_meta_boxes', 'employee', $post);
     ob_start();
     $metabox->enqueue_core();
     $html = ob_get_clean();
     $this->assertTrue(is_string($html));
     ob_start();
     $metabox->create_metabox($post);
     $html = ob_get_clean();
     $this->assertTrue(is_string($html));
 }
 function _handle_action($action, $params)
 {
     if (!current_user_can('update_plugins')) {
         // Not allowed, skip...
         return null;
     }
     $updater = $this->object->get_registry()->get_module('photocrati-auto_update');
     if ($updater != null) {
         $result = null;
         switch ($action) {
             case 'handle-item':
                 $item = $params['update-item'];
                 $command_action = $item['action'];
                 $command_info = $item['info'];
                 $command_stage = isset($command_info['-command-stage']) ? $command_info['-command-stage'] : null;
                 // XXX this is just to load a nice icon...but seems to be broken ('index' loads 'dashboard' which is missing)
                 if ($command_stage == 'install') {
                     $layout_screen = null;
                     if (function_exists('get_current_screen')) {
                         $layout_screen = get_current_screen();
                     } else {
                         global $current_screen;
                         $layout_screen = $current_screen;
                     }
                     if ($layout_screen == null && function_exists('set_current_screen')) {
                         set_current_screen('index');
                     }
                 }
                 if ($command_stage == 'cleanup') {
                     update_option('photocrati_auto_update_admin_update_list', null);
                     update_option('photocrati_auto_update_admin_check_date', '');
                 }
                 $result = $updater->execute_api_command($command_action, $command_info);
                 return array('action' => $command_action, 'info' => $result);
             case 'handle-list':
                 $item_list = $params['update-list'];
                 $return_list = array();
                 $clear_cache = false;
                 foreach ($item_list as $item) {
                     $command_action = $item['action'];
                     $command_info = $item['info'];
                     $command_stage = isset($command_info['-command-stage']) ? $command_info['-command-stage'] : null;
                     // Atomic handling of entire command lists is only supported for activation stage
                     if ($command_stage == 'activate') {
                         $result = $updater->execute_api_command($command_action, $command_info);
                         $item['info'] = $result;
                         $clear_cache = true;
                     }
                     $return_list[] = $item;
                 }
                 if ($clear_cache) {
                     update_option('photocrati_auto_update_admin_update_list', null);
                     update_option('photocrati_auto_update_admin_check_date', '');
                 }
                 return $return_list;
         }
     }
     return null;
 }
 function setUp()
 {
     parent::setUp();
     wp_set_current_user($this->factory->user->create(array('role' => 'administrator')));
     set_current_screen('index.php');
     // a new instance with active admin user
     $this->wolfnet = new Wolfnet();
 }
 function test_current_post_type_custom_post_type()
 {
     register_post_type('content');
     set_current_screen('content');
     $this->assertEquals('content', self::$EditFlowModule->get_current_post_type());
     _unregister_post_type('content');
     set_current_screen('front');
 }
Beispiel #18
0
 function setUp()
 {
     parent::setUp();
     set_current_screen('front');
     update_option('comments_per_page', 5);
     update_option('posts_per_page', 5);
     create_initial_taxonomies();
     $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
 }
Beispiel #19
0
 function setUp()
 {
     global $post;
     parent::setUp();
     $this->editor = new Editor(WP_Gistpen::$plugin_name, WP_Gistpen::$version);
     $this->create_post_and_children();
     set_current_screen('gistpen');
     $post = $this->gistpen;
 }
 public function setUp()
 {
     $this->screen = get_current_screen();
     $this->self = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : null;
     $this->get = $_GET;
     $this->submenus = _fieldmanager_registry('submenus');
     _fieldmanager_registry('submenus', array());
     // Spoof is_admin().
     set_current_screen('dashboard-user');
 }
 public function __construct()
 {
     require_once WPSC_FILE_PATH . '/wpsc-admin/includes/product-variation-list-table.class.php';
     $GLOBALS['hook_suffix'] = 'wpsc-product-variations-iframe';
     $this->parent_id = absint($_REQUEST['product_id']);
     set_current_screen();
     if (!empty($_REQUEST['tab'])) {
         $this->current_tab = $_REQUEST['tab'];
     }
 }
Beispiel #22
0
 private function get_table()
 {
     if (is_null($this->table)) {
         if (!get_current_screen()) {
             set_current_screen(self::USERS_SCREEN);
         }
         $this->table = _get_list_table('WP_Users_List_Table', array('screen' => self::USERS_SCREEN));
     }
     return $this->table;
 }
 public function init()
 {
     set_current_screen('shop_order');
     parent::__construct(array('plural' => 'Donations', 'screen' => get_current_screen()));
     $this->screen->post_type = 'shop_order';
     //$this->screen->id = 'shop_order';
     $post_type = $this->screen->post_type;
     $post_type_object = get_post_type_object($post_type);
     $this->user_posts_count = 0;
     $this->sticky_posts_count = 0;
 }
 /**
  * Constructor.
  *
  * @since 3.1.0
  * @access public
  *
  * @see WP_List_Table::__construct() for more information on default arguments.
  *
  * @param array $args An associative array of arguments.
  */
 public function __construct($userA, $args = array())
 {
     $this->user_args = $userA;
     set_current_screen('users');
     parent::__construct(array('singular' => 'user', 'plural' => 'users', 'screen' => get_current_screen()));
     $this->screen->id = 'users';
     $this->is_site_users = 'site-users-network' == $this->screen->id;
     if ($this->is_site_users) {
         $this->site_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     }
 }
Beispiel #25
0
 /**
  * Tear down the test fixture.
  * Reset $_POST, remove the wp_die() override, restore error reporting
  */
 public function tearDown()
 {
     parent::tearDown();
     $_POST = array();
     $_GET = array();
     unset($GLOBALS['post']);
     unset($GLOBALS['comment']);
     remove_filter('wp_die_ajax_handler', array($this, 'getDieHandler'), 1, 1);
     remove_action('clear_auth_cookie', array($this, 'logout'));
     error_reporting($this->_error_level);
     set_current_screen('front');
 }
 /**
  * @ticket 22896
  *
  * @expectedIncorrectUsage wp_deregister_script
  */
 function test_dont_allow_deregister_core_scripts_in_admin()
 {
     set_current_screen('edit.php');
     $this->assertTrue(is_admin());
     $libraries = array('jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse', 'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable', 'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs', 'jquery-ui-tooltip', 'jquery-ui-widget', 'backbone', 'underscore');
     foreach ($libraries as $library) {
         // Try to deregister the script, which should fail.
         wp_deregister_script($library);
         $this->assertTrue(wp_script_is($library, 'registered'));
     }
     set_current_screen('front');
 }
Beispiel #27
0
 public function test_has_htaccess()
 {
     if (!function_exists('buddydrive_admin')) {
         require_once buddydrive()->includes_dir . 'admin/buddydrive-admin.php';
     }
     // Load the admin
     buddydrive_admin();
     set_current_screen('plugins' . $this->suffix);
     $notice_hook = bp_core_do_network_admin() ? 'network_admin_notices' : 'admin_notices';
     do_action($notice_hook);
     $this->assertTrue(file_exists(buddydrive()->upload_dir . '/.htaccess'));
 }
Beispiel #28
0
 function setUp()
 {
     parent::setUp();
     set_current_screen('front');
     update_option('comments_per_page', 5);
     update_option('posts_per_page', 5);
     global $wp_rewrite;
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     create_initial_taxonomies();
     $wp_rewrite->flush_rules();
 }
 /**
  * Event date & upcoming filters SHOULD be removed from event list pages (they do their own date filtering)
  *
  * @test
  */
 public function it_should_remove_date_filters_on_event_list()
 {
     set_current_screen('edit-' . Tribe__Events__Main::POSTTYPE);
     $query = new WP_Query();
     $query->parse_query(['post_type' => Tribe__Events__Main::POSTTYPE]);
     if (isset($_GET['page'])) {
         unset($_GET['page']);
     }
     if (isset($_GET['tab'])) {
         unset($_GET['tab']);
     }
     $this->assertTrue(Tribe__Events__Query::should_remove_date_filters($query), 'Date filters should be removed when on the event list page');
 }
Beispiel #30
-1
 function setUp()
 {
     set_current_screen('edit-page');
     $GLOBALS['hook_suffix'] = '';
     $this->table = _get_list_table('WP_Posts_List_Table');
     parent::setUp();
     // note that our top/children/grandchildren arrays are 1-indexed
     // create top level pages
     $num_posts = 5;
     foreach (range(1, $num_posts) as $i) {
         $this->top[$i] = $this->factory->post->create_and_get(array('post_type' => 'page', 'post_title' => sprintf('Top Level Page %d', $i)));
     }
     // create child pages
     $num_children = 3;
     foreach ($this->top as $top => $top_page) {
         foreach (range(1, $num_children) as $i) {
             $this->children[$top][$i] = $this->factory->post->create_and_get(array('post_type' => 'page', 'post_parent' => $top_page->ID, 'post_title' => sprintf('Child %d', $i)));
         }
     }
     // create grand-child pages for the third and fourth top-level pages
     $num_grandchildren = 3;
     foreach (range(3, 4) as $top) {
         foreach ($this->children[$top] as $child => $child_page) {
             foreach (range(1, $num_grandchildren) as $i) {
                 $this->grandchildren[$top][$child][$i] = $this->factory->post->create_and_get(array('post_type' => 'page', 'post_parent' => $child_page->ID, 'post_title' => sprintf('Grandchild %d', $i)));
             }
         }
     }
 }