lightspeeddevelopment /
lsx
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * LSX functions and definitions - Widgets. |
||
| 4 | * |
||
| 5 | * @package lsx |
||
| 6 | * @subpackage widgets |
||
| 7 | */ |
||
| 8 | |||
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 10 | exit; |
||
| 11 | } |
||
| 12 | |||
| 13 | if ( ! function_exists( 'lsx_widget_area_init' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 14 | |||
| 15 | /** |
||
| 16 | * Register widgetized area and update sidebar with default widgets. |
||
| 17 | * |
||
| 18 | * @package lsx |
||
| 19 | * @subpackage widgets |
||
| 20 | */ |
||
| 21 | function lsx_widget_area_init() { |
||
|
0 ignored issues
–
show
|
|||
| 22 | register_sidebar( |
||
| 23 | array( |
||
| 24 | 'name' => esc_html__( 'Home', 'lsx' ), |
||
| 25 | 'id' => 'sidebar-home', |
||
| 26 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
||
| 27 | 'after_widget' => '</aside>', |
||
| 28 | 'before_title' => '<h3 class="widget-title">', |
||
| 29 | 'after_title' => '</h3>', |
||
| 30 | ) |
||
| 31 | ); |
||
| 32 | |||
| 33 | register_sidebar( |
||
| 34 | array( |
||
| 35 | 'name' => esc_html__( 'Sidebar', 'lsx' ), |
||
| 36 | 'id' => 'sidebar-1', |
||
| 37 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
||
| 38 | 'after_widget' => '</aside>', |
||
| 39 | 'before_title' => '<h3 class="widget-title">', |
||
| 40 | 'after_title' => '</h3>', |
||
| 41 | ) |
||
| 42 | ); |
||
| 43 | |||
| 44 | register_sidebar( |
||
| 45 | array( |
||
| 46 | 'name' => esc_html__( 'Footer', 'lsx' ), |
||
| 47 | 'id' => 'sidebar-footer', |
||
| 48 | 'before_widget' => '<div class="styler"><aside id="%1$s" class="widget %2$s">', |
||
| 49 | 'after_widget' => '</aside></div>', |
||
| 50 | 'before_title' => '<h3 class="widget-title">', |
||
| 51 | 'after_title' => '</h3>', |
||
| 52 | ) |
||
| 53 | ); |
||
| 54 | |||
| 55 | register_sidebar( |
||
| 56 | array( |
||
| 57 | 'name' => esc_html__( 'Footer Call to Action', 'lsx' ), |
||
| 58 | 'id' => 'sidebar-footer-cta', |
||
| 59 | 'before_widget' => '<aside id="%1$s" class="widget %2$s">', |
||
| 60 | 'after_widget' => '</aside>', |
||
| 61 | 'before_title' => '<h3 class="widget-title">', |
||
| 62 | 'after_title' => '</h3>', |
||
| 63 | ) |
||
| 64 | ); |
||
| 65 | } |
||
|
0 ignored issues
–
show
|
|||
| 66 | |||
| 67 | endif; |
||
| 68 | |||
| 69 | add_action( 'widgets_init', 'lsx_widget_area_init' ); |
||
| 70 | |||
| 71 | if ( ! function_exists( 'lsx_sidebar_footer_params' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 72 | |||
| 73 | /** |
||
|
0 ignored issues
–
show
|
|||
| 74 | * Register widgetized area and update sidebar with default widgets. |
||
| 75 | * |
||
| 76 | * @package lsx |
||
| 77 | * @subpackage widgets |
||
| 78 | * @return $params |
||
| 79 | */ |
||
| 80 | function lsx_sidebar_footer_params( $params ) { |
||
|
0 ignored issues
–
show
|
|||
| 81 | $sidebar_id = $params[0]['id']; |
||
| 82 | |||
| 83 | if ( 'sidebar-footer' === $sidebar_id ) { |
||
|
0 ignored issues
–
show
|
|||
| 84 | $total_widgets = wp_get_sidebars_widgets(); |
||
| 85 | $sidebar_widgets = count( $total_widgets[ $sidebar_id ] ); |
||
| 86 | $params[0]['before_widget'] = str_replace( 'class="styler', 'class="col-md-' . floor( 12 / $sidebar_widgets ), $params[0]['before_widget'] ); |
||
| 87 | } |
||
| 88 | |||
| 89 | return $params; |
||
| 90 | } |
||
|
0 ignored issues
–
show
|
|||
| 91 | |||
| 92 | endif; |
||
| 93 | |||
| 94 | add_filter( 'dynamic_sidebar_params', 'lsx_sidebar_footer_params' ); |
||
| 95 |