Example #1
0
    wp_die(__('You do not have permission to access this page.'), 403);
}
$title = __('Global Settings', 'global-admin');
$parent_file = 'settings.php';
get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview', 'global-admin'), 'content' => '<p>' . __('This screen sets and changes options for the entire setup as a whole. The settings on this page will affect all networks and sites.', 'global-admin') . '</p>'));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', 'global-admin') . '</strong></p>' . '<p>' . __('<a href="https://github.com/felixarntz/global-admin/wiki/Global-Admin-Settings-Screen" target="_blank">Documentation on Global Settings</a>', 'global-admin') . '</p>');
if ($_POST) {
    check_admin_referer('global-options');
    //TODO: process global settings
    $options = array();
    foreach ($options as $option_name) {
        if (!isset($_POST[$option_name])) {
            continue;
        }
        $value = wp_unslash($_POST[$option_name]);
        update_global_option($option_name, $value);
    }
    wp_redirect(add_query_arg('updated', 'true', global_admin_url('settings.php')));
    exit;
}
include ABSPATH . 'wp-admin/admin-header.php';
if (isset($_GET['updated'])) {
    ?>
<div id="message" class="updated notice is-dismissible"><p><?php 
    _e('Settings saved.');
    ?>
</p></div><?php 
}
?>

<div class="wrap">
Example #2
0
 function set_global_transient($transient, $value, $expiration = 0)
 {
     $expiration = (int) $expiration;
     /**
      * Filters a specific global transient before its value is set.
      *
      * The dynamic portion of the hook name, `$transient`, refers to the transient name.
      *
      * @since 1.0.0
      *
      * @param mixed  $value      New value of transient.
      * @param int    $expiration Time until expiration in seconds.
      * @param string $transient  Transient name.
      */
     $value = apply_filters('pre_set_global_transient_' . $transient, $value, $expiration, $transient);
     /**
      * Filters the expiration for a global transient before its value is set.
      *
      * The dynamic portion of the hook name, `$transient`, refers to the transient name.
      *
      * @since 1.0.0
      *
      * @param int    $expiration Time until expiration in seconds. Use 0 for no expiration.
      * @param mixed  $value      New value of transient.
      * @param string $transient  Transient name.
      */
     $expiration = apply_filters('expiration_of_global_transient_' . $transient, $expiration, $value, $transient);
     if (wp_using_ext_object_cache()) {
         $result = wp_cache_set($transient, $value, 'global-transient', $expiration);
     } else {
         $transient_timeout = '_transient_timeout_' . $transient;
         $transient_option = '_transient_' . $transient;
         if (false === get_global_option($transient_option)) {
             $autoload = 'yes';
             if ($expiration) {
                 $autoload = 'no';
                 add_global_option($transient_timeout, time() + $expiration, 'no');
             }
             $result = add_global_option($transient_option, $value, $autoload);
         } else {
             // If expiration is requested, but the transient has no timeout option,
             // delete, then re-create transient rather than update.
             $update = true;
             if ($expiration) {
                 if (false === get_global_option($transient_timeout)) {
                     delete_global_option($transient_option);
                     add_global_option($transient_timeout, time() + $expiration, 'no');
                     $result = add_global_option($transient_option, $value, 'no');
                     $update = false;
                 } else {
                     update_global_option($transient_timeout, time() + $expiration);
                 }
             }
             if ($update) {
                 $result = update_global_option($transient_option, $value);
             }
         }
     }
     if ($result) {
         /**
          * Fires after the value for a specific global transient has been set.
          *
          * The dynamic portion of the hook name, `$transient`, refers to the transient name.
          *
          * @since 1.0.0
          *
          * @param mixed  $value      Transient value.
          * @param int    $expiration Time until expiration in seconds.
          * @param string $transient  The name of the transient.
          */
         do_action('set_global_transient_' . $transient, $value, $expiration, $transient);
         /**
          * Fires after the value for a global transient has been set.
          *
          * @since 1.0.0
          *
          * @param string $transient  The name of the transient.
          * @param mixed  $value      Transient value.
          * @param int    $expiration Time until expiration in seconds.
          */
         do_action('setted_global_transient', $transient, $value, $expiration);
     }
     return $result;
 }
 /**
  * Remove capability from role.
  *
  * @since 4.8.0
  * @access public
  *
  * @param string $role Role name.
  * @param string $cap Capability name.
  */
 public function remove_cap($role, $cap)
 {
     if (!isset($this->roles[$role])) {
         return;
     }
     unset($this->roles[$role]['capabilities'][$cap]);
     if ($this->use_db) {
         update_global_option($this->role_key, $this->roles);
     }
 }
Example #4
0
 function wp_update_global_user_counts()
 {
     global $wpdb;
     $count = $wpdb->get_var("SELECT COUNT(ID) as c FROM {$wpdb->users} WHERE spam = '0' AND deleted = '0'");
     update_global_option('user_count', $count);
 }