/**
  * Enqueue Scripts
  *
  * Register and enqueue scripts for Frontend
  *
  * @author Andrea Grillo <*****@*****.**>
  * @since 1.0
  * @return void
  */
 public function enqueue_scripts()
 {
     /* === Style === */
     wp_enqueue_style('yith-wcms-checkout', YITH_WCMS_ASSETS_URL . 'css/frontend.css', array(), '1.0.0');
     /* === Script === */
     $script = apply_filters('yith_wcms_main_script', 'multistep.js');
     $script = function_exists('yit_load_js_file') ? yit_load_js_file($script) : str_replace('.js', '.min.js', $script);
     wp_register_script('yith-wcms-step', YITH_WCMS_ASSETS_URL . 'js/' . $script, array('wc-checkout'), '1.0.1', true);
     wp_enqueue_script('yith-wcms-step');
     do_action('yith_wcms_enqueue_scripts');
 }
Example #2
0
 public function pointer_load($hook_suffix)
 {
     /**
      * Get pointers for this screen
      */
     $screen = get_current_screen();
     $pointers = apply_filters("yit_pointers-{$screen->id}", array());
     if (!$pointers || !is_array($pointers)) {
         return;
     }
     /**
      * Get dismissed pointers
      */
     $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
     $valid_pointers = array();
     //$point_id       = null;
     /**
      * show pointers only on plugin activate action
      */
     if (in_array($screen->id, $this->special_screen)) {
         $show = false;
         $registered = $this->get_plugins_init($screen->id);
         $recently_activate = get_option('yit_recently_activated', array());
         /**
          * For "plugins" screen
          */
         $is_single_activate = isset($_GET['activate']) && 'true' == $_GET['activate'] ? true : false;
         $is_multi_activate = isset($_GET['activate-multi']) && 'true' == $_GET['activate-multi'] ? true : false;
         /**
          * For "update" screen
          *
          * Single plugin update use GET method
          *
          * Multi update plugins with bulk action send two post args called "action" and "action2"
          * action refer to first bulk action button (at the top of plugins table)
          * action2 refer to last bulk action button (at the bottom of plugins table)
          *
          */
         $is_single_upgrade = isset($_GET['action']) && 'upgrade-plugin' == $_GET['action'] ? true : false;
         $is_multi_upgrade = isset($_POST['action']) && 'update-selected' == $_POST['action'] || isset($_POST['action2']) && 'update-selected' == $_POST['action2'] ? true : false;
         if ($is_single_activate || $is_single_upgrade) {
             $point_id = '';
             /**
              * Single activation plugin
              * Single update plugin
              */
             foreach ($registered as $init => $p_id) {
                 if (in_array($init, $recently_activate)) {
                     $point_id = $p_id;
                     $pointer = $pointers[$point_id];
                     /**
                      * Sanity check
                      */
                     if (!(in_array($point_id, $dismissed) || empty($pointer) || empty($point_id) || empty($pointer['target']) || empty($pointer['options']))) {
                         /**
                          * Add the pointer to $valid_pointers array
                          */
                         $pointer['pointer_id'] = $point_id;
                         $valid_pointers['pointers'][] = $pointer;
                         $show = true;
                     }
                     break;
                 }
             }
         } else {
             if ($is_multi_activate || $is_multi_upgrade) {
                 /**
                  * Bulk Action: multi plugins activation
                  * Bulk Action: multi plugins update
                  */
                 $point_id = array();
                 $screen_id = $screen->id;
                 if ($is_multi_upgrade && isset($_POST['checked']) && count($_POST['checked']) > 0) {
                     $recently_activate = $_POST['checked'];
                     $screen_id = 'update';
                     $pointers = apply_filters("yit_pointers-{$screen_id}", array());
                 }
                 foreach ($registered as $init => $p_id) {
                     if (in_array($init, $recently_activate)) {
                         $point_id[] = $p_id;
                     }
                 }
                 /**
                  * Bulk Action: Activate Plugins
                  *
                  * count( $point_id ) is the number of YITH plugins that have registered specific pointers
                  * case 0   -> No pointers -> Exit
                  * case 1   -> Only one pointers to show -> Use the specific plugin pointer
                  * defautl  -> Two or more plugins need to show a pointer -> use a generic pointers
                  *
                  */
                 switch (count($point_id)) {
                     case 0:
                         $show = false;
                         break;
                     case 1:
                         $point_id = array_pop($point_id);
                         $pointer = $pointers[$point_id];
                         /**
                          * Sanity check
                          */
                         if (!(in_array($point_id, $dismissed) || empty($pointer) || empty($point_id) || empty($pointer['target']) || empty($pointer['options']))) {
                             /**
                              * Add the pointer to $valid_pointers array
                              */
                             $pointer['pointer_id'] = $point_id;
                             $valid_pointers['pointers'][] = $pointer;
                             $show = true;
                         }
                         break;
                     default:
                         $valid_pointers['pointers'][] = $this->_default_pointer[$screen_id];
                         $show = true;
                         break;
                 }
             }
         }
         update_option('yit_recently_activated', array());
         if (!$show) {
             return;
         }
     } else {
         /**
          * Check pointers and remove dismissed ones.
          */
         foreach ($pointers as $pointer_id => $pointer) {
             /**
              * Sanity check
              */
             if (in_array($pointer_id, $dismissed) || empty($pointer) || empty($pointer_id) || empty($pointer['target']) || empty($pointer['options'])) {
                 continue;
             }
             $pointer['pointer_id'] = $pointer_id;
             /**
              * Add the pointer to $valid_pointers array
              */
             $valid_pointers['pointers'][] = $pointer;
         }
     }
     /**
      * No valid pointers? Stop here.
      */
     if (empty($valid_pointers)) {
         return;
     }
     $script_file = function_exists('yit_load_js_file') ? yit_load_js_file('yit-wp-pointer.js') : 'yit-wp-pointer.min.js';
     /**
      * Enqueue wp-pointer script and style
      */
     wp_enqueue_style('wp-pointer');
     wp_enqueue_script('wp-pointer');
     wp_enqueue_script('yit-wp-pointer', YIT_CORE_PLUGIN_URL . '/assets/js/' . $script_file, array('wp-pointer'), false, true);
     wp_localize_script('yit-wp-pointer', 'custom_pointer', $valid_pointers);
 }
 /**
  * Admin Enqueue Scripts
  *
  * @return void
  *
  * @since  1.0
  * @author Andrea Grillo <*****@*****.**>
  */
 public function admin_enqueue_scripts()
 {
     /**
      * Support to YIT Framework < 2.0
      */
     $filename = function_exists('yit_load_js_file') ? yit_load_js_file('yit-licence.js') : 'yit-licence.js';
     $script_path = defined('YIT_CORE_PLUGIN_URL') ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
     $style_path = defined('YIT_CORE_PLUGIN_URL') ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
     wp_enqueue_script('yit-licence', $script_path . '/licence/assets/js/' . $filename, array('jquery'), '1.0.0', true);
     wp_enqueue_style('yit-theme-licence', $style_path . '/licence/assets/css/yit-licence.css');
 }
