function test_pmp_get_creators() { $creators = pmp_get_creators(); $expected_creators = array('APM' => '98bf597a-2a6f-446c-9b7e-d8ae60122f0d', 'NPR' => '6140faf0-fb45-4a95-859a-070037fafa01', 'PBS' => 'fc53c568-e939-4d9c-86ea-c2a2c70f1a99', 'PRI' => '7a865268-c9de-4b27-a3c1-983adad90921', 'PRX' => '609a539c-9177-4aa7-acde-c10b77a6a525'); $this->assertTrue(count($creators) == count($expected_creators)); foreach (array_keys($expected_creators) as $key) { $this->assertTrue(in_array($key, array_keys($creators))); } foreach (array_values($expected_creators) as $val) { $this->assertTrue(in_array($val, array_values($creators))); } }
/** * Render the plugin's search page * * @since 0.1 */ function pmp_search_page() { if (!current_user_can('edit_posts')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $context = array('creators' => pmp_get_creators(), 'profiles' => pmp_get_profiles()); if (isset($_GET['search_id'])) { $query_data = pmp_get_saved_search_query($_GET['search_id']); $context['PMP'] = pmp_json_obj(array('search' => $query_data, 'support_link_base' => pmp_get_support_link_base())); } else { $context['PMP'] = pmp_json_obj(array('support_link_base' => pmp_get_support_link_base())); } pmp_render_template('search.php', $context); }
/** * Builds a PMP object with common attributes used throughout the plugin's javascript files. * * @since 0.2 */ function pmp_json_obj($add = array()) { return array_merge(array('creators' => array_flip(pmp_get_creators()), 'ajax_nonce' => wp_create_nonce('pmp_ajax_nonce')), $add); }