function qtrans_in_nav_el($item_output, $item, $depth, $args) { $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : ''; $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : ''; $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : ''; /* Example link: http://google.com|en|http://google.com.ua|ua| */ if (preg_match_all('~(.*?)\\|(\\w{2,})\\|~', $item->url, $matches)) { $ext_url = ''; foreach ($matches[1] as $i => $match) { $ext_url .= "[:{$matches[2][$i]}]{$match}"; } $item->url = esc_attr(__($ext_url)); } // Determine integration with qTranslate Plugin if (function_exists('qtranxf_convertURL')) { $attributes .= !empty($item->url) ? ' href="' . qtranxf_convertURL(esc_attr($item->url)) . '"' : ''; } else { $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : ''; } $item_output = $args->before; $item_output .= '<a' . $attributes . '>'; $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after; return $item_output; }
public function convertURL($url, $lang = '') { if (function_exists('qtranxf_convertURL')) { return qtranxf_convertURL($url, $lang); } else { return qtrans_convertURL($url, $lang); } }
function qtrans_in_nav_el($item_output, $item, $depth, $args) { $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : ''; $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : ''; $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : ''; // Determine integration with qTranslate Plugin if (function_exists('qtranxf_convertURL')) { $attributes .= !empty($item->url) ? ' href="' . qtranxf_convertURL(esc_attr($item->url)) . '"' : ''; } else { $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : ''; } $item_output = $args->before; $item_output .= '<a' . $attributes . '>'; $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after; return $item_output; }
function wpa_qtrans_site_url($url) { // you probably don't want this in admin side if (is_admin()) { return $url; } return function_exists('qtranxf_convertURL') ? qtranxf_convertURL($url) : $url; }
function qtranxf_conf() { global $q_config, $qtranslate_options, $wpdb; //qtranxf_dbg_log('qtranxf_conf: REQUEST_TIME_FLOAT: ', $_SERVER['REQUEST_TIME_FLOAT']); //qtranxf_dbg_log('qtranxf_conf: POST: ',$_POST); //qtranxf_dbg_log('qtranxf_conf: GET: ',$_GET); // do redirection for dashboard if (isset($_GET['godashboard'])) { echo '<h2>' . __('Switching Language', 'qtranslate') . '</h2>' . sprintf(__('Switching language to %1$s... If the Dashboard isn\'t loading, use this <a href="%2$s" title="Dashboard">link</a>.', 'qtranslate'), $q_config['language_name'][qtranxf_getLanguage()], admin_url()) . '<script type="text/javascript">document.location="' . admin_url() . '";</script>'; exit; } // don't accidentally delete/enable/disable twice //$clean_uri = preg_replace("/&(delete|enable|disable|convert|markdefault|moveup|movedown)=[^&#]*/i","",$_SERVER['REQUEST_URI']); $clean_uri = $q_config['url_info']['qtranslate-settings-url']; $clean_uri = apply_filters('qtranslate_clean_uri', $clean_uri); $pluginurl = plugin_dir_url(QTRANSLATE_FILE); $nonce_action = 'qtranslate-x_configuration_form'; if (!qtranxf_verify_nonce($nonce_action)) { return; } // Allow to prepare loading additional features do_action('qtranslate_configuration_pre', $clean_uri); // Generate XHTML ?> <div class="wrap"> <?php if (isset($_GET['edit'])) { ?> <h2><?php _e('Edit Language', 'qtranslate'); ?> </h2> <form action="" method="post" id="qtranxs-edit-language"> <?php wp_nonce_field($nonce_action); qtranxf_language_form(); ?> <p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php _e('Save Changes »', 'qtranslate'); ?> " /></p> </form> <p class="qtranxs_notes"><a href="<?php echo admin_url('options-general.php?page=qtranslate-x#languages'); ?> "><?php _e('back to configuration page', 'qtranslate'); ?> </a></p> <?php } else { ?> <h2><?php _e('Language Management (qTranslate Configuration)', 'qtranslate'); ?> </h2> <p class="qtranxs_heading" style="font-size: small"><?php printf(__('For help on how to configure qTranslate correctly, take a look at the <a href="%1$s">qTranslate FAQ</a> and the <a href="%2$s">Support Forum</a>.', 'qtranslate'), 'https://qtranslatexteam.wordpress.com/faq/', 'https://wordpress.org/support/plugin/qtranslate-x'); echo '<br><small><em>'; printf(__('Plugin development is supported through your %sdonations to the development team%s.', 'qtranslate'), '<a href="https://qtranslatexteam.wordpress.com/donations/" target="_blank">', '</a>'); ?> </em></small></p> <?php if (isset($_GET['config_inspector'])) { $admin_config = $q_config['admin_config']; $admin_config = apply_filters('qtranslate_load_admin_page_config', $admin_config); $admin_config = apply_filters('i18n_admin_config', $admin_config); $front_config = $q_config['front_config']; $front_config = apply_filters('i18n_front_config', $front_config); $configs = array(); $configs['vendor'] = 'combined effective configuration'; $configs['admin-config'] = $admin_config; $configs['front-config'] = $front_config; $configs = qtranxf_standardize_i18n_config($configs); ?> <p class="qtranxs_notes"><a href="<?php echo admin_url('options-general.php?page=qtranslate-x#integration'); ?> "><?php _e('back to configuration page', 'qtranslate'); ?> </a></p> <h3 class="heading"><?php _e('Configuration Inspector', 'qtranslate'); ?> </h3> <p class="qtranxs_explanation"> <?php printf(__('Review a combined JSON-encoded configuration as loaded from options %s and %s, as well as from the theme and other plugins via filters %s and %s.', 'qtranslate'), '"' . __('Configuration Files', 'qtranslate') . '"', '"' . __('Custom Configuration', 'qtranslate') . '"', '"i18n_admin_config"', '"i18n_front_config"'); echo ' '; printf(__('Please, read %sIntegration Guide%s for more information.', 'qtranslate'), '<a href="https://qtranslatexteam.wordpress.com/integration/" target="_blank">', '</a>'); ?> </p> <p class="qtranxs_explanation"><textarea class="widefat" rows="30"><?php echo qtranxf_json_encode($configs); ?> </textarea></p> <p class="qtranxs_notes"><?php printf(__('Note to developers: ensure that front-end filter %s is also active on admin side, otherwise the changes it makes will not show up here. Having this filter active on admin side does not affect admin pages functionality, except this field.', 'qtranslate'), '"i18n_front_config"'); ?> </p> <p class="qtranxs_notes"><a href="<?php echo admin_url('options-general.php?page=qtranslate-x#integration'); ?> "><?php _e('back to configuration page', 'qtranslate'); ?> </a></p> <?php } else { // Set Navigation Tabs $admin_sections = qtranxf_get_admin_sections(); echo '<h2 class="nav-tab-wrapper">' . PHP_EOL; foreach ($admin_sections as $slug => $name) { echo '<a class="nav-tab" href="#' . $slug . '" title="' . sprintf(__('Click to switch to %s', 'qtranslate'), $name) . '">' . $name . '</a>' . PHP_EOL; } echo '</h2>' . PHP_EOL; ?> <form id="qtranxs-configuration-form" action="<?php echo $clean_uri; ?> " method="post"> <?php wp_nonce_field($nonce_action); // Prevent CSRF ?> <div class="tabs-content"><?php //<!-- tabs-container --> ?> <?php qtranxf_admin_section_start('general'); $permalink_is_query = qtranxf_is_permalink_structure_query(); //qtranxf_dbg_echo('$permalink_is_query: ',$permalink_is_query); $url_mode = $q_config['url_mode']; ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Default Language / Order', 'qtranslate'); ?> </th> <td><p class="qtranxs_explanation"><?php echo __('Every multilingual field is expected to have a meaningful content in the "Default Language". Usually, it is the language of your site before it became multilingual.', 'qtranslate'); echo ' '; echo __('Order of languages defines in which order they are listed, when languages need to be listed, otherwise it is not important.', 'qtranslate'); ?> </p> <fieldset id="qtranxs-languages-menu"> <legend class="hidden"><?php _e('Default Language', 'qtranslate'); ?> </legend> <table id="qtranxs-enabled-languages"> <?php $flag_location = qtranxf_flag_location(); foreach (qtranxf_getSortedLanguages() as $key => $language) { echo '<tr>'; echo '<td><label title="' . $q_config['language_name'][$language] . '"><input type="radio" name="default_language" value="' . $language . '"'; checked($language, $q_config['default_language']); echo ' />'; echo ' <a href="' . add_query_arg('moveup', $language, $clean_uri) . '"><img src="' . $pluginurl . 'arrowup.png" alt="up" /></a>'; echo ' <a href="' . add_query_arg('movedown', $language, $clean_uri) . '"><img src="' . $pluginurl . 'arrowdown.png" alt="down" /></a>'; echo ' <img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> '; echo ' ' . $q_config['language_name'][$language]; echo '</label></td>'; echo '<td>[:' . $language . ']</td><td><a href="' . $clean_uri . '&edit=' . $language . '">' . __('Edit', 'qtranslate') . '</a></td><td><a href="' . $clean_uri . '&disable=' . $language . '">' . __('Disable', 'qtranslate') . '</a></td>'; echo '</tr>' . PHP_EOL; } ?> </table> <p class="qtranxs_notes"><?php $url = get_bloginfo('url'); $url = qtranxf_convertURL($url, $q_config['default_language'], true); printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), $url); ?> </p> </fieldset> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('URL Modification Mode', 'qtranslate'); ?> </th> <td> <?php if ($permalink_is_query) { ?> <p><?php printf(__('Use one of the pretty %spermalinks%s, if the desirable mode is disabled.', 'qtranslate'), '<a href="' . admin_url('options-permalink.php') . '">', '</a>'); ?> </p> <?php } ?> <fieldset><legend class="hidden"><?php _e('URL Modification Mode', 'qtranslate'); ?> </legend> <label title="Query Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_QUERY; ?> " <?php checked($url_mode, QTX_URL_QUERY); ?> /> <?php echo __('Use Query Mode (?lang=en)', 'qtranslate') . '. ' . __('Most SEO unfriendly, not recommended.', 'qtranslate'); ?> </label><br/><br/> <?php /* if($permalink_is_query) { echo '<br/>'.PHP_EOL; printf(__('No other URL Modification Modes are available if permalink structure is set to "Default" on configuration page %sPermalink Setting%s. It is SEO advantageous to use some other permalink mode, which will enable more URL Modification Modes here as well.', 'qtranslate'),'<a href="'.admin_url('options-permalink.php').'">', '</a>'); echo PHP_EOL.'<br/><br/>'.PHP_EOL; }else{ */ ?> <label title="Pre-Path Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_PATH; ?> " <?php checked($url_mode, QTX_URL_PATH); disabled($permalink_is_query); ?> /> <?php echo __('Use Pre-Path Mode (Default, puts /en/ in front of URL)', 'qtranslate') . '. ' . __('SEO friendly.', 'qtranslate'); ?> </label><br/> <label title="Pre-Domain Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_DOMAIN; ?> " <?php checked($url_mode, QTX_URL_DOMAIN); ?> /> <?php echo __('Use Pre-Domain Mode (uses http://en.yoursite.com)', 'qtranslate') . '. ' . __('You will need to configure DNS sub-domains on your site.', 'qtranslate'); ?> </label><br/> <?php /* <p class="qtranxs_notes"><?php _e('Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode or Per-Domain mode.', 'qtranslate') ?></p><br/><br/> } */ ?> <label for="hide_default_language"> <input type="checkbox" name="hide_default_language" id="hide_default_language" value="1"<?php checked($q_config['hide_default_language']); ?> /> <?php _e('Hide URL language information for default language.', 'qtranslate'); ?> </label> <p class="qtranxs_notes"> <?php _e('This is only applicable to Pre-Path and Pre-Domain mode.', 'qtranslate'); ?> </p><br> <?php //if(!$permalink_is_query) { do_action('qtranslate_url_mode_choices', $permalink_is_query, $url_mode); ?> <label title="Per-Domain Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_DOMAINS; ?> " <?php checked($url_mode, QTX_URL_DOMAINS); ?> /> <?php echo __('Use Per-Domain mode: specify separate user-defined domain for each language.', 'qtranslate'); ?> </label> <?php //} ?> </fieldset> </td> </tr> <?php if ($url_mode == QTX_URL_DOMAINS) { $homeinfo = qtranxf_get_home_info(); $home_host = $homeinfo['host']; //parse_url(get_option('home'),PHP_URL_HOST); foreach ($q_config['enabled_languages'] as $lang) { $id = 'language_domain_' . $lang; $domain = isset($q_config['domains'][$lang]) ? $q_config['domains'][$lang] : $lang . '.' . $home_host; echo '<tr><td style="text-align: right">' . __('Domain for', 'qtranslate') . ' <a href="' . $clean_uri . '&edit=' . $lang . '">' . $q_config['language_name'][$lang] . '</a> (' . $lang . '):</td><td><input type="text" name="' . $id . '" id="' . $id . '" value="' . $domain . '" style="width:100%"/></td></tr>' . PHP_EOL; } } ?> <tr valign="top"> <th scope="row"><?php _e('Untranslated Content', 'qtranslate'); ?> </th> <td> <p class="qtranxs_explanation"><?php printf(__('The choices below define how to handle untranslated content at front-end of the site. A content of a page or a post is considered untranslated if the main text (%s) is empty for a given language, regardless of other fields like title, excerpt, etc. All three options are independent of each other.', 'qtranslate'), 'post_content'); ?> </p> <br/> <label for="hide_untranslated"><input type="checkbox" name="hide_untranslated" id="hide_untranslated" value="1"<?php checked($q_config['hide_untranslated']); ?> /> <?php _e('Hide Content which is not available for the selected language.', 'qtranslate'); ?> </label> <br/> <p class="qtranxs_notes"><?php _e('When checked, posts will be hidden if the content is not available for the selected language. If unchecked, a message will appear showing all the languages the content is available in.', 'qtranslate'); ?> <?php _e('The message about available languages for the content of a post or a page may also appear if a single post display with an untranslated content if viewed directly.', 'qtranslate'); ?> <?php printf(__('This function will not work correctly if you installed %s on a blog with existing entries. In this case you will need to take a look at option "%s" under "%s" section.', 'qtranslate'), 'qTranslate', __('Convert Database', 'qtranslate'), __('Import', 'qtranslate') . '/' . __('Export', 'qtranslate')); ?> </p> <br/> <label for="show_displayed_language_prefix"><input type="checkbox" name="show_displayed_language_prefix" id="show_displayed_language_prefix" value="1"<?php checked($q_config['show_displayed_language_prefix']); ?> /> <?php _e('Show displayed language prefix when content is not available for the selected language.', 'qtranslate'); ?> </label> <br/> <p class="qtranxs_notes"><?php _e('This is relevant to all fields other than the main content of posts and pages. Such untranslated fields are always shown in an alternative available language, and will be prefixed with the language name in parentheses, if this option is on.', 'qtranslate'); ?> </p> <br/> <label for="show_alternative_content"><input type="checkbox" name="show_alternative_content" id="show_alternative_content" value="1"<?php checked($q_config['show_alternative_content']); ?> /> <?php _e('Show content in an alternative language when translation is not available for the selected language.', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php printf(__('When a page or a post with an untranslated content is viewed, a message with a list of other available languages is displayed, in which languages are ordered as defined by option "%s". If this option is on, then the content of the first available language will also be shown, instead of the expected language, for the sake of user convenience.', 'qtranslate'), __('Default Language / Order', 'qtranslate')); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Language Names', 'qtranslate'); ?> </th> <td> <label for="camel_case"><input type="checkbox" name="camel_case" id="camel_case" value="1"<?php checked(!isset($q_config['language_name_case']) || !$q_config['language_name_case']); ?> /> <?php _e('Show language names in "Camel Case".', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php printf(__('Define how to display translated language names, whenever languages need to be listed, for example, in "%s" statement.', 'qtranslate'), __('Not Available Message', 'qtranslate')); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Detect Browser Language', 'qtranslate'); ?> </th> <td> <label for="detect_browser_language"><input type="checkbox" name="detect_browser_language" id="detect_browser_language" value="1"<?php checked($q_config['detect_browser_language']); ?> /> <?php _e('Detect the language of the browser and redirect accordingly.', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php _e('When the frontpage is visited via bookmark/external link/type-in, the visitor will be forwarded to the correct URL for the language specified by his browser.', 'qtranslate'); ?> </p> </td> </tr> </table> <?php qtranxf_admin_section_end('general'); ?> <?php qtranxf_admin_section_start('advanced'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Post Types', 'qtranslate'); ?> </th> <td> <label for="post_types"><?php _e('Post types enabled for translation:', 'qtranslate'); ?> </label><p> <?php $post_types = get_post_types(); foreach ($post_types as $post_type) { if (!qtranxf_post_type_optional($post_type)) { continue; } $post_type_off = isset($q_config['post_type_excluded']) && in_array($post_type, $q_config['post_type_excluded']); ?> <span style="margin-right: 12pt"><input type="hidden" name="post_types_all[<?php echo $post_type; ?> ]" value="<?php echo $post_type_off ? '0' : '1'; ?> "><input type="checkbox" name="post_types[<?php echo $post_type; ?> ]" id="post_type_<?php echo $post_type; ?> " value="1"<?php checked(!$post_type_off); ?> /> <?php echo $post_type; ?> </span> <?php } ?> </p><p class="qtranxs_notes"><?php _e('If a post type unchecked, no fields in a post of that type are treated as translatable on editing pages. However, the manual raw multilingual entries with language tags may still get translated in a usual way at front-end.', 'qtranslate'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Flag Image Path', 'qtranslate'); ?> </th> <td> <?php echo trailingslashit(content_url()); ?> <input type="text" name="flag_location" id="flag_location" value="<?php echo $q_config['flag_location']; ?> " style="width:100%"/> <p class="qtranxs_notes"><?php printf(__('Path to the flag images under wp-content, with trailing slash. (Default: %s, clear the value above to reset it to the default)', 'qtranslate'), qtranxf_flag_location_default()); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Ignore Links', 'qtranslate'); ?> </th> <td> <input type="text" name="ignore_file_types" id="ignore_file_types" value="<?php echo implode(',', array_diff($q_config['ignore_file_types'], explode(',', QTX_IGNORE_FILE_TYPES))); ?> " style="width:100%"/> <p class="qtranxs_notes"><?php printf(__('Don\'t convert links to files of the given file types. (Always included: %s)', 'qtranslate'), implode(', ', explode(',', QTX_IGNORE_FILE_TYPES))); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Head inline CSS', 'qtranslate'); ?> </th> <td> <label for="header_css_on"><input type="checkbox" name="header_css_on" id="header_css_on" value="1"<?php checked($q_config['header_css_on']); ?> /> <?php _e('CSS code added by plugin in the head of front-end pages:', 'qtranslate'); ?> </label> <br /> <textarea id="header_css" name="header_css" style="width:100%"><?php echo esc_textarea($q_config['header_css']); ?> </textarea> <p class="qtranxs_notes"><?php echo __('To reset to default, clear the text.', 'qtranslate') . ' ' . __('To disable this inline CSS, clear the check box.', 'qtranslate'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Cookie Settings', 'qtranslate'); ?> </th> <td> <label for="disable_client_cookies"><input type="checkbox" name="disable_client_cookies" id="disable_client_cookies" value="1"<?php checked($q_config['disable_client_cookies']); disabled($url_mode == QTX_URL_DOMAIN || $url_mode == QTX_URL_DOMAINS); ?> /> <?php printf(__('Disable language client cookie "%s" (not recommended).', 'qtranslate'), QTX_COOKIE_NAME_FRONT); ?> </label> <p class="qtranxs_notes"><?php echo sprintf(__('Language cookie is auto-disabled for "%s" "Pre-Domain" and "Per-Domain", as language is always unambiguously defined by a url in those modes.', 'qtranslate'), __('URL Modification Mode', 'qtranslate')) . ' ' . sprintf(__('Otherwise, use this option with a caution, for simple enough sites only. If checked, the user choice of browsing language will not be saved between sessions and some AJAX calls may deliver unexpected language, as well as some undesired language switching during browsing may occur under certain themes (%sRead More%s).', 'qtranslate'), '<a href="https://qtranslatexteam.wordpress.com/2015/02/26/browser-redirection-based-on-language/" target="_blank">', '</a>'); ?> </p> <br /> <label for="use_secure_cookie"><input type="checkbox" name="use_secure_cookie" id="use_secure_cookie" value="1"<?php checked($q_config['use_secure_cookie']); ?> /><?php printf(__('Make %s cookies available only through HTTPS connections.', 'qtranslate'), 'qTranslate‑X'); ?> </label> <p class="qtranxs_notes"><?php _e("Don't check this if you don't know what you're doing!", 'qtranslate'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Update Gettext Databases', 'qtranslate'); ?> </th> <td> <label for="auto_update_mo"><input type="checkbox" name="auto_update_mo" id="auto_update_mo" value="1"<?php checked($q_config['auto_update_mo']); ?> /> <?php _e('Automatically check for .mo-Database Updates of installed languages.', 'qtranslate'); ?> </label> <br/> <label for="update_mo_now"><input type="checkbox" name="update_mo_now" id="update_mo_now" value="1" /> <?php _e('Update Gettext databases now.', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php _e('qTranslate will query the Wordpress Localisation Repository every week and download the latest Gettext Databases (.mo Files).', 'qtranslate'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Date / Time Conversion', 'qtranslate'); ?> </th> <td> <label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE; ?> " <?php checked($q_config['use_strftime'], QTX_DATE); ?> /> <?php _e('Use emulated date function.', 'qtranslate'); ?> </label><br/> <label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE_OVERRIDE; ?> " <?php checked($q_config['use_strftime'], QTX_DATE_OVERRIDE); ?> /> <?php _e('Use emulated date function and replace formats with the predefined formats for each language.', 'qtranslate'); ?> </label><br/> <label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME; ?> " <?php checked($q_config['use_strftime'], QTX_STRFTIME); ?> /> <?php _e('Use strftime instead of date.', 'qtranslate'); ?> </label><br/> <label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME_OVERRIDE; ?> " <?php checked($q_config['use_strftime'], QTX_STRFTIME_OVERRIDE); ?> /> <?php _e('Use strftime instead of date and replace formats with the predefined formats for each language.', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php _e('Depending on the mode selected, additional customizations of the theme may be needed.', 'qtranslate'); ?> </p> <?php /* <br/><br/> <label><?php _e('If one of the above options "... replace formats with the predefined formats for each language" is in use, then exclude the following formats from being overridden:', 'qtranslate') ?></label><br/> <input type="text" name="ex_date_formats" id="qtranxs_ex_date_formats" value="<?php echo isset($q_config['ex_date_formats']) ? implode(' ',$q_config['ex_date_formats']) : QTX_EX_DATE_FORMATS_DEFAULT; ?>" style="width:100%"><br/> */ ?> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Translation of options', 'qtranslate'); ?> </th> <td> <label for="filter_options_mode_all"><input type="radio" name="filter_options_mode" id="filter_options_mode_all" value=<?php echo '"' . QTX_FILTER_OPTIONS_ALL . '"'; checked($q_config['filter_options_mode'], QTX_FILTER_OPTIONS_ALL); ?> /> <?php _e('Filter all WordPress options for translation at front-end. It may hurt performance of the site, but ensures that all options are translated.', 'qtranslate'); ?> <?php _e('Starting from version 3.2.5, only options with multilingual content get filtered, which should help on performance issues.', 'qtranslate'); ?> </label> <br /> <label for="filter_options_mode_list"><input type="radio" name="filter_options_mode" id="filter_options_mode_list" value=<?php echo '"' . QTX_FILTER_OPTIONS_LIST . '"'; checked($q_config['filter_options_mode'], QTX_FILTER_OPTIONS_LIST); ?> /> <?php _e('Translate only options listed below (for experts only):', 'qtranslate'); ?> </label> <br /> <input type="text" name="filter_options" id="qtranxs_filter_options" value="<?php echo isset($q_config['filter_options']) ? implode(' ', $q_config['filter_options']) : QTX_FILTER_OPTIONS_DEFAULT; ?> " style="width:100%"> <p class="qtranxs_notes"><?php printf(__('By default, all options are filtered to be translated at front-end for the sake of simplicity of configuration. However, for a developed site, this may cause a considerable performance degradation. Normally, there are very few options, which actually need a translation. You may simply list them above to minimize the performance impact, while still getting translations needed. Options names must match the field "%s" of table "%s" of WordPress database. A minimum common set of option, normally needed a translation, is already entered in the list above as a default example. Option names in the list may contain wildcard with symbol "%s".', 'qtranslate'), 'option_name', 'options', '%'); ?> </p> </td> </tr> <tr valign="top" id="option_editor_mode"> <th scope="row"><?php _e('Editor Mode', 'qtranslate'); ?> </th> <td> <label for="qtranxs_editor_mode_lsb"><input type="radio" name="editor_mode" id="qtranxs_editor_mode_lsb" value="<?php echo QTX_EDITOR_MODE_LSB; ?> "<?php checked($q_config['editor_mode'], QTX_EDITOR_MODE_LSB); ?> /> <?php _e('Use Language Switching Buttons (LSB).', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php echo __('This is the default mode.', 'qtranslate') . ' ' . __('Pages with translatable fields have Language Switching Buttons, which control what language is being edited, while admin language stays the same.', 'qtranslate'); ?> </p><br/> <label for="qtranxs_editor_mode_raw"><input type="radio" name="editor_mode" id="qtranxs_editor_mode_raw" value="<?php echo QTX_EDITOR_MODE_RAW; ?> "<?php checked($q_config['editor_mode'], QTX_EDITOR_MODE_RAW); ?> /> <?php _e('Editor Raw Mode', 'qtranslate'); ?> . <?php _e('Do not use Language Switching Buttons to edit multi-language text entries.', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php _e('Some people prefer to edit the raw entries containing all languages together separated by language defining tags, as they are stored in database.', 'qtranslate'); ?> </p><br/> <label for="qtranxs_editor_mode_single"><input type="radio" name="editor_mode" id="qtranxs_editor_mode_single" value="<?php echo QTX_EDITOR_MODE_SINGLGE; ?> "<?php checked($q_config['editor_mode'], QTX_EDITOR_MODE_SINGLGE); ?> /> <?php echo __('Single Language Mode.', 'qtranslate') . ' ' . __('The language edited is the same as admin language.', 'qtranslate'); ?> </label> <p class="qtranxs_notes"><?php echo __('Edit language cannot be switched without page re-loading. Try this mode, if some of the advanced translatable fields do not properly respond to the Language Switching Buttons due to incompatibility with a plugin, which severely alters the default WP behaviour. This mode is the most compatible with other themes and plugins.', 'qtranslate') . ' ' . __('One may find convenient to use the default Editor Mode, while remembering not to switch edit languages on custom advanced translatable fields, where LSB do not work.', 'qtranslate'); ?> </p> </td> </tr> <?php $options = qtranxf_fetch_file_selection(QTRANSLATE_DIR . '/admin/css/opLSBStyle'); if ($options) { ?> <tr valign="top" id="option_lsb_style"> <th scope="row"><?php _e('LSB Style', 'qtranslate'); ?> </th> <td> <fieldset> <legend class="hidden"><?php _e('LSB Style', 'qtranslate'); ?> </legend> <label><?php printf(__('Choose CSS style for how Language Switching Buttons are rendered:', 'qtranslate')); ?> </label> <br/><?php printf(__('LSB %s-wrap classes:', 'qtranslate'), 'ul'); ?> <input type="text" name="lsb_style_wrap_class" id="lsb_style_wrap_class" value="<?php echo $q_config['lsb_style_wrap_class']; ?> " size="50" > <br/><?php _e('Active button class:', 'qtranslate'); ?> <input type="text" name="lsb_style_active_class" id="lsb_style_active_class" value="<?php echo $q_config['lsb_style_active_class']; ?> " size="40" > <p class="qtranxs_notes"><?php _e('The above is reset to an appropriate default, if the below is changed.', 'qtranslate'); ?> </p> <br/><?php _e('CSS set:', 'qtranslate'); ?> <select name="lsb_style" id="lsb_style"><?php foreach ($options as $nm => $val) { echo '<option value="' . $val . '"' . selected($val, $q_config['lsb_style']) . '>' . $nm . '</option>'; } echo '<option value="custom"' . selected('custom', $q_config['lsb_style']) . '>' . __('Use custom CSS', 'qtranslate') . '</option>'; ?> </select> <p class="qtranxs_notes"><?php printf(__('Choice "%s" disables this option and allows one to use its own custom CSS provided by other means.', 'qtranslate'), __('Use custom CSS', 'qtranslate')); ?> </p> </fieldset> </td> </tr> <?php } ?> <tr valign="top" id="option_highlight_mode"> <?php $highlight_mode = $q_config['highlight_mode']; // reset default custom CSS when the field is empty, or when the "custom" option is not checked if (empty($q_config['highlight_mode_custom_css']) || $highlight_mode != QTX_HIGHLIGHT_MODE_CUSTOM_CSS) { $highlight_mode_custom_css = qtranxf_get_admin_highlight_css($highlight_mode); } else { $highlight_mode_custom_css = $q_config['highlight_mode_custom_css']; } ?> <th scope="row"><?php _e('Highlight Style', 'qtranslate'); ?> </th> <td> <p class="qtranxs_explanation"><?php _e('When there are many integrated or customized translatable fields, it may become confusing to know which field has multilingual value. The highlighting of translatable fields may come handy then:', 'qtranslate'); ?> </p> <fieldset> <legend class="hidden"><?php _e('Highlight Style', 'qtranslate'); ?> </legend> <label title="<?php _e('Do not highlight the translatable fields.', 'qtranslate'); ?> "> <input type="radio" name="highlight_mode" value="<?php echo QTX_HIGHLIGHT_MODE_NONE; ?> " <?php checked($highlight_mode, QTX_HIGHLIGHT_MODE_NONE); ?> /> <?php _e('Do not highlight the translatable fields.', 'qtranslate'); ?> </label><br/> <label title="<?php _e('Show a line on the left border of translatable fields.', 'qtranslate'); ?> "> <input type="radio" name="highlight_mode" value="<?php echo QTX_HIGHLIGHT_MODE_BORDER_LEFT; ?> " <?php checked($highlight_mode, QTX_HIGHLIGHT_MODE_BORDER_LEFT); ?> /> <?php _e('Show a line on the left border of translatable fields.', 'qtranslate'); ?> </label><br/> <label title="<?php _e('Draw a border around translatable fields.', 'qtranslate'); ?> "> <input type="radio" name="highlight_mode" value="<?php echo QTX_HIGHLIGHT_MODE_BORDER; ?> " <?php checked($highlight_mode, QTX_HIGHLIGHT_MODE_BORDER); ?> /> <?php _e('Draw a border around translatable fields.', 'qtranslate'); ?> </label><br/> <label title="<?php _e('Show a shadow on the left of translatable fields.', 'qtranslate'); ?> "> <input type="radio" name="highlight_mode" value="<?php echo QTX_HIGHLIGHT_MODE_LEFT_SHADOW; ?> " <?php checked($highlight_mode, QTX_HIGHLIGHT_MODE_LEFT_SHADOW); ?> /> <?php _e('Show a shadow on the left of translatable fields.', 'qtranslate'); ?> </label><br/> <label title="<?php _e('Outline border around translatable fields.', 'qtranslate'); ?> "> <input type="radio" name="highlight_mode" value="<?php echo QTX_HIGHLIGHT_MODE_OUTLINE; ?> " <?php checked($highlight_mode, QTX_HIGHLIGHT_MODE_OUTLINE); ?> /> <?php _e('Outline border around translatable fields.', 'qtranslate'); ?> </label><br/> <label title="<?php _e('Use custom CSS', 'qtranslate'); ?> "> <input type="radio" name="highlight_mode" value="<?php echo QTX_HIGHLIGHT_MODE_CUSTOM_CSS; ?> " <?php checked($highlight_mode, QTX_HIGHLIGHT_MODE_CUSTOM_CSS); ?> /> <?php echo __('Use custom CSS', 'qtranslate') . ':'; ?> </label><br/> </fieldset><br /> <textarea id="highlight_mode_custom_css" name="highlight_mode_custom_css" style="width:100%"><?php echo esc_textarea($highlight_mode_custom_css); ?> </textarea> <p class="qtranxs_notes"><?php echo __('To reset to default, clear the text.', 'qtranslate') . ' '; printf(__('The color in use is taken from your profile option %s, the third color.', 'qtranslate'), '"<a href="' . admin_url('/profile.php') . '">' . qtranxf_translate_wp('Admin Color Scheme') . '</a>"'); ?> </p> </td> </tr> <?php /* <tr valign="top"> <th scope="row"><?php _e('Debugging Information', 'qtranslate') ?></th> <td> <p class="qtranxs_explanation"><?php printf(__('If you encounter any problems and you are unable to solve them yourself, you can visit the <a href="%s">Support Forum</a>. Posting the following Content will help other detect any misconfigurations.', 'qtranslate'), 'https://wordpress.org/support/plugin/qtranslate-x') ?></p> <textarea readonly="readonly" id="qtranxs_debug"><?php $q_config_copy = $q_config; // remove information to keep data anonymous and other not needed things unset($q_config_copy['url_info']); unset($q_config_copy['js']); unset($q_config_copy['windows_locale']); //unset($q_config_copy['pre_domain']); unset($q_config_copy['term_name']); echo htmlspecialchars(print_r($q_config_copy, true)); ?></textarea> </td> </tr> */ ?> </table> <?php qtranxf_admin_section_end('advanced'); ?> <?php qtranxf_admin_section_start('integration'); ?> <table class="form-table"> <tr valign="top"> <td scope="row" colspan="2"><p class="heading"><?php printf(__('If your theme or some plugins are not fully integrated with %s, suggest their authors to review the %sIntegration Guide%s. In many cases they would only need to create a simple text file in order to be fully compatible with %s. Alternatively, you may create such a file for them and for yourselves.', 'qtranslate'), 'qTranslate‑X', '<a href="https://qtranslatexteam.wordpress.com/integration/" target="_blank">', '</a>', 'qTranslate‑X'); echo ' '; printf(__('Read %sIntegration Guide%s for more information on how to customize the configuration of %s.', 'qtranslate'), '<a href="https://qtranslatexteam.wordpress.com/integration/" target="_blank">', '</a>', 'qTranslate‑X'); ?> </p></td> </tr> <tr valign="top"> <th scope="row"><?php _e('Configuration Files', 'qtranslate'); ?> </th> <td><label for="qtranxs_config_files" class="qtranxs_explanation"><?php printf(__('List of configuration files. Unless prefixed with "%s", paths are relative to %s variable: %s. Absolute paths are also acceptable.', 'qtranslate'), './', 'WP_CONTENT_DIR', trailingslashit(WP_CONTENT_DIR)); ?> </label> <br/><textarea name="json_config_files" id="qtranxs_config_files" rows="4" style="width:100%"><?php if (isset($_POST['json_config_files'])) { echo sanitize_text_field(stripslashes($_POST['json_config_files'])); } else { echo implode(PHP_EOL, $q_config['config_files']); } ?> </textarea> <p class="qtranxs_notes"><?php printf(__('The list gets auto-updated on a 3rd-party integrated plugin activation/deactivation. You may also add your own custom files for your theme or plugins. File "%s" is the default configuration loaded from this plugin folder. It is not recommended to modify any configuration file from other authors, but you may alter any configuration item through your own custom file appended to the end of this list.', 'qtranslate'), './i18n-config.json'); echo ' '; printf(__('Use "%s" to review the resulting combined configuration from all "%s" and this option.', 'qtranslate'), '<a href="' . admin_url('options-general.php?page=qtranslate-x&config_inspector=show') . '">' . __('Configuration Inspector', 'qtranslate') . '</a>', __('Custom Configuration', 'qtranslate')); echo ' '; printf(__('Please, read %sIntegration Guide%s for more information.', 'qtranslate'), '<a href="https://qtranslatexteam.wordpress.com/integration/" target="_blank">', '</a>'); echo ' ' . __('To reset to default, clear the text.', 'qtranslate'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Custom Configuration', 'qtranslate'); ?> </th> <td><label for="qtranxs_json_custom_i18n_config" class="qtranxs_explanation"><?php printf(__('Additional custom JSON-encoded configuration of %s for all admin pages. It is processed after all files from option "%s" are loaded, providing opportunity to add or to override configuration tokens as necessary.', 'qtranslate'), 'qTranslate‑X', __('Configuration Files', 'qtranslate')); ?> </label> <br/><textarea name="json_custom_i18n_config" id="qtranxs_json_custom_i18n_config" rows="4" style="width:100%"><?php if (isset($_POST['json_custom_i18n_config'])) { echo sanitize_text_field(stripslashes($_POST['json_custom_i18n_config'])); } else { if (!empty($q_config['custom_i18n_config'])) { echo qtranxf_json_encode($q_config['custom_i18n_config']); } } ?> </textarea> <p class="qtranxs_notes"><?php printf(__('It would make no difference, if the content of this field is stored in a file, which name is listed last in option "%s". Therefore, this field only provides flexibility for the sake of convenience.', 'qtranslate'), __('Configuration Files', 'qtranslate')); echo ' '; printf(__('Please, read %sIntegration Guide%s for more information.', 'qtranslate'), '<a href="https://qtranslatexteam.wordpress.com/integration/" target="_blank">', '</a>'); echo ' '; printf(__('Use "%s" to review the resulting combined configuration from all "%s" and this option.', 'qtranslate'), '<a href="' . admin_url('options-general.php?page=qtranslate-x&config_inspector=show') . '">' . __('Configuration Inspector', 'qtranslate') . '</a>', __('Configuration Files', 'qtranslate')); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Custom Fields', 'qtranslate'); ?> </th> <td><p class="qtranxs_explanation"> <?php printf(__('Enter "%s" or "%s" attribute of text fields from your theme, which you wish to translate. This applies to post, page and media editors (%s). To lookup "%s" or "%s", right-click on the field in the post or the page editor and choose "%s". Look for an attribute of the field named "%s" or "%s". Enter it below, as many as you need, space- or comma-separated. After saving configuration, these fields will start responding to the language switching buttons, and you can enter different text for each language. The input fields of type %s will be parsed using %s syntax, while single line text fields will use %s syntax. If you need to override this behaviour, prepend prefix %s or %s to the name of the field to specify which syntax to use. For more information, read %sFAQ%s.', 'qtranslate'), 'id', 'class', '/wp-admin/post*', 'id', 'class', _x('Inspect Element', 'browser option', 'qtranslate'), 'id', 'class', '\'textarea\'', esc_html('<!--:-->'), '[:]', '\'<\'', '\'[\'', '<a href="https://qtranslatexteam.wordpress.com/faq/">', '</a>'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row" style="text-align: right">id</th> <td><label for="qtranxs_custom_fields" class="qtranxs_explanation"> <input type="text" name="custom_fields" id="qtranxs_custom_fields" value="<?php echo implode(' ', $q_config['custom_fields']); ?> " style="width:100%"></label> <p class="qtranxs_notes"><?php _e('The value of "id" attribute is normally unique within one page, otherwise the first field found, having an id specified, is picked up.', 'qtranslate'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row" style="text-align: right">class</th> <td><label for="qtranxs_custom_field_classes" class="qtranxs_explanation"> <input type="text" name="custom_field_classes" id="qtranxs_custom_field_classes" value="<?php echo implode(' ', $q_config['custom_field_classes']); ?> " style="width:100%"></label> <p class="qtranxs_notes"><?php printf(__('All the fields of specified classes will respond to Language Switching Buttons. Be careful not to include a class, which would affect language-neutral fields. If you cannot uniquely identify a field needed neither by %s, nor by %s attribute, report the issue on %sSupport Forum%s', 'qtranslate'), '"id"', '"class"', '<a href="https://wordpress.org/support/plugin/qtranslate-x">', '</a>'); ?> </p> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Custom Filters', 'qtranslate'); ?> </th> <td><label for="qtranxs_text_field_filters" class="qtranxs_explanation"> <input type="text" name="text_field_filters" id="qtranxs_text_field_filters" value="<?php echo implode(' ', $q_config['text_field_filters']); ?> " style="width:100%"></label> <p class="qtranxs_notes"><?php printf(__('Names of filters (which are enabled on theme or other plugins via %s function) to add translation to. For more information, read %sFAQ%s.', 'qtranslate'), 'apply_filters()', '<a href="https://qtranslatexteam.wordpress.com/faq/#CustomFields">', '</a>'); ?> </p> </td> </tr> <?php /* ?> <tr valign="top"> <th scope="row"><?php _e('Custom Admin Pages', 'qtranslate') ?></th> <td><label for="qtranxs_custom_pages" class="qtranxs_explanation"><input type="text" name="custom_pages" id="qtranxs_custom_pages" value="<?php echo implode(' ',$q_config['custom_pages']) ?>" style="width:100%"></label> <p class="qtranxs_notes"><?php printf(__('List the custom admin page paths for which you wish Language Switching Buttons to show up. The Buttons will then control fields configured in "Custom Fields" section. You may only include part of the full URL after %s, including a distinctive query string if needed. As many as desired pages can be listed space/comma separated. For more information, read %sFAQ%s.', 'qtranslate'),'/wp-admin/','<a href="https://qtranslatexteam.wordpress.com/faq/">','</a>') ?></p> </td> </tr> <?php */ ?> <tr valign="top"> <th scope="row"><?php _e('Compatibility Functions', 'qtranslate'); ?> </th> <td> <label for="qtranxs_qtrans_compatibility"><input type="checkbox" name="qtrans_compatibility" id="qtranxs_qtrans_compatibility" value="1"<?php checked($q_config['qtrans_compatibility']); ?> /> <?php printf(__('Enable function name compatibility (%s).', 'qtranslate'), 'qtrans_convertURL, qtrans_getAvailableLanguages, qtrans_generateLanguageSelectCode, qtrans_getLanguage, qtrans_getLanguageName, qtrans_getSortedLanguages, qtrans_join, qtrans_split, qtrans_use, qtrans_useCurrentLanguageIfNotFoundShowAvailable, qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage, qtrans_useDefaultLanguage, qtrans_useTermLib'); ?> </label><br/> <p class="qtranxs_notes"><?php printf(__('Some plugins and themes use direct calls to the functions listed, which are defined in former %s plugin and some of its forks. Turning this flag on will enable those function to exists, which will make the dependent plugins and themes to work. WordPress policy prohibits to define functions with the same names as in other plugins, since it generates user-unfriendly fatal errors, when two conflicting plugins are activated simultaneously. Before turning this option on, you have to make sure that there are no other plugins active, which define those functions.', 'qtranslate'), '<a href="https://wordpress.org/plugins/qtranslate/" target="_blank">qTranslate</a>'); ?> </p> </td> </tr> </table> <?php qtranxf_admin_section_end('integration'); // Allow to load additional services do_action('qtranslate_configuration', $clean_uri); ?> </div><?php //<!-- /tabs-container --> ?> </form> <?php } ?> </div><!-- /wrap --> <div class="wrap"> <div class="tabs-content"> <?php qtranxf_admin_section_start('languages'); class QTX_LanguageList extends WP_List_Table { private $_clean_uri; private $_language_names; public function __construct($language_names, $clean_uri) { parent::__construct(array('screen' => 'language')); $this->_language_names = $language_names; $this->_clean_uri = $clean_uri; } public function get_columns() { return array('code' => _x('Code', 'Two-letter Language Code meant.', 'qtranslate'), 'flag' => __('Flag', 'qtranslate'), 'name' => __('Name', 'qtranslate'), 'action' => __('Action', 'qtranslate'), 'edit' => __('Edit', 'qtranslate'), 'stored' => __('Stored', 'qtranslate')); } /* public function get_sortable_columns() { return array( 'code' => array('code',false), 'name' => array('name',true) //true means it's already sorted ); }*/ protected function column_default($item, $column_name) { return $item[$column_name]; } protected function get_default_primary_column_name() { return 'name'; } protected function display_tablenav($which) { } protected function get_table_classes() { return array('widefat', 'qtranxs-language-list'); } public function prepare_items() { global $q_config; $flags = qtranxf_language_configured('flag'); $languages_stored = get_option('qtranslate_language_names', array()); $languages_predef = qtranxf_default_language_name(); $flag_location_url = qtranxf_flag_location(); $flag_location_dir = trailingslashit(WP_CONTENT_DIR) . $q_config['flag_location']; $flag_location_url_def = content_url(qtranxf_flag_location_default()); //trailingslashit(content_url()).'/plugins/'.basename(dirname(QTRANSLATE_FILE)).'/flags/'; $clean_uri = $this->_clean_uri; $data = array(); foreach ($this->_language_names as $lang => $language) { if ($lang == 'code') { continue; } $flag = $flags[$lang]; if (file_exists($flag_location_dir . $flag)) { $flag_url = $flag_location_url . $flag; } else { $flag_url = $flag_location_url_def . $flag; } $data[] = array('code' => $lang, 'flag' => '<img src="' . $flag_url . '" alt="' . sprintf(__('%s Flag', 'qtranslate'), $language) . '">', 'name' => $language, 'action' => in_array($lang, $q_config['enabled_languages']) ? $q_config['default_language'] == $lang ? __('Default', 'qtranslate') : '<a class="edit" href="' . $clean_uri . '&disable=' . $lang . '#languages">' . __('Disable', 'qtranslate') . '</a>' : '<a class="edit" href="' . $clean_uri . '&enable=' . $lang . '#languages">' . __('Enable', 'qtranslate') . '</a>', 'edit' => '<a class="edit" href="' . $clean_uri . '&edit=' . $lang . '">' . __('Edit', 'qtranslate') . '</a>', 'stored' => !isset($languages_stored[$lang]) ? __('Pre-Defined', 'qtranslate') : '<a class="delete" href="' . $clean_uri . '&delete=' . $lang . '#languages">' . (isset($languages_predef[$lang]) ? __('Reset', 'qtranslate') : __('Delete', 'qtranslate')) . '</a>'); } $this->items = $data; } } ?> <div id="col-container"> <div id="col-right"> <div class="col-wrap"> <h3><?php _e('List of Configured Languages', 'qtranslate'); ?> </h3> <p class="qtranxs_notes"><?php $language_names = qtranxf_language_configured('language_name'); printf(__('Only enabled languages are loaded at front-end, while all %d configured languages are listed here.', 'qtranslate'), count($language_names)); echo ' '; _e('The table below contains both pre-defined and manually added or modified languages.', 'qtranslate'); echo ' '; printf(__('You may %s or %s a language, or %s manually added language, or %s previous modifications of a pre-defined language.', 'qtranslate'), '"' . __('Enable', 'qtranslate') . '"', '"' . __('Disable', 'qtranslate') . '"', '"' . __('Delete', 'qtranslate') . '"', '"' . __('Reset', 'qtranslate') . '"'); echo ' '; printf(__('Click %s to modify language properties.', 'qtranslate'), '"' . __('Edit', 'qtranslate') . '"'); ?> </p> <?php $tbl = new QTX_LanguageList($language_names, $clean_uri); $tbl->prepare_items(); $tbl->display(); /* ?> <table class="widefat"> <thead><tr><?php $tbl->print_column_headers(true) ?></tr></thead> <tbody id="the-list" class="qtranxs-language-list" class="list:cat"> <?php $flags = qtranxf_language_configured('flag'); $languages_stored = get_option('qtranslate_language_names',array()); $languages_predef = qtranxf_default_language_name(); $flag_location_url = qtranxf_flag_location(); $flag_location_dir = trailingslashit(WP_CONTENT_DIR).$q_config['flag_location']; $flag_location_url_def = content_url(qtranxf_flag_location_default()); //trailingslashit(content_url()).'/plugins/'.basename(dirname(QTRANSLATE_FILE)).'/flags/'; foreach($language_names as $lang => $language){ if($lang=='code') continue; $flag = $flags[$lang]; if(file_exists($flag_location_dir.$flag)){ $flag_url = $flag_location_url.$flag; }else{ $flag_url = $flag_location_url_def.$flag; } ?> <tr> <td><?php echo $lang; ?></td> <td><img src="<?php echo $flag_url; ?>" alt="<?php echo sprintf(__('%s Flag', 'qtranslate'), $language) ?>"></td> <td><?php echo $language; ?></td> <td><?php if(in_array($lang,$q_config['enabled_languages'])) { if($q_config['default_language']==$lang){ _e('Default', 'qtranslate'); } else{ ?><a class="edit" href="<?php echo $clean_uri; ?>&disable=<?php echo $lang; ?>#languages"><?php _e('Disable', 'qtranslate') ?></a><?php } } else { ?><a class="edit" href="<?php echo $clean_uri; ?>&enable=<?php echo $lang; ?>#languages"><?php _e('Enable', 'qtranslate') ?></a><?php } ?></td> <td><a class="edit" href="<?php echo $clean_uri; ?>&edit=<?php echo $lang; ?>"><?php _e('Edit', 'qtranslate') ?></a></td> <td><?php if(!isset($languages_stored[$lang])){ _e('Pre-Defined', 'qtranslate'); } else { ?><a class="delete" href="<?php echo $clean_uri; ?>&delete=<?php echo $lang; ?>#languages"><?php if(isset($languages_predef[$lang])) _e('Reset', 'qtranslate'); else _e('Delete', 'qtranslate') ?></a><?php } ?></td> </tr> <?php } ?> </tbody> <tfoot><tr><?php $tbl->print_column_headers(false) ?></tr></tfoot> </table> <?php */ ?> <p class="qtranxs_notes"><?php _e('Enabling a language will cause qTranslate to update the Gettext-Database for the language, which can take a while depending on your server\'s connection speed.', 'qtranslate'); ?> </p> </div> </div> <div id="col-left"> <div class="col-wrap"> <div class="form-wrap"> <h3><?php _e('Add Language', 'qtranslate'); ?> </h3> <form action="<?php echo $clean_uri; ?> " name="addlang" id="addlang" method="post" class="add:the-list: validate"> <?php wp_nonce_field($nonce_action); // Prevent CSRF qtranxf_language_form(); qtranxf_admin_section_end('languages', __('Add Language »', 'qtranslate')); ?> </form></div></div></div></div></div> <?php } ?> </div> <?php }
function qtrans_convertURL($url = '', $lang = '', $forceadmin = false, $showDefaultLanguage = false) { return qtranxf_convertURL($url, $lang, $forceadmin, $showDefaultLanguage); }
/** * @since 3.2.8 moved here from _hooks.php */ function qtranxf_convertBlogInfoURL($url, $what) { switch ($what) { case 'stylesheet_url': case 'template_url': case 'template_directory': case 'stylesheet_directory': return $url; default: return qtranxf_convertURL($url); } }
function qtranxf_customize_allowed_urls($urls) { global $q_config; $home = home_url('/', is_ssl() ? 'https' : 'http'); $urls[] = $home; foreach ($q_config['enabled_languages'] as $lang) { $url = qtranxf_convertURL($home, $lang, true, true); $urls[] = $url; } if ($q_config['hide_default_language']) { $urls[] = qtranxf_convertURL($home, $q_config['default_language'], true, false); } return $urls; }
function qtranxf_use_block($lang, $blocks, $show_available = false, $show_empty = false) { global $q_config; $content = qtranxf_split_blocks($blocks); // if content is available show the content in the requested language if (!empty($content[$lang])) { return $content[$lang]; } elseif ($show_empty) { return ''; } // content is not available in requested language (bad!!) what now? // find available and alternative languages if (empty($content[$q_config['default_language']])) { $alt_lang = null; $alt_content = null; $alt_lang_is_default = false; } else { $alt_lang = $q_config['default_language']; $alt_content = $content[$alt_lang]; $alt_lang_is_default = true; } $available_languages = array(); foreach ($content as $language => $lang_text) { if (empty($lang_text)) { continue; } if (!qtranxf_isEnabled($language)) { continue; } $available_languages[] = $language; if (empty($alt_lang)) { $alt_lang = $language; $alt_content = $lang_text; } } if (!$alt_lang) { return ''; } if (!$show_available) { if ($q_config['show_displayed_language_prefix']) { return '(' . $q_config['language_name'][$alt_lang] . ') ' . $alt_content; } else { return $alt_content; } /* // check if content is available in default language, if not return first language found. (prevent empty result) $language = $q_config['default_language']; if(!isset($available_languages[$language])){ } if($lang!=$q_config['default_language']){ $language = $q_config['default_language']; $lang_text = $content[$language]; //$lang_text = trim($lang_text); if(!empty($lang_text)){ if ($q_config['show_displayed_language_prefix']) return '('.$q_config['language_name'][$language].') '.$lang_text; else return $lang_text; } } foreach($content as $language => $lang_text) { $lang_text = trim($lang_text); if(empty($lang_text)) continue; if ($q_config['show_displayed_language_prefix']) return '('.$q_config['language_name'][$language].') '.$lang_text; else return $lang_text; } */ } // display selection for available languages //$available_languages = array_unique($available_languages); $language_list = ''; if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) { $normal_separator = $match[1]; $end_separator = $match[2]; // build available languages string backward $i = 0; foreach ($available_languages as $language) { if ($i == 1) { $language_list = $end_separator . $language_list; } if ($i > 1) { $language_list = $normal_separator . $language_list; } $language_list = '<a href="' . qtranxf_convertURL('', $language, false, true) . '">' . $q_config['language_name'][$language] . '</a>' . $language_list; ++$i; } } //qtranxf_dbg_echo('$language_list=',$language_list,true); //if(isset($post)){ // //qtranxf_dbg_echo('$post='.$post); //} if (!empty($q_config['show_alternative_content']) && $q_config['show_alternative_content']) { // show content in alternative language if (sizeof($available_languages) > 1) { if ($alt_lang_is_default) { //$fmt = __('For the sake of viewer convenience, the content is shown below in this site default language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in this site default language.', 'qtranslate'); } else { //$fmt = __('For the sake of viewer convenience, the content is shown below in an available alternative language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in one of the available alternative languages.', 'qtranslate'); } //$msg = sprintf($fmt, '<a href="'.qtranxf_convertURL('', $language, false, true).'">'.$q_config['language_name'][$alt_lang].'</a>'); $msg .= ' ' . __('You may click one of the links to switch the site language to another available language.', 'qtranslate'); } else { $msg = __('For the sake of viewer convenience, the content is shown below in the alternative language.', 'qtranslate'); $msg .= ' ' . __('You may click the link to switch the active language.', 'qtranslate'); } $altlanguagecontent = ' ' . $msg . '</p>' . $alt_content; } else { //by default, do not show alternative content $altlanguagecontent = '</p>'; } return '<p>' . preg_replace('/%LANG:([^:]*):([^%]*)%/', $language_list, $q_config['not_available'][$lang]) . $altlanguagecontent; }
/** * adds single-language sitemap links to the Yoast configuration page for XML Sitemaps. */ function qwpseo_xmlsitemaps_config() { global $q_config; $options = get_option('wpseo_xml'); //qtranxf_dbg_log('qwpseo_xmlsitemaps_config: $options: ',$options); if (empty($options['enablexmlsitemap'])) { return; } printf(__('%sNotes from %s' . PHP_EOL), '<h3>', 'qTranslate‑X</h3>'); echo '<p>' . PHP_EOL; echo __('In addition to main XML Sitemap, you may also view sitemaps for each individual language:') . PHP_EOL; echo '<ul>' . PHP_EOL; $sitemap_index_url = qtranxf_convertURL(get_option('home') . '/sitemap_index.xml', $q_config['default_language'], true); $url = home_url('i18n-index-sitemap.xml'); $rb = ''; foreach ($q_config['enabled_languages'] as $lang) { $href = qtranxf_convertURL($url, $lang, true, true); $u = $q_config['default_language'] == $lang ? qtranxf_convertURL($url, $lang, true, false) : $href; echo '<li>' . $q_config['language_name'][$lang] . ' (' . $lang . ', ' . $q_config['locale'][$lang] . '): <a href="' . $href . '" target="_blank">' . $u . '</a></li>' . PHP_EOL; $rb .= 'Sitemap: ' . $u . PHP_EOL; } echo '</ul><br />' . PHP_EOL; printf(__('It is advisable to append the site\'s "%s" with the list of index sitemaps separated by language'), '/robots.txt'); $nmaps = count($q_config['enabled_languages']) + 1; echo '<br /><textarea class="widefat" rows="' . $nmaps . '" name="robots-sitemaps" readonly="readonly">' . $rb . '</textarea>' . PHP_EOL; //echo '<pre>'.$rb.'</pre>'.PHP_EOL; echo '<br />or with this single entry of flat multilingual index sitemap<br /><textarea class="widefat" rows="2" name="robots-sitemap" readonly="readonly">Sitemap: ' . $sitemap_index_url . '</textarea>' . PHP_EOL; echo '<br />Do not combine two sets together, since they both equally cover all languages in all pages as defined by Yoast configuration.'; echo '</p>' . PHP_EOL; }
$current_url = get_permalink(); } // Obtaining from Qtranslate if (function_exists('qtrans_getSortedLanguages')) { $current_lang = qtrans_getLanguage(); $languages = qtrans_getSortedLanguages(); foreach ($languages as $lang) { $display_languages[$lang] = array('name' => $lang, 'url' => qtrans_convertURL($current_url, $lang, 0, 1)); } } // Obtaining from Qtranslate W if (function_exists('qtranxf_getSortedLanguages')) { $current_lang = qtranxf_getLanguage(); $languages = qtranxf_getSortedLanguages(); foreach ($languages as $lang) { $display_languages[$lang] = array('name' => $lang, 'url' => qtranxf_convertURL($current_url, $lang, 0, 1)); } } // Obtaining from Polylang if (function_exists('pll_current_language')) { global $polylang; $current_lang = pll_current_language(); $poly_langs = pll_the_languages(array('raw' => 1, 'echo' => 0)); foreach ($poly_langs as $lang) { $display_languages[$lang['slug']] = array('name' => $lang['slug'], 'url' => $lang['url']); } } if (!empty($display_languages)) { echo '<div class="languages">'; foreach ($display_languages as $lang) { echo '<a hreflang="' . $lang['name'] . '" ' . ($lang['name'] == $current_lang ? 'class="current"' : '') . ' href="' . $lang['url'] . '"><span>' . $lang['name'] . '</span></a>';
function qwpseo_sitemap_index($sm) { global $q_config, $wpseo_sitemaps; if (isset($q_config['sitemap-type'])) { return; } //qtranxf_dbg_log('qwpseo_sitemap_index: $wpseo_sitemaps: ', $wpseo_sitemaps); ob_start(); $wpseo_sitemaps->output(); $content = ob_get_contents(); ob_end_clean(); //qtranxf_dbg_log('qwpseo_sitemap_index: $content: ', $content); $p = 0; $sitemaps = array(); while (($p = strpos($content, '<sitemap>', $p)) !== false) { if (($e = strpos($content, '</sitemap>', $p)) !== false) { $len = $e - $p + strlen('</sitemap>'); $s = substr($content, $p, $len); //qtranxf_dbg_log('qwpseo_sitemap_index: $s: ', $s); $p += $len; $sitemaps[] = $s; } else { $p += strlen('<sitemap>'); } } $sm = ''; foreach ($q_config['enabled_languages'] as $lang) { //if($lang == $q_config['default_language']) continue; if ($lang == $q_config['language']) { continue; } //$sm .= preg_replace('!<loc>(.*)/([^/]+)</loc>!','<loc>$1/'.$lang.'-$2</loc>',$s); foreach ($sitemaps as $s) { if (preg_match('!<loc>([^<]+)</loc>!', $s, $matches)) { $loc = $matches[1]; $sm .= preg_replace('!<loc>([^<]+)</loc>!', '<loc>' . qtranxf_convertURL($loc, $lang) . '</loc>', $s); } } } //qtranxf_dbg_log('qwpseo_sitemap_index: $sm: ', $sm); return $sm; }
function language_converturl($url = null, $language = null) { global $slideshow_languageplugin; if (!empty($url) && !empty($language)) { switch ($slideshow_languageplugin) { case 'qtranslate': $url = qtrans_convertURL($url, $language); break; case 'qtranslate-x': $url = qtranxf_convertURL($url, $language); break; case 'wpml': if (function_exists('icl_get_languages')) { $languages = icl_get_languages(); $language = $this->language_current(); if (!empty($languages[$language]['url'])) { //$url = $languages[$language]['url']; } } break; } } return $url; }
function qtranxf_use_block($lang, $blocks, $show_available = false, $show_empty = false) { global $q_config; //qtranxf_dbg_log('qtranxf_use_language('.$lang.') $text: ', $text); //qtranxf_dbg_log('qtranxf_use_language: $blocks: ', $blocks); $available_langs = array(); $content = qtranxf_split_blocks($blocks, $available_langs); //qtranxf_dbg_log('qtranxf_use_block: $content: ',$content); //qtranxf_dbg_log('qtranxf_use_block: $available_langs: ',$available_langs); // if content is available show the content in the requested language if (!empty($available_langs[$lang])) { return $content[$lang]; } elseif ($show_empty) { return ''; } // content is not available in requested language (bad!!) what now? //remove available languages that are not enabled foreach ($available_langs as $language => $b) { if (qtranxf_isEnabled($language)) { continue; } unset($available_langs[$language]); } // set alternative language if (empty($available_langs[$q_config['default_language']])) { $alt_lang = null; $alt_content = null; $alt_lang_is_default = false; foreach ($available_langs as $language => $b) { $alt_lang = $language; $alt_content = $content[$language]; break; } } else { $alt_lang = $q_config['default_language']; $alt_content = $content[$alt_lang]; $alt_lang_is_default = true; } if (!$alt_lang) { return ''; } if (!$show_available) { if ($q_config['show_displayed_language_prefix']) { return '(' . $q_config['language_name'][$alt_lang] . ') ' . $alt_content; } else { return $alt_content; } } //qtranxf_dbg_log('$alt_content=',$alt_content); // display selection for available languages $language_list = ''; if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) { $normal_separator = $match[1]; $end_separator = $match[2]; if (!is_textdomain_loaded('language-names')) { //is not loaded by default, since this place should not be hit frequently $locale = $q_config['locale'][$q_config['language']]; load_textdomain('language-names', QTRANSLATE_DIR . '/lang/language-names/language-' . $locale . '.mo'); } $translations = get_translations_for_domain('language-names'); // build available languages string backward $i = 0; foreach ($available_langs as $language => $b) { if ($i == 1) { $language_list = $end_separator . $language_list; } elseif ($i > 1) { $language_list = $normal_separator . $language_list; } $locale = $q_config['locale'][$language]; while (!isset($translations->entries[$locale])) { if ($locale[2] == '_') { $locale = substr($locale, 0, 2); if (isset($translations->entries[$locale])) { break; } } $locale = null; break; } if ($locale) { $language_name = $translations->entries[$locale]->translations[0]; $language_name = mb_convert_case($language_name, MB_CASE_TITLE); } else { $language_name = $q_config['language_name'][$language]; } $language_list = '“<a href="' . qtranxf_convertURL('', $language, false, true) . '" class="qtranxs-available-language-link qtranxs-available-language-link-' . $language . '">' . $language_name . '</a>”' . $language_list; ++$i; } } //qtranxf_dbg_log('$language_list=',$language_list); $msg = ''; if (!empty($q_config['show_alternative_content']) && $q_config['show_alternative_content']) { // show content in alternative language if (sizeof($available_langs) > 1) { if ($alt_lang_is_default) { //$fmt = __('For the sake of viewer convenience, the content is shown below in this site default language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in this site default language.', 'qtranslate'); } else { //$fmt = __('For the sake of viewer convenience, the content is shown below in an available alternative language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in one of the available alternative languages.', 'qtranslate'); } //$msg = sprintf($fmt, '<a href="'.qtranxf_convertURL('', $language, false, true).'">'.$q_config['language_name'][$alt_lang].'</a>'); $msg .= ' ' . __('You may click one of the links to switch the site language to another available language.', 'qtranslate'); } else { $msg = __('For the sake of viewer convenience, the content is shown below in the alternative language.', 'qtranslate'); $msg .= ' ' . __('You may click the link to switch the active language.', 'qtranslate'); } $altlanguagecontent = ' ' . $msg . '</p>' . $alt_content; } else { //by default, do not show alternative content $altlanguagecontent = '</p>'; } $output = '<p class="qtranxs-available-languages-message qtranxs-available-languages-message-' . $lang . '">' . preg_replace('/%LANG:([^:]*):([^%]*)%/', $language_list, $q_config['not_available'][$lang]) . $altlanguagecontent; /* todo documentation */ return apply_filters('i18n_content_translation_not_available', $output, $lang, $language_list, $alt_lang, $alt_content, $msg, $q_config); }
/** * Language Select Code for non-Widget users * @args is a hash array of options, which accepts the following keys: * ‘type’ – one of the values: ‘text’, ‘image’, ‘both’, ‘dropdown’ and ‘custom’, which match the choices on widget admin page. * ‘format’ – needs to be provided if ‘type’ is ‘custom’. Read help text to this option on widget admin page. * ‘id’ – id of widget, which is used as a distinctive string to create CSS entities. * @since 3.4.5 type of argument is changed, compatibility with old way is preserved. */ function qtranxf_generateLanguageSelectCode($args = array(), $id = '') { global $q_config; if (is_string($args)) { $type = $args; } elseif (is_bool($args) && $args) { $type = 'image'; } elseif (is_array($args)) { if (!empty($args['type'])) { $type = $args['type']; } if (empty($id) && !empty($args['id'])) { $id = $args['id']; } } if (empty($type)) { $type = 'text'; } else { switch ($type) { case 'text': case 'image': case 'both': case 'short': case 'css_only': case 'custom': case 'dropdown': break; default: $type = 'text'; } } if (empty($id)) { $id = 'qtranslate'; } $id .= '-chooser'; if (is_404()) { $url = get_option('home'); } else { $url = ''; } $flag_location = qtranxf_flag_location(); echo PHP_EOL . '<ul class="language-chooser language-chooser-' . $type . ' qtranxs_language_chooser" id="' . $id . '">' . PHP_EOL; switch ($type) { case 'image': case 'text': case 'css_only': case 'dropdown': foreach (qtranxf_getSortedLanguages() as $language) { $alt = $q_config['language_name'][$language] . ' (' . $language . ')'; $classes = array('lang-' . $language); if ($language == $q_config['language']) { $classes[] = 'active'; } echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtranxf_convertURL($url, $language, false, true) . '"'; // set hreflang echo ' hreflang="' . $language . '"'; echo ' title="' . $alt . '"'; if ($type == 'image') { echo ' class="qtranxs_image qtranxs_image_' . $language . '"'; } elseif ($type == 'text') { echo ' class="qtranxs_text qtranxs_text_' . $language . '"'; } elseif ($type == 'css_only') { // to be removed echo ' class="qtranxs_css qtranxs_css_' . $language . '"'; } echo '>'; if ($type == 'image') { echo '<img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $alt . '" />'; } echo '<span'; if ($type == 'image' || $type == 'css_only') { echo ' style="display:none"'; } echo '>' . $q_config['language_name'][$language] . '</span>'; echo '</a></li>' . PHP_EOL; } //echo '</ul><div class="qtranxs_widget_end"></div>'.PHP_EOL; if ($type == 'dropdown') { echo '<script type="text/javascript">' . PHP_EOL . '// <![CDATA[' . PHP_EOL; echo "var lc = document.getElementById('" . $id . "');" . PHP_EOL; echo "var s = document.createElement('select');" . PHP_EOL; echo "s.id = 'qtranxs_select_" . $id . "';" . PHP_EOL; echo "lc.parentNode.insertBefore(s,lc);" . PHP_EOL; // create dropdown fields for each language foreach (qtranxf_getSortedLanguages() as $language) { echo qtranxf_insertDropDownElement($language, qtranxf_convertURL($url, $language, false, true), $id); } // hide html language chooser text echo "s.onchange = function() { document.location.href = this.value;}" . PHP_EOL; echo "lc.style.display='none';" . PHP_EOL; echo '// ]]>' . PHP_EOL . '</script>' . PHP_EOL; } break; case 'both': foreach (qtranxf_getSortedLanguages() as $language) { $alt = $q_config['language_name'][$language] . ' (' . $language . ')'; echo '<li'; if ($language == $q_config['language']) { echo ' class="active"'; } echo '><a href="' . qtranxf_convertURL($url, $language, false, true) . '"'; echo ' class="qtranxs_flag_' . $language . ' qtranxs_flag_and_text" title="' . $alt . '">'; //echo '<img src="'.$flag_location.$q_config['flag'][$language].'"></img>'; echo '<span>' . $q_config['language_name'][$language] . '</span></a></li>' . PHP_EOL; } break; case 'short': // undocumented, to be removed foreach (qtranxf_getSortedLanguages() as $language) { $alt = $q_config['language_name'][$language] . ' (' . $language . ')'; echo '<li'; if ($language == $q_config['language']) { echo ' class="active"'; } echo '><a href="' . qtranxf_convertURL($url, $language, false, true) . '"'; echo ' class="qtranxs_short_' . $language . ' qtranxs_short" title="' . $alt . '">'; echo '<span>' . $language . '</span></a></li>' . PHP_EOL; } break; case 'custom': $format = isset($args['format']) ? $args['format'] : ''; foreach (qtranxf_getSortedLanguages() as $language) { $alt = $q_config['language_name'][$language] . ' (' . $language . ')'; $s = $flag_location . $q_config['flag'][$language]; $n = $q_config['language_name'][$language]; $content = $format; $content = str_replace('%f', '<img src="' . $s . '" alt="' . $alt . '" />', $content); $content = str_replace('%s', $s, $content); $content = str_replace('%n', $n, $content); if (strpos($content, '%a') !== FALSE) { $a = qtranxf_getLanguageName($language); //this is an expensive function, do not call without necessity. $content = str_replace('%a', $a == $n ? '' : $a, $content); } $content = str_replace('%c', $language, $content); $classes = array('language-chooser-item', 'language-chooser-item-' . $language); if ($language == $q_config['language']) { $classes[] = 'active'; } echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtranxf_convertURL($url, $language, false, true) . '" title="' . $alt . '">' . $content . '</a></li>' . PHP_EOL; } break; } echo '</ul><div class="qtranxs_widget_end"></div>' . PHP_EOL; }
/** * Language select function for templating * * @param $type (string) choose the type of menu: 'text', 'image', 'both', 'dropdown' * @param $args (array) some args for draw the menu: array( 'id', 'class', 'short' ); * * @since 1.0 */ public function language_menu($type = "text", $args = array()) { global $q_config; // default arguments $defaults = array('id' => "qts-lang-menu", 'class' => "qts-lang-menu", 'short' => false); $args = wp_parse_args($args, $defaults); $languages = call_user_func($this->get_plugin_prefix() . 'getSortedLanguages'); // every type switch ($type) { case 'image': case 'text': case 'both': $baseurl = dirname(plugins_url()); $num_languages = count($languages); echo "<ul id=\"{$args['id']}\" class=\"qts_type_{$type} {$args['class']}\">" . PHP_EOL; foreach ($languages as $index => $lang) { $url = $this->get_current_url($lang); // 43LC: hack to play nice with qtranslate-x if ("qtranxf_" === $this->plugin_prefix && $this->default_language === $lang) { $url = qtranxf_convertURL('', $lang, false, true); } $item_class = array(); if ((string) $q_config['language'] == (string) $lang) { $item_class[] = 'current-menu-item'; } if ($index == $num_languages - 1) { $item_class[] = 'last-child'; } $item_class = ' class="qts_lang_item ' . implode(' ', $item_class) . '"'; $language_name = $args['short'] ? $lang : $q_config['language_name'][$lang]; if ($type == 'image') { $link_class = " class=\"qtrans_flag qtrans_flag_{$lang}\""; $link_content = "<span style=\"display:none\">{$language_name}</span>"; } else { if ($type == 'both') { $link_class = " class=\"qts_both qtrans_flag qtrans_flag_{$lang}\""; $link_content = "{$language_name}"; } else { $link_class = ''; $link_content = $language_name; $link_flag = ''; } } if ($type == 'image' || $type == 'both') { $link_flag_url = $baseurl . '/' . $q_config['flag_location'] . $q_config['flag'][$lang]; //TODO: add i18n for alt attribute //43LC: hardcoding height and width $link_flag = "<img widht=\"18\" height=\"12\" src=\"{$link_flag_url}\" alt=\"{$language_name}\" />"; } echo "<li {$item_class}><a href=\"{$url}\" lang=\"{$lang}\" hreflang=\"{$lang}\"{$link_class}>{$link_flag}{$link_content}</a></li>" . PHP_EOL; } echo "</ul>" . PHP_EOL; break; case 'dropdown': echo "<select id=\"{$args['id']}\" class=\"{$args['class']}\" onchange=\"window.location.href=this.options[this.selectedIndex].value\">" . PHP_EOL; foreach ($languages as $index => $lang) { $url = $this->get_current_url($lang); $item_class = ''; if ((string) $q_config['language'] == (string) $lang) { $item_class = 'selected="selected"'; } $language_name = $args['short'] ? $lang : $q_config['language_name'][$lang]; echo "<option value=\"{$url}\" {$item_class}>{$language_name}</option>" . PHP_EOL; } echo "</select>" . PHP_EOL; break; } }
function qts_service() { global $q_config, $qts_public_key, $qts_error_messages; if (!isset($_REQUEST['post'])) { echo '<script type="text/javascript">document.location="edit.php";</script>'; printf(__('To translate a post, please go to the <a href="%s">edit posts overview</a>.', 'qtranslate'), 'edit.php'); exit; } $post_id = intval($_REQUEST['post']); $confirm = isset($_GET['confirm']) ? true : false; $translate_from = ''; $translate_to = ''; $translate_from_name = ''; $translate_to_name = ''; if (isset($_REQUEST['source_language']) && qtranxf_isEnabled($_REQUEST['source_language'])) { $translate_from = $_REQUEST['source_language']; } if (isset($_REQUEST['target_language']) && qtranxf_isEnabled($_REQUEST['target_language'])) { $translate_to = $_REQUEST['target_language']; } if ($translate_to == $translate_from) { $translate_to = ''; } $p = get_post($post_id); $post =& $p; if (!$post) { printf(__('Post with id "%s" not found!', 'qtranslate'), $post_id); return; } $default_service = intval(get_option('qts_default_service'), 5); $service_settings = get_option('qts_service_settings'); // Detect available Languages and possible target languages $available_languages = qtranxf_getAvailableLanguages($post->post_content); if ($available_languages === FALSE && !empty($post->post_content)) { $available_languages = array($q_config['default_language']); } if ($available_languages === FALSE || sizeof($available_languages) == 0) { $error = __('The requested Post has no content, no Translation possible.', 'qtranslate'); } // try to guess source and target language if (!in_array($translate_from, $available_languages)) { $translate_from = ''; } $missing_languages = array_diff($q_config['enabled_languages'], $available_languages); if (empty($translate_from) && in_array($q_config['default_language'], $available_languages) && $translate_to != $q_config['default_language']) { $translate_from = $q_config['default_language']; } if (empty($translate_to) && sizeof($missing_languages) == 1) { $translate_to = $missing_languages[0]; } if (in_array($translate_to, $available_languages)) { $message = __('The Post already has content for the selected target language. If a translation request is send, the current text for the target language will be overwritten.', 'qtranslate'); } if (sizeof($available_languages) == 1) { if ($available_languages[0] == $translate_to) { unset($translate_to); } $translate_from = $available_languages[0]; } elseif ($translate_from == '' && sizeof($available_languages) > 1) { $languages = qtranxf_getSortedLanguages(); foreach ($languages as $language) { if ($language != $translate_to && in_array($language, $available_languages)) { $translate_from = $language; break; } } } // link to current page with get variables $url_link = add_query_arg('post', $post_id); if (!empty($translate_to)) { $url_link = add_query_arg('target_language', $translate_to, $url_link); } if (!empty($translate_from)) { $url_link = add_query_arg('source_language', $translate_from, $url_link); } // get correct title and content $post_title = qtranxf_use($translate_from, $post->post_title); $post_content = qtranxf_use($translate_from, $post->post_content); $post_excerpt = qtranxf_use($translate_from, $post->post_excerpt); if (!empty($translate_from)) { $translate_from_name = $q_config['language_name'][$translate_from]; } if (!empty($translate_to)) { $translate_to_name = $q_config['language_name'][$translate_to]; } $post_title_html = htmlspecialchars($post_title); $permalink = get_permalink($post_id); if ($permalink) { if ($translate_from_name) { $permalink = qtranxf_convertURL($translate_from_name, $permalink); } $post_title_html = '<a href="' . $permalink . '" target="_blank">' . $post_title_html . '</a>'; } if (!empty($translate_from) && !empty($translate_to)) { $title = sprintf('Translate "%1$s" from %2$s to %3$s', $post_title_html, $translate_from_name, $translate_to_name); } elseif (!empty($translate_from)) { $title = sprintf('Translate "%1$s" from %2$s', $post_title_html, $translate_from_name); } else { $title = sprintf('Translate "%1$s"', $post_title_html); } // Check data if (isset($_POST['service_id'])) { $service_id = intval($_POST['service_id']); $default_service = $service_id; update_option('qts_default_service', $service_id); $order_key = substr(md5(time() . AUTH_KEY), 0, 20); $request = array('order_service_id' => $service_id, 'order_url' => get_option('home'), 'order_key' => $order_key, 'order_title' => $post_title, 'order_text' => $post_content, 'order_excerpt' => $post_excerpt, 'order_source_language' => $translate_from, 'order_source_locale' => $q_config['locale'][$translate_from], 'order_target_language' => $translate_to, 'order_target_locale' => $q_config['locale'][$translate_to]); // check for additional fields if (isset($service_settings[$service_id]) && is_array($service_settings[$service_id])) { $request['order_required_field'] = array(); foreach ($service_settings[$service_id] as $setting => $value) { $request['order_required_field'][$setting] = $value; } } if (isset($_POST['token'])) { $request['order_token'] = $_POST['token']; } $answer = qts_queryQS(QTS_INIT_TRANSLATION, $request); if (isset($answer['error'])) { $error = sprintf(__('An error occured: %s', 'qtranslate'), $qts_error_messages[$answer['error']]); if ($answer['message'] != '') { $error .= '<br/>' . sprintf(__('Additional information: %s', 'qtranslate'), qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($answer['message'])); } } if (isset($answer['order_id'])) { $orders = get_option('qts_orders'); if (!is_array($orders)) { $orders = array(); } $orders[] = array('post_id' => $post_id, 'service_id' => $service_id, 'source_language' => $translate_from, 'target_language' => $translate_to, 'order' => array('order_key' => $order_key, 'order_id' => $answer['order_id'])); update_option('qts_orders', $orders); if (empty($answer['message'])) { $order_completed_message = ''; } else { $order_completed_message = htmlspecialchars($answer['message']); } qts_UpdateOrder($answer['order_id']); } } if (isset($error)) { ?> <div class="wrap"> <h2><?php _e('qTranslate Services', 'qtranslate'); ?> </h2> <div id="message" class="error fade"><p><?php echo $error; ?> </p></div> <p><?php printf(__('An serious error occured and qTranslate Services cannot proceed. For help, please visit the <a href="%s">Support Forum</a>', 'qtranslate'), 'http://www.qianqin.de/qtranslate/forum/'); ?> </p> </div> <?php return; } if (isset($order_completed_message)) { ?> <div class="wrap"> <h2><?php _e('qTranslate Services', 'qtranslate'); ?> </h2> <div id="message" class="updated fade"><p><?php _e('Order successfully sent.', 'qtranslate'); ?> </p></div> <p><?php _e('Your translation order has been successfully transfered to the selected service.', 'qtranslate'); ?> </p> <?php if (!empty($order_completed_message)) { ?> <p><?php printf(__('The service returned this message: %s', 'qtranslate'), $order_completed_message); ?> </p> <?php } ?> <p><?php _e('Feel free to choose an action:', 'qtranslate'); ?> </p> <ul> <li><a href="<?php echo add_query_arg('target_language', null, $url_link); ?> "><?php _e('Translate this post to another language.', 'qtranslate'); ?> </a></li> <li><a href="edit.php"><?php _e('Translate a different post.', 'qtranslate'); ?> </a></li> <li><a href="options-general.php?page=qtranslate-x#qtranslate_service_settings"><?php _e('View all open orders.', 'qtranslate'); ?> </a></li> <li><a href="options-general.php?page=qtranslate-x&qts_cron=true#qtranslate_service_settings"><?php _e('Let qTranslate Services check if any open orders are finished.', 'qtranslate'); ?> </a></li> <li><a href="<?php echo get_permalink($post_id); ?> "><?php _e('View this post.', 'qtranslate'); ?> </a></li> </ul> </div> <?php return; } ?> <div class="wrap"> <h2><?php _e('qTranslate Services', 'qtranslate'); ?> </h2> <?php if (!empty($message)) { ?> <div id="message" class="updated fade"><p><?php echo $message; ?> </p></div> <?php } ?> <h3><?php echo $title; ?> </h3> <form action="edit.php?page=qtranslate_services" method="post" id="qtranslate-services-translate"> <p><?php if (sizeof($available_languages) > 1) { $available_languages_name = array(); foreach (array_diff($available_languages, array($translate_from)) as $language) { $available_languages_name[] = '<a href="' . add_query_arg('source_language', $language, $url_link) . '">' . $q_config['language_name'][$language] . '</a>'; } $available_languages_names = join(", ", $available_languages_name); printf(__('Your article is available in multiple languages. If you do not want to translate from %1$s, you can switch to one of the following languages: %2$s', 'qtranslate'), $q_config['language_name'][$translate_from], $available_languages_names); } ?> </p> <input type="hidden" name="post" value="<?php echo $post_id; ?> "/> <input type="hidden" name="source_language" value="<?php echo $translate_from; ?> "/> <?php if (empty($translate_to)) { ?> <p><?php _e('Please choose the language you want to translate to:', 'qtranslate'); ?> </p> <ul> <?php foreach ($q_config['enabled_languages'] as $language) { if ($translate_from == $language) { continue; } ?> <li><label><input type="radio" name="target_language" value="<?php echo $language; ?> " /> <?php echo $q_config['language_name'][$language]; ?> </li> <?php } ?> </ul> <p class="submit"> <input type="submit" name="submit" class="button-primary" value="<?php _e('Continue', 'qtranslate'); ?> " /> </p> <?php } else { ?> <input type="hidden" name="target_language" value="<?php echo $translate_to; ?> "/> <?php if ($confirm) { ?> <input type="hidden" name="service_id" value="<?php echo $_REQUEST['service_id']; ?> "/> <input type="hidden" name="token" value="<?php echo $_REQUEST['token']; ?> "/> <div id="submitboxcontainer" class="metabox-holder"> <div id="submitdiv" class="postbox"> <h3 class="hndle"><?php _e('Confirm Order', 'qtranslate'); ?> </h3> <div class="inside"> <p><?php _e('Please confirm your order.', 'qtranslate'); ?> </p> <div class="qts_submit"><a class="button-primary" onclick="sendorder();"><?php _e('Confirm Order', 'qtranslate'); ?> </a></div> </div> </div> </div> <?php } else { ?> <div id="submitboxcontainer" class="metabox-holder"> <div id="submitdiv" class="postbox"> <h3 class="hndle"><?php _e('Request Translation', 'qtranslate'); ?> </h3> <div class="inside request"> <noscript><?php _e('Javascript is required for qTranslate Services', 'qtranslate'); ?> </noscript> <p><?php _e('Please choose a service first', 'qtranslate'); ?> </p> </div> </div> </div> <?php } $timestamp = time(); if ($timestamp != qts_queryQS(QTS_VERIFY, $timestamp)) { ?> <p class="error"><?php _e('ERROR: Could not connect to qTranslate Services. Please try again later.', 'qtranslate'); ?> </p> <?php return; } ?> <div id="qts_boxes" class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><?php _e('Translation Service', 'qtranslate'); ?> </h3> <div class="inside"> <ul> <?php if ($services = qts_queryQS(QTS_GET_SERVICES)) { $default_service_ok = false; foreach ($services as $service_id => $service) { if ($service_id != $default_service) { continue; } $default_service_ok = true; break; } if (!$default_service_ok) { foreach ($services as $service_id => $service) { $default_service = $service_id; break; } } foreach ($services as $service_id => $service) { // check if we have data for all required fields //if($service_id==1) continue;//qTranslate Services Test $requirements_matched = true; foreach ($service['service_required_fields'] as $field) { if (!isset($service_settings[$service_id][$field['name']]) || $service_settings[$service_id][$field['name']] == '') { $requirements_matched = false; } } if (!$requirements_matched) { ?> <li> <label><input type="radio" name="service_id" disabled="disabled" /> <b><?php echo qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_name']); ?> </b> ( <a href="<?php echo $service['service_url']; ?> " target="_blank"><?php _e('Website', 'qtranslate'); ?> </a> )</label> <p class="error"><?php printf(__('Cannot use this service, not all <a href="%s">required fields</a> filled in for this service.', 'qtranslate'), 'options-general.php?page=qtranslate-x#qts_service_' . $service_id); ?> </p> <p class="service_description"><?php echo qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_description']); ?> </p> </li> <?php } else { ?> <li><label><input type="radio" id="qts_service_<?php echo $service['service_id']; ?> " onclick="chooseservice(this.value)" value="<?php echo $service['service_id']; ?> "<?php checked($service['service_id'], $default_service); ?> <?php echo $confirm ? 'disabled="disabled"' : 'name="service_id"'; ?> /> <b><?php echo qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_name']); ?> </b> ( <a href="<?php echo $service['service_url']; ?> " target="_blank"><?php _e('Website', 'qtranslate'); ?> </a> )</label><p class="service_description"><?php echo qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($service['service_description']); ?> </p></li> <?php } } ?> </ul> <script type="text/javascript"> function chooseservice(id) { if(id == '0') return; jQuery('#qts_service_'+id).attr('checked','checked'); jQuery('#submitdiv .request').html('<?php _e('<p><img src="images/wpspin_light.gif"> Getting Quote...</p>', 'qtranslate'); ?> '); jQuery.post(ajaxurl, { action: 'qts_quote', translate_from: '<?php echo $translate_from; ?> ', translate_to: '<?php echo $translate_to; ?> ', service_id: id, post_id: '<?php echo $post_id; ?> '}, function(response) { eval(response); }); } function sendorder() { jQuery("#qtranslate-services-translate").submit(); } chooseservice('<?php echo isset($_REQUEST['service_id']) ? $_REQUEST['service_id'] : $default_service; ?> '); </script> </div> </div> <div class="postbox closed"> <div class="handlediv" title="<?php _e('Click to toggle'); ?> " onclick="jQuery(this).parent().removeClass('closed');jQuery(this).hide();"><br/></div> <h3 class="hndle"><?php _e('Review Article', 'qtranslate'); ?> </h3> <div class="inside"> <textarea name="qts_content_preview" id="qts_content_preview" readonly="readonly"><?php echo $post_content; ?> </textarea> </div> </div> <p><?php _e('Your article will be SSL encrypted and securly sent to qTranslate Services, which will forward your text to the chosen Translation Service. Once qTranslate Services receives the translated text, it will automatically appear on your blog.', 'qtranslate'); ?> </p> <?php } ?> </div> <?php } ?> </form> </div> <?php }
function qtranxf_use_block($lang, $blocks, $show_available = false, $show_empty = false) { global $q_config; $available_langs = array(); //$content = qtranxf_split_blocks($blocks); $content = qtranxf_split_blocks($blocks, $available_langs); //qtranxf_dbg_log('qtranxf_use_block: $available_langs: ',$available_langs); // if content is available show the content in the requested language //if(!empty($content[$lang])) return $content[$lang]; if (!empty($available_langs[$lang])) { return $content[$lang]; } elseif ($show_empty) { return ''; } // content is not available in requested language (bad!!) what now? // find available and alternative languages //if(empty($content[$q_config['default_language']])){ if (empty($available_langs[$q_config['default_language']])) { $alt_lang = null; $alt_content = null; $alt_lang_is_default = false; foreach ($available_langs as $language => $b) { if (!qtranxf_isEnabled($language)) { continue; } $alt_lang = $language; $alt_content = $content[$language]; break; } } else { $alt_lang = $q_config['default_language']; $alt_content = $content[$alt_lang]; $alt_lang_is_default = true; } /* $available_languages = array(); foreach($content as $language => $lang_text) { if(empty($lang_text)) continue; if(!qtranxf_isEnabled($language)) continue; $available_languages[] = $language; if(empty($alt_lang)){ $alt_lang = $language; $alt_content = $lang_text; } } */ if (!$alt_lang) { return ''; } if (!$show_available) { if ($q_config['show_displayed_language_prefix']) { return '(' . $q_config['language_name'][$alt_lang] . ') ' . $alt_content; } else { return $alt_content; } } //qtranxf_dbg_log('$alt_content=',$alt_content); // display selection for available languages $language_list = ''; if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) { $normal_separator = $match[1]; $end_separator = $match[2]; // build available languages string backward $translations = get_translations_for_domain('qtranslate'); $english_names = qtranxf_default_windows_locale(); //todo: load enabled only $i = 0; //foreach($available_languages as $language) { foreach ($available_langs as $language => $b) { if ($i == 1) { $language_list = $end_separator . $language_list; } elseif ($i > 1) { $language_list = $normal_separator . $language_list; } if (!empty($english_names[$language]) && isset($translations->entries[$english_names[$language]])) { $language_name = $translations->entries[$english_names[$language]]->translations[0]; } else { $language_name = $q_config['language_name'][$language]; } $language_list = '<a href="' . qtranxf_convertURL('', $language, false, true) . '" class="qtranxs-available-language-link qtranxs-available-language-link-' . $language . '">' . $language_name . '</a>' . $language_list; ++$i; } } //qtranxf_dbg_log('$language_list=',$language_list); $msg = ''; if (!empty($q_config['show_alternative_content']) && $q_config['show_alternative_content']) { // show content in alternative language //if(sizeof($available_languages) > 1){ if (sizeof($available_langs) > 1) { if ($alt_lang_is_default) { //$fmt = __('For the sake of viewer convenience, the content is shown below in this site default language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in this site default language.', 'qtranslate'); } else { //$fmt = __('For the sake of viewer convenience, the content is shown below in an available alternative language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in one of the available alternative languages.', 'qtranslate'); } //$msg = sprintf($fmt, '<a href="'.qtranxf_convertURL('', $language, false, true).'">'.$q_config['language_name'][$alt_lang].'</a>'); $msg .= ' ' . __('You may click one of the links to switch the site language to another available language.', 'qtranslate'); } else { $msg = __('For the sake of viewer convenience, the content is shown below in the alternative language.', 'qtranslate'); $msg .= ' ' . __('You may click the link to switch the active language.', 'qtranslate'); } $altlanguagecontent = ' ' . $msg . '</p>' . $alt_content; } else { //by default, do not show alternative content $altlanguagecontent = '</p>'; } $output = '<p class="qtranxs-available-languages-message qtranxs-available-languages-message-' . $lang . '">' . preg_replace('/%LANG:([^:]*):([^%]*)%/', $language_list, $q_config['not_available'][$lang]) . $altlanguagecontent; /* todo documentation */ return apply_filters('i18n_content_translation_not_available', $output, $lang, $language_list, $alt_lang, $alt_content, $msg, $q_config); }
function qtranxf_generateLanguageSelectCode($style = '', $id = '') { global $q_config; if ($style == '') { $style = 'text'; } if (is_bool($style) && $style) { $style = 'image'; } if (is_404()) { $url = get_option('home'); } else { $url = ''; } if ($id == '') { $id = 'qtranslate'; } $id .= '-chooser'; $flag_location = qtranxf_flag_location(); switch ($style) { case 'image': case 'text': case 'dropdown': echo PHP_EOL . '<ul class="qtranxs_language_chooser" id="' . $id . '">' . PHP_EOL; foreach (qtranxf_getSortedLanguages() as $language) { $classes = array('lang-' . $language); if ($language == $q_config['language']) { $classes[] = 'active'; } echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtranxf_convertURL($url, $language, false, true) . '"'; //echo '<li'; if($language == $q_config['language']) echo ' class="active"'; //echo '><a href="'.qtranxf_convertURL($url, $language, false, true).'"'; // set hreflang echo ' hreflang="' . $language . '"'; echo ' title="' . $q_config['language_name'][$language] . '"'; if ($style == 'image') { echo ' class="qtranxs_image qtranxs_image_' . $language . '"'; } elseif ($style == 'text') { echo ' class="qtranxs_text qtranxs_text_' . $language . '"'; } echo '>'; if ($style == 'image') { echo '<img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" />'; } echo '<span'; if ($style == 'image') { echo ' style="display:none"'; } echo '>' . $q_config['language_name'][$language] . '</span>'; echo '</a></li>' . PHP_EOL; } echo '</ul><div class="qtranxs_widget_end"></div>' . PHP_EOL; if ($style == 'dropdown') { echo '<script type="text/javascript">' . PHP_EOL . '// <![CDATA[' . PHP_EOL; echo "var lc = document.getElementById('" . $id . "');" . PHP_EOL; echo "var s = document.createElement('select');" . PHP_EOL; echo "s.id = 'qtranxs_select_" . $id . "';" . PHP_EOL; echo "lc.parentNode.insertBefore(s,lc);" . PHP_EOL; // create dropdown fields for each language foreach (qtranxf_getSortedLanguages() as $language) { echo qtranxf_insertDropDownElement($language, qtranxf_convertURL($url, $language, false, true), $id); } // hide html language chooser text echo "s.onchange = function() { document.location.href = this.value;}" . PHP_EOL; echo "lc.style.display='none';" . PHP_EOL; echo '// ]]>' . PHP_EOL . '</script>' . PHP_EOL; } break; case 'both': echo PHP_EOL . '<ul class="qtranxs_language_chooser" id="' . $id . '">' . PHP_EOL; foreach (qtranxf_getSortedLanguages() as $language) { echo '<li'; if ($language == $q_config['language']) { echo ' class="active"'; } echo '><a href="' . qtranxf_convertURL($url, $language, false, true) . '"'; echo ' class="qtranxs_flag_' . $language . ' qtranxs_flag_and_text" title="' . $q_config['language_name'][$language] . '">'; //echo '<img src="'.$flag_location.$q_config['flag'][$language].'"></img>'; echo '<span>' . $q_config['language_name'][$language] . '</span></a></li>' . PHP_EOL; } echo '</ul><div class="qtranxs_widget_end"></div>' . PHP_EOL; break; } }
function qtranxf_use_content($lang, $content, $available_langs, $show_available = false, $show_empty = false) { global $q_config; // if content is available show the content in the requested language if (!empty($available_langs[$lang])) { return $content[$lang]; } elseif ($show_empty) { return ''; } // content is not available in requested language (bad!!) what now? $alangs = array(); foreach ($q_config['enabled_languages'] as $language) { if (empty($available_langs[$language])) { continue; } $alangs[] = $language; } if (empty($alangs)) { return ''; } $available_langs = $alangs; // set alternative language to the first available in the order of enabled languages $alt_lang = current($available_langs); $alt_content = $content[$alt_lang]; $alt_lang_is_default = $alt_lang == $q_config['default_language']; if (!$show_available || !$q_config['show_alternative_content_message']) { if ($q_config['show_displayed_language_prefix']) { return '(' . $q_config['language_name'][$alt_lang] . ') ' . $alt_content; } else { return $alt_content; } } //qtranxf_dbg_log('$alt_content=',$alt_content); // display selection for available languages $language_list = ''; if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) { $normal_separator = $match[1]; $end_separator = $match[2]; // build available languages string backward $i = 0; foreach (array_reverse($available_langs) as $language) { if ($i == 1) { $language_list = $end_separator . $language_list; } elseif ($i > 1) { $language_list = $normal_separator . $language_list; } $language_name = qtranxf_getLanguageName($language); //$language_list = '“<a href="'.qtranxf_convertURL('', $language, false, true).'" class="qtranxs-available-language-link qtranxs-available-language-link-'.$language.'">'.$language_name.'</a>”'.$language_list; $language_list = '<a href="' . qtranxf_convertURL('', $language, false, true) . '" class="qtranxs-available-language-link qtranxs-available-language-link-' . $language . '" title="' . $q_config['language_name'][$language] . '">' . $language_name . '</a>' . $language_list; ++$i; } } //qtranxf_dbg_log('$language_list=',$language_list); $msg = ''; if (!empty($q_config['show_alternative_content']) && $q_config['show_alternative_content']) { // show content in alternative language if (sizeof($available_langs) > 1) { if ($alt_lang_is_default) { //$fmt = __('For the sake of viewer convenience, the content is shown below in this site default language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in this site\'s default language.', 'qtranslate'); } else { //$fmt = __('For the sake of viewer convenience, the content is shown below in an available alternative language %s.', 'qtranslate'); $msg = __('For the sake of viewer convenience, the content is shown below in one of the available alternative languages.', 'qtranslate'); } //$msg = sprintf($fmt, '<a href="'.qtranxf_convertURL('', $language, false, true).'">'.$q_config['language_name'][$alt_lang].'</a>'); $msg .= ' ' . __('You may click one of the links to switch the site language to another available language.', 'qtranslate'); } else { $msg = __('For the sake of viewer convenience, the content is shown below in the alternative language.', 'qtranslate'); $msg .= ' ' . __('You may click the link to switch the active language.', 'qtranslate'); } $altlanguagecontent = ' ' . $msg . '</p>' . $alt_content; } else { //by default, do not show alternative content $altlanguagecontent = '</p>'; } $output = '<p class="qtranxs-available-languages-message qtranxs-available-languages-message-' . $lang . '">' . preg_replace('/%LANG:([^:]*):([^%]*)%/', $language_list, $q_config['not_available'][$lang]) . $altlanguagecontent; /* * Chance to customize $output */ return apply_filters('i18n_content_translation_not_available', $output, $lang, $language_list, $alt_lang, $alt_content, $msg, $q_config); }
" title="<?php echo esc_attr($lang_name); ?> "><?php echo esc_attr($lang_name); ?> <i class="fa fa-angle-down"></i><i class="fa fa-angle-up"></i> <i class="fa fa-angle-down"></i><i class="fa fa-angle-up"></i> </a> <ul class="list nav-drop-menu" style="min-width:120px"> <?php $variable = qtranxf_getSortedLanguages(); if (!empty($variable) and is_array($variable)) { foreach ($variable as $key => $value) { $qtrans_link = qtranxf_convertURL('', $value, false, true); $lang_name = $q_config['language_name'][$value]; ?> <li> <a title="<?php echo esc_attr($lang_name); ?> " href="<?php echo esc_attr($qtrans_link); ?> "> <img src="<?php echo esc_attr($flag_dir . $flags[$value]); ?> " alt="<?php echo esc_attr($lang_name);
/** * @since 3.3.1 * Moved here from qtranslate_hooks.php and modified. */ function qtranxf_pagenum_link($url) { $url_fixed = preg_replace('#\\?lang=[a-z]{2}/#i', '/', $url); //kind of ugly fix for function get_pagenum_link in /wp-includes/link-template.php. Maybe we should cancel filter 'bloginfo_url' instead? return qtranxf_convertURL($url_fixed); }
/** * from 1.1.7 */ function qtrans_copy_default_theme_option() { if (!$this->check_qtrans) { return; } global $q_config; $locale_list = $q_config['locale']; $option_name = 'option_tree'; if ($this->check_qtrans) { $options = get_option($option_name); //$st_plugin_list_lang = icl_get_languages('skip_missing=0&orderby=custom'); $st_plugin_list_lang = array(); $qtrans_list = qtranxf_getSortedLanguages(); $flags = qtranxf_language_configured('flag'); if (!empty($qtrans_list) and is_array($qtrans_list)) { foreach ($qtrans_list as $key => $value) { $lang_name = $q_config['language_name'][$value]; $array = array('id' => $key, 'active' => $value == $q_config['language'] ? 1 : 0, 'encode_url' => 0, 'default_locale' => $locale_list[$value], 'tag' => '', 'native_name' => $lang_name, 'language_code' => $value, 'translated_name' => $lang_name, 'url' => qtranxf_convertURL(admin_url(), $value, true, true), 'country_flag_url' => qtranxf_flag_location() . $flags[$value]); $st_plugin_list_lang[$value] = $array; } } if (is_array($st_plugin_list_lang) && !empty($st_plugin_list_lang)) { foreach ($st_plugin_list_lang as $lang) { $lang_option = get_option($option_name . '_' . $lang['language_code']); if ($lang_option == '') { update_option($option_name . '_' . $lang['language_code'], $options); } } } } }