当前位置: 首页>>代码示例>>PHP>>正文


PHP get_settings_errors函数代码示例

本文整理汇总了PHP中get_settings_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP get_settings_errors函数的具体用法?PHP get_settings_errors怎么用?PHP get_settings_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_settings_errors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_license

 public function update_license($value = null)
 {
     $license = $this->get_license();
     if ($license === $value) {
         return $value;
     }
     $deactivate_license = false;
     if ($this->valid_hash($value)) {
         $this->set_license($value);
         $value = $this->activate_license();
         $this->set_license($value);
     } else {
         $this->deactivate_license();
         $this->delete_license();
         $deactivate_license = true;
         $value = '';
     }
     if ($this->valid_license()) {
         $text = esc_html__('%s license saved.');
         $text = sprintf($text, $this->item_name);
         add_settings_error(static::$settings_id, 'license_saved', $text, 'updated');
     } elseif (empty($deactivate_license)) {
         $text = esc_html__('%s license not saved.');
         $text = sprintf($text, $this->item_name);
         add_settings_error(static::$settings_id, 'license_not_saved', $text, 'error');
     }
     if (empty(self::$settings_saved)) {
         self::$settings_saved = true;
         set_transient('settings_errors', get_settings_errors(), 30);
     }
     return $value;
 }
开发者ID:bchamberlain88,项目名称:pavati,代码行数:32,代码来源:class-aihrus-licensing.php

示例2: presscore_ubermenu_generate_less_css_file_after_options_save

 function presscore_ubermenu_generate_less_css_file_after_options_save()
 {
     $set = get_settings_errors('options-framework');
     if (!empty($set)) {
         presscore_generate_less_css_file('the7-ubermenu.less', PRESSCORE_THEME_URI . '/css/the7-uber-menu.less');
     }
 }
开发者ID:noman90rauf,项目名称:wp-content,代码行数:7,代码来源:mod-ubermenu.php

示例3: init_settings

 /**
  * Callback for the 'admin_init' action; used to initialize settings APIs
  */
 public function init_settings()
 {
     if (isset($_GET['settings-updated'])) {
         $err = get_settings_errors();
         $errors = array();
         foreach ($err as $msg) {
             if ('general' !== $msg['setting'] && 'settings_updated' !== $msg['code']) {
                 $errors[] = $msg;
             }
         }
         $this->_errors = $errors;
         global $wp_settings_errors;
         $wp_settings_errors = array();
         if (0 == count($this->_errors)) {
             add_action('admin_notices', array(&$this, 'saved_notice'));
         } else {
             add_action('admin_notices', array($this, 'error_notice'));
         }
     }
     register_setting($this->get_group(), $this->get_option(), array(&$this, 'validate_options'));
     foreach ($this->_args['sections'] as $section_id => $section) {
         add_settings_section($section_id, $section['title'], array(&$this, 'section_callback'), $this->get_page());
         // page
         // add all the fields
         foreach ($section['fields'] as $field_id => $field) {
             $label = '<label for="' . $field_id . '"' . (isset($field['tooltip']) ? ' title="' . esc_attr($field['tooltip']) . '" ' : '') . '>' . esc_html($field['title']) . ($this->_is_required($field) ? '<span class="required">*</span>' : '') . '</label>';
             add_settings_field($field_id, $label, array(&$this, 'display_field'), $this->get_page(), $section_id, array($section_id, $field_id));
         }
     }
 }
开发者ID:heidarmostafa,项目名称:store-cpt,代码行数:33,代码来源:class.spectromsettings.php

