Plugin Directory

Changeset 1859624


Ignore:
Timestamp:
04/17/2018 08:43:48 AM (8 years ago)
Author:
laugei
Message:

Change selector for better compatibility with other plugins

Location:
woo-variations-select2/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • woo-variations-select2/trunk/js/woo-variations-select2.min.js

    r1716576 r1859624  
    1 jQuery(document).ready(function(r){var a=r(".variations_form .variations");r(".variations_form .variations").find("select").select2({minimumResultsForSearch:-1,dropdownParent:a})});
     1jQuery(document).ready(function(e){e.each(e(".single-product select[data-attribute_name]"),function(t,n){e(n).select2({minimumResultsForSearch:-1,dropdownParent:e(n).closest(".variations")})})});
  • woo-variations-select2/trunk/readme.txt

    r1716576 r1859624  
    33Tags: woocommerce, variations, select2
    44Requires at least: 4.6
    5 Tested up to: 4.8.1
    6 Stable tag: 1.0.1
     5Tested up to: 4.9.5
     6Stable tag: 1.0.2
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2424
    2525== Changelog ==
     26### 1.0.2
     27
     28* Changed selector for better compatibility with other plugins.
     29
    2630### 1.0.1
    2731
  • woo-variations-select2/trunk/woo-variations-select2.php

    r1716576 r1859624  
    44Description: A simple plugin that enables Select2 for WooCommerce variations select boxes
    55Author: Sti3bas
    6 Version: 1.0.1
     6Version: 1.0.2
    77Author URI: https://github.com/sti3bas
    88*/
     
    1111 * Check if WooCommerce is active
    1212 **/
    13 if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    14     add_action( 'admin_notices', 'woovs2_woocommerce_inactive_notice' );
    15     return;
     13if (! in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
     14    add_action('admin_notices', 'woovs2_woocommerce_inactive_notice');
     15    return;
    1616}
    1717
    18 function woovs2_woocommerce_inactive_notice() {
    19     ?>
     18function woovs2_woocommerce_inactive_notice()
     19{
     20    ?>
    2021    <div id="message" class="error">
    21         <p><?=__( 'WooCommerce variations Select2 is inactive. The WooCommerce plugin must be active for WooCommerce variations Select2 to work. Please install & activate WooCommerce.',  'woocommerce-variations-select2' )?></p>
     22        <p>
     23            <?php echo __('WooCommerce variations Select2 is inactive. The WooCommerce plugin must be active for WooCommerce variations Select2 to work. Please install & activate WooCommerce.', 'woocommerce-variations-select2')?>
     24        </p>
    2225    </div>
    2326    <?php
    2427}
    2528
    26 function woovs2_enqueue_scripts() {
     29function woovs2_enqueue_scripts()
     30{
     31    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    2732
    28     $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     33    if (! wp_script_is('select2', 'enqueued')) {
     34        wp_enqueue_script('select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', ['jquery']);
     35    }
    2936
    30     if( ! wp_script_is( 'select2', 'enqueued' ) ) {
    31         wp_enqueue_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array('jquery') );
    32     }
     37    if (! wp_style_is('select2', 'enqueued')) {
     38        wp_enqueue_style('select2', WC()->plugin_url() . '/assets/css/select2.css', []);
     39    }
    3340
    34     if( ! wp_style_is( 'select2', 'enqueued' ) ) {
    35         wp_enqueue_style( 'select2', WC()->plugin_url() . '/assets/css/select2.css', array() );
    36     }
    37 
    38     wp_enqueue_script( 'woo-select2', plugin_dir_url( __FILE__ ) . 'js/woo-variations-select2' . $suffix . '.js', array('jquery', 'select2') );
     41    wp_enqueue_script('woo-select2', plugin_dir_url(__FILE__) . 'js/woo-variations-select2' . $suffix . '.js', ['jquery', 'select2']);
    3942}
    4043
    41 add_action( 'wp_enqueue_scripts', 'woovs2_enqueue_scripts' );
     44add_action('wp_enqueue_scripts', 'woovs2_enqueue_scripts');
    4245
    4346?>
Note: See TracChangeset for help on using the changeset viewer.