Remove lingering instances of call time pass-by-reference, limited to instances of callable - use $this instead of &$this.

Props jdgrimes.
See #25160.



git-svn-id: https://develop.svn.wordpress.org/trunk@25254 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2013-09-05 16:33:50 +00:00
parent 21511593a4
commit 16ef2c2e36
20 changed files with 112 additions and 112 deletions

View File

@ -67,11 +67,11 @@ class Custom_Background {
if ( ! current_user_can('edit_theme_options') )
return;
$this->page = $page = add_theme_page(__('Background'), __('Background'), 'edit_theme_options', 'custom-background', array(&$this, 'admin_page'));
$this->page = $page = add_theme_page(__('Background'), __('Background'), 'edit_theme_options', 'custom-background', array($this, 'admin_page'));
add_action("load-$page", array(&$this, 'admin_load'));
add_action("load-$page", array(&$this, 'take_action'), 49);
add_action("load-$page", array(&$this, 'handle_upload'), 49);
add_action("load-$page", array($this, 'admin_load'));
add_action("load-$page", array($this, 'take_action'), 49);
add_action("load-$page", array($this, 'handle_upload'), 49);
if ( $this->admin_header_callback )
add_action("admin_head-$page", $this->admin_header_callback, 51);

View File

@ -84,13 +84,13 @@ class Custom_Image_Header {
if ( ! current_user_can('edit_theme_options') )
return;
$this->page = $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array(&$this, 'admin_page'));
$this->page = $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array($this, 'admin_page'));
add_action("admin_print_scripts-$page", array(&$this, 'js_includes'));
add_action("admin_print_styles-$page", array(&$this, 'css_includes'));
add_action("admin_head-$page", array(&$this, 'help') );
add_action("admin_head-$page", array(&$this, 'take_action'), 50);
add_action("admin_head-$page", array(&$this, 'js'), 50);
add_action("admin_print_scripts-$page", array($this, 'js_includes'));
add_action("admin_print_styles-$page", array($this, 'css_includes'));
add_action("admin_head-$page", array($this, 'help') );
add_action("admin_head-$page", array($this, 'take_action'), 50);
add_action("admin_head-$page", array($this, 'js'), 50);
if ( $this->admin_header_callback )
add_action("admin_head-$page", $this->admin_header_callback, 51);
}

View File

@ -179,7 +179,7 @@ class WP_Importer {
*/
function get_page( $url, $username = '', $password = '', $head = false ) {
// Increase the timeout
add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) );
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
$headers = array();
$args = array();

View File

@ -87,7 +87,7 @@ class WP_List_Table {
$this->screen = convert_to_screen( $args['screen'] );
add_filter( "manage_{$this->screen->id}_columns", array( &$this, 'get_columns' ), 0 );
add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
if ( !$args['plural'] )
$args['plural'] = $this->screen->base;
@ -99,7 +99,7 @@ class WP_List_Table {
if ( $args['ajax'] ) {
// wp_enqueue_script( 'list-table' );
add_action( 'admin_footer', array( &$this, '_js_vars' ) );
add_action( 'admin_footer', array( $this, '_js_vars' ) );
}
}
@ -857,7 +857,7 @@ class WP_List_Table {
}
elseif ( method_exists( $this, 'column_' . $column_name ) ) {
echo "<td $attributes>";
echo call_user_func( array( &$this, 'column_' . $column_name ), $item );
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
echo "</td>";
}
else {

View File

@ -84,7 +84,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
if ( $s ) {
$status = 'search';
$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( &$this, '_search_callback' ) );
$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) );
}
$totals = array();
@ -108,7 +108,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
if ( 'ASC' == $order )
$this->items = array_reverse( $this->items );
} else {
uasort( $this->items, array( &$this, '_order_callback' ) );
uasort( $this->items, array( $this, '_order_callback' ) );
}
}

View File