Example #4
0
 /**
  * Enqueue script and styles in admin side
  *
  * Add style and scripts to administrator
  *
  * @return void
  * @since    1.0
  * @author   Emanuela Castorina <*****@*****.**>
  */
 public function enqueue()
 {
     wp_enqueue_media();
     wp_enqueue_style('wp-color-picker');
     wp_enqueue_style('yit-plugin-metaboxes', YIT_CORE_PLUGIN_URL . '/assets/css/metaboxes.css');
     wp_enqueue_style('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css');
     wp_enqueue_script('jquery-ui-datepicker');
     wp_enqueue_script('yit-spinner', YIT_CORE_PLUGIN_URL . '/assets/js/panel.spinner.js', array('jquery'), '0.0.1', true);
     wp_enqueue_script('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array('jquery'), '1.1.0', true);
     wp_enqueue_script('ajax-chosen', yit_load_js_file(YIT_CORE_PLUGIN_URL . '/assets/js/chosen/ajax-chosen.jquery.js'), array('jquery'), '1.1.0', true);
     wp_enqueue_script('yit-metabox', YIT_CORE_PLUGIN_URL . '/assets/js/metabox.js', array('jquery', 'wp-color-picker'), '1.0.0', true);
     wp_enqueue_style('jquery-ui-overcast', YIT_CORE_PLUGIN_URL . '/assets/css/overcast/jquery-ui-1.8.9.custom.css', false, '1.8.9', 'all');
 }
Example #5
0
 /**
  * Admin Enqueue Scripts
  *
  * @return void
  *
  * @since  1.0
  * @author Andrea Grillo <*****@*****.**>
  */
 public function admin_enqueue_scripts()
 {
     /**
      * Support to YIT Framework < 2.0
      */
     $filename = function_exists('yit_load_js_file') ? yit_load_js_file('yit-licence.js') : 'yit-licence.js';
     $script_path = defined('YIT_CORE_PLUGIN_URL') ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
     $style_path = defined('YIT_CORE_PLUGIN_URL') ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
     wp_enqueue_script('yit-licence', $script_path . '/licence/assets/js/' . $filename, array('jquery'), '1.0.0', true);
     wp_enqueue_style('yit-theme-licence', $style_path . '/licence/assets/css/yit-licence.css');
     /* Localize Scripts */
     wp_localize_script('yit-licence', 'licence_message', array('error' => sprintf(_x('%s field cannot be empty', '%s = field name', 'yith-plugin-fw'), '%field%'), 'errors' => sprintf(__('%s and %s fields cannot be empty', 'yith-plugin-fw'), '%field_1%', '%field_2%'), 'server' => __('Unable to contact the remote server, please try again later. Thanks!', 'yith-plugin-fw'), 'email' => __('Email', 'yith-plugin-fw'), 'license_key' => __('License Key', 'yith-plugin-fw'), 'are_you_sure' => __('Are you sure you want to deactivate the license for current site?', 'yith-plugin-fw')));
     wp_localize_script('yit-licence', 'script_info', array('is_debug' => defined('YIT_LICENCE_DEBUG') && YIT_LICENCE_DEBUG));
 }
 /**
  * Enqueue Style and Scripts
  *
  * @return   void
  * @since    1.0
  * @author   Andrea Grillo <*****@*****.**>
  * @fire yith_wpv_stylesheet_paths The stylesheet paths
  */
 public function enqueue_scripts()
 {
     /* === Main Stylesheet === */
     wp_enqueue_style('yith-wc-product-vendors', YITH_WPV_ASSETS_URL . 'css/product-vendors.css');
     /* === Theme Stylesheet === */
     $paths = apply_filters('yith_wpv_stylesheet_paths', array(WC()->template_path() . 'product-vendors.css', 'product-vendors.css'));
     $located = locate_template($paths, false, false);
     $search = array(get_stylesheet_directory(), get_template_directory());
     $replace = array(get_stylesheet_directory_uri(), get_template_directory_uri());
     if (!empty($located)) {
         $theme_stylesheet = str_replace($search, $replace, $located);
         wp_enqueue_style('yith-wc-product-vendors-theme', $theme_stylesheet);
     }
     /* === Font Awesome Sylesheet === */
     wp_enqueue_style('font-awesome', YITH_WPV_ASSETS_URL . 'third-party/font-awesome/css/font-awesome.min.css');
     /* === Scripts === */
     wp_register_script('imagesloaded', YITH_WPV_ASSETS_URL . 'third-party/imagesloaded/imagesloaded.pkgd.min.js', array('jquery'), '3.1.8', true);
     wp_register_script('gmaps-api', '//maps.google.com/maps/api/js?sensor=false&amp;language=en', array('jquery'));
     wp_register_script('gmap3', YITH_WPV_ASSETS_URL . 'third-party/gmap3/gmap3.min.js', array('jquery', 'gmaps-api'), '6.0.0', false);
     if ($this->is_vendor_page()) {
         wp_enqueue_script('gmap3');
     }
     /* Add PrettyPhoto if WooCommerce Lightbox is disabled and Report Abuse link activated */
     $show_report_abuse = 'none' != get_option('yith_wpv_report_abuse_link_text') ? true : false;
     if ($show_report_abuse && 'no' === get_option('woocommerce_enable_lightbox')) {
         $wc_assets_path = str_replace(array('http:', 'https:'), '', WC()->plugin_url()) . '/assets/';
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_enqueue_script('prettyPhoto', $wc_assets_path . 'js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.5', true);
         wp_enqueue_style('woocommerce_prettyPhoto_css', $wc_assets_path . 'css/prettyPhoto.css');
     }
     if ($show_report_abuse) {
         $args = array('ajaxurl' => admin_url('admin-ajax.php'), 'messages' => array('success' => __('Abuse reported correctly.', 'yith_wc_product_vendors'), 'empty' => __('All fields are mandatory.', 'yith_wc_product_vendors'), 'failed' => __('Your request could not be processed. Please try again', 'yith_wc_product_vendors')), 'classes' => array('success' => 'woocommerce-message', 'failed' => 'woocommerce-error', 'empty' => 'woocommerce-info'));
         wp_enqueue_script('yith-wpv-prettyPhoto-init', YITH_WPV_ASSETS_URL . 'js/init.prettyPhoto.js', array('jquery', 'prettyPhoto'), '1.0', true);
         wp_localize_script('yith-wpv-prettyPhoto-init', 'report_abuse', $args);
     }
     $js_file = function_exists('yit_load_js_file') ? yit_load_js_file('multi-vendor.js') : 'multi-vendor.min.js';
     wp_enqueue_script('product-vendors', YITH_WPV_ASSETS_URL . 'js/' . $js_file, array('jquery', 'imagesloaded'), '1.0', true);
     wp_localize_script('product-vendors', 'field_check', array('is_vat_require' => YITH_Vendors()->is_vat_require()));
 }