Make WordPress Core


Ignore:
Timestamp:
05/18/2014 09:30:43 PM (12 years ago)
Author:
wonderboymusic
Message:

Use proper access modifiers and add a magic __get() method to Custom_Background and Custom_Image_Header.

See #27881, #22234.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/custom-header.php

    r28384 r28481  
    2323         * @access private
    2424         */
    25         var $admin_header_callback;
     25        private $admin_header_callback;
    2626
    2727        /**
     
    3232         * @access private
    3333         */
    34         var $admin_image_div_callback;
     34        private $admin_image_div_callback;
    3535
    3636        /**
     
    4141         * @access private
    4242         */
    43         var $default_headers = array();
     43        private $default_headers = array();
    4444
    4545        /**
     
    5050         * @access private
    5151         */
    52         var $uploaded_headers = array();
     52        private $uploaded_headers = array();
    5353
    5454        /**
     
    5959         * @access private
    6060         */
    61         var $page = '';
     61        private $page = '';
    6262
    6363        /**
     
    6969         * @return Custom_Image_Header
    7070         */
    71         function __construct($admin_header_callback, $admin_image_div_callback = '') {
     71        public function __construct($admin_header_callback, $admin_image_div_callback = '') {
    7272                $this->admin_header_callback = $admin_header_callback;
    7373                $this->admin_image_div_callback = $admin_image_div_callback;
     
    8282
    8383        /**
     84         * Make private properties readable for backwards compatibility
     85         *
     86         * @since 4.0.0
     87         * @param string $name
     88         * @return mixed
     89         */
     90        public function __get( $name ) {
     91                return $this->$name;
     92        }
     93
     94        /**
    8495         * Set up the hooks for the Custom Header admin page.
    8596         *
    8697         * @since 2.1.0
    8798         */
    88         function init() {
     99        public function init() {
    89100                if ( ! current_user_can('edit_theme_options') )
    90101                        return;
     
    107118         * @since 3.0.0
    108119         */
    109         function help() {
     120        public function help() {
    110121                get_current_screen()->add_help_tab( array(
    111122                        'id'      => 'overview',
     
    149160         * @return int Current step
    150161         */
    151         function step() {
     162        public function step() {
    152163                if ( ! isset( $_GET['step'] ) )
    153164                        return 1;
     
    168179         * @since 2.1.0
    169180         */
    170         function js_includes() {
     181        public function js_includes() {
    171182                $step = $this->step();
    172183
     
    186197         * @since 2.7.0
    187198         */
    188         function css_includes() {
     199        public function css_includes() {
    189200                $step = $this->step();
    190201
     
    200211         * @since 2.6.0
    201212         */
    202         function take_action() {
     213        public function take_action() {
    203214                if ( ! current_user_can('edit_theme_options') )
    204215                        return;
     
    246257         * @since 3.0.0
    247258         */
    248         function process_default_headers() {
     259        public function process_default_headers() {
    249260                global $_wp_default_headers;
    250261
     
    276287         * @since 3.0.0
    277288         */
    278         function show_header_selector( $type = 'default' ) {
     289        public function show_header_selector( $type = 'default' ) {
    279290                if ( 'default' == $type ) {
    280291                        $headers = $this->default_headers;
     
    313324         * @since 2.1.0
    314325         */
    315         function js() {
     326        public function js() {
    316327                $step = $this->step();
    317328                if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) )
     
    326337         * @since 2.6.0
    327338         */
    328         function js_1() {
     339        public function js_1() {
    329340                $default_color = '';
    330341                if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {
     
    342353                header_text_fields;
    343354
    344         function pickColor(color) {
     355        public function pickColor(color) {
    345356                $('#name').css('color', color);
    346357                $('#desc').css('color', color);
     
    348359        }
    349360
    350         function toggle_text() {
     361        public function toggle_text() {
    351362                var checked = $('#display-header-text').prop('checked'),
    352363                        text_color;
     
    390401         * @since 2.6.0
    391402         */
    392         function js_2() { ?>
     403        public function js_2() { ?>
    393404<script type="text/javascript">
    394405/* <![CDATA[ */
    395         function onEndCrop( coords ) {
     406        public function onEndCrop( coords ) {
    396407                jQuery( '#x1' ).val(coords.x);
    397408                jQuery( '#y1' ).val(coords.y);
     
    442453                        }
    443454                        ?>
    444                         onInit: function () {
     455                        onInit: public function () {
    445456                                jQuery('#width').val(xinit);
    446457                                jQuery('#height').val(yinit);
     
    464475         * @since 2.1.0
    465476         */
    466         function step_1() {
     477        public function step_1() {
    467478                $this->process_default_headers();
    468479?>
     
    682693         * @since 2.1.0
    683694         */
    684         function step_2() {
     695        public function step_2() {
    685696                check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload');
    686697                if ( ! current_theme_supports( 'custom-header', 'uploads' ) )
     
    796807         * @since 3.4.0
    797808         */
    798         function step_2_manage_upload() {
     809        public function step_2_manage_upload() {
    799810                $overrides = array('test_form' => false);
    800811
     
    833844         * @since 2.1.0
    834845         */
    835         function step_3() {
     846        public function step_3() {
    836847                check_admin_referer( 'custom-header-crop-image' );
    837848
     
    909920         * @since 2.1.0
    910921         */
    911         function finished() {
     922        public function finished() {
    912923                $this->updated = true;
    913924                $this->step_1();
     
    919930         * @since 2.1.0
    920931         */
    921         function admin_page() {
     932        public function admin_page() {
    922933                if ( ! current_user_can('edit_theme_options') )
    923934                        wp_die(__('You do not have permission to customize headers.'));
     
    936947         * @since 3.4.0
    937948         */
    938         function attachment_fields_to_edit( $form_fields ) {
     949        public function attachment_fields_to_edit( $form_fields ) {
    939950                return $form_fields;
    940951        }
     
    945956         * @since 3.4.0
    946957         */
    947         function filter_upload_tabs( $tabs ) {
     958        public function filter_upload_tabs( $tabs ) {
    948959                return $tabs;
    949960        }
     
    11481159         * new object. Returns JSON-encoded object details.
    11491160         */
    1150         function ajax_header_crop() {
     1161        public function ajax_header_crop() {
    11511162                check_ajax_referer( 'image_editor-' . $_POST['id'], 'nonce' );
    11521163
     
    12051216         * Media Manager, even if s/he doesn't save that change.
    12061217         */
    1207         function ajax_header_add() {
     1218        public function ajax_header_add() {
    12081219                check_ajax_referer( 'header-add', 'nonce' );
    12091220
     
    12311242         * choice in the Customizer's Header tool.
    12321243         */
    1233         function ajax_header_remove() {
     1244        public function ajax_header_remove() {
    12341245                check_ajax_referer( 'header-remove', 'nonce' );
    12351246
     
    12501261        }
    12511262
    1252         function customize_set_last_used( $wp_customize ) {
     1263        public function customize_set_last_used( $wp_customize ) {
    12531264                $data = $wp_customize->get_setting( 'header_image_data' )->post_value();
    12541265
Note: See TracChangeset for help on using the changeset viewer.