Version Description
- Initial release.
=
Download this release
Release Info
Developer | Nikschavan |
Plugin | Astra Customizer Reset |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- assets/js/customizer-reset.js +72 -0
- class-astra-theme-customizer-reset.php +135 -0
- readme.txt +27 -0
assets/js/customizer-reset.js
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Astra Theme Customizer Reset
|
3 |
+
*
|
4 |
+
* @package Astra Customizer Reset
|
5 |
+
* @since 1.0.0
|
6 |
+
*/
|
7 |
+
|
8 |
+
(function($) {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Theme Customizer enhancements for a better user experience.
|
12 |
+
*
|
13 |
+
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
14 |
+
*
|
15 |
+
* => Contents
|
16 |
+
*
|
17 |
+
* - Site title and description.
|
18 |
+
* - Colors
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Reset "Astra Theme" Customizer Options
|
23 |
+
*/
|
24 |
+
jQuery(document).ready(function($) {
|
25 |
+
|
26 |
+
var container = jQuery('#customize-header-actions'),
|
27 |
+
button = jQuery('<input type="submit" name="astra-reset" id="astra-reset" class="button-secondary button">')
|
28 |
+
.attr('value', astraThemeCustomizerReset.customizer.reset.stringReset)
|
29 |
+
.css({
|
30 |
+
'float': 'right',
|
31 |
+
'margin-top': '9px'
|
32 |
+
});
|
33 |
+
|
34 |
+
// Process on click.
|
35 |
+
button.on('click', function(event) {
|
36 |
+
event.preventDefault();
|
37 |
+
|
38 |
+
// Reset all confirm?
|
39 |
+
if (confirm(astraThemeCustomizerReset.customizer.reset.stringConfirm)) {
|
40 |
+
|
41 |
+
// Enable loader.
|
42 |
+
container.find('.spinner').addClass('is-active');
|
43 |
+
|
44 |
+
var data = {
|
45 |
+
wp_customize: 'on',
|
46 |
+
action: 'astra_theme_customizer_reset',
|
47 |
+
nonce: astraThemeCustomizerReset.customizer.reset.nonce
|
48 |
+
};
|
49 |
+
|
50 |
+
// Disable button.
|
51 |
+
button.attr('disabled', 'disabled');
|
52 |
+
|
53 |
+
// Process AJAX.
|
54 |
+
jQuery.post(ajaxurl, data, function(result) {
|
55 |
+
|
56 |
+
// If pass then trigger the state 'saved'.
|
57 |
+
if ('pass' === result.data) {
|
58 |
+
wp.customize.state('saved').set(true);
|
59 |
+
}
|
60 |
+
|
61 |
+
var Url = window.location.href;
|
62 |
+
Url = Url.split("?")[0];
|
63 |
+
window.location.href = Url;
|
64 |
+
|
65 |
+
});
|
66 |
+
}
|
67 |
+
});
|
68 |
+
|
69 |
+
container.append(button);
|
70 |
+
});
|
71 |
+
|
72 |
+
})(jQuery);
|
class-astra-theme-customizer-reset.php
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Reset Astra Customizer
|
4 |
+
* Plugin URI: https://wpastra.com/
|
5 |
+
* Description: Reset the Astra theme customizer options from customizer interface.
|
6 |
+
* Version: 1.0.0
|
7 |
+
* Author: Brainstorm Force
|
8 |
+
* Author URI: http://www.brainstormforce.com
|
9 |
+
* Text Domain: astra-customizer-reset
|
10 |
+
*
|
11 |
+
* @package Reset Astra Customizer
|
12 |
+
*/
|
13 |
+
|
14 |
+
define( 'ASTRA_THEME_CUSTOMIZER_RESET_URI', plugins_url( '/', __FILE__ ) );
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Astra Customizer Reset
|
18 |
+
*
|
19 |
+
* @since 1.0.0
|
20 |
+
*/
|
21 |
+
if ( ! class_exists( 'Astra_Theme_Customizer_Reset' ) ) :
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Astra Customizer Reset
|
25 |
+
*/
|
26 |
+
class Astra_Theme_Customizer_Reset {
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Member Variable
|
30 |
+
*
|
31 |
+
* @since 1.0.0
|
32 |
+
* @var $instance
|
33 |
+
*/
|
34 |
+
private static $instance;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* WordPress Customizer Object
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
+
* @var $wp_customize
|
41 |
+
*/
|
42 |
+
private $wp_customize;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initiator
|
46 |
+
*
|
47 |
+
* @since 1.0.0
|
48 |
+
*/
|
49 |
+
public static function get_instance() {
|
50 |
+
if ( ! isset( self::$instance ) ) {
|
51 |
+
self::$instance = new self;
|
52 |
+
}
|
53 |
+
return self::$instance;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Constructor
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
*/
|
61 |
+
public function __construct() {
|
62 |
+
|
63 |
+
add_action( 'wp_ajax_astra_theme_customizer_reset', array( $this, 'ajax_customizer_reset' ) );
|
64 |
+
add_action( 'customize_controls_enqueue_scripts', array( $this, 'controls_scripts' ) );
|
65 |
+
add_action( 'customize_register', array( $this, 'customize_register' ) );
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Customize Register Description
|
71 |
+
*
|
72 |
+
* @param object $wp_customize Object of WordPress customizer.
|
73 |
+
* @return void
|
74 |
+
* @since 1.0.0
|
75 |
+
*/
|
76 |
+
public function customize_register( $wp_customize ) {
|
77 |
+
$this->wp_customize = $wp_customize;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* AJAX Customizer Reset
|
82 |
+
*
|
83 |
+
* @since 1.0.0
|
84 |
+
* @return void
|
85 |
+
*/
|
86 |
+
public function ajax_customizer_reset() {
|
87 |
+
|
88 |
+
// Request come from a customizer preview?
|
89 |
+
if ( ! $this->wp_customize->is_preview() ) {
|
90 |
+
wp_send_json_error( 'fail' );
|
91 |
+
}
|
92 |
+
|
93 |
+
// Validate nonce.
|
94 |
+
check_ajax_referer( 'astra-theme-customizer-reset', 'nonce' );
|
95 |
+
|
96 |
+
// Reset option 'astra-settings'.
|
97 |
+
if( defined('ASTRA_THEME_SETTINGS') ) {
|
98 |
+
delete_option( ASTRA_THEME_SETTINGS );
|
99 |
+
}
|
100 |
+
|
101 |
+
wp_send_json_error( 'pass' );
|
102 |
+
|
103 |
+
wp_die();
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Customizer Scripts
|
108 |
+
*
|
109 |
+
* @since 1.0.0
|
110 |
+
* @return void
|
111 |
+
*/
|
112 |
+
public function controls_scripts() {
|
113 |
+
|
114 |
+
// Enqueue JS.
|
115 |
+
wp_enqueue_script( 'astra-theme-customizer-reset', ASTRA_THEME_CUSTOMIZER_RESET_URI . 'assets/js/customizer-reset.js', array( 'jquery', 'astra-customizer-controls-toggle-js' ), null, true );
|
116 |
+
|
117 |
+
// Add localize JS.
|
118 |
+
wp_localize_script( 'astra-theme-customizer-reset', 'astraThemeCustomizerReset', apply_filters( 'astra_theme_customizer_reset_js_localize', array(
|
119 |
+
'customizer' => array(
|
120 |
+
'reset' => array(
|
121 |
+
'stringConfirm' => __( 'Warning! This will remove all the Astra theme customizer options!', 'astra-customizer-reset' ),
|
122 |
+
'stringReset' => __( 'Reset All', 'astra-customizer-reset' ),
|
123 |
+
'nonce' => wp_create_nonce( 'astra-theme-customizer-reset' ),
|
124 |
+
),
|
125 |
+
),
|
126 |
+
) ) );
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
endif; // End if().
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Kicking this off by calling 'get_instance()' method
|
134 |
+
*/
|
135 |
+
Astra_Theme_Customizer_Reset::get_instance();
|
readme.txt
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Reset Astra Customizer ===
|
2 |
+
Contributors: brainstormforce, Mahesh901122, dineshc
|
3 |
+
Tags: astra theme, customizer reset, reset astra customizer
|
4 |
+
Tested up to: 4.8
|
5 |
+
Stable tag: trunk
|
6 |
+
Requires at least: 4.4
|
7 |
+
|
8 |
+
Reset the Astra theme customizer options from customizer interface.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
The Customizer Astra Theme Customizer reset plugin allows you to reset your Astra theme customizer settings from directly within the customizer interface.
|
12 |
+
|
13 |
+
== Changelog ==
|
14 |
+
|
15 |
+
= 1.0.0 =
|
16 |
+
* Initial release.
|
17 |
+
|
18 |
+
== Installation ==
|
19 |
+
|
20 |
+
1. Install the Astra Customizer Reset plugin either via the WordPress plugin directory, or by uploading the files to your server at wp-content/plugins.
|
21 |
+
2. After activating, you can reset the WordPress customizer options from customizer interface.
|
22 |
+
|
23 |
+
== Frequently Asked Questions ==
|
24 |
+
|
25 |
+
= Where to find the customizer reset link? =
|
26 |
+
|
27 |
+
Goto customizer from Appearance -> Customizer. The Reset All button is appear behind the Save button @see http://bsf.io/kh1v5
|