| @@ -55,13 +55,15 @@ | ||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | if ( is_admin() ) { |
| 58 | 58 | add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) ); |
| 59 | + add_action( 'admin_print_scripts', array( $this, 'localize_printed_admin_scripts' ) ); | |
| 60 | + // Use for modal search items, modal search users when edit manual LP Order ue Vue js. | |
| 59 | 61 | add_action( 'admin_print_footer_scripts', array( $this, 'localize_printed_admin_scripts' ) ); |
| 60 | 62 | } else { |
| 61 | 63 | add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ), $priority ); |
| 62 | 64 | add_action( 'wp_print_scripts', array( $this, 'localize_printed_scripts' ), $priority + 10 ); |
| 63 | - add_action( 'wp_print_footer_scripts', array( $this, 'localize_printed_scripts' ), $priority + 10 ); | |
| 65 | + //add_action( 'wp_print_footer_scripts', array( $this, 'localize_printed_scripts' ), $priority + 10 ); | |
| 64 | 66 | } |
| 65 | 67 | } |
| 66 | 68 | |
| 67 | 69 | abstract function load_scripts(); |
| @@ -104,12 +106,20 @@ | ||
| 104 | 106 | |
| 105 | 107 | // For version addon. |
| 106 | 108 | if ( ! LP_Debug::is_debug() && ! empty( $script->_version ) ) { |
| 107 | 109 | self::$_version_assets = $script->_version; |
| 110 | + } elseif ( LP_Debug::is_debug() ) { | |
| 111 | + self::$_version_assets = time(); | |
| 112 | + } else { | |
| 113 | + self::$_version_assets = LEARNPRESS_VERSION; | |
| 108 | 114 | } |
| 109 | 115 | // End |
| 110 | 116 | |
| 111 | 117 | wp_register_script( $handle, $script->_url, $script->_deps, self::$_version_assets, $script->_in_footer ); |
| 118 | + // Add strategy for script defer/async. @since 4.2.5.5 | |
| 119 | + foreach ( $script->_strategy as $key => $value ) { | |
| 120 | + wp_script_add_data( $handle, $key, $value ); | |
| 121 | + } | |
| 112 | 122 | |
| 113 | 123 | if ( ! $script->_only_register ) { |
| 114 | 124 | $can_load_js = $this->check_can_load_asset( $handle, $page_current, $script->_screens, $script->_exclude_screens ); |
| 115 | 125 | |
| @@ -123,8 +133,9 @@ | ||
| 123 | 133 | * Set translate on file js of folder js/dist |
| 124 | 134 | * Path translate of a string on file ".pot" if have must map to js/dist |
| 125 | 135 | */ |
| 126 | 136 | wp_set_script_translations( 'lp-quiz', 'learnpress' ); |
| 137 | + wp_set_script_translations( 'lp-profile', 'learnpress' ); | |
| 127 | 138 | wp_set_script_translations( 'lp-admin', 'learnpress' ); |
| 128 | 139 | } |
| 129 | 140 | |
| 130 | 141 | /** |
| @@ -138,9 +149,9 @@ | ||
| 138 | 149 | protected function handle_style( string $page_current = '' ) { |
| 139 | 150 | $styles = $this->_get_styles(); |
| 140 | 151 | if ( $styles ) { |
| 141 | 152 | /** |
| 142 | - * @var LP_Asset_Key[] $style | |
| 153 | + * @var LP_Asset_Key[] $styles | |
| 143 | 154 | */ |
| 144 | 155 | foreach ( $styles as $handle => $style ) { |
| 145 | 156 | if ( ! $style instanceof LP_Asset_Key ) { |
| 146 | 157 | continue; |
| @@ -148,8 +159,12 @@ | ||
| 148 | 159 | |
| 149 | 160 | // For version addon. |
| 150 | 161 | if ( ! LP_Debug::is_debug() && ! empty( $style->_version ) ) { |
| 151 | 162 | self::$_version_assets = $style->_version; |
| 163 | + } elseif ( LP_Debug::is_debug() ) { | |
| 164 | + self::$_version_assets = time(); | |
| 165 | + } else { | |
| 166 | + self::$_version_assets = LEARNPRESS_VERSION; | |
| 152 | 167 | } |
| 153 | 168 | // End |
| 154 | 169 | |
| 155 | 170 | wp_register_style( $handle, $style->_url, $style->_deps, self::$_version_assets ); |
| @@ -351,9 +366,8 @@ | ||
| 351 | 366 | if ( is_admin() ) { |
| 352 | 367 | $wp_scripts->print_extra_script( $handle ); |
| 353 | 368 | } |
| 354 | 369 | } |
| 355 | - | |
| 356 | 370 | } |
| 357 | 371 | |
| 358 | 372 | public function localize_printed_admin_scripts() { |
| 359 | 373 | $this->localize_printed_scripts( 'admin' ); |