本文整理汇总了PHP中set_user_setting函数的典型用法代码示例。如果您正苦于以下问题:PHP set_user_setting函数的具体用法?PHP set_user_setting怎么用?PHP set_user_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_user_setting函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_settings
function save_settings()
{
validate_request_vars();
if (sizeof($_REQUEST)) {
foreach ($_REQUEST as $var => $value) {
switch ($var) {
case 'timespan':
set_user_setting('cycle_timespan', get_request_var('timespan'));
break;
case 'refresh':
set_user_setting('cycle_delay', get_request_var('refresh'));
break;
case 'graphs':
set_user_setting('cycle_graphs', get_request_var('graphs'));
break;
case 'cols':
set_user_setting('cycle_columns', get_request_var('cols'));
break;
case 'height':
set_user_setting('cycle_height', get_request_var('height'));
break;
case 'width':
set_user_setting('cycle_width', get_request_var('width'));
break;
case 'legend':
set_user_setting('cycle_legend', get_request_var('legend'));
break;
case 'filter':
set_user_setting('cycle_filter', get_request_var('filter'));
break;
}
}
}
validate_request_vars(true);
}
示例2: independent_publisher_setup
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
* @since Independent Publisher 1.0
*/
function independent_publisher_setup()
{
/**
* Custom template tags for this theme.
*/
require get_stylesheet_directory() . '/inc/template-tags.php';
/**
* Customizer additions.
*/
require get_stylesheet_directory() . '/inc/customizer.php';
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
*/
load_theme_textdomain('independent-publisher', get_stylesheet_directory() . '/languages');
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support('automatic-feed-links');
/**
* Enable Custom Backgrounds
*/
add_theme_support('custom-background', apply_filters('independent_publisher_custom_background_args', array('default-color' => 'ffffff', 'default-image' => '')));
// Enable support for HTML5 markup.
add_theme_support('html5', array('comment-list', 'search-form', 'comment-form', 'gallery'));
/**
* Enable Post Thumbnails
*/
add_theme_support('post-thumbnails');
/*
* Add custom thumbnail size for use with featured images
*/
add_image_size('independent_publisher_post_thumbnail', 700, 700);
/**
* Enable editor style
*/
add_editor_style();
/**
* Set max width of full screen visual editor to match content width
*/
set_user_setting('dfw_width', 700);
/**
* Set default value for Show Post Word Count theme option
*/
add_option('independent_publisher_general_options', array('show_post_word_count' => true));
/**
* This theme uses wp_nav_menu() in two locations.
*/
register_nav_menus(array('primary' => __('Primary Menu', 'independent-publisher'), 'single' => __('Single Posts Menu', 'independent-publisher'), 'social' => __('Social', 'independent-publisher')));
/**
* Add support for the Aside Post Formats
*/
add_theme_support('post-formats', array('aside', 'link', 'gallery', 'status', 'quote', 'chat', 'image', 'video', 'audio'));
}
示例3: prepare_items
/**
*
* @global string $usersearch
* @global string $role
* @global wpdb $wpdb
* @global string $mode
*/
public function prepare_items()
{
global $usersearch, $role, $wpdb, $mode;
$usersearch = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : '';
$users_per_page = $this->get_items_per_page('users_network_per_page');
$role = isset($_REQUEST['role']) ? $_REQUEST['role'] : '';
$paged = $this->get_pagenum();
$args = array('number' => $users_per_page, 'offset' => ($paged - 1) * $users_per_page, 'search' => $usersearch, 'blog_id' => 0, 'fields' => 'all_with_meta');
if (wp_is_large_network('users')) {
$args['search'] = ltrim($args['search'], '*');
} else {
if ('' !== $args['search']) {
$args['search'] = trim($args['search'], '*');
$args['search'] = '*' . $args['search'] . '*';
}
}
if ($role === 'super') {
$logins = implode("', '", get_super_admins());
$args['include'] = $wpdb->get_col("SELECT ID FROM {$wpdb->users} WHERE user_login IN ('{$logins}')");
}
/*
* If the network is large and a search is not being performed,
* show only the latest users with no paging in order to avoid
* expensive count queries.
*/
if (!$usersearch && wp_is_large_network('users')) {
if (!isset($_REQUEST['orderby'])) {
$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
}
if (!isset($_REQUEST['order'])) {
$_GET['order'] = $_REQUEST['order'] = 'DESC';
}
$args['count_total'] = false;
}
if (isset($_REQUEST['orderby'])) {
$args['orderby'] = $_REQUEST['orderby'];
}
if (isset($_REQUEST['order'])) {
$args['order'] = $_REQUEST['order'];
}
if (!empty($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
set_user_setting('network_users_list_mode', $mode);
} else {
$mode = get_user_setting('network_users_list_mode', 'list');
}
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
$args = apply_filters('users_list_table_query_args', $args);
// Query the user IDs for this page
$wp_user_search = new WP_User_Query($args);
$this->items = $wp_user_search->get_results();
$this->set_pagination_args(array('total_items' => $wp_user_search->get_total(), 'per_page' => $users_per_page));
}
示例4: __construct
/**
* クラスの初期化
*
* @since 1.0.0
* @param object $blocks ブロックのインスタンス
*/
public function __construct($blocks)
{
BCE_Utilis::set_option();
// 自動最大高さ機能をオフ
set_user_setting('editor_expand', 'off');
$this->plugin_name = BCE_Utilis::get_plugin_name();
$this->version = BCE_Utilis::get_version();
$this->blocks = $blocks;
add_filter('the_editor', array($this, 'the_editor'), 10, 1);
add_action('wp_footer', array($this, 'output_locales'));
add_action('admin_footer', array($this, 'output_locales'));
}
示例5: get_user_setting
function get_user_setting($key, $should_set = true)
{
global $default_user_settings, $mobile_detect;
if (array_key_exists($key, $_COOKIE)) {
return $_COOKIE[$key];
} else {
switch ($key) {
case 'use_dialogs':
$default_value = is_mobile_browser() ? 'no' : 'yes';
break;
default:
$default_value = $default_user_settings[$key];
break;
}
if ($should_set) {
set_user_setting($key, $default_value);
}
return $default_value;
}
}
示例6: userUpdateLogin
/**
* Updates the login time in the database of the given user
* The login time is used to automatically logout users who have been
* inactive for the defined session time
* @param string $username the username to update the login info for
*/
function userUpdateLogin($user_id)
{
set_user_setting($user_id, 'sessiontime', time());
}
示例7: do_xmlrpc
$response = do_xmlrpc(xmlrpc_encode_request($cmd, $params));
if (!response || @xmlrpc_is_fault($response)) {
$errors[] = "Failed to add torrent \"{$d_name}\" to rTorrent:\n\n" . print_r($response, true);
}
}
}
}
if (count($errors)) {
array_unshift($errors, "One or more errors occurred:\n");
$script = 'alert(' . json_encode($errors) . '.join("\\n"))';
} else {
if (is_array($r_tags)) {
set_error_handler('handleError');
try {
set_torrent_tags($r_add_torrent, $r_tags, array());
set_user_setting('new_torrent_tags', implode('|', $r_tags));
} catch (Exception $e) {
restore_error_handler();
die('Error setting tags: ' . $e->getMessage());
}
restore_error_handler();
}
$script = 'closeWindow();';
}
print "<script type=\"text/javascript\">{$script}</script>\n";
break;
case 'delete_files':
if (is_array($_SESSION['to_add_data'])) {
foreach ($_SESSION['to_add_data'] as $data) {
@unlink("{$tmp_add_dir}/" . $data['filename']);
}
示例8: ajax_toggle_advanced_items
/**
* ajax_toggle_advanced_items function.
*
* @access public
* @return void
*/
public function ajax_toggle_advanced_items()
{
$nonce = $_POST['beansidebars_advanced_noonce'];
$status = $_POST['new_status'];
//Add nonce security to the request
if (!wp_verify_nonce($nonce, 'beansidebars_advanced_noonce')) {
die;
}
$response = set_user_setting('beansidebarsshowadvanced', $status);
echo $response;
die;
// WordPress may print out a spurious zero without this can be particularly bad if using JSON
}
示例9: dirname
* Widgets administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once dirname(__FILE__) . '/admin.php';
/** WordPress Administration Widgets API */
require_once ABSPATH . 'wp-admin/includes/widgets.php';
if (!current_user_can('edit_theme_options')) {
wp_die(__('Cheatin’ uh?'), 403);
}
$widgets_access = get_user_setting('widgets_access');
if (isset($_GET['widgets-access'])) {
$widgets_access = 'on' == $_GET['widgets-access'] ? 'on' : 'off';
set_user_setting('widgets_access', $widgets_access);
}
function wp_widgets_access_body_class($classes)
{
return "{$classes} widgets_access ";
}
if ('on' == $widgets_access) {
add_filter('admin_body_class', 'wp_widgets_access_body_class');
} else {
wp_enqueue_script('admin-widgets');
if (wp_is_mobile()) {
wp_enqueue_script('jquery-touch-punch');
}
}
/**
* Fires early before the Widgets administration screen loads,
示例10: prepare_items
/**
*
* @global string $s
* @global string $mode
* @global wpdb $wpdb
*/
public function prepare_items()
{
global $s, $mode, $wpdb;
$current_site = get_current_site();
if (!empty($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
set_user_setting('sites_list_mode', $mode);
} else {
$mode = get_user_setting('sites_list_mode', 'list');
}
$per_page = $this->get_items_per_page('sites_network_per_page');
$pagenum = $this->get_pagenum();
$s = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : '';
$wild = '';
if (false !== strpos($s, '*')) {
$wild = '%';
$s = trim($s, '*');
}
/*
* If the network is large and a search is not being performed, show only
* the latest sites with no paging in order to avoid expensive count queries.
*/
if (!$s && wp_is_large_network()) {
if (!isset($_REQUEST['orderby'])) {
$_GET['orderby'] = $_REQUEST['orderby'] = '';
}
if (!isset($_REQUEST['order'])) {
$_GET['order'] = $_REQUEST['order'] = 'DESC';
}
}
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
if (empty($s)) {
// Nothing to do.
} elseif (preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/', $s) || preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.?$/', $s) || preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.?$/', $s) || preg_match('/^[0-9]{1,3}\\.$/', $s)) {
// IPv4 address
$sql = $wpdb->prepare("SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like($s) . $wild);
$reg_blog_ids = $wpdb->get_col($sql);
if (!$reg_blog_ids) {
$reg_blog_ids = array(0);
}
$query = "SELECT *\n\t\t\t\tFROM {$wpdb->blogs}\n\t\t\t\tWHERE site_id = '{$wpdb->siteid}'\n\t\t\t\tAND {$wpdb->blogs}.blog_id IN (" . implode(', ', $reg_blog_ids) . ")";
} else {
if (is_numeric($s) && empty($wild)) {
$query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.blog_id = %s )", $s);
} elseif (is_subdomain_install()) {
$blog_s = str_replace('.' . $current_site->domain, '', $s);
$blog_s = $wpdb->esc_like($blog_s) . $wild . $wpdb->esc_like('.' . $current_site->domain);
$query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.domain LIKE %s ) ", $blog_s);
} else {
if ($s != trim('/', $current_site->path)) {
$blog_s = $wpdb->esc_like($current_site->path . $s) . $wild . $wpdb->esc_like('/');
} else {
$blog_s = $wpdb->esc_like($s);
}
$query .= $wpdb->prepare(" AND ( {$wpdb->blogs}.path LIKE %s )", $blog_s);
}
}
$order_by = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : '';
if ($order_by === 'registered') {
$query .= ' ORDER BY registered ';
} elseif ($order_by === 'lastupdated') {
$query .= ' ORDER BY last_updated ';
} elseif ($order_by === 'blogname') {
if (is_subdomain_install()) {
$query .= ' ORDER BY domain ';
} else {
$query .= ' ORDER BY path ';
}
} elseif ($order_by === 'blog_id') {
$query .= ' ORDER BY blog_id ';
} else {
$order_by = null;
}
if (isset($order_by)) {
$order = isset($_REQUEST['order']) && 'DESC' === strtoupper($_REQUEST['order']) ? "DESC" : "ASC";
$query .= $order;
}
// Don't do an unbounded count on large networks
if (!wp_is_large_network()) {
$total = $wpdb->get_var(str_replace('SELECT *', 'SELECT COUNT( blog_id )', $query));
}
$query .= " LIMIT " . intval(($pagenum - 1) * $per_page) . ", " . intval($per_page);
$this->items = $wpdb->get_results($query, ARRAY_A);
if (wp_is_large_network()) {
$total = count($this->items);
}
$this->set_pagination_args(array('total_items' => $total, 'per_page' => $per_page));
}
示例11: hide_forever
/**
* Hide the WooTransmitter notification forever, if desired.
* @since 1.0.0
* @return void
*/
public function hide_forever()
{
if (is_user_logged_in() && isset($_GET['wootransmitter-hide']) && $_GET['wootransmitter-hide'] == 'yes' && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'wootransmitter-hide')) {
set_user_setting('wootransmitterbridgehide', '1');
$redirect = remove_query_arg(array('wootransmitter-hide', '_wpnonce'), $this->current_url());
wp_safe_redirect($redirect);
exit;
}
}
示例12: accept_changes
/**
* Accpet changed gedcom record into database
*
* This function gets an updated record from the gedcom file and replaces it in the database
* @author John Finlay
* @param string $cid The change id of the record to accept
*/
function accept_changes($cid)
{
global $pgv_changes, $GEDCOM, $TBLPREFIX, $FILE, $GEDCOMS;
global $INDEX_DIRECTORY, $SYNC_GEDCOM_FILE, $fcontents, $manual_save;
if (isset($pgv_changes[$cid])) {
$changes = $pgv_changes[$cid];
$change = $changes[count($changes) - 1];
if ($GEDCOM != $change["gedcom"]) {
$GEDCOM = $change["gedcom"];
}
$FILE = $GEDCOM;
$gid = $change["gid"];
$gedrec = $change["undo"];
if (empty($gedrec)) {
$gedrec = find_gedcom_record($gid);
}
update_record($gedrec, $change["type"] == "delete");
//-- write the changes back to the gedcom file
if ($SYNC_GEDCOM_FILE) {
// TODO: We merge CONC lines on import, so need to add them back on export
if (!isset($manual_save) || $manual_save == false) {
//-- only allow one thread to accept changes at a time
// $mutex = new Mutex("accept_changes");
// $mutex->Wait();
}
if (empty($fcontents)) {
read_gedcom_file();
}
if ($change["type"] == "delete") {
$pos1 = find_newline_string($fcontents, "0 @{$gid}@");
if ($pos1 !== false) {
$pos2 = find_newline_string($fcontents, "0", $pos1 + 5);
if ($pos2 === false) {
$fcontents = substr($fcontents, 0, $pos1) . '0 TRLR' . PGV_EOL;
AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct");
} else {
$fcontents = substr($fcontents, 0, $pos1) . substr($fcontents, $pos2);
}
} else {
AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct. Deleted gedcom record {$gid} was not found in the gedcom file.");
}
} elseif ($change["type"] == "append") {
$pos1 = find_newline_string($fcontents, "0 TRLR");
$fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . '0 TRLR' . PGV_EOL;
} elseif ($change["type"] == "replace") {
$pos1 = find_newline_string($fcontents, "0 @{$gid}@");
if ($pos1 !== false) {
$pos2 = find_newline_string($fcontents, "0", $pos1 + 5);
if ($pos2 === false) {
$fcontents = substr($fcontents, 0, $pos1) . '0 TRLR' . PGV_EOL;
AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct");
} else {
$fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . substr($fcontents, $pos2);
}
} else {
//-- attempted to replace a record that doesn't exist
AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct. Replaced gedcom record {$gid} was not found in the gedcom file.");
$pos1 = find_newline_string($fcontents, "0 TRLR");
$fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . '0 TRLR' . PGV_EOL;
AddToLog("Gedcom record {$gid} was appended back to the GEDCOM file.");
}
}
if (!isset($manual_save) || $manual_save == false) {
write_file();
// $mutex->Release();
}
}
if ($change["type"] != "delete") {
//-- synchronize the gedcom record with any user account
$username = get_user_from_gedcom_xref($GEDCOM, $gid);
if ($username && get_user_setting($username, 'sync_gedcom') == 'Y') {
$firstname = get_gedcom_value("GIVN", 2, $gedrec);
$lastname = get_gedcom_value("SURN", 2, $gedrec);
if (empty($lastname)) {
$fullname = get_gedcom_value("NAME", 1, $gedrec, "", false);
$ct = preg_match("~(.*)/(.*)/~", $fullname, $match);
if ($ct > 0) {
$firstname = $match[1];
$lastname = $match[2];
} else {
$firstname = $fullname;
}
}
//-- SEE [ 1753047 ] Email/sync with account
$email = get_gedcom_value("EMAIL", 1, $gedrec);
if (empty($email)) {
$email = get_gedcom_value("_EMAIL", 1, $gedrec);
}
if (!empty($email)) {
set_user_setting($username, 'email', $email);
}
set_user_setting($username, 'firstname', $firstname);
set_user_setting($username, 'lastname', $lastname);
//.........这里部分代码省略.........
示例13: set_user_gedcom_setting
function set_user_gedcom_setting($user_id, $ged_id, $parameter, $value)
{
$ged_name = get_gedcom_from_id($ged_id);
$tmp = get_user_setting($user_id, $parameter);
if (is_string($tmp)) {
$tmp_array = unserialize($tmp);
if (!is_array($tmp_array)) {
$tmp_array = array();
}
} else {
$tmp_array = array();
}
if (empty($value)) {
// delete the value
unset($tmp_array[$ged_name]);
} else {
// update the value
$tmp_array[$ged_name] = $value;
}
set_user_setting($user_id, $parameter, serialize($tmp_array));
global $PGV_USERS_cache;
if (isset($PGV_USERS_cache[$user_id])) {
unset($PGV_USERS_cache[$user_id]);
}
}
示例14: rtgui_session_start
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with rtGui. If not, see <http://www.gnu.org/licenses/>.
require_once 'config.php';
require_once 'functions.php';
rtgui_session_start();
extract($_REQUEST, EXTR_PREFIX_ALL, 'r');
if ($r_operation == 'save_settings') {
set_user_setting('refresh_interval', $r_set_refresh);
rtorrent_xmlrpc('set_upload_rate', array($r_set_max_up));
rtorrent_xmlrpc('set_download_rate', array($r_set_max_down));
set_user_setting('theme', $r_set_theme);
set_user_setting('use_dialogs', $r_set_use_dialogs ? 'yes' : 'no');
set_user_setting('show_hidden', $r_set_show_hidden ? 'yes' : 'no');
}
$download_cap = rtorrent_xmlrpc('get_download_rate');
$upload_cap = rtorrent_xmlrpc('get_upload_rate');
if (isset($r_submit)) {
if ($r_dialog) {
echo <<<JS
<script type="text/javascript">
window.top.reloadUserSettings();
window.top.hideDialog(true);
</script>
JS;
} else {
header('Location: .');
}
die;
示例15: wp_die
<?php
global $current_screen;
/** WordPress Administration fields API */
//require_once(ABSPATH . 'wp-admin/includes/fields.php');
//require( SCF_DIR . '/inc/functions.widget.php');
if (!current_user_can('edit_theme_options')) {
wp_die(__('Cheatin’ uh?'));
}
wp_admin_css('widgets', true);
$fields_access = get_user_setting('widgets_access');
if (isset($_GET['fields-access'])) {
$fields_access = 'on' == $_GET['fields-access'] ? 'on' : 'off';
set_user_setting('widgets_access', $fields_access);
}
if ('on' == $fields_access) {
add_filter('admin_body_class', create_function('', '{return " widgets_access ";}'));
} else {
wp_enqueue_script('admin-widgets');
}
do_action('sidebar_admin_setup');
$title = __('Page Fields', 'custom_fields');
$parent_file = 'themes.php';
$help = '
<p>' . __('fields are independent sections of content that can be placed into any fieldized area provided by your theme (commonly called sidebars). To populate your sidebars/field areas with individual fields, drag and drop the title bars into the desired area. By default, only the first field area is expanded. To populate additional field areas, click on their title bars to expand them.') . '</p>
<p>' . __('Available fields section contains all the fields you can choose from. Once you drag a field into a sidebar, it will open to allow you to configure its settings. When you are happy with the field settings, click the Save button and the field will go live on your site. If you click Delete, it will remove the field.') . '</p>
<p>' . __('If you want to remove the field but save its setting for possible future use, just drag it into the Inactive fields area. You can add them back anytime from there. This is especially helpful when you switch to a theme with less or different field areas.') . '</p>
<p>' . __('fields may be used multiple times. You can give each field a title, to display on your site, but it’s not required.') . '</p>
<p>' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.') . '</p>
';
$help .= '<p><strong>' . __('For more information:') . '</strong></p>';