Plugin Directory

Changeset 2140636


Ignore:
Timestamp:
08/16/2019 02:04:14 PM (7 years ago)
Author:
wsmeu
Message:

Only enqueue styles and scripts on plugin related pages

Location:
color-system-visualizer
Files:
64 added
3 edited

Legend:

Unmodified
Added
Removed
  • color-system-visualizer/trunk/color-system-visualizer.php

    r2083565 r2140636  
    66Author: WSM – Walter Solbach Metallbau GmbH
    77Author URI: https://www.wsm.eu/
    8 Version: 1.1.2
     8Version: 1.1.3
    99Text Domain:
    1010Domain Path: /languages
  • color-system-visualizer/trunk/includes/cpm_enqueue_files.php

    r2083565 r2140636  
    44/* Enqueue Scripts for frontend */
    55function cpm_color_palette_scripts() {
    6     /* Enqueue CSS */
    7     // check if need to
    8     if( ( !empty( esc_attr( get_option( 'cpm_load_btstrp' ) ) ) ) && ( esc_attr( get_option( 'cpm_load_btstrp' ) ) == 'yes' ) ) {
    9         wp_register_style( 'cpm_bootstrap', plugins_url( 'css/bootstrap.min.css',__FILE__ ), false, '3.4.0' );
    10         wp_enqueue_style( 'cpm_bootstrap' );
    11     }
    12     wp_register_style( 'cpm_jquery_dataTables', plugins_url( 'css/jquery.dataTables.min.css',__FILE__ ), true, '1.10.19' );
    13     wp_enqueue_style( 'cpm_jquery_dataTables' );
    14     wp_register_style( 'cpm_deafault_css', plugins_url( 'css/cpm_deafault.css',__FILE__ ), true, '1.0.0' );
    15     wp_enqueue_style( 'cpm_deafault_css' );
    166
    17     /* Enqueue JS */
    18     wp_enqueue_script( 'cpm_jquery_dataTables', plugins_url( 'js/jquery.dataTables.min.js',__FILE__ ), array('jquery'), '1.10.19', true );
     7    // Check for current template file name and only enqueue styles + scripts if on a cpm page:
     8    global $template;
     9    if ( basename($template) == 'cpm-archive-template.php' || basename($template) == 'cpm-single-template.php' ) :
    1910
    20     // get current language in order to decide which json file for dataTable to load
    21     switch (get_locale()) {
    22         case 'de_DE':
    23         case 'de_DE_formal':
    24         case 'de_AT':
    25         case 'de_CH':
    26             $locale_file = plugins_url( '../languages/dataTables.de_DE.lang', __FILE__ );
    27             $locale_file = explode(site_url(), $locale_file)[1];
    28             break;
    29        
    30         default:
    31             $locale_file = plugins_url( '../languages/dataTables.en_GB.lang', __FILE__ );
    32             $locale_file = explode(site_url(), $locale_file)[1];
    33             break;
    34     }
    35     wp_add_inline_script( 'cpm_jquery_dataTables', 'jQuery(document).ready(function($){jQuery("#cpm_ColorTable").DataTable({"initComplete":function(settings,json){cpmTableListener()},"lengthMenu":[[10, 25, 50, -1],[10, 25, 50, "∞"]],"language":{"url":"' . $locale_file . '",},});});' );
    36     wp_enqueue_script( 'cpm_default_js', plugins_url( 'js/default.js',__FILE__ ), array('jquery'), '1.0.0', true );
     11        /* Enqueue CSS */
     12        // check if need to
     13        if( ( !empty( esc_attr( get_option( 'cpm_load_btstrp' ) ) ) ) && ( esc_attr( get_option( 'cpm_load_btstrp' ) ) == 'yes' ) ) {
     14            wp_register_style( 'cpm_bootstrap', plugins_url( 'css/bootstrap.min.css',__FILE__ ), false, '3.4.0' );
     15            wp_enqueue_style( 'cpm_bootstrap' );
     16        }
     17        wp_register_style( 'cpm_jquery_dataTables', plugins_url( 'css/jquery.dataTables.min.css',__FILE__ ), true, '1.10.19' );
     18        wp_enqueue_style( 'cpm_jquery_dataTables' );
     19        wp_register_style( 'cpm_deafault_css', plugins_url( 'css/cpm_deafault.css',__FILE__ ), true, '1.0.0' );
     20        wp_enqueue_style( 'cpm_deafault_css' );
     21
     22        /* Enqueue JS */
     23        wp_enqueue_script( 'cpm_jquery_dataTables', plugins_url( 'js/jquery.dataTables.min.js',__FILE__ ), array('jquery'), '1.10.19', true );
     24
     25        // get current language in order to decide which json file for dataTable to load
     26        switch (get_locale()) {
     27            case 'de_DE':
     28            case 'de_DE_formal':
     29            case 'de_AT':
     30            case 'de_CH':
     31                $locale_file = plugins_url( '../languages/dataTables.de_DE.lang', __FILE__ );
     32                $locale_file = explode(site_url(), $locale_file)[1];
     33                break;
     34           
     35            default:
     36                $locale_file = plugins_url( '../languages/dataTables.en_GB.lang', __FILE__ );
     37                $locale_file = explode(site_url(), $locale_file)[1];
     38                break;
     39        }
     40        wp_add_inline_script( 'cpm_jquery_dataTables', 'jQuery(document).ready(function($){jQuery("#cpm_ColorTable").DataTable({"initComplete":function(settings,json){cpmTableListener()},"lengthMenu":[[10, 25, 50, -1],[10, 25, 50, "∞"]],"language":{"url":"' . $locale_file . '",},});});' );
     41        wp_enqueue_script( 'cpm_default_js', plugins_url( 'js/default.js',__FILE__ ), array('jquery'), '1.0.0', true );
     42
     43    endif;
    3744}
    3845add_action( 'wp_enqueue_scripts', 'cpm_color_palette_scripts' );
  • color-system-visualizer/trunk/readme.txt

    r2083565 r2140636  
    33Tags: color, colour, color palette, colour palette, color manager, colour manager, color system, colour system, ral, hks, pantone
    44Requires at least:
    5 Tested up to: 5.1.1
    6 Stable tag: 1.1.2
     5Tested up to: 5.2.2
     6Stable tag: 1.1.3
    77License: GPLv3
    88License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3434== Changelog ==
    3535
     36= 1.1.3 =
     37* Only enqueue styles and scripts on plugin related pages
     38
    3639= 1.1.2 =
    3740* Bugfixed displaying single color on ajax search
Note: See TracChangeset for help on using the changeset viewer.