external
9 years ago
class-custom-sidebars-checkup-notification.php
9 years ago
class-custom-sidebars-cloning.php
9 years ago
class-custom-sidebars-editor.php
9 years ago
class-custom-sidebars-explain.php
9 years ago
class-custom-sidebars-export.php
9 years ago
class-custom-sidebars-replacer.php
9 years ago
class-custom-sidebars-visibility.php
9 years ago
class-custom-sidebars-widgets.php
9 years ago
class-custom-sidebars.php
9 years ago
class-custom-sidebars-widgets.php
85 lines
| 1 | <?php |
| 2 | |
| 3 | add_action( 'cs_init', array( 'CustomSidebarsWidgets', 'instance' ) ); |
| 4 | |
| 5 | /** |
| 6 | * Extends the widgets section to add the custom sidebars UI elements. |
| 7 | */ |
| 8 | class CustomSidebarsWidgets extends CustomSidebars { |
| 9 | |
| 10 | /** |
| 11 | * Returns the singleton object. |
| 12 | * |
| 13 | * @since 2.0 |
| 14 | */ |
| 15 | public static function instance() { |
| 16 | static $Inst = null; |
| 17 | |
| 18 | if ( null === $Inst ) { |
| 19 | $Inst = new CustomSidebarsWidgets(); |
| 20 | } |
| 21 | |
| 22 | return $Inst; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Constructor is private -> singleton. |
| 27 | * |
| 28 | * @since 2.0 |
| 29 | */ |
| 30 | private function __construct() { |
| 31 | if ( is_admin() ) { |
| 32 | add_action( |
| 33 | 'widgets_admin_page', |
| 34 | array( $this, 'widget_sidebar_content' ) |
| 35 | ); |
| 36 | |
| 37 | add_action( |
| 38 | 'admin_head-widgets.php', |
| 39 | array( $this, 'init_admin_head' ) |
| 40 | ); |
| 41 | } |
| 42 | add_action( 'widgets_admin_page', array( $this, 'add_div_start' ) ); |
| 43 | add_action( 'sidebar_admin_page', array( $this, 'add_div_end' ) ); |
| 44 | } |
| 45 | |
| 46 | public function add_div_start() { |
| 47 | echo '<div class="cs-wrap">'; |
| 48 | } |
| 49 | |
| 50 | public function add_div_end() { |
| 51 | echo '</div>'; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Adds the additional HTML code to the widgets section. |
| 56 | */ |
| 57 | public function widget_sidebar_content() { |
| 58 | if ( false === self::$accessibility_mode ) { |
| 59 | include CSB_VIEWS_DIR . 'widgets.php'; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Initialize the admin-head for the widgets page. |
| 65 | * |
| 66 | * @since 2.0.9.7 |
| 67 | */ |
| 68 | public function init_admin_head( $classes ) { |
| 69 | add_filter( |
| 70 | 'admin_body_class', |
| 71 | array( $this, 'admin_body_class' ) |
| 72 | ); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Add a class to the body tag. |
| 77 | * |
| 78 | * @since 2.0.9.7 |
| 79 | */ |
| 80 | public function admin_body_class( $classes ) { |
| 81 | $classes .= ' no-auto-init '; |
| 82 | return $classes; |
| 83 | } |
| 84 | }; |
| 85 |