PluginProbe
Bottom Admin Toolbar / 1.5.1
Bottom Admin Toolbar v1.5.1
trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.4 1.4.1 1.5.1 1.5.2 1.5.3
bottom-admin-toolbar / bottom-admin-toolbar.php

bottom-admin-toolbar.php in Bottom Admin Toolbar 1.5.1, at bottom-admin-toolbar.php

146 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Bottom Admin Toolbar
4 * Plugin URI: https://wordpress.org/plugins/bottom-admin-toolbar/
5 * Description: Change your admin bar position by activating that simple extension.
6 * Version: 1.5.1
7 * Tags: admin, bar, adminbar, bottom bar, toolbar
8 * Requires at least: 3.0 or higher
9 * Requires PHP: 5.6
10 * Tested up to: 6.6.1
11 * Stable tag: 1.5.1
12 * Author: M . Code
13 * License: GPL v2 or later
14 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 * Contributors: M . Code
16 * Donate link: https://ko-fi.com/devloper
17 */
18
19 if ( ! class_exists( 'BottomAdminToolbar' ) ) :
20 /**
21 * BottomAdminToolbar
22 */
23 class BottomAdminToolbar {
24 /**
25 * Constructor
26 */
27 public function __construct() {
28 define( 'BAB_PATH', plugin_dir_path( __FILE__ ) );
29 define( 'BAB_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
30 define( 'BAB_BASENAME', plugin_basename( __FILE__ ) );
31 add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
32 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_files' ) );
33 add_action( 'admin_init', array( $this, 'register_settings_section' ) );
34 add_action( 'admin_menu', array( $this, 'register_submenu_page' ) );
35 $show_in_admin = get_option( 'bab_show_in_admin' );
36 if ( $show_in_admin ) :
37 $show_in_admin = reset( $show_in_admin );
38 if ( $show_in_admin === 'yes' ) :
39 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_files' ) );
40 endif;
41 endif;
42 }
43
44 /**
45 * Enqueue custom files
46 */
47 public function enqueue_files() {
48 if ( is_admin_bar_showing() ) :
49 wp_enqueue_style( 'bab-css', BAB_ASSETS_URL . 'bab.css', array(), '1.0', 'all' );
50 wp_enqueue_script( 'bab-js', BAB_ASSETS_URL . 'bab.js', array(), '1.0', true );
51 endif;
52 }
53
54 /**
55 * Register settings section
56 */
57 public function register_settings_section() {
58
59 /**
60 * Register setting
61 */
62 register_setting( 'bottom-admin-bar', 'bab_show_in_admin' );
63
64 /**
65 * Register setting section
66 */
67 add_settings_section(
68 'bab_settings_section',
69 false,
70 false,
71 'bottom-admin-bar'
72 );
73
74 /**
75 * Register setting field
76 */
77 add_settings_field(
78 'bab_show_in_admin',
79 __( 'Activer dans l\'administration', 'bottom-admin-toolbar' ),
80 array( $this, 'bab_show_in_admin_cb' ),
81 'bottom-admin-bar',
82 'bab_settings_section',
83 array(
84 'label_for' => 'bab_show_in_admin',
85 'bab_custom_data' => 'custom',
86 )
87 );
88 }
89 /**
90 * Show html output
91 */
92 public function bab_show_in_admin_cb( $args ) {
93 $options = get_option( 'bab_show_in_admin' );
94 ?>
95 <select id="<?php echo esc_attr( $args['label_for'] ); ?>" data-custom="<?php echo esc_attr( $args['bab_custom_data'] ); ?>" name="bab_show_in_admin[<?php echo esc_attr( $args['label_for'] ); ?>]">
96 <option value="yes" <?php echo isset( $options[ $args['label_for'] ] ) ? ( selected( $options[ $args['label_for'] ], 'yes', false ) ) : ( '' ); ?>>
97 <?php esc_html_e( 'Oui', 'bottom-admin-toolbar' ); ?>
98 </option>
99 <option value="no" <?php echo isset( $options[ $args['label_for'] ] ) ? ( selected( $options[ $args['label_for'] ], 'no', false ) ) : ( '' ); ?>>
100 <?php esc_html_e( 'Non', 'bottom-admin-toolbar' ); ?>
101 </option>
102 </select>
103 <?php
104 }
105
106 /**
107 * Register sub menu page
108 */
109 public function register_submenu_page() {
110 add_submenu_page(
111 'options-general.php',
112 'Bottom Admin Toolbar',
113 'Bottom Admin Toolbar',
114 'manage_options',
115 'bab-settings',
116 array( $this, 'bab_settings_display' )
117 );
118 }
119
120 /**
121 * Display setings
122 */
123 public function bab_settings_display() {
124 if ( ! current_user_can( 'manage_options' ) ) :
125 return;
126 endif;
127
128 settings_errors( 'wporg_messages' );
129 ?>
130 <div class="wrap">
131 <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
132 <form action="options.php" method="post">
133 <?php
134 settings_fields( 'bottom-admin-bar' );
135 do_settings_sections( 'bottom-admin-bar' );
136 submit_button( 'Sauvegarder' );
137 ?>
138 </form>
139 </div>
140 <?php
141 }
142
143 }
144 new BottomAdminToolbar();
145 endif;
146