本文整理汇总了PHP中stats_set_options函数的典型用法代码示例。如果您正苦于以下问题:PHP stats_set_options函数的具体用法?PHP stats_set_options怎么用?PHP stats_set_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stats_set_options函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stats_configuration_load
function stats_configuration_load()
{
if (isset($_POST['action']) && $_POST['action'] == 'save_options' && $_POST['_wpnonce'] == wp_create_nonce('stats')) {
$options = stats_get_options();
$options['admin_bar'] = isset($_POST['admin_bar']) && $_POST['admin_bar'];
$options['hide_smile'] = isset($_POST['hide_smile']) && $_POST['hide_smile'];
$options['roles'] = array('administrator');
foreach (get_editable_roles() as $role => $details) {
if (isset($_POST["role_{$role}"]) && $_POST["role_{$role}"]) {
$options['roles'][] = $role;
}
}
$options['count_roles'] = array();
foreach (get_editable_roles() as $role => $details) {
if (isset($_POST["count_role_{$role}"]) && $_POST["count_role_{$role}"]) {
$options['count_roles'][] = $role;
}
}
stats_set_options($options);
stats_update_blog();
Jetpack::state('message', 'module_configured');
wp_safe_redirect(Jetpack::module_configuration_url('stats'));
exit;
}
}
示例2: stats_get_blog_id
function stats_get_blog_id($api_key)
{
$options = stats_get_options();
require_once ABSPATH . WPINC . '/class-IXR.php';
$client = new IXR_Client(STATS_XMLRPC_SERVER);
extract(parse_url(get_option('home')));
$path = rtrim($path, '/');
if (empty($path)) {
$path = '/';
}
$client->query('wpStats.get_blog_id', $api_key, stats_get_blog());
if ($client->isError()) {
if ($client->getErrorCode() == -32300) {
$options['error'] = __('Your blog was unable to connect to WordPress.com. Please ask your host for help. (' . $client->getErrorMessage() . ')', 'stats');
} else {
$options['error'] = $client->getErrorMessage();
}
stats_set_options($options);
return false;
} else {
$options['error'] = false;
}
$response = $client->getResponse();
$blog_id = isset($response['blog_id']) ? (int) $response['blog_id'] : false;
$options['host'] = $host;
$options['path'] = $path;
$options['blog_id'] = $blog_id;
stats_set_options($options);
stats_set_api_key($api_key);
return $blog_id;
}