示例4: add_settings

 /**
  * Add settings for the RSS feed
  * + also regenerates the secret if requested
  */
 public function add_settings()
 {
     //we register a setting to keep track of the RSS feed status (enabled/disabled)
     register_setting('simple_history_settings_group', 'simple_history_enable_rss_feed', array($this, 'update_rss_status'));
     /**
      * Start new section for RSS feed
      */
     $settings_section_rss_id = "simple_history_settings_section_rss";
     add_settings_section($settings_section_rss_id, _x("RSS feed", "rss settings headline", "simple-history"), array($this, "settings_section_output"), SimpleHistory::SETTINGS_MENU_SLUG);
     // Enable/Disabled RSS feed
     add_settings_field("simple_history_enable_rss_feed", __("Enable", "simple-history"), array($this, "settings_field_rss_enable"), SimpleHistory::SETTINGS_MENU_SLUG, $settings_section_rss_id);
     //if RSS is activated we display other fields
     if ($this->is_rss_enabled()) {
         // RSS address
         add_settings_field("simple_history_rss_feed", __("Address", "simple-history"), array($this, "settings_field_rss"), SimpleHistory::SETTINGS_MENU_SLUG, $settings_section_rss_id);
         // Regnerate address
         add_settings_field("simple_history_rss_feed_regenerate_secret", __("Regenerate", "simple-history"), array($this, "settings_field_rss_regenerate"), SimpleHistory::SETTINGS_MENU_SLUG, $settings_section_rss_id);
     }
     // Create new RSS secret
     $create_new_secret = false;
     $create_secret_nonce_name = "simple_history_rss_secret_regenerate_nonce";
     if (isset($_GET[$create_secret_nonce_name]) && wp_verify_nonce($_GET[$create_secret_nonce_name], 'simple_history_rss_update_secret')) {
         $create_new_secret = true;
         $this->update_rss_secret();
         // Add updated-message and store in transient and then redirect
         // This is the way options.php does it.
         $msg = __("Created new secret RSS address", 'simple-history');
         add_settings_error("simple_history_rss_feed_regenerate_secret", "simple_history_rss_feed_regenerate_secret", $msg, "updated");
         set_transient('settings_errors', get_settings_errors(), 30);
         $goback = esc_url_raw(add_query_arg('settings-updated', 'true', wp_get_referer()));
         wp_redirect($goback);
         exit;
     }
 }
开发者ID:HarvardChanSchool,项目名称:WordPress-Simple-History,代码行数:38,代码来源:SimpleHistoryRSSDropin.php

示例5: redirect_to_settings

 function redirect_to_settings()
 {
     //First preserve all errors that have been generated
     set_transient('settings_errors', get_settings_errors(), 30);
     //Call settings url
     wp_redirect($this->get_redirect_url() . '&settings-updated=true');
 }
开发者ID:philgutowski,项目名称:photo-express-for-google,代码行数:7,代码来源:class-google-photo-access.php

示例6: 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)));
     }
 }
开发者ID:guysyml,项目名称:software,代码行数:33,代码来源:Backup.php

示例7: ubermenu_migration_check

function ubermenu_migration_check()
{
    if (isset($_GET['page']) && $_GET['page'] == 'ubermenu-settings') {
        if (isset($_GET['do'])) {
            if ($_GET['do'] == 'migration-check' || $_GET['do'] == 'migrate' || $_GET['do'] == 'reset-styles') {
                //If we're doing the migration check now, don't show this message
                return;
            } else {
                if ($_GET['do'] == 'no-migrate') {
                    update_option(UBERMENU_PREFIX . 'migration_status', 'do-not-migrate');
                } else {
                    if ($_GET['do'] == 'reset-migration-check') {
                        update_option(UBERMENU_PREFIX . 'migration_status', false);
                    }
                }
            }
        }
    }
    $migration_status = get_option(UBERMENU_PREFIX . 'migration_status', false);
    //Have we already migrated, or determined we don't need to?
    if ($migration_status == 'complete' || $migration_status == 'n/a' || $migration_status == 'do-not-migrate') {
        return;
    }
    //We may need to migrate - do the old setting exist?
    $old_ops = get_option('wp-mega-menu-settings', false);
    // 'sparkops_ubermenu' );
    //There are some old setting, offer migration
    if (is_array($old_ops)) {
        if ($migration_status == false) {
            $notice = __('Looks like you\'ve updated to UberMenu 3.  Awesome!  Would you like to migrate your settings?', 'ubermenu');
            $notice .= ' <a class="button button-primary" href="' . admin_url('themes.php?page=ubermenu-settings&do=migration-check') . '">' . __('Begin Migration') . '</a>';
            $notice .= ' <a class="button ubermenu-migrate-dismiss" href="' . admin_url('themes.php?page=ubermenu-settings&do=no-migrate') . '">' . __('No, thanks', 'ubermenu') . '</a>';
            $add = true;
            //Avoid duplication
            $errors = get_settings_errors();
            if (is_array($errors)) {
                foreach ($errors as $er) {
                    if (is_array($er)) {
                        if ($er['code'] == 'migration-notice') {
                            $add = false;
                            break;
                        }
                    }
                }
            }
            if ($add) {
                add_settings_error('menu-migration', 'migration-notice', $notice, 'updated');
                add_action('admin_footer', 'ubermenu_migrate_nag_js');
            }
        } else {
            if ($migration_status == 'in_progress') {
                $notice = __('Migration did not complete successfully', 'ubermenu');
                add_settings_error('menu-migration', 'migration-notice-incomplete', $notice, 'error');
                update_option(UBERMENU_PREFIX . 'migration_status', false);
            }
        }
    } else {
        update_option(UBERMENU_PREFIX . 'migration_status', 'n/a');
    }
}
开发者ID:WackoMako,项目名称:stonedape,代码行数:60,代码来源:migration.php

