| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPRMenu Admin Framework |
| 4 |
* |
| 5 |
* @package WP Responsive Menu |
| 6 |
* @author MagniGenie |
| 7 |
* @copyright Copyright (c) 2019, WP Responsive Menu |
| 8 |
* @link https://magnigenie.com/ |
| 9 |
* @since WP Responsive Menu 3.1.4 |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
class WPRMenu_Framework_Admin { |
| 15 |
|
| 16 |
/** |
| 17 |
* Page hook for the options screen |
| 18 |
* |
| 19 |
* @since 1.7.0 |
| 20 |
* @type string |
| 21 |
*/ |
| 22 |
protected $options_screen = null; |
| 23 |
|
| 24 |
/** |
| 25 |
* Hook in the scripts and styles |
| 26 |
* |
| 27 |
* @since 1.7.0 |
| 28 |
*/ |
| 29 |
public function init() { |
| 30 |
|
| 31 |
//Gets options to load |
| 32 |
$options = & WPRMenu_Framework::_wpr_optionsframework_options(); |
| 33 |
|
| 34 |
//Checks if options are available |
| 35 |
if ( $options ) { |
| 36 |
|
| 37 |
// Add the options page and menu item. |
| 38 |
add_action( 'admin_menu', array( $this, 'add_wprmenu_options_page' ) ); |
| 39 |
|
| 40 |
// Add the required scripts and styles |
| 41 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) ); |
| 42 |
|
| 43 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); |
| 44 |
|
| 45 |
// Settings need to be registered after admin_init |
| 46 |
add_action( 'admin_init', array( $this, 'settings_init' ) ); |
| 47 |
|
| 48 |
// Adds options menu to the admin bar |
| 49 |
add_action( 'wp_before_admin_bar_render', array( $this, 'wpr_optionsframework_admin_bar' ) ); |
| 50 |
|
| 51 |
add_action( 'admin_menu', array( $this, 'wpr_demo_page' ), 30 ); |
| 52 |
|
| 53 |
add_action( 'admin_enqueue_scripts', array( $this, 'wprm_demo_import_styles' ) ); |
| 54 |
|
| 55 |
add_action( 'admin_enqueue_scripts', array( $this, 'wprm_demo_import_scripts' ) ); |
| 56 |
} |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Registers the settings |
| 62 |
* |
| 63 |
* @since 1.7.0 |
| 64 |
*/ |
| 65 |
function settings_init() { |
| 66 |
|
| 67 |
//Load WPRMenu Framework Settings |
| 68 |
$wpr_optionsframework_settings = get_option( 'wpr_optionsframework' ); |
| 69 |
|
| 70 |
// Registers the settings fields and callback |
| 71 |
register_setting( 'wpr_optionsframework', $wpr_optionsframework_settings['id'], array ( $this, 'validate_options' ) ); |
| 72 |
|
| 73 |
// Displays notice after options save |
| 74 |
add_action( 'wpr_optionsframework_after_validate', array( $this, 'save_options_notice' ) ); |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
static function menu_settings() { |
| 79 |
|
| 80 |
$menu = array( |
| 81 |
|
| 82 |
// Modes: submenu, menu |
| 83 |
'mode' => 'menu', |
| 84 |
|
| 85 |
// Submenu default settings |
| 86 |
'page_title' => __( 'Theme Options', 'wprmenu'), |
| 87 |
'menu_title' => __('Theme Options', 'wprmenu'), |
| 88 |
'capability' => 'edit_theme_options', |
| 89 |
'menu_slug' => 'wprmenu-framework', |
| 90 |
'parent_slug' => 'themes.php', |
| 91 |
|
| 92 |
// Menu default settings |
| 93 |
'icon_url' => 'dashicons-menu', |
| 94 |
'position' => '61' |
| 95 |
|
| 96 |
); |
| 97 |
|
| 98 |
return apply_filters( 'wpr_optionsframework_menu', $menu ); |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Add a subpage called "Theme Options" to the appearance menu. |
| 103 |
* |
| 104 |
* @since 1.7.0 |
| 105 |
*/ |
| 106 |
function add_wprmenu_options_page() { |
| 107 |
|
| 108 |
$menu = $this->menu_settings(); |
| 109 |
|
| 110 |
switch( $menu['mode'] ) { |
| 111 |
|
| 112 |
case 'menu': |
| 113 |
$this->options_screen = add_menu_page( |
| 114 |
$menu['page_title'], |
| 115 |
$menu['menu_title'], |
| 116 |
$menu['capability'], |
| 117 |
$menu['menu_slug'], |
| 118 |
array( $this, 'wprmenu_render_options_page' ), |
| 119 |
$menu['icon_url'], |
| 120 |
$menu['position'] |
| 121 |
); |
| 122 |
break; |
| 123 |
|
| 124 |
default: |
| 125 |
// http://codex.wordpress.org/Function_Reference/add_submenu_page |
| 126 |
$this->options_screen = add_submenu_page( |
| 127 |
$menu['parent_slug'], |
| 128 |
$menu['page_title'], |
| 129 |
$menu['menu_title'], |
| 130 |
$menu['capability'], |
| 131 |
$menu['menu_slug'], |
| 132 |
array( $this, 'wprmenu_render_options_page' ) ); |
| 133 |
break; |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
public function wprmenu_admin_url() { |
| 138 |
return untrailingslashit( plugins_url( '/inc/', WPRMENU_FILE ) ); |
| 139 |
} |
| 140 |
|
| 141 |
/** |
| 142 |
* Loads the required stylesheets |
| 143 |
* |
| 144 |
* @since 1.7.0 |
| 145 |
*/ |
| 146 |
|
| 147 |
function enqueue_admin_styles( $hook ) { |
| 148 |
|
| 149 |
if ( $this->options_screen != $hook ){ |
| 150 |
return; |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
//Register styles. |
| 155 |
wp_register_style( 'wprmenu_settings_framework_styles', $this->wprmenu_admin_url() . '/assets/css/wprmenu-settings-framework.css', array(), WPRMENU_VERSION ); |
| 156 |
wp_register_style( 'wprmenu_icons', $this->wprmenu_admin_url() . '/assets/icons/wpr-icons.css', array(), WPRMENU_VERSION ); |
| 157 |
wp_register_style( 'wprmenu_iconpicker', $this->wprmenu_admin_url() . '/assets/css/jquery.fonticonpicker.min.css', array(), WPRMENU_VERSION ); |
| 158 |
wp_register_style( 'wprmenu_bootflat', $this->wprmenu_admin_url() . '/assets/css/site.min.css', array(), WPRMENU_VERSION ); |
| 159 |
|
| 160 |
//Enqueue styles. |
| 161 |
wp_enqueue_style( 'wprmenu_settings_framework_styles' ); |
| 162 |
wp_enqueue_style( 'wprmenu_icons' ); |
| 163 |
wp_enqueue_style( 'wprmenu_iconpicker' ); |
| 164 |
wp_enqueue_style( 'wprmenu_bootflat' ); |
| 165 |
wp_enqueue_style( 'wp-color-picker' ); |
| 166 |
} |
| 167 |
|
| 168 |
public function wprm_demo_import_styles( $hook ) { |
| 169 |
$screen = get_current_screen(); |
| 170 |
|
| 171 |
$current_page = 'wpr-menu_page_wprmenu-demo-import'; |
| 172 |
|
| 173 |
wp_register_style( 'Sweetalert2-css', $this->wprmenu_admin_url() . '/assets/css/sweetalert2.min.css', array(), WPRMENU_VERSION ); |
| 174 |
wp_register_style( 'wpr_import_demo', $this->wprmenu_admin_url() . '/assets/css/wpr_import_demo.css', array(), WPRMENU_VERSION ); |
| 175 |
|
| 176 |
if( $screen->id !== $current_page ) |
| 177 |
return; |
| 178 |
|
| 179 |
// Enqueue SweetAlert2 Style |
| 180 |
wp_enqueue_style( 'Sweetalert2-css' ); |
| 181 |
wp_enqueue_style( 'wpr_import_demo' ); |
| 182 |
} |
| 183 |
|
| 184 |
function wprm_demo_import_scripts( $hook ) { |
| 185 |
$screen = get_current_screen(); |
| 186 |
|
| 187 |
$current_page = 'wpr-menu_page_wprmenu-demo-import'; |
| 188 |
|
| 189 |
if( $screen->id !== $current_page ){ |
| 190 |
return; |
| 191 |
} |
| 192 |
|
| 193 |
$options = get_option( 'wprmenu_options' ); |
| 194 |
|
| 195 |
//Exit Intent |
| 196 |
wp_register_script( 'wpr-exit-intent', $this->wprmenu_admin_url() . '/assets/js/wpr-exit-intent.js', array( 'jquery' ), WPRMENU_VERSION ); |
| 197 |
|
| 198 |
// Enqueue SweetAlert2 JS |
| 199 |
wp_register_script( 'Sweetalert2-js', $this->wprmenu_admin_url() . '/assets/js/sweetalert2.all.min.js', array( 'jquery'), WPRMENU_VERSION ); |
| 200 |
|
| 201 |
wp_register_script( 'wprmenu-import-demo', $this->wprmenu_admin_url() . '/assets/js/wprmenu-import-demo.js', array('jquery', 'wpr-exit-intent', 'Sweetalert2-js'), WPRMENU_VERSION ); |
| 202 |
|
| 203 |
$enable_preview = !empty( $options->wpr_live_preview ) ? $options->wpr_live_preview : 0; |
| 204 |
|
| 205 |
$params = array( |
| 206 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 207 |
'please_wait' => __('Please Wait !', 'wprmenu'), |
| 208 |
'import_done' => __('Import Done', 'wprmenu'), |
| 209 |
'please_reload' => __('Please reload the page by doing click the button below', 'wprmenu'), |
| 210 |
'navigating_away' => __('Seems like navigating away', 'wprmenu'), |
| 211 |
'confirm_message' => __('Are you sure to navigate away? Please save all the changes otherwise the recent changes will be reverted back', 'wprmenu'), |
| 212 |
'options_saved' => __( 'Options Saved!', 'wprmenu'), |
| 213 |
'options_not_saved' => __( 'Options Not Saved!', 'wprmenu'), |
| 214 |
'options_saved_msg' => __( 'The options has been saved. Please reload this page by doing click on the button below.', 'wprmenu'), |
| 215 |
'import_error_title' => __('Oops...', 'wprmenu'), |
| 216 |
'pro_version_error' => __('Please upgrade to PRO Version to import this demo.', 'wprmenu'), |
| 217 |
'preview_url' => home_url(), |
| 218 |
'enable_preview' => $enable_preview, |
| 219 |
'import_error' => __('Something went wrong', 'wprmenu'), |
| 220 |
'nonce' => wp_create_nonce( 'wprmenu-nonce' ), |
| 221 |
); |
| 222 |
|
| 223 |
wp_localize_script( 'wprmenu-import-demo' , 'wprmenu_params', $params ); |
| 224 |
|
| 225 |
wp_enqueue_script( 'wpr-exit-intent' ); |
| 226 |
wp_enqueue_script( 'Sweetalert2-js' ); |
| 227 |
wp_enqueue_script( 'wprmenu-import-demo' ); |
| 228 |
} |
| 229 |
|
| 230 |
/** |
| 231 |
* Loads the required javascript |
| 232 |
* |
| 233 |
* @since 1.7.0 |
| 234 |
*/ |
| 235 |
function enqueue_admin_scripts( $hook ) { |
| 236 |
|
| 237 |
if ( $this->options_screen != $hook ){ |
| 238 |
return; |
| 239 |
} |
| 240 |
|
| 241 |
// Register scripts. |
| 242 |
wp_register_script( 'wpr-bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', array( 'jquery'), WPRMENU_VERSION ); |
| 243 |
wp_register_script( 'wpr-ace', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/js/ace-min-noconflict/ace.js', array( 'jquery' ), WPRMENU_VERSION ); |
| 244 |
wp_register_script( 'wpr-ace-theme-chrome', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/js/ace-min-noconflict/theme-chrome.js', array( 'jquery' ), WPRMENU_VERSION ); |
| 245 |
wp_register_script( 'wpr-ace-mode-css', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/js/ace-min-noconflict/mode-css.js', array( 'jquery' ), WPRMENU_VERSION ); |
| 246 |
wp_register_script( 'icon-picker', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/js/jquery.fonticonpicker.min.js', array( 'jquery' ), WPRMENU_VERSION ); |
| 247 |
wp_enqueue_style( 'wpr_select2_style', $this->wprmenu_admin_url() . '/assets/css/select2.min.css', WPRMENU_VERSION ); |
| 248 |
|
| 249 |
wp_register_script( 'Select2-js', $this->wprmenu_admin_url() . '/assets/js/select2.full.js', array( 'jquery'), WPRMENU_VERSION ); |
| 250 |
wp_register_script( 'wpr-exit-intent', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/js/wpr-exit-intent.js', array( 'jquery' ), WPRMENU_VERSION ); |
| 251 |
wp_enqueue_style( 'Sweetalert2-css', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/css/sweetalert2.min.css', WPRMENU_VERSION ); |
| 252 |
wp_register_script( 'Sweetalert2-js', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/js/sweetalert2.all.min.js', array( 'jquery'), WPRMENU_VERSION ); |
| 253 |
wp_register_script( 'wprmenu-options', WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY . 'assets/js/wprmenu-options.js', array( 'jquery','wp-color-picker', 'Select2-js', 'wpr-ace', 'wpr-exit-intent', 'Sweetalert2-js' ), WPRMENU_VERSION ); |
| 254 |
|
| 255 |
$params = array( |
| 256 |
'options_path' => WPRMENU_OPTIONS_FRAMEWORK_DIRECTORY, |
| 257 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 258 |
'view_demo' => __('View Demo', 'wprmenu'), |
| 259 |
'preview_done' => __('Preview Done', 'wprmenu'), |
| 260 |
'loading_preview' => __('Loading Preview', 'wprmenu'), |
| 261 |
'import_demo' => __('Import Demo', 'wprmenu'), |
| 262 |
'import_error' => __('Something went wrong', 'wprmenu'), |
| 263 |
'please_wait' => __('Please Wait !', 'wprmenu'), |
| 264 |
'please_reload' => __('Please reload the page by doing click the button below', 'wprmenu'), |
| 265 |
'reload' => __('Reload', 'wprmenu'), |
| 266 |
'import_error_title' => __('Oops...', 'wprmenu'), |
| 267 |
'import_error' => __('Something went wrong', 'wprmenu'), |
| 268 |
'import_done' => __('Import Done', 'wprmenu'), |
| 269 |
'update_license_key' => __('Please Update Your License Key To Import Demo', 'wprmenu'), |
| 270 |
'pro_message' => __('Import requires PRO version', 'wprmenu'), |
| 271 |
'site_url' => get_site_url(), |
| 272 |
'please_reload' => __('Please reload the page by doing click the button below', 'wprmenu'), |
| 273 |
'reload' => __('Reload', 'wprmenu'), |
| 274 |
'navigating_away' => __('Seems like navigating away', 'wprmenu'), |
| 275 |
'confirm_message' => __('Are you sure to navigate away? Please save all the changes otherwise the recent changes will be reverted back', 'wprmenu'), |
| 276 |
'pro_version_text' => __('Pro Version', 'wprmenu'), |
| 277 |
'pro_version_upgrade_error' => __('This demo requires pro version to be activated', 'wprmenu'), |
| 278 |
'upgrade_to_pro' => __('Upgrade to PRO to use this option.', 'wprmenu'), |
| 279 |
'ugrade_pro_link' => WPRMENU_PRO_LINK, |
| 280 |
'preview_url' => get_home_url(), |
| 281 |
'social_link_remove_confirmation' => __( 'Do you really want to remove this social link?', 'wprmenu' ), |
| 282 |
); |
| 283 |
|
| 284 |
wp_localize_script( 'wprmenu-options', 'wprmenu_params' , $params ); |
| 285 |
|
| 286 |
wp_enqueue_script( 'wpr-bootstrap' ); |
| 287 |
wp_enqueue_script( 'wpr-ace' ); |
| 288 |
wp_enqueue_script( 'wpr-ace-theme-chrome' ); |
| 289 |
wp_enqueue_script( 'wpr-ace-mode-css' ); |
| 290 |
wp_enqueue_script( 'icon-picker' ); |
| 291 |
wp_enqueue_script( 'Select2-js' ); |
| 292 |
wp_enqueue_script( 'wpr-exit-intent' ); |
| 293 |
wp_enqueue_script( 'Sweetalert2-js' ); |
| 294 |
wp_enqueue_script( 'wprmenu-options' ); |
| 295 |
|
| 296 |
// Inline scripts from options-interface.php |
| 297 |
add_action( 'admin_head', array( $this, 'wpr_of_admin_head' ) ); |
| 298 |
} |
| 299 |
|
| 300 |
function wpr_of_admin_head() { |
| 301 |
// Hook to add custom scripts |
| 302 |
do_action( 'wpr_optionsframework_custom_scripts' ); |
| 303 |
} |
| 304 |
|
| 305 |
/** |
| 306 |
* Builds out the options panel. |
| 307 |
* |
| 308 |
* If we were using the Settings API as it was intended we would use |
| 309 |
* do_settings_sections here. But as we don't want the settings wrapped in a table, |
| 310 |
* we'll call our own custom wpr_optionsframework_fields. See options-interface.php |
| 311 |
* for specifics on how each individual field is generated. |
| 312 |
* |
| 313 |
* Nonces are provided using the settings_fields() |
| 314 |
* |
| 315 |
* @since 1.7.0 |
| 316 |
*/ |
| 317 |
function wprmenu_render_options_page() { ?> |
| 318 |
|
| 319 |
<div id="wpr_optionsframework-wrap" class="wrap"> |
| 320 |
<?php $menu = $this->menu_settings(); ?> |
| 321 |
<h2><?php echo esc_html( $menu['page_title'] ); ?></h2> |
| 322 |
|
| 323 |
<div class="clear"></div> |
| 324 |
|
| 325 |
<div class="wpr-options-settings-wrapper"> |
| 326 |
<?php settings_errors( 'wprmenu-framework' ); ?> |
| 327 |
|
| 328 |
<!--Navigation Tabs Starts Here --> |
| 329 |
<div class="mg-navtabs-wrapper"> |
| 330 |
<?php echo WPRMenu_Framework_Interface::wpr_optionsframework_tabs(); ?> |
| 331 |
</div> |
| 332 |
<!-- Navigation Tabs Ends Here --> |
| 333 |
|
| 334 |
<!-- Settings Panel Starts Here --> |
| 335 |
<div class="mg-settings-panel-right"> |
| 336 |
<div id="wpr_optionsframework-metabox" class="metabox-holder"> |
| 337 |
|
| 338 |
<div id="wpr_optionsframework" class="postbox"> |
| 339 |
<form id="wpr_form_settings" action="options.php" method="post"> |
| 340 |
<?php settings_fields( 'wpr_optionsframework' ); ?> |
| 341 |
<?php WPRMenu_Framework_Interface::wpr_optionsframework_fields(); /* Settings */ ?> |
| 342 |
<input type="submit" class="reset-button wpr-reset-button button-secondary" style="display: none;" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'wpr' ); ?>" /> |
| 343 |
</form> |
| 344 |
</div> <!-- / #container --> |
| 345 |
|
| 346 |
<div class="mg-options-submit-wrap"> |
| 347 |
|
| 348 |
<!-- Submit Settings --> |
| 349 |
<div id="wpr_optionsframework-submit"> |
| 350 |
<?php WPRMenu_Framework_Interface::wpr_render_form_button(); /* Submit/Reset Buttons */ ?> |
| 351 |
|
| 352 |
<?php WPRMenu_Framework_Interface::wpr_render_floating_buttons(); /* Floating Buttons */ ?> |
| 353 |
</div> <!-- / Submit Settings --> |
| 354 |
|
| 355 |
</div> |
| 356 |
|
| 357 |
</div> |
| 358 |
|
| 359 |
</div> |
| 360 |
|
| 361 |
</div> <!-- / .wpr-options-settings-wrapper--> |
| 362 |
<?php do_action( 'wpr_optionsframework_after' ); ?> |
| 363 |
|
| 364 |
</div> <!-- / .wrap --> |
| 365 |
<div class="clear"></div> |
| 366 |
|
| 367 |
<?php |
| 368 |
} |
| 369 |
|
| 370 |
/** |
| 371 |
* Validate Options. |
| 372 |
* |
| 373 |
* This runs after the submit/reset button has been clicked and |
| 374 |
* validates the inputs. |
| 375 |
* |
| 376 |
* @uses $_POST['reset'] to restore default options |
| 377 |
*/ |
| 378 |
function validate_options( $input ) { |
| 379 |
|
| 380 |
/* |
| 381 |
* Restore Defaults. |
| 382 |
* |
| 383 |
* In the event that the user clicked the "Restore Defaults" |
| 384 |
* button, the options defined in the theme's options.php |
| 385 |
* file will be added to the option for the active theme. |
| 386 |
*/ |
| 387 |
|
| 388 |
if ( isset( $_POST['reset'] ) ) { |
| 389 |
add_settings_error( 'wprmenu-framework', 'restore_defaults', __( 'Default options restored.', 'wprmenu' ), 'updated fade' ); |
| 390 |
return $this->get_default_values(); |
| 391 |
} |
| 392 |
|
| 393 |
/* |
| 394 |
* Update Settings |
| 395 |
* |
| 396 |
* This used to check for $_POST['update'], but has been updated |
| 397 |
* to be compatible with the theme customizer introduced in WordPress 3.4 |
| 398 |
*/ |
| 399 |
|
| 400 |
$clean = array(); |
| 401 |
$options = & WPRMenu_Framework::_wpr_optionsframework_options(); |
| 402 |
foreach ( $options as $option ) { |
| 403 |
|
| 404 |
if ( ! isset( $option['id'] ) ) { |
| 405 |
continue; |
| 406 |
} |
| 407 |
|
| 408 |
if ( ! isset( $option['type'] ) ) { |
| 409 |
continue; |
| 410 |
} |
| 411 |
|
| 412 |
$id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) ); |
| 413 |
|
| 414 |
// Set checkbox to false if it wasn't sent in the $_POST |
| 415 |
if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) { |
| 416 |
$input[$id] = false; |
| 417 |
} |
| 418 |
|
| 419 |
// Set each item in the multicheck to false if it wasn't sent in the $_POST |
| 420 |
if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) { |
| 421 |
foreach ( $option['options'] as $key => $value ) { |
| 422 |
$input[$id][$key] = false; |
| 423 |
} |
| 424 |
} |
| 425 |
|
| 426 |
// For a value to be submitted to database it must pass through a sanitization filter |
| 427 |
if ( has_filter( 'wpr_of_sanitize_' . $option['type'] ) && !empty( $input[$id] ) ) { |
| 428 |
$clean[$id] = apply_filters( 'wpr_of_sanitize_' . $option['type'], $input[$id], $option ); |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
// Hook to run after validation |
| 433 |
do_action( 'wpr_optionsframework_after_validate', $clean ); |
| 434 |
|
| 435 |
return $clean; |
| 436 |
} |
| 437 |
|
| 438 |
/** |
| 439 |
* Display message when options have been saved |
| 440 |
*/ |
| 441 |
|
| 442 |
function save_options_notice() { |
| 443 |
add_settings_error( 'wprmenu-framework', 'save_options', __( 'WP Responsive Menu Options Saved.', 'wprmenu' ), 'updated fade in' ); |
| 444 |
} |
| 445 |
|
| 446 |
/** |
| 447 |
* Get the default values for all the theme options |
| 448 |
* |
| 449 |
* Get an array of all default values as set in |
| 450 |
* options.php. The 'id','std' and 'type' keys need |
| 451 |
* to be defined in the configuration array. In the |
| 452 |
* event that these keys are not present the option |
| 453 |
* will not be included in this function's output. |
| 454 |
* |
| 455 |
* @return array Re-keyed options configuration array. |
| 456 |
* |
| 457 |
*/ |
| 458 |
|
| 459 |
function get_default_values() { |
| 460 |
$output = array(); |
| 461 |
$config = & WPRMenu_Framework::_wpr_optionsframework_options(); |
| 462 |
foreach ( (array) $config as $option ) { |
| 463 |
if ( ! isset( $option['id'] ) ) { |
| 464 |
continue; |
| 465 |
} |
| 466 |
if ( ! isset( $option['std'] ) ) { |
| 467 |
continue; |
| 468 |
} |
| 469 |
if ( ! isset( $option['type'] ) ) { |
| 470 |
continue; |
| 471 |
} |
| 472 |
if ( has_filter( 'wpr_of_sanitize_' . $option['type'] ) ) { |
| 473 |
$output[$option['id']] = apply_filters( 'wpr_of_sanitize_' . $option['type'], $option['std'], $option ); |
| 474 |
} |
| 475 |
} |
| 476 |
return $output; |
| 477 |
} |
| 478 |
|
| 479 |
/** |
| 480 |
* Add options menu item to admin bar |
| 481 |
*/ |
| 482 |
|
| 483 |
function wpr_optionsframework_admin_bar() { |
| 484 |
|
| 485 |
$menu = $this->menu_settings(); |
| 486 |
|
| 487 |
global $wp_admin_bar; |
| 488 |
|
| 489 |
if ( 'menu' == $menu['mode'] ) { |
| 490 |
$href = admin_url( 'admin.php?page=' . $menu['menu_slug'] ); |
| 491 |
} else { |
| 492 |
$href = admin_url( 'themes.php?page=' . $menu['menu_slug'] ); |
| 493 |
} |
| 494 |
|
| 495 |
$args = array( |
| 496 |
'parent' => 'appearance', |
| 497 |
'id' => 'wpr_of_theme_options', |
| 498 |
'title' => $menu['menu_title'], |
| 499 |
'href' => $href |
| 500 |
); |
| 501 |
|
| 502 |
$wp_admin_bar->add_menu( apply_filters( 'wpr_optionsframework_admin_bar', $args ) ); |
| 503 |
} |
| 504 |
|
| 505 |
public function wpr_demo_page() { |
| 506 |
add_submenu_page( |
| 507 |
'wp-responsive-menu', |
| 508 |
'Import Demo', |
| 509 |
'Import Demo', |
| 510 |
'manage_options', |
| 511 |
'wprmenu-demo-import', |
| 512 |
array( $this, 'wpr_import_demo_settings_page' ) |
| 513 |
); |
| 514 |
} |
| 515 |
|
| 516 |
public function wpr_import_demo_settings_page() { |
| 517 |
?> |
| 518 |
<div class="wrap wprmenu-import-wrap"> |
| 519 |
<h2><?php esc_attr_e('Import Demo', 'wprmenu'); ?></h2> |
| 520 |
|
| 521 |
<div class="mg-reset mg-wrap"> |
| 522 |
<div class="mg-content"> |
| 523 |
<div class="mg-main"> |
| 524 |
<div class="mg-row"> |
| 525 |
<div class="mg-column mg-full-width"> |
| 526 |
<div class="mg-box" style="background-color: transparent; box-shadow: none;"> |
| 527 |
|
| 528 |
<!-- Demo Import Heading Here--> |
| 529 |
<div class="mg-box-content" style="margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);"> |
| 530 |
<h3><span><?php _e( 'Easy Setup With Our Predefined Demos |
| 531 |
', 'wprmenu' ); ?> :)</span></h3> |
| 532 |
</div> |
| 533 |
<!-- Demo Import Heading Here --> |
| 534 |
|
| 535 |
<div class="mg-box-content"> |
| 536 |
<?php echo WPRMenu_Framework_Interface::wprmenu_get_demodata('Free'); ?> |
| 537 |
</div> |
| 538 |
|
| 539 |
<div class="mg-box-content"> |
| 540 |
<?php echo WPRMenu_Framework_Interface::wprmenu_get_demodata('Pro'); ?> |
| 541 |
</div> |
| 542 |
|
| 543 |
</div> |
| 544 |
</div> |
| 545 |
<div class="clear"></div> |
| 546 |
</div> |
| 547 |
</div> |
| 548 |
</div> |
| 549 |
</div> |
| 550 |
|
| 551 |
</div> |
| 552 |
<?php |
| 553 |
} |
| 554 |
|
| 555 |
} |
| 556 |
|