/** * Replace woo fragments script * * To update cart widget when language is switched */ public function replace_cart_fragments_script() { // remove the orginal wc-cart-fragments.js and register ours wp_deregister_script('wc-cart-fragments'); wp_enqueue_script('wc-cart-fragments', plugins_url('public/js/Cart.js', WOOPOLY_FILE), array('jquery', 'jquery-cookie'), Plugin::getVersion(), true); }
/** * Handle variation limitation about default language * * @global string $pagenow current page name * * @return boolean false if this is not new variable product */ public function handleVariableLimitation() { global $pagenow; if ($pagenow !== 'post-new.php') { return false; } if (isset($_GET['from_post'])) { return false; } if (pll_current_language() === pll_default_language()) { return false; } add_action('admin_print_scripts', function () { $jsID = 'variables-data'; $code = sprintf('var HYYAN_WPI_VARIABLES = {' . ' title : "%s" ,' . ' content : "%s" ,' . ' defaultLang : "%s"' . '};', __('Wrong default language for Variable Products', 'woopoly'), __("Variable products must be created in the default language first due to a plugin design limitation. <br> <a href='https://github.com/decarvalhoaa/woopoly/tree/master#what-you-need-to-know-about-this-plugin' target='_blank'>Read more</a>", 'woopoly'), pll_default_language()); Utilities::jsScriptWrapper($jsID, $code, false); }); add_action('admin_enqueue_scripts', function () { wp_enqueue_script('jquery-ui-core'); wp_enqueue_script("jquery-effects-core"); wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_script('woo-poly-variables', plugins_url('public/js/Variables.js', WOOPOLY_FILE), array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'), \Hyyan\WPI\Plugin::getVersion(), true); }, 100); }
/** * Replace woo fragments script. * * To update cart widget when language is switched */ public function replaceCartFragmentsScript() { /* remove the orginal wc-cart-fragments.js and register ours */ wp_deregister_script('wc-cart-fragments'); wp_enqueue_script('wc-cart-fragments', plugins_url('public/js/Cart.js', Hyyan_WPI_DIR), array('jquery', 'jquery-cookie'), Plugin::getVersion(), true); }