protected function getLanguageMutation() { $i84676540daef1510ea5729a183290848a9e7accb = 0; $i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 = $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900 = array(); if (file_exists(ABSPATH . 'wp-admin/includes/translation-install.php')) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 = get_available_languages(); $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900 = wp_get_available_translations(); } if (isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]) && isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]["native_name"])) { $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89 = array(SMS_DEFAULT_MUTATION => $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]["native_name"], "en_US" => "English (United States)"); $this->mutationColors[SMS_DEFAULT_MUTATION] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors); $this->mutationColors["en_US"] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors); } else { $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89 = array("en_US" => "English (United States)"); $this->mutationColors["en_US"] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors); } foreach ($i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 as $i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772) { if ($i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772 != SMS_DEFAULT_MUTATION) { $this->mutationColors[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors); if (isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]) && isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]["native_name"])) { $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772] = $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]["native_name"]; } } } return $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89; }
/** * @from 1.1 */ public function activate() { // initialization $options = get_option($this->option_name); $languages = $this->get_languages(); if (empty($languages) && empty($options)) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); $locale = get_locale(); $language_name = isset($translations[$locale]['native_name']) ? $translations[$locale]['native_name'] : 'English'; $language_slug = isset($translations[$locale]['iso']) && !empty($translations[$locale]['iso']) ? array_shift($translations[$locale]['iso']) : 'en'; $post_id = wp_insert_post(array('post_type' => $this->language_post_type, 'post_title' => $language_name, 'post_name' => $language_slug, 'post_status' => 'publish')); $options = array(); $options['main'] = $post_id; $options['default'] = $post_id; $options['show_slug'] = false; $options['autodetect'] = false; $options['current_first'] = false; $options['taxonomy'] = array('category'); $options['cpt'] = array('post', 'page'); $options['version'] = '1.2'; update_option($this->option_name, $options); } $admins = get_role('administrator'); $admins->add_cap('edit_language'); $admins->add_cap('edit_languages'); $admins->add_cap('edit_other_languages'); $admins->add_cap('publish_languages'); $admins->add_cap('read_language'); $admins->add_cap('read_private_languages'); $admins->add_cap('delete_language'); }
/** * Constructor. */ public function init() { $this->load_textdomain(self::NAME); $this->title(__('Localization', 'debug-bar-localization')); add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); if (!function_exists('wp_get_available_translations')) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; } $this->wp_translations = wp_get_available_translations(); $this->load_call_types = array('core' => __('WP Core', 'debug-bar-localization'), 'theme' => __('Themes', 'debug-bar-localization'), 'muplugin' => __('Must-Use Plugins', 'debug-bar-localization'), 'plugin' => __('Plugins', 'debug-bar-localization'), 'unknown' => __('Unknown', 'debug-bar-localization')); }
public static function language_detector_admin_notices() { // Check if the nag screen has been disabled for this language if (self::has_language_detector_dismissed()) { return; } // Get the current language locale $language = get_locale(); require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); printf('<div id="si_language_detect_nag_dismiss" class="notice notice-info is-dismissible"><p>%s</p></div>', sprintf(__('<span class="dashicons dashicons-megaphone"></span> <b>%1$s</b> does not have a translation for <b>%2$s</b>, please help the community translate at <a href="%3$s" target="_blank">%3$s</a>. Supporting translators receive major discounts on <a href="%4$s" target="_blank">pro licenses</a> and <a href="%5$s" target="_blank">add-ons</a>.', 'sprout-invoices'), esc_html(self::PLUGIN_NAME), esc_html($translations[$language]['native_name']), esc_url('https://translate.wordpress.org/projects/wp-plugins/sprout-invoices/'), si_get_sa_link('https://sproutapps.co/sprout-invoices/purchase/', 'translation'), si_get_sa_link('https://sproutapps.co/marketplace/', 'translation'))); }
function bogo_get_language_native_name($locale) { if ('en_US' == $locale) { return 'English (United States)'; } if (!function_exists('wp_get_available_translations')) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; } static $available_translations = array(); if (empty($available_translations)) { $available_translations = wp_get_available_translations(); } if (isset($available_translations[$locale]['native_name'])) { return $available_translations[$locale]['native_name']; } return false; }
public function load($lang = null) { if (null !== $lang) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; global $locale; if (!in_array($lang, get_available_languages())) { if (array_key_exists($lang, wp_get_available_translations())) { $language = wp_download_language_pack($lang); if ($language) { load_default_textdomain($language); $locale = $language; } } } else { load_default_textdomain($lang); $locale = $lang; } } $this->init(); $this->register_globals(); }
public function flagatar_admin_bar() { global $wp_admin_bar, $blog_id; // This is functionality for WP 4.0+ only if (version_compare(get_bloginfo('version'), '4.0', '>=')) { // Get native language names if (file_exists(ABSPATH . 'wp-admin/includes/translation-install.php')) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; } $translations = function_exists('wp_get_available_translations') ? wp_get_available_translations() : array(); } else { $translations = array(); } // Loop user's blogs trough foreach ((array) $wp_admin_bar->user->blogs as $blog) { $node_id = 'blog-' . $blog->userblog_id; $node = $wp_admin_bar->get_node($node_id); if ($node) { // We'll put it back... $wp_admin_bar->remove_node($node_id); // Get language $lang = is_multisite() ? get_blog_option($blog->userblog_id, 'WPLANG', 'en_US') : get_bloginfo('language'); // Oh, just sometimes language returns empty on WP 4.0, try different key if (empty($lang) && is_multisite()) { $lang = get_blog_option($blog->userblog_id, 'language', 'en_US'); } // Still no language? Default to US. if (empty($lang)) { $lang = 'en_US'; } // Blog name - and is this blog currently active? $blogname = $blog_id == $blog->userblog_id ? '<strong class="current">' . $blog->blogname . '</strong>' : $blog->blogname; // Update node and put it back $node->title = '<div class="blavatar flagatar" style="background-image:url(' . plugins_url('flags/' . strtoupper(substr($lang, -2)) . '.png', __FILE__) . ')"></div> ' . $blogname; // If we have name for this language, show it as title. Fall back to locale. $node->meta['title'] = isset($translations[$lang]) ? esc_attr($translations[$lang]['english_name'] . ' (' . $translations[$lang]['native_name'] . ')') : esc_attr($lang); $wp_admin_bar->add_node($node); } } }
function _vp_get_language_name_by_code($code) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); return isset($translations[$code]) ? $translations[$code]['native_name'] : 'English (United States)'; }
function _vp_get_language_name_by_code($code) { $translations = wp_get_available_translations(); return isset($translations[$code]) ? $translations[$code]['native_name'] : 'English (United States)'; }
/** * display list of language in dropdown * @param array $args */ public static function hw_dropdown_languages($args = array()) { $avaibles_languages = self::get_available_languages(); //avaiable languages $args = wp_parse_args($args, array('id' => '', 'name' => '', 'languages' => array(), 'translations' => array(), 'selected' => '', 'show_available_translations' => true)); $translations = $args['translations']; if (empty($translations)) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); } if (empty($args['languages'])) { $args['languages'] = self::hw_get_available_languages(); } /* * $args['languages'] should only contain the locales. Find the locale in * $translations to get the native name. Fall back to locale. */ $languages = array(); foreach ($args['languages'] as $locale) { //check lang for avaiable if (in_array($locale, $avaibles_languages)) { continue; } //exists installed this language $found_uninstalled = true; if (isset($translations[$locale])) { $translation = $translations[$locale]; $languages[] = array('language' => $translation['language'], 'native_name' => $translation['native_name'], 'lang' => $translation['iso'][1]); // Remove installed language from available translations. unset($translations[$locale]); } else { $languages[] = array('language' => $locale, 'native_name' => $locale, 'lang' => ''); } } if (!isset($found_uninstalled)) { return false; } //no avaible uninstalled languages in wp system printf('<select name="%s" id="%s" multiple style="max-height:200px;width:200px">', esc_attr($args['name']), esc_attr($args['id'])); // Holds the HTML markup. $structure = array(); foreach ($languages as $language) { $structure[] = sprintf('<option value="%s" lang="%s"%s data-installed="1">%s</option>', esc_attr($language['language']), esc_attr($language['lang']), selected($language['language'], $args['selected'], false), esc_html($language['native_name'])); } echo join("\n", $structure); echo '</select>'; return true; }
/** * return 'true', if no update needed, * or 'false', if update is impossible to do, * or 0, if all languages were updated successfully, * or positive integer number of errors occurred on languages update. */ function qtranxf_updateGettextDatabasesEx($force = false, $only_for_language = '') { if (empty($only_for_language)) { if (!$force) { $next_update = get_option('qtranslate_next_update_mo'); if (time() < $next_update) { return true; } } update_option('qtranslate_next_update_mo', time() + 7 * 24 * 60 * 60); } if (!is_dir(WP_LANG_DIR)) { if (!@mkdir(WP_LANG_DIR)) { return false; } } require_once ABSPATH . 'wp-admin/includes/translation-install.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; //include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version //$result = translations_api( 'core', array( 'version' => $wp_version )); //if ( is_wp_error( $result ) ){ // qtranxf_add_warning(__('Gettext databases <strong>not</strong> updated:', 'qtranslate') . ' ' . $result->get_error_message()); // return false; //} //$translations = $result['translations']; $translations = wp_get_available_translations(); if (empty($translations)) { qtranxf_add_warning(__('Gettext databases <strong>not</strong> updated:', 'qtranslate') . ' ' . __('Failed to fetch the list of available translations.', 'qtranslate')); return false; } set_time_limit(300); if (empty($only_for_language)) { global $q_config; $langs = $q_config['enabled_languages']; $locales = $q_config['locale']; } else { $langs = array($only_for_language); $locales = qtranxf_language_configured('locale'); } $errcnt = 0; /* //qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: count($translations): ',count($translations)); //qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: $translations: ',$translations); foreach ( $translations as $loc => $translation ) { $locale = $translation['language']; $lang = null; foreach($langs as $lng) { if(!isset($locales[$lng])){ $locales = qtranxf_language_configured('locale'); if(!isset($locales[$lng])) continue; } if($locales[$lng] != $locale) continue; $lang = $lng; break; } if(!$lang) continue; */ foreach ($langs as $lang) { $loc = $locales[$lang]; if (!isset($translations[$loc])) { continue; } $mo = WP_LANG_DIR . '/' . $loc . '.mo'; $mo_ok = file_exists($mo); //qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: $mo_ok for '.$mo.': ',$mo_ok); if ($mo_ok) { continue; } //WP now takes care of translations updates on its own $translation = (object) $translations[$loc]; $skin = new Automatic_Upgrader_Skin(); $upgrader = new Language_Pack_Upgrader($skin); $translation->type = 'core'; $result = $upgrader->upgrade($translation, array('clear_update_cache' => false)); if (is_wp_error($result)) { qtranxf_add_warning(sprintf(__('Failed to update gettext database for "%s": %s', 'qtranslate'), $lang, $result->get_error_message())); ++$errcnt; } } return $errcnt; }
/** * since 3.2.9.2 */ function qtranxf_default_enabled_languages() { //$languages = get_available_languages(); //qtranxf_dbg_log('qtranxf_default_enabled_languages: count(languages): ',count($languages)); //qtranxf_dbg_log('qtranxf_default_enabled_languages: get_available_languages: ',$languages); $locale = get_locale(); if (!$locale) { $locale = 'en_US'; } $lang = null; $locales = qtranxf_default_locale(); foreach ($locales as $ln => $lo) { if ($lo != $locale) { continue; } $lang = $ln; break; } if (!$lang) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); //qtranxf_dbg_log('qtranxf_default_enabled_languages: count(available_translations): ',count($translations)); //qtranxf_dbg_log('qtranxf_default_enabled_languages: wp_get_available_translations: ',$translations); if (empty($translations[$locale])) { $lang = substr($locale, 0, 2); $name = 'Unknown'; } else { $translation = $translations[$locale]; $lang = current($translation['iso']); if (!$lang) { $lang = substr($locale, 0, 2); } $name = empty($translation['native_name']) ? 'Unknown' : $translation['native_name']; } $flag_location = WP_CONTENT_DIR . '/' . qtranxf_flag_location_default(); do { $p = strpos($locale, '_'); if ($p > 0) { $fn = strtolower(substr($locale, $p, 2)); $flag = $fn . '.png'; if (file_exists($flag_location . $flag)) { break; } $flag = $fn . '.gpg'; if (file_exists($flag_location . $flag)) { break; } } $fn = strtolower(substr($locale, 0, 2)); $flag = $fn . '.png'; if (file_exists($flag_location . $flag)) { break; } $flag = $fn . '.gpg'; if (file_exists($flag_location . $flag)) { break; } $flag = 'aa.png'; } while (false); $props = array('language_name' => $name, 'flag' => $flag, 'locale' => $locale, 'date_format' => __('F j, Y'), 'time_format' => __('g:i a'), 'not_available' => 'Sorry, this entry is only available in %LANG:, : and %.'); qtranxf_set_default_options($qtranslate_options); qtranxf_save_languages(array($lang => $props), $qtranslate_options); //qtranxf_dbg_log('qtranxf_default_enabled_languages: $props: ',$props); } $enabled_languages = array($lang); if ($lang != 'en') { $enabled_languages[] = 'en'; } //qtranxf_dbg_log('qtranxf_default_enabled_languages: $lang="'.$lang.'"; $locale="'.$locale.'"; $enabled_languages: ',$enabled_languages); return $enabled_languages; }
/** * Download a language pack. * * @since 4.0.0 * * @see wp_get_available_translations() * * @param string $download Language code to download. * @return string|bool Returns the language code if successfully downloaded * (or already installed), or false on failure. */ function wp_download_language_pack($download) { // Check if the translation is already installed. if (in_array($download, get_available_languages())) { return $download; } if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) { return false; } // Confirm the translation is one we can download. $translations = wp_get_available_translations(); if (!$translations) { return false; } foreach ($translations as $translation) { if ($translation['language'] === $download) { $translation_to_load = true; break; } } if (empty($translation_to_load)) { return false; } $translation = (object) $translation; require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $skin = new Automatic_Upgrader_Skin(); $upgrader = new Language_Pack_Upgrader($skin); $translation->type = 'core'; $result = $upgrader->upgrade($translation, array('clear_update_cache' => false)); if (!$result || is_wp_error($result)) { return false; } return $translation->language; }
/** * Language selector. * * @since 4.0.0 * @since 4.3.0 Introduced the `echo` argument. * * @see get_available_languages() * @see wp_get_available_translations() * * @param string|array $args { * Optional. Array or string of arguments for outputting the language selector. * * @type string $id ID attribute of the select element. Default empty. * @type string $name Name attribute of the select element. Default empty. * @type array $languages List of installed languages, contain only the locales. * Default empty array. * @type array $translations List of available translations. Default result of * wp_get_available_translations(). * @type string $selected Language which should be selected. Default empty. * @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, or their * bool equivalents. Default 1. * @type bool $show_available_translations Whether to show available translations. Default true. * } * @return string HTML content only if 'echo' argument is 0. */ function wp_dropdown_languages($args = array()) { $args = wp_parse_args($args, array('id' => '', 'name' => '', 'languages' => array(), 'translations' => array(), 'selected' => '', 'echo' => 1, 'show_available_translations' => true)); $translations = $args['translations']; if (empty($translations)) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); } /* * $args['languages'] should only contain the locales. Find the locale in * $translations to get the native name. Fall back to locale. */ $languages = array(); foreach ($args['languages'] as $locale) { if (isset($translations[$locale])) { $translation = $translations[$locale]; $languages[] = array('language' => $translation['language'], 'native_name' => $translation['native_name'], 'lang' => current($translation['iso'])); // Remove installed language from available translations. unset($translations[$locale]); } else { $languages[] = array('language' => $locale, 'native_name' => $locale, 'lang' => ''); } } $translations_available = !empty($translations) && $args['show_available_translations']; $output = sprintf('<select name="%s" id="%s">', esc_attr($args['name']), esc_attr($args['id'])); // Holds the HTML markup. $structure = array(); // List installed languages. if ($translations_available) { $structure[] = '<optgroup label="' . esc_attr_x('Installed', 'translations') . '">'; } $structure[] = '<option value="" lang="en" data-installed="1">English (United States)</option>'; foreach ($languages as $language) { $structure[] = sprintf('<option value="%s" lang="%s"%s data-installed="1">%s</option>', esc_attr($language['language']), esc_attr($language['lang']), selected($language['language'], $args['selected'], false), esc_html($language['native_name'])); } if ($translations_available) { $structure[] = '</optgroup>'; } // List available translations. if ($translations_available) { $structure[] = '<optgroup label="' . esc_attr_x('Available', 'translations') . '">'; foreach ($translations as $translation) { $structure[] = sprintf('<option value="%s" lang="%s"%s>%s</option>', esc_attr($translation['language']), esc_attr(current($translation['iso'])), selected($translation['language'], $args['selected'], false), esc_html($translation['native_name'])); } $structure[] = '</optgroup>'; } $output .= join("\n", $structure); $output .= '</select>'; if ($args['echo']) { echo $output; } return $output; }
/** * Renders an HTML Dropdown of all the available languages * * @param array $args Arguments for the dropdown * * @return string $output Languages dropdown * * @since 0.1.0 */ function edd_lp_language_dropdown($args = array()) { $defaults = array('name' => 'languages', 'id' => 'languages', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'placeholder' => __('Select a language', 'edd-language-packs')); $args = wp_parse_args($args, $defaults); require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); $options = array(); if ($translations) { $options[0] = __('Select a language', 'edd-language-packs'); foreach ($translations as $translation) { $options[$translation['language']] = esc_html($translation['english_name']); } } else { $options[0] = __('No languages found', 'edd-language-packs'); } // This ensures that any selected products are included in the drop down if (is_array($args['selected'])) { foreach ($args['selected'] as $language => $english_name) { if (!in_array($language, $options)) { $options[$language] = $english_name; } } } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { if (!in_array($args['selected'], $options)) { $options[key($args['selected'])] = $args['selected']; } } $output = EDD()->html->select(array('name' => $args['name'], 'selected' => $args['selected'], 'id' => $args['id'], 'class' => $args['class'], 'options' => $options, 'chosen' => $args['chosen'], 'multiple' => $args['multiple'], 'placeholder' => $args['placeholder'], 'show_option_all' => false, 'show_option_none' => false)); return $output; }
static function create_table_available_language($options) { $languages = uls_get_available_languages(false); // get the all languages available in the wp $options = get_option('uls_settings'); // get information from DB $available_language = isset($options['available_language']) ? $options['available_language'] : uls_get_available_languages(false); // get the information that actually is in the DB wp_enqueue_script('uls_languages_js', plugins_url('js/uls-languages-tap.js', __FILE__), array('jquery')); ?> <table id="menu-locations-table" class=""> <thead> <tr> <th>Enable</th> <th>Language</th> <th>Frontend flag optional</th> <th>Optional flag</th> <th>Remove</th> </tr> </thead> <tbody> <?php foreach ($languages as $lang_name => $lang_code) { ?> <tr> <?php $checked = isset($available_language[$lang_name]) ? 'checked' : ''; ?> <td> <input type="checkbox" name="uls_available_language[<?php echo $lang_name; ?> ]" value="<?php echo $lang_code; ?> " <?php echo $checked; ?> /> </td> <td> <!--img src="<?php echo plugins_url("css/blank.gif", __FILE__); ?> " style="margin-right:5px;" class="flag_16x11 flag-<?php echo strtolower(substr($lang_code, -2)); ?> " alt="<?php echo $lang_name; ?> " title="<?php echo $lang_name; ?> " /--> <img src="<?php echo plugins_url("css/blank.gif", __FILE__); ?> " style="margin-right:5px;" class="flag_16x11 flag-<?php echo Codes::languageCode2CountryCode($lang_code); ?> " alt="<?php echo $lang_name; ?> " title="<?php echo $lang_name; ?> " /> <span><?php echo $lang_name; ?> </span> </td> <td> <input type="file" name="uls_available_language_new_flags[<?php echo $lang_name; ?> ]" value="" title="<?php echo __("the default dimension is 32x32 px, it is neccessary to keep the aesthetics"); ?> " /> </td> <td> <?php if (isset($options['uls_available_language_new_flags']) && isset($options['uls_available_language_new_flags'][$lang_name])) { ?> <img src="<?php echo $options['uls_available_language_new_flags'][$lang_name]['url']; ?> " class="optional_flag" alt="<?php echo $lang_name; ?> " title="<?php echo $lang_name; ?> " ></img> <?php } ?> </td> <td> <?php if (isset($options['uls_available_language_new_flags']) && isset($options['uls_available_language_new_flags'][$lang_name])) { ?> <input type="checkbox" name="uls_available_language_del_flags[<?php echo $lang_name; ?> ]" value="" /> <?php } ?> </td> </tr> <?php } ?> </tbody> </table> <input type="hidden" name="available_languages" value="available_languages" > <br/> <table id="menu-locations-table" class=""> <thead> <tr> <th>Install Additional Languages</th> </tr> </thead> <tbody> <tr> <?php require_once ABSPATH . '/wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); uasort($translations, array(__CLASS__, 'sort_translations_callback')); // check the requirement to can download language $execute_languages = true; $zip_message = ''; // meessage information $ssl_message = ''; // meessage information if (!class_exists('ZipArchive')) { $zip_message = '<p class="bg-warning">'; $zip_message .= __("Missing class ZipArchive. Please install and retry later."); $zip_message .= '</p>'; $execute_languages = false; } if (!extension_loaded('openssl')) { $ssl_message = '<p class="bg-warning">'; $ssl_message .= __("Missing extension openssl. Please enable openss extension in your php.ini and retry later."); $ssl_message .= '</p>'; $execute_languages = false; } echo "<td>" . __('Select a language') . ": </td><td><select id='tblang'>"; if ($execute_languages) { foreach ($translations as $language) { echo "<option value='" . $language['language'] . ";" . $language['package'] . ";" . $language['english_name'] . "'>"; echo $language['english_name'] . " - " . $language['native_name'] . "</option>"; } } echo "</select>"; if ($execute_languages) { ?> <input type="button" class="button-primary" id="button-download-language" value="<?php echo __('Download', 'user-language-switch'); ?> " /> <?php } ?> </td> </tr> </tbody> </table> <div id="div_message_download" class="div_message_download"> <?php if (isset($_GET['success'])) { if ($_GET['success'] == 1) { $ok_message = '<p class="bg-success">'; $ok_message .= __("Language successfully downloaded!!!"); $ok_message .= '</p>'; echo $ok_message; } else { if ($_GET['success'] == 0) { $error_message = '<p class="bg-warning">'; $error_message .= __("File writing permission denied. Please fix permissions to directory wp-content/languages."); $error_message .= '</p>'; echo $error_message; } } } echo $zip_message; echo $ssl_message; ?> </div> <?php }
/** * Display the Welcome page. * * @author Studio 164a * @package Charitable/Admin View/Welcome Page * @since 1.0.0 */ wp_enqueue_style('charitable-admin-pages'); require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $gateways = Charitable_Gateways::get_instance()->get_active_gateways_names(); $campaigns = wp_count_posts('campaign'); $campaigns_count = $campaigns->publish + $campaigns->draft + $campaigns->future + $campaigns->pending + $campaigns->private; $emails = charitable_get_helper('emails')->get_enabled_emails_names(); $install = isset($_GET['install']) && $_GET['install']; $languages = wp_get_available_translations(); $locale = get_locale(); $language = isset($languages[$locale]['native_name']) ? $languages[$locale]['native_name'] : $locale; $currency = charitable_get_option('currency', 'AUD'); $extensions = array(); if ('en_ZA' == $locale || 'ZAR' == $currency) { $extensions['ambassadors'] = __('Peer to peer fundraising or crowdfunding', 'charitable'); $extensions['payfast'] = __('Accept donations in South African Rand', 'charitable'); $extensions['anonymous-donations'] = __('Let donors give anonymously', 'charitable'); $extensions['user-avatar'] = __('Let your donors upload their own profile photo', 'charitable'); } elseif ('hi_IN' == $locale || 'INR' == $currency) { $extensions['ambassadors'] = __('Peer to peer fundraising or crowdfunding', 'charitable'); $extensions['payu-money'] = __('Accept donations in Indian Rupees', 'charitable'); $extensions['anonymous-donations'] = __('Let donors give anonymously', 'charitable'); $extensions['user-avatar'] = __('Let your donors upload their own profile photo', 'charitable'); } elseif (class_exists('EDD')) {
/** * Set default language title and slug * Filter for 'wp_insert_post_data' * * @from 1.0 */ public function set_default_slug_and_name($data, $postarr) { global $sublanguage_admin; if ($data['post_type'] == $sublanguage_admin->language_post_type) { if (isset($_POST['language_locale_dropdown']) && $_POST['language_locale_dropdown']) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); $locale = $_POST['language_locale_dropdown']; $data['post_content'] = esc_attr($_POST['language_locale_dropdown']); if (isset($translations[$locale]['native_name'])) { $data['post_title'] = $translations[$locale]['native_name']; } if (isset($translations[$locale]['iso'])) { while (is_array($translations[$locale]['iso'])) { $translations[$locale]['iso'] = array_shift($translations[$locale]['iso']); } $data['post_name'] = $translations[$locale]['iso']; } } } return $data; }
private static function get_proper_db_collation() { global $wp_version; if ($wp_version >= 4.2) { $blog_charset = 'utf8mb4'; $language = 'unicode'; } else { $blog_charset = strtolower(str_replace('-', '', get_option('blog_charset'))); $language = 'general'; require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); $locale = get_locale(); if ('en_US' != $locale && isset($translations[$locale])) { $language = strtolower($translations[$locale]['english_name']); } } return $blog_charset . '_' . $language . '_ci'; }
function test_tran() { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; print_r(wp_get_available_translations()); print_r(get_available_languages()); }
public static function settings_page() { $ncr_options = get_option('ncr_options'); //captcha_login $site_key = isset($ncr_options['site_key']) ? $ncr_options['site_key'] : ''; $secrete_key = isset($ncr_options['secrete_key']) ? $ncr_options['secrete_key'] : ''; $captcha_login = isset($ncr_options['captcha_login']) ? $ncr_options['captcha_login'] : ''; $captcha_registration = isset($ncr_options['captcha_registration']) ? $ncr_options['captcha_registration'] : ''; $captcha_registration_bp = isset($ncr_options['captcha_registration_bp']) ? $ncr_options['captcha_registration_bp'] : ''; $captcha_comment = isset($ncr_options['captcha_comment']) ? $ncr_options['captcha_comment'] : ''; $theme = isset($ncr_options['theme']) ? $ncr_options['theme'] : ''; $language = isset($ncr_options['language']) ? $ncr_options['language'] : ''; $error_message = isset($ncr_options['error_message']) ? $ncr_options['error_message'] : ''; // call to save the setting options self::save_options(); ?> <style> input[type='text'], textarea, select { width: 600px; } </style> <div class="wrap"> <div id="icon-options-general" class="icon32"></div> <h2><?php _e('No CAPTCHA reCAPTCHA', 'ncr-captcha'); ?> </h2> <p><?php _e('Protect WordPress login, registration and comment form with the new No CAPTCHA reCAPTCHA', 'ncr-captcha'); ?> </p> <?php if (isset($_GET['settings-updated']) && $_GET['settings-updated']) { echo '<div id="message" class="updated"><p><strong>' . __('Settings saved', 'ncr-captcha') . '</strong></p></div>'; } ?> <div id="poststuff"> <div id="post-body" class="metabox-holder columns-2"> <!-- main content --> <div id="post-body-content"> <div class="meta-box-sortables ui-sortable"> <form method="post"> <div class="postbox"> <div title="<?php _e('Click to toggle', 'ncr-captcha'); ?> " class="handlediv"><br></div> <h3 class="hndle"><span><?php _e('reCAPTCHA Keys', 'ncr-captcha'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tr> <th scope="row"><label for="site-key"><?php _e('Site key', 'ncr-captcha'); ?> </label> </th> <td> <input id="site-key" type="text" name="ncr_options[site_key]" value="<?php echo $site_key; ?> "> <p class="description"> <?php _e('Used for displaying the CAPTCHA.', 'ncr-captcha'); echo ' '; // escape the URL properly $url = 'https://www.google.com/recaptcha/admin'; printf(wp_kses(__('Grab it <a href="%s" target="_blank">Here</a>', 'ncr-captcha'), array('a' => array('href' => array(), 'target' => array('_blank')))), esc_url($url)); ?> </p> </td> </tr> <tr> <th scope="row"><label for="secrete-key"><?php _e('Secret key', 'ncr-captcha'); ?> </label> </th> <td> <input id="secrete-key" type="text" name="ncr_options[secrete_key]" value="<?php echo $secrete_key; ?> "> <p class="description"> <?php _e('Used for communication between your site and Google.', 'ncr-captcha'); echo ' '; // escape the URL properly $url = 'https://www.google.com/recaptcha/admin'; printf(wp_kses(__('Grab it <a href="%s" target="_blank">Here</a>', 'ncr-captcha'), array('a' => array('href' => array(), 'target' => array('_blank')))), esc_url($url)); ?> </p> </td> </tr> </table> <p> <?php wp_nonce_field('ncr_settings_nonce'); ?> <input class="button-primary" type="submit" name="settings_submit" value="<?php _e('Save All Changes', 'ncr-captcha'); ?> "> </p> </div> </div> <div class="postbox"> <div title="<?php _e('Click to toggle', 'ncr-captcha'); ?> " class="handlediv"><br></div> <h3 class="hndle"><span><?php _e('Display Settings', 'ncr-captcha'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tr> <th scope="row"><label for="login"><?php _e('Login Form', 'ncr-captcha'); ?> </label> </th> <td> <input id="login" type="checkbox" name="ncr_options[captcha_login]" value="yes" <?php checked($captcha_login, 'yes'); ?> > <p class="description"> <?php _e('Check to enable CAPTCHA in login form', 'ncr-captcha'); ?> </p> </td> </tr> <tr> <th scope="row"><label for="registration"><?php _e('Registration Form', 'ncr-captcha'); ?> </label> </th> <td> <input id="registration" type="checkbox" name="ncr_options[captcha_registration]" value="yes" <?php checked($captcha_registration, 'yes'); ?> > <p class="description"> <?php _e('Check to enable CAPTCHA in WordPress registration form', 'ncr-captcha'); ?> </p> </td> </tr> <tr> <th scope="row"><label for="comment"><?php _e('Comment Form', 'ncr-captcha'); ?> </label> </th> <td> <input id="comment" type="checkbox" name="ncr_options[captcha_comment]" value="yes" <?php checked($captcha_comment, 'yes'); ?> > <p class="description"> <?php _e('Check to enable CAPTCHA in WordPress comment system', 'ncr-captcha'); ?> </p> </td> </tr> <?php if (function_exists('buddypress')) { ?> <tr> <th scope="row"><label for="registration-bp"><?php _e('BuddyPress Registration Form', 'ncr-captcha'); ?> </label> </th> <td> <input id="registration-bp" type="checkbox" name="ncr_options[captcha_registration_bp]" value="yes" <?php checked($captcha_registration_bp, 'yes'); ?> > <p class="description"> <?php _e('Check to enable CAPTCHA on the BuddyPress registration form', 'ncr-captcha'); ?> </p> </td> </tr> <?php } ?> </table> <p> <?php wp_nonce_field('ncr_settings_nonce'); ?> <input class="button-primary" type="submit" name="settings_submit" value="<?php _e('Save All Changes', 'ncr-captcha'); ?> "> </p> </div> </div> <div class="postbox"> <div class="handlediv"><br></div> <h3 class="hndle"><span><?php _e('General Settings', 'ncr-captcha'); ?> </span> </h3> <div class="inside"> <table class="form-table"> <tr> <th scope="row"><label for="theme"><?php _e('Theme', 'ncr-captcha'); ?> </label></th> <td> <select id="theme" name="ncr_options[theme]"> <option value="light" <?php selected('light', $theme); ?> ><?php _e('Light', 'ncr-captcha'); ?> </option> <option value="dark" <?php selected('dark', $theme); ?> ><?php _e('Dark', 'ncr-captcha'); ?> </option> </select> <p class="description"> <?php _e('The theme colour of the widget.', 'ncr-captcha'); ?> </p> </td> </tr> </table> <table class="form-table"> <tr> <th scope="row"><label for="theme"><?php _e('Language', 'ncr-captcha'); ?> </label> </th> <td> <select id="theme" name="ncr_options[language]"> <?php printf('<option value="" %s>%s</option>', selected('', $language, false), __('Auto Detect', 'ncr-captcha')); /** WordPress Translation Install API */ require_once ABSPATH . 'wp-admin/includes/translation-install.php'; // display the list of available languages in WP core $available_languages = get_available_languages(); $available_translations = wp_get_available_translations(); foreach ($available_languages as $l) { printf('<option value="%s" lang="%s"%s>%s</option>', esc_attr($l), esc_attr(current($available_translations[$l]['iso'])), selected($l, $language, false), esc_html($available_translations[$l]['native_name'])); } printf('<option value="en_US" lang="en"%s>English (United States)</option>', selected('en_US', $language, false)); ?> </select> <p class="description"> <?php _e('Forces the widget to render in a specific language', 'ncr-captcha'); ?> </p> </td> </tr> </table> <table class="form-table"> <tr> <th scope="row"><label for="message"><?php _e('Error Message', 'ncr-captcha'); ?> </label> </th> <td> <input id="message" type="text" name="ncr_options[error_message]" value="<?php echo $error_message; ?> "> <p class="description"> <?php _e('Message or text to display when CAPTCHA is ignored or the test is failed.', 'ncr-captcha'); ?> </p> </td> </tr> </table> <p> <?php wp_nonce_field('settings_nonce'); ?> <input class="button-primary" type="submit" name="settings_submit" value="<?php _e('Save All Changes', 'ncr-captcha'); ?> "> </p> </div> </div> </form> </div> </div> <div id="postbox-container-1" class="postbox-container"> <div class="meta-box-sortables"> <div class="postbox"> <div class="handlediv"><br></div> <h3 class="hndle" style="text-align: center;"> <span><?php _e('Developer', 'ncr-captcha'); ?> </span> </h3> <div class="inside"> <div style="text-align: center; margin: auto"><?php _e('Made with lots of love by', 'ncr-captcha'); ?> <br> <?php /* translators: plugin author name */ ?> <a href="http://w3guy.com"><strong><?php _e('Agbonghama Collins', 'ncr-captcha'); ?> </strong></a></div> </div> </div> <div class="postbox" style="text-align: center"> <div class="handlediv"><br></div> <h3 class="hndle ui-sortable-handle"><span>Check out ProfilePress Plugin</span></h3> <div class="inside"> <p>A shortcode based WordPress form builder that makes building custom login, registration and password reset forms stupidly simple.</p> <strong>Features</strong> <ul> <li>Unlimited front-end login forms</li> <li>Unlimited front-end registration forms</li> <li>Unlimited password reset forms.</li> <li>Automatic login after registration.</li> <li>Social Logins.</li> <li>Custom user redirect users after login & logout</li> <li>One-click widget creator.</li> <li>And lots more.</li> <li></li> </ul> <div><a href="https://wordpress.org/plugins/ppress/" target="_blank"> <button class="button-primary" type="button">Download for Free</button> </a></div> </div> </div> <div class="postbox"> <div class="handlediv"><br></div> <h3 class="hndle" style="text-align: center;"> <span><?php _e('Support Plugin', 'ncr-captcha'); ?> </span> </h3><div class="inside"> <div style="text-align: center; margin: auto"> <?php // escape the URLs properly $flattr_url = 'https://flattr.com/submit/auto?user_id=tech4sky&url=https%3A%2F%2Fwordpress.org%2Fplugins%2Fno-captcha-recaptcha%2F'; $review_url = 'https://wordpress.org/support/view/plugin-reviews/no-captcha-recaptcha'; $compatibility_url = 'https://wordpress.org/plugins/no-captcha-recaptcha/#compatibility'; $twitter_url = 'http://twitter.com/home?status=I%20love%20this%20WordPress%20plugin!%20http://wordpress.org/plugins/no-captcha-recaptcha/'; ?> <p><?php printf(wp_kses(__('Is this plugin useful for you? If so, please help support its ongoing development and improvement with a <a href="%s" target="_blank">donation</a>.', 'ncr-captcha'), array('a' => array('href' => array(), 'target' => array('_blank')))), esc_url($flattr_url)); ?> </p> <p><?php _e('Or, if you are short on funds, there are other ways you can help out:', 'ncr-captcha'); ?> </p> <ul> <li><?php printf(wp_kses(__('Leave a positive review on the plugin\'s <a href="%s">WordPress listing</a>', 'ncr-captcha'), array('a' => array('href' => array(), 'target' => array('_blank')))), esc_url($review_url)); ?> </li> <li><?php printf(wp_kses(__('Vote "Works" on the plugin\'s <a href="%s" target="_blank">WordPress listing</a>', 'ncr-captcha'), array('a' => array('href' => array(), 'target' => array('_blank')))), esc_url($compatibility_url)); ?> </li> <li><?php printf(wp_kses(__('<a href="%s" target="_blank">Share your thoughts on Twitter</a>', 'ncr-captcha'), array('a' => array('href' => array(), 'target' => array('_blank')))), esc_url($twitter_url)); ?> </li> </ul> </div> </div> </div> </div> </div> </div> <br class="clear"> </div> </div> <?php }
public function default_sidebar_contents() { // Boxes that will appear randomly // Box about GitHub $headline = _x("Simple History is on GitHub", 'Sidebar box', 'simple-history'); $body = sprintf(_x('You can star, fork, or report issues with this plugin over at the <a href="%1$s">GitHub page</a>.', 'Sidebar box', 'simple-history'), 'https://github.com/bonny/WordPress-Simple-History'); $boxGithub = ' <div class="postbox"> <h3 class="hndle">' . $headline . '</h3> <div class="inside"> <p>' . $body . '</p> </div> </div> '; // Box about donation $headline = _x('Donate to support development', 'Sidebar box', 'simple-history'); $body = sprintf(_x('If you like and use Simple History you should <a href="%1$s">donate to keep this plugin free</a>.', 'Sidebar box', 'simple-history'), 'http://eskapism.se/sida/donate/'); $boxDonate = ' <div class="postbox"> <h3 class="hndle">' . $headline . '</h3> <div class="inside"> <p>' . $body . '</p> </div> </div> '; // Box about review $headline = _x('Review this plugin if you like it', 'Sidebar box', 'simple-history'); $body1 = sprintf(_x('If you like Simple History then please <a href="%1$s">give it a nice review over at wordpress.org</a>.', 'Sidebar box', 'simple-history'), 'https://wordpress.org/support/view/plugin-reviews/simple-history'); $body2 = _x('A good review will help new users find this plugin. And it will make the plugin author very happy :)', 'Sidebar box', 'simple-history'); $boxReview = ' <div class="postbox"> <h3 class="hndle">' . $headline . '</h3> <div class="inside"> <p>' . $body1 . '</p> <p>' . $body2 . '</p> </div> </div> '; // Box about tweeting and blogging /* $boxSocial = ' <div class="postbox"> <h3 class="hndle">Blog or tweet</h3> <div class="inside"> <p>Yeah, how about that yo.</p> </div> </div> '; */ // Box about possible events missing $boxMissingEvents = sprintf(' <div class="postbox"> <h3 class="hndle">%1$s</h3> <div class="inside"> <p>%2$s</p> <p><a href="*****@*****.**">hello@simple-history.com</a></p> </div> </div> ', _x("Add more to the log", "Sidebar box", "simple-history"), _x("Are there things you miss in the history log?", "Sidebar box", "simple-history")); // Box about support $boxSupport = sprintf(' <div class="postbox"> <h3 class="hndle">%1$s</h3> <div class="inside"> <p>%2$s</p> </div> </div> ', _x("Support", "Sidebar box", "simple-history"), sprintf(_x('<a href="%1$s">Visit the support forum</a> if you need help or have questions.', "Sidebar box", "simple-history"), 'https://wordpress.org/support/plugin/simple-history')); $arrBoxes = array("boxReview" => $boxReview, "boxSupport" => $boxSupport, "boxDonate" => $boxDonate); /** * Filter the default boxes to output in the sidebar * * @since 2.0.17 * * @param array $arrBoxes array with boxes to output. Check the key to determine which box is which. */ $arrBoxes = apply_filters("simple_history/SidebarDropin/default_sidebar_boxes", $arrBoxes); //echo $arrBoxes[array_rand($arrBoxes)]; echo implode("", $arrBoxes); // show all // Box to encourage people translate plugin $current_locale = get_locale(); /** WordPress Translation Install API. This file exists only since 4.0. */ $translation_install_file = ABSPATH . 'wp-admin/includes/translation-install.php'; // Show only the translation box if current language is not an english language if (in_array($current_locale, array("en_US", "en_GB", "en_CA", "en_NZ", "en_AU")) != $current_locale && file_exists($translation_install_file)) { require_once $translation_install_file; $translations = wp_get_available_translations(); // This text does not need translation since is's only shown in English $boxTranslationTmpl = ' <div class="postbox"> <h3 class="hndle">Translate Simple History to %1$s</h3> <div class="inside"> <p> It looks like Simple History is not yet translated to your language. </p> <p> If you\'re interested in translating it please check out the <a href="https://developer.wordpress.org/plugins/internationalization/localization/">localization</a> part of the Plugin Handbook for info on how to translate plugins. </p> <p> When you\'re done with your translation email it to me at <a href="mailto:par.thernstrom@gmail.com" rel="nofollow">par.thernstrom@gmail.com</a> or <a href="https://github.com/bonny/WordPress-Simple-History/" rel="nofollow">add a pull request</a>. </p> </div> </div> '; if (isset($translations[$current_locale])) { // Check if an existing text string returns something else, and that current lang is not en $teststring_translated = __("Just now", "simple-history"); $teststring_untranslated = "Just now"; if ($teststring_untranslated == $teststring_translated) { // strings are the same, so plugin probably not translated printf($boxTranslationTmpl, $translations[$current_locale]["english_name"]); } } } // if not en_US + translation install file exists }
/** * Download the chosen fallback language on save and create the language dropdown similar to the default language dropdown */ public function fallback_locale_field() { $languages = get_available_languages(); $translations = wp_get_available_translations(); $fallback_locale = $this->fallback_locale; // Handle translation install. if (!empty($fallback_locale) && !in_array($fallback_locale, $languages) && (!is_multisite() || is_super_admin())) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; if (wp_can_install_language_pack()) { $language = wp_download_language_pack($fallback_locale); if ($language) { $fallback_locale = $language; } } } wp_dropdown_languages(array('name' => 'fallback_locale', 'id' => 'fallback_locale', 'selected' => $fallback_locale, 'languages' => $languages, 'translations' => $translations, 'show_available_translations' => (!is_multisite() || is_super_admin()) && wp_can_install_language_pack())); }
/** * Language selector. * * @since 4.0.0 * * @see get_available_languages() * @see wp_get_available_translations() * * @param array $args Optional arguments. Default empty array. */ function wp_dropdown_languages($args = array()) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $args = wp_parse_args($args, array('id' => '', 'name' => '', 'languages' => array(), 'selected' => '')); if (empty($args['languages'])) { return false; } $translations = wp_get_available_translations(); /* * $args['languages'] should only contain the locales. Find the locale in * $translations to get the native name. Fall back to locale. */ $languages = array(); foreach ($args['languages'] as $locale) { if (isset($translations[$locale])) { $translation = $translations[$locale]; $languages[] = array('language' => $translation['language'], 'native_name' => $translation['native_name'], 'lang' => $translation['iso'][1]); } else { $languages[] = array('language' => $locale, 'native_name' => $locale, 'lang' => ''); } } printf('<select name="%s" id="%s">', esc_attr($args['name']), esc_attr($args['id'])); // List installed languages. echo '<option value="" lang="en">English (United States)</option>'; foreach ($languages as $language) { $selected = selected($language['language'], $args['selected'], false); printf('<option value="%s" lang="%s"%s>%s</option>', esc_attr($language['language']), esc_attr($language['lang']), $selected, esc_html($language['native_name'])); } echo '</select>'; }
static function download_language_packs() { $languages = pll_languages_list(array('fields' => 'locale')); // prevents upgrade if the .po file is already here. Let WP manage the upgrades :) foreach ($languages as $key => $locale) { if (file_exists(WP_LANG_DIR . "/{$locale}.po")) { unset($languages[$key]); } } if (empty($languages)) { return; } require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); if (!$translations) { return; } foreach ($translations as $translation) { if (in_array($translation['language'], $languages)) { $translation['type'] = 'core'; $translations_to_load[] = (object) $translation; } } if (!empty($translations_to_load)) { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $upgrader = new Language_Pack_Upgrader(new Automatic_Upgrader_Skin()); $upgrader->bulk_upgrade($translations_to_load, array('clear_update_cache' => false)); } }
function bogo_tools_page() { $message = ""; if (isset($_GET['message'])) { if ('success' == $_GET['message']) { $message = __("Translation installed successfully.", 'bogo'); } elseif ('failed' == $_GET['message']) { $message = __("Translation install failed.", 'bogo'); } } $default_locale = bogo_get_default_locale(); $available_locales = bogo_available_locales(); ?> <div class="wrap"> <h2><?php echo esc_html(__('Bogo Tools', 'bogo')); ?> </h2> <?php if (!empty($message)) { ?> <div id="message" class="updated"><p><?php echo esc_html($message); ?> </p></div> <?php } ?> <h3 class="title"><?php echo esc_html(__('Available Languages', 'bogo')); ?> </h3> <table id="bogo-languages-table" class="widefat"> <thead> <tr><th></th><th><?php echo esc_html(__('Language', 'bogo')); ?> </th></tr> </thead> <tfoot> <tr><th></th><th><?php echo esc_html(__('Language', 'bogo')); ?> </th></tr> </tfoot> <tbody id="translations"> <tr><th>1</th><td><p> <strong><?php echo esc_html(bogo_get_language($default_locale)); ?> </strong> [<?php echo esc_html($default_locale); ?> ] <br /><?php echo esc_html(__('Site Default Language', 'bogo')); ?> </p></td></tr> <?php $count = 1; foreach ($available_locales as $locale) { if ($locale == $default_locale) { continue; } $count += 1; ?> <tr><th><?php echo $count; ?> </th><td><p> <strong><?php echo esc_html(bogo_get_language($locale)); ?> </strong> [<?php echo esc_html($locale); ?> ] <br /><?php echo esc_html(__('Installed', 'bogo')); ?> </p></td></tr> <?php } $can_install = wp_can_install_language_pack(); foreach (wp_get_available_translations() as $locale => $translation) { if (in_array($locale, $available_locales)) { continue; } $count += 1; $install_link = ''; if ($can_install) { $install_link = menu_page_url('bogo-tools', false); $install_link = add_query_arg(array('action' => 'install_translation', 'locale' => $locale), $install_link); $install_link = wp_nonce_url($install_link, 'bogo-tools'); $install_link = sprintf('<a href="%1$s" class="install">%2$s</a>', $install_link, esc_html(__('Install', 'bogo'))); } ?> <tr><th><?php echo $count; ?> </th><td><p> <strong><?php echo esc_html(bogo_get_language($locale)); ?> </strong> [<?php echo esc_html($locale); ?> ] <?php echo $install_link; ?> </p></td></tr> <?php } ?> </tbody> </table> </div> <?php }
*/ global $wp_locale; for ($day_index = 0; $day_index <= 6; $day_index++) { $selected = get_option('start_of_week') == $day_index ? 'selected="selected"' : ''; echo "\n\t<option value='" . esc_attr($day_index) . "' {$selected}>" . $wp_locale->get_weekday($day_index) . '</option>'; } ?> </select></td> </tr> <?php do_settings_fields('general', 'default'); ?> <?php $languages = get_available_languages(); $translations = wp_get_available_translations(); if (!is_multisite() && defined('WPLANG') && '' !== WPLANG && 'en_US' !== WPLANG && !in_array(WPLANG, $languages)) { $languages[] = WPLANG; } if (!empty($languages) || !empty($translations)) { ?> <tr> <th width="33%" scope="row"><label for="WPLANG"><?php _e('Site Language'); ?> </label></th> <td> <?php $locale = get_locale(); if (!in_array($locale, $languages)) { $locale = '';
/** * Add custom HTML code after title in Post editing page * * @global type $post */ function hook_after_title() { global $post; if ($this->check_support()) { $wr_pagebuilder_content = get_post_meta($post->ID, '_wr_page_builder_content', true); // Get active tab $wr_page_active_tab = get_post_meta($post->ID, '_wr_page_active_tab', true); $tab_active = isset($wr_page_active_tab) ? intval($wr_page_active_tab) : (!empty($wr_pagebuilder_content) ? 1 : 0); // Deactivate pagebuilder $wr_deactivate_pb = get_post_meta($post->ID, '_wr_deactivate_pb', true); $wr_deactivate_pb = isset($wr_deactivate_pb) ? intval($wr_deactivate_pb) : 0; $wrapper_style = $tab_active ? 'style="display:none"' : ''; // Get array list of dismissed pointers for current user and convert it to array $dismissed_pointers = explode(',', get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true)); // If this post has not used PageBuilder global $post; $not_used_pb = isset($post) && 1 !== get_post_meta($post->ID, '_wr_page_active_tab'); // Check if our pointer is not among dismissed ones $translate = NULL; $current_lang = get_option('WPLANG'); if ($current_lang && !preg_match("/^en/", $current_lang) && $not_used_pb && !in_array('wr_pb_settings_pointer_translate', $dismissed_pointers)) { $language = 'your language'; if (file_exists(ABSPATH . 'wp-admin/includes/translation-install.php')) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $translations = wp_get_available_translations(); $language = $translations[$current_lang]['native_name']; } $translate = ' <div id="translation-transifex"> <p> <a target="_blank" href="http://goo.gl/Sg2owo">' . sprintf(__('Help translate WR PageBuilder to %s.'), $language) . '</a> <span id="wr-close"></span> </p> </div> <script type="text/javascript"> jQuery(document).ready( function($) { $("#wr-close").click(function(e){ $.post( ajaxurl, { pointer: "wr_pb_settings_pointer_translate", // pointer ID action: "dismiss-wp-pointer" }); $("#translation-transifex").hide(); }) }); </script> '; } echo ' <input id="wr_active_tab" name="wr_active_tab" value="' . $tab_active . '" type="hidden"> <input id="wr_deactivate_pb" name="wr_deactivate_pb" value="' . $wr_deactivate_pb . '" type="hidden"> <div class="jsn-bootstrap3 wr-editor-wrapper" ' . $wrapper_style . '> <ul class="nav nav-tabs" id="wr_editor_tabs"> <li class="active"><a href="#wr_editor_tab1">' . __('Classic Editor', WR_PBL) . '</a></li> <li><a href="#wr_editor_tab2">' . __('WR PageBuilder', WR_PBL) . '</a></li> </ul> ' . $translate . ' <div class="tab-content wr-editor-tab-content"> <div class="tab-pane active" id="wr_editor_tab1">'; } }
" tabindex="-1"><?php _e('WordPress'); ?> </a></p> <?php } // end function setup_config_display_header(); $language = ''; if (!empty($_REQUEST['language'])) { $language = preg_replace('/[^a-zA-Z_]/', '', $_REQUEST['language']); } elseif (isset($GLOBALS['wp_local_package'])) { $language = $GLOBALS['wp_local_package']; } switch ($step) { case -1: if (wp_can_install_language_pack() && empty($language) && ($languages = wp_get_available_translations())) { setup_config_display_header('language-chooser'); echo '<h1 class="screen-reader-text">Select a default language</h1>'; echo '<form id="setup" method="post" action="?step=0">'; wp_install_language_form($languages); echo '</form>'; break; } // Deliberately fall through if we can't reach the translations API. // Deliberately fall through if we can't reach the translations API. case 0: if (!empty($language)) { $loaded_language = wp_download_language_pack($language); if ($loaded_language) { load_default_textdomain($loaded_language); $GLOBALS['wp_locale'] = new WP_Locale();
/** * Add the inputs to the User Profile page * * @param WP_User $user User instance to output for. */ public static function user_profile($user) { $languages = get_available_languages(); $translations = wp_get_available_translations(); $locale = get_the_author_meta(self::meta_name, $user->ID); if (empty($locale)) { $locale = get_locale(); } if (!in_array($locale, $languages)) { $locale = ''; } wp_nonce_field(self::meta_name . '_profile_update', self::meta_name . '_nonce'); require_once 'templates/user-profile.php'; }