Plugin Directory

Changeset 3184742


Ignore:
Timestamp:
11/09/2024 06:30:18 AM (16 months ago)
Author:
icelayer
Message:

Update to version 0.2.12 from GitHub

Location:
sim-site-maintenance
Files:
2 added
26 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sim-site-maintenance/tags/0.2.12/readme.txt

    r3128836 r3184742  
    66Tested up to: 6.6
    77Requires PHP: 7.3
    8 Stable tag: 0.2.11
     8Stable tag: 0.2.12
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • sim-site-maintenance/tags/0.2.12/sim-site-maintenance.php

    r3128836 r3184742  
    55 * Plugin URI:        https://urielwilson.com/
    66 * Description:       Puts the site in maintenance mode for all non-logged-in users.
    7  * Version:           0.2.11
     7 * Version:           0.2.12
    88 * Requires at least: 4.0
    99 * Requires PHP:      7.3
  • sim-site-maintenance/tags/0.2.12/src/SimSiteMaintenance/Plugin.php

    r3126660 r3184742  
    2626        $is_login_register_page = \in_array( $GLOBALS['pagenow'], [ 'wp-login.php', 'wp-register.php' ], true );
    2727
    28         if ( $is_login_register_page ) {
     28    if ( $is_login_register_page || current_user_can( 'manage_options' ) ) {
    2929            return;
    3030        }
  • sim-site-maintenance/tags/0.2.12/vendor/autoload.php

    r3128830 r3184742  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654::getLoader();
     25return ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e::getLoader();
  • sim-site-maintenance/tags/0.2.12/vendor/composer/autoload_classmap.php

    r3126660 r3184742  
    1111    'Urisoft\\AbstractPlugin' => $vendorDir . '/devuri/plugin-interface/src/AbstractPlugin.php',
    1212    'Urisoft\\PluginInterface' => $vendorDir . '/devuri/plugin-interface/src/PluginInterface.php',
     13    'Urisoft\\TraitInstalled' => $vendorDir . '/devuri/plugin-interface/src/TraitInstalled.php',
    1314);
  • sim-site-maintenance/tags/0.2.12/vendor/composer/autoload_real.php

    r3128830 r3184742  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654
     5class ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::getInitializer($loader));
    3333
    3434        $loader->setClassMapAuthoritative(true);
    3535        $loader->register(true);
    3636
    37         $filesToLoad = \Composer\Autoload\ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$files;
     37        $filesToLoad = \Composer\Autoload\ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$files;
    3838        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3939            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • sim-site-maintenance/tags/0.2.12/vendor/composer/autoload_static.php

    r3128830 r3184742  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654
     7class ComposerStaticInit2846a37ebf10948744cdaafff9badd1e
    88{
    99    public static $files = array (
     
    3838        'Urisoft\\AbstractPlugin' => __DIR__ . '/..' . '/devuri/plugin-interface/src/AbstractPlugin.php',
    3939        'Urisoft\\PluginInterface' => __DIR__ . '/..' . '/devuri/plugin-interface/src/PluginInterface.php',
     40        'Urisoft\\TraitInstalled' => __DIR__ . '/..' . '/devuri/plugin-interface/src/TraitInstalled.php',
    4041    );
    4142
     
    4344    {
    4445        return \Closure::bind(function () use ($loader) {
    45             $loader->prefixLengthsPsr4 = ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$prefixLengthsPsr4;
    46             $loader->prefixDirsPsr4 = ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$prefixDirsPsr4;
    47             $loader->classMap = ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$classMap;
     46            $loader->prefixLengthsPsr4 = ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$prefixLengthsPsr4;
     47            $loader->prefixDirsPsr4 = ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$prefixDirsPsr4;
     48            $loader->classMap = ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$classMap;
    4849
    4950        }, null, ClassLoader::class);
  • sim-site-maintenance/tags/0.2.12/vendor/composer/installed.json

    r3126660 r3184742  
    33        {
    44            "name": "devuri/plugin-interface",
    5             "version": "v0.2.0",
    6             "version_normalized": "0.2.0.0",
     5            "version": "0.2.2",
     6            "version_normalized": "0.2.2.0",
    77            "source": {
    88                "type": "git",
    99                "url": "https://github.com/devuri/plugin-interface.git",
    10                 "reference": "2bbd4d5e6fd60af077f86dc7070683c38b162a4d"
     10                "reference": "ea052f329287d261445f9849811dd045c280247c"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/devuri/plugin-interface/zipball/2bbd4d5e6fd60af077f86dc7070683c38b162a4d",
    15                 "reference": "2bbd4d5e6fd60af077f86dc7070683c38b162a4d",
     14                "url": "https://api.github.com/repos/devuri/plugin-interface/zipball/ea052f329287d261445f9849811dd045c280247c",
     15                "reference": "ea052f329287d261445f9849811dd045c280247c",
    1616                "shasum": ""
    1717            },
     
    2424                "phpstan/phpstan-strict-rules": "^1.3",
    2525                "phpunit/phpunit": "^9.5",
     26                "szepeviktor/phpstan-wordpress": "^1.3",
    2627                "vimeo/psalm": "^4.24 || ^5.0"
    2728            },
    28             "time": "2024-03-23T16:22:10+00:00",
     29            "time": "2024-10-30T13:04:52+00:00",
    2930            "type": "library",
    3031            "installation-source": "dist",
  • sim-site-maintenance/tags/0.2.12/vendor/composer/installed.php

    r3128836 r3184742  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '6947fc8893ad52863cb8e1ff3763922dd9415943',
     6        'reference' => '117f5948a51cb1391630b5eee9a4988caf724e08',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'devuri/plugin-interface' => array(
    14             'pretty_version' => 'v0.2.0',
    15             'version' => '0.2.0.0',
    16             'reference' => '2bbd4d5e6fd60af077f86dc7070683c38b162a4d',
     14            'pretty_version' => '0.2.2',
     15            'version' => '0.2.2.0',
     16            'reference' => 'ea052f329287d261445f9849811dd045c280247c',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../devuri/plugin-interface',
     
    2323            'pretty_version' => 'dev-main',
    2424            'version' => 'dev-main',
    25             'reference' => '6947fc8893ad52863cb8e1ff3763922dd9415943',
     25            'reference' => '117f5948a51cb1391630b5eee9a4988caf724e08',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
  • sim-site-maintenance/tags/0.2.12/vendor/devuri/plugin-interface/README.md

    r3126660 r3184742  
    22
    33A simple PHP interface designed to provide a consistent structure for WordPress plugins. It defines a set of methods that any implementing class must adhere to, ensuring uniformity and ease of use across different plugins.
    4 
    5 ## Table of Contents
    6 
    7 - [Installation](#installation)
    8 - [Usage](#usage)
    9   - [Implementing the Plugin Interface](#implementing-the-plugin-interface)
    10   - [Using the Plugin Interface](#using-the-plugin-interface)
    11 - [Example](#example)
    12 - [Benefits of the Interface](#benefits-of-the-interface)
    13 - [License](#license)
    144
    155## Installation
     
    8373```
    8474
    85 > Or you can also use the base abstract Implementation, which will includes `init()` and the required properties `$plugin_dir_path` and `$plugin_dir_url`
     75> Or you can also use the base abstract Implementation, which will include `init()` and the required properties `$plugin_dir_path` and `$plugin_dir_url`
    8676```php
    8777<?php
     
    143133> using `wp_plugin_dir_path()` and `plugin_dir_url()` to set the plugin path and URL provides a robust approach to plugin development.
    144134
     135
     136## TraitInstalled
     137
     138The `TraitInstalled` on `AbstractPlugin` provides utility methods to check if a WordPress plugin is installed and active. It helps manage plugin dependencies efficiently.
     139
     140- **Check if a plugin is installed**
     141- **Check if a plugin is active**
     142- **Retrieve all installed plugins**
     143
     144### 1. `MyPlugin::is_installed($plugin_file)`
     145
     146Checks if a plugin is installed.
     147
     148- **Parameter**: 
     149  `$plugin_file` (string) - Path to the plugin file, e.g., `'example-plugin/example-plugin.php'`.
     150
     151- **Returns**: 
     152  `bool` - `true` if installed, `false` otherwise.
     153
     154- **Example**:
     155    ```php
     156    if (MyPlugin::is_installed('example-plugin/example-plugin.php')) {
     157        echo 'Plugin is installed.';
     158    }
     159    ```
     160
     161### 2. `MyPlugin::is_active($plugin_file)`
     162
     163Checks if a plugin is active.
     164
     165- **Parameter**: 
     166  `$plugin_file` (string) - Path to the plugin file, e.g., `'example-plugin/example-plugin.php'`.
     167
     168- **Returns**: 
     169  `bool` - `true` if active, `false` otherwise.
     170
     171- **Example**:
     172    ```php
     173    if (MyPlugin::is_active('example-plugin/example-plugin.php')) {
     174        echo 'Plugin is active.';
     175    }
     176    ```
     177
     178### 3. `MyPlugin::get_installed_plugins()`
     179
     180Retrieves all installed plugins.
     181
     182- **Returns**: 
     183  `array` - An array of installed plugins.
     184
     185- **Example**:
     186    ```php
     187    $installed_plugins = MyPlugin::get_installed_plugins();
     188    print_r($installed_plugins);
     189    ```
     190
     191### Example Usage
     192
     193Check if a plugin is both installed and active:
     194
     195```php
     196function is_example_plugin_ready() {
     197    $plugin_file = 'example-plugin/example-plugin.php';
     198    return MyPlugin::is_installed($plugin_file) && MyPlugin::is_active($plugin_file);
     199}
     200
     201if (!is_example_plugin_ready()) {
     202    // Show admin notice or handle plugin dependency
     203}
     204```
     205
    145206## Benefits of the Interface
    146207
     
    157218- **Promotes Dependency Injection**: The `init()` method acts as a form of dependency injection, enabling clients to provide external dependencies (such as plugin directory path and URL) to the implementing class. This fosters decoupling and enhances flexibility and reusability.
    158219
    159 
    160220## License
    161221
  • sim-site-maintenance/tags/0.2.12/vendor/devuri/plugin-interface/composer.json

    r3126660 r3184742  
    3838        "phpstan/phpstan-strict-rules": "^1.3",
    3939        "phpunit/phpunit": "^9.5",
     40        "szepeviktor/phpstan-wordpress": "^1.3",
    4041        "vimeo/psalm": "^4.24 || ^5.0"
    4142    },
  • sim-site-maintenance/tags/0.2.12/vendor/devuri/plugin-interface/src/AbstractPlugin.php

    r3126660 r3184742  
    1515abstract class AbstractPlugin implements PluginInterface
    1616{
     17    use TraitInstalled;
     18
    1719    public static $plugin_dir_path;
    1820    public static $plugin_dir_url;
  • sim-site-maintenance/tags/0.2.12/vendor/devuri/plugin-interface/src/PluginInterface.php

    r3126660 r3184742  
    3939     * one instance of the plugin is created.
    4040     */
    41     public static function init( string $plugin_dir_path = '', string $plugin_dir_url = ''): PluginInterface;
     41    public static function init( string $plugin_dir_path = '', string $plugin_dir_url = ''): self;
    4242
    4343    /**
  • sim-site-maintenance/trunk/readme.txt

    r3128836 r3184742  
    66Tested up to: 6.6
    77Requires PHP: 7.3
    8 Stable tag: 0.2.11
     8Stable tag: 0.2.12
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • sim-site-maintenance/trunk/sim-site-maintenance.php

    r3128836 r3184742  
    55 * Plugin URI:        https://urielwilson.com/
    66 * Description:       Puts the site in maintenance mode for all non-logged-in users.
    7  * Version:           0.2.11
     7 * Version:           0.2.12
    88 * Requires at least: 4.0
    99 * Requires PHP:      7.3
  • sim-site-maintenance/trunk/src/SimSiteMaintenance/Plugin.php

    r3126660 r3184742  
    2626        $is_login_register_page = \in_array( $GLOBALS['pagenow'], [ 'wp-login.php', 'wp-register.php' ], true );
    2727
    28         if ( $is_login_register_page ) {
     28    if ( $is_login_register_page || current_user_can( 'manage_options' ) ) {
    2929            return;
    3030        }
  • sim-site-maintenance/trunk/vendor/autoload.php

    r3128830 r3184742  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654::getLoader();
     25return ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e::getLoader();
  • sim-site-maintenance/trunk/vendor/composer/autoload_classmap.php

    r3126660 r3184742  
    1111    'Urisoft\\AbstractPlugin' => $vendorDir . '/devuri/plugin-interface/src/AbstractPlugin.php',
    1212    'Urisoft\\PluginInterface' => $vendorDir . '/devuri/plugin-interface/src/PluginInterface.php',
     13    'Urisoft\\TraitInstalled' => $vendorDir . '/devuri/plugin-interface/src/TraitInstalled.php',
    1314);
  • sim-site-maintenance/trunk/vendor/composer/autoload_real.php

    r3128830 r3184742  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654
     5class ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitd6976cbd529e0f101b1b542f1c3a3654', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit2846a37ebf10948744cdaafff9badd1e', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::getInitializer($loader));
    3333
    3434        $loader->setClassMapAuthoritative(true);
    3535        $loader->register(true);
    3636
    37         $filesToLoad = \Composer\Autoload\ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$files;
     37        $filesToLoad = \Composer\Autoload\ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$files;
    3838        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3939            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • sim-site-maintenance/trunk/vendor/composer/autoload_static.php

    r3128830 r3184742  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654
     7class ComposerStaticInit2846a37ebf10948744cdaafff9badd1e
    88{
    99    public static $files = array (
     
    3838        'Urisoft\\AbstractPlugin' => __DIR__ . '/..' . '/devuri/plugin-interface/src/AbstractPlugin.php',
    3939        'Urisoft\\PluginInterface' => __DIR__ . '/..' . '/devuri/plugin-interface/src/PluginInterface.php',
     40        'Urisoft\\TraitInstalled' => __DIR__ . '/..' . '/devuri/plugin-interface/src/TraitInstalled.php',
    4041    );
    4142
     
    4344    {
    4445        return \Closure::bind(function () use ($loader) {
    45             $loader->prefixLengthsPsr4 = ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$prefixLengthsPsr4;
    46             $loader->prefixDirsPsr4 = ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$prefixDirsPsr4;
    47             $loader->classMap = ComposerStaticInitd6976cbd529e0f101b1b542f1c3a3654::$classMap;
     46            $loader->prefixLengthsPsr4 = ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$prefixLengthsPsr4;
     47            $loader->prefixDirsPsr4 = ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$prefixDirsPsr4;
     48            $loader->classMap = ComposerStaticInit2846a37ebf10948744cdaafff9badd1e::$classMap;
    4849
    4950        }, null, ClassLoader::class);
  • sim-site-maintenance/trunk/vendor/composer/installed.json

    r3126660 r3184742  
    33        {
    44            "name": "devuri/plugin-interface",
    5             "version": "v0.2.0",
    6             "version_normalized": "0.2.0.0",
     5            "version": "0.2.2",
     6            "version_normalized": "0.2.2.0",
    77            "source": {
    88                "type": "git",
    99                "url": "https://github.com/devuri/plugin-interface.git",
    10                 "reference": "2bbd4d5e6fd60af077f86dc7070683c38b162a4d"
     10                "reference": "ea052f329287d261445f9849811dd045c280247c"
    1111            },
    1212            "dist": {
    1313                "type": "zip",
    14                 "url": "https://api.github.com/repos/devuri/plugin-interface/zipball/2bbd4d5e6fd60af077f86dc7070683c38b162a4d",
    15                 "reference": "2bbd4d5e6fd60af077f86dc7070683c38b162a4d",
     14                "url": "https://api.github.com/repos/devuri/plugin-interface/zipball/ea052f329287d261445f9849811dd045c280247c",
     15                "reference": "ea052f329287d261445f9849811dd045c280247c",
    1616                "shasum": ""
    1717            },
     
    2424                "phpstan/phpstan-strict-rules": "^1.3",
    2525                "phpunit/phpunit": "^9.5",
     26                "szepeviktor/phpstan-wordpress": "^1.3",
    2627                "vimeo/psalm": "^4.24 || ^5.0"
    2728            },
    28             "time": "2024-03-23T16:22:10+00:00",
     29            "time": "2024-10-30T13:04:52+00:00",
    2930            "type": "library",
    3031            "installation-source": "dist",
  • sim-site-maintenance/trunk/vendor/composer/installed.php

    r3128836 r3184742  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => '6947fc8893ad52863cb8e1ff3763922dd9415943',
     6        'reference' => '117f5948a51cb1391630b5eee9a4988caf724e08',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'devuri/plugin-interface' => array(
    14             'pretty_version' => 'v0.2.0',
    15             'version' => '0.2.0.0',
    16             'reference' => '2bbd4d5e6fd60af077f86dc7070683c38b162a4d',
     14            'pretty_version' => '0.2.2',
     15            'version' => '0.2.2.0',
     16            'reference' => 'ea052f329287d261445f9849811dd045c280247c',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../devuri/plugin-interface',
     
    2323            'pretty_version' => 'dev-main',
    2424            'version' => 'dev-main',
    25             'reference' => '6947fc8893ad52863cb8e1ff3763922dd9415943',
     25            'reference' => '117f5948a51cb1391630b5eee9a4988caf724e08',
    2626            'type' => 'wordpress-plugin',
    2727            'install_path' => __DIR__ . '/../../',
  • sim-site-maintenance/trunk/vendor/devuri/plugin-interface/README.md

    r3126660 r3184742  
    22
    33A simple PHP interface designed to provide a consistent structure for WordPress plugins. It defines a set of methods that any implementing class must adhere to, ensuring uniformity and ease of use across different plugins.
    4 
    5 ## Table of Contents
    6 
    7 - [Installation](#installation)
    8 - [Usage](#usage)
    9   - [Implementing the Plugin Interface](#implementing-the-plugin-interface)
    10   - [Using the Plugin Interface](#using-the-plugin-interface)
    11 - [Example](#example)
    12 - [Benefits of the Interface](#benefits-of-the-interface)
    13 - [License](#license)
    144
    155## Installation
     
    8373```
    8474
    85 > Or you can also use the base abstract Implementation, which will includes `init()` and the required properties `$plugin_dir_path` and `$plugin_dir_url`
     75> Or you can also use the base abstract Implementation, which will include `init()` and the required properties `$plugin_dir_path` and `$plugin_dir_url`
    8676```php
    8777<?php
     
    143133> using `wp_plugin_dir_path()` and `plugin_dir_url()` to set the plugin path and URL provides a robust approach to plugin development.
    144134
     135
     136## TraitInstalled
     137
     138The `TraitInstalled` on `AbstractPlugin` provides utility methods to check if a WordPress plugin is installed and active. It helps manage plugin dependencies efficiently.
     139
     140- **Check if a plugin is installed**
     141- **Check if a plugin is active**
     142- **Retrieve all installed plugins**
     143
     144### 1. `MyPlugin::is_installed($plugin_file)`
     145
     146Checks if a plugin is installed.
     147
     148- **Parameter**: 
     149  `$plugin_file` (string) - Path to the plugin file, e.g., `'example-plugin/example-plugin.php'`.
     150
     151- **Returns**: 
     152  `bool` - `true` if installed, `false` otherwise.
     153
     154- **Example**:
     155    ```php
     156    if (MyPlugin::is_installed('example-plugin/example-plugin.php')) {
     157        echo 'Plugin is installed.';
     158    }
     159    ```
     160
     161### 2. `MyPlugin::is_active($plugin_file)`
     162
     163Checks if a plugin is active.
     164
     165- **Parameter**: 
     166  `$plugin_file` (string) - Path to the plugin file, e.g., `'example-plugin/example-plugin.php'`.
     167
     168- **Returns**: 
     169  `bool` - `true` if active, `false` otherwise.
     170
     171- **Example**:
     172    ```php
     173    if (MyPlugin::is_active('example-plugin/example-plugin.php')) {
     174        echo 'Plugin is active.';
     175    }
     176    ```
     177
     178### 3. `MyPlugin::get_installed_plugins()`
     179
     180Retrieves all installed plugins.
     181
     182- **Returns**: 
     183  `array` - An array of installed plugins.
     184
     185- **Example**:
     186    ```php
     187    $installed_plugins = MyPlugin::get_installed_plugins();
     188    print_r($installed_plugins);
     189    ```
     190
     191### Example Usage
     192
     193Check if a plugin is both installed and active:
     194
     195```php
     196function is_example_plugin_ready() {
     197    $plugin_file = 'example-plugin/example-plugin.php';
     198    return MyPlugin::is_installed($plugin_file) && MyPlugin::is_active($plugin_file);
     199}
     200
     201if (!is_example_plugin_ready()) {
     202    // Show admin notice or handle plugin dependency
     203}
     204```
     205
    145206## Benefits of the Interface
    146207
     
    157218- **Promotes Dependency Injection**: The `init()` method acts as a form of dependency injection, enabling clients to provide external dependencies (such as plugin directory path and URL) to the implementing class. This fosters decoupling and enhances flexibility and reusability.
    158219
    159 
    160220## License
    161221
  • sim-site-maintenance/trunk/vendor/devuri/plugin-interface/composer.json

    r3126660 r3184742  
    3838        "phpstan/phpstan-strict-rules": "^1.3",
    3939        "phpunit/phpunit": "^9.5",
     40        "szepeviktor/phpstan-wordpress": "^1.3",
    4041        "vimeo/psalm": "^4.24 || ^5.0"
    4142    },
  • sim-site-maintenance/trunk/vendor/devuri/plugin-interface/src/AbstractPlugin.php

    r3126660 r3184742  
    1515abstract class AbstractPlugin implements PluginInterface
    1616{
     17    use TraitInstalled;
     18
    1719    public static $plugin_dir_path;
    1820    public static $plugin_dir_url;
  • sim-site-maintenance/trunk/vendor/devuri/plugin-interface/src/PluginInterface.php

    r3126660 r3184742  
    3939     * one instance of the plugin is created.
    4040     */
    41     public static function init( string $plugin_dir_path = '', string $plugin_dir_url = ''): PluginInterface;
     41    public static function init( string $plugin_dir_path = '', string $plugin_dir_url = ''): self;
    4242
    4343    /**
Note: See TracChangeset for help on using the changeset viewer.