本文整理汇总了PHP中MainWP_Utility::update_option方法的典型用法代码示例。如果您正苦于以下问题:PHP MainWP_Utility::update_option方法的具体用法?PHP MainWP_Utility::update_option怎么用?PHP MainWP_Utility::update_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWP_Utility
的用法示例。
在下文中一共展示了MainWP_Utility::update_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleSettingsPost
public static function handleSettingsPost()
{
if (isset($_POST['submit'])) {
$userExtension = MainWP_DB::Instance()->getUserExtension();
$userExtension->user_email = $_POST['mainwp_options_email'];
$userExtension->site_view = !isset($_POST['mainwp_options_siteview']) ? 0 : 1;
$userExtension->heatMap = !isset($_POST['mainwp_options_footprint_heatmap']) ? 1 : 0;
$userExtension->pluginDir = isset($_POST['mainwp_options_footprint_plugin_folder']) ? $_POST['mainwp_options_footprint_plugin_folder'] : 'default';
MainWP_DB::Instance()->updateUserExtension($userExtension);
if (MainWP_Utility::isAdmin()) {
MainWP_Utility::update_option('mainwp_optimize', !isset($_POST['mainwp_optimize']) ? 0 : 1);
MainWP_Utility::update_option('mainwp_seo', !isset($_POST['mainwp_seo']) ? 0 : 1);
$val = !isset($_POST['mainwp_automaticDailyUpdate']) ? 2 : $_POST['mainwp_automaticDailyUpdate'];
MainWP_Utility::update_option('mainwp_automaticDailyUpdate', $val);
$val = !isset($_POST['mainwp_backup_before_upgrade']) ? 0 : 1;
MainWP_Utility::update_option('mainwp_backup_before_upgrade', $val);
MainWP_Utility::update_option('mainwp_maximumPosts', $_POST['mainwp_maximumPosts']);
MainWP_Utility::update_option('mainwp_maximumComments', $_POST['mainwp_maximumComments']);
MainWP_Utility::update_option('mainwp_wp_cron', !isset($_POST['mainwp_options_wp_cron']) ? 0 : 1);
//MainWP_Utility::update_option('mainwp_use_favicon', (!isset($_POST['mainwp_use_favicon']) ? 0 : 1));
MainWP_Utility::update_option('mainwp_numberdays_Outdate_Plugin_Theme', $_POST['mainwp_numberdays_Outdate_Plugin_Theme']);
}
return true;
}
return false;
}
示例2: disableExtension
public static function disableExtension()
{
$snEnabledExtensions = get_option('mainwp_extloaded');
if (!is_array($snEnabledExtensions)) {
$snEnabledExtensions = array();
}
$key = array_search($_POST['slug'], $snEnabledExtensions);
if ($key != false) {
unset($snEnabledExtensions[$key]);
}
MainWP_Utility::update_option('mainwp_extloaded', $snEnabledExtensions);
die(json_encode(array('result' => 'SUCCESS')));
}
示例3: renderAdvanced
public static function renderAdvanced()
{
if (!mainwp_current_user_can('dashboard', 'manage_dashboard_settings')) {
mainwp_do_not_have_permissions(__('manage dashboard settings', 'mainwp'));
return;
}
if (isset($_POST['submit'])) {
MainWP_Utility::update_option('mainwp_maximumRequests', $_POST['mainwp_maximumRequests']);
MainWP_Utility::update_option('mainwp_minimumDelay', $_POST['mainwp_minimumDelay']);
MainWP_Utility::update_option('mainwp_maximumIPRequests', $_POST['mainwp_maximumIPRequests']);
MainWP_Utility::update_option('mainwp_minimumIPDelay', $_POST['mainwp_minimumIPDelay']);
MainWP_Utility::update_option('mainwp_sslVerifyCertificate', isset($_POST['mainwp_sslVerifyCertificate']) ? 1 : 0);
}
self::renderHeader('Advanced');
?>
<form method="POST" action="" id="mainwp-settings-page-form">
<div class="postbox" id="mainwp-advanced-options">
<h3 class="mainwp_box_title">
<span><i class="fa fa-cog"></i> <?php
_e('Cross IP Settings', 'mainwp');
?>
</span></h3>
<div class="inside">
<table class="form-table">
<tbody>
<tr>
<th scope="row"><?php
_e('Maximum simultaneous requests', 'mainwp');
?>
<?php
MainWP_Utility::renderToolTip(__('Maximum simultaneous requests. When too many requests are sent out, they will begin to time out. This will cause child sites to be shown as offline while they are online. With a typical shared host you should set this at 4, set to 0 for unlimited.', 'mainwp'));
?>
</th>
<td>
<input type="text" name="mainwp_maximumRequests" class=""
id="mainwp_maximumRequests" value="<?php
echo get_option('mainwp_maximumRequests') === false ? 4 : get_option('mainwp_maximumRequests');
?>
"/>
<i>Default: 4</i>
</td>
</tr>
<tr>
<th scope="row"><?php
_e('Minimum delay between requests (milliseconds)', 'mainwp');
?>
<?php
MainWP_Utility::renderToolTip(__('Minimum delay between requests (milliseconds). With a typical shared host you should set this at 200.', 'mainwp'));
?>
</th>
<td>
<input type="text" name="mainwp_minimumDelay" class=""
id="mainwp_minimumDelay" value="<?php
echo get_option('mainwp_minimumDelay') === false ? 200 : get_option('mainwp_minimumDelay');
?>
"/>
<i>Default: 200</i>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="postbox" id="mainwp-advanced-options">
<h3 class="mainwp_box_title">
<span><i class="fa fa-cog"></i> <?php
_e('IP Settings', 'mainwp');
?>
</span></h3>
<div class="inside">
<table class="form-table">
<tbody>
<tr>
<th scope="row"><?php
_e('Maximum simultaneous requests per ip', 'mainwp');
?>
<?php
MainWP_Utility::renderToolTip(__('Maximum simultaneous requests per IP. When too many requests are sent out, they will begin to time out. This will cause child sites to be shown as offline while they are online. With a typical shared host you should set this at 1, set to 0 for unlimited.', 'mainwp'));
?>
</th>
<td>
<input type="text" name="mainwp_maximumIPRequests" class=""
id="mainwp_maximumIPRequests" value="<?php
echo get_option('mainwp_maximumIPRequests') === false ? 1 : get_option('mainwp_maximumIPRequests');
?>
"/>
<i>Default: 1</i>
</td>
</tr>
<tr>
<th scope="row"><?php
_e('Minimum delay between requests to the same ip (milliseconds)', 'mainwp');
?>
<?php
MainWP_Utility::renderToolTip(__('Minimum delay between requests (milliseconds) per IP. With a typical shared host you should set this at 1000.', 'mainwp'));
?>
</th>
//.........这里部分代码省略.........
示例4: removeExtensionMenuFromMainWPMenu
public static function removeExtensionMenuFromMainWPMenu()
{
$snMenuExtensions = get_option('mainwp_extmenu');
if (!is_array($snMenuExtensions)) {
$snMenuExtensions = array();
}
$key = array_search($_POST['slug'], $snMenuExtensions);
if ($key !== false) {
unset($snMenuExtensions[$key]);
}
MainWP_Utility::update_option('mainwp_extmenu', $snMenuExtensions);
die(json_encode(array('result' => 'SUCCESS')));
}
示例5: activation
function activation()
{
delete_option('mainwp_requests');
MainWP_DB::Instance()->update();
MainWP_DB::Instance()->install();
//Redirect to settings page
MainWP_Utility::update_option('mainwp_activated', 'yes');
}
示例6: testloginapi
public function testloginapi($args)
{
$defaults = array('request' => 'testloginapi');
$args = wp_parse_args($defaults, $args);
$target_url = self::create_software_api_url($args);
$request = wp_remote_get($target_url, array('timeout' => 50, 'sslverify' => self::$apisslverify));
// $request = wp_remote_post( MainWP_Api_Manager::instance()->getUpgradeUrl() . 'wc-api/am-software-api/', array('body' => $args) );
if (is_wp_error($request)) {
if (self::$apisslverify == 1) {
MainWP_Utility::update_option('mainwp_api_sslVerifyCertificate', 0);
return array('retry_action' => 1);
}
throw new Exception($request->get_error_message());
return false;
}
$code = wp_remote_retrieve_response_code($request);
if ($code != 200) {
throw new Exception('Error: code ' . $code);
return false;
}
$response = wp_remote_retrieve_body($request);
return $response;
}
示例7: prepare_items
function prepare_items($globalIgnoredPluginConflicts = array(), $globalIgnoredThemeConflicts = array())
{
$this->globalIgnoredPluginConflicts = $globalIgnoredPluginConflicts;
$this->globalIgnoredThemeConflicts = $globalIgnoredThemeConflicts;
$orderby = 'wp.url';
if (!isset($_GET['orderby'])) {
$_order_by = get_option('mainwp_managesites_orderby');
$_order = get_option('mainwp_managesites_order');
if (!empty($_order_by)) {
$_GET['orderby'] = $_order_by;
$_GET['order'] = $_order;
}
} else {
MainWP_Utility::update_option('mainwp_managesites_orderby', $_GET['orderby']);
MainWP_Utility::update_option('mainwp_managesites_order', $_GET['order']);
}
if (isset($_GET['orderby'])) {
if ($_GET['orderby'] == 'site') {
$orderby = 'wp.name ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc');
} else {
if ($_GET['orderby'] == 'url') {
$orderby = 'wp.url ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc');
} else {
if ($_GET['orderby'] == 'group') {
$orderby = 'GROUP_CONCAT(gr.name ORDER BY gr.name SEPARATOR ", ") ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc');
} else {
if ($_GET['orderby'] == 'status') {
$orderby = 'CASE true
WHEN ((pluginConflicts <> "[]") AND (pluginConflicts IS NOT NULL) AND (pluginConflicts <> ""))
THEN 1
WHEN (offline_check_result = -1)
THEN 2
WHEN (wp_sync.sync_errors IS NOT NULL) AND (wp_sync.sync_errors <> "")
THEN 3
ELSE 4
+ (CASE plugin_upgrades WHEN "[]" THEN 0 ELSE 1 + LENGTH(plugin_upgrades) - LENGTH(REPLACE(plugin_upgrades, "\\"Name\\":", "\\"Name\\"")) END)
+ (CASE theme_upgrades WHEN "[]" THEN 0 ELSE 1 + LENGTH(theme_upgrades) - LENGTH(REPLACE(theme_upgrades, "\\"Name\\":", "\\"Name\\"")) END)
+ (CASE wp_upgrades WHEN "[]" THEN 0 ELSE 1 END)
END ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc');
} else {
if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'last_post') {
$orderby = 'wp_sync.last_post_gmt ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc');
}
}
}
}
}
}
$perPage = $this->get_items_per_page('mainwp_managesites_per_page');
$currentPage = $this->get_pagenum();
$no_request = !isset($_REQUEST['s']) && !isset($_REQUEST['g']) && !isset($_REQUEST['status']);
if (!isset($_REQUEST['status'])) {
if ($no_request) {
$_status = get_option('mainwp_managesites_filter_status');
if (!empty($_status)) {
$_REQUEST['status'] = $_status;
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_status', '');
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_status', $_REQUEST['status']);
}
if (!isset($_REQUEST['g'])) {
if ($no_request) {
$_g = get_option('mainwp_managesites_filter_group');
if (!empty($_g)) {
$_REQUEST['g'] = $_g;
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_group', '');
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_group', $_REQUEST['g']);
}
$where = null;
if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') {
if ($_REQUEST['status'] == 'online') {
$where = 'wp.offline_check_result = 1';
} else {
if ($_REQUEST['status'] == 'offline') {
$where = 'wp.offline_check_result = -1';
} else {
if ($_REQUEST['status'] == 'disconnected') {
$where = 'wp_sync.sync_errors != ""';
} else {
if ($_REQUEST['status'] == 'update') {
$available_update_ids = $this->get_available_update_siteids();
if (empty($available_update_ids)) {
$where = 'wp.id = -1';
} else {
$where = 'wp.id IN (' . implode(',', $available_update_ids) . ') ';
}
}
}
}
}
}
if (isset($_REQUEST['g']) && $_REQUEST['g'] != '') {
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($_REQUEST['g'], true));
//.........这里部分代码省略.........
示例8: renderActionLogs
public static function renderActionLogs()
{
self::renderHeader('Action logs');
if (isset($_REQUEST['actionlogs_status'])) {
if ($_REQUEST['actionlogs_status'] != MainWP_Logger::DISABLED) {
MainWP_Logger::Instance()->setLogPriority($_REQUEST['actionlogs_status']);
}
MainWP_Logger::Instance()->log('Action logs set to: ' . MainWP_Logger::Instance()->getLogText($_REQUEST['actionlogs_status']), MainWP_Logger::LOG);
if ($_REQUEST['actionlogs_status'] == MainWP_Logger::DISABLED) {
MainWP_Logger::Instance()->setLogPriority($_REQUEST['actionlogs_status']);
}
MainWP_Utility::update_option('mainwp_actionlogs', $_REQUEST['actionlogs_status']);
}
$enabled = get_option('mainwp_actionlogs');
if ($enabled === false) {
$enabled = MainWP_Logger::DISABLED;
}
?>
<div class="postbox" id="mainwp-code-display">
<h3 class="hndle" style="padding: 8px 12px; font-size: 14px;"><span>Action logs</span></h3>
<div style="padding: 1em;">
<form method="POST" action="">
Status:
<select name="actionlogs_status">
<option value="<?php
echo MainWP_Logger::DISABLED;
?>
" <?php
if (MainWP_Logger::DISABLED == $enabled) {
echo 'selected';
}
?>
>Disabled
</option>
<option value="<?php
echo MainWP_Logger::WARNING;
?>
" <?php
if (MainWP_Logger::WARNING == $enabled) {
echo 'selected';
}
?>
>Warning
</option>
<option value="<?php
echo MainWP_Logger::INFO;
?>
" <?php
if (MainWP_Logger::INFO == $enabled) {
echo 'selected';
}
?>
>Info
</option>
<option value="<?php
echo MainWP_Logger::DEBUG;
?>
" <?php
if (MainWP_Logger::DEBUG == $enabled) {
echo 'selected';
}
?>
>Debug
</option>
</select> <input type="submit" class="button button-primary" value="Save"/>
</form>
</div>
<div style="padding: 1em;"><?php
MainWP_Logger::showLog();
?>
</div>
</div>
<?php
self::renderFooter('Action logs');
}
示例9: secure_request
function secure_request($action = '', $query_arg = 'security')
{
if (!MainWP_Utility::isAdmin()) {
die(0);
}
if ($action == '') {
return;
}
if (!$this->check_security($action, $query_arg)) {
die(json_encode(array('error' => 'Invalid request')));
}
if (isset($_POST['dts'])) {
$ajaxPosts = get_option('mainwp_ajaxposts');
if (!is_array($ajaxPosts)) {
$ajaxPosts = array();
}
//If already processed, just quit!
if (isset($ajaxPosts[$action]) && $ajaxPosts[$action] == $_POST['dts']) {
die(json_encode(array('error' => 'Double request')));
}
$ajaxPosts[$action] = $_POST['dts'];
MainWP_Utility::update_option('mainwp_ajaxposts', $ajaxPosts);
}
}
示例10: post_update
function post_update()
{
$currentVersion = get_site_option('mainwp_db_version');
if ($currentVersion === false) {
return;
}
if (version_compare($currentVersion, '2.8', '<')) {
$this->wpdb->update($this->tableName('wp_backup'), array('subfolder' => 'MainWP Backups/%url%/%type%/%date%'), array('template' => '0'));
}
if (version_compare($currentVersion, '4.3', '<')) {
$row = $this->wpdb->get_row('SELECT * FROM ' . $this->tableName('users'), OBJECT);
if ($row != null) {
$row->userid = 0;
$this->updateUserExtension($row);
}
}
if (version_compare($currentVersion, '5.3', '<')) {
if (MainWP_System::Instance()->isSingleUser()) {
$row = $this->wpdb->get_row('SELECT * FROM ' . $this->tableName('ga'), OBJECT);
$this->wpdb->update($this->tableName('ga'), array('userid' => 0), array('userid' => $row->userid));
}
}
if (version_compare($currentVersion, '6.0', '=')) {
$this->wpdb->query('ALTER TABLE ' . $this->tableName('request_log') . ' CHANGE micro_timestamp_stop micro_timestamp_stop DECIMAL( 12, 2 ) NOT NULL DEFAULT 0');
$this->wpdb->query('ALTER TABLE ' . $this->tableName('request_log') . ' CHANGE micro_timestamp_start micro_timestamp_start DECIMAL( 12, 2 ) NOT NULL DEFAULT 0');
$this->wpdb->query('DELETE FROM ' . $this->tableName('request_log') . ' WHERE 1 ');
}
if (version_compare($currentVersion, '6.2', '<')) {
$options = array('mainwp_db_version', 'mainwp_requests', 'mainwp_plugin_version', 'mainwp_upgradeVersionInfo', 'mainwp_cron_last_offlinecheck', 'mainwp_cron_last_updatescheck', 'mainwp_automaticUpdate_backupChecks', 'mainwp_updatescheck_mail_update_core_new', 'mainwp_updatescheck_mail_update_plugins_new', 'mainwp_updatescheck_mail_update_themes_new', 'mainwp_updatescheck_mail_update_core', 'mainwp_updatescheck_mail_update_plugins', 'mainwp_updatescheck_mail_update_themes', 'mainwp_updatescheck_mail_ignore_core', 'mainwp_updatescheck_mail_ignore_plugins', 'mainwp_updatescheck_mail_ignore_themes', 'mainwp_updatescheck_mail_ignore_core_new', 'mainwp_updatescheck_mail_ignore_plugins_new', 'mainwp_updatescheck_mail_ignore_themes_new', 'mainwp_updatescheck_mail_pluginconflicts', 'mainwp_updatescheck_mail_themeconflicts', 'mainwp_updatescheck_last', 'mainwp_updatescheck_mail_email', 'mainwp_cron_last_ping', 'mainwp_cron_last_cronconflicts', 'mainwp_pluginConflicts', 'mainwp_themeConflicts', 'mainwp_cron_last_backups_continue', 'mainwp_cron_last_backups', 'mainwp_cron_last_stats', 'mainwp_backupsOnServer', 'mainwp_maximumFileDescriptors', 'mainwp_backupOnExternalSources', 'mainwp_notificationOnBackupFail', 'mainwp_notificationOnBackupStart', 'mainwp_chunkedBackupTasks', 'mainwp_maximumRequests', 'mainwp_minimumDelay', 'mainwp_maximumIPRequests', 'mainwp_minimumIPDelay', 'mainwp_extensions', 'mainwp_extloaded', 'mainwp_api_username', 'mainwp_api_password', 'mainwp_extension_widget_view', 'mainwp_news', 'mainwp_news_timestamp', 'mainwp_optimize', 'mainwp_seo', 'mainwp_automaticDailyUpdate', 'mainwp_backup_before_upgrade', 'mainwp_maximumPosts', 'mainwp_maximumComments', 'mainwp_cron_jobs', 'mainwp_wp_cron');
foreach ($options as $option) {
MainWP_Utility::fix_option($option);
}
}
if (version_compare($currentVersion, '7.3', '<')) {
//get all sites
$sites = $this->wpdb->get_results('SELECT id FROM ' . $this->tableName('wp'));
if (!empty($sites)) {
foreach ($sites as $site) {
$this->wpdb->insert($this->tableName('wp_settings_backup'), array('wpid' => $site->id, 'archiveFormat' => 'global'));
}
}
}
if (version_compare($currentVersion, '8', '<')) {
$apiPass = get_option('mainwp_api_password');
MainWP_Utility::update_option('mainwp_api_password', MainWP_Utility::encrypt($apiPass, 'MainWPAPI'));
}
if (version_compare($currentVersion, '8.1', '<')) {
//We can't split up here!
$wpSyncColumns = array('version', 'totalsize', 'dbsize', 'extauth', 'last_post_gmt', 'uptodate', 'sync_errors', 'dtsSync', 'dtsSyncStart', 'dtsAutomaticSync', 'dtsAutomaticSyncStart');
foreach ($wpSyncColumns as $wpSyncColumn) {
$rslts = $this->wpdb->get_results('SELECT id,' . $wpSyncColumn . ' FROM ' . $this->tableName('wp'), ARRAY_A);
if (empty($rslts)) {
continue;
}
foreach ($rslts as $rslt) {
$exists = $this->wpdb->get_results('SELECT wpid FROM ' . $this->tableName('wp_sync') . ' WHERE wpid = ' . $rslt['id'], ARRAY_A);
if (empty($exists)) {
$this->wpdb->insert($this->tableName('wp_sync'), array('wpid' => $rslt['id'], $wpSyncColumn => $rslt[$wpSyncColumn]));
} else {
$this->wpdb->update($this->tableName('wp_sync'), array($wpSyncColumn => $rslt[$wpSyncColumn]), array('wpid' => $rslt['id']));
}
}
$suppress = $this->wpdb->suppress_errors();
$this->wpdb->query('ALTER TABLE ' . $this->tableName('wp') . ' DROP COLUMN ' . $wpSyncColumn);
$this->wpdb->suppress_errors($suppress);
}
$optionColumns = array('last_wp_upgrades', 'last_plugin_upgrades', 'last_theme_upgrades', 'wp_upgrades', 'recent_comments', 'recent_posts', 'recent_pages');
foreach ($optionColumns as $optionColumn) {
$rslts = $this->wpdb->get_results('SELECT id,' . $optionColumn . ' FROM ' . $this->tableName('wp'), ARRAY_A);
if (empty($rslts)) {
continue;
}
foreach ($rslts as $rslt) {
MainWP_DB::updateWebsiteOption((object) $rslt, $optionColumn, $rslt[$optionColumn]);
}
$suppress = $this->wpdb->suppress_errors();
$this->wpdb->query('ALTER TABLE ' . $this->tableName('wp') . ' DROP COLUMN ' . $optionColumn);
$this->wpdb->suppress_errors($suppress);
}
}
}
示例11: resetUserCookie
public static function resetUserCookie($what, $value = '')
{
global $current_user;
if ($user_id = $current_user->ID) {
$reset_cookies = get_option('mainwp_reset_user_cookies');
if (!is_array($reset_cookies)) {
$reset_cookies = array();
}
if (!isset($reset_cookies[$user_id]) || !isset($reset_cookies[$user_id][$what])) {
$reset_cookies[$user_id][$what] = 1;
MainWP_Utility::update_option('mainwp_reset_user_cookies', $reset_cookies);
update_user_option($user_id, 'mainwp_saved_user_cookies', array());
return false;
}
$user_cookies = get_user_option('mainwp_saved_user_cookies');
if (!is_array($user_cookies)) {
$user_cookies = array();
}
if (!isset($user_cookies[$what])) {
return false;
}
}
return true;
}
示例12: mwp_setup_hide_wp_menu_save
public function mwp_setup_hide_wp_menu_save()
{
check_admin_referer('mwp-setup');
$hide_menus = array();
if (isset($_POST['mainwp_hide_wpmenu']) && is_array($_POST['mainwp_hide_wpmenu']) && count($_POST['mainwp_hide_wpmenu']) > 0) {
foreach ($_POST['mainwp_hide_wpmenu'] as $value) {
$hide_menus[] = $value;
}
}
MainWP_Utility::update_option('mwp_setup_hide_wp_menus', $hide_menus);
wp_redirect($this->get_next_step_link());
exit;
}
示例13: changeDefaultView
public static function changeDefaultView()
{
if (!isset($_POST['view'])) {
throw new Exception(__('Invalid Request', 'mainwp'));
}
if ($_POST['view'] == 'list') {
MainWP_Utility::update_option('mainwp_extension_widget_view', 'list');
} else {
MainWP_Utility::update_option('mainwp_extension_widget_view', 'grid');
}
return array('result' => 'SUCCESS');
}
示例14: grab_license_key
public function grab_license_key($api, $username, $password)
{
$options = get_option($api . '_APIManAdder');
if (!is_array($options)) {
$options = array();
}
$activation_status = isset($options['activated_key']) ? $options['activated_key'] : '';
$api_key = isset($options['api_key']) ? $options['api_key'] : '';
$api_email = isset($options['activation_email']) ? $options['activation_email'] : '';
if ($activation_status == 'Deactivated' || $activation_status == '' || $api_key == '' || $api_email == '') {
$return = array();
if ($username != '' && $password != '') {
$args = array('username' => $username, 'password' => $password, 'product_id' => $options['product_id'], 'instance' => $options['instance_id'], 'software_version' => $options['software_version'], 'platform' => $this->domain);
$activate_results = json_decode(MainWP_Api_Manager_Key::instance()->grabapikey($args), true);
$options['api_key'] = '';
$options['activation_email'] = '';
$options['activated_key'] = 'Deactivated';
if (is_array($activate_results) && $activate_results['activated'] == true && !empty($activate_results['api_key'])) {
$return['result'] = 'SUCCESS';
$mess = isset($activate_results['message']) ? $activate_results['message'] : '';
$return['message'] = __('Plugin activated. ', 'mainwp') . $mess;
$options['api_key'] = $return['api_key'] = $activate_results['api_key'];
$options['activation_email'] = $return['activation_email'] = $activate_results['activation_email'];
$options['activated_key'] = 'Activated';
$options['deactivate_checkbox'] = 'off';
} else {
if ($activate_results == false) {
$return['error'] = __('Connection failed to the License Key API server. Try again later.', "mainwp");
} else {
if (isset($activate_results['error'])) {
$return['error'] = $activate_results['error'];
} else {
if (empty($activate_results['api_key'])) {
$return['error'] = __('License key is empty.', 'mainwp');
} else {
$return['error'] = __('Undefined error.', 'mainwp');
}
}
}
}
if (isset($activate_results['code'])) {
switch ($activate_results['code']) {
case '100':
case '101':
case '102':
case '103':
case '104':
case '105':
case '106':
$error = isset($activate_results['error']) ? $activate_results['error'] : '';
$info = isset($activate_results['additional info']) ? ' ' . $activate_results['additional info'] : '';
$return['error'] = $error . $info;
break;
}
}
MainWP_Utility::update_option($api . '_APIManAdder', $options);
return $return;
} else {
return array('error' => __('Username and Password is required to grab Extension API Key.', 'mainwp'));
}
}
return array('result' => 'SUCCESS');
}
示例15: handleSettingsPost
public static function handleSettingsPost()
{
if (MainWP_Utility::isAdmin()) {
if (isset($_POST['submit'])) {
if (MainWP_Utility::ctype_digit($_POST['mainwp_options_backupOnServer']) && $_POST['mainwp_options_backupOnServer'] > 0) {
MainWP_Utility::update_option('mainwp_backupsOnServer', $_POST['mainwp_options_backupOnServer']);
}
if (MainWP_Utility::ctype_digit($_POST['mainwp_options_maximumFileDescriptors']) && $_POST['mainwp_options_maximumFileDescriptors'] > -1) {
MainWP_Utility::update_option('mainwp_maximumFileDescriptors', $_POST['mainwp_options_maximumFileDescriptors']);
}
MainWP_Utility::update_option('mainwp_maximumFileDescriptorsAuto', !isset($_POST['mainwp_maximumFileDescriptorsAuto']) ? 0 : 1);
if (MainWP_Utility::ctype_digit($_POST['mainwp_options_backupOnExternalSources']) && $_POST['mainwp_options_backupOnExternalSources'] >= 0) {
MainWP_Utility::update_option('mainwp_backupOnExternalSources', $_POST['mainwp_options_backupOnExternalSources']);
}
MainWP_Utility::update_option('mainwp_archiveFormat', $_POST['mainwp_archiveFormat']);
if (isset($_POST['mainwp_primaryBackup']) && !empty($_POST['mainwp_primaryBackup'])) {
MainWP_Utility::update_option('mainwp_notificationOnBackupFail', 0);
MainWP_Utility::update_option('mainwp_notificationOnBackupStart', 0);
MainWP_Utility::update_option('mainwp_chunkedBackupTasks', 0);
} else {
MainWP_Utility::update_option('mainwp_options_loadFilesBeforeZip', !isset($_POST['mainwp_options_loadFilesBeforeZip']) ? 0 : 1);
MainWP_Utility::update_option('mainwp_notificationOnBackupFail', !isset($_POST['mainwp_options_notificationOnBackupFail']) ? 0 : 1);
MainWP_Utility::update_option('mainwp_notificationOnBackupStart', !isset($_POST['mainwp_options_notificationOnBackupStart']) ? 0 : 1);
MainWP_Utility::update_option('mainwp_chunkedBackupTasks', !isset($_POST['mainwp_options_chunkedBackupTasks']) ? 0 : 1);
}
return true;
}
}
return false;
}