本文整理汇总了PHP中ICL_AdminNotifier::addMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP ICL_AdminNotifier::addMessage方法的具体用法?PHP ICL_AdminNotifier::addMessage怎么用?PHP ICL_AdminNotifier::addMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICL_AdminNotifier
的用法示例。
在下文中一共展示了ICL_AdminNotifier::addMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_terms_with_suffix_admin_notice
/**
* Displays the admin notice informing about terms in the old format, using the language suffix.
* The notice is displayed until it is either dismissed or the update button is pressed.
*/
public static function display_terms_with_suffix_admin_notice()
{
global $sitepress;
if (!$sitepress->get_setting('taxonomy_names_checked')) {
$suffix_count = count(WPML_Terms_Translations::get_all_terms_with_language_suffix());
if ($suffix_count > 0) {
$message = '<p>';
$message .= sprintf(__("This version of WPML allows the use of taxonomy terms with the same name across multiple languages. Your site currently has %d taxonomy terms that require an update, so they will not be displayed with language suffixes.", "sitepress"), $suffix_count);
$message .= '</p>';
if (defined('ICL_PLUGIN_URL')) {
$message .= '<p><a href="' . admin_url('admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/troubleshooting.php#termsuffixupdate') . '"><button class="button-primary">Open terms update page</button></a>';
}
ICL_AdminNotifier::addMessage("termssuffixnotice", $message, 'error', true, false, false, 'terms-suffix', true);
}
$sitepress->set_setting('taxonomy_names_checked', true, true);
}
//TODO: [WPML 3.3] the ICL_AdminNotifier class got improved and we should not call \ICL_AdminNotifier::displayMessages to display an admin notice
ICL_AdminNotifier::displayMessages('terms-suffix');
}
示例2: cpt_default_and_st_language_warning
function cpt_default_and_st_language_warning()
{
static $called = false;
if (!$called) {
global $sitepress, $sitepress_settings;
$st_language_code = $sitepress_settings['st']['strings_language'];
$st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
$st_page_url = admin_url('admin.php?page=wpml-string-translation/menu/string-translation.php');
$message = 'The strings language in your site is set to %s instead of English. ';
$message .= 'This means that the original slug will appear in the URL when displaying content in %s.';
$message .= ' ';
$message .= '<strong><a href="%s" target="_blank">Read more</a> | ';
$message .= '<a href="%s#icl_st_sw_form">Change strings language</a></strong>';
$message = __($message, 'wpml-string-translation');
$message = sprintf($message, $st_language, $st_language, 'http://wpml.org/faq/string-translation-default-language-not-english/', $st_page_url);
$fallback_message = _('<a href="%s" target="_blank">How to translate strings when default language is not English</a>');
$fallback_message = sprintf($fallback_message, 'http://wpml.org/faq/string-translation-default-language-not-english/');
ICL_AdminNotifier::addMessage('cpt_default_and_st_language_warning', $message, 'icl-admin-message-warning', true, $fallback_message, false, 'cpt-translation');
$called = true;
}
}
示例3: check_settings_integrity
//.........这里部分代码省略.........
}
global $wpdb;
static $result;
if (isset($result)) {
return $result;
}
$current_settings = get_option('icl_sitepress_settings');
if (!$current_settings) {
return true;
}
$setup_wizard_step = false;
if (isset($current_settings['setup_wizard_step'])) {
$setup_wizard_step = $current_settings['setup_wizard_step'];
}
$setup_complete = false;
$setup_complete_missing = true;
if (isset($current_settings['setup_complete'])) {
$setup_complete = $current_settings['setup_complete'];
$setup_complete_missing = false;
}
//Skip checks during first setup wizard
if ($setup_wizard_step !== false && $setup_wizard_step < 4 || !$setup_complete_missing && $setup_complete === false && $setup_wizard_step == 4) {
return true;
}
$default_language = false;
$default_language_missing = true;
if (isset($current_settings['default_language'])) {
$default_language = $current_settings['default_language'];
$default_language_missing = false;
}
$active_languages_sql = "SELECT * FROM " . $wpdb->prefix . 'icl_languages WHERE active=%d';
$active_languages_prepared = $wpdb->prepare($active_languages_sql, array(1));
$active_languages = $wpdb->get_results($active_languages_prepared);
$existing_translations_sql = "SELECT count(*) FROM " . $wpdb->prefix . 'icl_translations';
$existing_translations = $wpdb->get_var($existing_translations_sql);
$show_notice = false;
$message = '';
if ((!$setup_complete || !$default_language) && $existing_translations) {
$message .= '<p>';
$message .= __('Your WPML settings seem to be corrupted. To avoid corrupting your existing data, we have hidden WPML from this site.', 'sitepress');
$message .= '</p>';
$message .= '<p>';
$message .= __('If this is the first time you install WPML on this site, you may have faced a database or script connection drop, that caused settings to be not completely store.', 'sitepress');
$message .= __('In this case, you can click on the <strong>Reset Settings</strong> button: this will reset WPML settings and any language translation information, allowing you to restart the wizard.', 'sitepress');
$message .= '</p>';
$message .= '<p>';
$message .= sprintf(__('If you have just upgraded WPML or after starting over you keep getting this message, please contact the <a href="%s">support forum</a> as soon as possible, in order to provide you with a fix to this issue.', 'sitepress'), 'https://wpml.org/forums/');
$message .= '</p>';
$message .= '<p>';
$confirm_message = _x('Are you sure you want to reset WPML Settings?', 'Reset WPML settings', 'sitepress');
$confirm_message .= ' ';
$confirm_message .= _x('This will also empty translation information (if any).', 'Reset WPML settings', 'sitepress');
$message .= '<a href="?icl_reset_settings=1&debug_action=reset_wpml_settings&nonce=' . wp_create_nonce('reset_wpml_settings') . '" class="button" onclick="return window.confirm(\'' . $confirm_message . '\');" >' . __('Reset Settings', 'sitepress') . '</a>';
$message .= ' ';
$message .= ' ';
$message .= ' ';
$message .= '<a href="https://wpml.org/forums/" class="button">' . __('Contact Support', 'sitepress') . '</a>';
$message .= '</p>';
$message .= '<p>';
$message .= __('Additional details for the support team (there is no need to copy it, as the support team will be able to see it once logged in):', 'sitepress');
$message .= '</p>';
$message .= '<p><textarea rows="10" style="width:100%;display:block;" onclick="this.focus();this.select();" readonly="readonly">';
$message .= str_repeat('=', 50);
$wpml_plugins_list = SitePress::get_installed_plugins();
foreach ($wpml_plugins_list as $name => $plugin_data) {
$plugin_name = $name;
$file = $plugin_data['file'];
$message .= PHP_EOL . $plugin_name;
$message .= ' ' . (isset($plugin_data['plugin']['Version']) ? $plugin_data['plugin']['Version'] : __('Version n/a', 'sitepress'));
$message .= ' => ';
if (empty($plugin_data['plugin'])) {
$message .= 'Not installed';
} else {
$message .= 'Installed';
}
$message .= '/';
$message .= isset($file) && is_plugin_active($file) ? 'Active' : 'Not Active';
}
$message .= PHP_EOL . str_repeat('-', 50);
$message .= PHP_EOL . 'icl_translations count: ' . ($existing_translations ? $existing_translations : '0');
$message .= PHP_EOL . 'setup_complete: ' . ($setup_complete ? 'true' : 'false');
$message .= PHP_EOL . 'setup_complete missing: ' . ($setup_complete_missing ? 'true' : 'false');
$message .= PHP_EOL . 'default_language: ' . ($default_language ? $default_language : '""');
$message .= PHP_EOL . 'default_language_missing: ' . ($default_language_missing ? 'true' : 'false');
$message .= PHP_EOL . PHP_EOL . 'active_languages: ' . PHP_EOL . print_r($active_languages, true);
$message .= PHP_EOL . PHP_EOL . 'icl_sitepress_settings (serialized): ' . PHP_EOL . serialize($current_settings);
$message .= PHP_EOL . PHP_EOL . 'icl_sitepress_settings (unserialized): ' . PHP_EOL . print_r($current_settings, true);
$message .= PHP_EOL . str_repeat('=', 50);
$message .= '</textarea></p>';
$show_notice = true;
}
// ICL_AdminNotifier::removeMessage( 'check_settings_integrity' );
ICL_AdminNotifier::removeMessage('check_settings_integrity_corrupted');
if ($show_notice) {
ICL_AdminNotifier::addMessage('check_settings_integrity_corrupted', $message, 'error', false, false, false, 'check_settings_integrity', true);
ICL_AdminNotifier::displayMessages('check_settings_integrity');
}
$result = !$show_notice;
return $result;
}
示例4: wp_types_st_language_warning
/**
* Handle notification messages for WPML String Translation when default language and ST language is != 'en'
*/
function wp_types_st_language_warning()
{
global $sitepress, $sitepress_settings;
if (class_exists('ICL_AdminNotifier') && defined('ICL_SITEPRESS_VERSION')) {
ICL_AdminNotifier::removeMessage('wp_types_default_language_warning');
static $called = false;
if (!$called && isset($sitepress_settings['st'])) {
$st_language_code = $sitepress_settings['st']['strings_language'];
$st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
$st_page_url = admin_url('admin.php?page=' . WPML_ST_FOLDER . '/menu/string-translation.php');
$message = 'The strings language in your site is set to %s instead of English. ';
$message .= 'This means that all English texts that are hard-coded in PHP will appear when displaying content in %s.';
$message .= ' ';
$message .= '<strong><a href="%s" target="_blank">Read more</a> | ';
$message .= '<a href="%s#icl_st_sw_form">Change strings language</a></strong>';
$message = __($message, 'wpml-string-translation');
$message = sprintf($message, $st_language, $st_language, 'http://wpml.org/faq/string-translation-default-language-not-english/', $st_page_url);
$fallback_message = _('<a href="%s" target="_blank">How to translate strings when default language is not English</a>');
$fallback_message = sprintf($fallback_message, 'http://wpml.org/faq/string-translation-default-language-not-english/');
ICL_AdminNotifier::addMessage('wp_types_st_language_warning', $message, 'icl-admin-message icl-admin-message-warning', true, $fallback_message, false, 'wp-types');
$called = true;
}
}
}
示例5: administration_menu
function administration_menu()
{
ICL_AdminNotifier::removeMessage('setup-incomplete');
$main_page = apply_filters('icl_menu_main_page', basename(ICL_PLUGIN_PATH) . '/menu/languages.php');
$wpml_setup_is_complete = SitePress_Setup::setup_complete();
if ($wpml_setup_is_complete) {
add_menu_page(__('WPML', 'sitepress'), __('WPML', 'sitepress'), 'wpml_manage_languages', $main_page, null, ICL_PLUGIN_URL . '/res/img/icon16.png');
add_submenu_page($main_page, __('Languages', 'sitepress'), __('Languages', 'sitepress'), 'wpml_manage_languages', basename(ICL_PLUGIN_PATH) . '/menu/languages.php');
//By Gen, moved Translation management after language, because problems with permissions
do_action('icl_wpml_top_menu_added');
$wpml_setup_is_complete = $this->get_setting('existing_content_language_verified') && 2 <= count($this->get_active_languages());
if ($wpml_setup_is_complete) {
add_submenu_page($main_page, __('Theme and plugins localization', 'sitepress'), __('Theme and plugins localization', 'sitepress'), 'wpml_manage_theme_and_plugin_localization', basename(ICL_PLUGIN_PATH) . '/menu/theme-localization.php');
if (!defined('WPML_TM_VERSION')) {
add_submenu_page($main_page, __('Translation options', 'sitepress'), __('Translation options', 'sitepress'), 'wpml_manage_translation_options', basename(ICL_PLUGIN_PATH) . '/menu/translation-options.php');
}
}
$wpml_admin_menus_args = array('existing_content_language_verified' => $this->get_setting('existing_content_language_verified'), 'active_languages_count' => count($this->get_active_languages()), 'wpml_setup_is_ok' => $wpml_setup_is_complete);
do_action('wpml_admin_menus', $wpml_admin_menus_args);
} else {
$main_page = basename(ICL_PLUGIN_PATH) . '/menu/languages.php';
add_menu_page(__('WPML', 'sitepress'), __('WPML', 'sitepress'), 'manage_options', $main_page, null, ICL_PLUGIN_URL . '/res/img/icon16.png');
add_submenu_page($main_page, __('Languages', 'sitepress'), __('Languages', 'sitepress'), 'wpml_manage_languages', $main_page);
if (!$this->is_troubleshooting_page() && !SitePress_Setup::languages_table_is_complete()) {
$troubleshooting_url = admin_url('admin.php?page=' . ICL_PLUGIN_FOLDER . '/menu/troubleshooting.php');
$troubleshooting_link = '<a href="' . $troubleshooting_url . '" title="' . esc_attr(__('Troubleshooting', 'sitepress')) . '">' . __('Troubleshooting', 'sitepress') . '</a>';
$message = '';
$message .= __('WPML is missing some records in the languages tables and it cannot fully work until this issue is fixed.', 'sitepress');
$message .= '<br />';
$message .= sprintf(__('Please go to the %s page and click on %s to fix this problem.', 'sitepress'), $troubleshooting_link, __('Fix languages tables', 'sitepress'));
$message .= '<br />';
$message .= '<br />';
$message .= __('This warning will disappear once this issue is fixed.', 'sitepress');
ICL_AdminNotifier::removeMessage('setup-incomplete');
ICL_AdminNotifier::addMessage('setup-incomplete', $message, 'error', false, false, false, 'setup', true);
ICL_AdminNotifier::displayMessages('setup');
}
}
add_submenu_page($main_page, __('Support', 'sitepress'), __('Support', 'sitepress'), 'wpml_manage_support', ICL_PLUGIN_FOLDER . '/menu/support.php');
$this->troubleshooting_menu(ICL_PLUGIN_FOLDER . '/menu/support.php');
$this->debug_information_menu(ICL_PLUGIN_FOLDER . '/menu/support.php');
}
示例6: _st_default_and_st_language_warning
static function _st_default_and_st_language_warning()
{
global $sitepress;
$string_settings = apply_filters('wpml_get_setting', false, 'st');
if (isset($string_settings['strings_language'])) {
ICL_AdminNotifier::removeMessage('_st_default_language_warning');
static $called = false;
if (defined('WPML_ST_FOLDER') && !$called) {
$st_language_code = $string_settings['strings_language'];
$st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
$page = WPML_ST_FOLDER . '/menu/string-translation.php';
$st_page_url = admin_url('admin.php?page=' . $page);
$message = __('The strings language in your site is set to %s instead of English.
This means that all English texts that are hard-coded in PHP will appear when displaying content in %s.
<strong><a href="%s" target="_blank">Read more</a> | <a href="%s#icl_st_sw_form">Change strings language</a></strong>', 'wpml-string-translation');
$message = sprintf($message, $st_language, $st_language, 'https://wpml.org/faq/string-translation-default-language-not-english/', $st_page_url);
$fallback_message = __('<a href="%s" target="_blank">How to translate strings when default language is not English</a>', 'wpml-string-translation');
$fallback_message = sprintf($fallback_message, 'https://wpml.org/faq/string-translation-default-language-not-english/');
ICL_AdminNotifier::addMessage('_st_default_and_st_language_warning', $message, 'icl-admin-message-warning', true, $fallback_message, false, 'string-translation');
$called = true;
}
}
}