Plugin Directory

Changeset 3414829


Ignore:
Timestamp:
12/09/2025 02:04:55 AM (4 months ago)
Author:
spacedmonkey
Message:

Update to version 3.0.0 from GitHub

Location:
wp-multi-network
Files:
12 added
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-multi-network/tags/3.0.0/readme.txt

    r2788090 r3414829  
    22Author:            Triple J Software, Inc.
    33Author URI:        https://jjj.software
    4 Donate link:       https://buy.stripe.com/7sI3cd2tK1Cy2lydQR
    54Plugin URI:        https://wordpress.org/plugins/wp-multi-network/
    65License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    98Tags:              network, sites, domains, global, admin
    109Requires PHP:      5.2
    11 Requires at least: 4.9
    12 Tested up to:      6.1
     10Requires at least: 5.5
     11Tested up to:      7.0
    1312Stable tag:        2.5.2
    1413
     
    123122
    124123== Changelog ==
     124
     125= 2.5.3 =
     126* Remove filter_input usages
     127
    125128= 2.5.2 =
    126129* Use get_main_site_id function instead of get_main_site_for_network.
     
    128131
    129132= 2.5.1 =
    130 * Save main site on network as network option. 
     133* Save main site on network as network option.
    131134
    132135= 2.5.0 =
  • wp-multi-network/tags/3.0.0/wp-multi-network/assets/js/wp-multi-network.js

    r2584493 r3414829  
    1 jQuery( document ).ready(
    2     function ( $ ) {
     1/**
     2 * WP Multi Network Admin Script
     3 */
    34
    4             $( '.if-js-closed' )
    5             .removeClass( 'if-js-closed' )
    6             .addClass( 'closed' );
    75
    8             $( '.postbox' ).children( 'h3' ).click(
    9                 function () {
    10                     if ( $( this.parentNode ).hasClass( 'closed' ) ) {
    11                         $( this.parentNode ).removeClass( 'closed' );
    12                     } else {
    13                         $( this.parentNode ).addClass( 'closed' );
    14                     }
    15                 }
    16             );
     6jQuery( document ).ready( function ( $ ) {
     7    $( '.if-js-closed' ).removeClass( 'if-js-closed' ).addClass( 'closed' );
    178
    18             /* Handle clicks to add/remove sites to/from selected list */
    19             $( 'input[name=assign]' ).click(
    20                 function () {
    21                     move( 'from', 'to' );
    22                 }
    23             );
     9    $( '.postbox' )
     10        .children( 'h3' )
     11        .click( function () {
     12            if ( $( this.parentNode ).hasClass( 'closed' ) ) {
     13                $( this.parentNode ).removeClass( 'closed' );
     14            } else {
     15                $( this.parentNode ).addClass( 'closed' );
     16            }
     17        } );
    2418
    25             $( 'input[name=unassign]' ).click(
    26                 function () {
    27                     move( 'to', 'from' );
    28                 }
    29             );
     19    /* Handle clicks to add/remove sites to/from selected list */
     20    $( 'input[name=assign]' ).click( function () {
     21        move( 'from', 'to' );
     22    } );
    3023
    31             /* Select all sites in "selected" box when submitting */
    32             $( '#edit-network-form' ).submit(
    33                 function () {
    34                     $( '#to' ).children( 'option:enabled' ).attr( 'selected', true );
    35                     $( '#from' ).children( 'option:enabled' ).attr( 'selected', true );
    36                 }
    37             );
     24    $( 'input[name=unassign]' ).click( function () {
     25        move( 'to', 'from' );
     26    } );
    3827
    39         function move( from, to ) {
    40             jQuery( '#' + from ).children( 'option:selected' ).each(
    41                 function () {
    42                     jQuery( '#' + to ).append( jQuery( this ).clone() );
    43                     jQuery( this ).remove();
    44                 }
    45             );
    46         }
     28    /* Select all sites in "selected" box when submitting */
     29    $( '#edit-network-form' ).submit( function () {
     30        $( '#to' ).children( 'option:enabled' ).attr( 'selected', true );
     31        $( '#from' ).children( 'option:enabled' ).attr( 'selected', true );
     32    } );
     33
     34    function move( from, to ) {
     35        jQuery( '#' + from )
     36            .children( 'option:selected' )
     37            .each( function () {
     38                jQuery( '#' + to ).append( jQuery( this ).clone() );
     39                jQuery( this ).remove();
     40            } );
    4741    }
    48 );
     42} );
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/classes/class-wp-ms-network-command.php

    r2584493 r3414829  
    1212 * @since 1.3.0
    1313 */
    14 class WP_MS_Network_Command extends WP_CLI_Command {
     14class WP_MS_Network_Command {
    1515
    1616    /**
     
    1818     *
    1919     * @since 1.3.0
    20      * @var array
     20     * @var string[]
    2121     */
    2222    protected $obj_fields = array(
     
    5555     * @since 1.3.0
    5656     *
    57      * @param array $args       Positional CLI arguments.
    58      * @param array $assoc_args Associative CLI arguments.
     57     * @param string[]             $args Positional CLI arguments.
     58     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     59     * @return void
    5960     */
    6061    public function create( $args, $assoc_args ) {
    61         list( $domain, $path ) = $args;
     62        [ $domain, $path ] = $args;
    6263
    6364        $assoc_args = wp_parse_args(
     
    7576            $user  = $users->get( $assoc_args['network_admin'] );
    7677            if ( ! $user ) {
    77                 return new WP_Error( 'network_super_admin', 'Super user does not exist.' );
     78                WP_CLI::error( 'Super user does not exist.' );
    7879            }
    7980            $network_admin_id = $user->ID;
     
    8283        }
    8384
    84         $clone_network    = $assoc_args['clone_network'];
    85         $options_to_clone = false;
    86 
    87         if ( ! empty( $clone_network ) && ! get_network( $clone_network ) ) {
     85        $clone_network = $assoc_args['clone_network'];
     86
     87        if ( ! empty( $clone_network ) && is_numeric( $clone_network ) && ! get_network( $clone_network ) ) {
    8888            WP_CLI::error( sprintf( "Clone network %s doesn't exist.", $clone_network ) );
    89 
    90             if ( ! empty( $assoc_args['options_to_clone'] ) ) {
    91                 $options_to_clone = explode( ',', $assoc_args['options_to_clone'] );
    92             }
    9389        }
    9490
     
    10298                'network_admin_id' => $network_admin_id,
    10399                'clone_network'    => $clone_network,
    104                 'options_to_clone' => $options_to_clone,
     100                'options_to_clone' => $assoc_args['options_to_clone'],
    105101            )
    106102        );
     
    127123     * @since 1.3.0
    128124     *
    129      * @param array $args       Positional CLI arguments.
    130      * @param array $assoc_args Associative CLI arguments.
     125     * @param string[]             $args Positional CLI arguments.
     126     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     127     * @return void
    131128     */
    132129    public function update( $args, $assoc_args ) {
    133         list( $id, $domain ) = $args;
     130        [ $id, $domain ] = $args;
    134131
    135132        $defaults   = array(
     
    138135        $assoc_args = wp_parse_args( $assoc_args, $defaults );
    139136
    140         $network_id = update_network( $id, $domain, $assoc_args['path'] );
     137        $network_id = update_network( (int) $id, $domain, $assoc_args['path'] );
    141138
    142139        if ( is_wp_error( $network_id ) ) {
     
    158155     * @since 1.3.0
    159156     *
    160      * @param array $args       Positional CLI arguments.
    161      * @param array $assoc_args Associative CLI arguments.
     157     * @param string[]             $args Positional CLI arguments.
     158     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     159     * @return void
    162160     */
    163161    public function delete( $args, $assoc_args ) {
    164         list( $id ) = $args;
     162        [ $id ] = $args;
    165163
    166164        $assoc_args = wp_parse_args(
     
    170168        );
    171169
    172         $network_id = delete_network( $id, $assoc_args['delete_blogs'] );
     170        $network_id = delete_network( (int) $id, $assoc_args['delete_blogs'] );
    173171
    174172        if ( is_wp_error( $network_id ) ) {
     
    192190     * @since 1.3.0
    193191     *
    194      * @param array $args       Positional CLI arguments.
    195      * @param array $assoc_args Associative CLI arguments.
    196      */
    197     public function move_site( $args, $assoc_args ) {
    198         list( $site_id, $new_network_id ) = $args;
    199 
    200         $network_id = move_site( $site_id, $new_network_id );
     192     * @param string[]             $args Positional CLI arguments.
     193     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     194     * @return void
     195     */
     196    public function move_site( $args, $assoc_args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
     197        [ $site_id, $new_network_id ] = $args;
     198
     199        $network_id = move_site( (int) $site_id, (int) $new_network_id );
    201200
    202201        if ( is_wp_error( $network_id ) ) {
     
    228227     * @since 1.3.0
    229228     *
    230      * @param array $args       Positional CLI arguments.
    231      * @param array $assoc_args Associative CLI arguments.
     229     * @param string[]             $args Positional CLI arguments.
     230     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     231     * @return void
    232232     */
    233233    public function list_( $args, $assoc_args ) {
     
    257257     * @since 1.3.0
    258258     *
    259      * @param array $args       Positional CLI arguments.
    260      * @param array $assoc_args Associative CLI arguments.
     259     * @param string[]             $args Positional CLI arguments.
     260     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     261     * @return void
    261262     */
    262263    public function plugin( $args, $assoc_args ) {
    263         $this->fetcher = new \WP_CLI\Fetchers\Plugin();
    264         $action        = array_shift( $args );
     264        $fetchers_plugin = new \WP_CLI\Fetchers\Plugin();
     265        $action          = array_shift( $args );
     266
    265267        if ( ! in_array( $action, array( 'activate', 'deactivate' ), true ) ) {
    266268            WP_CLI::error( sprintf( '%s is not a supported action.', $action ) );
    267269        }
     270
    268271        $network_wide = \WP_CLI\Utils\get_flag_value( $assoc_args, 'network' );
    269272        $all          = \WP_CLI\Utils\get_flag_value( $assoc_args, 'all', false );
     
    281284                $args = array_map(
    282285                    function ( $file ) {
    283                             return \WP_CLI\Utils\get_plugin_name( $file );
     286                        return \WP_CLI\Utils\get_plugin_name( $file );
    284287                    }, array_keys( get_plugins() )
    285288                );
    286289            }
    287             foreach ( $this->fetcher->get_many( $args ) as $plugin ) {
     290            foreach ( $fetchers_plugin->get_many( $args ) as $plugin ) {
    288291                $status = $this->get_status( $plugin->file );
    289292                if ( $all && in_array( $status, array( 'active', 'active-network' ), true ) ) {
    290                     $needing_activation --;
     293                    --$needing_activation;
    291294                    continue;
    292295                }
     
    311314                    activate_plugins( $plugin->file, '', $network_wide );
    312315                } else {
    313                     deactivate_plugins( $plugin->file, '', $network_wide );
     316                    deactivate_plugins( $plugin->file, false, $network_wide );
    314317                }
    315318
     
    327330     * @since 1.3.0
    328331     *
    329      * @param array $assoc_args Associative CLI arguments. Passed by reference.
     332     * @param array<string, mixed> $assoc_args Associative CLI arguments. Passed by reference.
    330333     * @return WP_CLI\Formatter WP-CLI formatter instance.
    331334     */
     
    378381     * @param bool   $network_wide Whether to check network-wide or not.
    379382     * @param string $action       Action performed.
     383     * @return void
    380384     */
    381385    private function active_output( $name, $file, $network_wide, $action ) {
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/classes/class-wp-ms-networks-admin-bar.php

    r2584493 r3414829  
    1818
    1919    /**
    20      * Constructor.
     20     * Registers WordPress hooks for the plugin.
    2121     *
    22      * Hooks in the necessary methods.
     22     * Adds actions to:
     23     * - Modify the admin bar menu
     24     * - Add custom styles to the admin area
     25     * - Add custom styles to the front-end
    2326     *
    24      * @since 2.2.0
     27     * @return void
    2528     */
    26     public function __construct() {
     29    public function add_hooks(): void {
    2730        add_action( 'admin_bar_menu', array( $this, 'admin_bar' ), 20 );
    28 
    2931        add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
    3032        add_action( 'wp_print_styles', array( $this, 'admin_print_styles' ) );
     
    3840     *
    3941     * @since 2.2.0
     42     * @since 3.0.0 Prevent rendering of CSS if admin bar is not shown.
     43     * @return void
    4044     */
    4145    public function admin_print_styles() {
     46        if ( ! is_admin_bar_showing() ) {
     47            return;
     48        }
    4249        ?>
    4350        <style type="text/css">
     
    5663     *
    5764     * @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
     65     * @return void
    5866     */
    5967    public function admin_bar( $wp_admin_bar ) {
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/classes/class-wp-ms-networks-admin.php

    r2588851 r3414829  
    2121     *
    2222     * @since 2.0.0
    23      * @var array
     23     * @var array<string, array<int, string>>
    2424     */
    2525    private $feedback_strings = array();
     
    3333     */
    3434    public function __construct() {
    35         $this->set_feedback_strings();
    36 
    3735        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    3836        add_action( 'network_admin_menu', array( $this, 'network_admin_menu' ) );
     
    4139        add_action( 'admin_init', array( $this, 'route_save_handlers' ) );
    4240
     41        add_action( 'admin_init', array( $this, 'set_feedback_strings' ) );
    4342        add_action( 'network_admin_notices', array( $this, 'network_admin_notices' ) );
    4443
     
    5352     * @since 1.3.0
    5453     *
    55      * @param array $actions Array of action links.
    56      * @param int   $blog_id Current site ID.
    57      * @return array Adjusted action links.
     54     * @param array<string, string> $actions Array of action links.
     55     * @param int                   $blog_id Current site ID.
     56     * @return array<string, string> Adjusted action links.
    5857     */
    5958    public function add_move_blog_link( $actions = array(), $blog_id = 0 ) {
     
    8584     *
    8685     * @since 1.3.0
     86     * @return void
    8787     */
    8888    public function admin_menu() {
     
    103103     *
    104104     * @since 1.3.0
     105     * @return void
    105106     */
    106107    public function network_admin_menu() {
     
    120121     *
    121122     * @since 1.5.2
     123     * @return void
    122124     */
    123125    public function network_admin_menu_separator() {
     
    133135     * @global string $plugin_page
    134136     * @global string $submenu_file
     137     * @return void
    135138     */
    136139    public function fix_menu_highlight_for_move_page() {
     
    138141
    139142        if ( 'networks' === $plugin_page ) {
    140             $action = filter_input( INPUT_GET, 'action' );
     143            // phpcs:disable WordPress.Security.NonceVerification.Recommended
     144            $action = ! empty( $_GET['action'] )
     145                ? sanitize_key( $_GET['action'] )
     146                : '';
     147            // phpcs:enable
     148
    141149            if ( 'move' === $action ) {
    142150                $submenu_file = 'sites.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
     
    151159     *
    152160     * @param string $page Optional. Current page hook. Default empty string.
     161     * @return void
    153162     */
    154163    public function enqueue_scripts( $page = '' ) {
     
    159168        }
    160169
    161         wp_register_style( 'wp-multi-network', wpmn()->plugin_url . 'assets/css/wp-multi-network.css', array(), wpmn()->asset_version, false );
    162         wp_register_script( 'wp-multi-network', wpmn()->plugin_url . 'assets/js/wp-multi-network.js', array( 'jquery', 'post' ), wpmn()->asset_version, true );
     170        // Determine if we should load source or minified assets based on WP_SCRIPT_DEBUG.
     171        $suffix        = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? '' : '.min';
     172        $asset_version = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? time() : wpmn()->asset_version;
     173
     174        wp_register_style( 'wp-multi-network', wpmn()->plugin_url . 'assets/css/wp-multi-network' . $suffix . '.css', array(), $asset_version );
     175        wp_register_script( 'wp-multi-network', wpmn()->plugin_url . 'assets/js/wp-multi-network' . $suffix . '.js', array( 'jquery', 'post' ), $asset_version, true );
    163176
    164177        wp_enqueue_style( 'wp-multi-network' );
     
    170183     *
    171184     * @since 2.1.0
    172      */
    173     private function set_feedback_strings() {
     185     * @return void
     186     */
     187    public function set_feedback_strings() {
    174188        $this->feedback_strings = array(
    175189            'network_updated' => array(
     
    195209     * Prints feedback notices for network admin actions as necessary.
    196210     *
     211     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     212     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     213     *
    197214     * @since 1.3.0
     215     * @return void
    198216     */
    199217    public function network_admin_notices() {
    200218        $message = '';
    201219        $type    = '';
     220
    202221        foreach ( $this->feedback_strings as $slug => $messages ) {
    203             $passed = filter_input( INPUT_GET, $slug );
    204 
    205             if ( is_string( $passed ) ) {
    206                 if ( '1' === $passed ) {
    207                     $message = $messages['1'];
    208                     $type    = 'updated';
    209                 } else {
    210                     $message = $messages['0'];
    211                     $type    = 'error';
    212                 }
    213 
    214                 break;
     222
     223            // Skip if not known feedback.
     224            if ( ! isset( $_GET[ $slug ] ) || ! is_scalar( $_GET[ $slug ] ) ) {
     225                continue;
    215226            }
    216         }
    217 
     227
     228            // Pass/Fail.
     229            $passed = sanitize_key( $_GET[ $slug ] );
     230
     231            if ( '1' === $passed ) {
     232                // Pass.
     233                $message = $messages['1'];
     234                $type    = 'updated';
     235            } else {
     236                // Fail.
     237                $message = $messages['0'];
     238                $type    = 'error';
     239            }
     240
     241            // Done.
     242            break;
     243        }
     244
     245        // Bail if no message or type.
    218246        if ( empty( $message ) || empty( $type ) ) {
    219247            return;
     
    234262     * Routes the current request to the correct page.
    235263     *
    236      * @since 2.0.0
     264     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     265     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     266     *
     267     * @since 2.0.0
     268     * @return void
    237269     */
    238270    public function route_pages() {
     
    243275        }
    244276
    245         $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING );
    246         $action = sanitize_key( $action );
     277        $action = ! empty( $_GET['action'] )
     278            ? sanitize_key( $_GET['action'] )
     279            : '';
    247280
    248281        switch ( $action ) {
     
    265298            // View the list of networks, with bulk action handling.
    266299            case 'all_networks':
    267                 $doaction = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING );
    268                 if ( empty( $doaction ) || '-1' === $doaction ) {
    269                     $doaction = filter_input( INPUT_POST, 'action2', FILTER_SANITIZE_STRING );
     300                $doaction = ! empty( $_POST['action'] )
     301                    ? sanitize_key( $_POST['action'] )
     302                    : '';
     303
     304                if (
     305                    empty( $doaction )
     306                    ||
     307                    ( '-1' === $doaction )
     308                ) {
     309                    $doaction = ! empty( $_POST['action2'] )
     310                        ? sanitize_key( $_POST['action2'] )
     311                        : '';
    270312                }
    271                 $doaction = sanitize_key( $doaction );
    272313
    273314                switch ( $doaction ) {
     
    291332     * Handles network management form submissions.
    292333     *
    293      * @since 2.0.0
     334     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     335     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     336     *
     337     * @since 2.0.0
     338     * @return void
    294339     */
    295340    public function route_save_handlers() {
     
    301346        }
    302347
    303         $action = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING );
     348        $action = ! empty( $_POST['action'] )
     349            ? sanitize_key( $_POST['action'] )
     350            : '';
     351
    304352        if ( empty( $action ) ) {
    305353            $alternative_actions = array( 'delete', 'delete_multiple', 'move' );
     354
    306355            foreach ( $alternative_actions as $alternative_action ) {
    307                 if ( filter_input( INPUT_POST, $alternative_action ) ) {
     356                if ( ! empty( $_POST[ $alternative_action ] ) ) {
    308357                    $action = $alternative_action;
    309358                    break;
     
    350399     * Renders the new network creation dashboard page.
    351400     *
    352      * @since 2.0.0
     401     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     402     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     403     *
     404     * @since 2.0.0
     405     * @return void
    353406     */
    354407    public function page_edit_network() {
    355         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
    356         $network    = $network_id ? get_network( $network_id ) : null;
     408
     409        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     410            ? (int) $_GET['id']
     411            : 0;
     412
     413        $network = ! empty( $network_id )
     414            ? get_network( $network_id )
     415            : null;
    357416
    358417        add_meta_box( 'wpmn-edit-network-details', esc_html__( 'Details', 'wp-multi-network' ), 'wpmn_edit_network_details_metabox', get_current_screen()->id, 'normal', 'high', array( $network ) );
     
    392451            <hr class="wp-header-end">
    393452
    394             <form method="post" id="edit-network-form" action="">
     453            <form method="post" action="" id="edit-network-form">
    395454                <div id="poststuff" class="poststuff">
    396455                    <div id="post-body" class="metabox-holder columns-2">
     
    398457                            <div id="titlediv">
    399458                                <div id="titlewrap">
    400                                     <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html_e( 'Enter network title here', 'wp-multi-network' ); ?></label>
     459                                    <label class="screen-reader-text" id="title-prompt-text" for="title"><?php esc_html_e( 'Enter network title here', 'wp-multi-network' ); ?></label>
    401460                                    <input type="text" name="title" size="30" id="title" spellcheck="true" autocomplete="off" value="<?php echo esc_attr( $network_title ); ?>">
    402461                                </div>
     
    423482     * Renders the network listing dashboard page.
    424483     *
     484     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     485     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     486     *
    425487     * @since 2.0.0
    426488     *
    427489     * @uses WP_MS_Networks_List_Table List_Table iterator for networks
     490     * @return void
    428491     */
    429492    private function page_all_networks() {
     
    435498        $search_url       = $this->admin_url( array( 'action' => 'domains' ) );
    436499
    437         $search_text = filter_input( INPUT_POST, 's', FILTER_SANITIZE_STRING );
     500        $search_text = ! empty( $_POST['s'] )
     501            ? stripslashes( trim( sanitize_text_field( $_POST['s'] ) ) )
     502            : '';
     503
    438504        ?>
    439505
     
    463529            </form>
    464530
    465             <form method="post" id="form-domain-list" action="<?php echo esc_url( $all_networks_url ); ?>">
     531            <form method="post" action="<?php echo esc_url( $all_networks_url ); ?>" id="form-domain-list">
    466532                <?php $wp_list_table->display(); ?>
    467533            </form>
     
    474540     * Renders the dashboard screen for moving sites -- accessed from the "Sites" screen.
    475541     *
    476      * @since 2.0.0
     542     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     543     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     544     *
     545     * @since 2.0.0
     546     * @return void
    477547     */
    478548    private function page_move_site() {
    479         $site_id = filter_input( INPUT_GET, 'blog_id', FILTER_SANITIZE_NUMBER_INT );
    480         $site    = $site_id ? get_site( $site_id ) : null;
     549
     550        $site_id = ! empty( $_GET['blog_id'] ) && is_numeric( $_GET['blog_id'] )
     551            ? (int) $_GET['blog_id']
     552            : 0;
     553
     554        $site = ! empty( $site_id )
     555            ? get_site( $site_id )
     556            : null;
    481557
    482558        // Bail if invalid site ID.
     
    507583        );
    508584
    509         $add_network_url = $this->admin_url( array( 'page' => 'add-new-network' ) );
     585        // URLs to escape.
     586        $add_network_url = $this->admin_url(
     587            array(
     588                'page' => 'add-new-network',
     589            )
     590        );
     591        $form_action_url = $this->admin_url(
     592            array(
     593                'action'  => 'move',
     594                'blog_id' => $site_id,
     595            )
     596        );
    510597        ?>
    511598
     
    525612            <hr class="wp-header-end">
    526613
    527             <form method="post" action="<?php echo esc_attr( filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING ) ); ?>">
     614            <form method="post" action="<?php echo esc_url( $form_action_url ); ?>">
    528615                <div id="poststuff">
    529616                    <div id="post-body" class="metabox-holder columns-2">
     
    547634     * Renders the delete network page.
    548635     *
    549      * @since 2.0.0
     636     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     637     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     638     *
     639     * @since 2.0.0
     640     * @return void
    550641     */
    551642    private function page_delete_network() {
    552         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
    553         $network    = $network_id ? get_network( $network_id ) : null;
     643
     644        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     645            ? (int) $_GET['id']
     646            : 0;
     647
     648        $network = ! empty( $network_id )
     649            ? get_network( $network_id )
     650            : null;
    554651
    555652        // Bail if invalid network ID.
     
    578675            <hr class="wp-header-end">
    579676
    580             <form method="post" action="<?php echo esc_attr( remove_query_arg( 'action' ) ); ?>">
     677            <form method="post" action="<?php echo esc_url( remove_query_arg( 'action' ) ); ?>">
    581678                <?php
    582679
     
    638735     * Renders the delete multiple networks page.
    639736     *
    640      * @since 2.0.0
     737     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     738     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     739     *
     740     * @since 2.0.0
     741     * @return void
    641742     */
    642743    private function page_delete_networks() {
    643         $network_id   = get_main_network_id();
    644         $all_networks = filter_input( INPUT_POST, 'all_networks', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY );
    645         $all_networks = array_map( 'absint', $all_networks );
     744
     745        $network_id = get_main_network_id();
     746
     747        $all_networks = ! empty( $_POST['all_networks'] ) && is_array( $_POST['all_networks'] )
     748            ? wp_parse_id_list( (array) $_POST['all_networks'] )
     749            : array();
     750
    646751        $all_networks = array_diff( $all_networks, array( $network_id ) );
    647752
     
    758863     *
    759864     * @global wpdb $wpdb WordPress database abstraction object.
     865     * @return void
    760866     */
    761867    public function page_my_networks() {
     
    794900                $num_rows = ceil( $num / $cols );
    795901                $split    = 0;
     902                $rows     = array();
    796903                for ( $i = 1; $i <= $num_rows; $i++ ) {
    797904                    $rows[] = array_slice( $my_networks, $split, $cols );
     
    827934                                 * @param WP_Network $network         Current network object.
    828935                                 */
    829                                 echo apply_filters( 'mynetworks_network_actions', $network_actions, $network ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
     936                                echo apply_filters( 'mynetworks_network_actions', $network_actions, $network ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    830937                                ?>
    831938                            </p>
     
    834941                        <?php
    835942                        restore_current_network();
    836                         $i++;
     943                        ++$i;
    837944                    }
    838945                    echo '</tr>';
     
    848955     * Handles the request to add a new network.
    849956     *
    850      * @since 2.0.0
     957     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     958     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     959     *
     960     * @since 2.0.0
     961     * @return void
    851962     */
    852963    private function handle_add_network() {
    853964
    854965        // Sanitize options to clone.
    855         $options_to_clone = filter_input( INPUT_POST, 'options_to_clone', FILTER_DEFAULT, FILTER_FORCE_ARRAY );
     966        $options_to_clone = ! empty( $_POST['options_to_clone'] ) && is_array( $_POST['options_to_clone'] )
     967            ? $_POST['options_to_clone']
     968            : array();
     969
    856970        $options_to_clone = ! empty( $options_to_clone )
    857971            ? array_keys( $options_to_clone )
     
    859973
    860974        // Sanitize network ID to clone.
    861         $clone = filter_input( INPUT_POST, 'clone_network', FILTER_SANITIZE_NUMBER_INT );
     975        $clone = ! empty( $_GET['clone_network'] )
     976            ? (int) $_GET['clone_network']
     977            : 0;
     978
    862979        if ( empty( $clone ) ) {
    863980            $clone = get_current_site()->id;
    864981        }
    865982
    866         // Sanitize values.
    867         $network_title  = wp_unslash( filter_input( INPUT_POST, 'title', FILTER_SANITIZE_STRING ) );
    868         $network_domain = wp_unslash( filter_input( INPUT_POST, 'domain', FILTER_SANITIZE_STRING ) );
    869         $network_path   = wp_unslash( filter_input( INPUT_POST, 'path', FILTER_SANITIZE_STRING ) );
    870         $site_name      = wp_unslash( filter_input( INPUT_POST, 'new_site', FILTER_SANITIZE_STRING ) );
    871 
    872         // Additional formatting.
    873         $network_title  = wp_strip_all_tags( $network_title );
     983        // Unslash posted values.
     984        $network_title  = ! empty( $_POST['title'] )
     985            ? wp_unslash( $_POST['title'] )
     986            : '';
     987        $network_domain = ! empty( $_POST['domain'] )
     988            ? wp_unslash( $_POST['domain'] )
     989            : '';
     990        $network_path   = ! empty( $_POST['path'] )
     991            ? wp_unslash( $_POST['path'] )
     992            : '';
     993        $site_name      = ! empty( $_POST['new_site'] )
     994            ? wp_unslash( $_POST['new_site'] )
     995            : '';
     996
     997        // Additional sanitization.
     998        $network_title  = sanitize_text_field( $network_title );
    874999        $network_domain = str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) );
    8751000        $network_path   = str_replace( ' ', '', strtolower( sanitize_text_field( $network_path ) ) );
     
    8771002        // Fallback to network title if not explicitly set.
    8781003        $site_name = ! empty( $site_name )
    879             ? wp_strip_all_tags( $site_name )
     1004            ? sanitize_text_field( $site_name )
    8801005            : $network_title;
    8811006
     
    9401065     * Handles the request to update a network.
    9411066     *
    942      * @since 2.0.0
     1067     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1068     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1069     *
     1070     * @since 2.0.0
     1071     * @return void
    9431072     */
    9441073    private function handle_update_network() {
    9451074
    9461075        // Sanitize network ID.
    947         $network_id = filter_input( INPUT_POST, 'network_id', FILTER_SANITIZE_NUMBER_INT );
     1076        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     1077            ? (int) $_GET['id']
     1078            : 0;
    9481079
    9491080        // Bail if invalid network.
     
    9521083        }
    9531084
    954         // Sanitize values.
    955         $network_title  = wp_unslash( filter_input( INPUT_POST, 'title', FILTER_SANITIZE_STRING ) );
    956         $network_domain = wp_unslash( filter_input( INPUT_POST, 'domain', FILTER_SANITIZE_STRING ) );
    957         $network_path   = wp_unslash( filter_input( INPUT_POST, 'path', FILTER_SANITIZE_STRING ) );
    958 
    959         // Additional formatting.
     1085        // Unslash posted values.
     1086        $network_title  = ! empty( $_POST['title'] )
     1087            ? wp_unslash( $_POST['title'] )
     1088            : '';
     1089        $network_domain = ! empty( $_POST['domain'] )
     1090            ? wp_unslash( $_POST['domain'] )
     1091            : '';
     1092        $network_path   = ! empty( $_POST['path'] )
     1093            ? wp_unslash( $_POST['path'] )
     1094            : '';
     1095
     1096        // Additional sanitization.
    9601097        $network_title  = sanitize_text_field( $network_title );
    961         $network_domain = Requests_IDNAEncoder::encode( str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) ) );
     1098        $network_domain = str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) );
    9621099        $network_path   = str_replace( ' ', '', strtolower( sanitize_text_field( $network_path ) ) );
    9631100
     
    10021139     * Handles the request to move a site to another network.
    10031140     *
    1004      * @since 2.0.0
     1141     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1142     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1143     *
     1144     * @since 2.0.0
     1145     * @return void
    10051146     */
    10061147    private function handle_move_site() {
    10071148
    10081149        // Sanitize values.
    1009         $site_id     = filter_input( INPUT_GET, 'blog_id', FILTER_SANITIZE_NUMBER_INT );
    1010         $new_network = filter_input( INPUT_POST, 'to', FILTER_SANITIZE_NUMBER_INT );
     1150        $site_id = ! empty( $_GET['blog_id'] ) && is_numeric( $_GET['blog_id'] )
     1151            ? (int) $_GET['blog_id']
     1152            : 0;
     1153
     1154        $new_network = ! empty( $_POST['to'] ) && is_numeric( $_POST['to'] )
     1155            ? (int) $_POST['to']
     1156            : 0;
    10111157
    10121158        // Bail if no site ID.
     
    10621208     * Handles the request to reassign sites to another network.
    10631209     *
    1064      * @since 2.0.0
     1210     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1211     *
     1212     * @since 2.0.0
     1213     * @return void
    10651214     */
    10661215    private function handle_reassign_sites() {
    10671216
    10681217        // Sanitize values.
    1069         $to   = array_map( 'absint', (array) filter_input( INPUT_POST, 'to', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY ) );
    1070         $from = array_map( 'absint', (array) filter_input( INPUT_POST, 'from', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY ) );
     1218        $to = ! empty( $_POST['to'] ) && is_array( $_POST['to'] )
     1219            ? wp_parse_id_list( (array) $_POST['to'] )
     1220            : array();
     1221
     1222        $from = ! empty( $_POST['from'] ) && is_array( $_POST['from'] )
     1223            ? wp_parse_id_list( (array) $_POST['from'] )
     1224            : array();
    10711225
    10721226        // Bail early if no movement.
     
    10761230
    10771231        // Sanitize network ID.
    1078         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
     1232        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     1233            ? (int) $_GET['id']
     1234            : 0;
    10791235
    10801236        // Default to/from arrays.
     
    11261282     * Handles the request to delete a network.
    11271283     *
    1128      * @since 2.0.0
     1284     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1285     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1286     *
     1287     * @since 2.0.0
     1288     * @return void
    11291289     */
    11301290    private function handle_delete_network() {
    11311291
    11321292        // Sanitize values.
    1133         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
    1134         $override   = (bool) filter_input( INPUT_POST, 'override' );
     1293        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     1294            ? (int) $_GET['id']
     1295            : 0;
     1296
     1297        $override = ! empty( $_POST['override'] );
    11351298
    11361299        // Attempt to delete network.
     
    11531316     * Handles the request to delete multiple networks.
    11541317     *
    1155      * @since 2.0.0
     1318     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1319     *
     1320     * @since 2.0.0
     1321     * @return void
    11561322     */
    11571323    private function handle_delete_networks() {
    11581324
    11591325        // Sanitize values.
    1160         $deleted_networks = array_map( 'absint', filter_input( INPUT_POST, 'deleted_networks', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY ) );
    1161         $override         = (bool) filter_input( INPUT_POST, 'override' );
     1326        $deleted_networks = ! empty( $_POST['deleted_networks'] ) && is_array( $_POST['deleted_networks'] )
     1327            ? wp_parse_id_list( (array) $_POST['deleted_networks'] )
     1328            : array();
     1329
     1330        $override = (bool) ! empty( $_POST['override'] );
    11621331
    11631332        // Loop through deleted networks.
     
    11881357     * @since 2.0.0
    11891358     *
    1190      * @param array $args Optional. URL query arguments. Default empty array.
     1359     * @param array<string, int|string> $args Optional. URL query arguments. Default empty array.
     1360     * @return void
    11911361     */
    11921362    private function handle_redirect( $args = array() ) {
     
    12001370     * @since 1.3.0
    12011371     *
    1202      * @param array $args Optional. URL query arguments. Default empty array.
     1372     * @param array<string, int|string> $args Optional. URL query arguments. Default empty array.
    12031373     * @return string Absolute URL to the networks page.
    12041374     */
     
    12371407     *
    12381408     * @since 2.1.0
     1409     * @return void
    12391410     */
    12401411    private function check_nonce() {
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/classes/class-wp-ms-networks-capabilities.php

    r2584493 r3414829  
    2121     *
    2222     * @since 2.3.0
     23     * @return void
    2324     */
    2425    public function add_hooks() {
     
    3132     * @since 2.3.0
    3233     *
    33      * @param array  $caps    Array of required capabilities.
    34      * @param string $cap    Capability to map.
    35      * @param int    $user_id User ID.
    36      * @param array  $args    Additional context for the capability check.
    37      * @return array Filtered required capabilities.
     34     * @param string[] $caps Array of required capabilities.
     35     * @param string   $cap Capability to map.
     36     * @param int      $user_id User ID.
     37     * @param mixed[]  $args Additional context for the capability check.
     38     * @return string[] Filtered required capabilities.
    3839     */
    39     public function map_meta_cap( $caps, $cap, $user_id, $args ) {
     40    public function map_meta_cap( $caps, $cap, $user_id, $args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
    4041
    4142        // Map our meta capabilities to primitive capabilities first.
     
    6869     * @since 2.3.0
    6970     *
    70      * @return array List of primitive global capabilities.
     71     * @return string[] List of primitive global capabilities.
    7172     */
    7273    private function get_global_capabilities() {
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/classes/class-wp-ms-networks-list-table.php

    r2588851 r3414829  
    4747     * Prepares the list table items.
    4848     *
    49      * @since 1.3.0
     49     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     50     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     51     *
     52     * @since 1.3.0
     53     * @return void
    5054     */
    5155    public function prepare_items() {
     
    5357        $pagenum  = $this->get_pagenum();
    5458
    55         $order_by = filter_input( INPUT_GET, 'orderby', FILTER_SANITIZE_STRING );
    56         $order_by = ! empty( $order_by ) ? sanitize_key( $order_by ) : '';
    57         $order    = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING );
    58         $order    = ! empty( $order ) ? strtoupper( $order ) : 'ASC';
    59         $search   = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
    60         if ( ! $search ) {
    61             $search = filter_input( INPUT_POST, 's', FILTER_SANITIZE_STRING );
    62         }
    63 
    64         $search = stripslashes( trim( $search ) );
     59        $order_by = ! empty( $_GET['orderby'] )
     60            ? sanitize_key( $_GET['orderby'] )
     61            : '';
     62
     63        $order = ! empty( $_GET['order'] )
     64            ? strtoupper( sanitize_key( $_GET['order'] ) )
     65            : 'ASC';
     66
     67        $search = ! empty( $_REQUEST['s'] )
     68            ? stripslashes( sanitize_text_field( $_REQUEST['s'] ) )
     69            : '';
     70
    6571        if ( false !== strpos( $search, '*' ) ) {
    6672            $search = trim( $search, '*' );
     
    97103     *
    98104     * @since 1.3.0
     105     * @return void
    99106     */
    100107    public function no_items() {
     
    107114     * @since 1.3.0
    108115     *
    109      * @return array Bulk actions as $slug => $label pairs.
     116     * @return array<string, string> Bulk actions as $slug => $label pairs.
    110117     */
    111118    public function get_bulk_actions() {
     
    124131     * @since 1.3.0
    125132     *
    126      * @param type $which Where to display the pagination. Either 'top' or 'bottom'.
     133     * @param string $which Where to display the pagination. Either 'top' or 'bottom'.
    127134     */
    128135    public function pagination( $which ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
     
    146153     * @since 1.3.0
    147154     *
    148      * @return array Columns as $slug => $label pairs.
     155     * @return array<string, string> Columns as $slug => $label pairs.
    149156     */
    150157    public function get_columns() {
     
    173180     * @since 1.3.0
    174181     *
    175      * @return array Columns as $slug => $orderby_field pairs.
     182     * @return array<string, string> Columns as $slug => $orderby_field pairs.
    176183     */
    177184    public function get_sortable_columns() {
     
    189196     *
    190197     * @param object $network The current network item.
     198     * @return void
    191199     */
    192200    public function single_row( $network ) {
     
    271279     *
    272280     * @param WP_Network $network The current network object.
     281     * @return void
    273282     */
    274283    public function column_cb( $network ) {
     
    280289
    281290        ?>
    282         <label class="screen-reader-text" for="network_<?php echo esc_attr( $network->id ); ?>">
     291        <label class="screen-reader-text" for="network_<?php echo esc_attr( strval( $network->id ) ); ?>">
    283292            <?php
    284293            printf(
     
    289298            ?>
    290299        </label>
    291         <input type="checkbox" id="network_<?php echo esc_attr( $network->id ); ?>" name="all_networks[]" value="<?php echo esc_attr( $network->id ); ?>">
     300        <input type="checkbox" id="network_<?php echo esc_attr( strval( $network->id ) ); ?>" name="all_networks[]" value="<?php echo esc_attr( strval( $network->id ) ); ?>">
    292301        <?php
    293302    }
     
    299308     *
    300309     * @param WP_Network $network The current network object.
     310     * @return void
    301311     */
    302312    public function column_title( $network ) {
     
    327337        <strong>
    328338            <?php
    329             echo $link; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
    330             echo $network_states; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
     339            echo $link; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     340            echo $network_states; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    331341            ?>
    332342        </strong>
     
    341351     *
    342352     * @param WP_Network $network The current network object.
     353     * @return void
    343354     */
    344355    public function column_domain( $network ) {
     
    352363     *
    353364     * @param WP_Network $network The current network object.
     365     * @return void
    354366     */
    355367    public function column_path( $network ) {
     
    363375     *
    364376     * @param WP_Network $network The current network object.
     377     * @return void
    365378     */
    366379    public function column_blogs( $network ) {
     
    380393     *
    381394     * @param WP_Network $network The current network object.
     395     * @return void
    382396     */
    383397    public function column_admins( $network ) {
     
    395409     *
    396410     * @param WP_Network $network The current network object.
     411     * @return void
    397412     */
    398413    public function column_id( $network ) {
    399         echo esc_html( $network->id );
     414        echo esc_html( strval( $network->id ) );
    400415    }
    401416
     
    415430        // Bail if not primary column.
    416431        if ( $primary !== $column_name ) {
    417             return;
     432            return '';
    418433        }
    419434
     
    444459        // Edit the network.
    445460        if ( current_user_can( 'edit_network', $network->id ) ) {
    446             $edit_network_url = add_query_arg(
    447                 array(
    448                     'action' => 'edit_network',
    449                 ),
    450                 $base_url
    451             );
     461            $edit_network_url = add_query_arg( array( 'action' => 'edit_network' ), $base_url );
    452462
    453463            $actions['edit'] = '<span class="edit"><a href="' . esc_url( $edit_network_url ) . '">' . esc_html__( 'Edit', 'wp-multi-network' ) . '</a></span>';
     
    465475        if ( $this->can_delete( $network ) ) {
    466476            $delete_network_url = wp_nonce_url(
    467                 add_query_arg(
    468                     array(
    469                         'action' => 'delete_network',
    470                     ), $base_url
    471                 )
     477                add_query_arg( array( 'action' => 'delete_network' ), $base_url )
    472478            );
    473479
     
    480486         * @since 2.0.0
    481487         *
    482          * @param array  Action links as $slug => $link_markup pairs.
    483          * @param int    The current network ID.
    484          * @param string The current network name.
     488         * @param array  $filtered_acions Action links as $slug => $link_markup pairs.
     489         * @param int    $network_id The current network ID.
     490         * @param string $network_sitename The current network name.
    485491         */
    486         $actions = apply_filters( 'manage_networks_action_links', array_filter( $actions ), $network->id, $network->sitename );
     492        $actions = apply_filters( 'manage_networks_action_links', $actions, $network->id, $network->site_name );
    487493
    488494        // Return all row actions.
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/classes/class-wp-ms-rest-networks-controller.php

    r2584493 r3414829  
    3131     *
    3232     * @since 2.4.0
     33     * @return void
    3334     */
    3435    public function register_routes() {
     
    100101     * @since 2.4.0
    101102     *
    102      * @param WP_REST_Request $request Full details about the request.
     103     * @template T of WP_REST_Request
     104     * @param T $request Full details about the request.
    103105     *
    104106     * @return WP_Error|bool True if the request has read access, error object otherwise.
     
    113115     * @since 2.4.0
    114116     *
    115      * @param WP_REST_Request $request Full details about the request.
     117     * @template T of WP_REST_Request
     118     * @param T $request Full details about the request.
    116119     *
    117120     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    194197        }
    195198
    196         $total_networks = (int) $query->found_networks;
    197         $max_pages      = (int) $query->max_num_pages;
     199        $total_networks = $query->found_networks;
     200        $max_pages      = $query->max_num_pages;
    198201
    199202        if ( $total_networks < 1 ) {
     
    204207            $prepared_args['count'] = true;
    205208
    206             $total_networks = $query->query( $prepared_args );
    207             $max_pages      = ceil( $total_networks / $request['per_page'] );
     209            $total_networks = (int) $query->query( $prepared_args );
     210            $max_pages      = (int) ceil( $total_networks / $request['per_page'] );
    208211        }
    209212
    210213        $response = rest_ensure_response( $networks );
    211         $response->header( 'X-WP-Total', $total_networks );
    212         $response->header( 'X-WP-TotalPages', $max_pages );
     214        $response->header( 'X-WP-Total', strval( $total_networks ) );
     215        $response->header( 'X-WP-TotalPages', strval( $max_pages ) );
    213216
    214217        $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
     
    268271     * @since 2.4.0
    269272     *
    270      * @param WP_REST_Request $request Full details about the request.
     273     * @template T of WP_REST_Request
     274     * @param T $request Full details about the request.
    271275     *
    272276     * @return WP_Error|bool True if the request has read access for the item, error object otherwise.
     
    286290     * @since 2.4.0
    287291     *
    288      * @param WP_REST_Request $request Full details about the request.
     292     * @template T of WP_REST_Request
     293     * @param T $request Full details about the request.
    289294     *
    290295     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    307312     * @since 2.4.0
    308313     *
    309      * @param WP_REST_Request $request Full details about the request.
     314     * @template T of WP_REST_Request
     315     * @param T $request Full details about the request.
    310316     *
    311317     * @return WP_Error|bool True if the request has access to create items, error object otherwise.
     
    320326     * @since 2.4.0
    321327     *
    322      * @param WP_REST_Request $request Full details about the request.
     328     * @template T of WP_REST_Request
     329     * @param T $request Full details about the request.
    323330     *
    324331     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    405412     * @since 2.4.0
    406413     *
    407      * @param WP_REST_Request $request Full details about the request.
     414     * @template T of WP_REST_Request
     415     * @param T $request Full details about the request.
    408416     *
    409417     * @return WP_Error|bool True if the request has access to update the item, error object otherwise.
     
    431439     * @since 2.4.0
    432440     *
    433      * @param WP_REST_Request $request Full details about the request.
     441     * @template T of WP_REST_Request
     442     * @param T $request Full details about the request.
    434443     *
    435444     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    450459
    451460        if ( ! empty( $prepared_args ) ) {
    452             if ( is_wp_error( $prepared_args ) ) {
    453                 return $prepared_args;
    454             }
    455 
    456461            $domain = $prepared_args['domain'];
    457462            $path   = $prepared_args['path'];
     
    493498     * @since 2.4.0
    494499     *
    495      * @param WP_REST_Request $request Full details about the request.
     500     * @template T of WP_REST_Request
     501     * @param T $request Full details about the request.
    496502     *
    497503     * @return WP_Error|bool True if the request has access to delete the item, error object otherwise.
     
    511517     * @since 2.4.0
    512518     *
    513      * @param WP_REST_Request $request Full details about the request.
     519     * @template T of WP_REST_Request
     520     * @param T $request Full details about the request.
    514521     *
    515522     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    564571     * @since 2.4.0
    565572     *
    566      * @param WP_Network      $network Network object.
    567      * @param WP_REST_Request $request Request object.
     573     * @template T of WP_REST_Request
     574     * @param WP_Network $network Network object.
     575     * @param T          $request Request object.
    568576     *
    569577     * @return WP_REST_Response Response object.
     
    609617     * @param WP_Network $network Network object.
    610618     *
    611      * @return array Links for the given network.
     619     * @return array<string, array<string, string>> Links for the given network.
    612620     */
    613621    protected function prepare_links( $network ) {
     
    651659     * @since 2.4.0
    652660     *
    653      * @param WP_REST_Request $request Request object.
    654      *
    655      * @return array|WP_Error Prepared network, otherwise WP_Error object.
     661     * @template T of WP_REST_Request
     662     * @param T $request Request object.
     663     *
     664     * @return array<string, string>|WP_Error Prepared network, otherwise WP_Error object.
    656665     */
    657666    protected function prepare_item_for_database( $request ) {
     
    688697     * @since 2.4.0
    689698     *
    690      * @return array
     699     * @return array<string, mixed>
    691700     */
    692701    public function get_item_schema() {
     
    736745     * @since 2.4.0
    737746     *
    738      * @return array Networks collection parameters.
     747     * @return array<string, mixed> Networks collection parameters.
    739748     */
    740749    public function get_collection_params() {
     
    842851     * @since 2.4.0
    843852     *
    844      * @param WP_Network      $network Network object.
    845      * @param WP_REST_Request $request Request data to check.
     853     * @template T of WP_REST_Request
     854     * @param WP_Network $network Network object.
     855     * @param T          $request Request data to check.
    846856     *
    847857     * @return bool Whether the network can be read.
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/compat.php

    r2584493 r3414829  
    5757     * @param string $path    Site path.
    5858     * @param string $site_id Optional. Site ID, if an existing site. Default 0.
     59     *
    5960     * @return bool True if the site URL is valid, false otherwise.
    6061     */
    61     function wp_validate_site_url( $domain, $path, $site_id = 0 ) {
     62    function wp_validate_site_url( $domain, $path, $site_id = '0' ) {
    6263        global $wpdb;
    6364
     
    6768            return true;
    6869        }
    69         if ( true === $exists ) {
     70
     71        if ( true === (bool) $exists ) {
    7072            return false;
    7173        }
     
    8789        $pieces  = array_filter( array_merge( $domains, $paths ) );
    8890        foreach ( $pieces as $slug ) {
    89 
    90             // Bail if empty.
    91             if ( empty( $slug ) ) {
    92                 return false;
    93             }
    94 
    9591            // Bail if not lowercase or numbers.
    9692            if ( preg_match( '/[^a-z0-9]+/', $slug ) ) {
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/deprecated.php

    r2584493 r3414829  
    3737     * @param string $value   Upload path option value.
    3838     * @param int    $blog_id Site ID.
     39     * @return string
    3940     */
    4041    function wpmn_fix_subsite_upload_path( $value, $blog_id ) {
     
    5556    add_filter( 'blog_option_upload_path', 'wpmn_fix_subsite_upload_path', 10, 2 );
    5657}
    57 
    58 if ( ! function_exists( 'get_network_option' ) ) :
    59     /**
    60      * Gets an option from a given network.
    61      *
    62      * Switches to the specified network internally to operate on it.
    63      *
    64      * @since 1.0.0
    65      * @deprecated
    66      *
    67      * @param int    $network_id ID of network.
    68      * @param string $key        Option key.
    69      * @param mixed  $default    Default value if option doesn't exist.
    70      * @return mixed Value set for the option if it exists, `$default` if it doesn't.
    71      *               `WP_Error` instance if invalid network ID is passed.
    72      */
    73     function get_network_option( $network_id, $key, $default = false ) {
    74         if ( ! switch_to_network( $network_id, true ) ) {
    75             return new WP_Error(
    76                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    77                     'status' => 400,
    78                 )
    79             );
    80         }
    81 
    82         $result = get_site_option( $key, $default );
    83 
    84         restore_current_network();
    85 
    86         return $result;
    87     }
    88 endif;
    89 
    90 if ( ! function_exists( 'add_network_option' ) ) :
    91     /**
    92      * Adds an option from a given network.
    93      *
    94      * Switches to the specified network internally to operate on it.
    95      *
    96      * @since 1.0.0
    97      * @deprecated
    98      *
    99      * @param int    $network_id ID of network.
    100      * @param string $key        Option key.
    101      * @param mixed  $value      Option value, can be anything.
    102      * @return bool|WP_Error True if the option is added, false if not added.
    103      *                       `WP_Error` instance if invalid network ID is passed.
    104      */
    105     function add_network_option( $network_id, $key, $value ) {
    106         if ( ! switch_to_network( $network_id, true ) ) {
    107             return new WP_Error(
    108                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    109                     'status' => 400,
    110                 )
    111             );
    112         }
    113 
    114         $result = add_site_option( $key, $value );
    115 
    116         restore_current_network();
    117 
    118         return $result;
    119     }
    120 endif;
    121 
    122 if ( ! function_exists( 'update_network_option' ) ) :
    123     /**
    124      * Updates an option from a given network.
    125      *
    126      * Switches to the specified network internally to operate on it.
    127      *
    128      * @since 1.0.0
    129      * @deprecated
    130      *
    131      * @param int    $network_id ID of network.
    132      * @param string $key        Option key.
    133      * @param mixed  $value      Option value, can be anything.
    134      * @return bool|WP_Error True if the option is updated, false if not updated.
    135      *                       `WP_Error` instance if invalid network ID is passed.
    136      */
    137     function update_network_option( $network_id, $key, $value ) {
    138         if ( ! switch_to_network( $network_id, true ) ) {
    139             return new WP_Error(
    140                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    141                     'status' => 400,
    142                 )
    143             );
    144         }
    145 
    146         $result = update_site_option( $key, $value );
    147 
    148         restore_current_network();
    149 
    150         return $result;
    151     }
    152 endif;
    153 
    154 if ( ! function_exists( 'delete_network_option' ) ) :
    155     /**
    156      * Deletes an option from a given network.
    157      *
    158      * Switches to the specified network internally to operate on it.
    159      *
    160      * @since 1.0.0
    161      * @deprecated
    162      *
    163      * @param int    $network_id ID of network.
    164      * @param string $key        Option key.
    165      * @return bool|WP_Error True if the option is deleted, false if not deleted.
    166      *                       `WP_Error` instance if invalid network ID is passed.
    167      */
    168     function delete_network_option( $network_id, $key ) {
    169         if ( ! switch_to_network( $network_id, true ) ) {
    170             return new WP_Error(
    171                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    172                     'status' => 400,
    173                 )
    174             );
    175         }
    176 
    177         $result = delete_site_option( $key );
    178 
    179         restore_current_network();
    180 
    181         return $result;
    182     }
    183 endif;
    184 
    185 if ( ! function_exists( 'get_networks' ) ) :
    186     /**
    187      * Gets all networks.
    188      *
    189      * @since 1.0.0
    190      * @deprecated
    191      *
    192      * @param array $args Optional. Network query arguments. Default empty array.
    193      * @return array Networks available on the installation.
    194      */
    195     function get_networks( $args = array() ) {
    196 
    197         // Support for WordPress 4.6.0, if you're doing something really weird.
    198         if ( class_exists( 'WP_Network_Query' ) ) {
    199             $query = new WP_Network_Query();
    200 
    201             return $query->query( $args );
    202         }
    203 
    204         // The original get_networks() function.
    205         return $GLOBALS['wpdb']->get_results( "SELECT * FROM {$GLOBALS['wpdb']->site}" );
    206     }
    207 endif;
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/functions.php

    r2788090 r3414829  
    5555     *
    5656     * @param int $user_id Optional. User ID. Default is the current user.
    57      * @return array|bool Array of network IDs, or false if none.
     57     * @return int[]|bool Array of network IDs, or false if none.
    5858     */
    5959    function user_has_networks( $user_id = 0 ) {
     
    7575         * @since 2.0.0
    7676         *
    77          * @param array|bool|null List of network IDs or false. Anything but null will short-circuit
    78          *                        the process.
    79          * @param int             User ID for which the networks should be returned.
     77         * @param array|bool|null $my_networks List of network IDs or false. Anything but null will short-circuit
     78         *                                     the process.
     79         * @param int             $user_id User ID for which the networks should be returned.
    8080         */
    8181        $my_networks = apply_filters( 'networks_pre_user_is_network_admin', null, $user_id );
     
    9090             * @since 2.0.0
    9191             *
    92              * @param array|bool List of network IDs or false if no networks for the user.
    93              * @param int        User ID for which the networks should be returned.
     92             * @param array|bool $my_networks List of network IDs or false if no networks for the user.
     93             * @param int        $user_id User ID for which the networks should be returned.
    9494             */
    9595            return apply_filters( 'networks_user_is_network_admin', $my_networks, $user_id );
     
    121121     *
    122122     * @param int|WP_Network $network Optional. Network ID or object. Default is the current network.
    123      * @return int Main site ID for the network.
     123     * @return int|bool Main site ID for the network or false if network not found.
    124124     */
    125125    function get_main_site_for_network( $network = null ) {
     
    219219        global $wpdb, $switched_network, $switched_network_stack, $current_site;
    220220
    221         if ( empty( $new_network ) ) {
     221        // Maybe fallback to current network.
     222        if ( empty( $new_network ) || ! is_numeric( $new_network ) ) {
    222223            $new_network = $current_site->id;
    223224        }
     
    250251        }
    251252
    252         $prev_site_id = $current_site->id;
    253         $current_site = get_network( $new_network ); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
     253        $prev_site_id    = $current_site->id;
     254        $new_network_obj = get_network( $new_network );
     255        $current_site    = $new_network_obj; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
    254256
    255257        // Populate extra properties if not set already.
     
    413415     * @global wpdb $wpdb WordPress database abstraction object.
    414416     *
    415      * @param array $args  {
     417     * @param array<string, mixed> $args  {
    416418     *     Array of network arguments.
    417419     *
     
    577579        }
    578580
     581        /**
     582         * Fires after a new network blog has been added.
     583         *
     584         * @param int $new_blog_id ID of the added network blog.
     585         * @param int $new_network_id ID of the added network.
     586         * @param array $r Full associative array of network arguments.
     587         *
     588         * @since 2.5.3
     589         */
     590        do_action( 'added_network_blog', $new_blog_id, $new_network_id, $r );
     591
     592        // add new blog id as network meta data against the new network.
    579593        $r['network_meta']['main_site'] = $new_blog_id;
    580594
     
    601615            $current_siteurl = get_option( 'siteurl' );
    602616            $new_siteurl     = untrailingslashit( get_blogaddress_by_id( $new_blog_id ) );
    603             $upload_url      = str_replace( $current_siteurl, $new_siteurl, WP_CONTENT_URL );
     617            $upload_url      = str_replace( $current_siteurl, $new_siteurl, content_url() );
    604618            $upload_url      = $upload_url . '/uploads';
    605 
    606             $upload_dir = WP_CONTENT_DIR;
    607             if ( 0 === strpos( $upload_dir, ABSPATH ) ) {
    608                 $upload_dir = substr( $upload_dir, strlen( ABSPATH ) );
     619            $upload_dir      = WP_CONTENT_DIR;
     620            $needle          = strval( ABSPATH );
     621            if ( 0 === strpos( $upload_dir, $needle ) ) {
     622                $upload_dir = substr( $upload_dir, strlen( $needle ) );
    609623            }
    610624            $upload_dir .= '/uploads';
    611625
    612             if ( defined( 'MULTISITE' ) ) {
    613                 $ms_dir = '/sites/' . $new_blog_id;
    614             } else {
    615                 $ms_dir = '/' . $new_blog_id;
     626            // Check if wpmu_create_blog() already set the site-specific path.
     627            $existing_upload_path = get_blog_option( $new_blog_id, 'upload_path' );
     628            $site_path_suffix     = defined( 'MULTISITE' ) ? '/sites/' . $new_blog_id : '/' . $new_blog_id;
     629
     630            // Only add the site-specific path if it's not already present.
     631            if ( empty( $existing_upload_path ) || false === strpos( $existing_upload_path, $site_path_suffix ) ) {
     632                $upload_dir .= $site_path_suffix;
     633                $upload_url .= $site_path_suffix;
     634                update_blog_option( $new_blog_id, 'upload_path', $upload_dir );
     635                update_blog_option( $new_blog_id, 'upload_url_path', $upload_url );
    616636            }
    617 
    618             $upload_dir .= $ms_dir;
    619             $upload_url .= $ms_dir;
    620 
    621             update_blog_option( $new_blog_id, 'upload_path', $upload_dir );
    622             update_blog_option( $new_blog_id, 'upload_url_path', $upload_url );
    623637        }
    624638
     
    664678        clean_network_cache( $new_network_id );
    665679
     680        // Self-activate on new network.
     681        $existing_plugins = get_network_option( $new_network_id, 'active_sitewide_plugins', array() );
     682        if ( ! isset( $existing_plugins['wp-multi-network/wpmn-loader.php'] ) ) {
     683            $existing_plugins['wp-multi-network/wpmn-loader.php'] = time();
     684            update_network_option( $new_network_id, 'active_sitewide_plugins', $existing_plugins );
     685        }
     686
    666687        /**
    667688         * Fires after a new network has been added.
     
    706727
    707728        // Bail if site URL is invalid.
    708         if ( ! wp_validate_site_url( $domain, $path, $site_id ) ) {
     729        if ( ! wp_validate_site_url( $domain, $path, strval( $site_id ) ) ) {
    709730            /* translators: %s: site domain and path */
    710731            return new WP_Error( 'blog_bad', sprintf( __( 'The site "%s" is invalid, not available, or already exists.', 'wp-multi-network' ), $domain . $path ) );
     
    830851            }
    831852
    832             if ( true === $delete_blogs ) {
    833                 foreach ( $sites as $site ) {
    834                     if ( wp_should_rescue_orphaned_sites() ) {
    835                         move_site( $site->id, 0 );
    836                         continue;
    837                     }
    838 
    839                     wpmu_delete_blog( $site->id, true );
     853            foreach ( $sites as $site ) {
     854                if ( wp_should_rescue_orphaned_sites() ) {
     855                    move_site( $site->id, 0 );
     856                    continue;
    840857                }
     858
     859                wpmu_delete_blog( $site->id, true );
    841860            }
    842861        }
     
    961980     * @since 1.3.0
    962981     *
    963      * @return array List of network option names.
     982     * @return string[] List of network option names.
    964983     */
    965984    function network_options_list() {
     
    9861005     * @since 1.3.0
    9871006     *
    988      * @return array List of network $option_name => $option_label pairs.
     1007     * @return array<string, string> List of network $option_name => $option_label pairs.
    9891008     */
    9901009    function network_options_to_copy() {
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/metaboxes/edit-network.php

    r2588851 r3414829  
    1616 *
    1717 * @param WP_Network $network Optional. Network object. Default null.
     18 * @return void
    1819 */
    1920function wpmn_edit_network_details_metabox( $network = null ) {
    20     $domain = ! empty( $network->domain ) ? Requests_IDNAEncoder::encode( $network->domain ) : '';
    21     $path   = ! empty( $network->path ) ? $network->path : '/';
     21
     22    $domain = ! empty( $network->domain )
     23        ? $network->domain
     24        : '';
     25
     26    $path = ! empty( $network->path )
     27        ? $network->path
     28        : '/';
    2229
    2330    ?>
    2431
    2532    <table class="edit-network form-table">
     33        <?php do_action( 'wpmn_edit_network_details_metabox_before_group', $network ); ?>
     34
    2635        <tr class="form-field form-required">
    2736            <th scope="row">
     
    4453            </td>
    4554        </tr>
     55
     56        <?php do_action( 'wpmn_edit_network_details_metabox_after_group', $network ); ?>
    4657    </table>
    4758
     
    5364 *
    5465 * @since 1.7.0
     66 * @return void
    5567 */
    5668function wpmn_edit_network_new_site_metabox() {
     
    5870
    5971    <table class="edit-network form-table">
     72        <?php do_action( 'wpmn_edit_network_new_site_metabox_before_group' ); ?>
     73
    6074        <tr class="form-field form-required">
    6175            <th scope="row">
     
    6781            </td>
    6882        </tr>
     83
     84        <?php do_action( 'wpmn_edit_network_new_site_metabox_after_group' ); ?>
    6985    </table>
    7086
     
    7894 *
    7995 * @param WP_Network $network Optional. Network object. Default null.
     96 * @return void
    8097 */
    8198function wpmn_edit_network_assign_sites_metabox( $network = null ) {
    8299    $to = get_sites(
    83100        array(
    84             'site__not_in' => get_main_site_id( $network->id ),
     101            'site__not_in' => array( get_main_site_id( $network->id ) ),
    85102            'network_id'   => $network->id,
    86103        )
     
    111128                        <?php if ( ( (int) $site->network_id !== (int) $network->id ) && ! is_main_site_for_network( $site->id ) ) : ?>
    112129
    113                             <option value="<?php echo esc_attr( $site->id ); ?>">
    114                                 <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->name, $site->domain, $site->path ) ); ?>
     130                            <option value="<?php echo esc_attr( strval( $site->id ) ); ?>">
     131                                <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->blogname, $site->domain, $site->path ) ); ?>
    115132                            </option>
    116133
     
    132149                        <?php if ( (int) $site->network_id === (int) $network->id ) : ?>
    133150
    134                             <option value="<?php echo esc_attr( $site->id ); ?>" <?php disabled( is_main_site_for_network( $site->id ) ); ?>>
    135                                 <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->name, $site->domain, $site->path ) ); ?>
     151                            <option value="<?php echo esc_attr( strval( $site->id ) ); ?>" <?php disabled( is_main_site_for_network( $site->id ) ); ?>>
     152                                <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->blogname, $site->domain, $site->path ) ); ?>
    136153                            </option>
    137154
     
    154171 *
    155172 * @param WP_Network $network Optional. Network object. Default null.
     173 * @return void
    156174 */
    157175function wpmn_edit_network_publish_metabox( $network = null ) {
     
    234252                ?>
    235253                <input type="hidden" name="action" value="<?php echo esc_attr( $action ); ?>">
    236                 <input type="hidden" name="network_id" value="<?php echo esc_attr( $network_id ); ?>">
     254                <input type="hidden" name="network_id" value="<?php echo esc_attr( strval( $network_id ) ); ?>">
    237255            </div>
    238256            <div class="clear"></div>
  • wp-multi-network/tags/3.0.0/wp-multi-network/includes/metaboxes/move-site.php

    r2588851 r3414829  
    1616 *
    1717 * @param WP_Site $site Optional. Site object. Default null.
     18 * @return void
    1819 */
    1920function wpmn_move_site_list_metabox( $site = null ) {
     
    7879 *
    7980 * @param WP_Site $site Optional. Site object. Default null.
     81 * @return void
    8082 */
    8183function wpmn_move_site_assign_metabox( $site = null ) {
     
    139141                ?>
    140142                <input type="hidden" name="action" value="move">
    141                 <input type="hidden" name="from" value="<?php echo esc_attr( $site->network_id ); ?>">
     143                <input type="hidden" name="from" value="<?php echo esc_attr( strval( $site->network_id ) ); ?>">
    142144            </div>
    143145            <div class="clear"></div>
  • wp-multi-network/tags/3.0.0/wpmn-loader.php

    r2788090 r3414829  
    1616 * Text Domain:       wp-multi-network
    1717 * Network:           true
    18  * Requires at least: 4.9
    19  * Requires PHP:      5.2
    20  * Tested up to:      6.1
     18 * Requires at least: 5.5
     19 * Requires PHP:      7.2
     20 * Tested up to:      7.0
    2121 * Version:           2.5.2
    2222 */
     
    7070     * @var string
    7171     */
    72     public $asset_version = 202108250001;
     72    public $asset_version = '202108250001';
    7373
    7474    /**
     
    111111     *
    112112     * @since 1.3.0
     113     * @return void
    113114     */
    114115    private function constants() {
     
    126127     *
    127128     * @since 1.3.0
     129     * @return void
    128130     */
    129131    private function setup_globals() {
     
    138140     *
    139141     * @since 1.3.0
     142     * @return void
    140143     */
    141144    private function includes() {
     
    166169
    167170        $this->admin_bar = new WP_MS_Networks_Admin_Bar();
     171        $this->admin_bar->add_hooks();
    168172
    169173        if ( defined( 'WPMN_DEPRECATED' ) && ( true === WPMN_DEPRECATED ) ) {
     
    186190 *
    187191 * @since 1.3.0
    188  */
    189 function setup_multi_network() {
     192 * @return void
     193 */
     194function setup_multi_network() { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
    190195    wpmn();
    191196}
     
    196201 *
    197202 * @since 2.3.0
     203 * @return void
    198204 */
    199205function setup_multi_network_endpoints() {
     
    209215 *
    210216 * @since 1.7.0
    211  *
    212217 * @return WPMN_Loader WP Multi Network instance to use.
    213218 */
  • wp-multi-network/trunk/readme.txt

    r2788090 r3414829  
    22Author:            Triple J Software, Inc.
    33Author URI:        https://jjj.software
    4 Donate link:       https://buy.stripe.com/7sI3cd2tK1Cy2lydQR
    54Plugin URI:        https://wordpress.org/plugins/wp-multi-network/
    65License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    98Tags:              network, sites, domains, global, admin
    109Requires PHP:      5.2
    11 Requires at least: 4.9
    12 Tested up to:      6.1
     10Requires at least: 5.5
     11Tested up to:      7.0
    1312Stable tag:        2.5.2
    1413
     
    123122
    124123== Changelog ==
     124
     125= 2.5.3 =
     126* Remove filter_input usages
     127
    125128= 2.5.2 =
    126129* Use get_main_site_id function instead of get_main_site_for_network.
     
    128131
    129132= 2.5.1 =
    130 * Save main site on network as network option. 
     133* Save main site on network as network option.
    131134
    132135= 2.5.0 =
  • wp-multi-network/trunk/wp-multi-network/assets/js/wp-multi-network.js

    r2584493 r3414829  
    1 jQuery( document ).ready(
    2     function ( $ ) {
     1/**
     2 * WP Multi Network Admin Script
     3 */
    34
    4             $( '.if-js-closed' )
    5             .removeClass( 'if-js-closed' )
    6             .addClass( 'closed' );
    75
    8             $( '.postbox' ).children( 'h3' ).click(
    9                 function () {
    10                     if ( $( this.parentNode ).hasClass( 'closed' ) ) {
    11                         $( this.parentNode ).removeClass( 'closed' );
    12                     } else {
    13                         $( this.parentNode ).addClass( 'closed' );
    14                     }
    15                 }
    16             );
     6jQuery( document ).ready( function ( $ ) {
     7    $( '.if-js-closed' ).removeClass( 'if-js-closed' ).addClass( 'closed' );
    178
    18             /* Handle clicks to add/remove sites to/from selected list */
    19             $( 'input[name=assign]' ).click(
    20                 function () {
    21                     move( 'from', 'to' );
    22                 }
    23             );
     9    $( '.postbox' )
     10        .children( 'h3' )
     11        .click( function () {
     12            if ( $( this.parentNode ).hasClass( 'closed' ) ) {
     13                $( this.parentNode ).removeClass( 'closed' );
     14            } else {
     15                $( this.parentNode ).addClass( 'closed' );
     16            }
     17        } );
    2418
    25             $( 'input[name=unassign]' ).click(
    26                 function () {
    27                     move( 'to', 'from' );
    28                 }
    29             );
     19    /* Handle clicks to add/remove sites to/from selected list */
     20    $( 'input[name=assign]' ).click( function () {
     21        move( 'from', 'to' );
     22    } );
    3023
    31             /* Select all sites in "selected" box when submitting */
    32             $( '#edit-network-form' ).submit(
    33                 function () {
    34                     $( '#to' ).children( 'option:enabled' ).attr( 'selected', true );
    35                     $( '#from' ).children( 'option:enabled' ).attr( 'selected', true );
    36                 }
    37             );
     24    $( 'input[name=unassign]' ).click( function () {
     25        move( 'to', 'from' );
     26    } );
    3827
    39         function move( from, to ) {
    40             jQuery( '#' + from ).children( 'option:selected' ).each(
    41                 function () {
    42                     jQuery( '#' + to ).append( jQuery( this ).clone() );
    43                     jQuery( this ).remove();
    44                 }
    45             );
    46         }
     28    /* Select all sites in "selected" box when submitting */
     29    $( '#edit-network-form' ).submit( function () {
     30        $( '#to' ).children( 'option:enabled' ).attr( 'selected', true );
     31        $( '#from' ).children( 'option:enabled' ).attr( 'selected', true );
     32    } );
     33
     34    function move( from, to ) {
     35        jQuery( '#' + from )
     36            .children( 'option:selected' )
     37            .each( function () {
     38                jQuery( '#' + to ).append( jQuery( this ).clone() );
     39                jQuery( this ).remove();
     40            } );
    4741    }
    48 );
     42} );
  • wp-multi-network/trunk/wp-multi-network/includes/classes/class-wp-ms-network-command.php

    r2584493 r3414829  
    1212 * @since 1.3.0
    1313 */
    14 class WP_MS_Network_Command extends WP_CLI_Command {
     14class WP_MS_Network_Command {
    1515
    1616    /**
     
    1818     *
    1919     * @since 1.3.0
    20      * @var array
     20     * @var string[]
    2121     */
    2222    protected $obj_fields = array(
     
    5555     * @since 1.3.0
    5656     *
    57      * @param array $args       Positional CLI arguments.
    58      * @param array $assoc_args Associative CLI arguments.
     57     * @param string[]             $args Positional CLI arguments.
     58     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     59     * @return void
    5960     */
    6061    public function create( $args, $assoc_args ) {
    61         list( $domain, $path ) = $args;
     62        [ $domain, $path ] = $args;
    6263
    6364        $assoc_args = wp_parse_args(
     
    7576            $user  = $users->get( $assoc_args['network_admin'] );
    7677            if ( ! $user ) {
    77                 return new WP_Error( 'network_super_admin', 'Super user does not exist.' );
     78                WP_CLI::error( 'Super user does not exist.' );
    7879            }
    7980            $network_admin_id = $user->ID;
     
    8283        }
    8384
    84         $clone_network    = $assoc_args['clone_network'];
    85         $options_to_clone = false;
    86 
    87         if ( ! empty( $clone_network ) && ! get_network( $clone_network ) ) {
     85        $clone_network = $assoc_args['clone_network'];
     86
     87        if ( ! empty( $clone_network ) && is_numeric( $clone_network ) && ! get_network( $clone_network ) ) {
    8888            WP_CLI::error( sprintf( "Clone network %s doesn't exist.", $clone_network ) );
    89 
    90             if ( ! empty( $assoc_args['options_to_clone'] ) ) {
    91                 $options_to_clone = explode( ',', $assoc_args['options_to_clone'] );
    92             }
    9389        }
    9490
     
    10298                'network_admin_id' => $network_admin_id,
    10399                'clone_network'    => $clone_network,
    104                 'options_to_clone' => $options_to_clone,
     100                'options_to_clone' => $assoc_args['options_to_clone'],
    105101            )
    106102        );
     
    127123     * @since 1.3.0
    128124     *
    129      * @param array $args       Positional CLI arguments.
    130      * @param array $assoc_args Associative CLI arguments.
     125     * @param string[]             $args Positional CLI arguments.
     126     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     127     * @return void
    131128     */
    132129    public function update( $args, $assoc_args ) {
    133         list( $id, $domain ) = $args;
     130        [ $id, $domain ] = $args;
    134131
    135132        $defaults   = array(
     
    138135        $assoc_args = wp_parse_args( $assoc_args, $defaults );
    139136
    140         $network_id = update_network( $id, $domain, $assoc_args['path'] );
     137        $network_id = update_network( (int) $id, $domain, $assoc_args['path'] );
    141138
    142139        if ( is_wp_error( $network_id ) ) {
     
    158155     * @since 1.3.0
    159156     *
    160      * @param array $args       Positional CLI arguments.
    161      * @param array $assoc_args Associative CLI arguments.
     157     * @param string[]             $args Positional CLI arguments.
     158     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     159     * @return void
    162160     */
    163161    public function delete( $args, $assoc_args ) {
    164         list( $id ) = $args;
     162        [ $id ] = $args;
    165163
    166164        $assoc_args = wp_parse_args(
     
    170168        );
    171169
    172         $network_id = delete_network( $id, $assoc_args['delete_blogs'] );
     170        $network_id = delete_network( (int) $id, $assoc_args['delete_blogs'] );
    173171
    174172        if ( is_wp_error( $network_id ) ) {
     
    192190     * @since 1.3.0
    193191     *
    194      * @param array $args       Positional CLI arguments.
    195      * @param array $assoc_args Associative CLI arguments.
    196      */
    197     public function move_site( $args, $assoc_args ) {
    198         list( $site_id, $new_network_id ) = $args;
    199 
    200         $network_id = move_site( $site_id, $new_network_id );
     192     * @param string[]             $args Positional CLI arguments.
     193     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     194     * @return void
     195     */
     196    public function move_site( $args, $assoc_args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
     197        [ $site_id, $new_network_id ] = $args;
     198
     199        $network_id = move_site( (int) $site_id, (int) $new_network_id );
    201200
    202201        if ( is_wp_error( $network_id ) ) {
     
    228227     * @since 1.3.0
    229228     *
    230      * @param array $args       Positional CLI arguments.
    231      * @param array $assoc_args Associative CLI arguments.
     229     * @param string[]             $args Positional CLI arguments.
     230     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     231     * @return void
    232232     */
    233233    public function list_( $args, $assoc_args ) {
     
    257257     * @since 1.3.0
    258258     *
    259      * @param array $args       Positional CLI arguments.
    260      * @param array $assoc_args Associative CLI arguments.
     259     * @param string[]             $args Positional CLI arguments.
     260     * @param array<string, mixed> $assoc_args Associative CLI arguments.
     261     * @return void
    261262     */
    262263    public function plugin( $args, $assoc_args ) {
    263         $this->fetcher = new \WP_CLI\Fetchers\Plugin();
    264         $action        = array_shift( $args );
     264        $fetchers_plugin = new \WP_CLI\Fetchers\Plugin();
     265        $action          = array_shift( $args );
     266
    265267        if ( ! in_array( $action, array( 'activate', 'deactivate' ), true ) ) {
    266268            WP_CLI::error( sprintf( '%s is not a supported action.', $action ) );
    267269        }
     270
    268271        $network_wide = \WP_CLI\Utils\get_flag_value( $assoc_args, 'network' );
    269272        $all          = \WP_CLI\Utils\get_flag_value( $assoc_args, 'all', false );
     
    281284                $args = array_map(
    282285                    function ( $file ) {
    283                             return \WP_CLI\Utils\get_plugin_name( $file );
     286                        return \WP_CLI\Utils\get_plugin_name( $file );
    284287                    }, array_keys( get_plugins() )
    285288                );
    286289            }
    287             foreach ( $this->fetcher->get_many( $args ) as $plugin ) {
     290            foreach ( $fetchers_plugin->get_many( $args ) as $plugin ) {
    288291                $status = $this->get_status( $plugin->file );
    289292                if ( $all && in_array( $status, array( 'active', 'active-network' ), true ) ) {
    290                     $needing_activation --;
     293                    --$needing_activation;
    291294                    continue;
    292295                }
     
    311314                    activate_plugins( $plugin->file, '', $network_wide );
    312315                } else {
    313                     deactivate_plugins( $plugin->file, '', $network_wide );
     316                    deactivate_plugins( $plugin->file, false, $network_wide );
    314317                }
    315318
     
    327330     * @since 1.3.0
    328331     *
    329      * @param array $assoc_args Associative CLI arguments. Passed by reference.
     332     * @param array<string, mixed> $assoc_args Associative CLI arguments. Passed by reference.
    330333     * @return WP_CLI\Formatter WP-CLI formatter instance.
    331334     */
     
    378381     * @param bool   $network_wide Whether to check network-wide or not.
    379382     * @param string $action       Action performed.
     383     * @return void
    380384     */
    381385    private function active_output( $name, $file, $network_wide, $action ) {
  • wp-multi-network/trunk/wp-multi-network/includes/classes/class-wp-ms-networks-admin-bar.php

    r2584493 r3414829  
    1818
    1919    /**
    20      * Constructor.
     20     * Registers WordPress hooks for the plugin.
    2121     *
    22      * Hooks in the necessary methods.
     22     * Adds actions to:
     23     * - Modify the admin bar menu
     24     * - Add custom styles to the admin area
     25     * - Add custom styles to the front-end
    2326     *
    24      * @since 2.2.0
     27     * @return void
    2528     */
    26     public function __construct() {
     29    public function add_hooks(): void {
    2730        add_action( 'admin_bar_menu', array( $this, 'admin_bar' ), 20 );
    28 
    2931        add_action( 'admin_print_styles', array( $this, 'admin_print_styles' ) );
    3032        add_action( 'wp_print_styles', array( $this, 'admin_print_styles' ) );
     
    3840     *
    3941     * @since 2.2.0
     42     * @since 3.0.0 Prevent rendering of CSS if admin bar is not shown.
     43     * @return void
    4044     */
    4145    public function admin_print_styles() {
     46        if ( ! is_admin_bar_showing() ) {
     47            return;
     48        }
    4249        ?>
    4350        <style type="text/css">
     
    5663     *
    5764     * @param WP_Admin_Bar $wp_admin_bar Admin bar instance.
     65     * @return void
    5866     */
    5967    public function admin_bar( $wp_admin_bar ) {
  • wp-multi-network/trunk/wp-multi-network/includes/classes/class-wp-ms-networks-admin.php

    r2588851 r3414829  
    2121     *
    2222     * @since 2.0.0
    23      * @var array
     23     * @var array<string, array<int, string>>
    2424     */
    2525    private $feedback_strings = array();
     
    3333     */
    3434    public function __construct() {
    35         $this->set_feedback_strings();
    36 
    3735        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    3836        add_action( 'network_admin_menu', array( $this, 'network_admin_menu' ) );
     
    4139        add_action( 'admin_init', array( $this, 'route_save_handlers' ) );
    4240
     41        add_action( 'admin_init', array( $this, 'set_feedback_strings' ) );
    4342        add_action( 'network_admin_notices', array( $this, 'network_admin_notices' ) );
    4443
     
    5352     * @since 1.3.0
    5453     *
    55      * @param array $actions Array of action links.
    56      * @param int   $blog_id Current site ID.
    57      * @return array Adjusted action links.
     54     * @param array<string, string> $actions Array of action links.
     55     * @param int                   $blog_id Current site ID.
     56     * @return array<string, string> Adjusted action links.
    5857     */
    5958    public function add_move_blog_link( $actions = array(), $blog_id = 0 ) {
     
    8584     *
    8685     * @since 1.3.0
     86     * @return void
    8787     */
    8888    public function admin_menu() {
     
    103103     *
    104104     * @since 1.3.0
     105     * @return void
    105106     */
    106107    public function network_admin_menu() {
     
    120121     *
    121122     * @since 1.5.2
     123     * @return void
    122124     */
    123125    public function network_admin_menu_separator() {
     
    133135     * @global string $plugin_page
    134136     * @global string $submenu_file
     137     * @return void
    135138     */
    136139    public function fix_menu_highlight_for_move_page() {
     
    138141
    139142        if ( 'networks' === $plugin_page ) {
    140             $action = filter_input( INPUT_GET, 'action' );
     143            // phpcs:disable WordPress.Security.NonceVerification.Recommended
     144            $action = ! empty( $_GET['action'] )
     145                ? sanitize_key( $_GET['action'] )
     146                : '';
     147            // phpcs:enable
     148
    141149            if ( 'move' === $action ) {
    142150                $submenu_file = 'sites.php'; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
     
    151159     *
    152160     * @param string $page Optional. Current page hook. Default empty string.
     161     * @return void
    153162     */
    154163    public function enqueue_scripts( $page = '' ) {
     
    159168        }
    160169
    161         wp_register_style( 'wp-multi-network', wpmn()->plugin_url . 'assets/css/wp-multi-network.css', array(), wpmn()->asset_version, false );
    162         wp_register_script( 'wp-multi-network', wpmn()->plugin_url . 'assets/js/wp-multi-network.js', array( 'jquery', 'post' ), wpmn()->asset_version, true );
     170        // Determine if we should load source or minified assets based on WP_SCRIPT_DEBUG.
     171        $suffix        = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? '' : '.min';
     172        $asset_version = ( defined( 'WP_SCRIPT_DEBUG' ) && WP_SCRIPT_DEBUG ) ? time() : wpmn()->asset_version;
     173
     174        wp_register_style( 'wp-multi-network', wpmn()->plugin_url . 'assets/css/wp-multi-network' . $suffix . '.css', array(), $asset_version );
     175        wp_register_script( 'wp-multi-network', wpmn()->plugin_url . 'assets/js/wp-multi-network' . $suffix . '.js', array( 'jquery', 'post' ), $asset_version, true );
    163176
    164177        wp_enqueue_style( 'wp-multi-network' );
     
    170183     *
    171184     * @since 2.1.0
    172      */
    173     private function set_feedback_strings() {
     185     * @return void
     186     */
     187    public function set_feedback_strings() {
    174188        $this->feedback_strings = array(
    175189            'network_updated' => array(
     
    195209     * Prints feedback notices for network admin actions as necessary.
    196210     *
     211     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     212     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     213     *
    197214     * @since 1.3.0
     215     * @return void
    198216     */
    199217    public function network_admin_notices() {
    200218        $message = '';
    201219        $type    = '';
     220
    202221        foreach ( $this->feedback_strings as $slug => $messages ) {
    203             $passed = filter_input( INPUT_GET, $slug );
    204 
    205             if ( is_string( $passed ) ) {
    206                 if ( '1' === $passed ) {
    207                     $message = $messages['1'];
    208                     $type    = 'updated';
    209                 } else {
    210                     $message = $messages['0'];
    211                     $type    = 'error';
    212                 }
    213 
    214                 break;
     222
     223            // Skip if not known feedback.
     224            if ( ! isset( $_GET[ $slug ] ) || ! is_scalar( $_GET[ $slug ] ) ) {
     225                continue;
    215226            }
    216         }
    217 
     227
     228            // Pass/Fail.
     229            $passed = sanitize_key( $_GET[ $slug ] );
     230
     231            if ( '1' === $passed ) {
     232                // Pass.
     233                $message = $messages['1'];
     234                $type    = 'updated';
     235            } else {
     236                // Fail.
     237                $message = $messages['0'];
     238                $type    = 'error';
     239            }
     240
     241            // Done.
     242            break;
     243        }
     244
     245        // Bail if no message or type.
    218246        if ( empty( $message ) || empty( $type ) ) {
    219247            return;
     
    234262     * Routes the current request to the correct page.
    235263     *
    236      * @since 2.0.0
     264     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     265     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     266     *
     267     * @since 2.0.0
     268     * @return void
    237269     */
    238270    public function route_pages() {
     
    243275        }
    244276
    245         $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING );
    246         $action = sanitize_key( $action );
     277        $action = ! empty( $_GET['action'] )
     278            ? sanitize_key( $_GET['action'] )
     279            : '';
    247280
    248281        switch ( $action ) {
     
    265298            // View the list of networks, with bulk action handling.
    266299            case 'all_networks':
    267                 $doaction = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING );
    268                 if ( empty( $doaction ) || '-1' === $doaction ) {
    269                     $doaction = filter_input( INPUT_POST, 'action2', FILTER_SANITIZE_STRING );
     300                $doaction = ! empty( $_POST['action'] )
     301                    ? sanitize_key( $_POST['action'] )
     302                    : '';
     303
     304                if (
     305                    empty( $doaction )
     306                    ||
     307                    ( '-1' === $doaction )
     308                ) {
     309                    $doaction = ! empty( $_POST['action2'] )
     310                        ? sanitize_key( $_POST['action2'] )
     311                        : '';
    270312                }
    271                 $doaction = sanitize_key( $doaction );
    272313
    273314                switch ( $doaction ) {
     
    291332     * Handles network management form submissions.
    292333     *
    293      * @since 2.0.0
     334     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     335     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     336     *
     337     * @since 2.0.0
     338     * @return void
    294339     */
    295340    public function route_save_handlers() {
     
    301346        }
    302347
    303         $action = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING );
     348        $action = ! empty( $_POST['action'] )
     349            ? sanitize_key( $_POST['action'] )
     350            : '';
     351
    304352        if ( empty( $action ) ) {
    305353            $alternative_actions = array( 'delete', 'delete_multiple', 'move' );
     354
    306355            foreach ( $alternative_actions as $alternative_action ) {
    307                 if ( filter_input( INPUT_POST, $alternative_action ) ) {
     356                if ( ! empty( $_POST[ $alternative_action ] ) ) {
    308357                    $action = $alternative_action;
    309358                    break;
     
    350399     * Renders the new network creation dashboard page.
    351400     *
    352      * @since 2.0.0
     401     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     402     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     403     *
     404     * @since 2.0.0
     405     * @return void
    353406     */
    354407    public function page_edit_network() {
    355         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
    356         $network    = $network_id ? get_network( $network_id ) : null;
     408
     409        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     410            ? (int) $_GET['id']
     411            : 0;
     412
     413        $network = ! empty( $network_id )
     414            ? get_network( $network_id )
     415            : null;
    357416
    358417        add_meta_box( 'wpmn-edit-network-details', esc_html__( 'Details', 'wp-multi-network' ), 'wpmn_edit_network_details_metabox', get_current_screen()->id, 'normal', 'high', array( $network ) );
     
    392451            <hr class="wp-header-end">
    393452
    394             <form method="post" id="edit-network-form" action="">
     453            <form method="post" action="" id="edit-network-form">
    395454                <div id="poststuff" class="poststuff">
    396455                    <div id="post-body" class="metabox-holder columns-2">
     
    398457                            <div id="titlediv">
    399458                                <div id="titlewrap">
    400                                     <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo esc_html_e( 'Enter network title here', 'wp-multi-network' ); ?></label>
     459                                    <label class="screen-reader-text" id="title-prompt-text" for="title"><?php esc_html_e( 'Enter network title here', 'wp-multi-network' ); ?></label>
    401460                                    <input type="text" name="title" size="30" id="title" spellcheck="true" autocomplete="off" value="<?php echo esc_attr( $network_title ); ?>">
    402461                                </div>
     
    423482     * Renders the network listing dashboard page.
    424483     *
     484     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     485     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     486     *
    425487     * @since 2.0.0
    426488     *
    427489     * @uses WP_MS_Networks_List_Table List_Table iterator for networks
     490     * @return void
    428491     */
    429492    private function page_all_networks() {
     
    435498        $search_url       = $this->admin_url( array( 'action' => 'domains' ) );
    436499
    437         $search_text = filter_input( INPUT_POST, 's', FILTER_SANITIZE_STRING );
     500        $search_text = ! empty( $_POST['s'] )
     501            ? stripslashes( trim( sanitize_text_field( $_POST['s'] ) ) )
     502            : '';
     503
    438504        ?>
    439505
     
    463529            </form>
    464530
    465             <form method="post" id="form-domain-list" action="<?php echo esc_url( $all_networks_url ); ?>">
     531            <form method="post" action="<?php echo esc_url( $all_networks_url ); ?>" id="form-domain-list">
    466532                <?php $wp_list_table->display(); ?>
    467533            </form>
     
    474540     * Renders the dashboard screen for moving sites -- accessed from the "Sites" screen.
    475541     *
    476      * @since 2.0.0
     542     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     543     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     544     *
     545     * @since 2.0.0
     546     * @return void
    477547     */
    478548    private function page_move_site() {
    479         $site_id = filter_input( INPUT_GET, 'blog_id', FILTER_SANITIZE_NUMBER_INT );
    480         $site    = $site_id ? get_site( $site_id ) : null;
     549
     550        $site_id = ! empty( $_GET['blog_id'] ) && is_numeric( $_GET['blog_id'] )
     551            ? (int) $_GET['blog_id']
     552            : 0;
     553
     554        $site = ! empty( $site_id )
     555            ? get_site( $site_id )
     556            : null;
    481557
    482558        // Bail if invalid site ID.
     
    507583        );
    508584
    509         $add_network_url = $this->admin_url( array( 'page' => 'add-new-network' ) );
     585        // URLs to escape.
     586        $add_network_url = $this->admin_url(
     587            array(
     588                'page' => 'add-new-network',
     589            )
     590        );
     591        $form_action_url = $this->admin_url(
     592            array(
     593                'action'  => 'move',
     594                'blog_id' => $site_id,
     595            )
     596        );
    510597        ?>
    511598
     
    525612            <hr class="wp-header-end">
    526613
    527             <form method="post" action="<?php echo esc_attr( filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING ) ); ?>">
     614            <form method="post" action="<?php echo esc_url( $form_action_url ); ?>">
    528615                <div id="poststuff">
    529616                    <div id="post-body" class="metabox-holder columns-2">
     
    547634     * Renders the delete network page.
    548635     *
    549      * @since 2.0.0
     636     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     637     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     638     *
     639     * @since 2.0.0
     640     * @return void
    550641     */
    551642    private function page_delete_network() {
    552         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
    553         $network    = $network_id ? get_network( $network_id ) : null;
     643
     644        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     645            ? (int) $_GET['id']
     646            : 0;
     647
     648        $network = ! empty( $network_id )
     649            ? get_network( $network_id )
     650            : null;
    554651
    555652        // Bail if invalid network ID.
     
    578675            <hr class="wp-header-end">
    579676
    580             <form method="post" action="<?php echo esc_attr( remove_query_arg( 'action' ) ); ?>">
     677            <form method="post" action="<?php echo esc_url( remove_query_arg( 'action' ) ); ?>">
    581678                <?php
    582679
     
    638735     * Renders the delete multiple networks page.
    639736     *
    640      * @since 2.0.0
     737     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     738     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     739     *
     740     * @since 2.0.0
     741     * @return void
    641742     */
    642743    private function page_delete_networks() {
    643         $network_id   = get_main_network_id();
    644         $all_networks = filter_input( INPUT_POST, 'all_networks', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY );
    645         $all_networks = array_map( 'absint', $all_networks );
     744
     745        $network_id = get_main_network_id();
     746
     747        $all_networks = ! empty( $_POST['all_networks'] ) && is_array( $_POST['all_networks'] )
     748            ? wp_parse_id_list( (array) $_POST['all_networks'] )
     749            : array();
     750
    646751        $all_networks = array_diff( $all_networks, array( $network_id ) );
    647752
     
    758863     *
    759864     * @global wpdb $wpdb WordPress database abstraction object.
     865     * @return void
    760866     */
    761867    public function page_my_networks() {
     
    794900                $num_rows = ceil( $num / $cols );
    795901                $split    = 0;
     902                $rows     = array();
    796903                for ( $i = 1; $i <= $num_rows; $i++ ) {
    797904                    $rows[] = array_slice( $my_networks, $split, $cols );
     
    827934                                 * @param WP_Network $network         Current network object.
    828935                                 */
    829                                 echo apply_filters( 'mynetworks_network_actions', $network_actions, $network ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
     936                                echo apply_filters( 'mynetworks_network_actions', $network_actions, $network ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    830937                                ?>
    831938                            </p>
     
    834941                        <?php
    835942                        restore_current_network();
    836                         $i++;
     943                        ++$i;
    837944                    }
    838945                    echo '</tr>';
     
    848955     * Handles the request to add a new network.
    849956     *
    850      * @since 2.0.0
     957     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     958     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     959     *
     960     * @since 2.0.0
     961     * @return void
    851962     */
    852963    private function handle_add_network() {
    853964
    854965        // Sanitize options to clone.
    855         $options_to_clone = filter_input( INPUT_POST, 'options_to_clone', FILTER_DEFAULT, FILTER_FORCE_ARRAY );
     966        $options_to_clone = ! empty( $_POST['options_to_clone'] ) && is_array( $_POST['options_to_clone'] )
     967            ? $_POST['options_to_clone']
     968            : array();
     969
    856970        $options_to_clone = ! empty( $options_to_clone )
    857971            ? array_keys( $options_to_clone )
     
    859973
    860974        // Sanitize network ID to clone.
    861         $clone = filter_input( INPUT_POST, 'clone_network', FILTER_SANITIZE_NUMBER_INT );
     975        $clone = ! empty( $_GET['clone_network'] )
     976            ? (int) $_GET['clone_network']
     977            : 0;
     978
    862979        if ( empty( $clone ) ) {
    863980            $clone = get_current_site()->id;
    864981        }
    865982
    866         // Sanitize values.
    867         $network_title  = wp_unslash( filter_input( INPUT_POST, 'title', FILTER_SANITIZE_STRING ) );
    868         $network_domain = wp_unslash( filter_input( INPUT_POST, 'domain', FILTER_SANITIZE_STRING ) );
    869         $network_path   = wp_unslash( filter_input( INPUT_POST, 'path', FILTER_SANITIZE_STRING ) );
    870         $site_name      = wp_unslash( filter_input( INPUT_POST, 'new_site', FILTER_SANITIZE_STRING ) );
    871 
    872         // Additional formatting.
    873         $network_title  = wp_strip_all_tags( $network_title );
     983        // Unslash posted values.
     984        $network_title  = ! empty( $_POST['title'] )
     985            ? wp_unslash( $_POST['title'] )
     986            : '';
     987        $network_domain = ! empty( $_POST['domain'] )
     988            ? wp_unslash( $_POST['domain'] )
     989            : '';
     990        $network_path   = ! empty( $_POST['path'] )
     991            ? wp_unslash( $_POST['path'] )
     992            : '';
     993        $site_name      = ! empty( $_POST['new_site'] )
     994            ? wp_unslash( $_POST['new_site'] )
     995            : '';
     996
     997        // Additional sanitization.
     998        $network_title  = sanitize_text_field( $network_title );
    874999        $network_domain = str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) );
    8751000        $network_path   = str_replace( ' ', '', strtolower( sanitize_text_field( $network_path ) ) );
     
    8771002        // Fallback to network title if not explicitly set.
    8781003        $site_name = ! empty( $site_name )
    879             ? wp_strip_all_tags( $site_name )
     1004            ? sanitize_text_field( $site_name )
    8801005            : $network_title;
    8811006
     
    9401065     * Handles the request to update a network.
    9411066     *
    942      * @since 2.0.0
     1067     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1068     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1069     *
     1070     * @since 2.0.0
     1071     * @return void
    9431072     */
    9441073    private function handle_update_network() {
    9451074
    9461075        // Sanitize network ID.
    947         $network_id = filter_input( INPUT_POST, 'network_id', FILTER_SANITIZE_NUMBER_INT );
     1076        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     1077            ? (int) $_GET['id']
     1078            : 0;
    9481079
    9491080        // Bail if invalid network.
     
    9521083        }
    9531084
    954         // Sanitize values.
    955         $network_title  = wp_unslash( filter_input( INPUT_POST, 'title', FILTER_SANITIZE_STRING ) );
    956         $network_domain = wp_unslash( filter_input( INPUT_POST, 'domain', FILTER_SANITIZE_STRING ) );
    957         $network_path   = wp_unslash( filter_input( INPUT_POST, 'path', FILTER_SANITIZE_STRING ) );
    958 
    959         // Additional formatting.
     1085        // Unslash posted values.
     1086        $network_title  = ! empty( $_POST['title'] )
     1087            ? wp_unslash( $_POST['title'] )
     1088            : '';
     1089        $network_domain = ! empty( $_POST['domain'] )
     1090            ? wp_unslash( $_POST['domain'] )
     1091            : '';
     1092        $network_path   = ! empty( $_POST['path'] )
     1093            ? wp_unslash( $_POST['path'] )
     1094            : '';
     1095
     1096        // Additional sanitization.
    9601097        $network_title  = sanitize_text_field( $network_title );
    961         $network_domain = Requests_IDNAEncoder::encode( str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) ) );
     1098        $network_domain = str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) );
    9621099        $network_path   = str_replace( ' ', '', strtolower( sanitize_text_field( $network_path ) ) );
    9631100
     
    10021139     * Handles the request to move a site to another network.
    10031140     *
    1004      * @since 2.0.0
     1141     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1142     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1143     *
     1144     * @since 2.0.0
     1145     * @return void
    10051146     */
    10061147    private function handle_move_site() {
    10071148
    10081149        // Sanitize values.
    1009         $site_id     = filter_input( INPUT_GET, 'blog_id', FILTER_SANITIZE_NUMBER_INT );
    1010         $new_network = filter_input( INPUT_POST, 'to', FILTER_SANITIZE_NUMBER_INT );
     1150        $site_id = ! empty( $_GET['blog_id'] ) && is_numeric( $_GET['blog_id'] )
     1151            ? (int) $_GET['blog_id']
     1152            : 0;
     1153
     1154        $new_network = ! empty( $_POST['to'] ) && is_numeric( $_POST['to'] )
     1155            ? (int) $_POST['to']
     1156            : 0;
    10111157
    10121158        // Bail if no site ID.
     
    10621208     * Handles the request to reassign sites to another network.
    10631209     *
    1064      * @since 2.0.0
     1210     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1211     *
     1212     * @since 2.0.0
     1213     * @return void
    10651214     */
    10661215    private function handle_reassign_sites() {
    10671216
    10681217        // Sanitize values.
    1069         $to   = array_map( 'absint', (array) filter_input( INPUT_POST, 'to', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY ) );
    1070         $from = array_map( 'absint', (array) filter_input( INPUT_POST, 'from', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY ) );
     1218        $to = ! empty( $_POST['to'] ) && is_array( $_POST['to'] )
     1219            ? wp_parse_id_list( (array) $_POST['to'] )
     1220            : array();
     1221
     1222        $from = ! empty( $_POST['from'] ) && is_array( $_POST['from'] )
     1223            ? wp_parse_id_list( (array) $_POST['from'] )
     1224            : array();
    10711225
    10721226        // Bail early if no movement.
     
    10761230
    10771231        // Sanitize network ID.
    1078         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
     1232        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     1233            ? (int) $_GET['id']
     1234            : 0;
    10791235
    10801236        // Default to/from arrays.
     
    11261282     * Handles the request to delete a network.
    11271283     *
    1128      * @since 2.0.0
     1284     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1285     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     1286     *
     1287     * @since 2.0.0
     1288     * @return void
    11291289     */
    11301290    private function handle_delete_network() {
    11311291
    11321292        // Sanitize values.
    1133         $network_id = filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT );
    1134         $override   = (bool) filter_input( INPUT_POST, 'override' );
     1293        $network_id = ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] )
     1294            ? (int) $_GET['id']
     1295            : 0;
     1296
     1297        $override = ! empty( $_POST['override'] );
    11351298
    11361299        // Attempt to delete network.
     
    11531316     * Handles the request to delete multiple networks.
    11541317     *
    1155      * @since 2.0.0
     1318     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     1319     *
     1320     * @since 2.0.0
     1321     * @return void
    11561322     */
    11571323    private function handle_delete_networks() {
    11581324
    11591325        // Sanitize values.
    1160         $deleted_networks = array_map( 'absint', filter_input( INPUT_POST, 'deleted_networks', FILTER_SANITIZE_NUMBER_INT, FILTER_FORCE_ARRAY ) );
    1161         $override         = (bool) filter_input( INPUT_POST, 'override' );
     1326        $deleted_networks = ! empty( $_POST['deleted_networks'] ) && is_array( $_POST['deleted_networks'] )
     1327            ? wp_parse_id_list( (array) $_POST['deleted_networks'] )
     1328            : array();
     1329
     1330        $override = (bool) ! empty( $_POST['override'] );
    11621331
    11631332        // Loop through deleted networks.
     
    11881357     * @since 2.0.0
    11891358     *
    1190      * @param array $args Optional. URL query arguments. Default empty array.
     1359     * @param array<string, int|string> $args Optional. URL query arguments. Default empty array.
     1360     * @return void
    11911361     */
    11921362    private function handle_redirect( $args = array() ) {
     
    12001370     * @since 1.3.0
    12011371     *
    1202      * @param array $args Optional. URL query arguments. Default empty array.
     1372     * @param array<string, int|string> $args Optional. URL query arguments. Default empty array.
    12031373     * @return string Absolute URL to the networks page.
    12041374     */
     
    12371407     *
    12381408     * @since 2.1.0
     1409     * @return void
    12391410     */
    12401411    private function check_nonce() {
  • wp-multi-network/trunk/wp-multi-network/includes/classes/class-wp-ms-networks-capabilities.php

    r2584493 r3414829  
    2121     *
    2222     * @since 2.3.0
     23     * @return void
    2324     */
    2425    public function add_hooks() {
     
    3132     * @since 2.3.0
    3233     *
    33      * @param array  $caps    Array of required capabilities.
    34      * @param string $cap    Capability to map.
    35      * @param int    $user_id User ID.
    36      * @param array  $args    Additional context for the capability check.
    37      * @return array Filtered required capabilities.
     34     * @param string[] $caps Array of required capabilities.
     35     * @param string   $cap Capability to map.
     36     * @param int      $user_id User ID.
     37     * @param mixed[]  $args Additional context for the capability check.
     38     * @return string[] Filtered required capabilities.
    3839     */
    39     public function map_meta_cap( $caps, $cap, $user_id, $args ) {
     40    public function map_meta_cap( $caps, $cap, $user_id, $args ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
    4041
    4142        // Map our meta capabilities to primitive capabilities first.
     
    6869     * @since 2.3.0
    6970     *
    70      * @return array List of primitive global capabilities.
     71     * @return string[] List of primitive global capabilities.
    7172     */
    7273    private function get_global_capabilities() {
  • wp-multi-network/trunk/wp-multi-network/includes/classes/class-wp-ms-networks-list-table.php

    r2588851 r3414829  
    4747     * Prepares the list table items.
    4848     *
    49      * @since 1.3.0
     49     * @phpcs:disable WordPress.Security.NonceVerification.Missing
     50     * @phpcs:disable WordPress.Security.NonceVerification.Recommended
     51     *
     52     * @since 1.3.0
     53     * @return void
    5054     */
    5155    public function prepare_items() {
     
    5357        $pagenum  = $this->get_pagenum();
    5458
    55         $order_by = filter_input( INPUT_GET, 'orderby', FILTER_SANITIZE_STRING );
    56         $order_by = ! empty( $order_by ) ? sanitize_key( $order_by ) : '';
    57         $order    = filter_input( INPUT_GET, 'order', FILTER_SANITIZE_STRING );
    58         $order    = ! empty( $order ) ? strtoupper( $order ) : 'ASC';
    59         $search   = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
    60         if ( ! $search ) {
    61             $search = filter_input( INPUT_POST, 's', FILTER_SANITIZE_STRING );
    62         }
    63 
    64         $search = stripslashes( trim( $search ) );
     59        $order_by = ! empty( $_GET['orderby'] )
     60            ? sanitize_key( $_GET['orderby'] )
     61            : '';
     62
     63        $order = ! empty( $_GET['order'] )
     64            ? strtoupper( sanitize_key( $_GET['order'] ) )
     65            : 'ASC';
     66
     67        $search = ! empty( $_REQUEST['s'] )
     68            ? stripslashes( sanitize_text_field( $_REQUEST['s'] ) )
     69            : '';
     70
    6571        if ( false !== strpos( $search, '*' ) ) {
    6672            $search = trim( $search, '*' );
     
    97103     *
    98104     * @since 1.3.0
     105     * @return void
    99106     */
    100107    public function no_items() {
     
    107114     * @since 1.3.0
    108115     *
    109      * @return array Bulk actions as $slug => $label pairs.
     116     * @return array<string, string> Bulk actions as $slug => $label pairs.
    110117     */
    111118    public function get_bulk_actions() {
     
    124131     * @since 1.3.0
    125132     *
    126      * @param type $which Where to display the pagination. Either 'top' or 'bottom'.
     133     * @param string $which Where to display the pagination. Either 'top' or 'bottom'.
    127134     */
    128135    public function pagination( $which ) { // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
     
    146153     * @since 1.3.0
    147154     *
    148      * @return array Columns as $slug => $label pairs.
     155     * @return array<string, string> Columns as $slug => $label pairs.
    149156     */
    150157    public function get_columns() {
     
    173180     * @since 1.3.0
    174181     *
    175      * @return array Columns as $slug => $orderby_field pairs.
     182     * @return array<string, string> Columns as $slug => $orderby_field pairs.
    176183     */
    177184    public function get_sortable_columns() {
     
    189196     *
    190197     * @param object $network The current network item.
     198     * @return void
    191199     */
    192200    public function single_row( $network ) {
     
    271279     *
    272280     * @param WP_Network $network The current network object.
     281     * @return void
    273282     */
    274283    public function column_cb( $network ) {
     
    280289
    281290        ?>
    282         <label class="screen-reader-text" for="network_<?php echo esc_attr( $network->id ); ?>">
     291        <label class="screen-reader-text" for="network_<?php echo esc_attr( strval( $network->id ) ); ?>">
    283292            <?php
    284293            printf(
     
    289298            ?>
    290299        </label>
    291         <input type="checkbox" id="network_<?php echo esc_attr( $network->id ); ?>" name="all_networks[]" value="<?php echo esc_attr( $network->id ); ?>">
     300        <input type="checkbox" id="network_<?php echo esc_attr( strval( $network->id ) ); ?>" name="all_networks[]" value="<?php echo esc_attr( strval( $network->id ) ); ?>">
    292301        <?php
    293302    }
     
    299308     *
    300309     * @param WP_Network $network The current network object.
     310     * @return void
    301311     */
    302312    public function column_title( $network ) {
     
    327337        <strong>
    328338            <?php
    329             echo $link; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
    330             echo $network_states; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
     339            echo $link; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     340            echo $network_states; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
    331341            ?>
    332342        </strong>
     
    341351     *
    342352     * @param WP_Network $network The current network object.
     353     * @return void
    343354     */
    344355    public function column_domain( $network ) {
     
    352363     *
    353364     * @param WP_Network $network The current network object.
     365     * @return void
    354366     */
    355367    public function column_path( $network ) {
     
    363375     *
    364376     * @param WP_Network $network The current network object.
     377     * @return void
    365378     */
    366379    public function column_blogs( $network ) {
     
    380393     *
    381394     * @param WP_Network $network The current network object.
     395     * @return void
    382396     */
    383397    public function column_admins( $network ) {
     
    395409     *
    396410     * @param WP_Network $network The current network object.
     411     * @return void
    397412     */
    398413    public function column_id( $network ) {
    399         echo esc_html( $network->id );
     414        echo esc_html( strval( $network->id ) );
    400415    }
    401416
     
    415430        // Bail if not primary column.
    416431        if ( $primary !== $column_name ) {
    417             return;
     432            return '';
    418433        }
    419434
     
    444459        // Edit the network.
    445460        if ( current_user_can( 'edit_network', $network->id ) ) {
    446             $edit_network_url = add_query_arg(
    447                 array(
    448                     'action' => 'edit_network',
    449                 ),
    450                 $base_url
    451             );
     461            $edit_network_url = add_query_arg( array( 'action' => 'edit_network' ), $base_url );
    452462
    453463            $actions['edit'] = '<span class="edit"><a href="' . esc_url( $edit_network_url ) . '">' . esc_html__( 'Edit', 'wp-multi-network' ) . '</a></span>';
     
    465475        if ( $this->can_delete( $network ) ) {
    466476            $delete_network_url = wp_nonce_url(
    467                 add_query_arg(
    468                     array(
    469                         'action' => 'delete_network',
    470                     ), $base_url
    471                 )
     477                add_query_arg( array( 'action' => 'delete_network' ), $base_url )
    472478            );
    473479
     
    480486         * @since 2.0.0
    481487         *
    482          * @param array  Action links as $slug => $link_markup pairs.
    483          * @param int    The current network ID.
    484          * @param string The current network name.
     488         * @param array  $filtered_acions Action links as $slug => $link_markup pairs.
     489         * @param int    $network_id The current network ID.
     490         * @param string $network_sitename The current network name.
    485491         */
    486         $actions = apply_filters( 'manage_networks_action_links', array_filter( $actions ), $network->id, $network->sitename );
     492        $actions = apply_filters( 'manage_networks_action_links', $actions, $network->id, $network->site_name );
    487493
    488494        // Return all row actions.
  • wp-multi-network/trunk/wp-multi-network/includes/classes/class-wp-ms-rest-networks-controller.php

    r2584493 r3414829  
    3131     *
    3232     * @since 2.4.0
     33     * @return void
    3334     */
    3435    public function register_routes() {
     
    100101     * @since 2.4.0
    101102     *
    102      * @param WP_REST_Request $request Full details about the request.
     103     * @template T of WP_REST_Request
     104     * @param T $request Full details about the request.
    103105     *
    104106     * @return WP_Error|bool True if the request has read access, error object otherwise.
     
    113115     * @since 2.4.0
    114116     *
    115      * @param WP_REST_Request $request Full details about the request.
     117     * @template T of WP_REST_Request
     118     * @param T $request Full details about the request.
    116119     *
    117120     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    194197        }
    195198
    196         $total_networks = (int) $query->found_networks;
    197         $max_pages      = (int) $query->max_num_pages;
     199        $total_networks = $query->found_networks;
     200        $max_pages      = $query->max_num_pages;
    198201
    199202        if ( $total_networks < 1 ) {
     
    204207            $prepared_args['count'] = true;
    205208
    206             $total_networks = $query->query( $prepared_args );
    207             $max_pages      = ceil( $total_networks / $request['per_page'] );
     209            $total_networks = (int) $query->query( $prepared_args );
     210            $max_pages      = (int) ceil( $total_networks / $request['per_page'] );
    208211        }
    209212
    210213        $response = rest_ensure_response( $networks );
    211         $response->header( 'X-WP-Total', $total_networks );
    212         $response->header( 'X-WP-TotalPages', $max_pages );
     214        $response->header( 'X-WP-Total', strval( $total_networks ) );
     215        $response->header( 'X-WP-TotalPages', strval( $max_pages ) );
    213216
    214217        $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
     
    268271     * @since 2.4.0
    269272     *
    270      * @param WP_REST_Request $request Full details about the request.
     273     * @template T of WP_REST_Request
     274     * @param T $request Full details about the request.
    271275     *
    272276     * @return WP_Error|bool True if the request has read access for the item, error object otherwise.
     
    286290     * @since 2.4.0
    287291     *
    288      * @param WP_REST_Request $request Full details about the request.
     292     * @template T of WP_REST_Request
     293     * @param T $request Full details about the request.
    289294     *
    290295     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    307312     * @since 2.4.0
    308313     *
    309      * @param WP_REST_Request $request Full details about the request.
     314     * @template T of WP_REST_Request
     315     * @param T $request Full details about the request.
    310316     *
    311317     * @return WP_Error|bool True if the request has access to create items, error object otherwise.
     
    320326     * @since 2.4.0
    321327     *
    322      * @param WP_REST_Request $request Full details about the request.
     328     * @template T of WP_REST_Request
     329     * @param T $request Full details about the request.
    323330     *
    324331     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    405412     * @since 2.4.0
    406413     *
    407      * @param WP_REST_Request $request Full details about the request.
     414     * @template T of WP_REST_Request
     415     * @param T $request Full details about the request.
    408416     *
    409417     * @return WP_Error|bool True if the request has access to update the item, error object otherwise.
     
    431439     * @since 2.4.0
    432440     *
    433      * @param WP_REST_Request $request Full details about the request.
     441     * @template T of WP_REST_Request
     442     * @param T $request Full details about the request.
    434443     *
    435444     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    450459
    451460        if ( ! empty( $prepared_args ) ) {
    452             if ( is_wp_error( $prepared_args ) ) {
    453                 return $prepared_args;
    454             }
    455 
    456461            $domain = $prepared_args['domain'];
    457462            $path   = $prepared_args['path'];
     
    493498     * @since 2.4.0
    494499     *
    495      * @param WP_REST_Request $request Full details about the request.
     500     * @template T of WP_REST_Request
     501     * @param T $request Full details about the request.
    496502     *
    497503     * @return WP_Error|bool True if the request has access to delete the item, error object otherwise.
     
    511517     * @since 2.4.0
    512518     *
    513      * @param WP_REST_Request $request Full details about the request.
     519     * @template T of WP_REST_Request
     520     * @param T $request Full details about the request.
    514521     *
    515522     * @return WP_Error|WP_REST_Response Response object on success, or error object on failure.
     
    564571     * @since 2.4.0
    565572     *
    566      * @param WP_Network      $network Network object.
    567      * @param WP_REST_Request $request Request object.
     573     * @template T of WP_REST_Request
     574     * @param WP_Network $network Network object.
     575     * @param T          $request Request object.
    568576     *
    569577     * @return WP_REST_Response Response object.
     
    609617     * @param WP_Network $network Network object.
    610618     *
    611      * @return array Links for the given network.
     619     * @return array<string, array<string, string>> Links for the given network.
    612620     */
    613621    protected function prepare_links( $network ) {
     
    651659     * @since 2.4.0
    652660     *
    653      * @param WP_REST_Request $request Request object.
    654      *
    655      * @return array|WP_Error Prepared network, otherwise WP_Error object.
     661     * @template T of WP_REST_Request
     662     * @param T $request Request object.
     663     *
     664     * @return array<string, string>|WP_Error Prepared network, otherwise WP_Error object.
    656665     */
    657666    protected function prepare_item_for_database( $request ) {
     
    688697     * @since 2.4.0
    689698     *
    690      * @return array
     699     * @return array<string, mixed>
    691700     */
    692701    public function get_item_schema() {
     
    736745     * @since 2.4.0
    737746     *
    738      * @return array Networks collection parameters.
     747     * @return array<string, mixed> Networks collection parameters.
    739748     */
    740749    public function get_collection_params() {
     
    842851     * @since 2.4.0
    843852     *
    844      * @param WP_Network      $network Network object.
    845      * @param WP_REST_Request $request Request data to check.
     853     * @template T of WP_REST_Request
     854     * @param WP_Network $network Network object.
     855     * @param T          $request Request data to check.
    846856     *
    847857     * @return bool Whether the network can be read.
  • wp-multi-network/trunk/wp-multi-network/includes/compat.php

    r2584493 r3414829  
    5757     * @param string $path    Site path.
    5858     * @param string $site_id Optional. Site ID, if an existing site. Default 0.
     59     *
    5960     * @return bool True if the site URL is valid, false otherwise.
    6061     */
    61     function wp_validate_site_url( $domain, $path, $site_id = 0 ) {
     62    function wp_validate_site_url( $domain, $path, $site_id = '0' ) {
    6263        global $wpdb;
    6364
     
    6768            return true;
    6869        }
    69         if ( true === $exists ) {
     70
     71        if ( true === (bool) $exists ) {
    7072            return false;
    7173        }
     
    8789        $pieces  = array_filter( array_merge( $domains, $paths ) );
    8890        foreach ( $pieces as $slug ) {
    89 
    90             // Bail if empty.
    91             if ( empty( $slug ) ) {
    92                 return false;
    93             }
    94 
    9591            // Bail if not lowercase or numbers.
    9692            if ( preg_match( '/[^a-z0-9]+/', $slug ) ) {
  • wp-multi-network/trunk/wp-multi-network/includes/deprecated.php

    r2584493 r3414829  
    3737     * @param string $value   Upload path option value.
    3838     * @param int    $blog_id Site ID.
     39     * @return string
    3940     */
    4041    function wpmn_fix_subsite_upload_path( $value, $blog_id ) {
     
    5556    add_filter( 'blog_option_upload_path', 'wpmn_fix_subsite_upload_path', 10, 2 );
    5657}
    57 
    58 if ( ! function_exists( 'get_network_option' ) ) :
    59     /**
    60      * Gets an option from a given network.
    61      *
    62      * Switches to the specified network internally to operate on it.
    63      *
    64      * @since 1.0.0
    65      * @deprecated
    66      *
    67      * @param int    $network_id ID of network.
    68      * @param string $key        Option key.
    69      * @param mixed  $default    Default value if option doesn't exist.
    70      * @return mixed Value set for the option if it exists, `$default` if it doesn't.
    71      *               `WP_Error` instance if invalid network ID is passed.
    72      */
    73     function get_network_option( $network_id, $key, $default = false ) {
    74         if ( ! switch_to_network( $network_id, true ) ) {
    75             return new WP_Error(
    76                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    77                     'status' => 400,
    78                 )
    79             );
    80         }
    81 
    82         $result = get_site_option( $key, $default );
    83 
    84         restore_current_network();
    85 
    86         return $result;
    87     }
    88 endif;
    89 
    90 if ( ! function_exists( 'add_network_option' ) ) :
    91     /**
    92      * Adds an option from a given network.
    93      *
    94      * Switches to the specified network internally to operate on it.
    95      *
    96      * @since 1.0.0
    97      * @deprecated
    98      *
    99      * @param int    $network_id ID of network.
    100      * @param string $key        Option key.
    101      * @param mixed  $value      Option value, can be anything.
    102      * @return bool|WP_Error True if the option is added, false if not added.
    103      *                       `WP_Error` instance if invalid network ID is passed.
    104      */
    105     function add_network_option( $network_id, $key, $value ) {
    106         if ( ! switch_to_network( $network_id, true ) ) {
    107             return new WP_Error(
    108                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    109                     'status' => 400,
    110                 )
    111             );
    112         }
    113 
    114         $result = add_site_option( $key, $value );
    115 
    116         restore_current_network();
    117 
    118         return $result;
    119     }
    120 endif;
    121 
    122 if ( ! function_exists( 'update_network_option' ) ) :
    123     /**
    124      * Updates an option from a given network.
    125      *
    126      * Switches to the specified network internally to operate on it.
    127      *
    128      * @since 1.0.0
    129      * @deprecated
    130      *
    131      * @param int    $network_id ID of network.
    132      * @param string $key        Option key.
    133      * @param mixed  $value      Option value, can be anything.
    134      * @return bool|WP_Error True if the option is updated, false if not updated.
    135      *                       `WP_Error` instance if invalid network ID is passed.
    136      */
    137     function update_network_option( $network_id, $key, $value ) {
    138         if ( ! switch_to_network( $network_id, true ) ) {
    139             return new WP_Error(
    140                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    141                     'status' => 400,
    142                 )
    143             );
    144         }
    145 
    146         $result = update_site_option( $key, $value );
    147 
    148         restore_current_network();
    149 
    150         return $result;
    151     }
    152 endif;
    153 
    154 if ( ! function_exists( 'delete_network_option' ) ) :
    155     /**
    156      * Deletes an option from a given network.
    157      *
    158      * Switches to the specified network internally to operate on it.
    159      *
    160      * @since 1.0.0
    161      * @deprecated
    162      *
    163      * @param int    $network_id ID of network.
    164      * @param string $key        Option key.
    165      * @return bool|WP_Error True if the option is deleted, false if not deleted.
    166      *                       `WP_Error` instance if invalid network ID is passed.
    167      */
    168     function delete_network_option( $network_id, $key ) {
    169         if ( ! switch_to_network( $network_id, true ) ) {
    170             return new WP_Error(
    171                 'wpmn.network_missing', __( 'Network does not exist', 'wp-multi-network' ), array(
    172                     'status' => 400,
    173                 )
    174             );
    175         }
    176 
    177         $result = delete_site_option( $key );
    178 
    179         restore_current_network();
    180 
    181         return $result;
    182     }
    183 endif;
    184 
    185 if ( ! function_exists( 'get_networks' ) ) :
    186     /**
    187      * Gets all networks.
    188      *
    189      * @since 1.0.0
    190      * @deprecated
    191      *
    192      * @param array $args Optional. Network query arguments. Default empty array.
    193      * @return array Networks available on the installation.
    194      */
    195     function get_networks( $args = array() ) {
    196 
    197         // Support for WordPress 4.6.0, if you're doing something really weird.
    198         if ( class_exists( 'WP_Network_Query' ) ) {
    199             $query = new WP_Network_Query();
    200 
    201             return $query->query( $args );
    202         }
    203 
    204         // The original get_networks() function.
    205         return $GLOBALS['wpdb']->get_results( "SELECT * FROM {$GLOBALS['wpdb']->site}" );
    206     }
    207 endif;
  • wp-multi-network/trunk/wp-multi-network/includes/functions.php

    r2788090 r3414829  
    5555     *
    5656     * @param int $user_id Optional. User ID. Default is the current user.
    57      * @return array|bool Array of network IDs, or false if none.
     57     * @return int[]|bool Array of network IDs, or false if none.
    5858     */
    5959    function user_has_networks( $user_id = 0 ) {
     
    7575         * @since 2.0.0
    7676         *
    77          * @param array|bool|null List of network IDs or false. Anything but null will short-circuit
    78          *                        the process.
    79          * @param int             User ID for which the networks should be returned.
     77         * @param array|bool|null $my_networks List of network IDs or false. Anything but null will short-circuit
     78         *                                     the process.
     79         * @param int             $user_id User ID for which the networks should be returned.
    8080         */
    8181        $my_networks = apply_filters( 'networks_pre_user_is_network_admin', null, $user_id );
     
    9090             * @since 2.0.0
    9191             *
    92              * @param array|bool List of network IDs or false if no networks for the user.
    93              * @param int        User ID for which the networks should be returned.
     92             * @param array|bool $my_networks List of network IDs or false if no networks for the user.
     93             * @param int        $user_id User ID for which the networks should be returned.
    9494             */
    9595            return apply_filters( 'networks_user_is_network_admin', $my_networks, $user_id );
     
    121121     *
    122122     * @param int|WP_Network $network Optional. Network ID or object. Default is the current network.
    123      * @return int Main site ID for the network.
     123     * @return int|bool Main site ID for the network or false if network not found.
    124124     */
    125125    function get_main_site_for_network( $network = null ) {
     
    219219        global $wpdb, $switched_network, $switched_network_stack, $current_site;
    220220
    221         if ( empty( $new_network ) ) {
     221        // Maybe fallback to current network.
     222        if ( empty( $new_network ) || ! is_numeric( $new_network ) ) {
    222223            $new_network = $current_site->id;
    223224        }
     
    250251        }
    251252
    252         $prev_site_id = $current_site->id;
    253         $current_site = get_network( $new_network ); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
     253        $prev_site_id    = $current_site->id;
     254        $new_network_obj = get_network( $new_network );
     255        $current_site    = $new_network_obj; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
    254256
    255257        // Populate extra properties if not set already.
     
    413415     * @global wpdb $wpdb WordPress database abstraction object.
    414416     *
    415      * @param array $args  {
     417     * @param array<string, mixed> $args  {
    416418     *     Array of network arguments.
    417419     *
     
    577579        }
    578580
     581        /**
     582         * Fires after a new network blog has been added.
     583         *
     584         * @param int $new_blog_id ID of the added network blog.
     585         * @param int $new_network_id ID of the added network.
     586         * @param array $r Full associative array of network arguments.
     587         *
     588         * @since 2.5.3
     589         */
     590        do_action( 'added_network_blog', $new_blog_id, $new_network_id, $r );
     591
     592        // add new blog id as network meta data against the new network.
    579593        $r['network_meta']['main_site'] = $new_blog_id;
    580594
     
    601615            $current_siteurl = get_option( 'siteurl' );
    602616            $new_siteurl     = untrailingslashit( get_blogaddress_by_id( $new_blog_id ) );
    603             $upload_url      = str_replace( $current_siteurl, $new_siteurl, WP_CONTENT_URL );
     617            $upload_url      = str_replace( $current_siteurl, $new_siteurl, content_url() );
    604618            $upload_url      = $upload_url . '/uploads';
    605 
    606             $upload_dir = WP_CONTENT_DIR;
    607             if ( 0 === strpos( $upload_dir, ABSPATH ) ) {
    608                 $upload_dir = substr( $upload_dir, strlen( ABSPATH ) );
     619            $upload_dir      = WP_CONTENT_DIR;
     620            $needle          = strval( ABSPATH );
     621            if ( 0 === strpos( $upload_dir, $needle ) ) {
     622                $upload_dir = substr( $upload_dir, strlen( $needle ) );
    609623            }
    610624            $upload_dir .= '/uploads';
    611625
    612             if ( defined( 'MULTISITE' ) ) {
    613                 $ms_dir = '/sites/' . $new_blog_id;
    614             } else {
    615                 $ms_dir = '/' . $new_blog_id;
     626            // Check if wpmu_create_blog() already set the site-specific path.
     627            $existing_upload_path = get_blog_option( $new_blog_id, 'upload_path' );
     628            $site_path_suffix     = defined( 'MULTISITE' ) ? '/sites/' . $new_blog_id : '/' . $new_blog_id;
     629
     630            // Only add the site-specific path if it's not already present.
     631            if ( empty( $existing_upload_path ) || false === strpos( $existing_upload_path, $site_path_suffix ) ) {
     632                $upload_dir .= $site_path_suffix;
     633                $upload_url .= $site_path_suffix;
     634                update_blog_option( $new_blog_id, 'upload_path', $upload_dir );
     635                update_blog_option( $new_blog_id, 'upload_url_path', $upload_url );
    616636            }
    617 
    618             $upload_dir .= $ms_dir;
    619             $upload_url .= $ms_dir;
    620 
    621             update_blog_option( $new_blog_id, 'upload_path', $upload_dir );
    622             update_blog_option( $new_blog_id, 'upload_url_path', $upload_url );
    623637        }
    624638
     
    664678        clean_network_cache( $new_network_id );
    665679
     680        // Self-activate on new network.
     681        $existing_plugins = get_network_option( $new_network_id, 'active_sitewide_plugins', array() );
     682        if ( ! isset( $existing_plugins['wp-multi-network/wpmn-loader.php'] ) ) {
     683            $existing_plugins['wp-multi-network/wpmn-loader.php'] = time();
     684            update_network_option( $new_network_id, 'active_sitewide_plugins', $existing_plugins );
     685        }
     686
    666687        /**
    667688         * Fires after a new network has been added.
     
    706727
    707728        // Bail if site URL is invalid.
    708         if ( ! wp_validate_site_url( $domain, $path, $site_id ) ) {
     729        if ( ! wp_validate_site_url( $domain, $path, strval( $site_id ) ) ) {
    709730            /* translators: %s: site domain and path */
    710731            return new WP_Error( 'blog_bad', sprintf( __( 'The site "%s" is invalid, not available, or already exists.', 'wp-multi-network' ), $domain . $path ) );
     
    830851            }
    831852
    832             if ( true === $delete_blogs ) {
    833                 foreach ( $sites as $site ) {
    834                     if ( wp_should_rescue_orphaned_sites() ) {
    835                         move_site( $site->id, 0 );
    836                         continue;
    837                     }
    838 
    839                     wpmu_delete_blog( $site->id, true );
     853            foreach ( $sites as $site ) {
     854                if ( wp_should_rescue_orphaned_sites() ) {
     855                    move_site( $site->id, 0 );
     856                    continue;
    840857                }
     858
     859                wpmu_delete_blog( $site->id, true );
    841860            }
    842861        }
     
    961980     * @since 1.3.0
    962981     *
    963      * @return array List of network option names.
     982     * @return string[] List of network option names.
    964983     */
    965984    function network_options_list() {
     
    9861005     * @since 1.3.0
    9871006     *
    988      * @return array List of network $option_name => $option_label pairs.
     1007     * @return array<string, string> List of network $option_name => $option_label pairs.
    9891008     */
    9901009    function network_options_to_copy() {
  • wp-multi-network/trunk/wp-multi-network/includes/metaboxes/edit-network.php

    r2588851 r3414829  
    1616 *
    1717 * @param WP_Network $network Optional. Network object. Default null.
     18 * @return void
    1819 */
    1920function wpmn_edit_network_details_metabox( $network = null ) {
    20     $domain = ! empty( $network->domain ) ? Requests_IDNAEncoder::encode( $network->domain ) : '';
    21     $path   = ! empty( $network->path ) ? $network->path : '/';
     21
     22    $domain = ! empty( $network->domain )
     23        ? $network->domain
     24        : '';
     25
     26    $path = ! empty( $network->path )
     27        ? $network->path
     28        : '/';
    2229
    2330    ?>
    2431
    2532    <table class="edit-network form-table">
     33        <?php do_action( 'wpmn_edit_network_details_metabox_before_group', $network ); ?>
     34
    2635        <tr class="form-field form-required">
    2736            <th scope="row">
     
    4453            </td>
    4554        </tr>
     55
     56        <?php do_action( 'wpmn_edit_network_details_metabox_after_group', $network ); ?>
    4657    </table>
    4758
     
    5364 *
    5465 * @since 1.7.0
     66 * @return void
    5567 */
    5668function wpmn_edit_network_new_site_metabox() {
     
    5870
    5971    <table class="edit-network form-table">
     72        <?php do_action( 'wpmn_edit_network_new_site_metabox_before_group' ); ?>
     73
    6074        <tr class="form-field form-required">
    6175            <th scope="row">
     
    6781            </td>
    6882        </tr>
     83
     84        <?php do_action( 'wpmn_edit_network_new_site_metabox_after_group' ); ?>
    6985    </table>
    7086
     
    7894 *
    7995 * @param WP_Network $network Optional. Network object. Default null.
     96 * @return void
    8097 */
    8198function wpmn_edit_network_assign_sites_metabox( $network = null ) {
    8299    $to = get_sites(
    83100        array(
    84             'site__not_in' => get_main_site_id( $network->id ),
     101            'site__not_in' => array( get_main_site_id( $network->id ) ),
    85102            'network_id'   => $network->id,
    86103        )
     
    111128                        <?php if ( ( (int) $site->network_id !== (int) $network->id ) && ! is_main_site_for_network( $site->id ) ) : ?>
    112129
    113                             <option value="<?php echo esc_attr( $site->id ); ?>">
    114                                 <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->name, $site->domain, $site->path ) ); ?>
     130                            <option value="<?php echo esc_attr( strval( $site->id ) ); ?>">
     131                                <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->blogname, $site->domain, $site->path ) ); ?>
    115132                            </option>
    116133
     
    132149                        <?php if ( (int) $site->network_id === (int) $network->id ) : ?>
    133150
    134                             <option value="<?php echo esc_attr( $site->id ); ?>" <?php disabled( is_main_site_for_network( $site->id ) ); ?>>
    135                                 <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->name, $site->domain, $site->path ) ); ?>
     151                            <option value="<?php echo esc_attr( strval( $site->id ) ); ?>" <?php disabled( is_main_site_for_network( $site->id ) ); ?>>
     152                                <?php echo esc_html( sprintf( '%1$s (%2$s%3$s)', $site->blogname, $site->domain, $site->path ) ); ?>
    136153                            </option>
    137154
     
    154171 *
    155172 * @param WP_Network $network Optional. Network object. Default null.
     173 * @return void
    156174 */
    157175function wpmn_edit_network_publish_metabox( $network = null ) {
     
    234252                ?>
    235253                <input type="hidden" name="action" value="<?php echo esc_attr( $action ); ?>">
    236                 <input type="hidden" name="network_id" value="<?php echo esc_attr( $network_id ); ?>">
     254                <input type="hidden" name="network_id" value="<?php echo esc_attr( strval( $network_id ) ); ?>">
    237255            </div>
    238256            <div class="clear"></div>
  • wp-multi-network/trunk/wp-multi-network/includes/metaboxes/move-site.php

    r2588851 r3414829  
    1616 *
    1717 * @param WP_Site $site Optional. Site object. Default null.
     18 * @return void
    1819 */
    1920function wpmn_move_site_list_metabox( $site = null ) {
     
    7879 *
    7980 * @param WP_Site $site Optional. Site object. Default null.
     81 * @return void
    8082 */
    8183function wpmn_move_site_assign_metabox( $site = null ) {
     
    139141                ?>
    140142                <input type="hidden" name="action" value="move">
    141                 <input type="hidden" name="from" value="<?php echo esc_attr( $site->network_id ); ?>">
     143                <input type="hidden" name="from" value="<?php echo esc_attr( strval( $site->network_id ) ); ?>">
    142144            </div>
    143145            <div class="clear"></div>
  • wp-multi-network/trunk/wpmn-loader.php

    r2788090 r3414829  
    1616 * Text Domain:       wp-multi-network
    1717 * Network:           true
    18  * Requires at least: 4.9
    19  * Requires PHP:      5.2
    20  * Tested up to:      6.1
     18 * Requires at least: 5.5
     19 * Requires PHP:      7.2
     20 * Tested up to:      7.0
    2121 * Version:           2.5.2
    2222 */
     
    7070     * @var string
    7171     */
    72     public $asset_version = 202108250001;
     72    public $asset_version = '202108250001';
    7373
    7474    /**
     
    111111     *
    112112     * @since 1.3.0
     113     * @return void
    113114     */
    114115    private function constants() {
     
    126127     *
    127128     * @since 1.3.0
     129     * @return void
    128130     */
    129131    private function setup_globals() {
     
    138140     *
    139141     * @since 1.3.0
     142     * @return void
    140143     */
    141144    private function includes() {
     
    166169
    167170        $this->admin_bar = new WP_MS_Networks_Admin_Bar();
     171        $this->admin_bar->add_hooks();
    168172
    169173        if ( defined( 'WPMN_DEPRECATED' ) && ( true === WPMN_DEPRECATED ) ) {
     
    186190 *
    187191 * @since 1.3.0
    188  */
    189 function setup_multi_network() {
     192 * @return void
     193 */
     194function setup_multi_network() { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
    190195    wpmn();
    191196}
     
    196201 *
    197202 * @since 2.3.0
     203 * @return void
    198204 */
    199205function setup_multi_network_endpoints() {
     
    209215 *
    210216 * @since 1.7.0
    211  *
    212217 * @return WPMN_Loader WP Multi Network instance to use.
    213218 */
Note: See TracChangeset for help on using the changeset viewer.