/** Load scripts and styles required at the front end **/ public function load_scripts_and_styles() { // Enqueue scripts required for the ajax refresh functionality wp_enqueue_script('quotescollection', quotescollection_url('js/quotes-collection.js'), array('jquery'), self::PLUGIN_VERSION, false); wp_localize_script('quotescollection', 'quotescollectionAjax', array('ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('quotescollection'), 'nextQuote' => $this->refresh_link_text, 'loading' => __('Loading...', 'quotes-collection'), 'error' => __('Error getting quote', 'quotes-collection'), 'autoRefreshMax' => $this->auto_refresh_max, 'autoRefreshCount' => 0)); // Enqueue styles for the front end if (!is_admin()) { wp_register_style('quotescollection', quotescollection_url('css/quotes-collection.css'), false, self::PLUGIN_VERSION); wp_enqueue_style('quotescollection'); } }
public function load_scripts_and_styles() { // Load the confirm box scripts and styles only if on the quotes list page. $screen = get_current_screen(); if ($screen->id == $this->main_page_id) { wp_enqueue_script('quotescollection-confirm-delete', quotescollection_url('js/confirm-delete.js'), array('jquery-ui-dialog'), Quotes_Collection::PLUGIN_VERSION, true); wp_localize_script('quotescollection-confirm-delete', 'quotescollectionConfirm', array('dialogTitle' => _x('Delete?', 'confirmation dialog title', 'quotes-collection'), 'dialogTextSingular' => _x('Are you sure you want to delete this quote?', 'confirmation dialog text for deleting a single quote', 'quotes-collection'), 'dialogTextPlural' => _x('Are you sure you want to delete these quotes?', 'confirmation dialog text for deleting multiple quotes', 'quotes-collection'), 'buttonYes' => _x('Yes', 'confirmation dialog button text', 'quotes-collection'), 'buttonNo' => _x('No', 'confirmation dialog button text', 'quotes-collection'))); wp_enqueue_style('wp-jquery-ui-dialog'); } // And load the quotes-collection-admin.css if current page is any of the plugin's admin pages if ($screen->id == $this->main_page_id || $screen->id == $this->add_new_quote_page_id || $screen->id == $this->import_page_id || $screen->id == $this->export_page_id || $screen->id == $this->options_page_id) { wp_enqueue_style('quotescollection-admin', quotescollection_url('css/quotes-collection-admin.css'), array(), Quotes_Collection::PLUGIN_VERSION); } }