| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Manages filters and actions related to the classic editor |
| 8 | 5 | * |
| @@ -24,9 +21,9 @@ | ||
| 24 | 21 | $this->curlang = &$polylang->curlang; |
| 25 | 22 | $this->pref_lang = &$polylang->pref_lang; |
| 26 | 23 | |
| 27 | 24 | // Adds the Languages box in the 'Edit Post' and 'Edit Page' panels |
| 28 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); | |
| 25 | + add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 2 ); | |
| 29 | 26 | |
| 30 | 27 | // Ajax response for changing the language in the post metabox |
| 31 | 28 | add_action( 'wp_ajax_post_lang_choice', array( $this, 'post_lang_choice' ) ); |
| 32 | 29 | add_action( 'wp_ajax_pll_posts_not_translated', array( $this, 'ajax_posts_not_translated' ) ); |
| @@ -43,10 +40,11 @@ | ||
| 43 | 40 | * |
| 44 | 41 | * @since 0.1 |
| 45 | 42 | * |
| 46 | 43 | * @param string $post_type Current post type |
| 44 | + * @param object $post Current post | |
| 47 | 45 | */ |
| 48 | - public function add_meta_boxes( $post_type ) { | |
| 46 | + public function add_meta_boxes( $post_type, $post ) { | |
| 49 | 47 | if ( $this->model->is_translated_post_type( $post_type ) ) { |
| 50 | 48 | add_meta_box( |
| 51 | 49 | 'ml_box', |
| 52 | 50 | __( 'Languages', 'polylang' ), |
| @@ -69,9 +67,9 @@ | ||
| 69 | 67 | public function post_language() { |
| 70 | 68 | global $post_ID; |
| 71 | 69 | $post_type = get_post_type( $post_ID ); |
| 72 | 70 | |
| 73 | - // phpcs:ignore WordPress.Security.NonceVerification, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 71 | + // phpcs:ignore WordPress.Security.NonceVerification, WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable | |
| 74 | 72 | $from_post_id = isset( $_GET['from_post'] ) ? (int) $_GET['from_post'] : 0; |
| 75 | 73 | |
| 76 | 74 | $lang = ( $lg = $this->model->post->get_language( $post_ID ) ) ? $lg : |
| 77 | 75 | ( isset( $_GET['new_lang'] ) ? $this->model->get_language( sanitize_key( $_GET['new_lang'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification |
| @@ -113,13 +111,9 @@ | ||
| 113 | 111 | do_action( 'pll_before_post_translations', $post_type ); |
| 114 | 112 | |
| 115 | 113 | echo '<div id="post-translations" class="translations">'; |
| 116 | 114 | if ( $lang ) { |
| 117 | - if ( 'attachment' === $post_type ) { | |
| 118 | - include __DIR__ . '/view-translations-media.php'; | |
| 119 | - } else { | |
| 120 | - include __DIR__ . '/view-translations-post.php'; | |
| 121 | - } | |
| 115 | + include PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php'; | |
| 122 | 116 | } |
| 123 | 117 | echo '</div>' . "\n"; |
| 124 | 118 | } |
| 125 | 119 | |
| @@ -157,13 +151,9 @@ | ||
| 157 | 151 | $this->model->post->save_translations( $post_ID, $translations ); |
| 158 | 152 | |
| 159 | 153 | ob_start(); |
| 160 | 154 | if ( $lang ) { |
| 161 | - if ( 'attachment' === $post_type ) { | |
| 162 | - include __DIR__ . '/view-translations-media.php'; | |
| 163 | - } else { | |
| 164 | - include __DIR__ . '/view-translations-post.php'; | |
| 165 | - } | |
| 155 | + include PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php'; | |
| 166 | 156 | } |
| 167 | 157 | $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) ); |
| 168 | 158 | ob_end_clean(); |
| 169 | 159 | |