~canonical-sysadmins/wordpress/4.8.3

« back to all changes in this revision

Viewing changes to wp-includes/class-wp-admin-bar.php

  • Committer: Ryan Finnie
  • Date: 2015-08-31 16:09:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: ryan.finnie@canonical.com-20150831160947-1h6rfxby9z1ec62u
Merge WP4.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        private $bound = false;
13
13
        public $user;
14
14
 
 
15
        /**
 
16
         * @param string $name
 
17
         * @return string|array|void
 
18
         */
15
19
        public function __get( $name ) {
16
20
                switch ( $name ) {
17
21
                        case 'proto' :
23
27
                }
24
28
        }
25
29
 
 
30
        /**
 
31
         * @access public
 
32
         */
26
33
        public function initialize() {
27
34
                $this->user = new stdClass;
28
35
 
69
76
                do_action( 'admin_bar_init' );
70
77
        }
71
78
 
 
79
        /**
 
80
         * @param array $node
 
81
         */
72
82
        public function add_menu( $node ) {
73
83
                $this->add_node( $node );
74
84
        }
75
85
 
 
86
        /**
 
87
         * @param string $id
 
88
         */
76
89
        public function remove_menu( $id ) {
77
90
                $this->remove_node( $id );
78
91
        }
143
156
                $this->_set_node( $args );
144
157
        }
145
158
 
 
159
        /**
 
160
         * @param array $args
 
161
         */
146
162
        final protected function _set_node( $args ) {
147
163
                $this->nodes[ $args['id'] ] = (object) $args;
148
164
        }
150
166
        /**
151
167
         * Gets a node.
152
168
         *
 
169
         * @param string $id
153
170
         * @return object Node.
154
171
         */
155
172
        final public function get_node( $id ) {
157
174
                        return clone $node;
158
175
        }
159
176
 
 
177
        /**
 
178
         * @param string $id
 
179
         * @return object|void
 
180
         */
160
181
        final protected function _get_node( $id ) {
161
182
                if ( $this->bound )
162
183
                        return;
168
189
                        return $this->nodes[ $id ];
169
190
        }
170
191
 
 
192
        /**
 
193
         * @return array|void
 
194
         */
171
195
        final public function get_nodes() {
172
196
                if ( ! $nodes = $this->_get_nodes() )
173
197
                        return;
178
202
                return $nodes;
179
203
        }
180
204
 
 
205
        /**
 
206
         * @return array|void
 
207
         */
181
208
        final protected function _get_nodes() {
182
209
                if ( $this->bound )
183
210
                        return;
208
235
        /**
209
236
         * Remove a node.
210
237
         *
211
 
         * @param string The ID of the item.
 
238
         * @param string $id The ID of the item.
212
239
         */
213
240
        public function remove_node( $id ) {
214
241
                $this->_unset_node( $id );
215
242
        }
216
243
 
 
244
        /**
 
245
         * @param string $id
 
246
         */
217
247
        final protected function _unset_node( $id ) {
218
248
                unset( $this->nodes[ $id ] );
219
249
        }
220
250
 
 
251
        /**
 
252
         * @access public
 
253
         */
221
254
        public function render() {
222
255
                $root = $this->_bind();
223
256
                if ( $root )
224
257
                        $this->_render( $root );
225
258
        }
226
259
 
 
260
        /**
 
261
         * @return object|void
 
262
         */
227
263
        final protected function _bind() {
228
264
                if ( $this->bound )
229
265
                        return;
345
381
                return $root;
346
382
        }
347
383
 
 
384
        /**
 
385
         *
 
386
         * @global bool $is_IE
 
387
         * @param object $root
 
388
         */
348
389
        final protected function _render( $root ) {
349
390
                global $is_IE;
350
391
 
380
421
                <?php
381
422
        }
382
423
 
 
424
        /**
 
425
         * @param object $node
 
426
         */
383
427
        final protected function _render_container( $node ) {
384
428
                if ( $node->type != 'container' || empty( $node->children ) )
385
429
                        return;
391
435
                ?></div><?php
392
436
        }
393
437
 
 
438
        /**
 
439
         * @param object $node
 
440
         */
394
441
        final protected function _render_group( $node ) {
395
 
                if ( $node->type == 'container' )
396
 
                        return $this->_render_container( $node );
397
 
 
 
442
                if ( $node->type == 'container' ) {
 
443
                        $this->_render_container( $node );
 
444
                        return;
 
445
                }
398
446
                if ( $node->type != 'group' || empty( $node->children ) )
399
447
                        return;
400
448
 
410
458
                ?></ul><?php
411
459
        }
412
460
 
 
461
        /**
 
462
         * @param object $node
 
463
         */
413
464
        final protected function _render_item( $node ) {
414
465
                if ( $node->type != 'item' )
415
466
                        return;
482
533
                </li><?php
483
534
        }
484
535
 
 
536
        /**
 
537
         * @param string $id    Unused.
 
538
         * @param object $node
 
539
         */
485
540
        public function recursive_render( $id, $node ) {
486
541
                _deprecated_function( __METHOD__, '3.3', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()' );
487
542
                $this->_render_item( $node );
488
543
        }
489
544
 
 
545
        /**
 
546
         * @access public
 
547
         */
490
548
        public function add_menus() {
491
549
                // User related, aligned right.
492
550
                add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
498
556
                add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
499
557
                add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
500
558
                add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
501
 
                add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 40 );
 
559
                add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 );
 
560
                add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 );
502
561
 
503
562
                // Content related.
504
563
                if ( ! is_network_admin() && ! is_user_admin() ) {