| @@ -134,22 +134,23 @@ | ||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 137 | 137 | |
| 138 | - // For each script: | |
| 139 | - // 0 => the pages on which to load the script | |
| 140 | - // 1 => the scripts it needs to work | |
| 141 | - // 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise | |
| 142 | - // 3 => 1 if loaded in footer | |
| 143 | - // FIXME: check if I can load more scripts in footer | |
| 138 | + /* | |
| 139 | + * For each script: | |
| 140 | + * 0 => the pages on which to load the script | |
| 141 | + * 1 => the scripts it needs to work | |
| 142 | + * 2 => 1 if loaded even if languages have not been defined yet, 0 otherwise | |
| 143 | + * 3 => 1 if loaded in footer | |
| 144 | + */ | |
| 144 | 145 | $scripts = array( |
| 145 | - 'post' => array( array( 'edit', 'upload' ), array( 'jquery', 'wp-ajax-response' ), 0, 1 ), | |
| 146 | - 'term' => array( array( 'edit-tags', 'term' ), array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), 0, 1 ), | |
| 147 | - 'user' => array( array( 'profile', 'user-edit' ), array( 'jquery' ), 0, 0 ), | |
| 148 | - 'widgets' => array( array( 'widgets' ), array( 'jquery' ), 0, 0 ), | |
| 146 | + 'user' => array( array( 'profile', 'user-edit' ), array( 'jquery' ), 0, 0 ), | |
| 147 | + 'widgets' => array( array( 'widgets' ), array( 'jquery' ), 0, 0 ), | |
| 149 | 148 | ); |
| 150 | 149 | |
| 151 | 150 | if ( ! empty( $screen->post_type ) && $this->model->is_translated_post_type( $screen->post_type ) ) { |
| 151 | + $scripts['post'] = array( array( 'edit', 'upload' ), array( 'jquery', 'wp-ajax-response' ), 0, 1 ); | |
| 152 | + | |
| 152 | 153 | // Classic editor. |
| 153 | 154 | if ( ! method_exists( $screen, 'is_block_editor' ) || ! $screen->is_block_editor() ) { |
| 154 | 155 | $scripts['classic-editor'] = array( array( 'post', 'media', 'async-upload' ), array( 'jquery', 'wp-ajax-response', 'post' ), 0, 1 ); |
| 155 | 156 | } |
| @@ -157,8 +158,12 @@ | ||
| 157 | 158 | // Block editor with legacy metabox in WP 5.0+. |
| 158 | 159 | if ( method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor() && ! pll_use_block_editor_plugin() ) { |
| 159 | 160 | $scripts['block-editor'] = array( array( 'post' ), array( 'jquery', 'wp-ajax-response', 'wp-api-fetch' ), 0, 1 ); |
| 160 | 161 | } |
| 162 | + } | |
| 163 | + | |
| 164 | + if ( ! empty( $screen->taxonomy ) && $this->model->is_translated_taxonomy( $screen->taxonomy ) ) { | |
| 165 | + $scripts['term'] = array( array( 'edit-tags', 'term' ), array( 'jquery', 'wp-ajax-response', 'jquery-ui-autocomplete' ), 0, 1 ); | |
| 161 | 166 | } |
| 162 | 167 | |
| 163 | 168 | foreach ( $scripts as $script => $v ) { |
| 164 | 169 | if ( in_array( $screen->base, $v[0] ) && ( $v[2] || $this->model->get_languages_list() ) ) { |