示例8: compiler_add_error

    function compiler_add_error()
    {
        if (get_settings_errors('options-framework')) {
            return;
        }
        add_settings_error('options-framework', 'lessc_error', _x('Attention! Theme Options will not be saved, because one of your plugins conflicts with the theme.<br />
	How to make it work:<br />
	1. Deactivate all plugins.<br />
	2. Make required changes. Save Theme Options.<br />
	3. Activate the plugins back.', 'backend', LANGUAGE_ZONE), 'error');
    }
开发者ID:scottnkerr,项目名称:eeco,代码行数:11,代码来源:Compiler.class.php

示例9: presscore_generate_less_css_file_after_options_save

 /**
  * Update custom.less stylesheet.
  *
  */
 function presscore_generate_less_css_file_after_options_save()
 {
     $css_is_writable = apply_filters('presscore_less_cache_writable', true);
     $set = get_settings_errors('options-framework');
     if (!empty($set)) {
         $dynamic_stylesheets = presscore_get_dynamic_stylesheets_list();
         foreach ($dynamic_stylesheets as $stylesheet_handle => $stylesheet) {
             presscore_generate_less_css_file($stylesheet_handle, $stylesheet['src']);
         }
         if ($css_is_writable) {
             add_settings_error('presscore-wp-less', 'save_stylesheet', _x('Stylesheet saved.', 'backend', 'the7mk2'), 'updated fade');
         }
     }
 }
开发者ID:10asfar,项目名称:WordPress-the7-theme-demo-,代码行数:18,代码来源:dynamic-stylesheets-functions.php

示例10: handle_settings_save

 function handle_settings_save()
 {
     if (!isset($_REQUEST[$this->name()])) {
         wp_die(__('Settings could not be parsed — this may be caused by a plugin conflict.'));
     }
     $to_be_saved = $_REQUEST[$this->name()];
     $option_page = $_REQUEST['option_page'];
     $is_network_wide = isset($_REQUEST['network_wide']) && $_REQUEST['network_wide'];
     if (!wp_verify_nonce($_REQUEST['_wpnonce'], $option_page . "-options")) {
         wp_die(__('Cheatin&#8217; uh?'));
     }
     // if it's network request, we want to check that the current user is
     // a network admin
     if ($is_network_wide && !is_super_admin()) {
         wp_die(__('Cheatin&#8217; uh?'));
     }
     // verify that the user has the permissions to edit the clef page
     $capability = 'manage_options';
     $capability = apply_filters("option_page_capability_{$option_page}", $capability);
     if (!current_user_can($capability)) {
         wp_die(__('Cheatin&#8217; uh?'));
     }
     $whitelist_options = apply_filters('whitelist_options', array());
     $options = $whitelist_options[$option_page];
     if (empty($options[0]) || $options[0] != $this->name()) {
         wp_die("You can't do that!");
     }
     $to_be_saved = apply_filters('ajax_settings_pre_save', $to_be_saved);
     if ($is_network_wide) {
         update_site_option($this->name(), $to_be_saved);
     } else {
         update_option($this->name(), $to_be_saved);
     }
     $errors = get_settings_errors();
     $response = array();
     if (!empty($errors)) {
         $error_messages = array();
         foreach ($errors as &$error) {
             $error_messages[$error['code']] = $error['message'];
         }
         $response['errors'] = $error_messages;
         header('HTTP/1.0 400');
         wp_send_json_error($response);
     } else {
         $response['success'] = true;
         wp_send_json($response);
     }
 }
开发者ID:blueyedQT,项目名称:Arizona-Team-One.com,代码行数:48,代码来源:ajax-settings.php

示例11: test_sanitize_permalink_structure

 /**
  * @dataProvider permalink_structure_provider
  */
 public function test_sanitize_permalink_structure($provided, $expected, $valid)
 {
     global $wp_settings_errors;
     $old_wp_settings_errors = (array) $wp_settings_errors;
     $actual = sanitize_option('permalink_structure', $provided);
     $errors = get_settings_errors('permalink_structure');
     // Clear errors.
     $wp_settings_errors = $old_wp_settings_errors;
     if ($valid) {
         $this->assertEmpty($errors);
     } else {
         $this->assertNotEmpty($errors);
         $this->assertEquals('invalid_permalink_structure', $errors[0]['code']);
     }
     $this->assertEquals($expected, $actual);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:19,代码来源:sanitize-option.php

示例12: graphene_ajax_update_preset_handler

/**
 * Process the AJAX call to save/delete colour preset
 */
function graphene_ajax_update_preset_handler()
{
    global $wpdb;
    check_ajax_referer('graphene_options-options', '_wpnonce');
    if (!current_user_can('edit_theme_options')) {
        echo '<div class="error fade"><p>' . __("Sorry, but you don't have the necessary permission to modify theme options.", 'graphene') . '</p></div>';
        die;
    }
    $action = $_POST['colour_preset_action'];
    $preset = $action == 'delete' ? trim($_POST['colour_preset_name']) : sanitize_title($_POST['colour_preset_name']);
    $data = $_POST['graphene_settings'];
    if ($action == 'delete') {
        unset($data['colour_presets'][$preset]);
    }
    if ($action == 'save') {
        $count = $dash = '';
        while (array_key_exists($preset . $dash . $count, $data['colour_presets'])) {
            if (!$count) {
                $count = 0;
                $dash = '-';
            }
            $count++;
        }
        if ($count) {
            $preset .= '-' . $count;
        }
        $colour_settings = $data;
        unset($colour_settings['colour_preset']);
        unset($colour_settings['colour_presets']);
        $colour_settings = json_encode($colour_settings);
        $data['colour_presets'][$preset]['name'] = trim($_POST['colour_preset_name']);
        $data['colour_presets'][$preset]['code'] = $colour_settings;
        $data['colour_preset'] = $preset;
    }
    $data = graphene_settings_validator($data);
    if (get_settings_errors('graphene_options')) {
        settings_errors('graphene_options');
    } else {
        if ($data) {
            update_option('graphene_settings', stripslashes_deep($data));
        }
        $message = $action == 'delete' ? __('Colour preset deleted.', 'graphene') : __('Colour preset saved.', 'graphene');
        echo '<div class="updated fade"><p>' . $message . '</p></div>';
    }
    die;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:49,代码来源:ajax-handler.php

示例13: presscore_generate_less_css_file_after_options_save

 /**
  * Update custom.less stylesheet.
  *
  */
 function presscore_generate_less_css_file_after_options_save()
 {
     $css_is_writable = get_option('presscore_less_css_is_writable');
     if (isset($_GET['page']) && 'options-framework' == $_GET['page'] && !$css_is_writable) {
         return;
     }
     $set = get_settings_errors('options-framework');
     if (!empty($set)) {
         $dynamic_stylesheets = presscore_get_dynamic_stylesheets_list();
         foreach ($dynamic_stylesheets as $stylesheet_handle => $stylesheet) {
             presscore_generate_less_css_file($stylesheet_handle, $stylesheet['src']);
         }
         if ($css_is_writable) {
             add_settings_error('presscore-wp-less', 'save_stylesheet', _x('Stylesheet saved.', 'backend', 'the7mk2'), 'updated fade');
         }
     }
 }
开发者ID:RDePoppe,项目名称:luminaterealestate,代码行数:21,代码来源:dynamic-stylesheets-functions.php

示例14: lbmn_required_plugins_install_check

/**
 * ----------------------------------------------------------------------
 * Check if required plugins were manually installed
 */
function lbmn_required_plugins_install_check()
{
    if (!get_option(LBMN_THEME_NAME . '_required_plugins_installed')) {
        // Proceed only if '_required_plugins_installed' not already market as true
        $current_tgmpa_message = '';
        $current_tgmpa_messages = get_settings_errors('tgmpa');
        foreach ($current_tgmpa_messages as $message) {
            $current_tgmpa_message = $message['message'];
        }
        // If message has no link to install-required-plugins page then all
        // required plugins has been installed
        if (!stristr($current_tgmpa_message, 'install-required-plugins')) {
            // Update theme option '_required_plugins_installed'
            update_option(LBMN_THEME_NAME . '_required_plugins_installed', true);
        }
    }
}
开发者ID:shimion,项目名称:localinsurance-theme,代码行数:21,代码来源:functions-themeinstall.php

示例15: franz_ajax_update_handler

/**
 * Process the AJAX call to save the theme's settings
 */
function franz_ajax_update_handler()
{
    global $wpdb;
    check_ajax_referer('franz_options-options', '_wpnonce');
    if (!current_user_can('edit_theme_options')) {
        echo '<div class="error fade"><p>' . __("Sorry, but you don't have the necessary permission to modify theme options.", 'franz-josef') . '</p></div>';
        die;
    }
    $data = $_POST['franz_settings'];
    $data = franz_settings_validator($data);
    if (get_settings_errors('franz_options')) {
        settings_errors('franz_options');
    } else {
        if ($data) {
            update_option('franz_settings', stripslashes_deep($data));
        }
        echo '<div class="updated fade"><p>' . __('Options saved.', 'franz-josef') . '</p></div>';
    }
    die;
}
开发者ID:samuel657677,项目名称:flipbook,代码行数:23,代码来源:ajax-handler.php


注:本文中的get_settings_errors函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。