本文整理汇总了PHP中add_settings_error函数的典型用法代码示例。如果您正苦于以下问题:PHP add_settings_error函数的具体用法?PHP add_settings_error怎么用?PHP add_settings_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_settings_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_show_upgrade_notices
/**
* Display Upgrade Notices
*
* @since 1.3.1
* @return void
*/
function edd_show_upgrade_notices()
{
if (isset($_GET['page']) && $_GET['page'] == 'edd-upgrades') {
return;
}
// Don't show notices on the upgrades page
$edd_version = get_option('edd_version');
if (!$edd_version) {
// 1.3 is the first version to use this option so we must add it
$edd_version = '1.3';
}
if (!get_option('edd_payment_totals_upgraded') && !get_option('edd_version')) {
if (wp_count_posts('edd_payment')->publish < 1) {
return;
}
// No payment exist yet
// The payment history needs updated for version 1.2
$url = add_query_arg('edd-action', 'upgrade_payments');
$upgrade_notice = sprintf(__('The Payment History needs to be updated. %s', 'edd'), '<a href="' . wp_nonce_url($url, 'edd_upgrade_payments_nonce') . '">' . __('Click to Upgrade', 'edd') . '</a>');
add_settings_error('edd-notices', 'edd-payments-upgrade', $upgrade_notice, 'error');
}
if (version_compare($edd_version, '1.3.2', '<') && !get_option('edd_logs_upgraded')) {
printf('<div class="updated"><p>' . esc_html__('The Purchase and File Download History in Easy Digital Downloads needs to be upgraded, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
}
if (version_compare($edd_version, '1.3.4', '<') || version_compare($edd_version, '1.4', '<')) {
printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the plugin pages, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
}
if (version_compare($edd_version, '1.5', '<')) {
printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
}
}
示例2: edd_csr_admin_messages
/**
* Admin Messages
*
* @since 1.0
* @return void
*/
function edd_csr_admin_messages()
{
if (isset($_GET['edd-message']) && 'redirect_added' == $_GET['edd-message'] && current_user_can('manage_shop_settings')) {
add_settings_error('edd-csr-notices', 'edd-redirect-added', __('Redirect added.', 'edd-csr'), 'updated');
}
if (isset($_GET['edd-message']) && 'redirect_add_failed' == $_GET['edd-message'] && current_user_can('manage_shop_settings')) {
add_settings_error('edd-csr-notices', 'edd-redirect-add-fail', __('There was a problem adding your redirect, please try again.', 'edd-csr'), 'error');
}
if (isset($_GET['edd-message']) && 'redirect_updated' == $_GET['edd-message'] && current_user_can('manage_shop_settings')) {
add_settings_error('edd-csr-notices', 'edd-redirect-updated', __('Redirect updated.', 'edd-csr'), 'updated');
}
if (isset($_GET['edd-message']) && 'redirect_update_failed' == $_GET['edd-message'] && current_user_can('manage_shop_settings')) {
add_settings_error('edd-csr-notices', 'edd-redirect-updated-fail', __('There was a problem updating your redirect, please try again.', 'edd-csr'), 'error');
}
if (isset($_GET['edd-action']) && 'deactivate_redirect' == $_GET['edd-action'] && current_user_can('manage_shop_settings')) {
add_settings_error('edd-csr-notices', 'edd-redirect-deactivated', __('Redirect Deactivated', 'edd-csr'), 'updated');
}
if (isset($_GET['edd-action']) && 'activate_redirect' == $_GET['edd-action'] && current_user_can('manage_shop_settings')) {
add_settings_error('edd-csr-notices', 'edd-redirect-activated', __('Redirect Activated', 'edd-csr'), 'updated');
}
if (isset($_GET['edd-action']) && 'delete_redirect' == $_GET['edd-action'] && current_user_can('manage_shop_settings')) {
add_settings_error('edd-csr-notices', 'edd-redirect-deleted', __('Redirect Deleted', 'edd-csr'), 'updated');
}
settings_errors('edd-csr-notices');
}
示例3: reset
private function reset()
{
foreach ($this->settings as $setting => $section) {
$_POST[$setting] = array_merge($_POST[$setting], $this->get_defaults($setting));
}
add_settings_error($this->page, 'settings_reset', __('Default settings have been reset.', WP_ULIKE_SLUG), 'updated');
}
示例4: post_restore
public function post_restore()
{
if (isset($_POST['job_id']) && isset($_POST['backup_uniqid']) && isset($_POST['_wpnonce']) && isset($_POST['method'])) {
$nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
if (!wp_verify_nonce($nonce, 'my-wp-backup-restore-backup')) {
wp_die(esc_html__('Nope! Security check failed!', 'my-wp-backup'));
}
$id = absint($_POST['job_id']);
$uniqid = sanitize_key($_POST['backup_uniqid']);
$method = filter_input(INPUT_POST, 'method', FILTER_SANITIZE_STRING);
$backup = self::get($id, $uniqid);
if (!isset($backup['duration'])) {
add_settings_error('', '', __('Invalid backup id/uniqid.', 'my-wp-backup'));
set_transient('settings_errors', get_settings_errors());
wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
}
if (!$backup->has_archives()) {
// No local copy and no remote copy === DEAD END.
if (empty($backup['destinations'])) {
add_settings_error('', '', __('Backup files missing.', 'my-wp-backup'));
set_transient('settings_errors', get_settings_errors());
wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
}
if (!isset($backup['destinations'][$method])) {
add_settings_error('', '', sprintf(__('No backup files from %s.', 'my-wp-backup'), Job::$destinations[$method]));
set_transient('settings_errors', get_settings_errors());
wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
}
}
wp_schedule_single_event(time(), 'wp_backup_restore_backup', array(array($id, $uniqid, $method)));
wp_safe_redirect($this->admin->get_page_url('backup', array('uniqid' => $uniqid, 'action' => 'viewprogress', 'id' => $id)));
}
}
示例5: vimeography_validate_advanced_settings
public function vimeography_validate_advanced_settings($input)
{
$output['client_id'] = wp_filter_nohtml_kses($input['client_id']);
$output['client_secret'] = wp_filter_nohtml_kses($input['client_secret']);
$output['access_token'] = wp_filter_nohtml_kses($input['access_token']);
$output['access_token_secret'] = wp_filter_nohtml_kses($input['access_token_secret']);
if ($output['client_id'] == '' || $output['client_secret'] == '' || $output['access_token'] == '' || $output['access_token_secret'] == '') {
add_settings_error('vimeography_advanced_settings', 'required', __('Whoops! Make sure you fill out all of the Vimeo tokens!'));
return FALSE;
}
require_once VIMEOGRAPHY_PATH . 'lib/vimeo-advanced-api-library.php';
if (class_exists('phpVimeo')) {
$vimeo = new phpVimeo($output['client_id'], $output['client_secret'], $output['access_token'], $output['access_token_secret']);
}
// Do an authenticated call
try {
$data = $vimeo->call('vimeo.oauth.checkAccessToken');
if (!$data) {
add_settings_error('vimeography_advanced_settings', 'invalid', __('Woah! Looks like the Vimeo API is having some issues right now. Try this again in a little bit.'));
return FALSE;
}
$string = __('Success! Your Vimeo tokens for ') . $data->oauth->user->username . __(' have been added and saved.');
// not actually an error, function name is misleading
add_settings_error('vimeography_advanced_settings', 'valid', $string, 'updated');
$output['active'] = TRUE;
return $output;
} catch (VimeoAPIException $e) {
//add_settings_error( 'vimeography_advanced_settings', $e->getCode(), "Encountered an API error -- ".$e->getMessage());
add_settings_error('vimeography_advanced_settings', $e->getCode(), "Uh oh! Your Vimeo tokens didn't validate. Try again, and double check that all of your tokens are in the correct fields!");
return FALSE;
}
}
示例6: wf_theme_import_demo_xml
function wf_theme_import_demo_xml()
{
$error = false;
if (!defined('WP_LOAD_IMPORTERS')) {
define('WP_LOAD_IMPORTERS', true);
}
require_once ABSPATH . 'wp-admin/includes/import.php';
if (!class_exists('WP_Import')) {
$class_wp_import = get_template_directory() . '/admin/wordpress-importer/wordpress-importer.php';
if (file_exists($class_wp_import)) {
require_once $class_wp_import;
} else {
$error = true;
}
}
if ($error) {
add_settings_error('wf-theme-import-demo', 'wf-theme-import-demo', __('Demo data import failed! Try importing manually trough Tools - Import.', WF_THEME_TEXTDOMAIN), 'error');
return false;
} else {
if (!is_file(get_template_directory() . '/admin/demo-data.xml')) {
add_settings_error('wf-theme-import-demo', 'wf-theme-import-demo', __('Demo data XML file is missing.', WF_THEME_TEXTDOMAIN), 'error');
return false;
} else {
ob_start();
$wp_import = new wp_import();
$wp_import->fetch_attachments = true;
$wp_import->import(get_template_directory() . '/admin/demo-data.xml');
ob_end_clean();
}
}
return true;
}
示例7: sanitize_database_settings
function sanitize_database_settings($input)
{
// URL database limit option
if (isset($input[HA_Common::URL_DB_LIMIT_OPTION])) {
if (is_numeric($input[HA_Common::URL_DB_LIMIT_OPTION])) {
$url_db_limit = intval($input[HA_Common::URL_DB_LIMIT_OPTION]);
if ($url_db_limit <= 0) {
add_settings_error(HA_Common::DATABASE_SETTINGS_KEY, 'url_db_limit_range_error', 'URL database limit must be numeric greater than 0 or empty.', 'error');
}
} else {
if (strlen(trim($input[HA_Common::URL_DB_LIMIT_OPTION])) != 0) {
add_settings_error(HA_Common::DATABASE_SETTINGS_KEY, 'url_db_limit_trim_error', 'URL database limit must be numeric greater than 0 or empty.', 'error');
}
}
}
// check if clear database flag is set
if (isset($_POST['clear-database-flag']) && $_POST['clear-database-flag'] === "true") {
global $ha_admin_controller;
$response = $ha_admin_controller->get_data_services()->custom_query('clear_database', array());
if ($response['status'] == 'error') {
add_settings_error(HA_Common::DATABASE_SETTINGS_KEY, 'clear-database-success', $response['message'], 'error');
} else {
add_settings_error(HA_Common::DATABASE_SETTINGS_KEY, 'clear-database-success', $response['message'], 'updated');
}
}
return $input;
}
示例8: wpuxss_eml_mimes_validate
function wpuxss_eml_mimes_validate($input)
{
if (!$input) {
$input = array();
}
if (isset($_POST['eml-restore-mime-types-settings'])) {
$wpuxss_eml_mimes_backup = get_option('wpuxss_eml_mimes_backup');
$input = $wpuxss_eml_mimes_backup;
add_settings_error('wpuxss_eml_mimes', 'eml_mime_types_restored', __('MIME type settings restored.', 'eml'), 'updated');
} elseif (!isset($_POST['eml-settings-import']) && !isset($_POST['eml-settings-restore'])) {
add_settings_error('wpuxss_eml_mimes', 'eml_mime_types_saved', __('MIME type settings saved.', 'eml'), 'updated');
}
foreach ($input as $type => $mime) {
$sanitized_type = wpuxss_eml_sanitize_extension($type);
if ($sanitized_type !== $type) {
$input[$sanitized_type] = $input[$type];
unset($input[$type]);
$type = $sanitized_type;
}
$input[$type]['filter'] = isset($mime['filter']) && !!$mime['filter'] ? 1 : 0;
$input[$type]['upload'] = isset($mime['upload']) && !!$mime['upload'] ? 1 : 0;
$input[$type]['mime'] = sanitize_mime_type($mime['mime']);
$input[$type]['singular'] = sanitize_text_field($mime['singular']);
$input[$type]['plural'] = sanitize_text_field($mime['plural']);
}
return $input;
}
示例9: dpovi_options_page
function dpovi_options_page()
{
if (isset($_GET['settings-updated'])) {
add_settings_error('results', 'results', '<p>Found a lot of video IDs. Copy them below.</p>', 'updated');
}
?>
<div>
<h2>Denver Post Video ID discoverer</h2>
<?php
settings_errors();
?>
<form action="options.php" method="POST">
<?php
settings_fields('dpovi_options');
?>
<?php
do_settings_sections('dpovi');
?>
<input name="Submit" type="submit" value="<?php
esc_attr_e('Discover Video IDs');
?>
" />
</form></div>
<?php
}
示例10: dc_dc_woodle_general_settings_sanitize
/**
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
*/
public function dc_dc_woodle_general_settings_sanitize($input)
{
global $DC_Woodle;
$new_input = array();
$hasError = false;
if (isset($input['access_url'])) {
$new_input['access_url'] = rtrim($input['access_url'], '/');
} else {
add_settings_error("dc_{$this->tab}_settings_name", esc_attr("dc_{$this->tab}_settings_admin_error"), __('Moodle access URL should not be empty.', $DC_Woodle->text_domain), 'error');
$hasError = true;
}
if (isset($input['ws_token'])) {
$new_input['ws_token'] = sanitize_text_field($input['ws_token']);
} else {
add_settings_error("dc_{$this->tab}_settings_name", esc_attr("dc_{$this->tab}_settings_admin_error"), __('Moodle webservice token should not be empty.', $DC_Woodle->text_domain), 'error');
$hasError = true;
}
if (isset($input['create_wc_product'])) {
$new_input['create_wc_product'] = $input['create_wc_product'];
}
if (isset($input['update_user_info'])) {
$new_input['update_user_info'] = $input['update_user_info'];
}
if (isset($input['moodle_role_id'])) {
$new_input['moodle_role_id'] = !empty($input['moodle_role_id']) ? intval($input['moodle_role_id']) : '';
}
if (!$hasError) {
add_settings_error("dc_{$this->tab}_settings_name", esc_attr("dc_{$this->tab}_settings_admin_updated"), __('General settings updated', $DC_Woodle->text_domain), 'updated');
}
return $new_input;
}
示例11: show_error
/**
* Show an error message to administrators
*
* @param string $message
*/
private function show_error( $message ) {
if( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
return false;
}
add_settings_error( 'mc4wp-api', 'mc4wp-api-error', $message, 'error' );
}
示例12: lockr_options_validate
function lockr_options_validate($input)
{
$options = get_option('lockr_options');
$options['account_email'] = trim($input['account_email']);
$options['account_password'] = trim($input['account_password']);
$name = get_bloginfo('name', 'display');
if (!filter_var($options['account_email'], FILTER_VALIDATE_EMAIL)) {
add_settings_error('lockr_options', 'lockr-email', $options['account_email'] . ' is not a proper email address. Please try again.', 'error');
$options['account_email'] = '';
} else {
try {
\Lockr\Lockr::site()->register($options['account_email'], null, $name);
} catch (ClientException $e) {
try {
\Lockr\Lockr::site()->register($options['account_email'], $options['account_password'], $name);
} catch (ClientException $e) {
add_settings_error('lockr_options', 'lockr-email', 'Login credentials incorrect, please try again.', 'error');
} catch (ServerException $e) {
add_settings_error('lockr_options', 'lockr-email', 'An unknown error has occurred, please try again later.', 'error');
}
} catch (ServerException $e) {
add_settings_error('lockr_options', 'lockr-email', 'An unknown error has occurred, please try again later.', 'error');
}
}
$options['account_password'] = '';
return $options;
}
示例13: error_message
public function error_message()
{
foreach ($this->e->get_error_messages() as $message) {
add_settings_error('dana-don-boom-boom-doo-requirement', 'plugin_requirement', $message, 'error');
}
add_action('admin_notices', [$this, 'show_error']);
}
示例14: iqblockcountry_check_geoapikey
function iqblockcountry_check_geoapikey($input)
{
// Check first if API key is empty....
if (!empty($input)) {
$url = GEOIPAPICHECKURL;
$result = wp_remote_post($url, array('body' => array('api-key' => $input)));
$message = "";
$type = "updated";
if (200 == $result['response']['code']) {
$body = $result['body'];
$xml = new SimpleXmlElement($body);
if ($xml->check != "Ok") {
$message = __('The GeoIP API key is incorrect. Please update the key.', 'iqblockcountry');
$type = "error";
$input = FALSE;
} else {
$message = __('Setting saved.', 'iqblockcountry');
$type = "updated";
}
} else {
$input = FALSE;
}
add_settings_error('iqblockcountry_geoipapi_error', esc_attr('settings_updated'), $message, $type);
return $input;
}
return "";
}
示例15: iul_validate_behavior_fields
function iul_validate_behavior_fields($input)
{
$new_input = array();
if (isset($input['clear_setting'])) {
$iul_clear_settings = $input['clear_setting'];
unset($input['clear_setting']);
}
foreach ($input as $actions) {
if (!empty($actions['idle_action']) && !empty($actions['idle_page']) || ($actions['idle_action'] == 1 || $actions['idle_action'] == 2)) {
if (!empty($actions['user_role'])) {
if ($actions['idle_timer'] != 0 && $actions['idle_timer'] < 10) {
add_settings_error('', esc_attr('iul_error'), __('Idle time must be atleast 10 second', 'iul'), 'error');
$actions['idle_timer'] = '';
}
$new_input[$actions['user_role']] = array('idle_action' => $actions['idle_action'], 'idle_page' => $actions['idle_page'], 'idle_timer' => $actions['idle_timer']);
}
}
}
if (!empty($iul_clear_settings)) {
foreach ($iul_clear_settings as $index) {
unset($new_input[$index]);
}
}
return $new_input;
}