/** * * LOAD SCRIPTS IF REQUIRED * */ function wr2x_wp_enqueue_scripts() { global $wr2x_version, $wr2x_retinajs, $wr2x_retina_image, $wr2x_picturefill, $wr2x_lazysizes; $method = wr2x_getoption("method", "wr2x_advanced", 'Picturefill'); if (is_admin() && !wr2x_getoption("retina_admin", "wr2x_advanced", false)) { return; } // Picturefill if ($method == "Picturefill") { if (wr2x_is_debug()) { wp_enqueue_script('wr2x-debug', plugins_url('/js/debug.js', __FILE__), array(), $wr2x_version, false); } // Picturefill if (!wr2x_getoption("picturefill_noscript", "wr2x_advanced", false)) { wp_enqueue_script('picturefill', plugins_url('/js/picturefill.min.js', __FILE__), array(), $wr2x_picturefill, false); } // Lazysizes if (wr2x_getoption("picturefill_lazysizes", "wr2x_advanced", false) && wr2x_is_pro()) { wp_enqueue_script('lazysizes', plugins_url('/js/lazysizes.min.js', __FILE__), array(), $wr2x_lazysizes, false); } return; } // Debug + HTML Rewrite = No JS! if (wr2x_is_debug() && $method == "HTML Rewrite") { return; } // Debug mode, we force the devicePixelRatio to be Retina if (wr2x_is_debug()) { wp_enqueue_script('wr2x-debug', plugins_url('/js/debug.js', __FILE__), array(), $wr2x_version, false); } else { if (wr2x_getoption("ignore_mobile", "wr2x_advanced", false)) { $mobileDetect = new Mobile_Detect(); if ($mobileDetect->isMobile()) { return; } } } // Retina-Images and HTML Rewrite both need the devicePixelRatio cookie on the server-side if ($method == "Retina-Images" || $method == "HTML Rewrite") { wp_enqueue_script('retina-images', plugins_url('/js/retina-cookie.js', __FILE__), array(), $wr2x_retina_image, false); } // Retina.js only needs itself if ($method == "retina.js") { wp_enqueue_script('retinajs', plugins_url('/js/retina.min.js', __FILE__), array(), $wr2x_retinajs, true); } }
/** * * LOAD SCRIPTS IF REQUIRED * */ function wr2x_wp_enqueue_scripts() { global $wr2x_version, $wr2x_retinajs, $wr2x_retina_image; $method = wr2x_getoption("method", "wr2x_advanced", 'retina.js'); // Debug + HTML Rewrite = No JS! if (wr2x_is_debug() && $method == "HTML Rewrite") { return; } // Debug mode, we force the devicePixelRatio to be Retina if (wr2x_is_debug()) { wp_enqueue_script('debug', plugins_url('/js/debug.js', __FILE__), array(), $wr2x_version, false); } else { if (wr2x_getoption("ignore_mobile", "wr2x_advanced", false)) { $mobileDetect = new Mobile_Detect(); if ($mobileDetect->isMobile()) { return; } } } // Retina-Images and HTML Rewrite both need the devicePixelRatio cookie on the server-side if ($method == "Retina-Images" || $method == "HTML Rewrite") { wp_enqueue_script('retina-images', plugins_url('/js/retina-cookie.js', __FILE__), array(), $wr2x_retina_image, false); } // Retina.js only needs itself if ($method == "retina.js") { wp_enqueue_script('retinajs', plugins_url('/js/retina.js', __FILE__), array(), $wr2x_retinajs, true); } }