@ -99,7 +99,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( $s ) {
$status = 'search';
$plugins['search'] = array_filter( $plugins['all'], array( &$this, '_search_callback' ) );
$plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
}
$totals = array();
@ -121,7 +121,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$orderby = ucfirst( $orderby );
$order = strtoupper( $order );
uasort( $this->items, array( &$this, '_order_callback' ) );
uasort( $this->items, array( $this, '_order_callback' ) );
}
$plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 );

View File

@ -403,7 +403,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->init();
$this->install_strings();
add_filter('upgrader_source_selection', array(&$this, 'check_package') );
add_filter('upgrader_source_selection', array($this, 'check_package') );
$this->run(array(
'package' => $package,
@ -413,7 +413,7 @@ class Plugin_Upgrader extends WP_Upgrader {
'hook_extra' => array()
));
remove_filter('upgrader_source_selection', array(&$this, 'check_package') );
remove_filter('upgrader_source_selection', array($this, 'check_package') );
if ( ! $this->result || is_wp_error($this->result) )
return $this->result;
@ -443,9 +443,9 @@ class Plugin_Upgrader extends WP_Upgrader {
// Get the URL to the zip file
$r = $current->response[ $plugin ];
add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
//'source_selection' => array(&$this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
//'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
$this->run(array(
'package' => $r->package,
@ -458,8 +458,8 @@ class Plugin_Upgrader extends WP_Upgrader {
));
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'));
remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
if ( ! $this->result || is_wp_error($this->result) )
return $this->result;
@ -480,7 +480,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$current = get_site_transient( 'update_plugins' );
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
$this->skin->header();
@ -550,7 +550,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->skin->footer();
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
// Force refresh of plugin update information
delete_site_transient('update_plugins');
@ -712,7 +712,7 @@ class Theme_Upgrader extends WP_Upgrader {
if ( ! $api || is_wp_error($api) ) {
$this->skin->feedback( 'parent_theme_not_found', $theme_info->get('Template') );
// Don't show activate or preview actions after install
add_filter('install_theme_complete_actions', array(&$this, 'hide_activate_preview_actions') );
add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
return $install_result;
}
@ -737,7 +737,7 @@ class Theme_Upgrader extends WP_Upgrader {
) );
if ( is_wp_error($parent_result) )
add_filter('install_theme_complete_actions', array(&$this, 'hide_activate_preview_actions') );
add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
// Start cleaning up after the parents installation
remove_filter('install_theme_complete_actions', '__return_false', 999);
@ -760,8 +760,8 @@ class Theme_Upgrader extends WP_Upgrader {
$this->init();
$this->install_strings();
add_filter('upgrader_source_selection', array(&$this, 'check_package') );
add_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3);
add_filter('upgrader_source_selection', array($this, 'check_package') );
add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3);
$options = array(
'package' => $package,
@ -772,8 +772,8 @@ class Theme_Upgrader extends WP_Upgrader {
$this->run($options);
remove_filter('upgrader_source_selection', array(&$this, 'check_package') );
remove_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'));
remove_filter('upgrader_source_selection', array($this, 'check_package') );
remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'));
if ( ! $this->result || is_wp_error($this->result) )
return $this->result;
@ -802,9 +802,9 @@ class Theme_Upgrader extends WP_Upgrader {
$r = $current->response[ $theme ];
add_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2);
add_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2);
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4);
add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
$options = array(
'package' => $r['package'],
@ -818,9 +818,9 @@ class Theme_Upgrader extends WP_Upgrader {
$this->run($options);
remove_filter('upgrader_pre_install', array(&$this, 'current_before'));
remove_filter('upgrader_post_install', array(&$this, 'current_after'));
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'));
remove_filter('upgrader_pre_install', array($this, 'current_before'));
remove_filter('upgrader_post_install', array($this, 'current_after'));
remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
if ( ! $this->result || is_wp_error($this->result) )
return $this->result;
@ -840,9 +840,9 @@ class Theme_Upgrader extends WP_Upgrader {
$current = get_site_transient( 'update_themes' );
add_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2);
add_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2);
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4);
add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
$this->skin->header();
@ -912,9 +912,9 @@ class Theme_Upgrader extends WP_Upgrader {
$this->skin->footer();
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_filter('upgrader_pre_install', array(&$this, 'current_before'));
remove_filter('upgrader_post_install', array(&$this, 'current_after'));
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'));
remove_filter('upgrader_pre_install', array($this, 'current_before'));
remove_filter('upgrader_post_install', array($this, 'current_after'));
remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
// Force refresh of theme update information
wp_clean_themes_cache();

View File

@ -95,7 +95,7 @@ class _WP_List_Table_Compat extends WP_List_Table {
if ( !empty( $columns ) ) {
$this->_columns = $columns;
add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );
}
}

View File

@ -133,8 +133,8 @@ class testXMLParser {
$this->xml = xml_parser_create();
xml_set_object($this->xml, $this);
xml_parser_set_option($this->xml,XML_OPTION_CASE_FOLDING, 0);
xml_set_element_handler($this->xml, array(&$this, 'startHandler'), array(&$this, 'endHandler'));
xml_set_character_data_handler($this->xml, array(&$this, 'dataHandler'));
xml_set_element_handler($this->xml, array($this, 'startHandler'), array($this, 'endHandler'));
xml_set_character_data_handler($this->xml, array($this, 'dataHandler'));
$this->parse($in);
}

View File

@ -32,7 +32,7 @@ class WPProfiler {
if (!$this->stack) {
// log all actions and filters
add_filter('all', array(&$this, 'log_filter'));
add_filter('all', array($this, 'log_filter'));
}
// reset the wpdb queries log, storing it on the profile stack if necessary
@ -101,7 +101,7 @@ class WPProfiler {
}
if (!$this->stack) {
remove_filter('all', array(&$this, 'log_filter'));
remove_filter('all', array($this, 'log_filter'));
}
}

View File

@ -10,9 +10,9 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
add_filter('theme_root', array(&$this, '_theme_root'));
add_filter( 'stylesheet_root', array(&$this, '_theme_root') );
add_filter( 'template_root', array(&$this, '_theme_root') );
add_filter('theme_root', array($this, '_theme_root'));
add_filter( 'stylesheet_root', array($this, '_theme_root') );
add_filter( 'template_root', array($this, '_theme_root') );
// clear caches
wp_clean_themes_cache();
@ -21,9 +21,9 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
function tearDown() {
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
remove_filter('theme_root', array(&$this, '_theme_root'));
remove_filter( 'stylesheet_root', array(&$this, '_theme_root') );
remove_filter( 'template_root', array(&$this, '_theme_root') );
remove_filter('theme_root', array($this, '_theme_root'));
remove_filter( 'stylesheet_root', array($this, '_theme_root') );
remove_filter( 'template_root', array($this, '_theme_root') );
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );

View File

@ -12,7 +12,7 @@ class Tests_Filters extends WP_UnitTestCase {
$tag = rand_str();
$val = rand_str();
add_filter($tag, array(&$a, 'filter'));
add_filter($tag, array($a, 'filter'));
$this->assertEquals($val, apply_filters($tag, $val));
// only one event occurred for the hook, with empty args
@ -29,7 +29,7 @@ class Tests_Filters extends WP_UnitTestCase {
$tag = rand_str();
$val = rand_str();
add_filter($tag, array(&$a, 'filter'));
add_filter($tag, array($a, 'filter'));
$this->assertEquals($val, apply_filters($tag, $val));
// make sure our hook was called correctly
@ -37,7 +37,7 @@ class Tests_Filters extends WP_UnitTestCase {
$this->assertEquals(array($tag), $a->get_tags());
// now remove the filter, do it again, and make sure it's not called this time
remove_filter($tag, array(&$a, 'filter'));
remove_filter($tag, array($a, 'filter'));
$this->assertEquals($val, apply_filters($tag, $val));
$this->assertEquals(1, $a->get_call_count());
$this->assertEquals(array($tag), $a->get_tags());
@ -66,8 +66,8 @@ class Tests_Filters extends WP_UnitTestCase {
$val = rand_str();
// add both filters to the hook
add_filter($tag, array(&$a1, 'filter'));
add_filter($tag, array(&$a2, 'filter'));
add_filter($tag, array($a1, 'filter'));
add_filter($tag, array($a2, 'filter'));
$this->assertEquals($val, apply_filters($tag, $val));
@ -82,7 +82,7 @@ class Tests_Filters extends WP_UnitTestCase {
$val = rand_str();
$arg1 = rand_str();
add_filter($tag, array(&$a, 'filter'), 10, 2);
add_filter($tag, array($a, 'filter'), 10, 2);
// call the filter with a single argument
$this->assertEquals($val, apply_filters($tag, $val, $arg1));
@ -99,8 +99,8 @@ class Tests_Filters extends WP_UnitTestCase {
$arg2 = rand_str();
// a1 accepts two arguments, a2 doesn't
add_filter($tag, array(&$a1, 'filter'), 10, 3);
add_filter($tag, array(&$a2, 'filter'));
add_filter($tag, array($a1, 'filter'), 10, 3);
add_filter($tag, array($a2, 'filter'));
// call the filter with two arguments
$this->assertEquals($val, apply_filters($tag, $val, $arg1, $arg2));
@ -119,8 +119,8 @@ class Tests_Filters extends WP_UnitTestCase {
$val = rand_str();
// make two filters with different priorities
add_filter($tag, array(&$a, 'filter'), 10);
add_filter($tag, array(&$a, 'filter2'), 9);
add_filter($tag, array($a, 'filter'), 10);
add_filter($tag, array($a, 'filter2'), 9);
$this->assertEquals($val, apply_filters($tag, $val));
// there should be two events, one per filter
@ -151,7 +151,7 @@ class Tests_Filters extends WP_UnitTestCase {
$val = rand_str();
// add an 'all' filter
add_filter('all', array(&$a, 'filterall'));
add_filter('all', array($a, 'filterall'));
// do some filters
$this->assertEquals($val, apply_filters($tag1, $val));
$this->assertEquals($val, apply_filters($tag2, $val));
@ -163,8 +163,8 @@ class Tests_Filters extends WP_UnitTestCase {
// the right hooks should have been called in order
$this->assertEquals(array($tag1, $tag2, $tag1, $tag1), $a->get_tags());
remove_filter('all', array(&$a, 'filterall'));
$this->assertFalse( has_filter('all', array(&$a, 'filterall')) );
remove_filter('all', array($a, 'filterall'));
$this->assertFalse( has_filter('all', array($a, 'filterall')) );
}
@ -173,9 +173,9 @@ class Tests_Filters extends WP_UnitTestCase {
$tag = rand_str();
$val = rand_str();
add_filter('all', array(&$a, 'filterall'));
add_filter('all', array($a, 'filterall'));
$this->assertTrue( has_filter('all') );
$this->assertEquals( 10, has_filter('all', array(&$a, 'filterall')) );
$this->assertEquals( 10, has_filter('all', array($a, 'filterall')) );
$this->assertEquals($val, apply_filters($tag, $val));
// make sure our hook was called correctly
@ -183,8 +183,8 @@ class Tests_Filters extends WP_UnitTestCase {
$this->assertEquals(array($tag), $a->get_tags());
// now remove the filter, do it again, and make sure it's not called this time
remove_filter('all', array(&$a, 'filterall'));
$this->assertFalse( has_filter('all', array(&$a, 'filterall')) );
remove_filter('all', array($a, 'filterall'));
$this->assertFalse( has_filter('all', array($a, 'filterall')) );
$this->assertFalse( has_filter('all') );
$this->assertEquals($val, apply_filters($tag, $val));
// call cound should remain at 1
@ -200,7 +200,7 @@ class Tests_Filters extends WP_UnitTestCase {
$a = new MockAction();
$tag = rand_str();
add_action($tag, array(&$a, 'filter'));
add_action($tag, array($a, 'filter'));
apply_filters_ref_array($tag, array(&$obj));
@ -220,8 +220,8 @@ class Tests_Filters extends WP_UnitTestCase {
$b = new MockAction();
$tag = rand_str();
add_action($tag, array(&$a, 'filter_append'), 10, 2);
add_action($tag, array(&$b, 'filter_append'), 10, 2);
add_action($tag, array($a, 'filter_append'), 10, 2);
add_action($tag, array($b, 'filter_append'), 10, 2);
$result = apply_filters_ref_array($tag, array('string', &$obj));
@ -242,7 +242,7 @@ class Tests_Filters extends WP_UnitTestCase {
}
function _self_removal($tag) {
remove_action( $tag, array(&$this, '_self_removal'), 10, 1 );
remove_action( $tag, array($this, '_self_removal'), 10, 1 );
return $tag;
}
@ -254,9 +254,9 @@ class Tests_Filters extends WP_UnitTestCase {
$a = new MockAction();
$b = new MockAction();
add_action( $tag, array(&$a, 'filter_append'), 11, 1 );
add_action( $tag, array(&$b, 'filter_append'), 12, 1 );
add_action( $tag, array(&$this, '_self_removal'), 10, 1 );
add_action( $tag, array($a, 'filter_append'), 11, 1 );
add_action( $tag, array($b, 'filter_append'), 12, 1 );
add_action( $tag, array($this, '_self_removal'), 10, 1 );
$result = apply_filters($tag, $tag);
$this->assertEquals( 1, $a->get_call_count(), 'priority 11 filters should run after priority 10 empties itself' );

View File

@ -19,7 +19,7 @@ class Tests_Meta extends WP_UnitTestCase {
$meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' );
$this->assertEquals( 'unsanitized', $meta );
register_meta( 'post', 'some_meta', array( &$this, '_meta_sanitize_cb' ) );
register_meta( 'post', 'some_meta', array( $this, '_meta_sanitize_cb' ) );
$meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' );
$this->assertEquals( 'sanitized', $meta );
}

View File

@ -10,9 +10,9 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase {
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
$GLOBALS['wp_theme_directories'] = array( $this->theme_root );
add_filter('theme_root', array(&$this, '_theme_root'));
add_filter( 'stylesheet_root', array(&$this, '_theme_root') );
add_filter( 'template_root', array(&$this, '_theme_root') );
add_filter('theme_root', array($this, '_theme_root'));
add_filter( 'stylesheet_root', array($this, '_theme_root') );
add_filter( 'template_root', array($this, '_theme_root') );
// clear caches
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
@ -20,9 +20,9 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase {
function tearDown() {
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
remove_filter('theme_root', array(&$this, '_theme_root'));
remove_filter( 'stylesheet_root', array(&$this, '_theme_root') );
remove_filter( 'template_root', array(&$this, '_theme_root') );
remove_filter('theme_root', array($this, '_theme_root'));
remove_filter( 'stylesheet_root', array($this, '_theme_root') );
remove_filter( 'template_root', array($this, '_theme_root') );
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
parent::tearDown();

View File

@ -15,9 +15,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
// /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
add_filter('theme_root', array(&$this, '_theme_root'));
add_filter( 'stylesheet_root', array(&$this, '_theme_root') );
add_filter( 'template_root', array(&$this, '_theme_root') );
add_filter('theme_root', array($this, '_theme_root'));
add_filter( 'stylesheet_root', array($this, '_theme_root') );
add_filter( 'template_root', array($this, '_theme_root') );
// clear caches
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
@ -25,9 +25,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
function tearDown() {
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
remove_filter('theme_root', array(&$this, '_theme_root'));
remove_filter( 'stylesheet_root', array(&$this, '_theme_root') );
remove_filter( 'template_root', array(&$this, '_theme_root') );
remove_filter('theme_root', array($this, '_theme_root'));
remove_filter( 'stylesheet_root', array($this, '_theme_root') );
remove_filter( 'template_root', array($this, '_theme_root') );
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
parent::tearDown();

View File

@ -508,7 +508,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
$this->assertFalse( $admin->has_cap('add_post_meta', $post, '_protected') );
$this->assertFalse( $admin->has_cap('delete_post_meta', $post, '_protected') );
register_meta( 'post', '_protected', array( &$this, '_meta_filter' ), array( &$this, '_meta_yes_you_can' ) );
register_meta( 'post', '_protected', array( $this, '_meta_filter' ), array( $this, '_meta_yes_you_can' ) );
$this->assertTrue( $admin->has_cap('edit_post_meta', $post, '_protected') );
$this->assertTrue( $admin->has_cap('add_post_meta', $post, '_protected') );
$this->assertTrue( $admin->has_cap('delete_post_meta', $post, '_protected') );
@ -517,7 +517,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
$this->assertTrue( $admin->has_cap('add_post_meta', $post, 'not_protected') );
$this->assertTrue( $admin->has_cap('delete_post_meta', $post, 'not_protected') );
register_meta( 'post', 'not_protected', array( &$this, '_meta_filter' ), array( &$this, '_meta_no_you_cant' ) );
register_meta( 'post', 'not_protected', array( $this, '_meta_filter' ), array( $this, '_meta_no_you_cant' ) );
$this->assertFalse( $admin->has_cap('edit_post_meta', $post, 'not_protected') );
$this->assertFalse( $admin->has_cap('add_post_meta', $post, 'not_protected') );
$this->assertFalse( $admin->has_cap('delete_post_meta', $post, 'not_protected') );

View File

@ -237,7 +237,7 @@ class MakePOT {
return $this->wp_generic( $dir, array(
'project' => 'wp-core', 'output' => $output,
'extract_not_gettexted' => true,
'not_gettexted_files_filter' => array( &$this, 'is_not_ms_file' ),
'not_gettexted_files_filter' => array( $this, 'is_not_ms_file' ),
) );
}
@ -340,7 +340,7 @@ class MakePOT {
'includes' => $this->ms_files, 'excludes' => array(),
'default_output' => 'wordpress-ms.pot',
'extract_not_gettexted' => true,
'not_gettexted_files_filter' => array( &$this, 'is_ms_file' ),
'not_gettexted_files_filter' => array( $this, 'is_ms_file' ),
) );
if ( !$ms_result ) {
return false;
@ -557,7 +557,7 @@ $included_files = get_included_files();
if ($included_files[0] == __FILE__) {
$makepot = new MakePOT;
if ((3 == count($argv) || 4 == count($argv)) && in_array($method = str_replace('-', '_', $argv[1]), get_class_methods($makepot))) {
$res = call_user_func(array(&$makepot, $method), realpath($argv[2]), isset($argv[3])? $argv[3] : null);
$res = call_user_func(array($makepot, $method), realpath($argv[2]), isset($argv[3])? $argv[3] : null);
if (false === $res) {
fwrite(STDERR, "Couldn't generate POT file!\n");
}

View File

@ -59,7 +59,7 @@ class NotGettexted {
if ('.' == $item || '..' == $item)
continue;
if ('.php' == substr($item, -4))
$files[] = $full_item;
$files[] = $full_item;
if (is_dir($full_item))
$files += array_merge($files, NotGettexted::list_php_files($full_item, $files));
}
@ -99,7 +99,7 @@ class NotGettexted {
continue;
}
if ($this->STAGE_START_COMMENT <= $stage && $stage <= $this->STAGE_WHITESPACE_AFTER && '/'.$current_comment_id == $matches[1]) {
$stage = $this->STAGE_END_COMMENT;
$stage = $this->STAGE_END_COMMENT;
$this->logmsg('end comment', $current_comment_id);
$result .= call_user_func($other_action, $token);
if (!is_null($register_action)) call_user_func($register_action, $current_string, $current_comment_id, $current_string_line);
@ -152,7 +152,7 @@ class NotGettexted {
foreach($filenames as $filename) {
$tokens = token_get_all(file_get_contents($filename));
$aggregator = $this->make_string_aggregator($global_name, $filename);
$this->walk_tokens($tokens, array(&$this, 'ignore_token'), array(&$this, 'ignore_token'), $aggregator);
$this->walk_tokens($tokens, array($this, 'ignore_token'), array($this, 'ignore_token'), $aggregator);
}
$potf = '-' == $pot_filename? STDOUT : @fopen($pot_filename, 'a');
@ -196,7 +196,7 @@ class NotGettexted {
$source = file_get_contents($filename);
if ( strlen($source) > 150000 ) continue;
$tokens = token_get_all($source);
$new_file = $this->walk_tokens($tokens, $replacer, array(&$this, 'unchanged_token'));
$new_file = $this->walk_tokens($tokens, $replacer, array($this, 'unchanged_token'));
$f = fopen($filename, 'w');
fwrite($f, $new_file);
fclose($f);
@ -218,7 +218,7 @@ class NotGettexted {
$this->usage();
exit(1);
}
call_user_func_array(array(&$this, $this->commands[$argv[1]]), array_slice($argv, 2));
call_user_func_array(array($this, $this->commands[$argv[1]]), array_slice($argv, 2));
}
}

View File

@ -51,7 +51,7 @@ class PotExtMeta {
if ( $headers )
$this->headers = (array) $headers;
if ( is_dir( $ext_filename ) ) {
$pot = implode('', array_map(array(&$this, 'load_from_file'), glob("$ext_filename/*.php")));
$pot = implode('', array_map(array($this, 'load_from_file'), glob("$ext_filename/*.php")));
} else {
$pot = $this->load_from_file($ext_filename);
}

View File

@ -9,11 +9,11 @@ error_reporting( E_ALL );
require_once dirname( dirname( __FILE__ ) ) . '/not-gettexted.php';
class NotGettextedTest extends PHPUnit_Framework_TestCase {
function __construct() {
$this->ng = new NotGettexted;
}
function test_make_string_aggregator() {
global $baba;
$f = $this->ng->make_string_aggregator( 'baba', 'baba.php' );
@ -29,11 +29,11 @@ class NotGettextedTest extends PHPUnit_Framework_TestCase {
echo /* WP_I18N_GUGU*/ "yes" /* /WP_I18N_UGU */;
if ($x == "18181") { wp_die(sprintf(/*WP_I18N_DIE*/\'We died %d times!\'/*WP_I18N_DIE*/)); }
?>';
$tokens = token_get_all($code);
$this->assertEquals( '', $this->ng->walk_tokens( $tokens, array(&$this->ng, 'ignore_token'), array(&$this->ng, 'ignore_token') ) );
$this->assertEquals( '"yes"\'We died %d times!\'', $this->ng->walk_tokens( $tokens, array(&$this->ng, 'unchanged_token'), array(&$this->ng, 'ignore_token') ) );
$this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array(&$this->ng, 'unchanged_token'), array(&$this->ng, 'unchanged_token') ) );
$this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array(&$this->ng, 'unchanged_token'), array(&$this->ng, 'unchanged_token') ) );
$tokens = token_get_all($code);
$this->assertEquals( '', $this->ng->walk_tokens( $tokens, array($this->ng, 'ignore_token'), array($this->ng, 'ignore_token') ) );
$this->assertEquals( '"yes"\'We died %d times!\'', $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'ignore_token') ) );
$this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token') ) );
$this->assertEquals( $code, $this->ng->walk_tokens( $tokens, array($this->ng, 'unchanged_token'), array($this->ng, 'unchanged_token') ) );
}
function test_replace() {
@ -43,4 +43,4 @@ echo /* WP_I18N_GUGU*/ "yes" /* /WP_I18N_UGU */;
$this->assertEquals( file_get_contents( 'data/not-gettexted-0-result.php' ), file_get_contents( 'data/not-gettexted-0-work.php' ) );
unlink( 'data/not-gettexted-0-work.php' );
}
}
}