WordPress.org

Make WordPress Core

Ticket #27534: 27534.2.diff

File 27534.2.diff, 2.1 KB (added by DrewAPicture, 8 years ago)

_capture_* tweaks

  • src/wp-includes/class-wp-customize-widgets.php

     
    13171317
    13181318                $this->_is_capturing_option_updates = true;
    13191319
    1320                 add_filter( 'pre_update_option', array( $this, '_capture_filter_pre_update_option' ), 10, 3 );
     1320                add_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 );
    13211321        }
    13221322
    13231323        /**
     
    13311331         * @param mixed $old_value
    13321332         * @return mixed
    13331333         */
    1334         public function _capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
     1334        public function capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
    13351335                if ( $this->is_option_capture_ignored( $option_name ) ) {
    13361336                        return;
    13371337                }
    13381338
    13391339                if ( ! isset( $this->_captured_options[$option_name] ) ) {
    1340                         add_filter( "pre_option_{$option_name}", array( $this, '_capture_filter_pre_get_option' ) );
     1340                        add_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
    13411341                }
    13421342
    13431343                $this->_captured_options[$option_name] = $new_value;
     
    13541354         * @param mixed $value Option
    13551355         * @return mixed
    13561356         */
    1357         public function _capture_filter_pre_get_option( $value ) {
     1357        public function capture_filter_pre_get_option( $value ) {
    13581358                $option_name = preg_replace( '/^pre_option_/', '', current_filter() );
    13591359
    13601360                if ( isset( $this->_captured_options[$option_name] ) ) {
     
    13761376                        return;
    13771377                }
    13781378
    1379                 remove_filter( '_capture_filter_pre_update_option', array( $this, '_capture_filter_pre_update_option' ), 10, 3 );
     1379                remove_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 );
     1380
    13801381                foreach ( array_keys( $this->_captured_options ) as $option_name ) {
    1381                         remove_filter( "pre_option_{$option_name}", array( $this, '_capture_filter_pre_get_option' ) );
     1382                        remove_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
    13821383                }
    13831384
    13841385                $this->_captured_options = array();