page = $page; } public function add_admin_hooks() { add_action( 'admin_print_scripts', array( $this, 'wpml_js_scripts_setup' ) ); add_action( 'admin_print_styles', array( $this, 'wpml_css_setup' ) ); } public function register_styles() { wp_register_style( 'otgs-dialogs', ICL_PLUGIN_URL . '/res/css/otgs-dialogs.css', array( 'wp-jquery-ui-dialog' ), ICL_SITEPRESS_VERSION ); wp_register_style( 'wpml-dialog', ICL_PLUGIN_URL . '/res/css/dialog.css', array( 'otgs-dialogs' ), ICL_SITEPRESS_VERSION ); wp_register_style( 'otgs-ico', ICL_PLUGIN_URL . '/res/css/otgs-ico.css', null, ICL_SITEPRESS_VERSION ); wp_register_style( 'wpml-wizard', ICL_PLUGIN_URL . '/res/css/wpml-wizard.css', null, ICL_SITEPRESS_VERSION ); wp_register_style( 'wpml-popover-tooltip', ICL_PLUGIN_URL . '/dist/css/shared/wpml-popover-tooltip.css', null, ICL_SITEPRESS_VERSION ); } public function register_scripts() { wp_register_script( 'wpml-popover-tooltip', ICL_PLUGIN_URL . '/dist/js/shared/wpml-popover-tooltip.js', null, ICL_SITEPRESS_VERSION ); wp_register_script( 'otgs-table-sticky-header', ICL_PLUGIN_URL . '/dist/js/shared/otgs-table-sticky-header.js', array('jquery'), ICL_SITEPRESS_VERSION ); } private function print_js_globals() { $icl_ajax_url = wpml_get_admin_url( array( 'path' => 'admin.php', 'query' => array( 'page' => WPML_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', 'term.php' ), true ) && $current_language !== $default_language ) { $this->correct_status_links_js( $current_language ); } if ( 'edit-tags.php' === $pagenow || 'term.php' === $pagenow ) { $post_type = isset( $_GET['post_type'] ) ? '&post_type=' . esc_html( $_GET['post_type'] ) : ''; $admin_url = admin_url( 'edit-tags.php' ); $admin_url = add_query_arg( 'taxonomy', esc_js( $_GET['taxonomy'] ), $admin_url ); $admin_url = add_query_arg( 'lang', $current_language, $admin_url ); $admin_url = add_query_arg( 'message', 3, $admin_url ); if ( $post_type ) { $admin_url = add_query_arg( 'post_type', $post_type, $admin_url ); } ?> 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(); $trid = filter_var( $_GET['trid'], FILTER_SANITIZE_NUMBER_INT ); $translations = $this->sitepress->get_element_translations( $trid, 'post_' . $post_type ); if ( ! isset( $translations[ $source_lang ] ) ) { return; } $current_lang = $this->sitepress->get_current_language(); $translatable_taxs = $this->sitepress->get_translatable_taxonomies( true, $post_type ); $all_taxs = get_object_taxonomies( $post_type ); $js = array(); $this->sitepress->switch_lang($source_lang); 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('#" . esc_js( $tax ) . ".taghint').css('visibility','hidden');"; $js[] = "jQuery('#new-tag-" . esc_js( $tax ) . "').val('" . esc_js( join( ', ', $term_names ) ) . "');"; } } $this->sitepress->switch_lang( null ); if ( $js ) { ?> 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 = '