Skip to content

Commit

Permalink
Allow 'Save All Changes' from Plugin Updater instead of forcing update
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Apr 8, 2016
1 parent 797f967 commit 7e2b1d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/includes/classes/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,22 @@ protected function proUpdate($args)
if (empty($args['password'])) {
$args['password'] = $this->plugin->options['pro_update_password'];
}

if ($args['update'] === '0') { // We're only saving the options, not updating.
$this->plugin->updateOptions([
'pro_update_check' => $args['check'],
'pro_update_check_stable' => $args['check_stable'],
'pro_update_username' => $args['username'],
'pro_update_password' => $args['password'],
]);

$redirect_to = self_admin_url('/admin.php'); // Redirect preparations.
$query_args = ['page' => GLOBAL_NS.'-pro-updater', GLOBAL_NS.'_updated' => '1'];
$redirect_to = add_query_arg(urlencode_deep($query_args), $redirect_to);

wp_redirect($redirect_to).exit();
}

$product_api_url = 'https://'.urlencode(DOMAIN).'/';
$product_api_input_vars = [
'product_api' => [
Expand Down
9 changes: 7 additions & 2 deletions src/includes/classes/MenuPageProUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct()

echo '<div class="plugin-menu-page-heading">'."\n";

echo ' <button type="submit" style="float:right;">'.sprintf(__('Update %1$s Now', SLUG_TD), esc_html(NAME)).' <i class="si si-magic"></i></button>'."\n";
echo ' <button type="submit" name="'.esc_attr(GLOBAL_NS).'[proUpdate][update]" value="1" style="float:right;">'.sprintf(__('Update %1$s Now', SLUG_TD), esc_html(NAME)).' <i class="si si-magic"></i></button>'."\n";

echo ' <div class="plugin-menu-page-panel-togglers" title="'.esc_attr(__('All Panels', SLUG_TD)).'">'."\n";
echo ' <button type="button" class="plugin-menu-page-panels-open"><i class="si si-chevron-down"></i></button>'."\n";
Expand Down Expand Up @@ -84,6 +84,11 @@ public function __construct()

/* ----------------------------------------------------------------------------------------- */

if (!empty($_REQUEST[GLOBAL_NS.'_updated'])) {
echo '<div class="plugin-menu-page-notice notice">'."\n";
echo ' <i class="si si-thumbs-up"></i> '.__('Options updated successfully.', SLUG_TD)."\n";
echo '</div>'."\n";
}
if (!empty($_REQUEST[GLOBAL_NS.'_error'])) {
echo '<div class="plugin-menu-page-error error">'."\n";
echo ' <i class="si si-thumbs-down"></i> '.esc_html(stripslashes((string) $_REQUEST[GLOBAL_NS.'_error']))."\n";
Expand Down Expand Up @@ -160,7 +165,7 @@ public function __construct()
/* ----------------------------------------------------------------------------------------- */

echo '<div class="plugin-menu-page-save">'."\n";
echo ' <button type="submit">'.sprintf(__('Update %1$s Now', SLUG_TD), esc_html(NAME)).' <i class="si si-magic"></i></button>'."\n";
echo ' <button type="submit" name="'.esc_attr(GLOBAL_NS).'[proUpdate][update]" value="0">'.__('Save All Changes', SLUG_TD).' <i class="si si-save"></i></button>'."\n";
echo '</div>'."\n";

/* ----------------------------------------------------------------------------------------- */
Expand Down

0 comments on commit 7e2b1d2

Please sign in to comment.