Submit
Path:
~
/
home
/
getwphos
/
public_html
/
deerguard
/
wp-content
/
plugins
/
garland-addon
/
admin
/
extension
/
File Content:
class.custom-sidebars.php
<?php class Garland_Custom_Sidebars { private static $_instance = null; public function __construct() { add_action( 'admin_menu', array( $this, 'garland_addon_admin_menu' ) ); add_action( 'wp_ajax_garland-custom-sidebar-export', array( $this, 'garland_custom_sidebar_export' ) ); } public static function garland_addon_admin_menu(){ add_submenu_page( 'garland-welcome', esc_html__( 'Custom Sidebars', 'garland-addon' ), esc_html__( 'Custom Sidebars', 'garland-addon' ), 'manage_options', 'garland-sidebars', array( 'Garland_Custom_Sidebars', 'garland_sidebar_admin_page' ) ); } public static function garland_sidebar_admin_page(){ $garland_theme = wp_get_theme(); ?> <div class="garland-settings-wrap"> <div class="garland-header-bar"> <div class="garland-header-left"> <div class="garland-admin-logo-inline"> <img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/brand-logo.png' ); ?>" alt="garland-logo"> </div><!-- .garland-admin-logo-inline --> <h2 class="title"><?php esc_html_e( 'Garland Custom Sidebars', 'garland-addon' ); ?><span class="garland-version"><?php echo esc_attr( $garland_theme->get( 'Version' ) ); ?></span></h2> </div><!-- .garland-header-left --> <div class="garland-header-right"> <a href="<?php echo esc_url( 'https://wordpress.zozothemes.com/garland/' ); ?>" class="button garland-btn"><?php esc_html_e( 'Live Demo', 'garland-addon' ); ?></a> </div><!-- .garland-header-right --> </div><!-- .garland-header-bar --> <div class="garland-settings-tabs garland-custom-sidebar-wrap"> <div id="garland-general" class="garland-settings-tab active"> <div class="container"> <div class="row"> <div class="col-4"> <div class="media admin-box"> <div class="admin-box-icon mr-3"> <span class="dashicons dashicons-welcome-widgets-menus"></span> </div> <div class="media-body admin-box-info"> <h3 class="admin-box-title"><?php esc_html_e( 'Add New Sidebar', 'garland-addon' ); ?></h3> <div class="admin-box-content"> <?php esc_html_e( 'You can add new custom sidebar here. Also we give you option to remove or delete custom sidebars.', 'garland-addon' ); ?> </div> <?php $sidebars = ''; $sidebar_opt_name = 'garland_custom_sidebars'; $sidebars = get_option( $sidebar_opt_name ); if ( isset( $_POST['garland_custom_sidebar_nonce'] ) && wp_verify_nonce( $_POST['garland_custom_sidebar_nonce'], 'garland-()@)(*^#@!' ) ) { if (isset($_POST['garland_sidebar_name']) && !empty($_POST['garland_sidebar_name'])) { $sidebar_name = sanitize_text_field($_POST['garland_sidebar_name']); // Sanitize $sidebar_slug = sanitize_title($sidebar_name); if (!empty($sidebars)) { $sidebars[$sidebar_slug] = $sidebar_name; }else{ $sidebars = array( $sidebar_slug => $sidebar_name ); } update_option( 'garland_custom_sidebars', $sidebars ); } } if ( isset( $_POST['garland_custom_sidebar_remove_nonce'] ) && wp_verify_nonce( $_POST['garland_custom_sidebar_remove_nonce'], 'garland-()I*^*^%@!' ) ) { $remove_sidebar = isset($_POST['garland_sidebar_remove_name']) && !empty($_POST['garland_sidebar_remove_name']) ? sanitize_text_field($_POST['garland_sidebar_remove_name']) : ''; // Sanitize unset($sidebars[$remove_sidebar]); update_option('garland_custom_sidebars', $sidebars); $sidebars = get_option($sidebar_opt_name); } ?> <form action="" method="post" enctype="multipart/form-data"> <?php wp_nonce_field( 'garland-()@)(*^#@!', 'garland_custom_sidebar_nonce' ); ?> <input type="input" name="garland_sidebar_name" class="custom-sidebar-name" value="" /> </form> <a href="#" class="garland-btn btn-default custom-sidebar-create"><?php esc_html_e( 'Add', 'garland-addon' ); ?></a> <a href="widgets.php"> View Added Sidebars.</a> </div> </div> </div> <div class="col-8"> <div class="admin-box"> <h3 class="admin-box-title sidebar-title"><?php esc_html_e( 'Custom Sidebars', 'garland-addon' ); ?></h3> <?php if( !empty( $sidebars ) ): ?> <form action="" method="post" enctype="multipart/form-data"> <?php wp_nonce_field( 'garland-()I*^*^%@!', 'garland_custom_sidebar_remove_nonce' ); ?> <input type="hidden" name="garland_sidebar_remove_name" id="garland-sidebar-remove-name" value="" /> <table class="garland-admin-table garland-custom-sidebar-table"> <thead> <tr> <td><?php esc_html_e( 'Name', 'garland-addon' ); ?></td> <td><?php esc_html_e( 'Slug', 'garland-addon' ); ?></td> <td><?php esc_html_e( 'Delete', 'garland-addon' ); ?></td> </tr> </thead> <tbody> <?php foreach( $sidebars as $sidebar_slug => $sidebar_name ){ ?> <tr> <td><?php echo esc_html( $sidebar_name ); ?></td> <td><?php echo esc_html( $sidebar_slug ); ?></td> <td class="text-center"><a href="#" data-sidebar="<?php echo esc_attr( $sidebar_slug ); ?>" class="garland-sidebar-remove"><span class="dashicons dashicons-trash"></span></a></td> </tr> <?php } ?> </tbody> </table> </form> <a href="#" class="garland-btn btn-default custom-sidebar-export"><?php esc_html_e( 'Export as JSON', 'garland-addon' ); ?></a> <?php else: ?> <p><?php esc_html_e( 'Sorry! No custom sidebars available.', 'garland-addon' ); ?></p> <?php endif; ?> </div> </div> </div> </div> </div> </div> </div> <?php } public static function rmdir_recurse($path) { $path = rtrim($path, '/').'/'; $handle = opendir($path); while(false !== ($file = readdir($handle))) { if($file != '.' and $file != '..' ) { $fullpath = $path.$file; if(is_dir($fullpath)) self::rmdir_recurse($fullpath); else unlink($fullpath); } } closedir($handle); rmdir($path); } public static function garland_custom_sidebar_export(){ $nonce = $_POST['nonce']; if ( ! wp_verify_nonce( $nonce, 'garland-()@)(*^#@!' ) ) wp_die ( esc_html__( 'Not Ok', 'garland-addon' ) ); $sidebars = get_option( 'garland_custom_sidebars' ); if( !empty( $sidebars ) ){ //wp_send_json( $sidebars ); echo json_encode( $sidebars ); }else{ echo ''; } wp_die(); } public static function get_instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; } } Garland_Custom_Sidebars::get_instance();
Submit
FILE
FOLDER
Name
Size
Permission
Action
demo-importer
---
0755
mega-menu
---
0755
metabox
---
0755
theme-options
---
0755
class.custom-fonts.php
8642 bytes
0644
class.custom-sidebars.php
7237 bytes
0644
N4ST4R_ID | Naxtarrr