Skip to content
Browse files

Fixed ajax calls for other metaboxes (again).

  • Loading branch information...
1 parent 1314009 commit 617d8b6df0b2ddbc68ddc5440aa89997f61f50ad @mvied committed Feb 5, 2013
View
2 admin/css/settings.css
@@ -90,7 +90,7 @@
#wphttps-main #settings-reset,
#wphttps-main #network-settings-reset,
#wphttps-main #filters-reset,
-#wphttps-main #domain_mapping-reset {
+#wphttps-main #domain-mapping-reset {
float: left;
margin-right: 10px;
}
View
15 admin/templates/metabox/domain_mapping.php
@@ -57,17 +57,22 @@
</table>
<p class="button-controls">
- <input type="submit" name="domain_mapping-save" value="<?php _e('Save Changes','wordpress-https'); ?>" class="button-primary" id="domain_mapping-save" />
- <input type="submit" name="domain_mapping-reset" value="<?php _e('Reset','wordpress-https'); ?>" class="button-secondary" id="domain_mapping-reset" />
+ <input type="submit" name="domain-mapping-save" value="<?php _e('Save Changes','wordpress-https'); ?>" class="button-primary" id="domain-mapping-save" />
+ <input type="submit" name="domain-mapping-reset" value="<?php _e('Reset','wordpress-https'); ?>" class="button-secondary" id="domain-mapping-reset" />
<img alt="<?php _e('Waiting...','wordpress-https'); ?>" src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting submit-waiting" />
</p>
</form>
<script type="text/javascript">
jQuery(document).ready(function($) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_form').submit(function(e) {
+ var form = $('#<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_form').first();
+ $('#domain-mapping-save').click(function() {
+ $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_save');
+ });
+ $('#domain-mapping-reset').click(function() {
+ $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_reset');
+ });
+ $(form).submit(function(e) {
e.preventDefault();
- var form = this;
- $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping');
$(form).find('.submit-waiting').show();
$.post(ajaxurl, $(form).serialize(), function(response) {
$(form).find('.submit-waiting').hide();
View
11 admin/templates/metabox/filters.php
@@ -21,10 +21,15 @@
<script type="text/javascript">
jQuery(document).ready(function($) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form').submit(function(e) {
+ var form = $('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form').first();
+ $('#filters-save').click(function() {
+ $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_filters_save');
+ });
+ $('#filters-reset').click(function() {
+ $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_filters_reset');
+ });
+ $(form).submit(function(e) {
e.preventDefault();
- var form = this;
- $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_url_filters');
$(form).find('.submit-waiting').show();
$.post(ajaxurl, $(form).serialize(), function(response) {
$(form).find('.submit-waiting').hide();
View
44 lib/WordPressHTTPS/Module/DomainMapping.php
@@ -19,7 +19,8 @@ class WordPressHTTPS_Module_DomainMapping extends Mvied_Plugin_Module {
*/
public function init() {
if ( is_admin() ) {
- add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_domain_mapping', array(&$this, 'save'));
+ add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_domain_mapping_save', array(&$this, 'save'));
+ add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_domain_mapping_reset', array(&$this, 'reset'));
if ( isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false ) {
// Add meta boxes
add_action('admin_init', array(&$this, 'add_meta_boxes'));
@@ -67,6 +68,26 @@ public function add_meta_boxes() {
}
/**
+ * Reset Domain Mapping
+ *
+ * @param array $settings
+ * @return void
+ */
+ public function reset() {
+ if ( !wp_verify_nonce($_POST['_wpnonce'], $this->getPlugin()->getSlug() . '-options') ) {
+ return false;
+ }
+
+ $message = "Domain Mapping reset.";
+ $errors = array();
+ $reload = true;
+
+ $this->getPlugin()->setSetting('ssl_host_mapping', WordPressHTTPS::$ssl_host_mapping);
+
+ require_once($this->getPlugin()->getDirectory() . '/admin/templates/ajax_message.php');
+ }
+
+ /**
* Save Domain Mapping
*
* @param array $settings
@@ -80,23 +101,14 @@ public function save() {
$message = "Domain Mapping saved.";
$errors = array();
$reload = false;
- $logout = false;
- if ( isset($_POST['domain_mapping-save']) ) {
- $ssl_host_mapping = array();
- for( $i=0; $i<sizeof($_POST['http_domain']); $i++ ) {
- if ( isset($_POST['http_domain'][$i]) && $_POST['http_domain'][$i] != '' && isset($_POST['https_domain'][$i]) && $_POST['https_domain'][$i] != '' ) {
- $ssl_host_mapping[$_POST['http_domain'][$i]] = $_POST['https_domain'][$i];
- }
- }
- $this->getPlugin()->setSetting('ssl_host_mapping', $ssl_host_mapping);
- } else if ( isset($_POST['domain_mapping-reset']) ) {
- $this->getPlugin()->setSetting('ssl_host_mapping', WordPressHTTPS::$ssl_host_mapping);
- $reload = true;
- }
- if ( $logout ) {
- wp_logout();
+ $ssl_host_mapping = array();
+ for( $i=0; $i<sizeof($_POST['http_domain']); $i++ ) {
+ if ( isset($_POST['http_domain'][$i]) && $_POST['http_domain'][$i] != '' && isset($_POST['https_domain'][$i]) && $_POST['https_domain'][$i] != '' ) {
+ $ssl_host_mapping[$_POST['http_domain'][$i]] = $_POST['https_domain'][$i];
+ }
}
+ $this->getPlugin()->setSetting('ssl_host_mapping', $ssl_host_mapping);
require_once($this->getPlugin()->getDirectory() . '/admin/templates/ajax_message.php');
}
View
1 lib/WordPressHTTPS/Module/Settings.php
@@ -198,7 +198,6 @@ public function reset() {
$message = "Settings reset.";
$errors = array();
$reload = true;
- $logout = false;
foreach ($this->getPlugin()->getSettings() as $key => $default) {
$this->getPlugin()->setSetting($key, $default);
View
38 lib/WordPressHTTPS/Module/UrlFilters.php
@@ -19,7 +19,8 @@ class WordPressHTTPS_Module_UrlFilters extends Mvied_Plugin_Module {
*/
public function init() {
if ( is_admin() ) {
- add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_url_filters', array(&$this, 'save'));
+ add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_filters_save', array(&$this, 'save'));
+ add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_filters_reset', array(&$this, 'reset'));
if ( isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false ) {
// Add meta boxes
add_action('admin_init', array(&$this, 'add_meta_boxes'));
@@ -69,6 +70,26 @@ public function add_meta_boxes() {
}
/**
+ * Reset Url Filters
+ *
+ * @param array $settings
+ * @return void
+ */
+ public function reset() {
+ if ( !wp_verify_nonce($_POST['_wpnonce'], $this->getPlugin()->getSlug() . '-options') ) {
+ return false;
+ }
+
+ $message = "URL Filters reset.";
+ $errors = array();
+ $reload = true;
+
+ $this->getPlugin()->setSetting('secure_filter', array());
+
+ require_once($this->getPlugin()->getDirectory() . '/admin/templates/ajax_message.php');
+ }
+
+ /**
* Save Url Filters
*
* @param array $settings
@@ -82,19 +103,10 @@ public function save() {
$message = "URL Filters saved.";
$errors = array();
$reload = false;
- $logout = false;
- if ( isset($_POST['filters-save']) ) {
- $filters = array_map('trim', explode("\n", $_POST['secure_filter']));
- $filters = array_filter($filters); // Removes blank array items
- $this->getPlugin()->setSetting('secure_filter', $filters);
- } else if ( isset($_POST['filters-reset']) ) {
- $this->getPlugin()->setSetting('secure_filter', array());
- $reload = true;
- }
- if ( $logout ) {
- wp_logout();
- }
+ $filters = array_map('trim', explode("\n", $_POST['secure_filter']));
+ $filters = array_filter($filters); // Removes blank array items
+ $this->getPlugin()->setSetting('secure_filter', $filters);
require_once($this->getPlugin()->getDirectory() . '/admin/templates/ajax_message.php');
}

0 comments on commit 617d8b6

Please sign in to comment.
Something went wrong with that request. Please try again.