mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -20,34 +20,38 @@ function tests_reset__SERVER() {
|
||||
}
|
||||
|
||||
// For adding hooks before loading WP
|
||||
function tests_add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
|
||||
function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
|
||||
global $wp_filter;
|
||||
|
||||
if ( function_exists( 'add_filter' ) ) {
|
||||
add_filter( $tag, $function_to_add, $priority, $accepted_args );
|
||||
} else {
|
||||
$idx = _test_filter_build_unique_id($tag, $function_to_add, $priority);
|
||||
$wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
|
||||
$idx = _test_filter_build_unique_id( $tag, $function_to_add, $priority );
|
||||
$wp_filter[ $tag ][ $priority ][ $idx ] = array(
|
||||
'function' => $function_to_add,
|
||||
'accepted_args' => $accepted_args,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function _test_filter_build_unique_id($tag, $function, $priority) {
|
||||
if ( is_string($function) )
|
||||
function _test_filter_build_unique_id( $tag, $function, $priority ) {
|
||||
if ( is_string( $function ) ) {
|
||||
return $function;
|
||||
}
|
||||
|
||||
if ( is_object($function) ) {
|
||||
if ( is_object( $function ) ) {
|
||||
// Closures are currently implemented as objects
|
||||
$function = array( $function, '' );
|
||||
} else {
|
||||
$function = (array) $function;
|
||||
}
|
||||
|
||||
if (is_object($function[0]) ) {
|
||||
return spl_object_hash($function[0]) . $function[1];
|
||||
} else if ( is_string($function[0]) ) {
|
||||
if ( is_object( $function[0] ) ) {
|
||||
return spl_object_hash( $function[0] ) . $function[1];
|
||||
} elseif ( is_string( $function[0] ) ) {
|
||||
// Static Calling
|
||||
return $function[0].$function[1];
|
||||
return $function[0] . $function[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,14 +64,14 @@ function _delete_all_data() {
|
||||
$wpdb->comments,
|
||||
$wpdb->commentmeta,
|
||||
$wpdb->term_relationships,
|
||||
$wpdb->termmeta
|
||||
$wpdb->termmeta,
|
||||
) as $table ) {
|
||||
$wpdb->query( "DELETE FROM {$table}" );
|
||||
}
|
||||
|
||||
foreach ( array(
|
||||
$wpdb->terms,
|
||||
$wpdb->term_taxonomy
|
||||
$wpdb->term_taxonomy,
|
||||
) as $table ) {
|
||||
$wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" );
|
||||
}
|
||||
@@ -96,8 +100,8 @@ function _delete_all_posts() {
|
||||
}
|
||||
|
||||
function _wp_die_handler( $message, $title = '', $args = array() ) {
|
||||
if ( !$GLOBALS['_wp_die_disabled'] ) {
|
||||
_wp_die_handler_txt( $message, $title, $args);
|
||||
if ( ! $GLOBALS['_wp_die_disabled'] ) {
|
||||
_wp_die_handler_txt( $message, $title, $args );
|
||||
} else {
|
||||
//Ignore at our peril
|
||||
}
|
||||
@@ -125,7 +129,7 @@ function _wp_die_handler_txt( $message, $title, $args ) {
|
||||
echo "Title : $title\n";
|
||||
if ( ! empty( $args ) ) {
|
||||
echo "Args: \n";
|
||||
foreach( $args as $k => $v ){
|
||||
foreach ( $args as $k => $v ) {
|
||||
echo "\t $k : $v\n";
|
||||
}
|
||||
}
|
||||
@@ -137,7 +141,7 @@ function _wp_die_handler_exit( $message, $title, $args ) {
|
||||
echo "Title : $title\n";
|
||||
if ( ! empty( $args ) ) {
|
||||
echo "Args: \n";
|
||||
foreach( $args as $k => $v ){
|
||||
foreach ( $args as $k => $v ) {
|
||||
echo "\t $k : $v\n";
|
||||
}
|
||||
}
|
||||
@@ -163,8 +167,8 @@ function _upload_dir_no_subdir( $uploads ) {
|
||||
$subdir = $uploads['subdir'];
|
||||
|
||||
$uploads['subdir'] = '';
|
||||
$uploads['path'] = str_replace( $subdir, '', $uploads['path'] );
|
||||
$uploads['url'] = str_replace( $subdir, '', $uploads['url'] );
|
||||
$uploads['path'] = str_replace( $subdir, '', $uploads['path'] );
|
||||
$uploads['url'] = str_replace( $subdir, '', $uploads['url'] );
|
||||
|
||||
return $uploads;
|
||||
}
|
||||
@@ -173,7 +177,7 @@ function _upload_dir_no_subdir( $uploads ) {
|
||||
* Helper used with the `upload_dir` filter to set https upload URL.
|
||||
*/
|
||||
function _upload_dir_https( $uploads ) {
|
||||
$uploads['url'] = str_replace( 'http://', 'https://', $uploads['url'] );
|
||||
$uploads['url'] = str_replace( 'http://', 'https://', $uploads['url'] );
|
||||
$uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
|
||||
|
||||
return $uploads;
|
||||
|
||||
Reference in New Issue
Block a user