Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/php-sniffer-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
php-version: '7.4'
coverage: none
tools: composer, cs2pr
tools: composer

- name: Get Composer cache directory
id: composer-cache
Expand All @@ -41,4 +41,4 @@ jobs:
run: composer install --prefer-dist --no-suggest --no-progress --no-interaction

- name: Detect coding standard violations (PHPCS)
run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings
run: composer run phpcs
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@
"composer/installers": "^1.0 || ^2.0"
},
"require-dev": {
"php-stubs/wp-cli-stubs": "^2.11",
"phpcompatibility/phpcompatibility-wp": "^2.1.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.12",
"szepeviktor/phpstan-wordpress": "^1.0",
"wp-coding-standards/wpcs": "^3.1.0",
"yoast/wp-test-utils": "^1.2"
"php-stubs/wp-cli-stubs": "^2.12.0",
"phpcompatibility/phpcompatibility-wp": "^2.1.8",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^2.1.33",
"staabm/annotate-pull-request-from-checkstyle": "^1.8.6",
"szepeviktor/phpstan-wordpress": "^2.0.3",
"wp-coding-standards/wpcs": "^3.3.0",
"yoast/wp-test-utils": "^1.2.0"
},
"scripts": {
"phpstan": "vendor/bin/phpstan analyse --memory-limit=1G"
"phpstan": "vendor/bin/phpstan analyse --memory-limit=1G",
"phpcs": "vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | vendor/bin/cs2pr --graceful-warnings"
},
"config": {
"allow-plugins": {
Expand Down
8 changes: 6 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ parameters:
#- %rootDir%/../../php-stubs/wp-cli-stubs/wp-cli-tools-stubs.php
ignoreErrors:
- '/^Call to static method encode\(\) on an unknown class Requests_IDNAEncoder\.$/'
- '/^Constant WP_CONTENT_URL not found\.$/'
# WP_Network::$blog_id is a private property that can be accessed via magic methods.
- '/^Access to an undefined property WP_Network::\$blog_id\.$/'
# WP_CLI\Fetchers\User::get() returns WP_User without root namespace.
- '/^Access to property \$ID on an unknown class WP_CLI\\Fetchers\\WP_User\.$/'
- '/^Cannot access property \$ID on WP_CLI\\Fetchers\\WP_User\|false\.$/'
# Backward compatibility with old method of passing arguments.
- '/^Call to function is_array\(\) with array<string, mixed> will always evaluate to true\.$/'
# Associative CLI arguments. Passed by reference.
- '/^Parameter \&\$assoc_args by-ref type of method WP_MS_Network_Command::get_formatter\(\) expects array<string, mixed>, array given\.$/'

Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ private function handle_delete_networks() {
*
* @since 2.0.0
*
* @param array<string, string> $args Optional. URL query arguments. Default empty array.
* @param array<string, int|string> $args Optional. URL query arguments. Default empty array.
* @return void
*/
private function handle_redirect( $args = array() ) {
Expand All @@ -1221,7 +1221,7 @@ private function handle_redirect( $args = array() ) {
*
* @since 1.3.0
*
* @param array<string, string> $args Optional. URL query arguments. Default empty array.
* @param array<string, int|string> $args Optional. URL query arguments. Default empty array.
* @return string Absolute URL to the networks page.
*/
private function admin_url( $args = array() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,7 @@ protected function handle_row_actions( $network, $column_name, $primary ) {

// Edit the network.
if ( current_user_can( 'edit_network', $network->id ) ) {
$edit_network_url = add_query_arg(
array(
'action' => 'edit_network',
),
$base_url
);
$edit_network_url = add_query_arg( array( 'action' => 'edit_network' ), $base_url );

$actions['edit'] = '<span class="edit"><a href="' . esc_url( $edit_network_url ) . '">' . esc_html__( 'Edit', 'wp-multi-network' ) . '</a></span>';
}
Expand All @@ -474,11 +469,7 @@ protected function handle_row_actions( $network, $column_name, $primary ) {
// Delete the network.
if ( $this->can_delete( $network ) ) {
$delete_network_url = wp_nonce_url(
add_query_arg(
array(
'action' => 'delete_network',
), $base_url
)
add_query_arg( array( 'action' => 'delete_network' ), $base_url )
);

$actions['delete'] = '<span class="delete"><a href="' . esc_url( $delete_network_url ) . '">' . esc_html__( 'Delete', 'wp-multi-network' ) . '</a></span>';
Expand All @@ -493,7 +484,7 @@ protected function handle_row_actions( $network, $column_name, $primary ) {
* @param int $network_id The current network ID.
* @param string $network_sitename The current network name.
*/
$actions = apply_filters( 'manage_networks_action_links', array_filter( $actions ), $network->id, $network->site_name );
$actions = apply_filters( 'manage_networks_action_links', $actions, $network->id, $network->site_name );

// Return all row actions.
return $this->row_actions( $actions );
Expand Down
16 changes: 7 additions & 9 deletions wp-multi-network/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ function add_network( $args = array() ) {
// so we have to replace the hostname the hard way.
$current_siteurl = get_option( 'siteurl' );
$new_siteurl = untrailingslashit( get_blogaddress_by_id( $new_blog_id ) );
$upload_url = str_replace( $current_siteurl, $new_siteurl, WP_CONTENT_URL );
$upload_url = str_replace( $current_siteurl, $new_siteurl, content_url() );
$upload_url = $upload_url . '/uploads';

$upload_dir = WP_CONTENT_DIR;
Expand Down Expand Up @@ -842,15 +842,13 @@ function delete_network( $network_id, $delete_blogs = false ) {
return new WP_Error( 'network_not_empty', __( 'Cannot delete network with sites.', 'wp-multi-network' ) );
}

if ( true === $delete_blogs ) {
foreach ( $sites as $site ) {
if ( wp_should_rescue_orphaned_sites() ) {
move_site( $site->id, 0 );
continue;
}

wpmu_delete_blog( $site->id, true );
foreach ( $sites as $site ) {
if ( wp_should_rescue_orphaned_sites() ) {
move_site( $site->id, 0 );
continue;
}

wpmu_delete_blog( $site->id, true );
}
}

Expand Down
Loading