function _ga_adjust_admin_bar_site_menu($admin_bar) { if (!is_user_logged_in() || !current_user_can('manage_global')) { return; } $blogname = sprintf(__('Global Admin: %s'), esc_html(get_global_option('global_name'))); $title = wp_html_excerpt($blogname, 40, '…'); $admin_bar->add_menu(array('id' => 'site-name', 'title' => $title, 'href' => home_url('/'))); $admin_bar->add_menu(array('parent' => 'site-name', 'id' => 'view-site', 'title' => __('Visit Site'), 'href' => home_url('/'))); }
/** * Remove role by name. * * @since 4.8.0 * @access public * * @param string $role Role name. */ public function remove_role($role) { if (!isset($this->role_objects[$role])) { return; } unset($this->role_objects[$role]); unset($this->role_names[$role]); unset($this->roles[$role]); if ($this->use_db) { update_global_option($this->role_key, $this->roles); } if (get_global_option('default_role') == $role) { update_global_option('default_role', 'subscriber'); } }
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; }
function get_global_site_count() { return get_global_option('site_count'); }