Plugin Directory

Changeset 2695407


Ignore:
Timestamp:
03/17/2022 01:21:41 PM (4 years ago)
Author:
wearerequired
Message:

Update to version 2.1.0 from GitHub

Location:
wp-widget-disable
Files:
6 added
4 deleted
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-widget-disable/tags/2.1.0/CHANGELOG.md

    r2237194 r2695407  
    44The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
    55and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     6
     7### [2.1.0] - 2022-03-17
     8
     9* Enhancement: Hide disbaled sidebar widgets when widget block editor is enabled.
     10* Changed: Requires at least PHP 5.6 and WordPress 4.7.
    611
    712## [2.0.0] - 2020-02-02
     
    8085
    8186[Unreleased]: https://github.com/wearerequired/WP-Widget-Disable/compare/2.0.0...master
     87[2.1.0]: https://github.com/wearerequired/WP-Widget-Disable/compare/2.0.0...2.1.0
    8288[2.0.0]: https://github.com/wearerequired/WP-Widget-Disable/compare/1.9.0...2.0.0
    8389[1.9.1]: https://github.com/wearerequired/WP-Widget-Disable/compare/1.9.0...1.9.1
  • wp-widget-disable/tags/2.1.0/classes/class-wp-widget-disable.php

    r2237194 r2695407  
    22/**
    33 * Holds the main plugin class.
    4  *
    5  * @package WP_Widget_Disable
    64 */
    75
     
    1311     * Plugin version.
    1412     */
    15     const VERSION = '2.0.0';
     13    const VERSION = '2.1.0';
    1614
    1715    /**
     
    242240     *
    243241     * @param array $links Plugin action links.
    244      *
    245242     * @return array
    246243     */
     
    447444     *
    448445     * @param array $input Sidebar widgets to disable.
    449      *
    450446     * @return array
    451447     */
     
    508504     *
    509505     * @param array $input Dashboards widgets to disable.
    510      *
    511506     * @return array
    512507     */
     
    638633        }
    639634
    640         $options = (array) get_option( $this->sidebar_widgets_option, [] );
     635        $options                  = (array) get_option( $this->sidebar_widgets_option, [] );
     636        $widgets_to_hide          = $this->get_widgets_to_hide_from_legacy_widget_block();
     637        $use_widgets_block_editor = $this->use_widgets_block_editor();
    641638
    642639        foreach ( $widgets as $id => $widget_object ) {
     640            // Hide widgets if widgets block is enabled.
     641            if ( $use_widgets_block_editor && in_array( $widget_object->id_base, $widgets_to_hide, true ) ) {
     642                continue;
     643            }
    643644            printf(
    644645                '<p><input type="checkbox" id="%1$s" name="%2$s" value="disabled" %3$s> <label for="%1$s">%4$s</label></p>',
     
    797798        <?php
    798799    }
     800
     801    /**
     802     * Check if block editor is enabled for widgets.
     803     *
     804     * @return bool
     805     */
     806    public function use_widgets_block_editor() {
     807        if ( function_exists( 'wp_use_widgets_block_editor' ) ) {
     808            return wp_use_widgets_block_editor();
     809        }
     810        return false;
     811    }
     812
     813    /**
     814     * Get list of widgets to hide from legacy widget block.
     815     *
     816     * @return array
     817     */
     818    public function get_widgets_to_hide_from_legacy_widget_block() {
     819        if ( function_exists( 'get_legacy_widget_block_editor_settings' ) ) {
     820            return get_legacy_widget_block_editor_settings()['widgetTypesToHideFromLegacyWidgetBlock'];
     821        }
     822        return [];
     823    }
    799824}
  • wp-widget-disable/tags/2.1.0/vendor/autoload.php

    r2237194 r2695407  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82::getLoader();
     7return ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597::getLoader();
  • wp-widget-disable/tags/2.1.0/vendor/composer/ClassLoader.php

    r2048125 r2695407  
    3838 * @author Fabien Potencier <fabien@symfony.com>
    3939 * @author Jordi Boggiano <j.boggiano@seld.be>
    40  * @see    http://www.php-fig.org/psr/psr-0/
    41  * @see    http://www.php-fig.org/psr/psr-4/
     40 * @see    https://www.php-fig.org/psr/psr-0/
     41 * @see    https://www.php-fig.org/psr/psr-4/
    4242 */
    4343class ClassLoader
    4444{
     45    /** @var ?string */
     46    private $vendorDir;
     47
    4548    // PSR-4
     49    /**
     50     * @var array[]
     51     * @psalm-var array<string, array<string, int>>
     52     */
    4653    private $prefixLengthsPsr4 = array();
     54    /**
     55     * @var array[]
     56     * @psalm-var array<string, array<int, string>>
     57     */
    4758    private $prefixDirsPsr4 = array();
     59    /**
     60     * @var array[]
     61     * @psalm-var array<string, string>
     62     */
    4863    private $fallbackDirsPsr4 = array();
    4964
    5065    // PSR-0
     66    /**
     67     * @var array[]
     68     * @psalm-var array<string, array<string, string[]>>
     69     */
    5170    private $prefixesPsr0 = array();
     71    /**
     72     * @var array[]
     73     * @psalm-var array<string, string>
     74     */
    5275    private $fallbackDirsPsr0 = array();
    5376
     77    /** @var bool */
    5478    private $useIncludePath = false;
     79
     80    /**
     81     * @var string[]
     82     * @psalm-var array<string, string>
     83     */
    5584    private $classMap = array();
     85
     86    /** @var bool */
    5687    private $classMapAuthoritative = false;
     88
     89    /**
     90     * @var bool[]
     91     * @psalm-var array<string, bool>
     92     */
    5793    private $missingClasses = array();
     94
     95    /** @var ?string */
    5896    private $apcuPrefix;
    5997
     98    /**
     99     * @var self[]
     100     */
     101    private static $registeredLoaders = array();
     102
     103    /**
     104     * @param ?string $vendorDir
     105     */
     106    public function __construct($vendorDir = null)
     107    {
     108        $this->vendorDir = $vendorDir;
     109    }
     110
     111    /**
     112     * @return string[]
     113     */
    60114    public function getPrefixes()
    61115    {
    62116        if (!empty($this->prefixesPsr0)) {
    63             return call_user_func_array('array_merge', $this->prefixesPsr0);
     117            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
    64118        }
    65119
     
    67121    }
    68122
     123    /**
     124     * @return array[]
     125     * @psalm-return array<string, array<int, string>>
     126     */
    69127    public function getPrefixesPsr4()
    70128    {
     
    72130    }
    73131
     132    /**
     133     * @return array[]
     134     * @psalm-return array<string, string>
     135     */
    74136    public function getFallbackDirs()
    75137    {
     
    77139    }
    78140
     141    /**
     142     * @return array[]
     143     * @psalm-return array<string, string>
     144     */
    79145    public function getFallbackDirsPsr4()
    80146    {
     
    82148    }
    83149
     150    /**
     151     * @return string[] Array of classname => path
     152     * @psalm-return array<string, string>
     153     */
    84154    public function getClassMap()
    85155    {
     
    88158
    89159    /**
    90      * @param array $classMap Class to filename map
     160     * @param string[] $classMap Class to filename map
     161     * @psalm-param array<string, string> $classMap
     162     *
     163     * @return void
    91164     */
    92165    public function addClassMap(array $classMap)
     
    103176     * appending or prepending to the ones previously set for this prefix.
    104177     *
    105      * @param string       $prefix  The prefix
    106      * @param array|string $paths   The PSR-0 root directories
    107      * @param bool         $prepend Whether to prepend the directories
     178     * @param string          $prefix  The prefix
     179     * @param string[]|string $paths   The PSR-0 root directories
     180     * @param bool            $prepend Whether to prepend the directories
     181     *
     182     * @return void
    108183     */
    109184    public function add($prefix, $paths, $prepend = false)
     
    148223     * appending or prepending to the ones previously set for this namespace.
    149224     *
    150      * @param string       $prefix  The prefix/namespace, with trailing '\\'
    151      * @param array|string $paths   The PSR-4 base directories
    152      * @param bool         $prepend Whether to prepend the directories
     225     * @param string          $prefix  The prefix/namespace, with trailing '\\'
     226     * @param string[]|string $paths   The PSR-4 base directories
     227     * @param bool            $prepend Whether to prepend the directories
    153228     *
    154229     * @throws \InvalidArgumentException
     230     *
     231     * @return void
    155232     */
    156233    public function addPsr4($prefix, $paths, $prepend = false)
     
    196273     * replacing any others previously set for this prefix.
    197274     *
    198      * @param string       $prefix The prefix
    199      * @param array|string $paths  The PSR-0 base directories
     275     * @param string          $prefix The prefix
     276     * @param string[]|string $paths  The PSR-0 base directories
     277     *
     278     * @return void
    200279     */
    201280    public function set($prefix, $paths)
     
    212291     * replacing any others previously set for this namespace.
    213292     *
    214      * @param string       $prefix The prefix/namespace, with trailing '\\'
    215      * @param array|string $paths  The PSR-4 base directories
     293     * @param string          $prefix The prefix/namespace, with trailing '\\'
     294     * @param string[]|string $paths  The PSR-4 base directories
    216295     *
    217296     * @throws \InvalidArgumentException
     297     *
     298     * @return void
    218299     */
    219300    public function setPsr4($prefix, $paths)
     
    235316     *
    236317     * @param bool $useIncludePath
     318     *
     319     * @return void
    237320     */
    238321    public function setUseIncludePath($useIncludePath)
     
    257340     *
    258341     * @param bool $classMapAuthoritative
     342     *
     343     * @return void
    259344     */
    260345    public function setClassMapAuthoritative($classMapAuthoritative)
     
    277362     *
    278363     * @param string|null $apcuPrefix
     364     *
     365     * @return void
    279366     */
    280367    public function setApcuPrefix($apcuPrefix)
     
    297384     *
    298385     * @param bool $prepend Whether to prepend the autoloader or not
     386     *
     387     * @return void
    299388     */
    300389    public function register($prepend = false)
    301390    {
    302391        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
     392
     393        if (null === $this->vendorDir) {
     394            return;
     395        }
     396
     397        if ($prepend) {
     398            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
     399        } else {
     400            unset(self::$registeredLoaders[$this->vendorDir]);
     401            self::$registeredLoaders[$this->vendorDir] = $this;
     402        }
    303403    }
    304404
    305405    /**
    306406     * Unregisters this instance as an autoloader.
     407     *
     408     * @return void
    307409     */
    308410    public function unregister()
    309411    {
    310412        spl_autoload_unregister(array($this, 'loadClass'));
     413
     414        if (null !== $this->vendorDir) {
     415            unset(self::$registeredLoaders[$this->vendorDir]);
     416        }
    311417    }
    312418
     
    315421     *
    316422     * @param  string    $class The name of the class
    317      * @return bool|null True if loaded, null otherwise
     423     * @return true|null True if loaded, null otherwise
    318424     */
    319425    public function loadClass($class)
     
    324430            return true;
    325431        }
     432
     433        return null;
    326434    }
    327435
     
    368476    }
    369477
     478    /**
     479     * Returns the currently registered loaders indexed by their corresponding vendor directories.
     480     *
     481     * @return self[]
     482     */
     483    public static function getRegisteredLoaders()
     484    {
     485        return self::$registeredLoaders;
     486    }
     487
     488    /**
     489     * @param  string       $class
     490     * @param  string       $ext
     491     * @return string|false
     492     */
    370493    private function findFileWithExtension($class, $ext)
    371494    {
     
    439562 *
    440563 * Prevents access to $this/self from included files.
     564 *
     565 * @param  string $file
     566 * @return void
     567 * @private
    441568 */
    442569function includeFile($file)
  • wp-widget-disable/tags/2.1.0/vendor/composer/autoload_classmap.php

    r1487873 r2695407  
    77
    88return array(
     9    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    910    'WP_Requirements_Check' => $vendorDir . '/wearerequired/wp-requirements-check/WP_Requirements_Check.php',
    1011);
  • wp-widget-disable/tags/2.1.0/vendor/composer/autoload_real.php

    r2237194 r2695407  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82
     5class ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597
    66{
    77    private static $loader;
     
    1414    }
    1515
     16    /**
     17     * @return \Composer\Autoload\ClassLoader
     18     */
    1619    public static function getLoader()
    1720    {
     
    2023        }
    2124
    22         spl_autoload_register(array('ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82', 'loadClassLoader'), true, true);
    23         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82', 'loadClassLoader'));
     25        require __DIR__ . '/platform_check.php';
     26
     27        spl_autoload_register(array('ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597', 'loadClassLoader'), true, true);
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597', 'loadClassLoader'));
    2530
    2631        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    2732        if ($useStaticLoader) {
    28             require_once __DIR__ . '/autoload_static.php';
     33            require __DIR__ . '/autoload_static.php';
    2934
    30             call_user_func(\Composer\Autoload\ComposerStaticInit3b2a2c909c6199de140597783e388f82::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit914942eb63a3b2b6fe068eb2b363a597::getInitializer($loader));
    3136        } else {
    3237            $map = require __DIR__ . '/autoload_namespaces.php';
  • wp-widget-disable/tags/2.1.0/vendor/composer/autoload_static.php

    r2237194 r2695407  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit3b2a2c909c6199de140597783e388f82
     7class ComposerStaticInit914942eb63a3b2b6fe068eb2b363a597
    88{
    99    public static $classMap = array (
     10        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
    1011        'WP_Requirements_Check' => __DIR__ . '/..' . '/wearerequired/wp-requirements-check/WP_Requirements_Check.php',
    1112    );
     
    1415    {
    1516        return \Closure::bind(function () use ($loader) {
    16             $loader->classMap = ComposerStaticInit3b2a2c909c6199de140597783e388f82::$classMap;
     17            $loader->classMap = ComposerStaticInit914942eb63a3b2b6fe068eb2b363a597::$classMap;
    1718
    1819        }, null, ClassLoader::class);
  • wp-widget-disable/tags/2.1.0/vendor/composer/installed.json

    r2048125 r2695407  
    1 [
    2     {
    3         "name": "wearerequired/wp-requirements-check",
    4         "version": "1.1.0",
    5         "version_normalized": "1.1.0.0",
    6         "source": {
    7             "type": "git",
    8             "url": "https://github.com/wearerequired/wp-requirements-check.git",
    9             "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812"
    10         },
    11         "dist": {
    12             "type": "zip",
    13             "url": "https://api.github.com/repos/wearerequired/wp-requirements-check/zipball/82b8a6c4b953f59e7e534df2d4287e34af950812",
    14             "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812",
    15             "shasum": ""
    16         },
    17         "time": "2019-03-11T11:11:33+00:00",
    18         "type": "library",
    19         "installation-source": "dist",
    20         "autoload": {
    21             "classmap": [
    22                 "WP_Requirements_Check.php"
    23             ]
    24         },
    25         "notification-url": "https://packagist.org/downloads/",
    26         "license": [
    27             "GPL-2.0+"
    28         ],
    29         "authors": [
    30             {
    31                 "name": "Pascal Birchler",
    32                 "email": "pascal@required.ch",
    33                 "role": "Developer"
     1{
     2    "packages": [
     3        {
     4            "name": "wearerequired/wp-requirements-check",
     5            "version": "1.1.0",
     6            "version_normalized": "1.1.0.0",
     7            "source": {
     8                "type": "git",
     9                "url": "https://github.com/wearerequired/wp-requirements-check.git",
     10                "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812"
    3411            },
    35             {
    36                 "name": "required",
    37                 "email": "support@required.ch",
    38                 "homepage": "https://required.com",
    39                 "role": "Company"
     12            "dist": {
     13                "type": "zip",
     14                "url": "https://api.github.com/repos/wearerequired/wp-requirements-check/zipball/82b8a6c4b953f59e7e534df2d4287e34af950812",
     15                "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812",
     16                "shasum": ""
    4017            },
    41             {
    42                 "name": "Ulrich Pogson",
    43                 "email": "ulrich@required.ch",
    44                 "role": "Developer"
    45             }
    46         ],
    47         "description": "Simple requirements checking class",
    48         "keywords": [
    49             "requirements",
    50             "wordpress"
    51         ]
    52     }
    53 ]
     18            "time": "2019-03-11T11:11:33+00:00",
     19            "type": "library",
     20            "installation-source": "dist",
     21            "autoload": {
     22                "classmap": [
     23                    "WP_Requirements_Check.php"
     24                ]
     25            },
     26            "notification-url": "https://packagist.org/downloads/",
     27            "license": [
     28                "GPL-2.0+"
     29            ],
     30            "authors": [
     31                {
     32                    "name": "Pascal Birchler",
     33                    "email": "pascal@required.ch",
     34                    "role": "Developer"
     35                },
     36                {
     37                    "name": "required",
     38                    "email": "support@required.ch",
     39                    "homepage": "https://required.com",
     40                    "role": "Company"
     41                },
     42                {
     43                    "name": "Ulrich Pogson",
     44                    "email": "ulrich@required.ch",
     45                    "role": "Developer"
     46                }
     47            ],
     48            "description": "Simple requirements checking class",
     49            "keywords": [
     50                "requirements",
     51                "wordpress"
     52            ],
     53            "support": {
     54                "issues": "https://github.com/wearerequired/wp-requirements-check/issues",
     55                "source": "https://github.com/wearerequired/wp-requirements-check/tree/master"
     56            },
     57            "install-path": "../wearerequired/wp-requirements-check"
     58        }
     59    ],
     60    "dev": false,
     61    "dev-package-names": []
     62}
  • wp-widget-disable/tags/2.1.0/wp-widget-disable.php

    r2237194 r2695407  
    44 * Plugin URI:  https://required.com/services/wordpress-plugins/wp-widget-disable/
    55 * Description: Disable sidebar and dashboard widgets with an easy to use interface. Simply use the checkboxes provided under <strong>Appearance -> Disable Widgets</strong> and select the widgets you'd like to hide.
    6  * Version:     2.0.0
     6 * Version:     2.1.0
    77 * Author:      required
    88 * Author URI:  https://required.com
     
    1010 * Text Domain: wp-widget-disable
    1111 *
    12  * Copyright (c) 2015-2020 required (email: support@required.ch)
     12 * Copyright (c) 2015-2022 required (email: support@required.ch)
    1313 *
    1414 * This program is free software; you can redistribute it and/or modify
     
    2525 * along with this program; if not, write to the Free Software
    2626 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    27  *
    28  * @package WP_Widget_Disable
    2927 */
    3028
     
    3937    array(
    4038        'title' => 'WP Widget Disable',
    41         'php'   => '5.4',
    42         'wp'    => '4.0',
     39        'php'   => '5.6',
     40        'wp'    => '4.7',
    4341        'file'  => __FILE__,
    4442    )
  • wp-widget-disable/trunk/CHANGELOG.md

    r2237194 r2695407  
    44The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
    55and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     6
     7### [2.1.0] - 2022-03-17
     8
     9* Enhancement: Hide disbaled sidebar widgets when widget block editor is enabled.
     10* Changed: Requires at least PHP 5.6 and WordPress 4.7.
    611
    712## [2.0.0] - 2020-02-02
     
    8085
    8186[Unreleased]: https://github.com/wearerequired/WP-Widget-Disable/compare/2.0.0...master
     87[2.1.0]: https://github.com/wearerequired/WP-Widget-Disable/compare/2.0.0...2.1.0
    8288[2.0.0]: https://github.com/wearerequired/WP-Widget-Disable/compare/1.9.0...2.0.0
    8389[1.9.1]: https://github.com/wearerequired/WP-Widget-Disable/compare/1.9.0...1.9.1
  • wp-widget-disable/trunk/classes/class-wp-widget-disable.php

    r2237194 r2695407  
    22/**
    33 * Holds the main plugin class.
    4  *
    5  * @package WP_Widget_Disable
    64 */
    75
     
    1311     * Plugin version.
    1412     */
    15     const VERSION = '2.0.0';
     13    const VERSION = '2.1.0';
    1614
    1715    /**
     
    242240     *
    243241     * @param array $links Plugin action links.
    244      *
    245242     * @return array
    246243     */
     
    447444     *
    448445     * @param array $input Sidebar widgets to disable.
    449      *
    450446     * @return array
    451447     */
     
    508504     *
    509505     * @param array $input Dashboards widgets to disable.
    510      *
    511506     * @return array
    512507     */
     
    638633        }
    639634
    640         $options = (array) get_option( $this->sidebar_widgets_option, [] );
     635        $options                  = (array) get_option( $this->sidebar_widgets_option, [] );
     636        $widgets_to_hide          = $this->get_widgets_to_hide_from_legacy_widget_block();
     637        $use_widgets_block_editor = $this->use_widgets_block_editor();
    641638
    642639        foreach ( $widgets as $id => $widget_object ) {
     640            // Hide widgets if widgets block is enabled.
     641            if ( $use_widgets_block_editor && in_array( $widget_object->id_base, $widgets_to_hide, true ) ) {
     642                continue;
     643            }
    643644            printf(
    644645                '<p><input type="checkbox" id="%1$s" name="%2$s" value="disabled" %3$s> <label for="%1$s">%4$s</label></p>',
     
    797798        <?php
    798799    }
     800
     801    /**
     802     * Check if block editor is enabled for widgets.
     803     *
     804     * @return bool
     805     */
     806    public function use_widgets_block_editor() {
     807        if ( function_exists( 'wp_use_widgets_block_editor' ) ) {
     808            return wp_use_widgets_block_editor();
     809        }
     810        return false;
     811    }
     812
     813    /**
     814     * Get list of widgets to hide from legacy widget block.
     815     *
     816     * @return array
     817     */
     818    public function get_widgets_to_hide_from_legacy_widget_block() {
     819        if ( function_exists( 'get_legacy_widget_block_editor_settings' ) ) {
     820            return get_legacy_widget_block_editor_settings()['widgetTypesToHideFromLegacyWidgetBlock'];
     821        }
     822        return [];
     823    }
    799824}
  • wp-widget-disable/trunk/vendor/autoload.php

    r2237194 r2695407  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82::getLoader();
     7return ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597::getLoader();
  • wp-widget-disable/trunk/vendor/composer/ClassLoader.php

    r2048125 r2695407  
    3838 * @author Fabien Potencier <fabien@symfony.com>
    3939 * @author Jordi Boggiano <j.boggiano@seld.be>
    40  * @see    http://www.php-fig.org/psr/psr-0/
    41  * @see    http://www.php-fig.org/psr/psr-4/
     40 * @see    https://www.php-fig.org/psr/psr-0/
     41 * @see    https://www.php-fig.org/psr/psr-4/
    4242 */
    4343class ClassLoader
    4444{
     45    /** @var ?string */
     46    private $vendorDir;
     47
    4548    // PSR-4
     49    /**
     50     * @var array[]
     51     * @psalm-var array<string, array<string, int>>
     52     */
    4653    private $prefixLengthsPsr4 = array();
     54    /**
     55     * @var array[]
     56     * @psalm-var array<string, array<int, string>>
     57     */
    4758    private $prefixDirsPsr4 = array();
     59    /**
     60     * @var array[]
     61     * @psalm-var array<string, string>
     62     */
    4863    private $fallbackDirsPsr4 = array();
    4964
    5065    // PSR-0
     66    /**
     67     * @var array[]
     68     * @psalm-var array<string, array<string, string[]>>
     69     */
    5170    private $prefixesPsr0 = array();
     71    /**
     72     * @var array[]
     73     * @psalm-var array<string, string>
     74     */
    5275    private $fallbackDirsPsr0 = array();
    5376
     77    /** @var bool */
    5478    private $useIncludePath = false;
     79
     80    /**
     81     * @var string[]
     82     * @psalm-var array<string, string>
     83     */
    5584    private $classMap = array();
     85
     86    /** @var bool */
    5687    private $classMapAuthoritative = false;
     88
     89    /**
     90     * @var bool[]
     91     * @psalm-var array<string, bool>
     92     */
    5793    private $missingClasses = array();
     94
     95    /** @var ?string */
    5896    private $apcuPrefix;
    5997
     98    /**
     99     * @var self[]
     100     */
     101    private static $registeredLoaders = array();
     102
     103    /**
     104     * @param ?string $vendorDir
     105     */
     106    public function __construct($vendorDir = null)
     107    {
     108        $this->vendorDir = $vendorDir;
     109    }
     110
     111    /**
     112     * @return string[]
     113     */
    60114    public function getPrefixes()
    61115    {
    62116        if (!empty($this->prefixesPsr0)) {
    63             return call_user_func_array('array_merge', $this->prefixesPsr0);
     117            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
    64118        }
    65119
     
    67121    }
    68122
     123    /**
     124     * @return array[]
     125     * @psalm-return array<string, array<int, string>>
     126     */
    69127    public function getPrefixesPsr4()
    70128    {
     
    72130    }
    73131
     132    /**
     133     * @return array[]
     134     * @psalm-return array<string, string>
     135     */
    74136    public function getFallbackDirs()
    75137    {
     
    77139    }
    78140
     141    /**
     142     * @return array[]
     143     * @psalm-return array<string, string>
     144     */
    79145    public function getFallbackDirsPsr4()
    80146    {
     
    82148    }
    83149
     150    /**
     151     * @return string[] Array of classname => path
     152     * @psalm-return array<string, string>
     153     */
    84154    public function getClassMap()
    85155    {
     
    88158
    89159    /**
    90      * @param array $classMap Class to filename map
     160     * @param string[] $classMap Class to filename map
     161     * @psalm-param array<string, string> $classMap
     162     *
     163     * @return void
    91164     */
    92165    public function addClassMap(array $classMap)
     
    103176     * appending or prepending to the ones previously set for this prefix.
    104177     *
    105      * @param string       $prefix  The prefix
    106      * @param array|string $paths   The PSR-0 root directories
    107      * @param bool         $prepend Whether to prepend the directories
     178     * @param string          $prefix  The prefix
     179     * @param string[]|string $paths   The PSR-0 root directories
     180     * @param bool            $prepend Whether to prepend the directories
     181     *
     182     * @return void
    108183     */
    109184    public function add($prefix, $paths, $prepend = false)
     
    148223     * appending or prepending to the ones previously set for this namespace.
    149224     *
    150      * @param string       $prefix  The prefix/namespace, with trailing '\\'
    151      * @param array|string $paths   The PSR-4 base directories
    152      * @param bool         $prepend Whether to prepend the directories
     225     * @param string          $prefix  The prefix/namespace, with trailing '\\'
     226     * @param string[]|string $paths   The PSR-4 base directories
     227     * @param bool            $prepend Whether to prepend the directories
    153228     *
    154229     * @throws \InvalidArgumentException
     230     *
     231     * @return void
    155232     */
    156233    public function addPsr4($prefix, $paths, $prepend = false)
     
    196273     * replacing any others previously set for this prefix.
    197274     *
    198      * @param string       $prefix The prefix
    199      * @param array|string $paths  The PSR-0 base directories
     275     * @param string          $prefix The prefix
     276     * @param string[]|string $paths  The PSR-0 base directories
     277     *
     278     * @return void
    200279     */
    201280    public function set($prefix, $paths)
     
    212291     * replacing any others previously set for this namespace.
    213292     *
    214      * @param string       $prefix The prefix/namespace, with trailing '\\'
    215      * @param array|string $paths  The PSR-4 base directories
     293     * @param string          $prefix The prefix/namespace, with trailing '\\'
     294     * @param string[]|string $paths  The PSR-4 base directories
    216295     *
    217296     * @throws \InvalidArgumentException
     297     *
     298     * @return void
    218299     */
    219300    public function setPsr4($prefix, $paths)
     
    235316     *
    236317     * @param bool $useIncludePath
     318     *
     319     * @return void
    237320     */
    238321    public function setUseIncludePath($useIncludePath)
     
    257340     *
    258341     * @param bool $classMapAuthoritative
     342     *
     343     * @return void
    259344     */
    260345    public function setClassMapAuthoritative($classMapAuthoritative)
     
    277362     *
    278363     * @param string|null $apcuPrefix
     364     *
     365     * @return void
    279366     */
    280367    public function setApcuPrefix($apcuPrefix)
     
    297384     *
    298385     * @param bool $prepend Whether to prepend the autoloader or not
     386     *
     387     * @return void
    299388     */
    300389    public function register($prepend = false)
    301390    {
    302391        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
     392
     393        if (null === $this->vendorDir) {
     394            return;
     395        }
     396
     397        if ($prepend) {
     398            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
     399        } else {
     400            unset(self::$registeredLoaders[$this->vendorDir]);
     401            self::$registeredLoaders[$this->vendorDir] = $this;
     402        }
    303403    }
    304404
    305405    /**
    306406     * Unregisters this instance as an autoloader.
     407     *
     408     * @return void
    307409     */
    308410    public function unregister()
    309411    {
    310412        spl_autoload_unregister(array($this, 'loadClass'));
     413
     414        if (null !== $this->vendorDir) {
     415            unset(self::$registeredLoaders[$this->vendorDir]);
     416        }
    311417    }
    312418
     
    315421     *
    316422     * @param  string    $class The name of the class
    317      * @return bool|null True if loaded, null otherwise
     423     * @return true|null True if loaded, null otherwise
    318424     */
    319425    public function loadClass($class)
     
    324430            return true;
    325431        }
     432
     433        return null;
    326434    }
    327435
     
    368476    }
    369477
     478    /**
     479     * Returns the currently registered loaders indexed by their corresponding vendor directories.
     480     *
     481     * @return self[]
     482     */
     483    public static function getRegisteredLoaders()
     484    {
     485        return self::$registeredLoaders;
     486    }
     487
     488    /**
     489     * @param  string       $class
     490     * @param  string       $ext
     491     * @return string|false
     492     */
    370493    private function findFileWithExtension($class, $ext)
    371494    {
     
    439562 *
    440563 * Prevents access to $this/self from included files.
     564 *
     565 * @param  string $file
     566 * @return void
     567 * @private
    441568 */
    442569function includeFile($file)
  • wp-widget-disable/trunk/vendor/composer/autoload_classmap.php

    r1487873 r2695407  
    77
    88return array(
     9    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    910    'WP_Requirements_Check' => $vendorDir . '/wearerequired/wp-requirements-check/WP_Requirements_Check.php',
    1011);
  • wp-widget-disable/trunk/vendor/composer/autoload_real.php

    r2237194 r2695407  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82
     5class ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597
    66{
    77    private static $loader;
     
    1414    }
    1515
     16    /**
     17     * @return \Composer\Autoload\ClassLoader
     18     */
    1619    public static function getLoader()
    1720    {
     
    2023        }
    2124
    22         spl_autoload_register(array('ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82', 'loadClassLoader'), true, true);
    23         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInit3b2a2c909c6199de140597783e388f82', 'loadClassLoader'));
     25        require __DIR__ . '/platform_check.php';
     26
     27        spl_autoload_register(array('ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597', 'loadClassLoader'), true, true);
     28        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit914942eb63a3b2b6fe068eb2b363a597', 'loadClassLoader'));
    2530
    2631        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
    2732        if ($useStaticLoader) {
    28             require_once __DIR__ . '/autoload_static.php';
     33            require __DIR__ . '/autoload_static.php';
    2934
    30             call_user_func(\Composer\Autoload\ComposerStaticInit3b2a2c909c6199de140597783e388f82::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit914942eb63a3b2b6fe068eb2b363a597::getInitializer($loader));
    3136        } else {
    3237            $map = require __DIR__ . '/autoload_namespaces.php';
  • wp-widget-disable/trunk/vendor/composer/autoload_static.php

    r2237194 r2695407  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit3b2a2c909c6199de140597783e388f82
     7class ComposerStaticInit914942eb63a3b2b6fe068eb2b363a597
    88{
    99    public static $classMap = array (
     10        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
    1011        'WP_Requirements_Check' => __DIR__ . '/..' . '/wearerequired/wp-requirements-check/WP_Requirements_Check.php',
    1112    );
     
    1415    {
    1516        return \Closure::bind(function () use ($loader) {
    16             $loader->classMap = ComposerStaticInit3b2a2c909c6199de140597783e388f82::$classMap;
     17            $loader->classMap = ComposerStaticInit914942eb63a3b2b6fe068eb2b363a597::$classMap;
    1718
    1819        }, null, ClassLoader::class);
  • wp-widget-disable/trunk/vendor/composer/installed.json

    r2048125 r2695407  
    1 [
    2     {
    3         "name": "wearerequired/wp-requirements-check",
    4         "version": "1.1.0",
    5         "version_normalized": "1.1.0.0",
    6         "source": {
    7             "type": "git",
    8             "url": "https://github.com/wearerequired/wp-requirements-check.git",
    9             "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812"
    10         },
    11         "dist": {
    12             "type": "zip",
    13             "url": "https://api.github.com/repos/wearerequired/wp-requirements-check/zipball/82b8a6c4b953f59e7e534df2d4287e34af950812",
    14             "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812",
    15             "shasum": ""
    16         },
    17         "time": "2019-03-11T11:11:33+00:00",
    18         "type": "library",
    19         "installation-source": "dist",
    20         "autoload": {
    21             "classmap": [
    22                 "WP_Requirements_Check.php"
    23             ]
    24         },
    25         "notification-url": "https://packagist.org/downloads/",
    26         "license": [
    27             "GPL-2.0+"
    28         ],
    29         "authors": [
    30             {
    31                 "name": "Pascal Birchler",
    32                 "email": "pascal@required.ch",
    33                 "role": "Developer"
     1{
     2    "packages": [
     3        {
     4            "name": "wearerequired/wp-requirements-check",
     5            "version": "1.1.0",
     6            "version_normalized": "1.1.0.0",
     7            "source": {
     8                "type": "git",
     9                "url": "https://github.com/wearerequired/wp-requirements-check.git",
     10                "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812"
    3411            },
    35             {
    36                 "name": "required",
    37                 "email": "support@required.ch",
    38                 "homepage": "https://required.com",
    39                 "role": "Company"
     12            "dist": {
     13                "type": "zip",
     14                "url": "https://api.github.com/repos/wearerequired/wp-requirements-check/zipball/82b8a6c4b953f59e7e534df2d4287e34af950812",
     15                "reference": "82b8a6c4b953f59e7e534df2d4287e34af950812",
     16                "shasum": ""
    4017            },
    41             {
    42                 "name": "Ulrich Pogson",
    43                 "email": "ulrich@required.ch",
    44                 "role": "Developer"
    45             }
    46         ],
    47         "description": "Simple requirements checking class",
    48         "keywords": [
    49             "requirements",
    50             "wordpress"
    51         ]
    52     }
    53 ]
     18            "time": "2019-03-11T11:11:33+00:00",
     19            "type": "library",
     20            "installation-source": "dist",
     21            "autoload": {
     22                "classmap": [
     23                    "WP_Requirements_Check.php"
     24                ]
     25            },
     26            "notification-url": "https://packagist.org/downloads/",
     27            "license": [
     28                "GPL-2.0+"
     29            ],
     30            "authors": [
     31                {
     32                    "name": "Pascal Birchler",
     33                    "email": "pascal@required.ch",
     34                    "role": "Developer"
     35                },
     36                {
     37                    "name": "required",
     38                    "email": "support@required.ch",
     39                    "homepage": "https://required.com",
     40                    "role": "Company"
     41                },
     42                {
     43                    "name": "Ulrich Pogson",
     44                    "email": "ulrich@required.ch",
     45                    "role": "Developer"
     46                }
     47            ],
     48            "description": "Simple requirements checking class",
     49            "keywords": [
     50                "requirements",
     51                "wordpress"
     52            ],
     53            "support": {
     54                "issues": "https://github.com/wearerequired/wp-requirements-check/issues",
     55                "source": "https://github.com/wearerequired/wp-requirements-check/tree/master"
     56            },
     57            "install-path": "../wearerequired/wp-requirements-check"
     58        }
     59    ],
     60    "dev": false,
     61    "dev-package-names": []
     62}
  • wp-widget-disable/trunk/wp-widget-disable.php

    r2237194 r2695407  
    44 * Plugin URI:  https://required.com/services/wordpress-plugins/wp-widget-disable/
    55 * Description: Disable sidebar and dashboard widgets with an easy to use interface. Simply use the checkboxes provided under <strong>Appearance -> Disable Widgets</strong> and select the widgets you'd like to hide.
    6  * Version:     2.0.0
     6 * Version:     2.1.0
    77 * Author:      required
    88 * Author URI:  https://required.com
     
    1010 * Text Domain: wp-widget-disable
    1111 *
    12  * Copyright (c) 2015-2020 required (email: support@required.ch)
     12 * Copyright (c) 2015-2022 required (email: support@required.ch)
    1313 *
    1414 * This program is free software; you can redistribute it and/or modify
     
    2525 * along with this program; if not, write to the Free Software
    2626 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    27  *
    28  * @package WP_Widget_Disable
    2927 */
    3028
     
    3937    array(
    4038        'title' => 'WP Widget Disable',
    41         'php'   => '5.4',
    42         'wp'    => '4.0',
     39        'php'   => '5.6',
     40        'wp'    => '4.7',
    4341        'file'  => __FILE__,
    4442    )
Note: See TracChangeset for help on using the changeset viewer.