page = $page; } private function print_js_globals(){ $icl_ajax_url_root = rtrim ( get_site_url (), '/' ); if ( defined ( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ) { $icl_ajax_url_root = str_replace ( 'http://', 'https://', $icl_ajax_url_root ); } $icl_ajax_url = $icl_ajax_url_root . '/wp-admin/admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/languages.php'; ?> sitepress->get_default_language(); $current_language = $this->sitepress->get_current_language(); $page_basename = $this->page; $this->print_js_globals(); $wpml_script_setup_args['default_language'] = $default_language; $wpml_script_setup_args['current_language'] = $current_language; do_action('wpml_scripts_setup', $wpml_script_setup_args); if ( 'options-reading.php' === $pagenow ) { $this->print_reading_options_js(); } elseif ( in_array( $pagenow, array( 'categories.php', 'edit-tags.php', 'edit.php' ), true ) && $current_language !== $default_language ) { $this->correct_status_links_js( $current_language ); } if ( 'edit-tags.php' === $pagenow ) { ?> post_translations->get_element_translations( false, $trid ); remove_filter( 'pre_option_sticky_posts', array( $sitepress, 'option_sticky_posts' ) ); // remove filter used to get language relevant stickies. get them all $sticky_posts = get_option( 'sticky_posts' ); add_filter( 'pre_option_sticky_posts', array( $sitepress, 'option_sticky_posts' ), 10, 2 ); // add filter back $is_sticky = false; foreach ( $translations as $t ) { if ( in_array( $t, $sticky_posts ) ) { $is_sticky = true; break; } } if ( $this->sitepress->get_setting( 'sync_ping_status' ) || $this->sitepress->get_setting( 'sync_comment_status' ) ) { $this->print_ping_and_comment_sync_js( $trid, $source_lang ); } if ($this->sitepress->get_setting( 'sync_private_flag' ) && 'private' === $this->post_translations->get_original_post_status ( $trid, $source_lang ) ) { ?> sitepress->get_setting( 'sync_post_taxonomies' ) ) { $this->print_tax_sync_js(); } $custom_field_note = new WPML_Sync_Custom_Field_Note( $this->sitepress ); $custom_field_note->print_sync_copy_custom_field_note( $source_lang, $translations ); } ?> sitepress->get_setting( 'sync_sticky_flag' ) ): ?> sitepress->get_setting( 'sync_page_template' ) || $this->sitepress->get_setting( 'sync_page_ordering' ) ) ) ) { $this->print_mo_sync_js( $trid, $source_lang ); } if ( $this->sitepress->is_post_edit_screen() && $this->sitepress->get_setting( 'sync_post_date' ) ) { $this->print_sync_date_js(); } if ( 'post-new.php' === $pagenow && isset( $_GET[ 'trid' ] ) && $sitepress->get_setting( 'sync_post_format' ) && function_exists ( 'get_post_format' ) ) { $format = $this->post_translations->get_original_post_format($trid, $source_lang); ?> sitepress->get_setting( 'sync_page_ordering' ) ? $this->post_translations->get_original_menu_order( $trid, $source_lang ) : null; $page_template = $this->sitepress->get_setting( 'sync_page_template' ) ? get_post_meta( $this->post_translations->get_element_id( $source_lang, $trid ), '_wp_page_template', true ) : null; if ( $menu_order || $page_template ) { ?> get_current_req_post_id(); if ( $post_id !== null ) { $original_id = $this->post_translations->get_original_element( $post_id ); if ( $original_id && (int) $original_id !== (int) $post_id ) { $original_date = get_post_field( 'post_date', $original_id ); $exp = explode( ' ', $original_date ); list( $aa, $mm, $jj ) = explode( '-', $exp[0] ); list( $hh, $mn, $ss ) = explode( ':', $exp[1] ); ?> sitepress->get_default_language(); $current_lang = $this->sitepress->get_current_language(); $translatable_taxs = $this->sitepress->get_translatable_taxonomies( true, $post_type ); $all_taxs = get_object_taxonomies( $post_type ); $translations = $this->sitepress->get_element_translations( $_GET['trid'], 'post_' . $post_type ); $js = array(); foreach ( $all_taxs as $tax ) { $tax_detail = get_taxonomy( $tax ); $terms = get_the_terms( $translations[ $source_lang ]->element_id, $tax ); $term_names = array(); if ( $terms ) { foreach ( $terms as $term ) { if ( $tax_detail->hierarchical ) { $term_id = in_array( $tax, $translatable_taxs ) ? $this->term_translations->term_id_in( $term->term_id, $current_lang, false ) : $term->term_id; $js[] = "jQuery('#in-" . $tax . "-" . $term_id . "').attr('checked', 'checked');"; } else { if ( in_array( $tax, $translatable_taxs ) ) { $term_id = $this->term_translations->term_id_in( $term->term_id, $current_lang, false ); if ( $term_id ) { $term = get_term( $term_id, $tax ); $term_names[] = esc_js( $term->name ); } } else { $term_names[] = esc_js( $term->name ); } } } } if ( $term_names ) { $js[] = "jQuery('#{$tax} .taghint').css('visibility','hidden');"; $js[] = "jQuery('#new-tag-{$tax}').val('" . join( ', ', $term_names ) . "');"; } } if ( $js ) { echo ''; } } private function get_current_req_post_id() { return isset( $_GET['post'] ) ? filter_var( $_GET['post'], FILTER_SANITIZE_NUMBER_INT ) : null; } private function print_reading_options_js(){ list( $warn_home, $warn_posts ) = $this->verify_home_and_blog_pages_translations (); if ( $warn_home || $warn_posts ) { ?> missing_page_warning ( $page_on_front, __ ( 'Your home page does not exist or its translation is not published in %s.', 'sitepress' ) ); } $page_for_posts = get_option ( 'page_for_posts' ); if ( $page_for_posts ) { $warn_posts = $this->missing_page_warning ( $page_for_posts, __ ( 'Your blog page does not exist or its translation is not published in %s.', 'sitepress' ), 'margin-top:4px;' ); } return array( $warn_home, $warn_posts ); } /** * @param int $original_page_id * @param string $label * @param string $additional_css * * @return string */ private function missing_page_warning( $original_page_id, $label, $additional_css = '' ) { $warn_posts = ''; if ( $original_page_id ) { $page_posts_translations = $this->post_translations->get_element_translations( $original_page_id ); $missing_posts = array(); $active_languages = $this->sitepress->get_active_languages(); foreach ( $active_languages as $lang ) { if ( ! isset( $page_posts_translations[ $lang['code'] ] ) || get_post_status( $page_posts_translations[ $lang['code'] ] ) !== 'publish' ) { $missing_posts[] = $lang['display_name']; } } if ( ! empty( $missing_posts ) ) { $warn_posts = '
'; $warn_posts .= sprintf( $label, join( ', ', $missing_posts ) ); $warn_posts .= '
'; $warn_posts .= '' . __( 'Edit this page to add translations', 'sitepress' ) . ''; $warn_posts .= '
'; } } return $warn_posts; } }