/**
  * 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');
     }
 }
示例#2
0
            $type = 'script';
            $prefix_ = !empty($prefix) ? $prefix : self::$prefix;
            $handle = $prefix_ . $name . '-' . $type;
            wp_localize_script($handle, $object_name, $translation_array);
        }
        /**
         * Include asset files directly in page
         *
         * @param string $name   Asset slug name
         * @param string $scr    The link to asset file
         * @param string $type   Asset type (css/js)
         * @param string $prefix Prefix string for asset
         */
        static function include_inline($name, $src, $type, $prefix = '')
        {
            $prefix_ = !empty($prefix) ? $prefix : self::$prefix;
            $handle = $prefix_ . $name . '-' . $type;
            switch ($type) {
                case 'js':
                    printf("<script type='text/javascript' src='%s'></script>", $src);
                    break;
                case 'css':
                    printf("<link rel='stylesheet' id='%s' href='%s' type='text/css' media='all' />", esc_attr($handle), esc_url($src));
                    break;
            }
        }
    }
}
// Call to run
PT_CV_Asset::register();
示例#3
0
 /**
  * Styles for Preview & WP frontend
  *
  * @global bool $is_IE
  */
 static function frontend_styles()
 {
     $unload_bootstrap = PT_CV_Functions::get_option_value('unload_bootstrap');
     if (!is_admin() && empty($unload_bootstrap)) {
         PT_CV_Asset::enqueue('bootstrap', 'style');
     }
     PT_CV_Asset::enqueue('public', 'style', array('src' => plugins_url('public/assets/css/public.css', PT_CV_FILE)));
     // Fix bootstrap error in IE
     global $is_IE;
     if ($is_IE) {
         PT_CV_Asset::enqueue('html5shiv', 'script', array('src' => plugins_url('assets/ie-fix/html5shiv.min.js', PT_CV_FILE), 'ver' => '3.7.0'));
         PT_CV_Asset::enqueue('respond', 'script', array('src' => plugins_url('assets/ie-fix/respond.js', PT_CV_FILE), 'ver' => '1.4.2'));
     }
 }
示例#4
0
 /**
  * Styles for Preview & WP frontend
  *
  * @global bool $is_IE
  */
 static function frontend_styles()
 {
     PT_CV_Asset::enqueue('bootstrap', 'style');
     PT_CV_Asset::enqueue('public', 'style', array('src' => plugins_url('public/assets/css/public.css', PT_CV_FILE)));
     // Fix bootstrap error in IE
     global $is_IE;
     if ($is_IE) {
         PT_CV_Asset::enqueue('html5shiv', 'script', array('src' => plugins_url('assets/ie-fix/html5shiv.min.js', PT_CV_FILE), 'ver' => '3.7.0'));
         PT_CV_Asset::enqueue('respond', 'script', array('src' => plugins_url('assets/ie-fix/respond.js', PT_CV_FILE), 'ver' => '1.4.2'));
     }
     // Load Pro styles
     do_action(PT_CV_PREFIX_ . 'frontend_styles');
 }