| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Base class for both admin |
| 8 | 5 | * |
| @@ -22,9 +19,9 @@ | ||
| 22 | 19 | public function __construct( &$links_model ) { |
| 23 | 20 | parent::__construct( $links_model ); |
| 24 | 21 | |
| 25 | 22 | // Plugin i18n, only needed for backend |
| 26 | - load_plugin_textdomain( 'polylang' ); | |
| 23 | + load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); | |
| 27 | 24 | |
| 28 | 25 | // Adds the link to the languages panel in the WordPress admin menu |
| 29 | 26 | add_action( 'admin_menu', array( $this, 'add_menus' ) ); |
| 30 | 27 | |
| @@ -32,8 +29,15 @@ | ||
| 32 | 29 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
| 33 | 30 | add_action( 'admin_print_footer_scripts', array( $this, 'admin_print_footer_scripts' ), 0 ); // High priority in case an ajax request is sent by an immediately invoked function |
| 34 | 31 | |
| 35 | 32 | add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls_enqueue_scripts' ) ); |
| 33 | + | |
| 34 | + if ( defined( 'POLYLANG_PRO' ) ) { | |
| 35 | + new PLL_Pro(); | |
| 36 | + } elseif ( ! defined( 'PLL_LINGOTEK_AD' ) || PLL_LINGOTEK_AD ) { | |
| 37 | + require_once POLYLANG_DIR . '/lingotek/lingotek.php'; // Lingotek | |
| 38 | + add_action( 'wp_loaded', array( new PLL_Lingotek(), 'init' ) ); | |
| 39 | + } | |
| 36 | 40 | } |
| 37 | 41 | |
| 38 | 42 | /** |
| 39 | 43 | * Setups filters and action needed on all admin pages and on plugins page |
| @@ -45,8 +49,16 @@ | ||
| 45 | 49 | parent::init(); |
| 46 | 50 | |
| 47 | 51 | $this->notices = new PLL_Admin_Notices( $this ); |
| 48 | 52 | |
| 53 | + if ( Polylang::is_wizard() && class_exists( 'PLL_Wizard_Pro' ) ) { | |
| 54 | + // Instantiate PLL_Wizard_Pro class after all PLL_Admin object is all initialized. | |
| 55 | + // After PLL_Admin::maybe_load_sync_post which is hooked on admin_init with priority 20. | |
| 56 | + add_action( 'admin_init', array( $this, 'instantiate_wizard_pro' ), 30 ); | |
| 57 | + } | |
| 58 | + | |
| 59 | + $this->wizard = new PLL_Wizard( $this ); | |
| 60 | + | |
| 49 | 61 | if ( ! $this->model->get_languages_list() ) { |
| 50 | 62 | return; |
| 51 | 63 | } |
| 52 | 64 | |
| @@ -60,8 +72,14 @@ | ||
| 60 | 72 | add_filter( 'request', array( $this, 'request' ) ); |
| 61 | 73 | |
| 62 | 74 | // Adds the languages in admin bar |
| 63 | 75 | add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); // 100 determines the position |
| 76 | + | |
| 77 | + // Translate slugs, only for pretty permalinks | |
| 78 | + if ( get_option( 'permalink_structure' ) && class_exists( 'PLL_Translate_Slugs' ) ) { | |
| 79 | + $slugs_model = new PLL_Translate_Slugs_Model( $this ); | |
| 80 | + $this->translate_slugs = new PLL_Translate_Slugs( $slugs_model, $this->curlang ); | |
| 81 | + } | |
| 64 | 82 | } |
| 65 | 83 | |
| 66 | 84 | /** |
| 67 | 85 | * Adds the link to the languages panel in the WordPress admin menu |
| @@ -176,8 +194,24 @@ | ||
| 176 | 194 | * |
| 177 | 195 | * @since 2.4.0 |
| 178 | 196 | */ |
| 179 | 197 | public function localize_scripts() { |
| 198 | + if ( wp_script_is( 'pll_classic-editor', 'enqueued' ) ) { | |
| 199 | + wp_localize_script( | |
| 200 | + 'pll_classic-editor', | |
| 201 | + 'confirm_text', | |
| 202 | + __( 'You are about to overwrite an existing translation. Are you sure you want to proceed?', 'polylang' ) | |
| 203 | + ); | |
| 204 | + } | |
| 205 | + | |
| 206 | + if ( wp_script_is( 'pll_block-editor', 'enqueued' ) ) { | |
| 207 | + wp_localize_script( | |
| 208 | + 'pll_block-editor', | |
| 209 | + 'confirm_text', | |
| 210 | + __( 'You are about to overwrite an existing translation. Are you sure you want to proceed?', 'polylang' ) | |
| 211 | + ); | |
| 212 | + } | |
| 213 | + | |
| 180 | 214 | if ( wp_script_is( 'pll_widgets', 'enqueued' ) ) { |
| 181 | 215 | wp_localize_script( |
| 182 | 216 | 'pll_widgets', |
| 183 | 217 | 'pll_widgets', |
| @@ -404,6 +438,14 @@ | ||
| 404 | 438 | 'meta' => 'all' === $lang->slug ? array() : array( 'lang' => esc_attr( $lang->get_locale( 'display' ) ) ), |
| 405 | 439 | ) |
| 406 | 440 | ); |
| 407 | 441 | } |
| 442 | + } | |
| 443 | + /** | |
| 444 | + * Instantiate PLL_Wizard_Pro class. | |
| 445 | + * | |
| 446 | + * @since 2.7 | |
| 447 | + */ | |
| 448 | + public function instantiate_wizard_pro() { | |
| 449 | + $this->wizard_pro = new PLL_Wizard_Pro( $this ); | |
| 408 | 450 | } |
| 409 | 451 | } |