/** * Scripts for Preview & WP frontend * * @param bool $is_admin Whether or not in WP Admin */ static function frontend_scripts($is_admin = false) { $unload_bootstrap = PT_CV_Functions::get_option_value('unload_bootstrap'); if ($is_admin || empty($unload_bootstrap)) { // Load bootstrap js PT_CV_Asset::enqueue('bootstrap'); } // Load bootstrap paginator PT_CV_Asset::enqueue('bootstrap-paginator'); // Public script PT_CV_Asset::enqueue('public', 'script', array('src' => plugins_url('public/assets/js/public.js', PT_CV_FILE), 'deps' => array('jquery'))); // Localize for Public script PT_CV_Asset::localize_script('public', PT_CV_PREFIX_UPPER . 'PUBLIC', array('_prefix' => PT_CV_PREFIX, '_nonce' => wp_create_nonce(PT_CV_PREFIX_ . 'ajax_nonce'), 'is_admin' => is_admin(), 'is_mobile' => wp_is_mobile(), 'ajaxurl' => admin_url('admin-ajax.php'), 'lang' => PT_CV_Functions::get_language(), 'move_bootstrap' => apply_filters(PT_CV_PREFIX_ . 'move_bootstrap', 1))); // Localize for Pagination script PT_CV_Asset::localize_script('bootstrap-paginator', PT_CV_PREFIX_UPPER . 'PAGINATION', array('first' => apply_filters(PT_CV_PREFIX_ . 'pagination_first', '«'), 'prev' => apply_filters(PT_CV_PREFIX_ . 'pagination_prev', '‹'), 'next' => apply_filters(PT_CV_PREFIX_ . 'pagination_next', '›'), 'last' => apply_filters(PT_CV_PREFIX_ . 'pagination_last', '»'), 'goto_first' => apply_filters(PT_CV_PREFIX_ . 'goto_first', __('Go to first page', PT_CV_DOMAIN)), 'goto_prev' => apply_filters(PT_CV_PREFIX_ . 'goto_prev', __('Go to previous page', PT_CV_DOMAIN)), 'goto_next' => apply_filters(PT_CV_PREFIX_ . 'goto_next', __('Go to next page', PT_CV_DOMAIN)), 'goto_last' => apply_filters(PT_CV_PREFIX_ . 'goto_last', __('Go to last page', PT_CV_DOMAIN)), 'current_page' => apply_filters(PT_CV_PREFIX_ . 'current_page', __('Current page is', PT_CV_DOMAIN)), 'goto_page' => apply_filters(PT_CV_PREFIX_ . 'goto_page', __('Go to page', PT_CV_DOMAIN)))); }
/** * Register and enqueue admin-specific JavaScript. * * @since 1.0.0 * * @return null Return early if no settings page is registered. */ public function enqueue_admin_scripts() { if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix == $screen->id || in_array($screen->id, $this->plugin_sub_screen_hook_suffix)) { // WP assets wp_enqueue_script('wp-color-picker'); wp_enqueue_script('jquery-ui-sortable'); // Main admin script PT_CV_Asset::enqueue('admin', 'script', array('src' => plugins_url('assets/js/admin.js', __FILE__), 'deps' => array('jquery'))); // Localize strings PT_CV_Asset::localize_script('admin', PT_CV_PREFIX_UPPER . 'ADMIN', array('_prefix' => PT_CV_PREFIX, '_group_prefix' => PT_CV_Html::html_group_class() . '-', '_nonce' => wp_create_nonce(PT_CV_PREFIX_ . 'ajax_nonce'), 'supported_version' => PT_CV_Functions::wp_version_compare('3.5'), 'text' => array('no_taxonomy' => __('There is no taxonomy for selected content type', 'content-views-query-and-display-post-page'), 'pagination_disable' => __('Pagination is disabled when Limit = -1', 'content-views-query-and-display-post-page'), 'prevent_click' => __('Opening a link is prevented in preview box', 'content-views-query-and-display-post-page')), 'btn' => array('preview' => array('show' => __('Show Preview', 'content-views-query-and-display-post-page'), 'hide' => __('Hide Preview', 'content-views-query-and-display-post-page'), 'update' => __('Update Preview', 'content-views-query-and-display-post-page'))), 'data' => array('post_types_vs_taxonomies' => PT_CV_Values::post_types_vs_taxonomies()))); // Bootstrap for Admin PT_CV_Asset::enqueue('bootstrap-admin', 'script', array('src' => plugins_url('assets/bootstrap/js/bootstrap.full.js', PT_CV_FILE))); // For Preview PT_CV_Html::frontend_scripts(); PT_CV_Asset::enqueue('select2'); } }
/** * Scripts for Preview & WP frontend */ static function frontend_scripts() { PT_CV_Asset::enqueue('bootstrap'); // Public script PT_CV_Asset::enqueue('public', 'script', array('src' => plugins_url('public/assets/js/public.js', PT_CV_FILE), 'deps' => array('jquery'))); // Localize for Public script PT_CV_Asset::localize_script('public', PT_CV_PREFIX_UPPER . 'PUBLIC', array('_prefix' => PT_CV_PREFIX, 'page_to_show' => apply_filters(PT_CV_PREFIX_ . 'pages_to_show', 5), '_nonce' => wp_create_nonce(PT_CV_PREFIX_ . 'ajax_nonce'), 'is_admin' => is_admin(), 'is_mobile' => apply_filters(PT_CV_PREFIX_ . 'is_mobile', wp_is_mobile()), 'ajaxurl' => admin_url('admin-ajax.php'), 'lang' => PT_CV_Functions::get_language(), 'loading_image_src' => PT_CV_Html::loading_img_src()) + apply_filters(PT_CV_PREFIX_ . 'public_localize_script_extra', array())); // Localize for Pagination script PT_CV_Asset::localize_script(array('bootstrap', 'bootstrap-admin'), PT_CV_PREFIX_UPPER . 'PAGINATION', array('first' => apply_filters(PT_CV_PREFIX_ . 'pagination_first', '«'), 'prev' => apply_filters(PT_CV_PREFIX_ . 'pagination_prev', '‹'), 'next' => apply_filters(PT_CV_PREFIX_ . 'pagination_next', '›'), 'last' => apply_filters(PT_CV_PREFIX_ . 'pagination_last', '»'), 'goto_first' => apply_filters(PT_CV_PREFIX_ . 'goto_first', __('Go to first page', 'content-views-query-and-display-post-page')), 'goto_prev' => apply_filters(PT_CV_PREFIX_ . 'goto_prev', __('Go to previous page', 'content-views-query-and-display-post-page')), 'goto_next' => apply_filters(PT_CV_PREFIX_ . 'goto_next', __('Go to next page', 'content-views-query-and-display-post-page')), 'goto_last' => apply_filters(PT_CV_PREFIX_ . 'goto_last', __('Go to last page', 'content-views-query-and-display-post-page')), 'current_page' => apply_filters(PT_CV_PREFIX_ . 'current_page', __('Current page is', 'content-views-query-and-display-post-page')), 'goto_page' => apply_filters(PT_CV_PREFIX_ . 'goto_page', __('Go to page', 'content-views-query-and-display-post-page')))); // Load Pro scripts do_action(PT_CV_PREFIX_ . 'frontend_scripts'); }