Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
home
/
getwphos
/
public_html
/
perfumehousedhaka
/
wp-content
/
themes
/
yobazar
/
admin
/
File Content:
register_sidebar.php
<?php function yobazar_get_list_sidebars(){ $default_sidebars = array( array( 'name' => esc_html__( 'Home Sidebar', 'yobazar' ), 'id' => 'home-sidebar', 'before_widget' => '<section id="%1$s" class="widget-container %2$s">', 'after_widget' => '</section>', 'before_title' => '<div class="widget-title-wrapper"><a class="block-control" href="javascript:void(0)"></a><h3 class="widget-title heading-title">', 'after_title' => '</h3></div>', ) ,array( 'name' => esc_html__( 'Blog Sidebar', 'yobazar' ), 'id' => 'blog-sidebar', 'before_widget' => '<section id="%1$s" class="widget-container %2$s">', 'after_widget' => '</section>', 'before_title' => '<div class="widget-title-wrapper"><a class="block-control" href="javascript:void(0)"></a><h3 class="widget-title heading-title">', 'after_title' => '</h3></div>', ) ,array( 'name' => esc_html__( 'Blog Detail Sidebar', 'yobazar' ), 'id' => 'blog-detail-sidebar', 'before_widget' => '<section id="%1$s" class="widget-container %2$s">', 'after_widget' => '</section>', 'before_title' => '<div class="widget-title-wrapper"><a class="block-control" href="javascript:void(0)"></a><h3 class="widget-title heading-title">', 'after_title' => '</h3></div>', ) ,array( 'name' => esc_html__( 'Product Category Sidebar', 'yobazar' ), 'id' => 'product-category-sidebar', 'before_widget' => '<section id="%1$s" class="widget-container %2$s">', 'after_widget' => '</section>', 'before_title' => '<div class="widget-title-wrapper"><a class="block-control" href="javascript:void(0)"></a><h3 class="widget-title heading-title">', 'after_title' => '</h3></div>', ) ,array( 'name' => esc_html__( 'Filter Widget Area', 'yobazar' ), 'id' => 'filter-widget-area', 'before_widget' => '<section id="%1$s" class="widget-container %2$s">', 'after_widget' => '</section>', 'before_title' => '<div class="widget-title-wrapper"><a class="block-control" href="javascript:void(0)"></a><h3 class="widget-title heading-title">', 'after_title' => '</h3></div>', ) ,array( 'name' => esc_html__( 'Product Detail Sidebar', 'yobazar' ), 'id' => 'product-detail-sidebar', 'before_widget' => '<section id="%1$s" class="widget-container %2$s">', 'after_widget' => '</section>', 'before_title' => '<div class="widget-title-wrapper"><a class="block-control" href="javascript:void(0)"></a><h3 class="widget-title heading-title">', 'after_title' => '</h3></div>', ) ); $custom_sidebars = yobazar_get_custom_sidebars(); if( is_array($custom_sidebars) && !empty($custom_sidebars) ){ foreach( $custom_sidebars as $name ){ $default_sidebars[] = array( 'name' => ''.$name.'', 'id' => sanitize_title($name), 'description' => '', 'class' => 'ts-custom-sidebar', 'before_widget' => '<section id="%1$s" class="widget-container %2$s">', 'after_widget' => '</section>', 'before_title' => '<div class="widget-title-wrapper"><a class="block-control" href="javascript:void(0)"></a><h3 class="widget-title heading-title">', 'after_title' => '</h3></div>', ); } } return $default_sidebars; } function yobazar_register_widget_area(){ $default_sidebars = yobazar_get_list_sidebars(); foreach( $default_sidebars as $sidebar ){ register_sidebar($sidebar); } } add_action( 'widgets_init', 'yobazar_register_widget_area' ); /* Custom Sidebar */ add_action( 'sidebar_admin_page', 'yobazar_custom_sidebar_form' ); function yobazar_custom_sidebar_form(){ ?> <form action="<?php echo admin_url( 'widgets.php' ); ?>" method="post" id="ts-form-add-sidebar"> <input type="text" name="sidebar_name" id="sidebar_name" placeholder="<?php esc_attr_e('Custom Sidebar Name', 'yobazar'); ?>" /> <input type="hidden" id="ts_custom_sidebar_nonce" value="<?php echo wp_create_nonce('ts-custom-sidebar'); ?>" /> <button class="button-primary" id="ts-add-sidebar"><?php esc_html_e('Add Sidebar', 'yobazar'); ?></button> </form> <?php } function yobazar_get_custom_sidebars(){ $option_name = 'ts_custom_sidebars'; $custom_sidebars = get_option($option_name); return is_array($custom_sidebars)?$custom_sidebars:array(); } add_action('wp_ajax_yobazar_add_custom_sidebar', 'yobazar_add_custom_sidebar'); function yobazar_add_custom_sidebar(){ if( isset($_POST['sidebar_name']) ){ check_ajax_referer('ts-custom-sidebar', 'sidebar_nonce'); $option_name = 'ts_custom_sidebars'; if( !get_option($option_name) || get_option($option_name) == '' ){ delete_option($option_name); } $sidebar_name = sanitize_text_field($_POST['sidebar_name']); if( get_option($option_name) ){ $custom_sidebars = yobazar_get_custom_sidebars(); if( !in_array($sidebar_name, $custom_sidebars) ){ $custom_sidebars[] = $sidebar_name; } $result = update_option($option_name, $custom_sidebars); } else{ $custom_sidebars = array(); $custom_sidebars[] = $sidebar_name; $result = add_option($option_name, $custom_sidebars); } if( $result ){ die( esc_html__('Successfully added the sidebar', 'yobazar') ); } else{ die( esc_html__('Error! It seems that the sidebar exists. Please try again!', 'yobazar') ); } } die(''); } add_action('wp_ajax_yobazar_delete_custom_sidebar', 'yobazar_delete_custom_sidebar'); function yobazar_delete_custom_sidebar(){ if( isset($_POST['sidebar_name']) ){ check_ajax_referer('ts-custom-sidebar', 'sidebar_nonce'); $option_name = 'ts_custom_sidebars'; $del_sidebar = sanitize_text_field($_POST['sidebar_name']); $custom_sidebars = yobazar_get_custom_sidebars(); foreach( $custom_sidebars as $key => $value ){ if( $value == $del_sidebar ){ unset($custom_sidebars[$key]); break; } } $custom_sidebars = array_values($custom_sidebars); update_option($option_name, $custom_sidebars); die( esc_html__('Successfully deleted the sidebar', 'yobazar') ); } die(''); } ?>
Submit
FILE
FOLDER
Name
Size
Permission
Action
assets
---
0755
preset-colors
---
0755
functions.php
4527 bytes
0644
init.php
200 bytes
0644
options.php
113998 bytes
0644
redux.php
10690 bytes
0644
register_sidebar.php
6181 bytes
0644
N4ST4R_ID | Naxtarrr