Plugin Directory

Changeset 3338199


Ignore:
Timestamp:
08/02/2025 11:31:34 AM (8 months ago)
Author:
plance
Message:

Added support for installing a plugin for the multisite.

Location:
my-maps/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • my-maps/trunk/includes/class-plugin.php

    r3330608 r3338199  
    2121     */
    2222    public static function activate() {
    23         global $wpdb;
    24 
    2523        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    2624
    27         dbDelta(
    28             "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}plance_msm_maps` (
    29             `id` INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
    30             `title` VARCHAR(255) NOT NULL,
    31             `address` TEXT NOT NULL,
    32             `date_create` INT(10) UNSIGNED NOT NULL
    33             ) {$wpdb->get_charset_collate()};"
     25        self::walk_site(
     26            function() {
     27                global $wpdb;
     28
     29                dbDelta(
     30                    "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}plance_msm_maps` (
     31                    `id` INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
     32                    `title` VARCHAR(255) NOT NULL,
     33                    `address` TEXT NOT NULL,
     34                    `date_create` INT(10) UNSIGNED NOT NULL
     35                    ) {$wpdb->get_charset_collate()};"
     36                );
     37            }
    3438        );
    3539
     
    4347     */
    4448    public static function uninstall() {
    45         global $wpdb;
     49        self::walk_site(
     50            function() {
     51                global $wpdb;
    4652
    47         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- intentional schema change on uninstall
    48         $wpdb->query( 'DROP TABLE IF EXISTS `' . $wpdb->prefix . 'plance_msm_maps`' );
     53                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- intentional schema change on uninstall
     54                $wpdb->query( 'DROP TABLE IF EXISTS `' . $wpdb->prefix . 'plance_msm_maps`' );
     55            }
     56        );
    4957
    5058        return true;
    5159    }
     60
     61    /**
     62     * Walk site.
     63     *
     64     * @param  callable $callback Callback.
     65     * @return void
     66     */
     67    private static function walk_site( $callback ) {
     68        if ( is_multisite() ) {
     69            $sites = get_sites();
     70
     71            foreach ( $sites as $site ) {
     72                switch_to_blog( $site->blog_id );
     73
     74                call_user_func( $callback );
     75
     76                restore_current_blog();
     77            }
     78        } else {
     79            call_user_func( $callback );
     80        }
     81    }
    5282}
  • my-maps/trunk/my-maps.php

    r3330642 r3338199  
    88 * Description: Creating shortcode maps, using friendly interface
    99 * Plugin URI:  https://plance.top/
    10  * Version:     1.1.1
     10 * Version:     1.1.2
    1111 * Author:      plance
    1212 * Author URI:  http://plance.top/
  • my-maps/trunk/readme.txt

    r3330642 r3338199  
    4747== Changelog ==
    4848
     49= 1.1.2 =
     50* Added support for installing a plugin for the multisite.
     51
    4952= 1.1.1 =
    5053* Change help.
Note: See TracChangeset for help on using the changeset viewer.