function icl_register_admin_options($array, $key = "", $option = array()) { foreach ($array as $k => $v) { if (is_array($v)) { array_push($option, $k); $this->icl_register_admin_options($v, $key . '[' . $k . ']', $option); array_pop($option); } else { $context = $this->get_context($key, $k); if ($v === '') { icl_unregister_string($context, $key . $k); } else { icl_register_string($context, $key . $k, $v); $vals = array($k => 1); if (count($option)) { for ($i = count($option) - 1; $i >= 0; $i--) { $vals = array($option[$i] => $vals); } } $_icl_admin_option_names = get_option('_icl_admin_option_names'); $_icl_admin_option_names = array_merge_recursive((array) $_icl_admin_option_names, $vals); update_option('_icl_admin_option_names', $_icl_admin_option_names); } } } }
function icl_register_admin_options($array, $key = "", $option = array()) { if (is_object($option)) { $option = object_to_array($option); } foreach ($array as $k => $v) { $option = $key === '' ? array($k => maybe_unserialize($this->get_option_without_filtering($k))) : $option; if (is_array($v)) { $this->icl_register_admin_options($v, $key . '[' . $k . ']', $option[$k]); } else { $context = $this->get_context($key, $k); if ($v === '') { icl_unregister_string($context, $key . $k); } elseif (isset($option[$k]) && ($key === '' || preg_match_all('#\\[([^\\]]+)\\]#', (string) $key, $opt_key_matches) > 0)) { icl_register_string($context, $key . $k, $option[$k]); $vals = array($k => 1); $opt_keys = isset($opt_key_matches) ? array_reverse($opt_key_matches[1]) : array(); foreach ($opt_keys as $opt) { $vals = array($opt => $vals); } update_option('_icl_admin_option_names', array_merge_recursive((array) get_option('_icl_admin_option_names'), $vals)); } } } }
/** * Unregister multilanguage string, Polylang missing support of this feature * * @since 1.0.0 * * @param string $plugin_name_human_format The Plugin name. * @param string $string_name The name of the string. */ function deregister_string($plugin_name_human_format, $string_name) { if (function_exists('icl_unregister_string')) { icl_unregister_string($plugin_name_human_format, $string_name); } elseif (has_filter('cml_my_translations')) { $plugin_name_human_format_replaced = str_replace(' ', '-', $plugin_name_human_format); CMLTranslations::delete($plugin_name_human_format_replaced); } }
/** * Deletes custom petition form strings that are registered with WPML * * @param int $id value of the petition's 'id' field in the database */ public function unregister_petition($id) { if (function_exists('icl_unregister_string')) { $context = 'Petition ' . $id; icl_unregister_string($context, 'petition title'); icl_unregister_string($context, 'email subject'); icl_unregister_string($context, 'greeting'); icl_unregister_string($context, 'petition message'); icl_unregister_string($context, 'custom field label'); icl_unregister_string($context, 'twitter message'); icl_unregister_string($context, 'optin label'); } }
function pc_cat_wpml_del_name($cat_id) { if (function_exists('icl_unregister_string')) { icl_unregister_string('PrivateContent Categories', $cat_id); } }
/** * WPML support: Update strings that need translation. * * @param array $old_menu The old custom menu, if any. * @param array $custom_menu The new custom menu. */ private function update_wpml_strings($old_menu, $custom_menu) { if (!function_exists('icl_register_string')) { return; } $previous_strings = $this->get_wpml_strings($old_menu); $new_strings = $this->get_wpml_strings($custom_menu); //Delete strings that are no longer valid. if (function_exists('icl_unregister_string')) { $removed_strings = array_diff_key($previous_strings, $new_strings); foreach ($removed_strings as $name => $value) { icl_unregister_string(self::WPML_CONTEXT, $name); } } //Register/update the new menu strings. foreach ($new_strings as $name => $value) { icl_register_string(self::WPML_CONTEXT, $name, $value); } }
public function languages_page() { // prepare the list of tabs $tabs = array('lang' => __('Languages', 'polylang')); // only if at least one language has been created if ($listlanguages = $this->model->get_languages_list()) { $tabs['strings'] = __('Strings translation', 'polylang'); $tabs['settings'] = __('Settings', 'polylang'); } // allows plugins to add tabs $tabs = apply_filters('pll_settings_tabs', $tabs); switch ($this->active_tab) { case 'lang': // prepare the list table of languages $list_table = new PLL_Table_Languages(); $list_table->prepare_items($listlanguages); break; case 'strings': // get the strings to translate $data = PLL_Admin_Strings::get_strings(); // get the groups foreach ($data as $key => $row) { $groups[] = $row['context']; } $groups = array_unique($groups); $selected = empty($_GET['group']) || !in_array($_GET['group'], $groups) ? -1 : $_GET['group']; $s = empty($_GET['s']) ? '' : wp_unslash($_GET['s']); // filter for search string foreach ($data as $key => $row) { if (-1 != $selected && $row['context'] != $selected || !empty($s) && stripos($row['name'], $s) === false && stripos($row['string'], $s) === false) { unset($data[$key]); } } // load translations foreach ($listlanguages as $language) { // filters by language if requested if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg) { continue; } $mo = new PLL_MO(); $mo->import_from_db($language); foreach ($data as $key => $row) { $data[$key]['translations'][$language->slug] = $mo->translate($row['string']); $data[$key]['row'] = $key; // store the row number for convenience } } // get an array with language slugs as keys, names as values $languages = array_combine(wp_list_pluck($listlanguages, 'slug'), wp_list_pluck($listlanguages, 'name')); $string_table = new PLL_Table_String(compact('languages', 'groups', 'selected')); $string_table->prepare_items($data); break; case 'settings': $post_types = get_post_types(array('public' => true, '_builtin' => false)); $post_types = array_diff($post_types, get_post_types(array('_pll' => true))); $post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true)); $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false)); $taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true))); $taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies, true)); break; } $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : ''; switch ($action) { case 'add': check_admin_referer('add-lang', '_wpnonce_add-lang'); if ($this->model->add_language($_POST) && 'en_US' != $_POST['locale']) { // attempts to install the language pack require_once ABSPATH . 'wp-admin/includes/translation-install.php'; if (!wp_download_language_pack($_POST['locale'])) { add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang')); } // force checking for themes and plugins translations updates wp_clean_themes_cache(); wp_clean_plugins_cache(); } self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true ) break; case 'delete': check_admin_referer('delete-lang'); if (!empty($_GET['lang'])) { $this->model->delete_language((int) $_GET['lang']); } self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true ) break; case 'edit': if (!empty($_GET['lang'])) { $edit_lang = $this->model->get_language((int) $_GET['lang']); } break; case 'update': check_admin_referer('add-lang', '_wpnonce_add-lang'); $error = $this->model->update_language($_POST); self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true ) break; case 'default-lang': check_admin_referer('default-lang'); if ($lang = $this->model->get_language((int) $_GET['lang'])) { $this->model->update_default_lang($lang->slug); } self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true ) break; case 'content-default-lang': check_admin_referer('content-default-lang'); if ($nolang = $this->model->get_objects_with_no_lang()) { if (!empty($nolang['posts'])) { $this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']); } if (!empty($nolang['terms'])) { $this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']); } } self::redirect(); // to refresh the page ( possible thanks to the $_GET['noheader']=true ) break; case 'string-translation': if (!empty($_POST['submit'])) { check_admin_referer('string-translation', '_wpnonce_string-translation'); $strings = PLL_Admin_Strings::get_strings(); foreach ($this->model->get_languages_list() as $language) { if (empty($_POST['translation'][$language->slug])) { // in case the language filter is active ( thanks to John P. Bloch ) continue; } $mo = new PLL_MO(); $mo->import_from_db($language); foreach ($_POST['translation'][$language->slug] as $key => $translation) { $translation = apply_filters('pll_sanitize_string_translation', $translation, $strings[$key]['name'], $strings[$key]['context']); $mo->add_entry($mo->make_entry($strings[$key]['string'], $translation)); } // clean database ( removes all strings which were registered some day but are no more ) if (!empty($_POST['clean'])) { $new_mo = new PLL_MO(); foreach ($strings as $string) { $new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string']))); } } isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language); } add_settings_error('general', 'pll_strings_translations_updated', __('Translations updated.', 'polylang'), 'updated'); do_action('pll_save_strings_translations'); } // unregisters strings registered through WPML API if ($string_table->current_action() == 'delete' && !empty($_POST['strings']) && function_exists('icl_unregister_string')) { check_admin_referer('string-translation', '_wpnonce_string-translation'); $strings = PLL_Admin_Strings::get_strings(); foreach ($_POST['strings'] as $key) { icl_unregister_string($strings[$key]['context'], $strings[$key]['name']); } } // to refresh the page ( possible thanks to the $_GET['noheader']=true ) $args = array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group'))); if (!empty($args['s'])) { $args['s'] = urlencode($args['s']); // searched string needs to be encoded as it comes from $_POST } self::redirect($args); break; case 'activate': check_admin_referer('pll_activate'); $this->modules[$_GET['module']]->activate(); self::redirect(); break; case 'deactivate': check_admin_referer('pll_deactivate'); $this->modules[$_GET['module']]->deactivate(); self::redirect(); break; default: do_action("mlang_action_{$action}"); break; } // displays the page include PLL_SETTINGS_INC . '/view-languages.php'; }
} } } /*Contact*/ $parallax_one_contact_pl = get_theme_mod('parallax_one_contact_info_content'); if (!empty($parallax_one_contact_pl)) { $parallax_one_contact_pl_decoded = json_decode($parallax_one_contact_pl); foreach ($parallax_one_contact_pl_decoded as $parallax_one_contact_box) { $text = $parallax_one_contact_box->text; $id = esc_attr($parallax_one_contact_box->id); if (!empty($id)) { if (!empty($text)) { icl_unregister_string('Contact', $id . '_contact'); icl_register_string('Contact', $id . '_contact', $title); } else { icl_unregister_string('Contact', $id . '_contact'); } } } } } /*Check if Repeater is empty*/ function parallax_one_general_repeater_is_empty($parallax_one_arr) { $parallax_one_services_decoded = json_decode($parallax_one_arr); foreach ($parallax_one_services_decoded as $parallax_box) { if (!empty($parallax_box->choice) && $parallax_box->choice == 'parallax_none') { $parallax_box->icon_value = ''; $parallax_box->image_url = ''; } foreach ($parallax_box as $key => $value) {
/** * Helper function to unregister a WPML string * * @access public * @since 2.1 */ function ot_wpml_unregister_string($id) { if (function_exists('icl_unregister_string')) { icl_unregister_string('Opções do Tema', $id); } }
public static function fp_rac_delete_email_template() { if (isset($_POST['row_id'])) { global $wpdb; $row_id = $_POST['row_id']; $table_name_email = $wpdb->prefix . 'rac_templates_email'; $wpdb->delete($table_name_email, array('id' => $row_id)); //removing registered WPML strings if (function_exists('icl_unregister_string')) { icl_unregister_string('RAC', 'rac_template_' . $row_id . '_message'); icl_unregister_string('RAC', 'rac_template_' . $row_id . '_subject'); } } exit; }
/** * Asks WPML to forget about $name * * @param stirn $name */ function tg_unregister_string_wpml($name) { if (function_exists('icl_unregister_string')) { icl_unregister_string('tag-groups', $name); } }
function mg_options_wpml_sync() { if (!function_exists('icl_register_string')) { die('error'); } require_once MG_DIR . '/functions.php'; $already_saved = get_option('mg_wpml_synced_opts'); $to_save = array(); foreach (mg_main_types() as $type => $name) { $type_opts = get_option('mg_' . $type . '_opt'); $typename = $type == 'img_gallery' ? 'Image Gallery' : ucfirst($type); if (is_array($type_opts) && count($type_opts) > 0) { foreach ($type_opts as $opt) { $index = $typename . ' Options - ' . $opt; $to_save[$index] = $index; icl_register_string('Media Grid - Item Options', $index, $opt); if (isset($already_saved[$index])) { unset($already_saved[$index]); } } } } if (is_array($already_saved) && count($already_saved) > 0) { foreach ($already_saved as $opt) { icl_unregister_string('Media Grid - Item Options', $opt); } } if (!get_option('mg_wpml_synced_opts')) { add_option('mg_wpml_synced_opts', '255', '', 'yes'); } update_option('mg_wpml_synced_opts', $to_save); die('success'); }
$sql_signatures_table = "DROP TABLE {$db_signatures}"; $wpdb->query($sql_signatures_table); // delete WPML strings if (function_exists('icl_unregister_string')) { // delete petition strings in WPML foreach ($petitions as $petition) { $context = 'Petition ' . $petition->id; icl_unregister_string($context, 'petition title'); icl_unregister_string($context, 'email subject'); icl_unregister_string($context, 'greeting'); icl_unregister_string($context, 'petition message'); icl_unregister_string($context, 'custom field label'); icl_unregister_string($context, 'twitter message'); icl_unregister_string($context, 'optin label'); } // delete widget strings in WPML foreach ($petitions as $petition) { $context = 'Petition ' . $petition->id; icl_unregister_string($context, 'widget title'); icl_unregister_string($context, 'widget call to action'); } // delete options strings in WPML icl_unregister_string('Petition', 'submit button text'); icl_unregister_string('Petition', 'success message'); icl_unregister_string('Petition', 'share message'); icl_unregister_string('Petition', 'expiration message'); icl_unregister_string('Petition', 'already signed message'); icl_unregister_string('Petition', 'signaturelist title'); icl_unregister_string('Petition', 'confirmation email subject'); icl_unregister_string('Petition', 'confirmation email message'); }
function icl_register_admin_options($array, $key = "") { foreach ($array as $k => $v) { if (is_array($v)) { icl_register_admin_options($v, $key . '[' . $k . ']'); } else { if ($v === '') { icl_unregister_string('admin_options_' . get_option('template'), $key . $k); } else { icl_register_string('admin_options_' . get_option('template'), $key . $k, $v); } } } }
public function languages_page() { // prepare the list of tabs $tabs = array('lang' => __('Languages', 'polylang')); // only if at least one language has been created if ($listlanguages = $this->model->get_languages_list()) { $tabs['strings'] = __('Strings translation', 'polylang'); $tabs['settings'] = __('Settings', 'polylang'); } $active_tab = !empty($_GET['tab']) ? $_GET['tab'] : 'lang'; switch ($active_tab) { case 'lang': // prepare the list table of languages $list_table = new PLL_Table_Languages(); $list_table->prepare_items($listlanguages); // error messages for data validation $errors[1] = __('Enter a valid WordPress locale', 'polylang'); $errors[2] = __('The language code contains invalid characters', 'polylang'); $errors[3] = __('The language code must be unique', 'polylang'); $errors[4] = __('The language must have a name', 'polylang'); $errors[5] = __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang'); break; case 'strings': // get the strings to translate $data = $this->get_strings(); $selected = empty($_REQUEST['group']) ? -1 : $_REQUEST['group']; foreach ($data as $key => $row) { $groups[] = $row['context']; // get the groups // filter for search string if ($selected != -1 && $row['context'] != $selected || !empty($_REQUEST['s']) && stripos($row['name'], $_REQUEST['s']) === false && stripos($row['string'], $_REQUEST['s']) === false) { unset($data[$key]); } } $groups = array_unique($groups); // load translations foreach ($listlanguages as $language) { // filters by language if requested if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg) { continue; } $mo = new PLL_MO(); $mo->import_from_db($language); foreach ($data as $key => $row) { $data[$key]['translations'][$language->name] = $mo->translate($row['string']); $data[$key]['row'] = $key; // store the row number for convenience } } $string_table = new PLL_Table_String($groups, $selected); $string_table->prepare_items($data); break; case 'settings': $post_types = get_post_types(array('public' => true, '_builtin' => false)); $post_types = array_diff($post_types, get_post_types(array('_pll' => true))); $post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true)); $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false)); $taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true))); $taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies, true)); break; default: break; } $using_permalinks = $GLOBALS['wp_rewrite']->using_permalinks(); $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : ''; switch ($action) { case 'add': check_admin_referer('add-lang', '_wpnonce_add-lang'); $error = $this->model->add_language($_POST); if (0 == $error && !PLL_Admin::download_mo($_POST['locale'])) { $error = 5; } wp_redirect('admin.php?page=mlang' . ($error ? '&error=' . $error : '')); // to refresh the page (possible thanks to the $_GET['noheader']=true) exit; break; case 'delete': check_admin_referer('delete-lang'); if (!empty($_GET['lang'])) { $this->model->delete_language((int) $_GET['lang']); } wp_redirect('admin.php?page=mlang'); // to refresh the page (possible thanks to the $_GET['noheader']=true) exit; break; case 'edit': if (!empty($_GET['lang'])) { $edit_lang = $this->model->get_language((int) $_GET['lang']); } break; case 'update': check_admin_referer('add-lang', '_wpnonce_add-lang'); $error = $this->model->update_language($_POST); wp_redirect('admin.php?page=mlang' . ($error ? '&error=' . $error : '')); // to refresh the page (possible thanks to the $_GET['noheader']=true) exit; break; case 'string-translation': if (!empty($_REQUEST['submit'])) { check_admin_referer('string-translation', '_wpnonce_string-translation'); $strings = $this->get_strings(); foreach ($this->model->get_languages_list() as $language) { if (empty($_POST['translation'][$language->name])) { // in case the language filter is active (thanks to John P. Bloch) continue; } $mo = new PLL_MO(); $mo->import_from_db($language); foreach ($_POST['translation'][$language->name] as $key => $translation) { $mo->add_entry($mo->make_entry($strings[$key]['string'], stripslashes($translation))); } // clean database (removes all strings which were registered some day but are no more) if (!empty($_POST['clean'])) { $new_mo = new PLL_MO(); foreach ($strings as $string) { $new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string']))); } } isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language); } } do_action('pll_save_strings_translations'); // unregisters strings registered through WPML API if ($string_table->current_action() == 'delete' && !empty($_REQUEST['strings']) && function_exists('icl_unregister_string')) { check_admin_referer('string-translation', '_wpnonce_string-translation'); $strings = $this->get_strings(); foreach ($_REQUEST['strings'] as $key) { icl_unregister_string($strings[$key]['context'], $strings[$key]['name']); } } // to refresh the page (possible thanks to the $_GET['noheader']=true) $url = 'admin.php?page=mlang&tab=strings'; foreach (array('s', 'paged', 'group') as $qv) { $url = empty($_REQUEST[$qv]) ? $url : $url . '&' . $qv . '=' . $_REQUEST[$qv]; } wp_redirect($url); exit; break; case 'options': check_admin_referer('options-lang', '_wpnonce_options-lang'); $this->options['default_lang'] = sanitize_title($_POST['default_lang']); // we have slug as value foreach (array('force_lang', 'rewrite') as $key) { $this->options[$key] = isset($_POST[$key]) ? (int) $_POST[$key] : 0; } // FIXME : TODO error message if not a valid url if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) { foreach ($_POST['domains'] as $key => $domain) { $this->options['domains'][$key] = esc_url_raw(trim($domain)); } $this->options['domains'][$this->options['default_lang']] = get_option('home'); } foreach (array('browser', 'hide_default', 'redirect_lang', 'media_support') as $key) { $this->options[$key] = isset($_POST[$key]) ? 1 : 0; } if (3 == $this->options['force_lang']) { $this->options['browser'] = $this->options['hide_default'] = 0; } foreach (array('sync', 'post_types', 'taxonomies') as $key) { $this->options[$key] = empty($_POST[$key]) ? array() : array_keys($_POST[$key], 1); } update_option('polylang', $this->options); // refresh rewrite rules in case rewrite, hide_default, post types or taxonomies options have been modified // it seems useless to refresh permastruct here flush_rewrite_rules(); // refresh language cache in case home urls have been modified $this->model->clean_languages_cache(); // fills existing posts & terms with default language if (isset($_POST['fill_languages']) && ($nolang = $this->model->get_objects_with_no_lang())) { if (!empty($nolang['posts'])) { $this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']); } if (!empty($nolang['terms'])) { $this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']); } } wp_redirect('admin.php?page=mlang&tab=settings&updated=true'); // updated=true interpreted by WP exit; break; default: break; } // displays the page include PLL_ADMIN_INC . '/view-languages.php'; }
foreach ($shop_isle_advantages_pl_decoded as $shop_isle_advantages) { if (!empty($shop_isle_advantages->id)) { $id = $shop_isle_advantages->id; } $icon_value = $shop_isle_advantages->icon_value; $text = $shop_isle_advantages->text; $subtext = $shop_isle_advantages->subtext; if (!empty($id)) { if (!empty($icon_value)) { icl_unregister_string('Advantage ' . $id, 'Advantage icon'); icl_register_string('Advantage ' . $id, 'Advantage icon', $icon_value); } else { icl_unregister_string('Advantage ' . $id, 'Advantage icon'); } if (!empty($text)) { icl_unregister_string('Advantage ' . $id, 'Advantage text'); icl_register_string('Advantage ' . $id, 'Advantage text', $text); } else { icl_unregister_string('Advantage ' . $id, 'Advantage text'); } if (!empty($subtext)) { icl_unregister_string('Advantage ' . $id, 'Advantage subtext'); icl_register_string('Advantage ' . $id, 'Advantage subtext', $subtext); } else { icl_unregister_string('Advantage ' . $id, 'Advantage subtext'); } } } } } }
foreach ($llorix_one_lite_social_icons_pl_decoded as $llorix_one_header_social_box) { $icon = $llorix_one_header_social_box->icon_value; $link = $llorix_one_header_social_box->link; $id = $llorix_one_header_social_box->id; if (!empty($id)) { if (!empty($icon)) { icl_unregister_string('Footer Social Icon', $id . '_footer_social_icon'); icl_register_string('Footer Social Icon', $id . '_footer_social_icon', $icon); } else { icl_unregister_string('Footer Social Icon', $id . '_footer_social_icon'); } if (!empty($link)) { icl_unregister_string('Footer Social Link', $id . '_footer_social_link'); icl_register_string('Footer Social Link', $id . '_footer_social_link', $link); } else { icl_unregister_string('Footer Social Link', $id . '_footer_social_link'); } } } } } /*Check if Repeater is empty*/ function llorix_one_lite_general_repeater_is_empty($llorix_one_lite_arr) { $llorix_one_lite_arr_decoded = json_decode($llorix_one_lite_arr); foreach ($llorix_one_lite_arr_decoded as $llorix_one_lite_box) { if (!empty($llorix_one_lite_box->choice) && $llorix_one_lite_box->choice == 'llorix_one_lite_none') { $llorix_one_lite_box->icon_value = ''; $llorix_one_lite_box->image_url = ''; } foreach ($llorix_one_lite_box as $key => $value) {
function icl_register_admin_options($array, $key = "") { foreach ($array as $k => $v) { if (is_array($v)) { icl_register_admin_options($v, $key . '[' . $k . ']'); } else { if ($v === '') { icl_unregister_string('admin_texts_theme_' . get_option('template'), $key . $k); } else { icl_register_string('admin_texts_theme_' . get_option('template'), $key . $k, $v); $vals[$k] = 1; $_icl_admin_option_names = get_option('_icl_admin_option_names'); if (!isset($_icl_admin_option_names['theme'])) { $_icl_admin_option_names['theme'] = array(); } $theme_used = get_option('template'); if (!isset($_icl_admin_option_names['theme'][$theme_used])) { $_icl_admin_option_names['theme'][$theme_used] = array(); } $_icl_admin_option_names['theme'][get_option('template')] = array_merge_recursive((array) $_icl_admin_option_names['theme'][get_option('template')], $vals); $_icl_admin_option_names['theme'][get_option('template')] = __array_unique_recursive($_icl_admin_option_names['theme'][get_option('template')]); update_option('_icl_admin_option_names', $_icl_admin_option_names); } } } }
function pcud_fields_wpml_sync($fdata) { if (!function_exists('icl_register_string')) { return false; } $saved = (array) get_option('pcud_wpml_synced_fields', array()); $to_save = array(); foreach ($fdata['pcud_f_index'] as $key => $val) { $index = $val; $to_save[$index] = array('label'); //// label // check if unregister before if (isset($saved[$index]) && isset($saved[$index]['label']) && $saved[$index]['label'] != $fdata['pcud_f_label'][$key]) { icl_unregister_string('PrivateContent User Data', 'Custom fields - ' . $index); // retrocompatibility icl_unregister_string('PrivateContent User Data', $index . ' - label'); } $to_save[$index]['label'] = $fdata['pcud_f_label'][$key]; icl_register_string('PrivateContent User Data', $index . ' - label', $fdata['pcud_f_label'][$key]); //// options // check if unregister before if (isset($saved[$index]) && isset($saved[$index]['opt']) && $saved[$index]['label'] != $fdata['pcud_f_options'][$key]) { icl_unregister_string('PrivateContent User Data', 'Custom fields opt - ' . $index); // retrocompatibility icl_unregister_string('PrivateContent User Data', $index . ' - options'); } if (!empty($fdata['pcud_f_options'][$key])) { $to_save[$index]['opt'] = $fdata['pcud_f_options'][$key]; icl_register_string('PrivateContent User Data', $index . ' - options', $fdata['pcud_f_options'][$key]); } //// placeholder // check if unregister before if (isset($saved[$index]) && isset($saved[$index]['placeh']) && $saved[$index]['placeh'] != $fdata['pcud_f_placeh'][$key]) { icl_unregister_string('PrivateContent User Data', 'Custom fields placeholder - ' . $index); // retrocompatibility icl_unregister_string('PrivateContent User Data', $index . ' - placeholder'); } if (!empty($fdata[$key]['pcud_f_placeh'])) { $to_save[$index]['placeh'] = $fdata['pcud_f_placeh'][$key]; icl_register_string('PrivateContent User Data', $index . ' - placeholder', $fdata['pcud_f_placeh'][$key]); } //// single checkbox text // check if unregister before if (isset($saved[$index]) && isset($saved[$index]['check_txt']) && $saved[$index]['check_txt'] != $fdata['pcud_f_check_txt'][$key]) { icl_unregister_string('PrivateContent User Data', $index . ' - checkbox text'); } if (!empty($fdata[$key]['pcud_f_check_txt'])) { $to_save[$index]['check_txt'] = $fdata['pcud_f_check_txt'][$key]; icl_register_string('PrivateContent User Data', $index . ' - checkbox text', $fdata['pcud_f_check_txt'][$key]); } } // save registered fields update_option('pcud_wpml_synced_fields', $to_save); }
public function deleted_group_action($group) { // Unregister name if (!empty($group->name)) { icl_unregister_string($this->_context, "{$this->_group_string_prefix}{$group->id} name", $group->name); } // Unregister description if (!empty($group->description)) { icl_unregister_string($this->_context, "{$this->_group_string_prefix}{$group->id} description", $group->description); } }
function delete_wppizza_wpmlstrings() { /**deregister wpml strings**/ if (function_exists('icl_translate')) { $options = get_option('wppizza'); /*localization*/ foreach ($options['localization'] as $k => $arr) { icl_unregister_string('wppizza', $k); } /**additives**/ if (isset($options['additives']) && is_array($options['additives'])) { foreach ($options['additives'] as $k => $str) { icl_unregister_string('wppizza', 'additives_' . $k . ''); } } /**sizes**/ if (isset($options['sizes']) && is_array($options['sizes'])) { foreach ($options['sizes'] as $k => $arr) { foreach ($arr as $sKey => $sArr) { icl_unregister_string('wppizza', 'sizes_' . $k . '_' . $sKey . ''); } } } /**order_form**/ foreach ($options['order_form'] as $k => $arr) { icl_unregister_string('wppizza', 'order_form_' . $k . ''); } /**confirmation_form**/ foreach ($options['confirmation_form'] as $k => $arr) { icl_unregister_string('wppizza', 'confirmation_form_' . $k . ''); } /**order**/ icl_unregister_string('wppizza', 'order_email_from'); icl_unregister_string('wppizza', 'order_email_from_name'); /**order email to **/ if (isset($options['order']['order_email_to']) && is_array($options['order']['order_email_to'])) { foreach ($options['order']['order_email_to'] as $k => $arr) { icl_unregister_string('wppizza', 'order_email_to_' . $k . ''); } } /**order email bcc **/ if (isset($options['order']['order_email_bcc']) && is_array($options['order']['order_email_bcc'])) { foreach ($options['order']['order_email_bcc'] as $k => $arr) { icl_unregister_string('wppizza', 'order_email_bcc_' . $k . ''); } } /**order email attachments **/ if (isset($options['order']['order_email_attachments']) && is_array($options['order']['order_email_attachments'])) { foreach ($options['order']['order_email_attachments'] as $k => $arr) { icl_unregister_string('wppizza', 'order_email_attachments_' . $k . ''); } } /**single item permalink**/ icl_unregister_string('wppizza', 'single_item_permalink_rewrite'); /**gateways select label**/ icl_unregister_string('wppizza', 'gateway_select_label'); /**cod gateway***/ icl_unregister_string('wppizza_gateways', 'cod_gateway_label'); } }
/** * Saves the strings translations in DB * Optionaly clean the DB * * @since 1.9 */ public function save_translations() { check_admin_referer('string-translation', '_wpnonce_string-translation'); if (!empty($_POST['submit'])) { foreach ($this->languages as $language) { if (empty($_POST['translation'][$language->slug])) { // In case the language filter is active ( thanks to John P. Bloch ) continue; } $mo = new PLL_MO(); $mo->import_from_db($language); foreach ($_POST['translation'][$language->slug] as $key => $translation) { /** * Filter the string translation before it is saved in DB * Allows to sanitize strings registered with pll_register_string * * @since 1.6 * * @param string $translation the string translation * @param string $name the name as defined in pll_register_string * @param string $context the context as defined in pll_register_string */ $translation = apply_filters('pll_sanitize_string_translation', $translation, $this->strings[$key]['name'], $this->strings[$key]['context']); $mo->add_entry($mo->make_entry($this->strings[$key]['string'], $translation)); } // Clean database ( removes all strings which were registered some day but are no more ) if (!empty($_POST['clean'])) { $new_mo = new PLL_MO(); foreach ($this->strings as $string) { $new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string']))); } } isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language); } add_settings_error('general', 'pll_strings_translations_updated', __('Translations updated.', 'polylang'), 'updated'); /** * Fires after the strings translations are saved in DB * * @since 1.2 */ do_action('pll_save_strings_translations'); } // Unregisters strings registered through WPML API if ($this->current_action() === 'delete' && !empty($_POST['strings']) && function_exists('icl_unregister_string')) { foreach ($_POST['strings'] as $key) { icl_unregister_string($this->strings[$key]['context'], $this->strings[$key]['name']); } } // To refresh the page ( possible thanks to the $_GET['noheader']=true ) $args = array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group'))); if (!empty($_GET['paged']) && !empty($_POST['submit'])) { $args['paged'] = (int) $_GET['paged']; // Don't rely on $_REQUEST['paged'] or $_POST['paged']. See #14 } if (!empty($args['s'])) { $args['s'] = urlencode($args['s']); // Searched string needs to be encoded as it comes from $_POST } PLL_Settings::redirect($args); }
public function languages_page() { // prepare the list of tabs $tabs = array('lang' => __('Languages', 'polylang')); // only if at least one language has been created if ($listlanguages = $this->model->get_languages_list()) { $tabs['strings'] = __('Strings translation', 'polylang'); $tabs['settings'] = __('Settings', 'polylang'); } $tabs = apply_filters('pll_settings_tabs', $tabs); switch ($this->active_tab) { case 'lang': // prepare the list table of languages $list_table = new PLL_Table_Languages(); $list_table->prepare_items($listlanguages); break; case 'strings': // get the strings to translate $data = PLL_Admin_Strings::get_strings(); // get the groups foreach ($data as $key => $row) { $groups[] = $row['context']; } $groups = array_unique($groups); $selected = empty($_REQUEST['group']) || !in_array($_REQUEST['group'], $groups) ? -1 : $_REQUEST['group']; $s = empty($_REQUEST['s']) ? '' : wp_unslash($_REQUEST['s']); // filter for search string foreach ($data as $key => $row) { if ($selected != -1 && $row['context'] != $selected || !empty($s) && stripos($row['name'], $s) === false && stripos($row['string'], $s) === false) { unset($data[$key]); } } // load translations foreach ($listlanguages as $language) { // filters by language if requested if (($lg = get_user_meta(get_current_user_id(), 'pll_filter_content', true)) && $language->slug != $lg) { continue; } $mo = new PLL_MO(); // print_r($language); $mo->import_from_db($language); foreach ($data as $key => $row) { $data[$key]['translations'][$language->slug] = $mo->translate($row['string']); $data[$key]['row'] = $key; // store the row number for convenience } } // get an array with language slugs as keys, names as values $languages = array_combine(wp_list_pluck($listlanguages, 'slug'), wp_list_pluck($listlanguages, 'name')); $string_table = new PLL_Table_String(compact('languages', 'groups', 'selected')); $string_table->prepare_items($data); break; case 'settings': $post_types = get_post_types(array('public' => true, '_builtin' => false)); $post_types = array_diff($post_types, get_post_types(array('_pll' => true))); $post_types = array_unique(apply_filters('pll_get_post_types', $post_types, true)); $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false)); $taxonomies = array_diff($taxonomies, get_taxonomies(array('_pll' => true))); $taxonomies = array_unique(apply_filters('pll_get_taxonomies', $taxonomies, true)); break; default: break; } $action = isset($_REQUEST['pll_action']) ? $_REQUEST['pll_action'] : ''; switch ($action) { case 'add': check_admin_referer('add-lang', '_wpnonce_add-lang'); if ($this->model->add_language($_POST)) { // backward compatibility WP < 4.0 if (version_compare($GLOBALS['wp_version'], '4.0', '<')) { PLL_Admin::download_mo($_POST['locale']); } elseif ('en_US' != $_POST['locale']) { // attempts to install the language pack require_once ABSPATH . 'wp-admin/includes/translation-install.php'; if (!wp_download_language_pack($_POST['locale'])) { add_settings_error('general', 'pll_download_mo', __('The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang')); } // force checking for themes and plugins translations updates wp_update_themes(); wp_update_plugins(); } } $this->redirect(); // to refresh the page (possible thanks to the $_GET['noheader']=true) break; case 'delete': check_admin_referer('delete-lang'); if (!empty($_GET['lang'])) { $this->model->delete_language((int) $_GET['lang']); } $this->redirect(); // to refresh the page (possible thanks to the $_GET['noheader']=true) break; case 'edit': if (!empty($_GET['lang'])) { $edit_lang = $this->model->get_language((int) $_GET['lang']); } break; case 'update': check_admin_referer('add-lang', '_wpnonce_add-lang'); $error = $this->model->update_language($_POST); $this->redirect(); // to refresh the page (possible thanks to the $_GET['noheader']=true) break; case 'string-translation': if (!empty($_REQUEST['submit'])) { check_admin_referer('string-translation', '_wpnonce_string-translation'); $strings = PLL_Admin_Strings::get_strings(); foreach ($this->model->get_languages_list() as $language) { if (empty($_POST['translation'][$language->slug])) { // in case the language filter is active (thanks to John P. Bloch) continue; } $mo = new PLL_MO(); $mo->import_from_db($language); foreach ($_POST['translation'][$language->slug] as $key => $translation) { $translation = apply_filters('pll_sanitize_string_translation', $translation, $strings[$key]['name'], $strings[$key]['context']); $mo->add_entry($mo->make_entry($strings[$key]['string'], $translation)); } // clean database (removes all strings which were registered some day but are no more) if (!empty($_POST['clean'])) { $new_mo = new PLL_MO(); foreach ($strings as $string) { $new_mo->add_entry($mo->make_entry($string['string'], $mo->translate($string['string']))); } } isset($new_mo) ? $new_mo->export_to_db($language) : $mo->export_to_db($language); } add_settings_error('general', 'pll_strings_translations_updated', __('Translations updated.', 'polylang'), 'updated'); } do_action('pll_save_strings_translations'); // unregisters strings registered through WPML API if ($string_table->current_action() == 'delete' && !empty($_REQUEST['strings']) && function_exists('icl_unregister_string')) { check_admin_referer('string-translation', '_wpnonce_string-translation'); $strings = PLL_Admin_Strings::get_strings(); foreach ($_REQUEST['strings'] as $key) { icl_unregister_string($strings[$key]['context'], $strings[$key]['name']); } } // to refresh the page (possible thanks to the $_GET['noheader']=true) $this->redirect(array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group')))); break; case 'options': check_admin_referer('options-lang', '_wpnonce_options-lang'); $this->options['default_lang'] = sanitize_title($_POST['default_lang']); // we have slug as value foreach (array('force_lang', 'rewrite') as $key) { $this->options[$key] = isset($_POST[$key]) ? (int) $_POST[$key] : 0; } if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) { foreach ($_POST['domains'] as $key => $domain) { $this->options['domains'][$key] = esc_url_raw(trim($domain)); } } foreach (array('browser', 'hide_default', 'redirect_lang', 'media_support') as $key) { $this->options[$key] = isset($_POST[$key]) ? 1 : 0; } if (3 == $this->options['force_lang']) { $this->options['browser'] = $this->options['hide_default'] = 0; } foreach (array('sync', 'post_types', 'taxonomies') as $key) { $this->options[$key] = empty($_POST[$key]) ? array() : array_keys($_POST[$key], 1); } update_option('polylang', $this->options); // refresh rewrite rules in case rewrite, hide_default, post types or taxonomies options have been modified // it seems useless to refresh permastruct here flush_rewrite_rules(); // refresh language cache in case home urls have been modified $this->model->clean_languages_cache(); // fills existing posts & terms with default language if (isset($_POST['fill_languages']) && ($nolang = $this->model->get_objects_with_no_lang())) { if (!empty($nolang['posts'])) { $this->model->set_language_in_mass('post', $nolang['posts'], $this->options['default_lang']); } if (!empty($nolang['terms'])) { $this->model->set_language_in_mass('term', $nolang['terms'], $this->options['default_lang']); } } add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); $this->redirect(); break; default: break; } // displays the page include PLL_ADMIN_INC . '/view-languages.php'; }
function profile_builder_wpml_unregister_string($context, $name) { if (function_exists('icl_unregister_string')) { icl_unregister_string($context, $name, $value); } }
function icl_register_admin_options($array, $key = "") { foreach ($array as $k => $v) { if (is_array($v)) { icl_register_admin_options($v, $key . '[' . $k . ']'); } else { if ($v === '') { icl_unregister_string('admin_texts_theme_' . get_option('template'), $key . $k); } else { icl_register_string('admin_texts_theme_' . get_option('template'), $key . $k, $v); $int = preg_match_all('#\\[([^\\]]+)\\]#', $key, $matches); $vals = array(); if (count($matches[1]) > 0) { $vals[] = $k; for ($i = count($matches[1]) - 1; $i >= 0; $i--) { $tmp = $vals; unset($vals); $vals[$matches[1][$i]] = $tmp; } } else { $vals[0] = $k; } $_icl_admin_option_names = get_option('_icl_admin_option_names'); $_icl_admin_option_names['theme'][get_option('template')] = array_merge_recursive((array) $_icl_admin_option_names['theme'][get_option('template')], $vals); $_icl_admin_option_names['theme'][get_option('template')] = __array_unique_recursive($_icl_admin_option_names['theme'][get_option('template')]); update_option('_icl_admin_option_names', $_icl_admin_option_names); } } } }
function cimy_wpml_unregister_string($name) { global $cimy_uef_name; if (function_exists('icl_unregister_string')) { icl_unregister_string($cimy_uef_name, $name); } }
/** * Helper function to unregister a WPML string * * @access public * @since 2.1 */ function ot_wpml_unregister_string($id) { if (function_exists('icl_unregister_string')) { icl_unregister_string('Theme Options', $id); } }
/** * Unregisters a string for translation * * @param string $context * @param string $name */ public function unregisterString($context, $name) { if (function_exists('icl_unregister_string')) { icl_unregister_string($context, $name); } }
protected function cleanup_form_strings($form) { if (isset($form['id'])) { global $wpdb; $form_id = $form['id']; $current_strings = $this->get_form_strings($form_id); $this->register_strings($form); $st_context = $this->get_st_context($form_id); $database_strings = (bool) $current_strings !== false ? $wpdb->get_col($wpdb->prepare("SELECT s.name\n FROM {$wpdb->prefix}icl_strings s\n WHERE s.context = %s", $st_context)) : array(); foreach ($database_strings as $key => $string_name) { if (isset($current_strings[substr($key, strlen($form_id) + 1)])) { icl_unregister_string($st_context, $string_name); } } } }
$string->value = $fields[$fid[0]]->field_options[$fid[1]]; $new_val = true; } } if ($new_val && $string->value != '' && !is_array($string->value)) { $str_name = function_exists('mb_substr') ? mb_substr($string->name, 0, 160) : substr($string->name, 0, 160); icl_register_string('formidable', $str_name, $string->value); } } unset($fid); } if (is_array($string->value)) { continue; } if ($string->value == '' || $string->value == '*') { icl_unregister_string('formidable', $string->name); continue; } ?> <tr class="<?php echo $alternate; ?> "> <td><?php echo htmlspecialchars(stripslashes($string->value)); ?> </td> <?php foreach ($translations as $trans) { if ($trans->string_id != $string->id) { continue;