Plugin Directory

Changeset 3338184


Ignore:
Timestamp:
08/02/2025 10:33:15 AM (8 months ago)
Author:
plance
Message:

feat: Added support for installing a plugin for the multisite.

Location:
my-text-shortcodes/trunk
Files:
3 edited

Legend:

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

    r3327046 r3338184  
    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_text_shortcodes` (
    29             `sh_id` INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
    30             `sh_title` VARCHAR(150) NOT NULL,
    31             `sh_code` VARCHAR(25) NOT NULL,
    32             `sh_description` text NOT NULL,
    33             `sh_is_lock` TINYINT(1) UNSIGNED NOT NULL,
    34             `sh_date_create` INT(10) UNSIGNED NOT NULL
    35             ) {$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_text_shortcodes` (
     31                    `sh_id` INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
     32                    `sh_title` VARCHAR(150) NOT NULL,
     33                    `sh_code` VARCHAR(25) NOT NULL,
     34                    `sh_description` text NOT NULL,
     35                    `sh_is_lock` TINYINT(1) UNSIGNED NOT NULL,
     36                    `sh_date_create` INT(10) UNSIGNED NOT NULL
     37                    ) {$wpdb->get_charset_collate()};"
     38                );
     39            }
    3640        );
    3741
     
    4549     */
    4650    public static function uninstall() {
    47         global $wpdb;
     51        self::walk_site(
     52            function() {
     53                global $wpdb;
    4854
    49         // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- intentional schema change on uninstall
    50         $wpdb->query( 'DROP TABLE IF EXISTS `' . $wpdb->prefix . 'plance_text_shortcodes`' );
     55                // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- intentional schema change on uninstall
     56                $wpdb->query( 'DROP TABLE IF EXISTS `' . $wpdb->prefix . 'plance_text_shortcodes`' );
     57            }
     58        );
    5159
    5260        return true;
    5361    }
     62
     63    /**
     64     * Walk site.
     65     *
     66     * @param  callable $callback Callback.
     67     * @return void
     68     */
     69    private static function walk_site( $callback ) {
     70        if ( is_multisite() ) {
     71            $sites = get_sites();
     72
     73            foreach ( $sites as $site ) {
     74                switch_to_blog( $site->blog_id );
     75
     76                call_user_func( $callback );
     77
     78                restore_current_blog();
     79            }
     80        } else {
     81            call_user_func( $callback );
     82        }
     83    }
    5484}
  • my-text-shortcodes/trunk/my-text-shortcodes.php

    r3328422 r3338184  
    88 * Description: Creating text shortcodes, 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-text-shortcodes/trunk/readme.txt

    r3328422 r3338184  
    44Requires at least: 4.0.0
    55Tested up to: 6.8
    6 Stable tag: 1.1.1
     6Stable tag: 1.1.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2929
    3030== Changelog ==
     31= 1.1.2 =
     32* Added support for installing a plugin for the multisite.
     33
    3134= 1.1.1 =
    3235* Change labels.
Note: See TracChangeset for help on using the changeset viewer.