Permalink
Browse files

Updated other Ajax calls.

  • Loading branch information...
1 parent e5f4594 commit ea80f2ec43c695c1173e6c2e1174c6e719733657 @mvied committed Feb 3, 2013
@@ -56,8 +56,6 @@
</tr>
</table>
-<input type="hidden" name="action" value="wphttps-domain-mapping" />
-
<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" />
@@ -66,14 +64,15 @@
</form>
<script type="text/javascript">
jQuery(document).ready(function($) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_form').submit(function() {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_form .submit-waiting').show();
- }).ajaxForm({
- data: { ajax: '1'},
- success: function(responseText, textStatus, XMLHttpRequest) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_form .submit-waiting').hide();
- $('#message-body').html(responseText).fadeOut(0).fadeIn().delay(5000).fadeOut();
- }
+ $('#<?php echo $this->getPlugin()->getSlug(); ?>_domain_mapping_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();
+ $('#message-body').html(response).fadeOut(0).fadeIn().delay(5000).fadeOut();
+ });
});
if ( $('#domain_mapping tr').length <= 1 ) {
@@ -11,7 +11,7 @@
</td>
</tr>
</table>
-<input type="hidden" name="action" value="wphttps-filters" />
+
<p class="button-controls">
<input type="submit" name="filters-save" value="<?php _e('Save Changes','wordpress-https'); ?>" class="button-primary" id="filters-save" />
<input type="submit" name="filters-reset" value="<?php _e('Reset','wordpress-https'); ?>" class="button-secondary" id="filters-reset" />
@@ -21,13 +21,15 @@
<script type="text/javascript">
jQuery(document).ready(function($) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form').submit(function() {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form .submit-waiting').show();
- }).ajaxForm({
- success: function(responseText, textStatus, XMLHttpRequest) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form .submit-waiting').hide();
- $('#message-body').html(responseText).fadeOut(0).fadeIn().delay(5000).fadeOut();
- }
+ $('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_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();
+ $('#message-body').html(response).fadeOut(0).fadeIn().delay(5000).fadeOut();
+ });
});
$('#filters-reset').click(function(e, el) {
@@ -1,4 +1,4 @@
-<form name="<?php echo $this->getPlugin()->getSlug(); ?>_settings_form" id="<?php echo $this->getPlugin()->getSlug(); ?>_settings_form" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
+<form name="<?php echo $this->getPlugin()->getSlug(); ?>_network_settings_form" id="<?php echo $this->getPlugin()->getSlug(); ?>_network_settings_form" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
<?php settings_fields($this->getPlugin()->getSlug()); ?>
<table id="blog-table">
@@ -80,22 +80,22 @@
</table>
-<input type="hidden" name="action" value="wphttps-network" />
-
<p class="button-controls">
<input type="submit" name="network-settings-save" value="<?php _e('Save Changes','wordpress-https'); ?>" class="button-primary" id="network-settings-save" />
<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(); ?>_settings_form').submit(function() {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form .submit-waiting').show();
- }).ajaxForm({
- success: function(responseText, textStatus, XMLHttpRequest) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form .submit-waiting').hide();
- $('#message-body').html(responseText).fadeOut(0).fadeIn().delay(5000).fadeOut();
- }
+ $('#<?php echo $this->getPlugin()->getSlug(); ?>_network_settings_form').submit(function(e) {
+ e.preventDefault();
+ var form = this;
+ $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_network_settings');
+ $(form).find('.submit-waiting').show();
+ $.post(ajaxurl, $(form).serialize(), function(response) {
+ $(form).find('.submit-waiting').hide();
+ $('#message-body').html(response).fadeOut(0).fadeIn().delay(5000).fadeOut();
+ });
});
});
</script>
@@ -113,10 +113,11 @@
jQuery(document).ready(function($) {
$('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form').submit(function(e) {
e.preventDefault();
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_settings');
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form .submit-waiting').show();
- $.post(ajaxurl, $('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form').serialize(), function(response) {
- $('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form .submit-waiting').hide();
+ var form = this;
+ $(form).find('input[name="action"]').val('<?php echo $this->getPlugin()->getSlug(); ?>_settings');
+ $(form).find('.submit-waiting').show();
+ $.post(ajaxurl, $(form).serialize(), function(response) {
+ $(form).find('.submit-waiting').hide();
$('#message-body').html(response).fadeOut(0).fadeIn().delay(5000).fadeOut();
});
});
@@ -18,13 +18,12 @@ class WordPressHTTPS_Module_DomainMapping extends Mvied_Plugin_Module {
* @return void
*/
public function init() {
- if ( is_admin() && isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false ) {
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'wphttps-domain-mapping' ) {
- add_action('plugins_loaded', array(&$this, 'save'), 1);
+ if ( is_admin() ) {
+ add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_domain_mapping', array(&$this, 'save'));
+ if ( isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false ) {
+ // Add meta boxes
+ add_action('admin_init', array(&$this, 'add_meta_boxes'));
}
-
- // Add meta boxes
- add_action('admin_init', array(&$this, 'add_meta_boxes'));
}
// Custom filter https_external_url
@@ -18,13 +18,9 @@ class WordPressHTTPS_Module_Network extends Mvied_Plugin_Module {
* @return void
*/
public function init() {
- if ( is_admin() && isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false ) {
- // Network admin
- if ( strpos($_SERVER['REQUEST_URI'], 'wp-admin/network') !== false ) {
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'wphttps-network' ) {
- add_action('plugins_loaded', array(&$this, 'save'), 1);
- }
-
+ if ( is_admin() ) {
+ add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_network_settings', array(&$this, 'save'));
+ if ( isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false && strpos($_SERVER['REQUEST_URI'], 'wp-admin/network') !== false ) {
// Add meta boxes
add_action('admin_init', array(&$this, 'add_meta_boxes'));
@@ -18,13 +18,12 @@ class WordPressHTTPS_Module_UrlFilters extends Mvied_Plugin_Module {
* @return void
*/
public function init() {
- if ( is_admin() && isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false ) {
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'wphttps-filters' ) {
- add_action('plugins_loaded', array(&$this, 'save'), 1);
+ if ( is_admin() ) {
+ add_action('wp_ajax_' . $this->getPlugin()->getSlug() . '_url_filters', array(&$this, 'save'));
+ if ( isset($_GET['page']) && strpos($_GET['page'], $this->getPlugin()->getSlug()) !== false ) {
+ // Add meta boxes
+ add_action('admin_init', array(&$this, 'add_meta_boxes'));
}
-
- // Add meta boxes
- add_action('admin_init', array(&$this, 'add_meta_boxes'));
}
add_filter('force_ssl', array(&$this, 'secure_filter_url'), 10, 3);

0 comments on commit ea80f2e

Please sign in to comment.