Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/menu-elements.tar
Назад
class-wpml-lang-domains-box.php 0000644 00000014650 14721653536 0012516 0 ustar 00 <?php /** * Class WPML_Lang_Domains_Box * * Displays the table holding the language domains on languages.php */ class WPML_Lang_Domains_Box extends WPML_SP_User { public function render() { $active_languages = $this->sitepress->get_active_languages(); $default_language = $this->sitepress->get_default_language(); $language_domains = $this->sitepress->get_setting( 'language_domains', array() ); $default_home = (string) $this->sitepress->convert_url( $this->sitepress->get_wp_api()->get_home_url(), $default_language ); $home_schema = wpml_parse_url( $default_home, PHP_URL_SCHEME ) . '://'; $home_path = wpml_parse_url( $default_home, PHP_URL_PATH ); $is_per_domain = WPML_LANGUAGE_NEGOTIATION_TYPE_DOMAIN === (int) $this->sitepress->get_setting( 'language_negotiation_type' ); $is_sso_enabled = (bool) $this->sitepress->get_setting( 'language_per_domain_sso_enabled', ! $is_per_domain ); ob_start(); ?> <table class="language_domains sub-section"> <?php foreach ( $active_languages as $code => $lang ) { $text_box_id = esc_attr( 'language_domain_' . $code ); ?> <tr> <td> <label for="<?php echo $text_box_id; ?>"> <?php echo esc_html( $lang['display_name'] ); ?> </label> </td> <?php if ( $code === $default_language ) { ?> <td id="icl_ln_home"> <code> <?php echo esc_url( $default_home ); ?> </code> </td> <td> </td> <?php } else { ?> <td style="white-space: nowrap"> <code><?php echo esc_html( $home_schema ); ?></code> <input type="text" id="<?php echo $text_box_id; ?>" name="language_domains[<?php echo esc_attr( $code ); ?>]" value="<?php echo $this->get_language_domain( $code, $default_home, $language_domains ); ?>" data-language="<?php echo esc_attr( $code ); ?>" size="30"/> <?php if ( isset( $home_path[1] ) && is_string( $home_path[1] ) ) { ?> <code><?php echo esc_html( $home_path ); ?></code> <?php } ?> </td> <td> <p style="white-space: nowrap"><input class="validate_language_domain" type="checkbox" id="validate_language_domains_<?php echo esc_attr( $code ); ?>" name="validate_language_domains[]" value="<?php echo esc_attr( $code ); ?>" checked="checked"/> <label for="validate_language_domains_<?php echo esc_attr( $code ); ?>"> <?php esc_html_e( 'Validate on save', 'sitepress' ); ?> </label> </p> <p style="white-space: nowrap"> <span class="spinner spinner-<?php echo esc_attr( $code ); ?>"></span> <span id="ajx_ld_<?php echo esc_attr( $code ); ?>"></span> </p> </td> <?php } ?> </tr> <?php } ?> <tr> <td colspan="2"> <label for="sso_enabled"> <input type="checkbox" id="sso_enabled" name="sso_enabled" value="1" <?php checked( $is_sso_enabled, true, true ); ?>> <?php esc_html_e( 'Auto sign-in and sign-out users from all domains', 'sitepress' ); ?> </label> <span id="sso_information"><i class="otgs-ico-help"></i></span> <div id="sso_enabled_notice" style="display: none;"> <?php esc_html_e( 'Please log-out and login again in order to be able to access the admin features in all language domains.', 'sitepress' ); ?> </div> </td> </tr> </table> <div id="language_per_domain_sso_description" style="display:none;"> <p> <?php /* translators: this is the first of two sentences explaining the "Auto sign-in and sign-out users from all domains" feature */ echo esc_html_x( 'This feature allows the theme and plugins to work correctly when on sites that use languages in domains.', 'Tooltip: Auto sign-in and sign-out users from all domains', 'sitepress' ); ?> <br> <?php /* translators: this is the second of two sentences explaining the "Auto sign-in and sign-out users from all domains" feature */ echo esc_html_x( "It requires a call to each of the site's language domains on both log-in and log-out, so there's a small performance penalty to using it.", 'Tooltip: Auto sign-in and sign-out users from all domains', 'sitepress' ); ?> </p> </div> <?php return ob_get_clean(); } /** * @param string $code * @param string $default_home * @param string[] $language_domains * * @return string */ private function get_language_domain( $code, $default_home, $language_domains ) { $home_schema = wpml_parse_url( $default_home, PHP_URL_SCHEME ) . '://'; $home_path = wpml_parse_url( $default_home, PHP_URL_PATH ); if ( isset( $language_domains[ $code ] ) ) { $pattern = [ '#^' . $home_schema . '#', '#' . $home_path . '$#', ]; $language_domain_raw = preg_replace( $pattern, '', $language_domains[ $code ] ); } else { $language_domain_raw = $this->render_suggested_url( $default_home, $code ); } return filter_var( $language_domain_raw, FILTER_SANITIZE_URL ); } private function render_suggested_url( $home, $lang ) { $url_parts = parse_url( $home ); $exp = explode( '.', $url_parts['host'] ); $suggested_url = $lang . '.'; array_shift( $exp ); $suggested_url .= count( $exp ) < 2 ? $url_parts['host'] : implode( '.', $exp ); return $suggested_url; } } class-wpml-admin-scripts-setup.php 0000644 00000047573 14721653536 0013304 0 ustar 00 <?php class WPML_Admin_Scripts_Setup extends WPML_Full_Translation_API { const PRIORITY_ENQUEUE_SCRIPTS = 10; /** @var string $page */ private $page; /** * @param wpdb $wpdb * @param SitePress $sitepress * @param WPML_Post_Translation $post_translation * @param WPML_Terms_Translations $term_translation * @param string $page */ public function __construct( &$wpdb, &$sitepress, &$post_translation, &$term_translation, $page ) { parent::__construct( $sitepress, $wpdb, $post_translation, $term_translation ); $this->page = $page; } public function add_admin_hooks() { add_action( 'admin_print_scripts', array( $this, 'wpml_js_scripts_setup' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'wpml_css_setup' ), self::PRIORITY_ENQUEUE_SCRIPTS ); } 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( 'wpml-wizard', ICL_PLUGIN_URL . '/res/css/wpml-wizard.css', [], 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' ), ) ); ?> <script type="text/javascript"> // <![CDATA[ var icl_ajx_url = '<?php echo esc_url( $icl_ajax_url ); ?>', icl_ajx_saved = '<?php echo icl_js_escape( __( 'Data saved', 'sitepress' ) ); ?>', icl_ajx_error = '<?php echo icl_js_escape( __( 'Error: data not saved', 'sitepress' ) ); ?>', icl_default_mark = '<?php echo icl_js_escape( __( 'default', 'sitepress' ) ); ?>', icl_this_lang = '<?php echo esc_js( $this->sitepress->get_current_language() ); ?>', icl_ajxloaderimg_src = '<?php echo esc_url( ICL_PLUGIN_URL ); ?>/res/img/ajax-loader.gif', icl_cat_adder_msg = '<?php echo icl_js_escape( sprintf( __( 'To add categories that already exist in other languages go to the <a%s>category management page</a>', 'sitepress' ), ' href="' . admin_url( 'edit-tags.php?taxonomy=category' ) . '"' ) ); ?>'; // ]]> <?php if ( ! $this->sitepress->get_setting( 'ajx_health_checked' ) && ! (bool) get_option( '_wpml_inactive' ) ) { $error = __( "WPML can't run normally. There is an installation or server configuration problem. %1\$sShow details%2\$s", 'sitepress' ); $error_message = sprintf( $error, '<a href="#" onclick="jQuery(this).parent().next().slideToggle()">', '</a>' ); ?> addLoadEvent(function () { jQuery.ajax({ type : "POST", url : icl_ajx_url, data : "icl_ajx_action=health_check", error: function (msg) { var icl_initial_language = jQuery('#icl_initial_language'); if (icl_initial_language.length) { icl_initial_language.find('input').attr('disabled', 'disabled'); } jQuery('.wrap').prepend('<div class="error"><p><?php echo icl_js_escape( $error_message );?></p><p style="display:none"><?php echo icl_js_escape( __( 'AJAX Error:', 'sitepress' ) ); ?> ' + msg.statusText + ' [' + msg.status + ']<br />URL:' + icl_ajx_url + '</p></div>'); } }); }); <?php } ?> </script> <?php } public function wpml_js_scripts_setup() { // TODO: [WPML 3.3] move javascript to external resource (use wp_localize_script() to pass arguments) global $pagenow, $sitepress; $default_language = $this->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 ); } ?> <script type="text/javascript"> addLoadEvent(function () { var edit_tag = jQuery('#edittag'); if (edit_tag.find('[name="_wp_original_http_referer"]').length && edit_tag.find('[name="_wp_http_referer"]').length) { edit_tag.find('[name="_wp_original_http_referer"]').val('<?php echo esc_js( $admin_url ); ?>'); } }); </script> <?php } $trid = filter_input( INPUT_GET, 'trid', FILTER_SANITIZE_NUMBER_INT ); $source_lang = null !== $trid ? filter_input( INPUT_GET, 'source_lang', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : null; if ( 'post-new.php' === $pagenow ) { if ( $trid ) { $translations = $this->post_translations->get_element_translations( false, $trid ); $sticky_posts = wpml_sticky_post_sync()->get_unfiltered_sticky_posts_option(); $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 ) ) { ?> <script type="text/javascript">addLoadEvent(function () { jQuery('#visibility-radio-private').prop('checked', true); jQuery('#post-visibility-display').html('<?php echo icl_js_escape( __( 'Private', 'sitepress' ) ); ?>'); }); </script> <?php } if ( $this->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 ); } ?> <?php if ( ! empty( $is_sticky ) && $this->sitepress->get_setting( 'sync_sticky_flag' ) ) : ?> <script type="text/javascript"> addLoadEvent( function () { var block_editor = wpml_get_block_editor(); if(block_editor){ document.addEventListener('DOMContentLoaded', function () { block_editor.then(function () { setTimeout(function () { wp.data.dispatch('core/editor').editPost({sticky: true}); }, 100); }); }); } else { jQuery('#sticky').prop('checked', true); var post_visibility_display = jQuery('#post-visibility-display'); post_visibility_display.html(post_visibility_display.html() + ', <?php echo icl_js_escape( __( 'Sticky', 'sitepress' ) ); ?>'); } } ); </script> <?php endif; ?> <?php } if ( ( 'page-new.php' === $pagenow || ( 'post-new.php' === $pagenow && isset( $_GET['post_type'] ) ) ) && ( $trid && ( $this->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 ); ?> <script type="text/javascript"> addLoadEvent(function () { jQuery('#post-format-' + '<?php echo $format; ?>').prop('checked', true); }); </script> <?php } wp_enqueue_script( 'theme-preview' ); if ( 'languages' === $page_basename || 'string-translation' === $page_basename ) { wp_enqueue_script( 'wp-color-picker' ); wp_register_style( 'wpml-color-picker', ICL_PLUGIN_URL . '/res/css/colorpicker.css', array( 'wp-color-picker' ), ICL_SITEPRESS_VERSION ); wp_enqueue_style( 'wpml-color-picker' ); wp_enqueue_script( 'jquery-ui-sortable' ); } } /** * Prints JavaScript to display correct links on the posts by status break down and also fixes links * to category and tag pages * * @param string $current_language */ private function correct_status_links_js( $current_language ) { ?> <script type="text/javascript"> addLoadEvent( function () { jQuery(document).ready( function () { jQuery('.subsubsub>li a').each( function () { var h = jQuery(this).attr('href'); var urlg = -1 === h.indexOf('?') ? '?' : '&'; jQuery(this).attr('href', h + urlg + 'lang=<?php echo esc_js( $current_language ); ?>'); } ); jQuery('.column-categories a, .column-tags a, .column-posts a').each( function () { jQuery(this).attr('href', jQuery(this).attr('href') + '&lang=<?php echo esc_js( $current_language ); ?>'); } ); } ); } ); </script> <?php } /** * Prints the JavaScript for synchronizing page order or page template on the post edit screen. * * @param int $trid * @param string $source_lang */ private function print_mo_sync_js( $trid, $source_lang ) { $menu_order = $this->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 ) { ?> <script type="text/javascript">addLoadEvent(function () { <?php if ( $menu_order ) { ?> jQuery('#menu_order').val(<?php echo esc_js( $menu_order ); ?>); <?php } if ( $page_template && 'default' !== $page_template ) { ?> jQuery('#page_template').val('<?php echo esc_js( $page_template ); ?>'); <?php } ?> });</script> <?php } } /** * Prints the JavaScript for synchronizing ping and comment status for a post translation on the post edit screen. * * @param int $trid * @param string $source_lang */ private function print_ping_and_comment_sync_js( $trid, $source_lang ) { ?> <script type="text/javascript">addLoadEvent(function () { var comment_status = jQuery('#comment_status'); var ping_status = jQuery('#ping_status'); <?php if ( $this->sitepress->get_setting( 'sync_comment_status' ) ) : ?> <?php if ( $this->post_translations->get_original_comment_status( $trid, $source_lang ) === 'open' ) : ?> comment_status.prop('checked', true); <?php else : ?> comment_status.prop('checked', false); <?php endif; ?> <?php endif; ?> <?php if ( $this->sitepress->get_setting( 'sync_ping_status' ) ) : ?> <?php if ( $this->post_translations->get_original_ping_status( $trid, $source_lang ) === 'open' ) : ?> ping_status.prop('checked', true); <?php else : ?> ping_status.prop('checked', false); <?php endif; ?> <?php endif; ?> });</script> <?php } /** * Prints the JavaScript for disabling editing the post_date on the post edit screen, * when the synchronize post_date for translations setting is activated. */ private function print_sync_date_js() { $post_id = $this->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] ); ?> <script type="text/javascript"> addLoadEvent( function () { jQuery('#aa').val('<?php echo esc_js( $aa ); ?>').attr('readonly', 'readonly'); jQuery('#mm').val('<?php echo esc_js( $mm ); ?>').attr('disabled', 'disabled').attr('id', 'mm-disabled').attr('name', 'mm-disabled'); // create a hidden element for month because we wont get anything returned from the disabled month dropdown. jQuery('<input type="hidden" id="mm" name="mm" value="<?php echo $mm; ?>" />').insertAfter('#mm-disabled'); jQuery('#jj').val('<?php echo esc_js( $jj ); ?>').attr('readonly', 'readonly'); jQuery('#hh').val('<?php echo esc_js( $hh ); ?>').attr('readonly', 'readonly'); jQuery('#mn').val('<?php echo esc_js( $mn ); ?>').attr('readonly', 'readonly'); jQuery('#ss').val('<?php echo esc_js( $ss ); ?>').attr('readonly', 'readonly'); var timestamp = jQuery('#timestamp'); timestamp.find('b').append(( '<span> <?php esc_html_e( 'Copied From the Original', 'sitepress' ); ?></span>')); timestamp.next().html('<span style="margin-left:1em;"><?php esc_html_e( 'Edit', 'sitepress' ); ?></span>'); }); </script> <?php } } } private function print_tax_sync_js() { $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : 'post'; $source_lang = isset( $_GET['source_lang'] ) ? filter_input( INPUT_GET, 'source_lang', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : $this->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(\'input[id^="in-' . $tax . '-' . $term_id . '"]\').filter(function() { return /^in-' . $tax . '-' . $term_id . '(-\\d+)?$/.test(this.id); }).prop(\'checked\', true);'; } 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 ) { ?> <script type="text/javascript"> // <![CDATA[ addLoadEvent(function(){ <?php echo join( PHP_EOL, $js ); ?> jQuery().ready(function() { jQuery(".tagadd").click(); jQuery('html, body').prop({scrollTop:0}); jQuery('#title').focus(); }); }); // ]]> </script> <?php } } 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 ) { ?> <script type="text/javascript"> addLoadEvent(function () { jQuery('input[name="show_on_front"]').parent().parent().parent().parent().append('<?php echo str_replace( "'", "\\'", $warn_home . $warn_posts ); ?>'); }); </script> <?php } } function wpml_css_setup() { if ( isset( $_GET['page'] ) ) { $page = basename( $_GET['page'] ); $page_basename = str_replace( '.php', '', $page ); $page_basename = preg_replace( '/[^\w-]/', '', $page_basename ); } wp_enqueue_style( 'sitepress-style', ICL_PLUGIN_URL . '/res/css/style.css', array(), ICL_SITEPRESS_VERSION ); if ( isset( $page_basename ) && file_exists( WPML_PLUGIN_PATH . '/res/css/' . $page_basename . '.css' ) ) { wp_enqueue_style( 'sitepress-' . $page_basename, ICL_PLUGIN_URL . '/res/css/' . $page_basename . '.css', array(), ICL_SITEPRESS_VERSION ); } wp_enqueue_style( 'wpml-dialog' ); wp_enqueue_style( 'otgs-icons' ); wp_enqueue_style( 'wpml-wizard' ); wp_enqueue_style( 'thickbox' ); } private function verify_home_and_blog_pages_translations() { $warn_home = $warn_posts = ''; $page_on_front = get_option( 'page_on_front' ); if ( 'page' === get_option( 'show_on_front' ) && $page_on_front ) { $warn_home = $this->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 = '<div class="icl_form_errors" style="font-weight:bold;' . $additional_css . '">'; $warn_posts .= sprintf( $label, join( ', ', $missing_posts ) ); $warn_posts .= '<br />'; $warn_posts .= '<a href="' . get_edit_post_link( $original_page_id ) . '">' . __( 'Edit this page to add translations', 'sitepress' ) . '</a>'; $warn_posts .= '</div>'; } } return $warn_posts; } } class-wpml-tm-post-link-factory.php 0000644 00000002301 14721653536 0013350 0 ustar 00 <?php /** * Class WPML_TM_Post_Link_Factory * * Creates post links for the TM dashboard and the translation queue */ class WPML_TM_Post_Link_Factory { /** @var SitePress $sitepress */ private $sitepress; public function __construct( SitePress $sitepress ) { $this->sitepress = $sitepress; } /** * Link to the front end, link text is the post title * * @param int $post_id * * @return string */ public function view_link( $post_id ) { return (string) ( new WPML_TM_Post_View_Link_Title( $this->sitepress, (int) $post_id ) ); } /** * Link to the front end, link text is given by the anchor * * @param int $post_id * @param string $anchor * * @return string */ public function view_link_anchor( $post_id, $anchor, $target = '' ) { return (string) ( new WPML_TM_Post_View_Link_Anchor( $this->sitepress, (int) $post_id, $anchor, $target ) ); } /** * Link to the backend, link text is given by the anchor * * @param int $post_id * @param string $anchor * * @return string */ public function edit_link_anchor( $post_id, $anchor ) { return (string) ( new WPML_TM_Post_Edit_Link_Anchor( $this->sitepress, (int) $post_id, $anchor ) ); } } class-wpml-tm-post-edit-link-anchor.php 0000644 00000000524 14721653536 0014103 0 ustar 00 <?php /** * Class WPML_TM_Post_Edit_Link_Anchor * * Creates post links with a given anchor text, pointing at the back-end * post edit view */ class WPML_TM_Post_Edit_Link_Anchor extends WPML_TM_Post_Link_Anchor { protected function link_target() { return $this->sitepress->get_wp_api()->get_edit_post_link( $this->post_id ); } } class-wpml-tm-post-view-link-anchor.php 0000644 00000000513 14721653536 0014126 0 ustar 00 <?php /** * Class WPML_TM_Post_View_Link_Anchor * * Creates post links with a given anchor text, pointing at the front-end * post view */ class WPML_TM_Post_View_Link_Anchor extends WPML_TM_Post_Link_Anchor { protected function link_target() { return $this->sitepress->get_wp_api()->get_permalink( $this->post_id ); } } class-wpml-support-page.php 0000644 00000005106 14721653536 0012001 0 ustar 00 <?php class WPML_Support_Page { /** * @var \WPML_WP_API */ private $wpml_wp_api; /** * WPML_Support_Page constructor. * * @param WPML_WP_API $wpml_wp_api */ public function __construct( &$wpml_wp_api ) { $this->wpml_wp_api = &$wpml_wp_api; $this->init_hooks(); } public function display_compatibility_issues() { $message = $this->get_message(); $this->render_message( $message ); } /** * @return string */ private function get_message() { $message = ''; if ( ! $this->wpml_wp_api->extension_loaded( 'libxml' ) ) { $message .= $this->missing_extension_message(); if ( $this->wpml_wp_api->version_compare_naked( $this->wpml_wp_api->phpversion(), '7.0.0', '>=' ) ) { $message .= $this->missing_extension_message_for_php7(); } $message .= $this->contact_the_admin(); return $message; } return $message; } private function init_hooks() { add_action( 'wpml_support_page_after', array( $this, 'display_compatibility_issues' ) ); } /** * @return string */ private function missing_extension_message() { return '<p class="missing-extension-message">' . esc_html__( 'It looks like the %1$s extension, which is required by WPML, is not installed. Please refer to this link to know how to install this extension: %2$s.', 'sitepress' ) . '</p>'; } /** * @return string */ private function missing_extension_message_for_php7() { return '<p class="missing-extension-message-for-php7">' . esc_html__( 'You are using PHP 7: in some cases, the extension might have been removed during a system update. In this case, please see %3$s.', 'sitepress' ) . '</p>'; } /** * @return string */ private function contact_the_admin() { return '<p class="contact-the-admin">' . esc_html__( 'You may need to contact your server administrator or your hosting company to install this extension.', 'sitepress' ) . '</p>'; } /** * @param string $message */ private function render_message( $message ) { if ( $message ) { $libxml_text = '<strong>libxml</strong>'; $libxml_link = '<a href="http://php.net/manual/en/book.libxml.php" target="_blank">http://php.net/manual/en/book.libxml.php</a>'; $libxml_php7_link = '<a href="https://wpml.org/errata/php-7-possible-issues-simplexml/?utm_source=plugin&utm_medium=gui&utm_campaign=wpmlcore" target="_blank">PHP 7: possible issues with simplexml</a>'; echo '<div class="icl-admin-message icl-admin-message-icl-admin-message-warning icl-admin-message-warning error">'; echo sprintf( $message, $libxml_text, $libxml_link, $libxml_php7_link ); echo '</div>'; } } } class-wpml-taxonomy-translation.php 0000644 00000003057 14721653536 0013570 0 ustar 00 <?php /** * class WPML_Taxonomy_Translation * * Used by WCML so be careful about modifications to the contructor */ class WPML_Taxonomy_Translation { private $ui = null; private $taxonomy = ''; private $args = array(); private $screen_options_factory = null; /** * WPML_Taxonomy_Translation constructor. * * @param string $taxonomy if given renders a specific taxonomy, * otherwise renders a placeholder * @param bool[] $args array with possible indices: * 'taxonomy_selector' => bool .. whether or not to show the taxonomy selector * @param WPML_UI_Screen_Options_Factory $screen_options_factory */ public function __construct( $taxonomy = '', $args = array(), $screen_options_factory = null ) { $this->taxonomy = $taxonomy; $this->args = $args; $this->screen_options_factory = $screen_options_factory; add_action('init', array($this, 'prepareUi'), SitePress::INIT_HOOK_TRANSLATIONS_PRIORITY + 1 ); } public function prepareUi() { global $sitepress; $this->ui = new WPML_Taxonomy_Translation_UI( $sitepress, $this->taxonomy, $this->args, $this->screen_options_factory ); } /** * Echos the HTML that serves as an entry point for the taxonomy translation * screen and enqueues necessary js. * This should be called only after the plugin translations are loaded. (``init`` hook) */ public function render() { if ( ! $this->ui ) { $this->prepareUi(); } $this->ui->render(); } } class-wpml-custom-columns-factory.php 0000644 00000000463 14721653536 0014011 0 ustar 00 <?php /** * @author OnTheGo Systems */ class WPML_Custom_Columns_Factory implements IWPML_Backend_Action_Loader, IWPML_AJAX_Action_Loader { private $hooks; /** * @return WPML_Custom_Columns */ public function create() { global $sitepress; return new WPML_Custom_Columns( $sitepress ); } } class-wpml-custom-types-translation-ui.php 0000644 00000007214 14721653536 0015000 0 ustar 00 <?php class WPML_Custom_Types_Translation_UI { /** @var array */ private $translation_option_class_names; /** @var WPML_Translation_Modes $translation_modes */ private $translation_modes; /** @var WPML_UI_Unlock_Button $unlock_button_ui */ private $unlock_button_ui; public function __construct( WPML_Translation_Modes $translation_modes, WPML_UI_Unlock_Button $unlock_button_ui ) { $this->translation_modes = $translation_modes; $this->unlock_button_ui = $unlock_button_ui; $this->translation_option_class_names = array( WPML_CONTENT_TYPE_TRANSLATE => 'translate', WPML_CONTENT_TYPE_DISPLAY_AS_IF_TRANSLATED => 'display-as-translated', WPML_CONTENT_TYPE_DONT_TRANSLATE => 'dont-translate', ); } public function render_custom_types_header_ui( $type_label ) { ?> <header class="wpml-flex-table-header wpml-flex-table-sticky"> <div class="wpml-flex-table-row"> <div class="wpml-flex-table-cell name"> <?php echo $type_label; ?> </div> <?php $this->renderModeLabels(); ?> </div> </header> <?php } public function render_row( $content_label, $name, $content_slug, $disabled, $current_translation_mode, $unlocked, $content_label_singular = false ) { $radio_name = esc_attr( $name . '[' . $content_slug . ']' ); $unlocked_name = esc_attr( $name . '_unlocked[' . $content_slug . ']' ); ?> <div class="wpml-flex-table-cell name"> <?php $this->unlock_button_ui->render( $disabled, $unlocked, $radio_name, $unlocked_name ); echo $content_label; ?> (<i><?php echo esc_html( $content_slug ); ?></i>) </div> <?php foreach ( $this->translation_modes->get_options() as $value => $label ) { $disabled_state_for_mode = self::get_disabled_state_for_mode( $unlocked, $disabled, $value, $content_slug ) ?> <div class="wpml-flex-table-cell text-center <?php echo $this->translation_option_class_names[ $value ]; ?>" data-header="<?php echo esc_attr( $label ); ?>"> <input type="radio" name="<?php echo $radio_name; ?>" class="js-custom-post-mode" value="<?php echo esc_attr( $value ); ?>" <?php echo $disabled_state_for_mode['html_attribute']; ?> data-slug="<?php esc_attr_e( $content_slug ) ?>" data-name="<?php esc_attr_e( $content_label ) ?>" data-singular-name="<?php esc_attr_e( $content_label_singular ?: $content_label ) ?>" <?php checked( $value, $current_translation_mode ); ?> /> <?php if ( $disabled_state_for_mode['reason_message'] ) { ?> <p class="otgs-notice warning js-disabled-externally"><?php echo wp_kses_post( $disabled_state_for_mode['reason_message'] ); ?></p> <?php } ?> </div> <?php } } /** * @param bool $unlocked * @param bool $disabled * @param int $mode * @param string $content_slug * * @return array */ public static function get_disabled_state_for_mode( $unlocked, $disabled, $mode, $content_slug ) { $disabled_state_for_mode = array( 'state' => ! $unlocked && $disabled, 'reason_message' => '', ); $disabled_state_for_mode = apply_filters( 'wpml_disable_translation_mode_radio', $disabled_state_for_mode, $mode, $content_slug ); $disabled_state_for_mode['html_attribute'] = $disabled_state_for_mode['state'] ? 'disabled="disabled"' : ''; return $disabled_state_for_mode; } public function renderModeLabels() { foreach ( $this->translation_modes->get_options() as $value => $label ) { ?> <div class="wpml-flex-table-cell text-center <?php echo $this->translation_option_class_names[ $value ]; ?>"> <?php echo wp_kses_post( $label ); ?> </div> <?php } } } class-wpml-tm-post-link.php 0000644 00000000574 14721653536 0011715 0 ustar 00 <?php abstract class WPML_TM_Post_Link { /** @var SitePress $sitepress */ protected $sitepress; /** @var int $post */ protected $post_id; /** * WPML_TM_Post_Link constructor. * * @param SitePress $sitepress * @param int $post_id */ public function __construct( $sitepress, $post_id ) { $this->sitepress = $sitepress; $this->post_id = $post_id; } } class-wpml-custom-columns.php 0000644 00000013623 14721653536 0012346 0 ustar 00 <?php use WPML\Element\API\TranslationsRepository; /** * Class WPML_Custom_Columns */ class WPML_Custom_Columns implements IWPML_Action { const COLUMN_KEY = 'icl_translations'; const CUSTOM_COLUMNS_PRIORITY = 1010; /** * @param SitePress $sitepress */ private $sitepress; /** * @var WPML_Post_Status_Display */ public $post_status_display; public function __construct( SitePress $sitepress ) { $this->sitepress = $sitepress; } /** * @param array $columns * * @return array */ public function add_posts_management_column( $columns ) { $new_columns = $columns; if ( 'trash' === get_query_var( 'post_status' ) ) { return $columns; } $flags_column = $this->get_flags_column(); if ( $flags_column ) { $new_columns = []; foreach ( $columns as $column_key => $column_content ) { $new_columns[ $column_key ] = $column_content; if ( ( 'title' === $column_key || 'name' === $column_key ) && ! isset( $new_columns[ self::COLUMN_KEY ] ) ) { $new_columns[ self::COLUMN_KEY ] = $flags_column; } } } return $new_columns; } public function get_flags_column() { $active_languages = $this->get_filtered_active_languages(); if ( count( $active_languages ) <= 1 ) { return ''; } $current_language = $this->sitepress->get_current_language(); unset( $active_languages[ $current_language ] ); if ( ! count( $active_languages ) ) { return ''; } $flags_column = '<span class="screen-reader-text">' . esc_html__( 'Languages', 'sitepress' ) . '</span>'; foreach ( $active_languages as $language_data ) { $flags_column .= $this->get_flag_img( $language_data ); } return $flags_column; } private function get_flag_img( $language_data ) { $url = $this->sitepress->get_flag_url( $language_data['code'] ); if ( $url !== '' ) { return '<img src="' . esc_url( $url ) . '" width="18" height="12" alt="' . esc_attr( $language_data['display_name'] ) . '" title="' . esc_attr( $language_data['display_name'] ) . '" style="margin:2px" />'; } else { return $language_data['code']; } } /** * Add posts management column. * * @param string $column_name * @param int|null $post_id */ public function add_content_for_posts_management_column( $column_name, $post_id = null ) { global $post; if ( ! $post_id ) { $post_id = $post->ID; } if ( self::COLUMN_KEY !== $column_name ) { return; } $active_languages = $this->get_filtered_active_languages(); if ( null === $this->post_status_display ) { $this->post_status_display = new WPML_Post_Status_Display( $active_languages ); } unset( $active_languages[ $this->sitepress->get_current_language() ] ); foreach ( $active_languages as $language_data ) { $icon_html = $this->post_status_display->get_status_html( $post_id, $language_data['code'] ); echo $icon_html; } } /** * Check translation management column screen option. * * @param string $post_type Current post type. * * @return bool */ public function show_management_column_content( $post_type ) { $user = get_current_user_id(); $hidden_columns = get_user_meta( $user, 'manageedit-' . $post_type . 'columnshidden', true ); if ( '' === $hidden_columns ) { $is_visible = (bool) apply_filters( 'wpml_hide_management_column', true, $post_type ); if ( false === $is_visible ) { update_user_meta( $user, 'manageedit-' . $post_type . 'columnshidden', array( self::COLUMN_KEY ) ); } return $is_visible; } return ! is_array( $hidden_columns ) || ! in_array( self::COLUMN_KEY, $hidden_columns, true ); } /** * Get list of active languages. * * @return array */ private function get_filtered_active_languages() { $active_languages = $this->sitepress->get_active_languages(); return apply_filters( 'wpml_active_languages_access', $active_languages, array( 'action' => 'edit' ) ); } public function add_hooks() { add_action( 'admin_init', array( $this, 'add_custom_columns_hooks', ), self::CUSTOM_COLUMNS_PRIORITY ); // accommodate Types init@999 } /** * Add custom columns hooks. */ public function add_custom_columns_hooks() { $post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post'; if ( $post_type && $this->has_custom_columns() && array_key_exists( $post_type, $this->sitepress->get_translatable_documents() ) ) { add_filter( 'manage_' . $post_type . '_posts_columns', array( $this, 'add_posts_management_column', ) ); $show_management_column_content = $this->show_management_column_content( $post_type ); if ( $show_management_column_content ) { if ( is_post_type_hierarchical( $post_type ) ) { add_action( 'manage_pages_custom_column', array( $this, 'add_content_for_posts_management_column', ) ); } add_action( 'manage_posts_custom_column', array( $this, 'add_content_for_posts_management_column', ) ); add_action( 'manage_posts_custom_column', [ $this, 'preloadTranslationData' ], 1, 0 ); add_action( 'manage_pages_custom_column', [ $this, 'preloadTranslationData' ], 1, 0 ); } } } public function preloadTranslationData() { static $loaded = false; if ( $loaded ) { return; } global $wp_query; $posts = $wp_query->posts; if ( is_array( $posts ) ) { TranslationsRepository::preloadForPosts( $posts ); $loaded = true; } } /** * Check if we need to add custom columns on page. * * @return bool */ private function has_custom_columns() { global $pagenow; if ( 'edit.php' === $pagenow || 'edit-pages.php' === $pagenow || ( 'admin-ajax.php' === $pagenow && ( ( array_key_exists( 'action', $_POST ) && 'inline-save' === filter_var( $_POST['action'] ) ) || ( array_key_exists( 'action', $_GET ) && 'fetch-list' === filter_var( $_GET['action'] ) ) ) ) ) { return true; } return false; } } class-wpml-user-options-menu.php 0000644 00000014435 14721653536 0012771 0 ustar 00 <?php /** * Class WPML_User_Options_Menu * Renders the WPML UI elements on the WordPress user profile edit screen */ class WPML_User_Options_Menu { /** @var WP_User */ private $current_user; /** @var SitePress */ private $sitepress; /** * @var string */ private $user_language; /** * @var string */ private $user_admin_def_lang; /** * @var string */ private $admin_default_language; /** * @var string */ private $admin_language; /** * @var mixed[] */ private $all_languages; /** * WPML_User_Options_Menu constructor. * * @param SitePress $sitepress * @param WP_User $current_user */ public function __construct( SitePress $sitepress, WP_User $current_user ) { $this->sitepress = $sitepress; $this->current_user = $current_user; $this->user_language = $this->sitepress->get_wp_api()->get_user_meta( $this->current_user->ID, 'icl_admin_language', true ); $this->user_admin_def_lang = $this->sitepress->get_setting( 'admin_default_language' ); $this->user_admin_def_lang = $this->user_admin_def_lang === '_default_' ? $this->sitepress->get_default_language() : $this->user_admin_def_lang; $lang = $this->sitepress->get_language_details( $this->user_admin_def_lang ); $this->admin_default_language = is_array( $lang ) && isset( $lang['display_name'] ) ? $lang['display_name'] : $this->user_admin_def_lang; $this->admin_language = $this->sitepress->get_admin_language(); $user_language_for_all_languages = $this->user_admin_def_lang; if ( $this->user_language ) { $user_language_for_all_languages = $this->user_language; } $this->all_languages = $this->sitepress->get_languages( $user_language_for_all_languages ); } /** * @return string the html for the user profile edit screen element WPML * adds to it */ public function render() { $wp_api = $this->sitepress->get_wp_api(); $hide_wpml_languages = $wp_api->version_compare_naked( get_bloginfo( 'version' ), '4.7', '>=' ) ? 'style="display: none"' : ''; ob_start(); $admin_default_language_selected = $this->user_language === $this->user_admin_def_lang; ?> <tr class="user-language-wrap"> <th colspan="2"><h3><a name="wpml"></a><?php esc_html_e( 'WPML language settings', 'sitepress' ); ?></h3></th> </tr> <tr class="user-language-wrap" <?php echo $hide_wpml_languages; ?>> <th><label for="icl_user_admin_language"><?php esc_html_e( 'Select your language:', 'sitepress' ); ?></label></th> <td> <select id="icl_user_admin_language" name="icl_user_admin_language"> <option value=""<?php selected( true, $admin_default_language_selected ); ?>> <?php echo esc_html( sprintf( __( 'Default admin language (currently %s)', 'sitepress' ), $this->admin_default_language ) ); ?> </option> <?php foreach ( array( true, false ) as $active ) { foreach ( (array) $this->all_languages as $lang_code => $al ) { if ( (bool) $al['active'] === $active ) { $current_language_selected = $this->user_language === $lang_code; $language_name = $al['display_name']; if ( $this->admin_language !== $lang_code ) { $language_name .= ' (' . $al['native_name'] . ')'; } ?> <option value="<?php echo esc_attr( $lang_code ); ?>"<?php selected( true, $current_language_selected ); ?>> <?php echo esc_html( $language_name ); ?> </option> <?php } } } $use_admin_language_for_edit = $wp_api->get_user_meta( $this->current_user->ID, 'icl_admin_language_for_edit', true ) ?> </select> <span class="description"> <?php esc_html_e( 'this will be your admin language and will also be used for translating comments.', 'sitepress' ); ?> </span> </td> </tr> <?php $this->get_hidden_languages_options( $use_admin_language_for_edit ); do_action( 'wpml_user_profile_options', $this->current_user->ID ); return ob_get_clean(); } /** * @param bool $use_admin_language_for_edit */ private function get_hidden_languages_options( $use_admin_language_for_edit ) { /** * Filters a condition if current user can see hidden languages options in profile settings * * @params bool $show_hidden_languages_options */ $show_hidden_languages_options = apply_filters( 'wpml_show_hidden_languages_options', current_user_can( 'manage_options' ) ); if ( $show_hidden_languages_options ) { $hidden_languages = $this->sitepress->get_setting( 'hidden_languages' ); $display_hidden_languages = get_user_meta( $this->current_user->ID, 'icl_show_hidden_languages', true ); ?> <tr class="user-language-wrap"> <th><?php esc_html_e( 'Editing language:', 'sitepress' ); ?></th> <td> <input type="checkbox" name="icl_admin_language_for_edit" id="icl_admin_language_for_edit" value="1" <?php checked( true, $use_admin_language_for_edit ); ?> /> <label for="icl_admin_language_for_edit"><?php esc_html_e( 'Set admin language as editing language.', 'sitepress' ); ?></label> </td> </tr> <tr class="user-language-wrap"> <th><?php esc_html_e( 'Hidden languages:', 'sitepress' ); ?></th> <td> <p> <?php if ( ! empty( $hidden_languages ) ) { if ( 1 === count( $hidden_languages ) ) { echo esc_html( sprintf( __( '%s is currently hidden to visitors.', 'sitepress' ), $this->all_languages[ end( $hidden_languages ) ]['display_name'] ) ); } else { $hidden_languages_array = array(); foreach ( (array) $hidden_languages as $l ) { $hidden_languages_array[] = $this->all_languages[ $l ]['display_name']; } $hidden_languages = implode( ', ', $hidden_languages_array ); echo esc_html( sprintf( __( '%s are currently hidden to visitors.', 'sitepress' ), $hidden_languages ) ); } } else { esc_html_e( 'All languages are currently displayed. Choose what to do when site languages are hidden.', 'sitepress' ); } ?> </p> <p> <input id="icl_show_hidden_languages" name="icl_show_hidden_languages" type="checkbox" value="1" <?php checked( true, $display_hidden_languages ); ?> /> <label for="icl_show_hidden_languages"><?php esc_html_e( 'Display hidden languages', 'sitepress' ); ?></label> </p> </td> </tr> <?php } } } class-wpml-inactive-content-render.php 0000644 00000002034 14721653536 0014077 0 ustar 00 <?php class WPML_Inactive_Content_Render extends WPML_Twig_Template_Loader { const TEMPLATE = 'inactive-content.twig'; /** @var WPML_Inactive_Content $inactive_content */ private $inactive_content; public function __construct( WPML_Inactive_Content $inactive_content, array $paths ) { $this->inactive_content = $inactive_content; parent::__construct( $paths ); } public function render() { $model = array( 'content' => $this->inactive_content, 'strings' => [ 'title' => __( "You deactivated the following language(s) from your site, but there are still some existing translations saved in your database.", 'sitepress' ), 'more_info' => __( "If you don't plan to activate this language again, you can delete the associated content from your database.", "sitepress" ), 'language' => __( 'Language', 'sitepress' ), 'delete_translated_content' => __( 'Delete content', 'sitepress' ) ], ); return $this->get_template()->show( $model, self::TEMPLATE ); } } class-wpml-taxonomy-translation-screen-data.php 0000644 00000016220 14721653536 0015750 0 ustar 00 <?php class WPML_Taxonomy_Translation_Screen_Data extends WPML_WPDB_And_SP_User { const WPML_TAXONOMY_TRANSLATION_MAX_TERMS_RESULTS_SET = 1000; /** @var string $taxonomy */ private $taxonomy; /** * WPML_Taxonomy_Translation_Screen_Data constructor. * * @param SitePress $sitepress * @param string $taxonomy */ public function __construct( &$sitepress, $taxonomy ) { $wpdb = $sitepress->wpdb(); parent::__construct( $wpdb, $sitepress ); $this->taxonomy = $taxonomy; } /** * The returned array from this function is indexed as follows. * It holds an array of all terms to be displayed under [terms] * and the count of all terms matching the filter under [count]. * * The array under [terms] itself is index as such: * [trid][lang] * * It holds in itself the terms objects of the to be displayed terms. * These are ordered by their names alphabetically. * Also their objects are amended by the index $term->translation_of holding the term_taxonomy_id of their original element * and their level under $term->level in case of hierarchical terms. * * Also the index [trid][source_lang] holds the source language of the term group. * * @return array */ public function terms() { $terms_data = array( 'truncated' => 0, 'terms' => array(), ); $attributes_to_select = array(); $icl_translations_table_name = $this->wpdb->prefix . 'icl_translations'; $attributes_to_select[ $this->wpdb->terms ] = array( 'alias' => 't', 'vars' => array( 'name', 'slug', 'term_id' ), ); $attributes_to_select[ $this->wpdb->term_taxonomy ] = array( 'alias' => 'tt', 'vars' => array( 'term_taxonomy_id', 'parent', 'description', ), ); $attributes_to_select[ $icl_translations_table_name ] = array( 'alias' => 'i', 'vars' => array( 'language_code', 'trid', 'source_language_code', ), ); $query_limit_cap = defined( 'WPML_TAXONOMY_TRANSLATION_MAX_TERMS_RESULTS_SET' ) ? WPML_TAXONOMY_TRANSLATION_MAX_TERMS_RESULTS_SET : self::WPML_TAXONOMY_TRANSLATION_MAX_TERMS_RESULTS_SET; $join_statements = array(); $as = $this->alias_statements( $attributes_to_select ); $join_statements[] = "{$as['t']} JOIN {$as['tt']} ON tt.term_id = t.term_id"; $join_statements[] = "{$as['i']} ON i.element_id = tt.term_taxonomy_id"; $from_clause = $this->build_from_clause( join( ' JOIN ', $join_statements ), $attributes_to_select, $query_limit_cap ); $select_clause = $this->build_select_vars( $attributes_to_select ); $where_clause = $this->build_where_clause( $attributes_to_select ); $full_statement = "SELECT SQL_CALC_FOUND_ROWS {$select_clause} FROM {$from_clause} WHERE {$where_clause}"; $all_terms = $this->wpdb->get_results( $full_statement ); $real_terms_count = (int) $this->wpdb->get_var( 'SELECT FOUND_ROWS()' ); if ( $real_terms_count > $query_limit_cap ) { $terms_data['truncated'] = 1; } if ( ! is_array( $all_terms ) ) { return $terms_data; } if ( function_exists( 'get_term_meta' ) ) { $all_terms = $this->add_metadata( $all_terms ); } if ( $all_terms ) { $terms_data['terms'] = $this->order_terms_list( $this->index_terms_array( $all_terms ) ); } return $terms_data; } /** * @param array $terms * Turn a numerical array of terms objects into an associative once, * holding the same terms, but indexed by their term_id. * * @return array */ private function index_terms_array( $terms ) { $terms_indexed = array(); foreach ( $terms as $term ) { $terms_indexed[ $term->term_id ] = $term; } return $terms_indexed; } /** * @param array $trid_group * @param array $terms * Transforms the term arrays generated by the Translation Tree class and turns them into * standard WordPress terms objects. * * @return mixed */ private function set_language_information( $trid_group, $terms ) { foreach ( $trid_group['elements'] as $lang => $term ) { $term_object = $terms[ $term['term_id'] ]; $term_object->level = $term['level']; $trid_group[ $lang ] = $term_object; } unset( $trid_group['elements'] ); return $trid_group; } /** * Orders a list of terms alphabetically and hierarchy-wise * * @param array $terms * * @return array */ private function order_terms_list( $terms ) { $terms_tree = new WPML_Translation_Tree( $this->sitepress, $this->taxonomy, $terms ); $ordered_terms = $terms_tree->get_alphabetically_ordered_list(); foreach ( $ordered_terms as $key => $trid_group ) { $ordered_terms[ $key ] = self::set_language_information( $trid_group, $terms ); } return $ordered_terms; } /** * @param array $selects * Generates a list of to be selected variables in an sql query. * * @return string */ private function build_select_vars( $selects ) { $output = ''; if ( is_array( $selects ) ) { $coarse_selects = array(); foreach ( $selects as $select ) { $vars = $select['vars']; $table = $select['alias']; foreach ( $vars as $key => $var ) { $vars[ $key ] = $table . '.' . $var; } $coarse_selects[] = join( ', ', $vars ); } $output = join( ', ', $coarse_selects ); } return $output; } /** * @param array $selects * Returns an array of alias statements to be used in SQL queries with joins. * * @return array */ private function alias_statements( $selects ) { $output = array(); foreach ( $selects as $key => $select ) { $output[ $select['alias'] ] = $key . ' AS ' . $select['alias']; } return $output; } private function build_where_clause( $selects ) { $where_clauses[] = $selects[ $this->wpdb->term_taxonomy ]['alias'] . $this->wpdb->prepare( '.taxonomy = %s ', $this->taxonomy ); $where_clauses[] = $selects[ $this->wpdb->prefix . 'icl_translations' ]['alias'] . $this->wpdb->prepare( '.element_type = %s ', 'tax_' . $this->taxonomy ); $where_clause = join( ' AND ', $where_clauses ); return $where_clause; } /** * @param string $from * @param array $selects * @param int $limit * * @return string */ private function build_from_clause( $from, $selects, $limit ) { return $from . sprintf( " INNER JOIN ( SELECT trid FROM %s WHERE element_type = '%s' AND source_language_code IS NULL LIMIT %d ) lm on lm.trid = %s.trid", $this->wpdb->prefix . 'icl_translations', 'tax_' . $this->taxonomy, $limit, $selects[ $this->wpdb->prefix . 'icl_translations' ]['alias'] ); } /** * @param array $all_terms * * @return array */ private function add_metadata( $all_terms ) { $setting_factory = $this->sitepress->core_tm()->settings_factory(); foreach ( $all_terms as $term ) { $meta_data = get_term_meta( $term->term_id ); foreach ( $meta_data as $meta_key => $meta_data ) { if ( in_array( $setting_factory->term_meta_setting( $meta_key )->status(), array( WPML_TRANSLATE_CUSTOM_FIELD, WPML_COPY_ONCE_CUSTOM_FIELD ), true ) ) { $term->meta_data[ $meta_key ] = $meta_data; } } } return $all_terms; } } PostLinkUrl.php 0000644 00000001204 14721653536 0007514 0 ustar 00 <?php namespace WPML\TM\Menu; use SitePress; use WPML\FP\Cast; use WPML\FP\Fns; use WPML\FP\Lst; use WPML\FP\Maybe; use WPML\FP\Obj; use WPML\FP\Relation; use WPML\LIB\WP\User; use WPML\LIB\WP\Post; use function WPML\FP\pipe; class PostLinkUrl { /** * @param int $postId * * @return string */ public function viewLinkUrl( $postId ) { return Maybe::of( $postId ) ->map( Post::get() ) ->reject( pipe( Obj::prop( 'post_status' ), Lst::includes( Fns::__, [ 'private', 'trash', ] ) ) ) ->map( 'get_permalink' ) ->getOrElse( '' ); } } class-wpml-translation-tree.php 0000644 00000016737 14721653536 0012662 0 ustar 00 <?php /** * Class WPML_Translation_Tree * * @package wpml-core * @subpackage taxonomy-term-translation */ class WPML_Translation_Tree extends WPML_SP_User { private $taxonomy; private $tree = array(); private $trid_levels; private $language_order; private $term_ids; /** * @param SitePress $sitepress * @param string $element_type * @param object[] $terms */ public function __construct( &$sitepress, $element_type, $terms ) { if ( ! $terms ) { throw new InvalidArgumentException( 'No terms to order given given' ); } parent::__construct( $sitepress ); $this->taxonomy = $element_type; $this->language_order = $this->get_language_order( $terms ); $this->tree = $this->get_tree_from_terms_array( $terms ); } /** * Returns all terms in the translation tree, ordered by hierarchy and as well as alphabetically within a level and/or parent term relationship. * * @return array */ public function get_alphabetically_ordered_list() { $root_list = $this->sort_trids_alphabetically( $this->tree ); $ordered_list_flattened = array(); foreach ( $root_list as $root_trid_group ) { $ordered_list_flattened = $this->get_children_recursively( $root_trid_group, $ordered_list_flattened ); } return $ordered_list_flattened; } /** * @param array $terms * * Generates a tree representation of an array of terms objects * * @return array|bool */ private function get_tree_from_terms_array( $terms ) { $trids = $this->generate_trid_groups( $terms ); $trid_tree = $this->parse_tree( $trids, false, 0 ); return $trid_tree; } /** * Groups an array of terms objects by their trid and language_code * * @param array<\stdClass> $terms * * @return array<int,array> */ private function generate_trid_groups( $terms ) { $trids = array(); foreach ( $terms as $term ) { $trids [ $term->trid ] [ $term->language_code ] = array( 'ttid' => $term->term_taxonomy_id, 'parent' => $term->parent, 'term_id' => $term->term_id, ); if ( isset( $term->name ) ) { $trids [ $term->trid ] [ $term->language_code ]['name'] = $this->get_unique_term_name( $term->name ); } $this->term_ids[] = $term->term_id; } return $trids; } /** * @param string $name * * @return string */ private function get_unique_term_name( $name ) { return uniqid( $name . '-' ); } /** * @param array<int, array> $trids * @param array|bool|false $root_trid_group * @param int $level current depth in the tree * Recursively turns an array of unordered trid objects into a tree. * * @return array|bool */ private function parse_tree( $trids, $root_trid_group, $level ) { $return = array(); foreach ( $trids as $trid => $trid_group ) { if ( $this->is_root( $trid_group, $root_trid_group ) ) { unset( $trids[ $trid ] ); if ( ! isset( $this->trid_levels[ $trid ] ) ) { $this->trid_levels[ $trid ] = 0; } $this->trid_levels[ $trid ] = max( array( $level, $this->trid_levels[ $trid ] ) ); $return [ $trid ] = array( 'trid' => $trid, 'elements' => $trid_group, 'children' => $this->parse_tree( $trids, $trid_group, $level + 1 ), ); } } return empty( $return ) ? false : $return; } /** * @param array|bool $parent * @param array $children * Checks if one trid is the root of another. This is the case if at least one parent child * relationship between both trids exists. * * @return bool */ private function is_root( $children, $parent ) { $root = ! (bool) $parent; foreach ( $this->language_order as $c_lang ) { if ( ! isset( $children[ $c_lang ] ) ) { continue; } $child_in_lang = $children[ $c_lang ]; if ( $parent === false ) { $root = ! ( $child_in_lang['parent'] != 0 || in_array( $child_in_lang['parent'], $this->term_ids ) ); break; } else { foreach ( (array) $parent as $p_lang => $parent_in_lang ) { if ( $c_lang == $p_lang && $child_in_lang['parent'] == $parent_in_lang['term_id'] ) { $root = true; break; } } } } return $root; } private function sort_trids_alphabetically( $trid_groups ) { $terms_in_trids = array(); $ordered_trids = array(); foreach ( $trid_groups as $trid_group ) { foreach ( $trid_group['elements'] as $lang => $term ) { if ( ! isset( $terms_in_trids[ $lang ] ) ) { $terms_in_trids[ $lang ] = array(); } $trid = $trid_group['trid']; $term['trid'] = $trid; $terms_in_trids[ $lang ][ $trid ][] = $term; } } $sorted = array(); foreach ( $this->language_order as $lang ) { if ( isset( $terms_in_trids[ $lang ] ) ) { $terms_in_lang_and_trids = $terms_in_trids[ $lang ]; $term_names = array(); $term_names_numerical = array(); foreach ( $terms_in_lang_and_trids as $trid => $terms_in_lang_and_trid ) { if ( in_array( $trid, $sorted ) ) { continue; } $term_in_lang_and_trid = array_pop( $terms_in_lang_and_trid ); $term_name = $term_in_lang_and_trid['name']; $term_names [ $term_name ] = $trid; $term_names_numerical [] = $term_name; } natsort( $term_names_numerical ); foreach ( $term_names_numerical as $name ) { $ordered_trids [] = $trid_groups[ $term_names[ $name ] ]; $sorted[] = $term_names[ $name ]; } } } return $ordered_trids; } /** * @param array $trid_group * @param array $existing_list * * Reads in a trid array and appends it and its children to the input array. * This is done in the order parent->alphabetically ordered children -> ( alphabetically ordered children's children) ... * * @return array */ private function get_children_recursively( $trid_group, $existing_list = array() ) { $children = $trid_group['children']; unset( $trid_group['children'] ); $existing_list [] = $this->add_level_information_to_terms( $trid_group ); if ( is_array( $children ) ) { $children = $this->sort_trids_alphabetically( $children ); foreach ( $children as $child ) { $existing_list = $this->get_children_recursively( $child, $existing_list ); } } return $existing_list; } /** * Adds the hierarchical depth as a variable to all terms. * 0 means, that the term has no parent. * * @param array $tridgroup * * @return array */ private function add_level_information_to_terms( $tridgroup ) { foreach ( $tridgroup['elements'] as $lang => &$term ) { $level = 0; $term_id = $term['term_id']; while ( ( $term_id = wp_get_term_taxonomy_parent_id( $term_id, $this->taxonomy ) ) ) { $level ++; } $term['level'] = $level; } return $tridgroup; } /** * Counts the number of terms per language and returns an array of language codes, * that is ordered by the number of terms in every language. * * @param array $terms * * @return array */ private function get_language_order( $terms ) { $langs = array(); $default_lang = $this->sitepress->get_default_language(); foreach ( $terms as $term ) { $term_lang = $term->language_code; if ( $term_lang === $default_lang ) { continue; } if ( isset( $langs[ $term_lang ] ) ) { $langs[ $term_lang ] += 1; } else { $langs[ $term_lang ] = 1; } } natsort( $langs ); $return = array_keys( $langs ); $return [] = $default_lang; $return = array_reverse( $return ); return $return; } } post-edit-screen/wpml-post-edit-screen.class.php 0000644 00000004321 14721653536 0015724 0 ustar 00 <?php class WPML_Post_Edit_Screen { /** @var SitePress $sitepress */ private $sitepress; /** * @param SitePress $sitepress */ public function __construct( SitePress $sitepress ) { $this->sitepress = $sitepress; if ( $this->sitepress->get_setting( 'language_negotiation_type' ) == 2 ) { add_filter( 'preview_post_link', array( $this, 'preview_post_link_filter' ), 10, 1 ); add_filter( 'preview_page_link ', array( $this, 'preview_post_link_filter' ), 10, 1 ); } add_action( 'wpml_scripts_setup', array( $this, 'scripts_setup' ), 10, 1 ); add_filter( 'get_sample_permalink', array( $this, 'get_sample_permalink_filter' ) ); } /** * Enqueues scripts and styles for the post edit screen. */ function scripts_setup() { wp_enqueue_style( 'wp-jquery-ui-dialog' ); wp_enqueue_style( 'sitepress-post-edit', ICL_PLUGIN_URL . '/res/css/post-edit.css', array(), ICL_SITEPRESS_VERSION ); wp_enqueue_script( 'sitepress-post-edit', ICL_PLUGIN_URL . '/res/js/post-edit.js', array( 'jquery-ui-dialog', 'jquery-ui-autocomplete' ), ICL_SITEPRESS_VERSION ); } /** * Filters the preview links on the post edit screen so that they always point to the currently used language * domain. This ensures that the user can actually see the preview, as he might not have the login cookie set for * the actual language domain of the post. * * @param string $link * * @return mixed */ public function preview_post_link_filter( $link ) { if ( ! $this->sitepress->get_setting( 'language_per_domain_sso_enabled' ) ) { $original_host = filter_var( $_SERVER['HTTP_HOST'], FILTER_SANITIZE_URL ); if ( $original_host ) { $domain = wpml_parse_url( $link, PHP_URL_HOST ); $link = str_replace( '//' . $domain . '/', '//' . $original_host . '/', $link ); } } return $link; } /** * @param array $permalink Array containing the sample permalink with placeholder for the post name, and the post name. * * @return array */ public function get_sample_permalink_filter( array $permalink ) { $permalink[0] = $this->sitepress->convert_url( $permalink[0] ); return $permalink; } } class-wpml-tm-post-link-anchor.php 0000644 00000002133 14721653536 0013156 0 ustar 00 <?php abstract class WPML_TM_Post_Link_Anchor extends WPML_TM_Post_Link { /** @var string $anchor */ private $anchor; /** @var string $target */ private $target; /** * WPML_TM_Post_Link_Anchor constructor. * * @param SitePress $sitepress * @param int $post_id * @param string $anchor * @param string $target */ public function __construct( SitePress $sitepress, $post_id, $anchor, $target = '' ) { parent::__construct( $sitepress, $post_id ); $this->anchor = $anchor; $this->target = $target; } public function __toString() { $post = $this->sitepress->get_wp_api()->get_post( $this->post_id ); return ! $post || ( in_array( $post->post_status, array( 'draft', 'private', 'trash' ), true ) && $post->post_author != $this->sitepress->get_wp_api() ->get_current_user_id() ) ? '' : sprintf( '<a href="%s"%s>%s</a>', esc_url( $this->link_target() ), $this->target ? ' target="' . $this->target . '"' : '', esc_html( $this->anchor ) ); } protected abstract function link_target(); } PostTypesUI.php 0000644 00000003541 14721653536 0007504 0 ustar 00 <?php namespace WPML\Settings; use WPML\Settings\PostType\Automatic; use WPML\Setup\Option; class PostTypesUI extends \WPML_Custom_Types_Translation_UI { public function renderModeLabels() { parent::renderModeLabels(); $style_column = Option::shouldTranslateEverything() ? '' : 'display: none'; ?> <div class="wpml-flex-table-cell text-center translate-automatically" style="<?php echo esc_attr( $style_column ); ?>"> <?php esc_html_e( 'Translate', 'sitepress' ); ?> <br/><?php esc_html_e( 'automatically', 'sitepress' ); ?> </div> <?php } public function render_row( $content_label, $name, $content_slug, $disabled, $current_translation_mode, $unlocked, $content_label_singular = false ) { parent::render_row( ...func_get_args() ); $style_column = Option::shouldTranslateEverything() ? '' : 'display: none'; $isAutomatic = Automatic::isAutomatic( $content_slug ); $name = 'automatic_post_type[' . $content_slug . ']'; $style = $current_translation_mode !== WPML_CONTENT_TYPE_TRANSLATE ? 'display:none' : ''; ?> <div class="wpml-flex-table-cell text-center translate-automatically" style="<?php echo esc_attr( $style_column ); ?>"> <div class="otgs-toggle-group" style="<?php echo esc_attr( $style ); ?>"> <input type="checkbox" class="otgs-switcher-input" name="<?php echo esc_attr( $name ); ?>" data-was-automatic-before-user-changes="<?php echo $isAutomatic ? '1' : '0'; ?>" <?php echo $isAutomatic ? 'checked' : ''; ?> <?php echo ( $disabled && ! $unlocked ) ? 'disabled' : ''; ?> id="<?php echo esc_attr( $name ); ?>" > <label for="<?php echo esc_attr( $name ); ?>" class="otgs-switcher" data-on="<?php esc_attr_e( 'YES', 'sitepress' ); ?>" data-off="<?php esc_attr_e( 'NO', 'sitepress' ); ?>" > </label> </div> </div> <?php } } class-wpml-taxonomy-translation-ui.php 0000644 00000011457 14721653536 0014206 0 ustar 00 <?php /** * Class WPML_Taxonomy_Translation_UI */ class WPML_Taxonomy_Translation_UI { private $sitepress; private $taxonomy; private $tax_selector; private $screen_options; /** * WPML_Taxonomy_Translation constructor. * * @param SitePress $sitepress * @param string $taxonomy if given renders a specific taxonomy, * otherwise renders a placeholder * @param bool[] $args array with possible indices: * 'taxonomy_selector' => bool .. whether or not to show the taxonomy selector * @param WPML_UI_Screen_Options_Factory $screen_options_factory */ public function __construct( SitePress $sitepress, $taxonomy = '', array $args = array(), WPML_UI_Screen_Options_Factory $screen_options_factory = null ) { $this->sitepress = $sitepress; $this->tax_selector = isset( $args['taxonomy_selector'] ) ? $args['taxonomy_selector'] : true; $this->taxonomy = $taxonomy ? $taxonomy : false; if ( $screen_options_factory ) { $help_title = function() { return esc_html__( 'Taxonomy Translation', 'sitepress' ); }; $help_text = [ $this, 'get_help_text' ]; $this->screen_options = $screen_options_factory->create_pagination( 'taxonomy_translation_per_page', ICL_TM_DOCS_PER_PAGE ); $screen_options_factory->create_help_tab( 'taxonomy_translation_help_tab', $help_title, $help_text ); } } /** * Echos the HTML that serves as an entry point for the taxonomy translation * screen and enqueues necessary js. */ public function render() { WPML_Taxonomy_Translation_Table_Display::enqueue_taxonomy_table_resources( $this->sitepress ); $output = '<div class="wrap">'; if ( $this->taxonomy ) { $output .= '<input type="hidden" id="tax-preselected" value="' . $this->taxonomy . '">'; } if ( ! $this->tax_selector ) { $output .= '<input type="hidden" id="tax-selector-hidden" value="1"/>'; } if ( $this->tax_selector ) { $output .= '<h1>' . esc_html__( 'Taxonomy Translation', 'sitepress' ) . '</h1>'; $output .= '<br/>'; } $output .= '<div id="wpml_tt_taxonomy_translation_wrap" data-items_per_page="' . $this->get_items_per_page() . '">'; $output .= '<div class="loading-content"><span class="spinner" style="visibility: visible"></span></div>'; $output .= '</div>'; do_action( 'icl_menu_footer' ); echo $output . '</div>'; } /** * @return int */ private function get_items_per_page() { $items_per_page = 10; if ( $this->screen_options ) { $items_per_page = $this->screen_options->get_items_per_page(); } return $items_per_page; } /** * @return string */ public function get_help_text() { /* translators: this is the title of a documentation page used to terminate the sentence "is not possible to ..." */ $translate_base_taxonomy_slug_link_title = esc_html__( 'translate the base taxonomy slugs with WPML', 'sitepress' ); $translate_base_taxonomy_slug_link = '<a href="https://wpml.org/faq/translate-taxonomy-slugs-wpml/?utm_source=plugin&utm_medium=gui&utm_campaign=wpmlcore" target="_blank">' . $translate_base_taxonomy_slug_link_title . '</a>'; /* translators: this is the title of a documentation page used to terminate the sentence "To learn more, please visit our documentation page about..." */ $translate_taxonomies_link_title = esc_html__( 'translating post categories and custom taxonomies', 'sitepress' ); $translate_taxonomies_link = '<a href="https://wpml.org/documentation/getting-started-guide/translating-post-categories-and-custom-taxonomies/?utm_source=plugin&utm_medium=gui&utm_campaign=wpmlcore" target="_blank">' . $translate_taxonomies_link_title . '</a>'; $help_sentences = array(); $help_sentences[] = esc_html__( "WPML allows you to easily translate your site's taxonomies. Only taxonomies marked as translatable will be available for translation. Select the taxonomy in the dropdown menu and then use the list of taxonomy terms that appears to translate them.", 'sitepress' ); /* translators: the sentence is completed with "translate the base taxonomy slugs with WPML" */ $help_sentences[] = sprintf( esc_html__( 'Please note that currently, you can translate the slugs of taxonomy terms but it is not possible to %s.', 'sitepress' ), $translate_base_taxonomy_slug_link ); /* translators: the sentence is completed with "translating post categories and custom taxonomies" */ $help_sentences[] = sprintf( esc_html__( 'To learn more, please visit our documentation page about %s.', 'sitepress' ), $translate_taxonomies_link ); return '<p>' . implode( '</p><p>', $help_sentences ) . '</p>'; } } class-wpml-tm-post-edit-custom-field-settings-menu.php 0000644 00000006720 14721653536 0017075 0 ustar 00 <?php /** * Class WPML_TM_Post_Edit_Custom_Field_Settings_Menu */ class WPML_TM_Post_Edit_Custom_Field_Settings_Menu { /** @var WPML_Custom_Field_Setting_Factory $setting_factory */ private $setting_factory; /** @var WP_Post $post */ private $post; private $rendered = false; /** * WPML_TM_Post_Edit_Custom_Field_Settings_Menu constructor. * * @param WPML_Custom_Field_Setting_Factory $settings_factory * @param WP_Post $post */ public function __construct( &$settings_factory, $post ) { $this->setting_factory = &$settings_factory; $this->post = $post; } /** * @return string */ public function render() { $custom_keys = get_post_custom_keys( $this->post->ID ); $custom_keys = $this->setting_factory->filter_custom_field_keys( $custom_keys ); ob_start(); if ( 0 !== count( $custom_keys ) ) { ?> <table class="widefat"> <thead> <tr> <th colspan="2"><?php esc_html_e( 'Custom fields', 'sitepress' ); ?></th> </tr> </thead> <tbody> <?php foreach ( $custom_keys as $cfield ) { $field_setting = $this->setting_factory->post_meta_setting( $cfield ); if ( $field_setting->excluded() ) { continue; } $this->rendered = true; $radio_disabled = $field_setting->get_html_disabled(); $status = (int) $field_setting->status(); $states = array( array( 'value' => WPML_IGNORE_CUSTOM_FIELD, 'text' => __( "Don't translate", 'sitepress' ) ), array( 'value' => WPML_COPY_CUSTOM_FIELD, 'text' => __( "Copy", 'sitepress' ) ), array( 'value' => WPML_COPY_ONCE_CUSTOM_FIELD, 'text' => __( "Copy once", 'sitepress' ) ), array( 'value' => WPML_TRANSLATE_CUSTOM_FIELD, 'text' => __( "Translate", 'sitepress' ) ), ); ?> <tr> <td id="icl_mcs_cf_<?php echo esc_attr( base64_encode( $cfield ) ); ?>"> <div class="icl_mcs_cf_name"> <?php echo esc_html( $cfield ); ?> </div> <?php /** * Filter for custom field description in multilingual content setup metabox on post edit screen * * @param string $custom_field_description custom field description * @param string $custom_field_name custom field name * @param int $post_id current post ID */ $cfield_description = apply_filters( 'wpml_post_edit_settings_custom_field_description', "", $cfield, $this->post->ID ); if ( !empty( $cfield_description ) ) { printf( '<div class="icl_mcs_cf_description">%s</div>', esc_html( $cfield_description ) ); } ?> </td> <td align="right"> <?php foreach ( $states as $state ) { $checked = $status == $state['value'] ? ' checked="checked"' : ''; ?> <label> <input class="icl_mcs_cfs" name="icl_mcs_cf_<?php echo esc_attr( base64_encode( $cfield ) ); ?>" type="radio" value="<?php echo esc_attr( (string) $state['value'] ); ?>" <?php echo esc_attr( $radio_disabled . $checked ); ?> /> <?php echo esc_html( $state['text'] ) ?> </label> <?php } ?> </td> </tr> <?php } ?> </tbody> </table> <br/> <?php } return ob_get_clean(); } /** * @return bool true if there were actual custom fields to display options for */ public function is_rendered() { return $this->rendered; } } class-wpml-tm-post-view-link-title.php 0000644 00000000610 14721653536 0013773 0 ustar 00 <?php /** * Class WPML_TM_Post_View_Link_Title * * Creates post links with the post title as anchor text, pointing at the front-end * post view */ class WPML_TM_Post_View_Link_Title extends WPML_TM_Post_View_Link_Anchor { public function __construct( &$sitepress, $post_id ) { parent::__construct( $sitepress, $post_id, $sitepress->get_wp_api()->get_the_title( $post_id ) ); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка