public function testGetPostTypesLabels() { $postTypesToIndex = Core\FieldsHelper::getPostTypesToIndex(); $postLabels = Core\FieldsHelper::getPostTypesLabels($postTypesToIndex); $type = 'post'; $postType = get_post_type_object($type); $this->assertEquals($postType->labels->name, $postLabels[$type]); $type = 'page'; $postType = get_post_type_object($type); $this->assertEquals($postType->labels->name, $postLabels[$type]); }
/** * Enqueue the admin scripts * @param string $hook Page where it was called * @return void */ public function enqueueScripts($hook) { if ($hook != 'toplevel_page_opSou_general_settings') { return; } $jspath = Registry::instance()->getPluginUrl() . "admin/assets/scripts/open-search-functions.js"; $csspath = Registry::instance()->getPluginUrl() . "admin/assets/styles/settings.css"; wp_enqueue_script('jquery-ui-progressbar'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('openSearchSettings', $jspath, array('jquery', 'jquery-ui-progressbar'), Registry::instance()->getPluginVersion()); wp_enqueue_style('jquery-ui'); wp_enqueue_style('openSearchSettings', $csspath, array(), Registry::instance()->getPluginVersion()); $adminUrl = admin_url(); $homeUrl = home_url(null, is_ssl() ? 'https' : 'http'); $postTypesToIndex = Core\FieldsHelper::getPostTypesToIndex(); $postLabels = Core\FieldsHelper::getPostTypesLabels($postTypesToIndex); $args = array('siteUrl' => $homeUrl, 'ajaxUrl' => sprintf('%s%s', $adminUrl, "admin-ajax.php"), 'ajaxIndexAction' => Settings::ajaxIndexAction, 'ajaxIndexNonce' => wp_create_nonce(Settings::ajaxIndexAction), 'postsPerPage' => $this->postsPerPageToIndex, 'postsPerPageToRemove' => $this->postsPerPageToRemove, 'postTypesToIndex' => array_keys($postTypesToIndex), 'totalPublishedPosts' => self::getTotalPublishedPosts(), 'labels' => array('indexationError' => 'There was an error trying to run indexation, please contact to the author.', 'starting' => 'Starting...', 'indexing' => 'Indexing ', 'complete' => 'Completed!', 'running' => "We're indexing your content and sending it to OpenSearch. Hang tight - it could take several minutes!", 'removing' => 'Removing unpublish posts from the index', 'postsLabels' => $postLabels, 'indexNameChanged' => 'Index name was changed. Please save changes to index content.')); // pre($args); wp_localize_script('openSearchSettings', 'opSouVars', $args, Registry::instance()->getPluginVersion()); }