Version Description
(20th Dec 2021) = * Enhancement: Refactored code to enqueue JS and CSS files as per coding standards * Enhancement: Refactored code to utilise libraries bundled with WordPress core * Enhancement: Sanitized, Escaped, and Validated all variable, file uploads and data * Enhancement: Moved inline scripts to wp_enqueue_script and wp_add_inline_script
Download this release
Release Info
Developer | expresstech |
Plugin | Responsive Menu |
Version | 4.1.6 |
Comparing to | |
See all releases |
Code changes from version 4.1.5 to 4.1.6
- app/Collections/OptionsCollection.php +0 -95
- app/Container/Container.php +0 -47
- app/Controllers/AdminController.php +0 -377
- app/Controllers/FrontController.php +0 -140
- app/Database/Database.php +0 -31
- app/Database/Migration.php +0 -54
- app/Database/Migrations/Migrate.php +0 -35
- app/Database/Migrations/Migrate_0_0_1_0_0_2.php +0 -29
- app/Database/Migrations/Migrate_0_0_2_0_0_3.php +0 -25
- app/Database/Migrations/Migrate_0_0_5_0_0_6.php +0 -11
- app/Database/Migrations/Migrate_1_1_0_1_1_1.php +0 -7
- app/Database/Migrations/Migrate_3_1_0_3_1_1.php +0 -14
- app/Database/Migrations/Migrate_3_1_13_3_1_14.php +0 -75
- app/Database/Migrations/Migrate_3_1_7_3_1_8.php +0 -21
- app/Formatters/Minifier.php +0 -24
- app/Management/OptionManager.php +0 -66
- app/Tasks/UpdateOptionsTask.php +0 -68
- app/Validation/Validator.php +0 -118
- app/Validation/Validators/BaseValidator.php +0 -19
- app/Validation/Validators/Colour.php +0 -24
- app/Validation/Validators/Number.php +0 -19
- app/Validation/Validators/Positive.php +0 -19
- app/View/View.php +0 -18
- app/Walkers/Walker.php +0 -140
- config/default_options.php +0 -344
- config/polylang.php +0 -16
- config/routing.php +0 -101
- config/services.php +0 -43
- config/twig.php +0 -145
- config/wp/scripts.php +0 -76
- imgs/responsive-menu-logo.png +0 -0
- migration.php +0 -49
- public/css/admin/additional.css +0 -109
- public/css/admin/base.css +0 -733
- public/css/admin/bootstrap-select.css +0 -6
- public/css/admin/bootstrap-toggle.css +0 -28
- public/css/admin/bootstrap.css +0 -5
- public/css/admin/minicolours.css +0 -323
- public/css/admin/resposnsive-menu-notice.css +0 -48
- public/css/admin/selectize.css +0 -324
- public/css/admin/themes/dark.css +0 -178
- public/css/admin/themes/light.css +0 -188
- public/css/animations/boring.css.twig +0 -19
- public/css/animations/off.css.twig +0 -0
- public/css/app.css.twig +0 -710
- public/fonts/admin/glyphicons-halflings-regular.eot +0 -0
- public/fonts/admin/glyphicons-halflings-regular.svg +0 -288
- public/fonts/admin/glyphicons-halflings-regular.ttf +0 -0
- public/fonts/admin/glyphicons-halflings-regular.woff +0 -0
- public/fonts/admin/glyphicons-halflings-regular.woff2 +0 -0
- public/img/banner.jpg +0 -0
- public/img/banner.png +0 -0
- public/js/admin/additional.js +0 -80
- public/js/admin/base.js +0 -202
- public/js/admin/bootstrap-file.js +0 -1
- public/js/admin/bootstrap-select.js +0 -9
- public/js/admin/bootstrap-toggle.js +0 -9
- public/js/admin/bootstrap.js +0 -7
- public/js/admin/minicolours.js +0 -11
- public/js/admin/selectize.js +0 -3
- public/js/app.js.twig +0 -280
- readme.txt +8 -2
- responsive-menu.php +53 -56
- review-banner-class.php +31 -44
- tests/app/Collections/OptionsCollectionTest.php +0 -135
- tests/app/Container/ContainerTest.php +0 -66
- tests/app/Controllers/AdminControllerTest.php +0 -21
- tests/app/Database/MigrationTest.php +0 -227
- tests/app/Formatters/MinifierTest.php +0 -28
- tests/app/Management/OptionManagerTest.php +0 -85
- tests/app/Validation/ValidatorTest.php +0 -47
- tests/app/Validation/Validators/ColourTest.php +0 -40
- tests/app/Validation/Validators/NumberTest.php +0 -47
- tests/app/Validation/Validators/PositiveTest.php +0 -41
- v4.0.0/assets/admin/build/js/rmpMain.js +1 -1
- v4.0.0/assets/admin/js/rmp-menu-wizard.js +1 -1
- v4.0.0/assets/admin/js/rmp-preview.js +27 -27
- v4.0.0/assets/admin/rmp-main.js +1 -1
- v4.0.0/assets/scss/main.scss +3 -1
- v4.0.0/inc/classes/class-admin.php +136 -162
- v4.0.0/inc/classes/class-assets.php +17 -24
- v4.0.0/inc/classes/class-control-manager.php +841 -947
- v4.0.0/inc/classes/class-editor-manager.php +31 -38
- v4.0.0/inc/classes/class-editor.php +3 -6
app/Collections/OptionsCollection.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Collections;
|
4 |
-
|
5 |
-
class OptionsCollection implements \ArrayAccess, \Countable {
|
6 |
-
|
7 |
-
private $options;
|
8 |
-
|
9 |
-
public function __construct(array $options = []) {
|
10 |
-
$this->options = array_map(function($o) {
|
11 |
-
return is_array($o) ? json_encode($o) : $o;
|
12 |
-
}, $options);
|
13 |
-
}
|
14 |
-
|
15 |
-
public function add(array $option) {
|
16 |
-
$value = $option[key($option)];
|
17 |
-
$this->options[key($option)] = is_array($value) ? json_encode($value) : $value;
|
18 |
-
}
|
19 |
-
|
20 |
-
public function getActiveArrow() {
|
21 |
-
if($this->options['active_arrow_image'])
|
22 |
-
return '<img alt="' . $this->options['active_arrow_image_alt'] .'" src="' . $this->getThemedUrl($this->options['active_arrow_image']) .'" />';
|
23 |
-
|
24 |
-
return $this->options['active_arrow_shape'];
|
25 |
-
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getInActiveArrow() {
|
29 |
-
if($this->options['inactive_arrow_image'])
|
30 |
-
return '<img alt="' . $this->options['inactive_arrow_image_alt'] .'" src="' . $this->getThemedUrl($this->options['inactive_arrow_image']) .'" />';
|
31 |
-
|
32 |
-
return $this->options['inactive_arrow_shape'];
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getTitleImage() {
|
37 |
-
if($this->options['menu_title_image'])
|
38 |
-
return '<img alt="' . $this->options['menu_title_image_alt'] .'" src="' . $this->getThemedUrl($this->options['menu_title_image']) .'" />';
|
39 |
-
|
40 |
-
return null;
|
41 |
-
|
42 |
-
}
|
43 |
-
|
44 |
-
public function getButtonIcon() {
|
45 |
-
if($this->options['button_image'])
|
46 |
-
return '<img alt="' . $this->options['button_image_alt'] .'" src="' . $this->getThemedUrl($this->options['button_image']) .'" class="responsive-menu-button-icon responsive-menu-button-icon-active" />';
|
47 |
-
|
48 |
-
return '<span class="responsive-menu-inner"></span>';
|
49 |
-
}
|
50 |
-
|
51 |
-
public function getButtonIconActive() {
|
52 |
-
if($this->options['button_image'])
|
53 |
-
return '<img alt="' . $this->options['button_image_alt_when_clicked'] .'" src="' . $this->getThemedUrl($this->options['button_image_when_clicked']) .'" class="responsive-menu-button-icon responsive-menu-button-icon-inactive" />';
|
54 |
-
}
|
55 |
-
|
56 |
-
public function offsetExists($offset) {
|
57 |
-
return array_key_exists($offset, $this->options);
|
58 |
-
}
|
59 |
-
|
60 |
-
public function offsetGet($offset) {
|
61 |
-
if(isset($this->options[$offset]))
|
62 |
-
return $this->options[$offset];
|
63 |
-
return null;
|
64 |
-
}
|
65 |
-
|
66 |
-
public function offsetSet($offset, $value) {
|
67 |
-
$this->add([$offset => $value]);
|
68 |
-
}
|
69 |
-
|
70 |
-
public function offsetUnset($offset) {
|
71 |
-
if(isset($this->options[$offset]))
|
72 |
-
unset($this->options[$offset]);
|
73 |
-
}
|
74 |
-
|
75 |
-
public function toArray() {
|
76 |
-
$array = [];
|
77 |
-
foreach($this->options as $key => $val)
|
78 |
-
$array[$key] = $val;
|
79 |
-
return $array;
|
80 |
-
}
|
81 |
-
|
82 |
-
public function count() {
|
83 |
-
return count($this->options);
|
84 |
-
}
|
85 |
-
|
86 |
-
private function getThemedUrl($image_url) {
|
87 |
-
if($this->options['menu_theme']):
|
88 |
-
$theme_url = wp_upload_dir()['baseurl'] . '/responsive-menu-themes/' . $this->options['menu_theme'];
|
89 |
-
$image_url = str_replace('{theme_images}', $theme_url . '/images', $image_url);
|
90 |
-
endif;
|
91 |
-
|
92 |
-
return $image_url;
|
93 |
-
}
|
94 |
-
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Container/Container.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Container;
|
4 |
-
|
5 |
-
class Container implements \ArrayAccess {
|
6 |
-
|
7 |
-
private $values = [];
|
8 |
-
private $raw = [];
|
9 |
-
private $keys = [];
|
10 |
-
|
11 |
-
public function offsetSet($id, $value) {
|
12 |
-
$this->values[$id] = $value;
|
13 |
-
$this->keys[$id] = true;
|
14 |
-
}
|
15 |
-
|
16 |
-
public function offsetGet($id) {
|
17 |
-
|
18 |
-
if(!isset($this->keys[$id])) {
|
19 |
-
throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
|
20 |
-
}
|
21 |
-
|
22 |
-
if(isset($this->raw[$id]) || !is_object($this->values[$id]) || !method_exists($this->values[$id], '__invoke')) {
|
23 |
-
return $this->values[$id];
|
24 |
-
}
|
25 |
-
|
26 |
-
$raw = $this->values[$id];
|
27 |
-
$val = $this->values[$id] = $raw($this);
|
28 |
-
$this->raw[$id] = $this->values[$id];
|
29 |
-
|
30 |
-
return $this->values[$id];
|
31 |
-
}
|
32 |
-
|
33 |
-
public function offsetExists($id) {
|
34 |
-
return isset($this->keys[$id]);
|
35 |
-
}
|
36 |
-
|
37 |
-
public function offsetUnset($id) {
|
38 |
-
if(isset($this->keys[$id])) {
|
39 |
-
unset($this->values[$id], $this->raw[$id], $this->keys[$id]);
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
public function keys() {
|
44 |
-
return array_keys($this->values);
|
45 |
-
}
|
46 |
-
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Controllers/AdminController.php
DELETED
@@ -1,377 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Controllers;
|
4 |
-
use ResponsiveMenu\View\View;
|
5 |
-
use ResponsiveMenu\Management\OptionManager;
|
6 |
-
use ResponsiveMenu\Validation\Validator;
|
7 |
-
use ResponsiveMenu\Tasks\UpdateOptionsTask;
|
8 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Entry point for all admin functionality.
|
12 |
-
*
|
13 |
-
* All routing for the admin comes through the functions below. When any
|
14 |
-
* button is pressed in the admin view, it will come through here.
|
15 |
-
*
|
16 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
17 |
-
*
|
18 |
-
* @since 3.0
|
19 |
-
*/
|
20 |
-
class AdminController {
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Constructor for setting up the AdminController.
|
24 |
-
*
|
25 |
-
* The constructor allows us to switch implementations for managing options
|
26 |
-
* and for rendering views. Useful for switching out mocked or stubbed
|
27 |
-
* classes during testing.
|
28 |
-
*
|
29 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
30 |
-
*
|
31 |
-
* @since 3.0
|
32 |
-
*
|
33 |
-
* @param OptionManager $manager Instance of a Management options class.
|
34 |
-
* @param View $view Instance of a View class for rendering.
|
35 |
-
*/
|
36 |
-
public function __construct(OptionManager $manager, View $view) {
|
37 |
-
$this->manager = $manager;
|
38 |
-
$this->view = $view;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Main GET route for the admin section.
|
43 |
-
*
|
44 |
-
* This is the default view for the plugin on an initial GET request to the
|
45 |
-
* page.
|
46 |
-
*
|
47 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
48 |
-
*
|
49 |
-
* @since 3.0
|
50 |
-
*
|
51 |
-
* @return string Output HTML from rendered view.
|
52 |
-
*/
|
53 |
-
public function index() {
|
54 |
-
return $this->view->render(
|
55 |
-
'admin/main.html.twig', ['options' => $this->manager->all()]
|
56 |
-
);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Rebuild database POST route for the admin section.
|
61 |
-
*
|
62 |
-
* This route is called when the Rebuild Database button is clicked from
|
63 |
-
* inside the admin section. The intention is to set the version back to
|
64 |
-
* a pre 3.0 version, which will then force a rebuild.
|
65 |
-
*
|
66 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
67 |
-
*
|
68 |
-
* @since 3.0
|
69 |
-
* @param bool $valid_nonce Is the form nonce valid or not.
|
70 |
-
*
|
71 |
-
* @return string Output HTML from rendered view.
|
72 |
-
*/
|
73 |
-
public function rebuild( $valid_nonce ) {
|
74 |
-
|
75 |
-
// Check form nonce is valid or not.
|
76 |
-
if ( ! $valid_nonce ) {
|
77 |
-
return $this->view->render(
|
78 |
-
'admin/main.html.twig',
|
79 |
-
[
|
80 |
-
'options' => $this->manager->all(),
|
81 |
-
'alert' => [ 'danger' => 'CSRF token not valid' ]
|
82 |
-
]
|
83 |
-
);
|
84 |
-
}
|
85 |
-
|
86 |
-
update_option('responsive_menu_version', '2.8.9');
|
87 |
-
|
88 |
-
return $this->view->render(
|
89 |
-
'admin/main.html.twig',
|
90 |
-
[
|
91 |
-
'options' => $this->manager->all(),
|
92 |
-
'alert' => ['success' => 'Responsive Menu Database Rebuilt Successfully.']
|
93 |
-
]
|
94 |
-
);
|
95 |
-
}
|
96 |
-
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Apply a specific theme options and commit to the database.
|
100 |
-
*
|
101 |
-
* This route is called when the Apply Theme button is pressed inside the
|
102 |
-
* admin area. It loads in the options file for the theme and updates the
|
103 |
-
* options accordingly.
|
104 |
-
*
|
105 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
106 |
-
*
|
107 |
-
* @since 3.1.16
|
108 |
-
*
|
109 |
-
* @param string $theme The theme name to apply
|
110 |
-
* @param bool $valid_nonce Is the form nonce valid or not.
|
111 |
-
*
|
112 |
-
* @return string Output HTML from rendered view.
|
113 |
-
*/
|
114 |
-
public function apply_theme( $theme, $valid_nonce ) {
|
115 |
-
$options = $this->manager->all();
|
116 |
-
|
117 |
-
// Check form nonce is valid or not.
|
118 |
-
if ( ! $valid_nonce ) {
|
119 |
-
return $this->view->render(
|
120 |
-
'admin/main.html.twig',
|
121 |
-
[
|
122 |
-
'options' => $options,
|
123 |
-
'alert' => [ 'danger' => 'CSRF token not valid' ]
|
124 |
-
]
|
125 |
-
);
|
126 |
-
}
|
127 |
-
|
128 |
-
$upload_folder = wp_upload_dir()['basedir'];
|
129 |
-
$theme_folder = $upload_folder . '/responsive-menu-themes/';
|
130 |
-
$options_file_location = $theme_folder . $theme . '/options.json';
|
131 |
-
|
132 |
-
$theme_options_file = file_get_contents($options_file_location);
|
133 |
-
$theme_options = json_decode($theme_options_file, true);
|
134 |
-
|
135 |
-
foreach($theme_options as $key => $value)
|
136 |
-
$options[$key] = $value;
|
137 |
-
|
138 |
-
$options['menu_theme'] = $theme;
|
139 |
-
|
140 |
-
$this->manager->updateOptions($options->toArray());
|
141 |
-
|
142 |
-
return $this->view->render(
|
143 |
-
'admin/main.html.twig',
|
144 |
-
[
|
145 |
-
'options' => $options,
|
146 |
-
'alert' => ['success' => 'Responsive Menu Theme Applied Successfully.']
|
147 |
-
]
|
148 |
-
);
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Import a theme from a zip file.
|
153 |
-
*
|
154 |
-
* This route is called when the Upload Theme button is pressed inside the
|
155 |
-
* admin area. It loads in the selected zip file for the theme and unpacks
|
156 |
-
* it in the uploads directory.
|
157 |
-
*
|
158 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
159 |
-
*
|
160 |
-
* @since 3.1.16
|
161 |
-
*
|
162 |
-
* @param string $theme The theme file location to unzip
|
163 |
-
* @param bool $valid_nonce Is the form nonce valid or not.
|
164 |
-
*
|
165 |
-
* @return string Output HTML from rendered view.
|
166 |
-
*/
|
167 |
-
public function import_theme( $theme, $valid_nonce ) {
|
168 |
-
|
169 |
-
// Check nonce is valid or not.
|
170 |
-
if ( ! $valid_nonce ):
|
171 |
-
$alert = [ 'danger' => 'CSRF token not valid' ];
|
172 |
-
elseif ( ! empty( $theme ) ):
|
173 |
-
WP_Filesystem();
|
174 |
-
$upload_folder = wp_upload_dir()['basedir'] . '/responsive-menu-themes';
|
175 |
-
|
176 |
-
$unzipfile = unzip_file($theme, $upload_folder);
|
177 |
-
|
178 |
-
if(is_wp_error($unzipfile)) {
|
179 |
-
$alert = ['danger' => $unzipfile->get_error_message()];
|
180 |
-
} else {
|
181 |
-
$alert = ['success' => 'Responsive Menu Theme Imported Successfully.'];
|
182 |
-
}
|
183 |
-
|
184 |
-
else:
|
185 |
-
$alert = ['danger' => 'No import file selected'];
|
186 |
-
|
187 |
-
endif;
|
188 |
-
|
189 |
-
return $this->view->render(
|
190 |
-
'admin/main.html.twig',
|
191 |
-
[
|
192 |
-
'options' => $this->manager->all(),
|
193 |
-
'alert' => $alert
|
194 |
-
]
|
195 |
-
);
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Update the options based on submitted admin form.
|
200 |
-
*
|
201 |
-
* This route is called whenever the Update Options button is pressed and is
|
202 |
-
* the most commonly called route. Takes the submitted options and runs the
|
203 |
-
* update options task.
|
204 |
-
*
|
205 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
206 |
-
*
|
207 |
-
* @since 3.0
|
208 |
-
*
|
209 |
-
* @param bool $valid_nonce Is the form nonce valid or not
|
210 |
-
* @param array $new_options An array of the submitted options.
|
211 |
-
*
|
212 |
-
* @return string Output HTML from rendered view.
|
213 |
-
*/
|
214 |
-
public function update($valid_nonce, $new_options) {
|
215 |
-
$validator = new Validator();
|
216 |
-
$errors = [];
|
217 |
-
|
218 |
-
if(!$valid_nonce):
|
219 |
-
$alert = ['danger' => 'CSRF token not valid'];
|
220 |
-
$options = new OptionsCollection($new_options);
|
221 |
-
|
222 |
-
elseif($validator->validate($new_options)):
|
223 |
-
try {
|
224 |
-
$options = $this->manager->updateOptions($new_options);
|
225 |
-
$task = new UpdateOptionsTask;
|
226 |
-
$task->run($options, $this->view);
|
227 |
-
$alert = ['success' => 'Responsive Menu Options Updated Successfully.'];
|
228 |
-
|
229 |
-
} catch (\Exception $e) {
|
230 |
-
$alert = ['danger' => $e->getMessage()];
|
231 |
-
}
|
232 |
-
|
233 |
-
else:
|
234 |
-
$options = new OptionsCollection($new_options);
|
235 |
-
$errors = $validator->getErrors();
|
236 |
-
$alert = ['danger' => $errors];
|
237 |
-
|
238 |
-
endif;
|
239 |
-
|
240 |
-
return $this->view->render(
|
241 |
-
'admin/main.html.twig',
|
242 |
-
[
|
243 |
-
'options' => $options,
|
244 |
-
'alert' => $alert,
|
245 |
-
'errors' => $errors
|
246 |
-
]
|
247 |
-
);
|
248 |
-
}
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Reset the options back to the defaults.
|
252 |
-
*
|
253 |
-
* This route is called whenever the Reset Options button is pressed. Resets
|
254 |
-
* all options back to their default states and runs the update options
|
255 |
-
* task.
|
256 |
-
*
|
257 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
258 |
-
*
|
259 |
-
* @since 3.0
|
260 |
-
*
|
261 |
-
* @param array $default_options An array of the default options.
|
262 |
-
* @param bool $valid_nonce Is the form nonce valid or not.
|
263 |
-
*
|
264 |
-
* @return string Output HTML from rendered view.
|
265 |
-
*/
|
266 |
-
public function reset($default_options, $valid_nonce ) {
|
267 |
-
|
268 |
-
// Check form nonce is valid or not.
|
269 |
-
if ( ! $valid_nonce ) {
|
270 |
-
return $this->view->render(
|
271 |
-
'admin/main.html.twig',
|
272 |
-
[
|
273 |
-
'options' => $this->manager->all(),
|
274 |
-
'alert' => [ 'danger' => 'CSRF token not valid' ]
|
275 |
-
]
|
276 |
-
);
|
277 |
-
}
|
278 |
-
|
279 |
-
try {
|
280 |
-
$options = $this->manager->updateOptions($default_options);
|
281 |
-
$task = new UpdateOptionsTask;
|
282 |
-
$task->run($options, $this->view);
|
283 |
-
$alert = ['success' => 'Responsive Menu Options Reset Successfully'];
|
284 |
-
|
285 |
-
} catch(\Exception $e) {
|
286 |
-
$alert = ['danger' => $e->getMessage()];
|
287 |
-
}
|
288 |
-
|
289 |
-
return $this->view->render(
|
290 |
-
'admin/main.html.twig',
|
291 |
-
[
|
292 |
-
'options' => $options,
|
293 |
-
'alert' => $alert
|
294 |
-
]
|
295 |
-
);
|
296 |
-
}
|
297 |
-
|
298 |
-
/**
|
299 |
-
* Import options from a file.
|
300 |
-
*
|
301 |
-
* This route is called when the Import Options button is pressed inside the
|
302 |
-
* admin area. It loads in the selected json file and updates the options.
|
303 |
-
*
|
304 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
305 |
-
*
|
306 |
-
* @since 3.0
|
307 |
-
*
|
308 |
-
* @param array $imported_options An array of the imported options.
|
309 |
-
* @param bool $valid_nonce Is the form nonce valid or not.
|
310 |
-
*
|
311 |
-
* @return string Output HTML from rendered view.
|
312 |
-
*/
|
313 |
-
public function import( $imported_options, $valid_nonce ) {
|
314 |
-
$errors = [];
|
315 |
-
|
316 |
-
// Check nonce is valid or not.
|
317 |
-
if ( ! $valid_nonce ) {
|
318 |
-
$alert = [ 'danger' => 'CSRF token not valid' ];
|
319 |
-
$options = $this->manager->all();
|
320 |
-
} elseif( ! empty( $imported_options ) ) {
|
321 |
-
|
322 |
-
$validator = new Validator();
|
323 |
-
if($validator->validate($imported_options)):
|
324 |
-
try {
|
325 |
-
unset($imported_options['button_click_trigger']);
|
326 |
-
$options = $this->manager->updateOptions($imported_options);
|
327 |
-
$task = new UpdateOptionsTask;
|
328 |
-
$task->run($options, $this->view);
|
329 |
-
$alert = ['success' => 'Responsive Menu Options Imported Successfully.'];
|
330 |
-
} catch(\Exception $e) {
|
331 |
-
$options = $this->manager->all();
|
332 |
-
$alert = ['danger' => $e->getMessage()];
|
333 |
-
}
|
334 |
-
|
335 |
-
else:
|
336 |
-
$options = new OptionsCollection($imported_options);
|
337 |
-
$errors = $validator->getErrors();
|
338 |
-
$alert = ['danger' => $errors];
|
339 |
-
|
340 |
-
endif;
|
341 |
-
|
342 |
-
} else {
|
343 |
-
$options = $this->manager->all();
|
344 |
-
$alert = ['danger' => 'No import file selected'];
|
345 |
-
|
346 |
-
}
|
347 |
-
|
348 |
-
return $this->view->render(
|
349 |
-
'admin/main.html.twig',
|
350 |
-
[
|
351 |
-
'options' => $options,
|
352 |
-
'alert' => $alert,
|
353 |
-
'errors' => $errors
|
354 |
-
]
|
355 |
-
);
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
* Export all current options to a json file.
|
360 |
-
*
|
361 |
-
* This route is called when the Export Options button is pressed inside
|
362 |
-
* the admin area. It returns a json file of all the current options as a
|
363 |
-
* download attachment to the browser.
|
364 |
-
*
|
365 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
366 |
-
*
|
367 |
-
* @since 3.0
|
368 |
-
*
|
369 |
-
* @return attachment json file attachment of plugin options.
|
370 |
-
*/
|
371 |
-
public function export() {
|
372 |
-
return json_encode(
|
373 |
-
$this->manager->all()->toArray()
|
374 |
-
);
|
375 |
-
}
|
376 |
-
|
377 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Controllers/FrontController.php
DELETED
@@ -1,140 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Controllers;
|
4 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
5 |
-
use ResponsiveMenu\View\View;
|
6 |
-
use ResponsiveMenu\Management\OptionManager;
|
7 |
-
use ResponsiveMenu\Formatters\Minifier;
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Entry point for all front end functionality.
|
11 |
-
*
|
12 |
-
* All routing for the front end comes through the functions below. When a
|
13 |
-
* front end page is loaded in the browser it will come through here.
|
14 |
-
*
|
15 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
16 |
-
*
|
17 |
-
* @since 3.0
|
18 |
-
*/
|
19 |
-
class FrontController {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Constructor for setting up the FrontController.
|
23 |
-
*
|
24 |
-
* The constructor allows us to switch implementations for managing options
|
25 |
-
* and for rendering views. Useful for switching out mocked or stubbed
|
26 |
-
* classes during testing.
|
27 |
-
*
|
28 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
29 |
-
*
|
30 |
-
* @since 3.0
|
31 |
-
*
|
32 |
-
* @param OptionManager $manager Instance of a Management options class.
|
33 |
-
* @param View $view Instance of a View class for rendering.
|
34 |
-
*/
|
35 |
-
public function __construct(OptionManager $manager, View $view) {
|
36 |
-
$this->manager = $manager;
|
37 |
-
$this->view = $view;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Main route for the front end.
|
42 |
-
*
|
43 |
-
* This is the default view for the plugin on an initial GET request to the
|
44 |
-
* front end page.
|
45 |
-
*
|
46 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
47 |
-
*
|
48 |
-
* @since 3.0
|
49 |
-
*
|
50 |
-
* @return string Output HTML from rendered view.
|
51 |
-
*/
|
52 |
-
public function index() {
|
53 |
-
$options = $this->manager->all();
|
54 |
-
$this->buildFrontEnd($options);
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Preview route for the front end.
|
59 |
-
*
|
60 |
-
* This is the preview view for the plugin when the preview admin option is
|
61 |
-
* pressed.
|
62 |
-
*
|
63 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
64 |
-
*
|
65 |
-
* @since 3.0
|
66 |
-
*
|
67 |
-
* @return string Output HTML from rendered view.
|
68 |
-
*/
|
69 |
-
public function preview() {
|
70 |
-
return $this->view->render('preview.html.twig');
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Helper private method to setup and build the front end.
|
75 |
-
*
|
76 |
-
* This is the preview view for the plugin when the preview admin option is
|
77 |
-
* pressed. We turn external files off to enable the preview options to
|
78 |
-
* take effect.
|
79 |
-
*
|
80 |
-
* TODO: This is a horrible method that really needs to be broken up in some
|
81 |
-
* way. There is a lot of setup and WordPress specific functionality going
|
82 |
-
* on here that would ideally be abstracted away.
|
83 |
-
*
|
84 |
-
* @author Peter Featherstone <peter@featherstone.me>
|
85 |
-
*
|
86 |
-
* @since 3.0
|
87 |
-
*
|
88 |
-
* @param OptionsCollection $options A OptionsCollection object.
|
89 |
-
*/
|
90 |
-
private function buildFrontEnd(OptionsCollection $options) {
|
91 |
-
add_filter('body_class', function($classes) use($options) {
|
92 |
-
$classes[] = 'responsive-menu-' . $options['animation_type'] . '-' . $options['menu_appear_from'];
|
93 |
-
return $classes;
|
94 |
-
});
|
95 |
-
|
96 |
-
if($options['external_files'] == 'on'):
|
97 |
-
add_action('wp_enqueue_scripts', function() use($options) {
|
98 |
-
$css_file = wp_upload_dir()['baseurl'] . '/responsive-menu/css/responsive-menu-' . get_current_blog_id() . '.css';
|
99 |
-
$js_file = wp_upload_dir()['baseurl'] . '/responsive-menu/js/responsive-menu-' . get_current_blog_id() . '.js';
|
100 |
-
wp_enqueue_style('responsive-menu', $css_file, null, false);
|
101 |
-
wp_enqueue_script('responsive-menu', $js_file, ['jquery'], false, $options['scripts_in_footer'] == 'on' ? true : false);
|
102 |
-
});
|
103 |
-
else:
|
104 |
-
add_action('wp_head', function() use($options) {
|
105 |
-
$css_data = $this->view->render('css/app.css.twig', ['options' => $options]);
|
106 |
-
if($options['minify_scripts'] == 'on')
|
107 |
-
$css_data = Minifier::minify($css_data);
|
108 |
-
|
109 |
-
echo '<style>' . $css_data . '</style>';
|
110 |
-
}, 100);
|
111 |
-
|
112 |
-
add_action($options['scripts_in_footer'] == 'on' ? 'wp_footer' : 'wp_head', function() use($options) {
|
113 |
-
$js_data = $this->view->render('js/app.js.twig', ['options' => $options]);
|
114 |
-
if($options['minify_scripts'] == 'on')
|
115 |
-
$js_data = Minifier::minify($js_data);
|
116 |
-
|
117 |
-
echo '<script>' . $js_data . '</script>';
|
118 |
-
}, 100);
|
119 |
-
endif;
|
120 |
-
|
121 |
-
if($options['shortcode'] == 'on'):
|
122 |
-
add_shortcode('responsive_menu', function($atts) use($options) {
|
123 |
-
|
124 |
-
if(is_array($atts))
|
125 |
-
$merged_options = array_merge($options->toArray(), $atts);
|
126 |
-
else
|
127 |
-
$merged_options = $options->toArray();
|
128 |
-
|
129 |
-
$new_collection = new OptionsCollection($merged_options);
|
130 |
-
return $this->view->render('app.html.twig', ['options' => $new_collection]);
|
131 |
-
});
|
132 |
-
else:
|
133 |
-
add_action('wp_footer', function() use($options) {
|
134 |
-
echo $this->view->render('app.html.twig', ['options' => $options]);
|
135 |
-
});
|
136 |
-
endif;
|
137 |
-
|
138 |
-
}
|
139 |
-
|
140 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Database.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database;
|
4 |
-
|
5 |
-
class Database {
|
6 |
-
|
7 |
-
public function __construct($db_base) {
|
8 |
-
$this->db = $db_base;
|
9 |
-
}
|
10 |
-
|
11 |
-
public function all($table) {
|
12 |
-
$results = $this->db->get_results("SELECT * FROM {$this->db->prefix}{$table}", ARRAY_A);
|
13 |
-
$flattened = [];
|
14 |
-
foreach($results as $result)
|
15 |
-
$flattened[$result['name']] = $result['value'];
|
16 |
-
return $flattened;
|
17 |
-
}
|
18 |
-
|
19 |
-
public function update($table, array $to_update) {
|
20 |
-
return $this->db->replace($this->db->prefix . $table, $to_update, ['%s', '%s']);
|
21 |
-
}
|
22 |
-
|
23 |
-
public function delete($table, $name) {
|
24 |
-
return $this->db->delete($this->db->prefix . $table, $name);
|
25 |
-
}
|
26 |
-
|
27 |
-
public function insert($table, array $arguments) {
|
28 |
-
return $this->db->insert($this->db->prefix . $table, $arguments);
|
29 |
-
}
|
30 |
-
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migration.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database;
|
4 |
-
use ResponsiveMenu\Management\OptionManager;
|
5 |
-
|
6 |
-
class Migration {
|
7 |
-
|
8 |
-
private $manager;
|
9 |
-
private $old_version;
|
10 |
-
private $new_version;
|
11 |
-
private $defaults;
|
12 |
-
|
13 |
-
public function __construct(OptionManager $manager, $old_version, $new_version, $defaults) {
|
14 |
-
$this->manager = $manager;
|
15 |
-
$this->old_version = $old_version;
|
16 |
-
$this->new_version = $new_version;
|
17 |
-
$this->defaults = $defaults;
|
18 |
-
}
|
19 |
-
|
20 |
-
public function needsTable() {
|
21 |
-
return substr($this->old_version, 0, 1) < 3;
|
22 |
-
}
|
23 |
-
|
24 |
-
public function needsUpdate() {
|
25 |
-
return version_compare($this->old_version, $this->new_version, '<');
|
26 |
-
}
|
27 |
-
|
28 |
-
public function addNewOptions() {
|
29 |
-
return $this->manager->createOptions(array_diff_key($this->defaults, $this->manager->all()->toArray()));
|
30 |
-
}
|
31 |
-
|
32 |
-
public function tidyUpOptions() {
|
33 |
-
return $this->manager->removeOptions(array_diff_key($this->manager->all()->toArray(), $this->defaults));
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getMigrationClasses() {
|
37 |
-
$migrations = [];
|
38 |
-
if($this->old_version):
|
39 |
-
foreach(glob(__DIR__ . '/Migrations/Migrate_*.php') as $file) {
|
40 |
-
$class_name = 'ResponsiveMenu\Database\Migrations\\' . basename($file, '.php');
|
41 |
-
$class = new $class_name;
|
42 |
-
if(
|
43 |
-
version_compare($class->getOldVersion(), $this->new_version, '<') &&
|
44 |
-
version_compare($this->old_version, $class->getNewVersion(), '<')
|
45 |
-
)
|
46 |
-
$migrations[$class->getOldVersion()] = $class;
|
47 |
-
}
|
48 |
-
|
49 |
-
uksort($migrations, 'version_compare');
|
50 |
-
endif;
|
51 |
-
return $migrations;
|
52 |
-
}
|
53 |
-
|
54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
5 |
-
|
6 |
-
class Migrate {
|
7 |
-
|
8 |
-
public function migrate(OptionsCollection $options) {
|
9 |
-
if(isset($this->migrations))
|
10 |
-
foreach($this->migrations as $copy_to => $copy_from)
|
11 |
-
$options[$copy_to] = $options[$copy_from];
|
12 |
-
|
13 |
-
if(isset($this->migration_scripts))
|
14 |
-
foreach($this->migration_scripts as $script)
|
15 |
-
$options = $this->$script($options);
|
16 |
-
|
17 |
-
return $options;
|
18 |
-
}
|
19 |
-
|
20 |
-
public function getOldVersion() {
|
21 |
-
$v = $this->getVersionArray();
|
22 |
-
return $v[0] . '.' . $v[1] . '.' . $v[2];
|
23 |
-
}
|
24 |
-
|
25 |
-
public function getNewVersion() {
|
26 |
-
$v = $this->getVersionArray();
|
27 |
-
return $v[3] . '.' . $v[4] . '.' . $v[5];
|
28 |
-
}
|
29 |
-
|
30 |
-
private function getVersionArray() {
|
31 |
-
$versions = str_replace('ResponsiveMenu\Database\Migrations\Migrate_', '', get_class($this));
|
32 |
-
return explode('_', $versions);
|
33 |
-
}
|
34 |
-
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate_0_0_1_0_0_2.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
5 |
-
|
6 |
-
class Migrate_0_0_1_0_0_2 extends Migrate {
|
7 |
-
|
8 |
-
protected $migrations = [
|
9 |
-
'foo' => 'baz'
|
10 |
-
];
|
11 |
-
|
12 |
-
protected $migration_scripts = [
|
13 |
-
'updateSun'
|
14 |
-
];
|
15 |
-
|
16 |
-
protected function updateSun(OptionsCollection $options) {
|
17 |
-
$sun = json_decode($options['sun']);
|
18 |
-
if(is_array($sun)):
|
19 |
-
$new_sun = [];
|
20 |
-
foreach($sun as $update):
|
21 |
-
unset($update[2]);
|
22 |
-
$new_sun[] = $update;
|
23 |
-
endforeach;
|
24 |
-
$options['sun'] = $new_sun;
|
25 |
-
endif;
|
26 |
-
return $options;
|
27 |
-
}
|
28 |
-
|
29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate_0_0_2_0_0_3.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
5 |
-
|
6 |
-
class Migrate_0_0_2_0_0_3 extends Migrate {
|
7 |
-
|
8 |
-
protected $migration_scripts = [
|
9 |
-
'updateSun'
|
10 |
-
];
|
11 |
-
|
12 |
-
protected function updateSun(OptionsCollection $options) {
|
13 |
-
$sun = json_decode($options['sun']);
|
14 |
-
if(is_array($sun)):
|
15 |
-
$new_sun = [];
|
16 |
-
foreach($sun as $update):
|
17 |
-
unset($update[1]);
|
18 |
-
$new_sun[] = $update;
|
19 |
-
endforeach;
|
20 |
-
$options['sun'] = $new_sun;
|
21 |
-
endif;
|
22 |
-
return $options;
|
23 |
-
}
|
24 |
-
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate_0_0_5_0_0_6.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
|
5 |
-
class Migrate_0_0_5_0_0_6 extends Migrate {
|
6 |
-
|
7 |
-
protected $migrations = [
|
8 |
-
'moon' => 'baz'
|
9 |
-
];
|
10 |
-
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate_1_1_0_1_1_1.php
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
|
5 |
-
class Migrate_1_1_0_1_1_1 extends Migrate {
|
6 |
-
|
7 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate_3_1_0_3_1_1.php
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
|
5 |
-
class Migrate_3_1_0_3_1_1 extends Migrate {
|
6 |
-
|
7 |
-
protected $migrations = [
|
8 |
-
'button_background_colour_active' => 'button_background_colour',
|
9 |
-
'button_line_colour_hover' => 'button_line_colour',
|
10 |
-
'button_line_colour_active' => 'button_line_colour',
|
11 |
-
'menu_container_background_colour' => 'menu_background_colour',
|
12 |
-
];
|
13 |
-
|
14 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate_3_1_13_3_1_14.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
|
5 |
-
class Migrate_3_1_13_3_1_14 extends Migrate {
|
6 |
-
|
7 |
-
protected $migrations = [
|
8 |
-
// Menu > Styling
|
9 |
-
'menu_links_line_height' => 'menu_links_height',
|
10 |
-
'menu_links_line_height_unit' => 'menu_links_height_unit',
|
11 |
-
|
12 |
-
// Sub Menus > Styling
|
13 |
-
'submenu_font' => 'menu_font',
|
14 |
-
'submenu_font_size' => 'menu_font_size',
|
15 |
-
'submenu_font_size_unit' => 'menu_font_size_unit',
|
16 |
-
'submenu_links_height' => 'menu_links_height',
|
17 |
-
'submenu_links_height_unit' => 'menu_links_height_unit',
|
18 |
-
'submenu_links_line_height' => 'menu_links_height',
|
19 |
-
'submenu_links_line_height_unit' => 'menu_links_height_unit',
|
20 |
-
'submenu_text_alignment' => 'menu_text_alignment',
|
21 |
-
|
22 |
-
// Sub Menus > Item Borders
|
23 |
-
'submenu_border_width' => 'menu_border_width',
|
24 |
-
'submenu_border_width_unit' => 'menu_border_width_unit',
|
25 |
-
'submenu_item_border_colour' => 'menu_item_border_colour',
|
26 |
-
'submenu_item_border_colour_hover' => 'menu_item_border_colour_hover',
|
27 |
-
'submenu_current_item_border_colour' => 'menu_current_item_border_colour',
|
28 |
-
'submenu_current_item_border_hover_colour' => 'menu_current_item_border_hover_colour',
|
29 |
-
|
30 |
-
// Sub Menus > Item Text
|
31 |
-
'submenu_link_colour' => 'menu_link_colour',
|
32 |
-
'submenu_link_hover_colour' => 'menu_link_hover_colour',
|
33 |
-
'submenu_current_link_colour' => 'menu_current_link_colour',
|
34 |
-
'submenu_current_link_hover_colour' => 'menu_current_link_hover_colour',
|
35 |
-
|
36 |
-
// Sub Menus > Item Background
|
37 |
-
'submenu_item_background_colour' => 'menu_item_background_colour',
|
38 |
-
'submenu_item_background_hover_colour' => 'menu_item_background_hover_colour',
|
39 |
-
'submenu_current_item_background_colour' => 'menu_current_item_background_colour',
|
40 |
-
'submenu_current_item_background_hover_colour' => 'menu_current_item_background_hover_colour',
|
41 |
-
|
42 |
-
// Sub Menus > Trigger Icon
|
43 |
-
'submenu_arrow_position' => 'arrow_position',
|
44 |
-
|
45 |
-
// Sub Menus > Trigger Sizing
|
46 |
-
'submenu_submenu_arrow_height' => 'submenu_arrow_height',
|
47 |
-
'submenu_submenu_arrow_height_unit' => 'submenu_arrow_height_unit',
|
48 |
-
'submenu_submenu_arrow_width' => 'submenu_arrow_width',
|
49 |
-
'submenu_submenu_arrow_width_unit' => 'submenu_arrow_width_unit',
|
50 |
-
|
51 |
-
// Sub Menus > Trigger Colours
|
52 |
-
'submenu_sub_arrow_shape_colour' => 'menu_sub_arrow_shape_colour',
|
53 |
-
'submenu_sub_arrow_shape_hover_colour' => 'menu_sub_arrow_shape_hover_colour',
|
54 |
-
'submenu_sub_arrow_shape_colour_active' => 'menu_sub_arrow_shape_colour_active',
|
55 |
-
'submenu_sub_arrow_shape_hover_colour_active' => 'menu_sub_arrow_shape_hover_colour_active',
|
56 |
-
|
57 |
-
// Sub Menus > Trigger Background
|
58 |
-
'submenu_sub_arrow_background_colour' => 'menu_sub_arrow_background_colour',
|
59 |
-
'submenu_sub_arrow_background_hover_colour' => 'menu_sub_arrow_background_hover_colour',
|
60 |
-
'submenu_sub_arrow_background_colour_active' => 'menu_sub_arrow_background_colour_active',
|
61 |
-
'submenu_sub_arrow_background_hover_colour_active' => 'menu_sub_arrow_background_hover_colour_active',
|
62 |
-
|
63 |
-
// Sub Menus > Trigger Border
|
64 |
-
'submenu_sub_arrow_border_colour' => 'menu_sub_arrow_border_colour',
|
65 |
-
'submenu_sub_arrow_border_hover_colour' => 'menu_sub_arrow_border_hover_colour',
|
66 |
-
'submenu_sub_arrow_border_colour_active' => 'menu_sub_arrow_border_colour_active',
|
67 |
-
'submenu_sub_arrow_border_hover_colour_active' => 'menu_sub_arrow_border_hover_colour_active',
|
68 |
-
|
69 |
-
// Desktop Menu > Top Level Styling
|
70 |
-
'single_menu_line_height' => 'single_menu_height',
|
71 |
-
'single_menu_line_height_unit' => 'single_menu_height_unit',
|
72 |
-
|
73 |
-
];
|
74 |
-
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Database/Migrations/Migrate_3_1_7_3_1_8.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Database\Migrations;
|
4 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
5 |
-
|
6 |
-
class Migrate_3_1_7_3_1_8 extends Migrate {
|
7 |
-
|
8 |
-
protected $migrations = [
|
9 |
-
'use_desktop_menu' => 'use_single_menu'
|
10 |
-
];
|
11 |
-
|
12 |
-
protected $migration_scripts = [
|
13 |
-
'setOldTheme'
|
14 |
-
];
|
15 |
-
|
16 |
-
protected function setOldTheme(OptionsCollection $options) {
|
17 |
-
$options['admin_theme'] = 'light';
|
18 |
-
return $options;
|
19 |
-
}
|
20 |
-
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Formatters/Minifier.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Formatters;
|
4 |
-
|
5 |
-
class Minifier {
|
6 |
-
|
7 |
-
public static function minify($data) {
|
8 |
-
|
9 |
-
/* remove comments */
|
10 |
-
$minified = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $data);
|
11 |
-
|
12 |
-
/* remove tabs, spaces, newlines, etc. */
|
13 |
-
$minified = str_replace(array("\r\n","\r","\n","\t",' ',' ',' '), '', $minified);
|
14 |
-
|
15 |
-
/* remove other spaces before/after ; */
|
16 |
-
$minified = preg_replace(array('(( )+{)','({( )+)'), '{', $minified);
|
17 |
-
$minified = preg_replace(array('(( )+})','(}( )+)','(;( )*})'), '}', $minified);
|
18 |
-
$minified = preg_replace(array('(;( )+)','(( )+;)'), ';', $minified);
|
19 |
-
|
20 |
-
return $minified;
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Management/OptionManager.php
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Management;
|
4 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
5 |
-
use ResponsiveMenu\Database\Database;
|
6 |
-
|
7 |
-
class OptionManager {
|
8 |
-
|
9 |
-
private $db;
|
10 |
-
private $default_options;
|
11 |
-
|
12 |
-
public function __construct(Database $db, $default_options) {
|
13 |
-
$this->db = $db;
|
14 |
-
$this->default_options = $default_options;
|
15 |
-
}
|
16 |
-
|
17 |
-
public function all() {
|
18 |
-
$options = $this->db->all('responsive_menu');
|
19 |
-
return new OptionsCollection($options);
|
20 |
-
}
|
21 |
-
|
22 |
-
public function updateOptions(array $options) {
|
23 |
-
$updated_options = $this->combineOptions($options);
|
24 |
-
foreach($updated_options as $name => $val):
|
25 |
-
$val = is_array($val) ? json_encode($val) : $val;
|
26 |
-
$updated_options[$name] = $val;
|
27 |
-
$this->db->update('responsive_menu', ['name' => $name, 'value' => $val]);
|
28 |
-
endforeach;
|
29 |
-
return new OptionsCollection($updated_options);
|
30 |
-
}
|
31 |
-
|
32 |
-
public function createOptions(array $options) {
|
33 |
-
$updated_options = $this->combineOptions($options);
|
34 |
-
foreach($options as $name => $val):
|
35 |
-
$val = is_array($val) ? json_encode($val) : $val;
|
36 |
-
$updated_options[$name] = $val;
|
37 |
-
$this->db->insert('responsive_menu', ['name' => $name, 'value' => $val]);
|
38 |
-
endforeach;
|
39 |
-
return new OptionsCollection($updated_options);
|
40 |
-
}
|
41 |
-
|
42 |
-
public function removeOptions(array $options) {
|
43 |
-
$updated_options = $this->combineOptions($options);
|
44 |
-
foreach($options as $name => $val):
|
45 |
-
$val = is_array($val) ? json_encode($val) : $val;
|
46 |
-
$updated_options[$name] = $val;
|
47 |
-
unset($updated_options[$name]);
|
48 |
-
$this->db->delete('responsive_menu', ['name' => $name]);
|
49 |
-
endforeach;
|
50 |
-
return new OptionsCollection($updated_options);
|
51 |
-
}
|
52 |
-
|
53 |
-
public function buildFromArray(array $options) {
|
54 |
-
$new_options = $this->combineOptions($options);
|
55 |
-
foreach($options as $name => $val):
|
56 |
-
$val = is_array($val) ? json_encode($val) : $val;
|
57 |
-
$new_options[$name] = $val;
|
58 |
-
endforeach;
|
59 |
-
return new OptionsCollection($new_options);
|
60 |
-
}
|
61 |
-
|
62 |
-
private function combineOptions($new_options) {
|
63 |
-
return array_merge($this->default_options, $new_options);
|
64 |
-
}
|
65 |
-
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Tasks/UpdateOptionsTask.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Tasks;
|
4 |
-
use ResponsiveMenu\Collections\OptionsCollection;
|
5 |
-
use ResponsiveMenu\Formatters\Minifier;
|
6 |
-
use ResponsiveMenu\View\View;
|
7 |
-
|
8 |
-
class UpdateOptionsTask {
|
9 |
-
|
10 |
-
private $translatables = [
|
11 |
-
'menu_to_use',
|
12 |
-
'button_title',
|
13 |
-
'menu_title',
|
14 |
-
'menu_title_link',
|
15 |
-
'menu_additional_content',
|
16 |
-
'menu_search_box_text'
|
17 |
-
];
|
18 |
-
|
19 |
-
public function run(OptionsCollection $options, View $view) {
|
20 |
-
/*
|
21 |
-
* Build CSS and Js files
|
22 |
-
*
|
23 |
-
*/
|
24 |
-
if($options['external_files'] == 'on'):
|
25 |
-
|
26 |
-
$base_dir = wp_upload_dir()['basedir'] . '/responsive-menu';
|
27 |
-
|
28 |
-
if(!wp_mkdir_p($base_dir . '/css'))
|
29 |
-
throw new \Exception('You don\'t have permissions to create CSS data folder - please check permissions.');
|
30 |
-
|
31 |
-
if(!wp_mkdir_p($base_dir . '/js'))
|
32 |
-
throw new \Exception('You don\'t have permissions to create JS data folder - please check permissions.');
|
33 |
-
|
34 |
-
$css_file = $base_dir . '/css/responsive-menu-' . get_current_blog_id() . '.css';
|
35 |
-
$css_data = $view->render('css/app.css.twig', ['options' => $options]);
|
36 |
-
|
37 |
-
if($options['minify_scripts'] == 'on')
|
38 |
-
$css_data = Minifier::minify($css_data);
|
39 |
-
|
40 |
-
if(!file_put_contents($css_file, $css_data))
|
41 |
-
throw new \Exception('You don\'t have permissions to write external CSS file - please check permissions.');
|
42 |
-
|
43 |
-
$js_file = $base_dir . '/js/responsive-menu-' . get_current_blog_id() . '.js';
|
44 |
-
$js_data = $view->render('js/app.js.twig', ['options' => $options]);
|
45 |
-
|
46 |
-
if($options['minify_scripts'] == 'on')
|
47 |
-
$js_data = Minifier::minify($js_data);
|
48 |
-
|
49 |
-
if(!file_put_contents($js_file, $js_data)):
|
50 |
-
throw new \Exception('You don\'t have permissions to write external JS file - please check permissions.');
|
51 |
-
endif;
|
52 |
-
|
53 |
-
else:
|
54 |
-
/*
|
55 |
-
* TODO: Do some tidy up like removing external files if this option is not set - be a good citizen!
|
56 |
-
*/
|
57 |
-
endif;
|
58 |
-
|
59 |
-
/*
|
60 |
-
* Update translations for WPML
|
61 |
-
*/
|
62 |
-
foreach($this->translatables as $option_name)
|
63 |
-
if(isset($options[$option_name]))
|
64 |
-
do_action('wpml_register_single_string', 'Responsive Menu', $option_name, $options[$option_name]);
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Validation/Validator.php
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Validation;
|
4 |
-
|
5 |
-
class Validator {
|
6 |
-
|
7 |
-
private $errors;
|
8 |
-
|
9 |
-
public function validate($options) {
|
10 |
-
foreach($this->validation_map as $validator_name => $options_list):
|
11 |
-
foreach($options_list as $option):
|
12 |
-
if(isset($options[$option])):
|
13 |
-
$validator_obj = 'ResponsiveMenu\Validation\Validators\\' . $validator_name;
|
14 |
-
$validator = new $validator_obj($options[$option]);
|
15 |
-
if(!$validator->validate()):
|
16 |
-
$nice_name = str_replace('_', ' ', ucwords($option));
|
17 |
-
$this->errors[$option][] = 'Validation failed on <a class="validation-error scroll-to-option" href="#responsive-menu-' . str_replace('_', '-', $option) . '">' . $nice_name . '</a>: ' . $validator->getErrorMessage();
|
18 |
-
endif;
|
19 |
-
endif;
|
20 |
-
endforeach;
|
21 |
-
endforeach;
|
22 |
-
|
23 |
-
if(!empty($this->errors))
|
24 |
-
return false;
|
25 |
-
|
26 |
-
return true;
|
27 |
-
}
|
28 |
-
|
29 |
-
public function getErrors() {
|
30 |
-
return $this->errors;
|
31 |
-
}
|
32 |
-
|
33 |
-
private $validation_map = [
|
34 |
-
|
35 |
-
// Numeric Validators
|
36 |
-
'Number' => [
|
37 |
-
'breakpoint',
|
38 |
-
'button_line_width',
|
39 |
-
'button_line_height',
|
40 |
-
'button_line_margin',
|
41 |
-
'button_width',
|
42 |
-
'button_height',
|
43 |
-
'button_top',
|
44 |
-
'animation_speed',
|
45 |
-
'transition_speed',
|
46 |
-
'button_font_size',
|
47 |
-
'button_title_line_height',
|
48 |
-
'menu_width',
|
49 |
-
'menu_title_font_size',
|
50 |
-
'menu_border_width',
|
51 |
-
'menu_font_size',
|
52 |
-
'menu_links_height',
|
53 |
-
'menu_links_line_height',
|
54 |
-
'submenu_arrow_height',
|
55 |
-
'submenu_arrow_width',
|
56 |
-
'menu_depth_0',
|
57 |
-
'menu_depth_1',
|
58 |
-
'menu_depth_2',
|
59 |
-
'menu_depth_3',
|
60 |
-
'menu_depth_4',
|
61 |
-
'menu_depth_5',
|
62 |
-
],
|
63 |
-
|
64 |
-
// Positive Digits
|
65 |
-
'Positive' => [
|
66 |
-
'breakpoint',
|
67 |
-
],
|
68 |
-
|
69 |
-
// Colour Validators
|
70 |
-
'Colour' => [
|
71 |
-
'button_background_colour',
|
72 |
-
'button_background_colour_hover',
|
73 |
-
'button_line_colour',
|
74 |
-
'button_text_colour',
|
75 |
-
'menu_background_colour',
|
76 |
-
'menu_item_background_colour',
|
77 |
-
'menu_item_background_hover_colour',
|
78 |
-
'menu_item_border_colour',
|
79 |
-
'menu_item_border_colour_hover',
|
80 |
-
'menu_title_background_colour',
|
81 |
-
'menu_title_background_hover_colour',
|
82 |
-
'menu_current_item_background_colour',
|
83 |
-
'menu_current_item_background_hover_colour',
|
84 |
-
'menu_current_item_border_colour',
|
85 |
-
'menu_current_item_border_hover_colour',
|
86 |
-
'menu_title_colour',
|
87 |
-
'menu_title_hover_colour',
|
88 |
-
'menu_link_colour',
|
89 |
-
'menu_link_hover_colour',
|
90 |
-
'menu_current_link_colour',
|
91 |
-
'menu_current_link_hover_colour',
|
92 |
-
'menu_sub_arrow_border_colour',
|
93 |
-
'menu_sub_arrow_border_hover_colour',
|
94 |
-
'menu_sub_arrow_border_colour_active',
|
95 |
-
'menu_sub_arrow_border_hover_colour_active',
|
96 |
-
'menu_sub_arrow_background_colour',
|
97 |
-
'menu_sub_arrow_background_hover_colour',
|
98 |
-
'menu_sub_arrow_background_colour_active',
|
99 |
-
'menu_sub_arrow_background_hover_colour_active',
|
100 |
-
'menu_sub_arrow_shape_colour',
|
101 |
-
'menu_sub_arrow_shape_hover_colour',
|
102 |
-
'menu_sub_arrow_shape_colour_active',
|
103 |
-
'menu_sub_arrow_shape_hover_colour_active',
|
104 |
-
'menu_additional_content_colour',
|
105 |
-
'menu_overlay_colour',
|
106 |
-
'menu_search_box_text_colour',
|
107 |
-
'menu_search_box_border_colour',
|
108 |
-
'menu_search_box_background_colour',
|
109 |
-
'menu_search_box_placeholder_colour',
|
110 |
-
'button_background_colour_active',
|
111 |
-
'button_line_colour_hover',
|
112 |
-
'button_line_colour_active',
|
113 |
-
'menu_container_background_colour'
|
114 |
-
]
|
115 |
-
|
116 |
-
];
|
117 |
-
|
118 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Validation/Validators/BaseValidator.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Validation\Validators;
|
4 |
-
|
5 |
-
abstract class BaseValidator {
|
6 |
-
|
7 |
-
protected $error;
|
8 |
-
protected $data;
|
9 |
-
|
10 |
-
abstract public function validate();
|
11 |
-
|
12 |
-
public function __construct($data) {
|
13 |
-
$this->data = $data;
|
14 |
-
}
|
15 |
-
|
16 |
-
public function getErrorMessage() {
|
17 |
-
return $this->error;
|
18 |
-
}
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Validation/Validators/Colour.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Validation\Validators;
|
4 |
-
|
5 |
-
class Colour extends BaseValidator {
|
6 |
-
|
7 |
-
public function validate() {
|
8 |
-
$valid_colour = false;
|
9 |
-
|
10 |
-
// First check valid Hex
|
11 |
-
if(preg_match('/^#(?:[0-9a-f]{3}){1,2}$/i', $this->data))
|
12 |
-
$valid_colour = true;
|
13 |
-
|
14 |
-
// Next check valid rgba()
|
15 |
-
if(preg_match('/rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)/i', $this->data))
|
16 |
-
$valid_colour = true;
|
17 |
-
|
18 |
-
if(!$valid_colour)
|
19 |
-
$this->error = 'Invalid colour value';
|
20 |
-
|
21 |
-
return $valid_colour;
|
22 |
-
}
|
23 |
-
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Validation/Validators/Number.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Validation\Validators;
|
4 |
-
|
5 |
-
class Number extends BaseValidator {
|
6 |
-
|
7 |
-
public function validate() {
|
8 |
-
$valid_integer = false;
|
9 |
-
|
10 |
-
if(is_numeric($this->data))
|
11 |
-
$valid_integer = true;
|
12 |
-
|
13 |
-
if(!$valid_integer)
|
14 |
-
$this->error = 'Invalid number';
|
15 |
-
|
16 |
-
return $valid_integer;
|
17 |
-
}
|
18 |
-
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/Validation/Validators/Positive.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace ResponsiveMenu\Validation\Validators;
|
4 |
-
|
5 |
-
class Positive extends BaseValidator {
|
6 |
-
|
7 |
-
public function validate() {
|
8 |
-
$is_positive = false;
|
9 |
-
|
10 |
-
if($this->data >= 0)
|
11 |
-
$is_positive = true;
|
12 |
-
|
13 |
-
if(!$is_positive)
|
14 |
-
$this->error = 'Number must be 0 or positive';
|
15 |
-
|
16 |
-
return $is_positive;
|
17 |
-
}
|
18 |
-
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|