├── CHANGELOG.md
├── LICENSE.txt
├── README.md
├── SECURITY.md
├── composer.json
├── docs
├── images
│ └── screenshot.png
├── mu-plugin-info.md
└── testing
│ └── testing-tips.md
├── jetpack-beta.php
├── src
├── admin
│ ├── admin.css
│ ├── admin.js
│ ├── branch-card.template.php
│ ├── exception.template.php
│ ├── header.template.php
│ ├── notice.template.php
│ ├── plugin-manage.template.php
│ ├── plugin-select.template.php
│ ├── show-needed-updates.template.php
│ ├── toggles.template.php
│ └── updates.js
├── class-admin.php
├── class-autoupdateself.php
├── class-clicommand.php
├── class-hooks.php
├── class-parsedownext.php
├── class-plugin.php
├── class-plugindataexception.php
└── class-utils.php
└── vendor
├── autoload.php
├── autoload_packages.php
├── automattic
└── jetpack-admin-ui
│ ├── CHANGELOG.md
│ ├── LICENSE.txt
│ ├── README.md
│ ├── SECURITY.md
│ ├── composer.json
│ └── src
│ └── class-admin-menu.php
├── composer
├── ClassLoader.php
├── InstalledVersions.php
├── LICENSE
├── autoload_classmap.php
├── autoload_namespaces.php
├── autoload_psr4.php
├── autoload_real.php
├── autoload_static.php
├── installed.json
├── installed.php
├── jetpack_autoload_classmap.php
├── platform_check.php
└── semver
│ ├── CHANGELOG.md
│ ├── LICENSE
│ ├── README.md
│ ├── composer.json
│ └── src
│ ├── Comparator.php
│ ├── CompilingMatcher.php
│ ├── Constraint
│ ├── Bound.php
│ ├── Constraint.php
│ ├── ConstraintInterface.php
│ ├── MatchAllConstraint.php
│ ├── MatchNoneConstraint.php
│ └── MultiConstraint.php
│ ├── Interval.php
│ ├── Intervals.php
│ ├── Semver.php
│ └── VersionParser.php
├── erusev
└── parsedown
│ ├── LICENSE.txt
│ ├── Parsedown.php
│ ├── README.md
│ └── composer.json
└── jetpack-autoloader
├── class-autoloader-handler.php
├── class-autoloader-locator.php
├── class-autoloader.php
├── class-container.php
├── class-hook-manager.php
├── class-latest-autoloader-guard.php
├── class-manifest-reader.php
├── class-path-processor.php
├── class-php-autoloader.php
├── class-plugin-locator.php
├── class-plugins-handler.php
├── class-shutdown-handler.php
├── class-version-loader.php
└── class-version-selector.php
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 4.1.4-alpha - unreleased
4 |
5 | This is an alpha version! The changes listed here are not final.
6 |
7 | ### Changed
8 | - Update package dependencies.
9 |
10 | ### Fixed
11 | - Linting: Fix more Stylelint violations.
12 | - Linting: Remove outdated vendor prefixes in stylesheets.
13 |
14 | ## 4.1.3 - 2025-04-17
15 | ### Changed
16 | - Code: First pass of style coding standards. [#42734]
17 |
18 | ### Fixed
19 | - Code: Update stylesheets to use hex instead of named colors. [#42920]
20 | - Code: Update stylesheets to use WordPress font styles. [#42928]
21 | - Ensure wpcomsh doesn't reactivate `jetpack/jetpack.php` when we've deactivated it in favor of `jetpack-dev/jetpack.php`. [#43135]
22 | - Linting: Use double colon notation for pseudo-element selectors. [#43019]
23 |
24 | ## 4.1.2 - 2025-04-03
25 | ### Changed
26 | - Code: Use function-style `exit()` and `die()` with a default status code of 0. [#41167]
27 | - Update package dependencies. [#40515] [#40799] [#42180] [#42815]
28 |
29 | ## 4.1.1 - 2024-12-04
30 | ### Changed
31 | - Admin menu: change order of Jetpack sub-menu items [#39095]
32 | - Update dependencies. [#40286]
33 | - Update package dependencies. [#38228] [#38822] [#39288] [#39653] [#40116]
34 | - Use site url in email subject if the site title exists and is equale to "Site Title" [#38908]
35 |
36 | ### Fixed
37 | - Fix an undefined variable reference. [#38247]
38 | - Lossless image optimization of images in projects/plugins [subdirectories from a* through social] [#38573]
39 |
40 | ## 4.1.0 - 2024-07-02
41 | ### Added
42 | - Hook into red bubble notification when bad installation is detected [#36449]
43 | - Support testing mu-plugins (i.e. wpcomsh). [#37955]
44 |
45 | ### Changed
46 | - General: use wp_admin_notice function introduced in WP 6.4 to display notices. [#37051]
47 | - Only show installation errors on plugins page [#36390]
48 | - Updated package dependencies. [#35591] [#36309] [#36775] [#37348] [#37767]
49 |
50 | ### Fixed
51 | - Strip comments in markdown. [#38140]
52 |
53 | ## 4.0.0 - 2024-02-07
54 | ### Changed
55 | - Code Modernization: Replace usage of substr() with str_starts_with() and str_ends_with(). [#34207]
56 | - General: updated PHP requirement to PHP 7.0+ [#34126]
57 | - Updated package dependencies.
58 |
59 | ## 3.1.6 - 2023-10-02
60 | ### Changed
61 | - General: remove backwards-compatibility function checks now that the package supports WP 6.2. [#32772]
62 | - Updated Jetpack submenu sort order so individual features are alpha-sorted. [#32958]
63 | - Updated package dependencies. [#31308], [#32966], [#32307]
64 |
65 | ### Fixed
66 | - Avoid deprecation warning in PHP 8.1 when viewing Beta settings screen. [#31295]
67 | - If another PHP error handler was set, chain to it insead of calling PHP's default handler. [#32834]
68 | - Use WordPress core's `Plugin_Upgrader` to install plugins, as it handles edge cases better. [#33216]
69 |
70 | ## 3.1.5 - 2023-04-27
71 | ### Security
72 | - Disable HTML-style tags in the markdown renderer, the library used doesn't always handle them properly. [#30339]
73 |
74 | ### Changed
75 | - Updated package dependencies. [#28910]
76 |
77 | ## 3.1.4 - 2023-01-11
78 | ### Changed
79 | - Admin menu: ensure that the Jetpack Beta menu always lives under the main Jetpack menu.
80 |
81 | ## 3.1.3 - 2022-09-20
82 | ### Changed
83 | - Renaming `master` references to `trunk` [#24712]
84 | - Updated package dependencies.
85 |
86 | ## 3.1.2 - 2022-06-08
87 | ### Added
88 | - Adding trunk branch cases in preparation for monorepo branch renaming
89 | - Set `Update URI` in the plugin header.
90 |
91 | ### Changed
92 | - PHPCS: Fix `WordPress.Security.ValidatedSanitizedInput`
93 | - Updated package dependencies.
94 |
95 | ### Fixed
96 | - Download from the correct URL when updating to a version tagged like "v3.1.1" rather than "3.1.1".
97 | - Ensure that WP CLI is present before extending the class.
98 | - Fixed testing tips links
99 |
100 | ## 3.1.1 - 2022-03-01
101 | ### Added
102 | - Added docs to JS file.
103 |
104 | ### Changed
105 | - Updated composer.lock
106 |
107 | ## 3.1.0 - 2021-12-08
108 | ### Added
109 | - Added an action to auto-create a GitHub release when a version is tagged.
110 | - Improved exception handling when network access to a8c servers is impaired.
111 |
112 | ### Changed
113 | - Updated Beta release instructions to avoid extra MacOS files in the ZIP.
114 | - Updated package dependencies
115 |
116 | ## 3.0.3 - 2021-10-06
117 | ### Changed
118 | - Updated package dependencies.
119 |
120 | ### Fixed
121 | - Remove unused variable in plugin-select.template.php.
122 |
123 | ## 3.0.2 - 2021-07-29
124 | ### Added
125 | - Use WP core's ajax updater to apply updates.
126 |
127 | ### Fixed
128 | - Detect when "Bleeding Edge" needs an update.
129 | - Fix search when branch name contains multiple `-`.
130 | - Guard against an undefined index warning.
131 | - Typo fix.
132 |
133 | ## 3.0.1 - 2021-07-19
134 | ### Added
135 | - Add small breadcrumb link to get back to the main plugin selection screen.
136 |
137 | ### Fixed
138 | - Correctly handle self-autoupgrades when the release tag begins with "v".
139 | - Fixes non-breaking JS errors.
140 |
141 | ## 3.0.0 - 2021-07-14
142 | ### Added
143 | - Added support for more than just the Jetpack plugin. This involved a major code restructuring.
144 | - Created a changelog from the git history with help from [auto-changelog](https://www.npmjs.com/package/auto-changelog). It could probably use cleanup!
145 | - Provide a soft failure if activating an unbuilt development version of the Beta plugin.
146 | - Testing Tips: Add tips to help testers get started.
147 |
148 | ### Changed
149 | - Enable autotagger and update release instructions.
150 | - Remove composer dev-monorepo hack.
151 | - Update package dependencies.
152 |
153 | ### Removed
154 | - Remove the `jetpack_autoload_dev` option and the `JETPACK_AUTOLOAD_DEV` constant update.
155 |
156 | ### Fixed
157 | - Fix autoloader issue in prodution build.
158 |
159 | ## 2.4.6 - 2021-02-08
160 |
161 | - Prevents updating stable version of Jetpack when using beta plugin in Docker instance.
162 | - Fixes some errant copy appearing in the beta plugin welcome message.
163 | - Sets the JETPACK_AUTOLOAD_DEV constant to true when a development version of Jetpack is activated.
164 |
165 | ## 2.4.5 - 2021-01-25
166 |
167 | - Resolves a conflict between stable and beta Jetpack versions with the autoloader.
168 |
169 | ## 2.4.4 - 2021-01-05
170 |
171 | - Avoids PHP notice for an unset array key if an option is not set.
172 | - Updates the color to match the latest per the [Jetpack color guidelines](https://color-studio.blog).
173 |
174 | ## 2.4.3 - 2020-04-01
175 |
176 | - Avoid Fatal errors when switching between branches that might be at different base version of the code.
177 |
178 | ## 2.4.2 - 2020-01-21
179 |
180 | - Avoid Fatal errors; when Jetpack's vendor directory cannot be found, do not attempt to update.
181 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Jetpack Beta Tester
2 |
3 | This plugin can be used **alongside [the Jetpack plugin](https://wordpress.org/plugins/jetpack/)**, and will allow you run specific versions of Jetpack on your site:
4 | - Bleeding Edge (`master` or `trunk`)
5 | - Release Candidates (latest Beta releases)
6 | - Feature branches ([branches currently being worked on in the Jetpack repository](https://github.com/Automattic/Jetpack/pulls))
7 | - SVN Tags ([any existing tag in Jetpack's SVN repo](https://plugins.svn.wordpress.org/jetpack/tags/)): this allows you to install past versions of Jetpack on your site if necessary.
8 |
9 | 
10 |
11 | -------
12 |
13 | ## Quick Start
14 |
15 | **Want to help us test out Jetpack?**
16 |
17 | We'd love to have you! Just [download the latest version of this plugin](https://github.com/Automattic/jetpack-beta/releases) and install it alongside Jetpack, and we'll help keep you up to date with the very latest.
18 |
19 | You can also join our Jetpack Beta mailing list at [jetpack.com/beta](https://jetpack.com/beta).
20 |
21 | ### Contribute
22 |
23 | If you find issues with this plugin, you can [report bugs here on GitHub](https://github.com/Automattic/jetpack/issues/new?assignees=&labels=%5BType%5D+Bug&template=bug-report.yml).
24 |
25 | -------
26 |
27 | ### Deployment
28 |
29 | Deployment is handled automatically via GitHub Actions upon tagging.
30 |
31 | ## Security
32 |
33 | Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic).
34 |
35 | -------
36 |
37 | ## License
38 |
39 | Jetpack is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt).
40 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | Full details of the Automattic Security Policy can be found on [automattic.com](https://automattic.com/security/).
4 |
5 | ## Supported Versions
6 |
7 | Generally, only the latest version of Jetpack and its associated plugins have continued support. If a critical vulnerability is found in the current version of a plugin, we may opt to backport any patches to previous versions.
8 |
9 | ## Reporting a Vulnerability
10 |
11 | Our HackerOne program covers the below plugin software, as well as a variety of related projects and infrastructure:
12 |
13 | * [Jetpack](https://jetpack.com/)
14 | * Jetpack Backup
15 | * Jetpack Boost
16 | * Jetpack CRM
17 | * Jetpack Protect
18 | * Jetpack Search
19 | * Jetpack Social
20 | * Jetpack VideoPress
21 |
22 | **For responsible disclosure of security issues and to be eligible for our bug bounty program, please submit your report via the [HackerOne](https://hackerone.com/automattic) portal.**
23 |
24 | Our most critical targets are:
25 |
26 | * Jetpack and the Jetpack composer packages (all within this repo)
27 | * Jetpack.com -- the primary marketing site.
28 | * cloud.jetpack.com -- a management site.
29 | * wordpress.com -- the shared management site for both Jetpack and WordPress.com sites.
30 |
31 | For more targets, see the `In Scope` section on [HackerOne](https://hackerone.com/automattic).
32 |
33 | _Please note that the **WordPress software is a separate entity** from Automattic. Please report vulnerabilities for WordPress through [the WordPress Foundation's HackerOne page](https://hackerone.com/wordpress)._
34 |
35 | ## Guidelines
36 |
37 | We're committed to working with security researchers to resolve the vulnerabilities they discover. You can help us by following these guidelines:
38 |
39 | * Follow [HackerOne's disclosure guidelines](https://www.hackerone.com/disclosure-guidelines).
40 | * Pen-testing Production:
41 | * Please **setup a local environment** instead whenever possible. Most of our code is open source (see above).
42 | * If that's not possible, **limit any data access/modification** to the bare minimum necessary to reproduce a PoC.
43 | * **_Don't_ automate form submissions!** That's very annoying for us, because it adds extra work for the volunteers who manage those systems, and reduces the signal/noise ratio in our communication channels.
44 | * To be eligible for a bounty, all of these guidelines must be followed.
45 | * Be Patient - Give us a reasonable time to correct the issue before you disclose the vulnerability.
46 |
47 | We also expect you to comply with all applicable laws. You're responsible to pay any taxes associated with your bounties.
48 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "automattic/jetpack-beta",
3 | "description": "Serves beta and PR branches of Jetpack to a WordPress install near you!",
4 | "homepage": "https://jetpack.com/",
5 | "type": "wordpress-plugin",
6 | "license": "GPL-2.0-or-later",
7 | "support": {
8 | "issues": "https://github.com/Automattic/jetpack/issues"
9 | },
10 | "require": {
11 | "automattic/jetpack-admin-ui": "^0.5.10",
12 | "automattic/jetpack-autoloader": "^5.0.7",
13 | "composer/semver": "3.4.3",
14 | "erusev/parsedown": "1.7.4"
15 | },
16 | "require-dev": {
17 | "automattic/jetpack-changelogger": "^6.0.5"
18 | },
19 | "scripts": {},
20 | "autoload": {
21 | "classmap": [
22 | "src/"
23 | ]
24 | },
25 | "minimum-stability": "dev",
26 | "prefer-stable": true,
27 | "config": {
28 | "sort-packages": true,
29 | "autoloader-suffix": "567fa3f555de8fd218dfdc1688bb97b5_betaⓥ4_1_4_alpha",
30 | "allow-plugins": {
31 | "automattic/jetpack-autoloader": true
32 | }
33 | },
34 | "extra": {
35 | "autotagger": true,
36 | "autorelease": {
37 | "titlefmt": "Jetpack Beta %s"
38 | },
39 | "mirror-repo": "Automattic/jetpack-beta",
40 | "release-branch-prefix": "jetpack-beta",
41 | "version-constants": {
42 | "JPBETA_VERSION": "jetpack-beta.php"
43 | },
44 | "beta-plugin-slug": "jetpack-beta"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/docs/images/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Automattic/jetpack-beta/e1a2df0ad4573a418dd73a5876b483c8aa313cba/docs/images/screenshot.png
--------------------------------------------------------------------------------
/docs/mu-plugin-info.md:
--------------------------------------------------------------------------------
1 | ## Mu-plugin support
2 |
3 | WordPress does not provide user interface for installing and uninstalling mu-plugins. Further, mu-plugins that aren't already a single file need a "loader" that is a single file placed in the mu-plugins directory (generally `wp-content/mu-plugins/`). While there are many ways this can be done, Jetpack Beta Tester makes some assumptions about how mu-plugins it supports are installed:
4 |
5 | * The directory of code for the mu-plugin is located in the mu-plugins directory and named after the plugin slug, similar to how plugins are installed. So, for example, a plugin with slug "wpcomsh" would be at `wp-content/mu-plugins/wpcomsh/`.
6 | * The corresponding loader file is named with the plugin slug with `-loader.php` appended. So, for example, a plugin with slug "wpcomsh" would have its loader named `wp-content/mu-plugins/wpcomsh-loader.php`.
7 |
8 | If your installation of the mu-plugin does not follow these conventions, attempting to use Jetpack Beta Tester to install development versions of the mu-plugin may result in multiple versions of the plugin being active simultaneously, which will very likely break your site.
9 |
10 | Also, be aware that Jetpack Beta Tester will not enable a stable version of a mu-plugin for you. You will have to follow the plugin's instructions for creating the loader to properly enable it.
11 |
12 | Jetpack Beta Tester will not auto-update mu-plugins, nor will it prompt when updates are available. WordPress core's plugin update infrastructure does not handle mu-plugins, so we can't hook into it like we do normal plugins.
13 |
14 | When a development version is active and no stable version directory exists, a "Deactivate" button will be provided in the UI to easily deactivate the development version.
15 | If a stable directory does exist, only the usual button to activate it will be provided; if you want to deactivate the mu-plugin in this situation, do so in the normal manner by removing the loader file.
16 |
17 | ### How it works
18 |
19 | For those interested in the details of how Jetpack Beta Tester manages mu-plugins, read on.
20 |
21 | When installing mu-plugins, Jetpack Beta Tester will unpack them into the mu-plugins directory in the same manner that it unpacks normal plugins into the plugins directory. It even uses WordPress core's `Plugin_Upgrader` class to do most of the work, hooking the 'upgrader_package_options' filter to change the destination from WP_PLUGIN_DIR to WPMU_PLUGIN_DIR.
22 |
23 | Activation is done via the loader file:
24 |
25 | * If the loader file exists then Jetpack Beta Tester assumes that either a stable or dev version is active.
26 | * While this may not be entirely accurate for something like wpcomsh where its standard loader checks the `IS_ATOMIC` constant before actually loading, it's good enough for our purposes.
27 | * To activate a dev version, Jetpack Beta Tester changes the opening ` array(
72 | 'plugin' => 'Jetpack Beta',
73 | ),
74 | );
75 |
76 | return $slugs;
77 | }
78 | );
79 |
80 | /**
81 | * Outputs an admin notice for folks running Jetpack Beta without having run composer install.
82 | *
83 | * @since 3.0.0
84 | */
85 | function jetpack_beta_admin_missing_autoloader() {
86 | if ( get_current_screen()->id !== 'plugins' ) {
87 | return;
88 | }
89 | $message = sprintf(
90 | wp_kses(
91 | /* translators: Placeholder is a link to a support document. */
92 | __( 'Your installation of Jetpack Beta is incomplete. If you installed Jetpack Beta from GitHub, please refer to this document to set up your development environment.', 'jetpack-beta' ),
93 | array(
94 | 'a' => array(
95 | 'href' => array(),
96 | 'target' => array(),
97 | 'rel' => array(),
98 | ),
99 | )
100 | ),
101 | 'https://github.com/Automattic/jetpack/blob/trunk/docs/development-environment.md'
102 | );
103 | wp_admin_notice(
104 | $message,
105 | array(
106 | 'type' => 'error',
107 | 'dismissible' => true,
108 | )
109 | );
110 | }
111 |
112 | add_action( 'admin_notices', 'jetpack_beta_admin_missing_autoloader' );
113 | return;
114 | }
115 |
116 | add_action( 'init', array( Automattic\JetpackBeta\AutoupdateSelf::class, 'instance' ) );
117 |
118 | Automattic\JetpackBeta\Hooks::setup();
119 |
120 | register_activation_hook( __FILE__, array( Automattic\JetpackBeta\Hooks::class, 'activate' ) );
121 | register_deactivation_hook( __FILE__, array( Automattic\JetpackBeta\Hooks::class, 'deactivate' ) );
122 |
123 | add_action( 'init', array( Automattic\JetpackBeta\Hooks::class, 'instance' ) );
124 | add_action( 'muplugins_loaded', array( Automattic\JetpackBeta\Hooks::class, 'is_network_enabled' ) );
125 |
126 | if ( defined( 'WP_CLI' ) && WP_CLI ) {
127 | // @phan-suppress-next-line PhanUndeclaredFunctionInCallable -- https://github.com/phan/phan/issues/4763
128 | WP_CLI::add_command( 'jetpack-beta', Automattic\JetpackBeta\CliCommand::class );
129 | }
130 |
--------------------------------------------------------------------------------
/src/admin/admin.js:
--------------------------------------------------------------------------------
1 | ( function () {
2 | // Elements
3 | let prs = document.getElementById( 'section-pr' )?.querySelectorAll( '.branch-card' );
4 | if ( ! prs ) {
5 | return; // Return early if on main plugin selection screen.
6 | }
7 | const releases = document.getElementById( 'section-releases' ).querySelectorAll( '.branch-card' );
8 | const search_input_prs = document.getElementById( 'search-component-prs' );
9 | const search_input_releases = document.getElementById( 'search-component-releases' );
10 | const search_close_link_prs = document.getElementById( 'search-component-prs-close' );
11 | const search_close_link_releases = document.getElementById( 'search-component-releases-close' );
12 | const activate_links = document.querySelectorAll( '.activate-branch' );
13 | const toggle_links = document.querySelectorAll( '.form-toggle__label' );
14 |
15 | const pr_index = [];
16 | const release_index = [];
17 | const each = Array.prototype.forEach;
18 | let clicked_activate = false;
19 | let clicked_toggle = false;
20 |
21 | // Build index of prs
22 | each.call( prs, function ( element, index ) {
23 | hide( element );
24 | element.querySelector( '.activate-branch' ).setAttribute( 'data-index', index );
25 | pr_index[ index ] = {
26 | header: element.querySelector( '.branch-card-header' ).textContent,
27 | key: element.getAttribute( 'data-pr' ),
28 | element: element,
29 | };
30 | } );
31 |
32 | // Build index of releases
33 | each.call( releases, function ( element, index ) {
34 | hide( element );
35 | element.querySelector( '.activate-branch' ).setAttribute( 'data-index', index );
36 | release_index[ index ] = {
37 | header: element.querySelector( '.branch-card-header' ).textContent,
38 | key: element.getAttribute( 'data-release' ),
39 | element: element,
40 | };
41 | } );
42 |
43 | search_input_listener( search_input_prs );
44 | search_input_listener( search_input_releases );
45 | /**
46 | * Attaches keyup event listener to the search inputs.
47 | *
48 | * @param {object} input_area - Search input DOM Element object.
49 | */
50 | function search_input_listener( input_area ) {
51 | if ( ! input_area ) {
52 | return;
53 | }
54 |
55 | input_area.addEventListener( 'keyup', function ( event ) {
56 | const section_id = event.srcElement.id;
57 | const search_for = pr_to_header( input_area.value );
58 | const index = 'search-component-releases' === section_id ? release_index : pr_index;
59 |
60 | if ( ! search_for ) {
61 | if ( input_area.id === 'search-component-prs' ) {
62 | each.call( prs, hide );
63 | hide( search_close_link_prs );
64 | }
65 |
66 | if ( input_area.id === 'search-component-releases' ) {
67 | each.call( releases, hide );
68 | hide( search_close_link_releases );
69 | }
70 |
71 | return;
72 | }
73 |
74 | if ( input_area.id === 'search-component-prs' ) {
75 | show( search_close_link_prs );
76 | }
77 |
78 | if ( input_area.id === 'search-component-releases' ) {
79 | show( search_close_link_releases );
80 | }
81 |
82 | index.forEach( show_found.bind( this, search_for, section_id ) );
83 | } );
84 | }
85 |
86 | /**
87 | * Displays matching search results.
88 | *
89 | * @param {string} search_for - Search input term.
90 | * @param {string} section - Which search section to display result in (pr/release).
91 | * @param {object} found - A matching prs or releases array item from the search.
92 | */
93 | function show_found( search_for, section, found ) {
94 | const element = found.element;
95 | const header_text = /^ *[0-9]+ *$/.test( search_for ) ? `${ found.key }` : found.header;
96 | const class_selector = '.branch-card-header';
97 |
98 | const found_position = header_text.indexOf( search_for );
99 | if ( -1 === found_position ) {
100 | hide( element );
101 | return;
102 | }
103 |
104 | element.querySelector( class_selector ).innerHTML = highlight_word( search_for, header_text );
105 | show( element );
106 | }
107 |
108 | hide_search_close_link( search_close_link_prs );
109 | hide_search_close_link( search_close_link_releases );
110 | /**
111 | * Attaches click event listener that controls hiding search results and clearing search inputs.
112 | * Also handles hiding the close search icon when search input is empty.
113 | *
114 | * @param {object} section - DOM Element object for a close search icon.
115 | */
116 | function hide_search_close_link( section ) {
117 | if ( ! section ) {
118 | return;
119 | }
120 |
121 | hide( section );
122 | section.addEventListener( 'click', function ( event ) {
123 | if ( section.id === 'search-component-prs-close' ) {
124 | each.call( prs, hide );
125 | hide( section );
126 | search_input_prs.value = '';
127 | }
128 |
129 | if ( section.id === 'search-component-releases-close' ) {
130 | each.call( releases, hide );
131 | hide( section );
132 | search_input_releases.value = '';
133 | }
134 |
135 | event.preventDefault();
136 | } );
137 | }
138 |
139 | // Attach click event listeners to all of the 'Activate' links.
140 | each.call( activate_links, function ( element ) {
141 | element.addEventListener( 'click', activate_link_click.bind( this, element ) );
142 | } );
143 | /**
144 | * Handles click event for the 'Activate' links.
145 | *
146 | * @param {object} element - The 'Activate' link element being clicked.
147 | */
148 | function activate_link_click( element ) {
149 | if ( clicked_activate ) {
150 | return;
151 | }
152 | if ( element.textContent === window.JetpackBeta.activate ) {
153 | element.parentNode.textContent = window.JetpackBeta.activating;
154 | } else {
155 | element.parentNode.textContent = window.JetpackBeta.updating;
156 | }
157 |
158 | const index = parseInt( element.getAttribute( 'data-index' ) );
159 |
160 | prs = Array.prototype.filter.call( prs, function ( pr, i ) {
161 | return index === i ? false : true;
162 | } );
163 | disable_activate_branch_links();
164 | trackEvent( element );
165 | clicked_activate = true;
166 | }
167 |
168 | /**
169 | * Disables the 'Activate' links.
170 | */
171 | function disable_activate_branch_links() {
172 | each.call( activate_links, function ( element ) {
173 | element.addEventListener( 'click', function ( event ) {
174 | event.preventDefault();
175 | } );
176 | element.removeEventListener( 'click', activate_link_click.bind( this, element ) );
177 | element.classList.add( 'is-disabled' );
178 | } );
179 | }
180 |
181 | // Attaches click event listener to all toggle links.
182 | each.call( toggle_links, function ( element ) {
183 | element.addEventListener( 'click', toggle_link_click.bind( this, element ) );
184 | } );
185 | /**
186 | * Handles click event for one of the toggle links (e.g. Autoupdates switch).
187 | *
188 | * @param {object} element - The toggle link element being clicked.
189 | */
190 | function toggle_link_click( element ) {
191 | if ( clicked_toggle ) {
192 | return;
193 | }
194 | clicked_toggle = true;
195 | element.classList.toggle( 'is-active' );
196 | trackEvent( element );
197 | }
198 |
199 | // Helper functions
200 |
201 | /**
202 | * Massage search input to match pr/release 'header'.
203 | *
204 | * @param {string} search - The raw search input text.
205 | * @return {string} The massaged search string.
206 | */
207 | function pr_to_header( search ) {
208 | return search
209 | .replace( /\//g, ' / ' )
210 | .replace( /-/g, ' ' )
211 | .replace( / +/g, ' ' )
212 | .toLowerCase()
213 | .trim();
214 | }
215 |
216 | /**
217 | * Highlights text in search results matching the search input text.
218 | *
219 | * @param {string} word - The search input term.
220 | * @param {string} phrase - The full pr/release header text.
221 | * @return {string} Search result with span wrapping matching word (search input) for styling.
222 | */
223 | function highlight_word( word, phrase ) {
224 | const replace = '' + word + '';
225 | return phrase.replace( word, replace );
226 | }
227 |
228 | /**
229 | * Sets an element to display:none
230 | *
231 | * @param {object} element - DOM Element object.
232 | */
233 | function hide( element ) {
234 | element.classList.add( 'branch-card-hide' );
235 | }
236 |
237 | /**
238 | * Unsets/clears an element's display value.
239 | *
240 | * @param {object} element - DOM Element object.
241 | */
242 | function show( element ) {
243 | element.classList.remove( 'branch-card-hide' );
244 | }
245 |
246 | /**
247 | * Track user event such as a click on a button or a link.
248 | *
249 | * @param {string} element - Element that was clicked.
250 | */
251 | function trackEvent( element ) {
252 | // Do not track anything if TOS have not been accepted yet and the file isn't enqueued.
253 | if ( ! window.jpTracksAJAX || 'function' !== typeof window.jpTracksAJAX.record_ajax_event ) {
254 | return;
255 | }
256 |
257 | const eventName = element.getAttribute( 'data-jptracks-name' );
258 | const eventProp = element.getAttribute( 'data-jptracks-prop' );
259 |
260 | window.jpTracksAJAX.record_ajax_event( eventName, 'click', eventProp );
261 | }
262 | } )();
263 |
--------------------------------------------------------------------------------
/src/admin/branch-card.template.php:
--------------------------------------------------------------------------------
1 | which ? $plugin->dev_plugin_slug() : $plugin->plugin_slug();
22 | $classes = array( 'dops-foldable-card', 'has-expanded-summary', 'dops-card', 'branch-card' );
23 | $data_attr = '';
24 | $more_info = array();
25 | if ( isset( $branch->pr ) && is_int( $branch->pr ) ) {
26 | $data_attr = sprintf( 'data-pr="%s"', esc_attr( $branch->pr ) );
27 | // translators: Translates the `More info` link. %1$s: URL. %2$s: PR number.
28 | $more_info[] = sprintf( __( 'more info #%2$s', 'jetpack-beta' ), $branch->plugin_url, $branch->pr );
29 | } elseif ( 'release' === $branch->source ) {
30 | $data_attr = sprintf( 'data-release="%s"', esc_attr( $branch->version ) );
31 | $more_info[] = sprintf(
32 | // translators: Which release is being selected.
33 | __( 'Public release (%1$s) available on WordPress.org', 'jetpack-beta' ),
34 | esc_html( $branch->version ),
35 | esc_attr( $branch->version )
36 | );
37 | } elseif ( 'rc' === $branch->source || 'trunk' === $branch->source || 'unknown' === $branch->source && $branch->version ) {
38 | $more_info[] = sprintf(
39 | // translators: %s: Version number.
40 | __( 'Version %s', 'jetpack-beta' ),
41 | $branch->version
42 | );
43 | }
44 |
45 | if ( isset( $branch->update_date ) ) {
46 | // translators: %s is how long ago the branch was updated.
47 | $more_info[] = sprintf( __( 'last updated %s ago', 'jetpack-beta' ), human_time_diff( strtotime( $branch->update_date ) ) );
48 | }
49 |
50 | $activate_url = wp_nonce_url(
51 | Utils::admin_url(
52 | array(
53 | 'activate-branch' => "{$branch->source}:{$branch->id}",
54 | 'plugin' => $plugin->plugin_slug(),
55 | )
56 | ),
57 | 'activate_branch'
58 | );
59 |
60 | if ( $active_branch->source === $branch->source && $active_branch->id === $branch->id ) {
61 | $classes[] = 'branch-card-active';
62 | }
63 | if ( 'unknown' === $branch->source ) {
64 | if ( $branch->id === 'deactivate' ) {
65 | $classes[] = 'deactivate-mu-plugin';
66 | $classes[] = 'deactivate-mu-plugin-' . $plugin->plugin_slug();
67 | } else {
68 | $classes[] = 'existing-branch-for-' . $plugin->plugin_slug();
69 | }
70 | }
71 | if ( empty( $branch->is_last ) ) {
72 | $classes[] = 'is-compact';
73 | }
74 |
75 | // Needs to match what core's wp_ajax_update_plugin() will return.
76 | // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment, WordPress.WP.I18n.TextDomainMismatch
77 | $updater_version = sprintf( __( 'Version %s', 'default' ), $branch->version );
78 |
79 | if ( $branch->source === 'unknown' && $branch->id === 'deactivate' ) {
80 | $active_text = __( 'Inactive', 'jetpack-beta' );
81 | $activate_text = __( 'Deactivate', 'jetpack-beta' );
82 | } else {
83 | $active_text = __( 'Active', 'jetpack-beta' );
84 | $activate_text = __( 'Activate', 'jetpack-beta' );
85 | }
86 |
87 | ?>
88 |
class="" data-slug="" data-updater-version="">
89 |
104 |
105 |
18 |
19 |
getMessage() ); ?>
20 |
26 |
27 |
--------------------------------------------------------------------------------
/src/admin/header.template.php:
--------------------------------------------------------------------------------
1 |
17 |
34 |
--------------------------------------------------------------------------------
/src/admin/notice.template.php:
--------------------------------------------------------------------------------
1 | base );
19 |
20 | ?>
21 |
41 |
42 |
43 |
44 |
45 | Latest Stable.',
50 | 'jetpack-beta'
51 | )
52 | );
53 | ?>
54 |
55 |
56 | Bleeding Edge, you\'ll get all the cool new features we\'re planning to ship in our next release.', 'jetpack-beta' )
59 | );
60 | ?>
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/admin/plugin-select.template.php:
--------------------------------------------------------------------------------
1 |
25 |
26 |
27 |
28 |
33 |
34 |
35 |
36 |
37 | $plugin ) {
39 | $classes = array( 'dops-foldable-card', 'has-expanded-summary', 'dops-card' );
40 | if ( $plugin->is_active( 'stable' ) ) {
41 | $classes[] = 'plugin-stable';
42 | $verslug = $plugin->plugin_slug();
43 | $version = $plugin->stable_pretty_version() ?? '';
44 | } elseif ( $plugin->is_active( 'dev' ) ) {
45 | $classes[] = 'plugin-dev';
46 | $verslug = $plugin->dev_plugin_slug();
47 | $version = $plugin->dev_pretty_version() ?? '';
48 | } else {
49 | $classes[] = 'plugin-inactive';
50 | $verslug = '';
51 | $version = __( 'Plugin is not active', 'jetpack-beta' );
52 | }
53 | $classes[] = 'is-compact';
54 |
55 | $url = Utils::admin_url(
56 | array(
57 | 'plugin' => $slug,
58 | )
59 | );
60 |
61 | ?>
62 |
63 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/src/admin/show-needed-updates.template.php:
--------------------------------------------------------------------------------
1 | plugin_file() => 1,
26 | $plugin->dev_plugin_file() => 1,
27 | JPBETA__PLUGIN_FOLDER . '/jetpack-beta.php' => 1,
28 | )
29 | );
30 | }
31 | if ( ! $updates ) {
32 | return;
33 | }
34 |
35 | wp_enqueue_script( 'jetpack-beta-updates', plugins_url( 'updates.js', __FILE__ ), array( 'jquery', 'updates' ), JPBETA_VERSION, true );
36 | wp_localize_script(
37 | 'jetpack-beta-updates',
38 | 'JetpackBetaUpdates',
39 | array(
40 | 'activate' => __( 'Activate', 'jetpack-beta' ),
41 | 'activating' => __( 'Activating...', 'jetpack-beta' ),
42 | 'updating' => __( 'Updating...', 'jetpack-beta' ),
43 | 'leaving' => __( 'Don\'t go Plugin is still installing!', 'jetpack-beta' ),
44 | )
45 | );
46 | // Junk needed by core's 'updates' JS.
47 | wp_print_admin_notice_templates();
48 | wp_localize_script(
49 | 'updates',
50 | '_wpUpdatesItemCounts',
51 | array(
52 | 'totals' => wp_get_update_data(),
53 | )
54 | );
55 |
56 | ?>
57 |
58 |
59 | $update ) {
61 | $slug = dirname( $file );
62 | $isdev = false;
63 | if ( JPBETA__PLUGIN_FOLDER === $slug ) {
64 | // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
65 | $name = $update->Name;
66 | } else {
67 | if ( str_ends_with( $slug, '-dev' ) ) {
68 | $isdev = true;
69 | $slug = substr( $slug, 0, -4 );
70 | }
71 | $plugin = Plugin::get_plugin( $slug );
72 | $name = $plugin->get_name() . ' | ' . ( $isdev ? $plugin->dev_pretty_version() : $plugin->stable_pretty_version() );
73 | }
74 |
75 | $url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $file ) ), 'upgrade-plugin_' . $file );
76 |
77 | // translators: %s: Version number.
78 | $sub_header = sprintf( __( 'Version %s is available', 'jetpack-beta' ), $update->update->new_version );
79 |
80 | ?>
81 |
" data-plugin="">
82 |
95 |
96 |
97 |
98 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/admin/updates.js:
--------------------------------------------------------------------------------
1 | /* global jQuery, wp, JetpackBeta */
2 | /**
3 | * Update message hooks.
4 | *
5 | * @param {jQuery} $ - jQuery object.
6 | * @param {object} wp - WP object.
7 | * @param {object} i18n - I18n data.
8 | */
9 | ( function ( $, wp, i18n ) {
10 | const $updateNotices = $( '.jetpack-beta__update-needed' ),
11 | $document = $( document );
12 |
13 | /**
14 | * Success handler for plugin updates.
15 | *
16 | * @param {object} response - Response object.
17 | */
18 | function onSuccess( response ) {
19 | // Too bad we can't just use wp.updates.updatePluginSuccess(), but it assumes it's on one of core's pages.
20 | const $adminBarUpdates = $( '#wp-admin-bar-updates' );
21 | $adminBarUpdates.removeClass( 'spin' );
22 |
23 | $updateNotices.find( '[data-plugin="' + response.plugin + '"]' ).remove();
24 | if ( $updateNotices.find( '[data-plugin]' ).length <= 0 ) {
25 | $updateNotices.remove();
26 | }
27 |
28 | // Update any version strings that are flagged as being for this slug.
29 | $( '[data-jpbeta-version-for="' + response.slug + '"]' ).text( response.newVersion );
30 | // Clear the "active" indicator on all branch cards, then try to set it on a card for the new version.
31 | const $active = $( '.branch-card-active[data-slug="' + response.slug + '"]' );
32 | if ( $active.length ) {
33 | $active.removeClass( 'branch-card-active' );
34 | $(
35 | '.branch-card[data-slug="' +
36 | response.slug +
37 | '"][data-updater-version="' +
38 | response.newVersion +
39 | '"]'
40 | )
41 | .first()
42 | .addClass( 'branch-card-active' );
43 | }
44 | // Delete the "Existing Version" branch card for the slug, if any, because we just updated it to
45 | // some release version card.
46 | $( '.existing-branch-for-' + response.slug ).remove();
47 |
48 | wp.a11y.speak( wp.i18n.__( 'Update completed successfully.', 'jetpack-beta' ) );
49 | wp.updates.decrementCount( 'plugin' );
50 | $document.trigger( 'wp-plugin-update-success', response );
51 | }
52 |
53 | /**
54 | * Error handler for plugin updates.
55 | *
56 | * @param {object} response - Response object.
57 | */
58 | function onError( response ) {
59 | // Too bad we can't just use wp.updates.updatePluginError(), but it assumes it's on one of core's pages.
60 | if ( ! wp.updates.isValidResponse( response, 'update' ) ) {
61 | return;
62 | }
63 |
64 | if ( wp.updates.maybeHandleCredentialError( response, 'update-plugin' ) ) {
65 | return;
66 | }
67 |
68 | const $adminBarUpdates = $( '#wp-admin-bar-updates' );
69 |
70 | let $notice;
71 | if ( response.plugin ) {
72 | $notice = $updateNotices.find( '[data-plugin="' + response.plugin + '"]' );
73 | } else {
74 | $notice = $updateNotices.find( '[data-slug="' + response.slug + '"]' );
75 | }
76 | const $button = $notice.find( '.update-branch' );
77 |
78 | // eslint-disable-next-line @wordpress/valid-sprintf
79 | const errorMessage = wp.i18n.sprintf( i18n.failedmsg, response.errorMessage );
80 |
81 | $notice.addClass( 'is-error' );
82 | $button.removeClass( 'is-disabled' ).addClass( 'is-error' );
83 | $button.prop( 'disabled', false );
84 | $button.text( i18n.failed );
85 | $notice.find( '.error-message' ).remove();
86 | $notice
87 | .find( '.dops-foldable-card__main' )
88 | .first()
89 | .append( $( '
' ).html( errorMessage ) );
90 |
91 | $adminBarUpdates.removeClass( 'spin' );
92 |
93 | wp.a11y.speak( errorMessage, 'assertive' );
94 |
95 | $document.trigger( 'wp-plugin-update-error', response );
96 | }
97 |
98 | /**
99 | * Click handler for plugin updates in Jetpack Beta update notices.
100 | *
101 | * @param {Event} event - Event interface.
102 | */
103 | $updateNotices.on( 'click', '[data-plugin] .update-branch', function ( event ) {
104 | const $button = $( event.target );
105 |
106 | event.preventDefault();
107 |
108 | if ( $button.hasClass( 'is-disabled' ) ) {
109 | return;
110 | }
111 |
112 | const $notice = $button.parents( '.dops-card' ),
113 | $adminBarUpdates = $( '#wp-admin-bar-updates' );
114 |
115 | $notice.removeClass( 'is-error' );
116 | $notice.find( '.error-message' ).remove();
117 | $button.removeClass( 'is-error' ).addClass( 'is-disabled' );
118 | $button.prop( 'disabled', true );
119 | $button.text( i18n.updating );
120 |
121 | wp.updates.maybeRequestFilesystemCredentials( event );
122 |
123 | // Too bad we can't just call wp.updates.updatePlugin(), but it assumes it's on one of core's pages.
124 | $adminBarUpdates.addClass( 'spin' );
125 |
126 | const args = {
127 | plugin: $notice.data( 'plugin' ),
128 | slug: $notice.data( 'slug' ),
129 | success: onSuccess,
130 | error: onError,
131 | };
132 |
133 | $document.trigger( 'wp-plugin-updating', args );
134 | wp.updates.ajax( 'update-plugin', args );
135 | } );
136 | } )( jQuery, wp, JetpackBeta );
137 |
--------------------------------------------------------------------------------
/src/class-clicommand.php:
--------------------------------------------------------------------------------
1 |
28 | * : Subcommand to run. Either 'list' or 'activate'.
29 | *
30 | * [
...]
31 | * : Any additional args to the subcommand.
32 | *
33 | * @deprecated since 3.0.0
34 | * @param array $args Arguments passed to CLI.
35 | */
36 | public function branch( $args ) {
37 | $this->validation_checks();
38 |
39 | $subcommand = array_shift( $args );
40 | if ( 'list' === $subcommand ) {
41 | WP_CLI::warning( __( 'Command `wp jetpack-beta branch list` is deprecated. Use `wp jetpack-beta list jetpack` instead.', 'jetpack-beta' ) );
42 | WP_CLI::run_command( array( 'jetpack-beta', 'list', 'jetpack' ) );
43 | } elseif ( 'activate' === $subcommand ) {
44 | WP_CLI::warning( __( 'Command `wp jetpack-beta branch activate ` is deprecated. Use `wp jetpack-beta activate jetpack ` instead.', 'jetpack-beta' ) );
45 | WP_CLI::run_command( array_merge( array( 'jetpack-beta', 'activate', 'jetpack' ), $args ) );
46 | } else {
47 | WP_CLI::warning( __( 'Command `wp jetpack-beta branch` is deprecated. See `wp help jetpack-beta` for available commands.', 'jetpack-beta' ) );
48 | WP_CLI::error( __( 'Specify subcommand. "activate" and "list" subcommands are supported', 'jetpack-beta' ) );
49 | }
50 | }
51 |
52 | /**
53 | * List available plugins or branches.
54 | *
55 | * ## Options
56 | *
57 | * []
58 | * : If specified, list branches available for the plugin.
59 | *
60 | * ## Examples
61 | *
62 | * wp jetpack-beta list
63 | * wp jetpack-beta list jetpack
64 | *
65 | * @subcommand list
66 | * @param array $args Arguments passed to CLI.
67 | */
68 | public function do_list( $args ) {
69 | $this->validation_checks();
70 |
71 | if ( ! $args ) {
72 | try {
73 | $plugins = Plugin::get_all_plugins( true );
74 | } catch ( PluginDataException $ex ) {
75 | WP_CLI::error( $ex->getMessage() );
76 | }
77 | if ( ! $plugins ) {
78 | WP_CLI::error( __( 'No plugins are available', 'jetpack-beta' ) );
79 | }
80 |
81 | $l = 0;
82 | foreach ( $plugins as $slug => $plugin ) {
83 | $l = max( $l, strlen( $slug ) );
84 | }
85 | WP_CLI::line( 'Available plugins: ' );
86 | foreach ( $plugins as $slug => $plugin ) {
87 | WP_CLI::line( sprintf( " %-{$l}s - %s", $slug, $plugin->get_name() ) );
88 | }
89 | return;
90 | }
91 |
92 | $plugin = Plugin::get_plugin( $args[0], true );
93 | if ( ! $plugin ) {
94 | // translators: %s: subcommand that was not found.
95 | WP_CLI::error( sprintf( __( 'Plugin \'%s\' is not known. Use `wp jetpack-beta list` to list known plugins', 'jetpack-beta' ), $args[0] ) );
96 | }
97 |
98 | $manifest = $plugin->get_manifest();
99 | $dev_info = $plugin->dev_info();
100 | $active_branch = $dev_info ? $dev_info->branch : null;
101 | $branches = array( 'stable', 'trunk', 'rc' );
102 | foreach ( $manifest->pr as $pr ) {
103 | $branches[] = $pr->branch;
104 | }
105 | asort( $branches );
106 | WP_CLI::line( 'Available branches: ' );
107 | foreach ( $branches as $branch ) {
108 | WP_CLI::line( ( $active_branch === $branch ? '* ' : ' ' ) . $branch );
109 | }
110 | }
111 |
112 | /**
113 | * Activate a branch for a plugin.
114 | *
115 | * ## Options
116 | *
117 | *
118 | * : The plugin to activate a branch for.
119 | *
120 | *
121 | * : The branch to activate.
122 | *
123 | * ## Examples
124 | *
125 | * wp jetpack-beta activate jetpack trunk
126 | * wp jetpack-beta activate jetpack master (deprecated alias for trunk)
127 | * wp jetpack-beta activate jetpack stable
128 | * wp jetpack-beta activate jetpack rc
129 | * wp jetpack-beta activate jetpack 9.8
130 | * wp jetpack-beta activate jetpack update/some-branch
131 | *
132 | * @param array $args Arguments passed to CLI.
133 | */
134 | public function activate( $args ) {
135 | $this->validation_checks();
136 |
137 | $plugin = Plugin::get_plugin( $args[0], true );
138 | if ( ! $plugin ) {
139 | // translators: %s: Plugin slug that was not found.
140 | WP_CLI::error( sprintf( __( 'Plugin \'%s\' is not known. Use `wp jetpack-beta list` to list known plugins', 'jetpack-beta' ), $args[0] ) );
141 | }
142 |
143 | if ( 'trunk' === $args[1] || 'master' === $args[1] ) {
144 | $source = 'trunk';
145 | $id = '';
146 | // translators: %1$s: Plugin name.
147 | $premsg = __( 'Activating %1$s trunk branch', 'jetpack-beta' );
148 | // translators: %1$s: Plugin name.
149 | $postmsg = __( '%1$s is now on the trunk branch', 'jetpack-beta' );
150 | } elseif ( 'stable' === $args[1] ) {
151 | $source = 'stable';
152 | $id = '';
153 | // translators: %1$s: Plugin name.
154 | $premsg = __( 'Activating %1$s latest release', 'jetpack-beta' );
155 | // translators: %1$s: Plugin name.
156 | $postmsg = __( '%1$s is now on the latest release', 'jetpack-beta' );
157 | } elseif ( 'rc' === $args[1] ) {
158 | $source = 'rc';
159 | $id = '';
160 | // translators: %1$s: Plugin name.
161 | $premsg = __( 'Activating %1$s release candidate', 'jetpack-beta' );
162 | // translators: %1$s: Plugin name.
163 | $postmsg = __( '%1$s is now on the latest release candidate', 'jetpack-beta' );
164 | } elseif ( preg_match( '/^\d+(?:\.\d+)(?:-beta\d*)?$/', $args[1] ) ) {
165 | $source = 'release';
166 | $id = $args[1];
167 | // translators: %1$s: Plugin name. %2$s: Version number.
168 | $premsg = __( 'Activating %1$s release version %2$s', 'jetpack-beta' );
169 | // translators: %1$s: Plugin name. %2$s: Version number.
170 | $postmsg = __( '%1$s is now on release version %2$s', 'jetpack-beta' );
171 | } else {
172 | $source = 'pr';
173 | $id = $args[1];
174 | // translators: %1$s: Plugin name. %2$s: Branch name.
175 | $premsg = __( 'Activating %1$s branch %2$s', 'jetpack-beta' );
176 | // translators: %1$s: Plugin name. %2$s: Branch name.
177 | $postmsg = __( '%1$s is now on branch %2$s', 'jetpack-beta' );
178 | }
179 |
180 | WP_CLI::line( sprintf( $premsg, $plugin->get_name(), $id ) );
181 | $ret = $plugin->install_and_activate( $source, $id );
182 | if ( is_wp_error( $ret ) ) {
183 | WP_CLI::error( $ret->get_error_message() );
184 | } else {
185 | WP_CLI::line( sprintf( $postmsg, $plugin->get_name(), $id ) );
186 | }
187 | }
188 |
189 | /**
190 | * Validate environment.
191 | */
192 | private function validation_checks() {
193 | if ( is_multisite() && ! is_main_site() ) {
194 | WP_CLI::error( __( 'Secondary sites in multisite instalations are not supported', 'jetpack-beta' ) );
195 | }
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/src/class-parsedownext.php:
--------------------------------------------------------------------------------
1 | InlineTypes['#'][] = 'PRLink';
33 | $this->inlineMarkerList .= '#';
34 | }
35 |
36 | /**
37 | * Set the PR link format (and enable PR links).
38 | *
39 | * @param string $format Printf-style format string. Should include `%d` for the PR number.
40 | * @return $this
41 | */
42 | public function setPRLinkFormat( $format ) {
43 | $this->prLinkFormat = $format;
44 | return $this;
45 | }
46 |
47 | /**
48 | * Link PRs.
49 | *
50 | * @param array $excerpt Excerpt.
51 | * @return array|null
52 | */
53 | protected function inlinePRLink( $excerpt ) {
54 | if ( null === $this->prLinkFormat ||
55 | ! preg_match( '/^#(\d+)/', $excerpt['text'], $m )
56 | ) {
57 | return null;
58 | }
59 |
60 | return array(
61 | 'extent' => strlen( $m[0] ),
62 | 'element' => array(
63 | 'name' => 'a',
64 | 'text' => $m[0],
65 | 'attributes' => array(
66 | 'href' => sprintf( $this->prLinkFormat, (int) $m[1] ),
67 | ),
68 | ),
69 | );
70 | }
71 |
72 | /**
73 | * Remove HTML comments.
74 | *
75 | * Parsedown disables its code that does this in safe mode. Restore it here.
76 | *
77 | * @param array $excerpt Excerpt.
78 | * @return array|null
79 | */
80 | protected function inlineMarkup( $excerpt ) {
81 | // Code adapted from vendor/erusev/parsedown/Parsedown.php
82 | if ( $excerpt['text'][1] === '!' && preg_match( '/^/s', $excerpt['text'], $m ) ) {
83 | return array(
84 | 'markup' => '', // Just strip it, don't preserve it like Parsedown non-safe-mode does.
85 | 'extent' => strlen( $m[0] ),
86 | );
87 | }
88 |
89 | return null;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/class-plugindataexception.php:
--------------------------------------------------------------------------------
1 | 'jetpack-beta' ), $query );
32 |
33 | // If it's multisite, and a plugin is specified, and the plugin is network-activated,
34 | // link to the network URL instead of the regular one.
35 | if ( is_multisite() && isset( $query['plugin'] ) ) {
36 | $prefix = $query['plugin'] . '/';
37 | $l = strlen( $prefix );
38 | foreach ( Plugin::get_plugin_file_map() as $nondev => $dev ) {
39 | if ( substr( $nondev, 0, $l ) !== $prefix ) {
40 | continue;
41 | }
42 | if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
43 | require_once ABSPATH . '/wp-admin/includes/plugin.php';
44 | }
45 | if ( is_plugin_active_for_network( $nondev ) || is_plugin_active_for_network( $dev ) ) {
46 | return network_admin_url( 'admin.php?' . http_build_query( $query ) );
47 | }
48 | break;
49 | }
50 | }
51 |
52 | return admin_url( 'admin.php?' . http_build_query( $query ) );
53 | }
54 |
55 | /**
56 | * List options to sync.
57 | */
58 | public static function options_to_sync() {
59 | return array(
60 | 'jp_beta_autoupdate',
61 | 'jp_beta_email_notifications',
62 | );
63 | }
64 |
65 | /**
66 | * Get WP Option: jp_beta_autoupdate
67 | */
68 | public static function is_set_to_autoupdate() {
69 | return get_option( 'jp_beta_autoupdate', false );
70 | }
71 |
72 | /**
73 | * Get WP Option: jp_beta_email_notifications
74 | */
75 | public static function is_set_to_email_notifications() {
76 | return get_option( 'jp_beta_email_notifications', true );
77 | }
78 |
79 | /**
80 | * Helper function used to fetch remote data from WordPress.org, GitHub, and betadownload.jetpack.me
81 | *
82 | * @param string $url - Url being fetched.
83 | * @param string $transient - Transient name (manifest|org_data|github_commits_).
84 | * @param bool $bypass - Whether to bypass cached response.
85 | */
86 | public static function get_remote_data( $url, $transient, $bypass = false ) {
87 | $prefix = 'jetpack_beta_';
88 | $cache = get_site_transient( $prefix . $transient );
89 | if ( $cache && ! $bypass ) {
90 | return $cache;
91 | }
92 |
93 | $remote_manifest = wp_remote_get( $url );
94 |
95 | if ( is_wp_error( $remote_manifest ) ) {
96 | return false;
97 | }
98 |
99 | $cache = json_decode( wp_remote_retrieve_body( $remote_manifest ) );
100 | set_site_transient( $prefix . $transient, $cache, MINUTE_IN_SECONDS * 15 );
101 |
102 | return $cache;
103 | }
104 |
105 | /**
106 | * Delete set transients, e.g. when plugin is deactivated.
107 | */
108 | public static function delete_all_transiants() {
109 | global $wpdb;
110 |
111 | // Multisite uses wp_sitemeta for transients. Non-multisite uses wp_options.
112 | if ( is_multisite() ) {
113 | $sql = "SELECT meta_key AS n FROM {$wpdb->sitemeta} WHERE meta_key LIKE %s AND site_id = %d";
114 | $extra_vals = array( get_current_network_id() );
115 | } else {
116 | $sql = "SELECT option_name AS n FROM {$wpdb->options} WHERE option_name LIKE %s";
117 | $extra_vals = array();
118 | }
119 |
120 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
121 | $results = $wpdb->get_results( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_jetpack_beta_' ) . '%', ...$extra_vals ) );
122 | foreach ( $results as $row ) {
123 | delete_site_transient( substr( $row->n, 16 ) );
124 | }
125 | }
126 |
127 | /**
128 | * Test whether the Beta Tester has been used.
129 | *
130 | * In other words, if any -dev version has been downloaded yet.
131 | *
132 | * @return bool
133 | */
134 | public static function has_been_used() {
135 | foreach ( Plugin::get_plugin_file_map() as $dev ) {
136 | if ( file_exists( WP_PLUGIN_DIR . "/$dev" ) || file_exists( WPMU_PLUGIN_DIR . "/$dev" ) ) {
137 | return true;
138 | }
139 | }
140 |
141 | return false;
142 | }
143 |
144 | /**
145 | * Lists plugins needing an update.
146 | *
147 | * @param bool $include_stable Set true to include stable versions.
148 | * @return object[] Keys are plugin files, values are the plugin objects.
149 | */
150 | public static function plugins_needing_update( $include_stable = false ) {
151 | require_once ABSPATH . 'wp-admin/includes/plugin.php';
152 | require_once ABSPATH . 'wp-admin/includes/update.php';
153 |
154 | // Determine the plugins needing updating.
155 | wp_clean_plugins_cache();
156 | ob_start();
157 | wp_update_plugins();
158 | ob_end_clean();
159 | $updates = get_plugin_updates();
160 |
161 | // See if any of our plugins are to be updated.
162 | $our_plugins = Plugin::get_plugin_file_map();
163 | if ( $include_stable ) {
164 | $our_plugins += array_flip( $our_plugins );
165 | }
166 | $our_plugins[] = JPBETA__PLUGIN_FOLDER . '/jetpack-beta.php';
167 |
168 | return array_intersect_key( $updates, array_flip( $our_plugins ) );
169 | }
170 |
171 | /**
172 | * Rendering markdown for testing instructions.
173 | *
174 | * @param Plugin $plugin Plugin being processed.
175 | * @param string $content Markdown content to render.
176 | * @return string HTML.
177 | */
178 | public static function render_markdown( Plugin $plugin, $content ) {
179 | return ParsedownExt::instance()
180 | ->setSafeMode( true )
181 | ->setPRLinkFormat( "https://github.com/{$plugin->repo()}/pull/%d" )
182 | ->text( $content );
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/vendor/autoload.php:
--------------------------------------------------------------------------------
1 | = 7.0. [#34192]
89 |
90 | ## [0.2.25] - 2023-11-14
91 |
92 | ## [0.2.24] - 2023-10-30
93 | ### Fixed
94 | - Handle Akismet submenu even if Jetpack is present, as Jetpack now relies on this package to do so. [#33559]
95 |
96 | ## [0.2.23] - 2023-09-19
97 | ### Changed
98 | - Updated Jetpack submenu sort order so individual features are alpha-sorted. [#32958]
99 |
100 | ## [0.2.22] - 2023-09-11
101 | ### Fixed
102 | - Akismet: update naming to common form [#32908]
103 |
104 | ## [0.2.21] - 2023-08-23
105 | ### Changed
106 | - Updated package dependencies. [#32605]
107 |
108 | ## [0.2.20] - 2023-04-25
109 | ### Fixed
110 | - Avoid errors when used in combination with an older version of the Logo package. [#30136]
111 |
112 | ## [0.2.19] - 2023-04-10
113 | ### Added
114 | - Add Jetpack Autoloader package suggestion. [#29988]
115 |
116 | ## [0.2.18] - 2023-04-04
117 | ### Changed
118 | - Menu icon: update to latest version of the Jetpack logo [#29418]
119 |
120 | ## [0.2.17] - 2023-02-20
121 | ### Changed
122 | - Minor internal updates.
123 |
124 | ## [0.2.16] - 2023-01-25
125 | ### Changed
126 | - Minor internal updates.
127 |
128 | ## [0.2.15] - 2023-01-11
129 | ### Changed
130 | - Updated package dependencies.
131 |
132 | ## [0.2.14] - 2022-12-02
133 | ### Changed
134 | - Updated package dependencies. [#27688]
135 |
136 | ## [0.2.13] - 2022-11-22
137 | ### Changed
138 | - Updated package dependencies. [#27043]
139 |
140 | ## [0.2.12] - 2022-09-20
141 | ### Changed
142 | - Updated package dependencies.
143 |
144 | ## [0.2.11] - 2022-07-26
145 | ### Changed
146 | - Updated package dependencies. [#25158]
147 |
148 | ## [0.2.10] - 2022-07-12
149 | ### Changed
150 | - Updated package dependencies.
151 |
152 | ## [0.2.9] - 2022-06-21
153 | ### Changed
154 | - Renaming master to trunk.
155 |
156 | ## [0.2.8] - 2022-06-14
157 | ### Changed
158 | - Updated package dependencies.
159 |
160 | ## [0.2.7] - 2022-04-26
161 | ### Changed
162 | - Update package.json metadata.
163 |
164 | ## [0.2.6] - 2022-04-05
165 | ### Changed
166 | - Updated package dependencies.
167 |
168 | ## [0.2.5] - 2022-03-08
169 | ### Fixed
170 | - Do not handle Akismet submenu if Jetpack plugin is present
171 |
172 | ## [0.2.4] - 2022-02-09
173 | ### Added
174 | - Support for akismet menu with stand-alone plugins
175 |
176 | ### Fixed
177 | - Fixes menu order working around a bug in add_submenu_page
178 |
179 | ## [0.2.3] - 2022-01-25
180 | ### Changed
181 | - Updated package dependencies.
182 |
183 | ## [0.2.2] - 2022-01-18
184 | ### Changed
185 | - General: update required node version to v16.13.2
186 |
187 | ## [0.2.1] - 2022-01-04
188 | ### Changed
189 | - Switch to pcov for code coverage.
190 | - Updated package dependencies
191 |
192 | ## [0.2.0] - 2021-12-14
193 | ### Added
194 | - New method to get the top level menu item
195 |
196 | ## [0.1.1] - 2021-11-17
197 | ### Changed
198 | - Set `convertDeprecationsToExceptions` true in PHPUnit config.
199 | - Update PHPUnit configs to include just what needs coverage rather than include everything then try to exclude stuff that doesn't.
200 |
201 | ## 0.1.0 - 2021-10-13
202 | ### Added
203 | - Created the package.
204 |
205 | ### Changed
206 | - Updated package dependencies.
207 |
208 | ### Fixed
209 | - Fixing menu visibility issues.
210 |
211 | [0.5.10]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.9...0.5.10
212 | [0.5.9]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.8...0.5.9
213 | [0.5.8]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.7...0.5.8
214 | [0.5.7]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.6...0.5.7
215 | [0.5.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.5...0.5.6
216 | [0.5.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.4...0.5.5
217 | [0.5.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.3...0.5.4
218 | [0.5.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.2...0.5.3
219 | [0.5.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.1...0.5.2
220 | [0.5.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.5.0...0.5.1
221 | [0.5.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.6...0.5.0
222 | [0.4.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.5...0.4.6
223 | [0.4.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.4...0.4.5
224 | [0.4.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.3...0.4.4
225 | [0.4.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.2...0.4.3
226 | [0.4.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.1...0.4.2
227 | [0.4.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.4.0...0.4.1
228 | [0.4.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.3.2...0.4.0
229 | [0.3.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.3.1...0.3.2
230 | [0.3.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.3.0...0.3.1
231 | [0.3.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.25...0.3.0
232 | [0.2.25]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.24...0.2.25
233 | [0.2.24]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.23...0.2.24
234 | [0.2.23]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.22...0.2.23
235 | [0.2.22]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.21...0.2.22
236 | [0.2.21]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.20...0.2.21
237 | [0.2.20]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.19...0.2.20
238 | [0.2.19]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.18...0.2.19
239 | [0.2.18]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.17...0.2.18
240 | [0.2.17]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.16...0.2.17
241 | [0.2.16]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.15...0.2.16
242 | [0.2.15]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.14...0.2.15
243 | [0.2.14]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.13...0.2.14
244 | [0.2.13]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.12...0.2.13
245 | [0.2.12]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.11...0.2.12
246 | [0.2.11]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.10...0.2.11
247 | [0.2.10]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.9...0.2.10
248 | [0.2.9]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.8...0.2.9
249 | [0.2.8]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.7...0.2.8
250 | [0.2.7]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.6...0.2.7
251 | [0.2.6]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.5...0.2.6
252 | [0.2.5]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.4...0.2.5
253 | [0.2.4]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.3...0.2.4
254 | [0.2.3]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.2...0.2.3
255 | [0.2.2]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.1...0.2.2
256 | [0.2.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.2.0...0.2.1
257 | [0.2.0]: https://github.com/Automattic/jetpack-admin-ui/compare/0.1.1...0.2.0
258 | [0.1.1]: https://github.com/Automattic/jetpack-admin-ui/compare/0.1.0...0.1.1
259 |
--------------------------------------------------------------------------------
/vendor/automattic/jetpack-admin-ui/README.md:
--------------------------------------------------------------------------------
1 | # admin-ui
2 |
3 | Generic Jetpack wp-admin UI elements
4 | ## How to use
5 | ### Menu Registration
6 |
7 | Use the Admin_Menu class to add your plugin under the Jetpack top level menu in WP-Admin.
8 |
9 | This package will make sure to register the top level menu, if not registered yet, and will add the new menu(s) item(s) under it.
10 |
11 | Use the `add_menu` to register your menu, no need to do it inside the `admin_menu` hook. You can do it in your plugin initialization.
12 |
13 | The parameters this method gets are the same parameters `add_submenu_page` gets, except that you don't need to inform `parent` menu.
14 |
15 | Example:
16 |
17 | ```PHP
18 | use Automattic\Jetpack\Admin_UI\Admin_Menu;
19 |
20 | $page_suffix = Admin_Menu::add_menu(
21 | __( 'My Awesome plugin', 'my-awesome-plugin' ),
22 | __( 'My Awesome plugin', 'my-awesome-plugin' ),
23 | 'manage_options',
24 | 'my-awesome-plugin',
25 | '__my_plugin_page_callback'
26 | );
27 | add_action( 'load-' . $page_suffix, 'my_plugin_do_stuff_on_page_load' );
28 |
29 | ```
30 | ## Security
31 |
32 | Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic).
33 |
34 | ## License
35 |
36 | admin-ui is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)
37 |
38 |
--------------------------------------------------------------------------------
/vendor/automattic/jetpack-admin-ui/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | Full details of the Automattic Security Policy can be found on [automattic.com](https://automattic.com/security/).
4 |
5 | ## Supported Versions
6 |
7 | Generally, only the latest version of Jetpack and its associated plugins have continued support. If a critical vulnerability is found in the current version of a plugin, we may opt to backport any patches to previous versions.
8 |
9 | ## Reporting a Vulnerability
10 |
11 | Our HackerOne program covers the below plugin software, as well as a variety of related projects and infrastructure:
12 |
13 | * [Jetpack](https://jetpack.com/)
14 | * Jetpack Backup
15 | * Jetpack Boost
16 | * Jetpack CRM
17 | * Jetpack Protect
18 | * Jetpack Search
19 | * Jetpack Social
20 | * Jetpack VideoPress
21 |
22 | **For responsible disclosure of security issues and to be eligible for our bug bounty program, please submit your report via the [HackerOne](https://hackerone.com/automattic) portal.**
23 |
24 | Our most critical targets are:
25 |
26 | * Jetpack and the Jetpack composer packages (all within this repo)
27 | * Jetpack.com -- the primary marketing site.
28 | * cloud.jetpack.com -- a management site.
29 | * wordpress.com -- the shared management site for both Jetpack and WordPress.com sites.
30 |
31 | For more targets, see the `In Scope` section on [HackerOne](https://hackerone.com/automattic).
32 |
33 | _Please note that the **WordPress software is a separate entity** from Automattic. Please report vulnerabilities for WordPress through [the WordPress Foundation's HackerOne page](https://hackerone.com/wordpress)._
34 |
35 | ## Guidelines
36 |
37 | We're committed to working with security researchers to resolve the vulnerabilities they discover. You can help us by following these guidelines:
38 |
39 | * Follow [HackerOne's disclosure guidelines](https://www.hackerone.com/disclosure-guidelines).
40 | * Pen-testing Production:
41 | * Please **setup a local environment** instead whenever possible. Most of our code is open source (see above).
42 | * If that's not possible, **limit any data access/modification** to the bare minimum necessary to reproduce a PoC.
43 | * **_Don't_ automate form submissions!** That's very annoying for us, because it adds extra work for the volunteers who manage those systems, and reduces the signal/noise ratio in our communication channels.
44 | * To be eligible for a bounty, all of these guidelines must be followed.
45 | * Be Patient - Give us a reasonable time to correct the issue before you disclose the vulnerability.
46 |
47 | We also expect you to comply with all applicable laws. You're responsible to pay any taxes associated with your bounties.
48 |
--------------------------------------------------------------------------------
/vendor/automattic/jetpack-admin-ui/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "automattic/jetpack-admin-ui",
3 | "description": "Generic Jetpack wp-admin UI elements",
4 | "type": "jetpack-library",
5 | "license": "GPL-2.0-or-later",
6 | "require": {
7 | "php": ">=7.2"
8 | },
9 | "require-dev": {
10 | "yoast/phpunit-polyfills": "^4.0.0",
11 | "automattic/jetpack-changelogger": "^6.0.5",
12 | "automattic/jetpack-logo": "^3.0.5",
13 | "automattic/jetpack-test-environment": "@dev",
14 | "automattic/phpunit-select-config": "^1.0.3"
15 | },
16 | "suggest": {
17 | "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package."
18 | },
19 | "autoload": {
20 | "classmap": [
21 | "src/"
22 | ]
23 | },
24 | "scripts": {
25 | "phpunit": [
26 | "phpunit-select-config phpunit.#.xml.dist --colors=always"
27 | ],
28 | "test-coverage": [
29 | "php -dpcov.directory=. ./vendor/bin/phpunit-select-config phpunit.#.xml.dist --coverage-php \"$COVERAGE_DIR/php.cov\""
30 | ],
31 | "test-php": [
32 | "@composer phpunit"
33 | ]
34 | },
35 | "minimum-stability": "dev",
36 | "prefer-stable": true,
37 | "extra": {
38 | "autotagger": true,
39 | "mirror-repo": "Automattic/jetpack-admin-ui",
40 | "textdomain": "jetpack-admin-ui",
41 | "changelogger": {
42 | "link-template": "https://github.com/Automattic/jetpack-admin-ui/compare/${old}...${new}"
43 | },
44 | "branch-alias": {
45 | "dev-trunk": "0.5.x-dev"
46 | },
47 | "version-constants": {
48 | "::PACKAGE_VERSION": "src/class-admin-menu.php"
49 | }
50 | },
51 | "config": {
52 | "allow-plugins": {
53 | "roots/wordpress-core-installer": true
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/automattic/jetpack-admin-ui/src/class-admin-menu.php:
--------------------------------------------------------------------------------
1 | get_base64_logo()
79 | : 'dashicons-admin-plugins';
80 |
81 | if ( ! $jetpack_plugin_present ) {
82 | add_menu_page(
83 | 'Jetpack',
84 | 'Jetpack',
85 | 'edit_posts',
86 | 'jetpack',
87 | '__return_null',
88 | $icon,
89 | 3
90 | );
91 |
92 | // If Jetpack plugin is not present, user will only be able to see this menu if they have enough capability to at least one of the sub menus being added.
93 | $can_see_toplevel_menu = false;
94 | }
95 |
96 | /**
97 | * The add_sub_menu function has a bug and will not keep the right order of menu items.
98 | *
99 | * @see https://core.trac.wordpress.org/ticket/52035
100 | * Let's order the items before registering them.
101 | * Since this all happens after the Jetpack plugin menu items were added, all items will be added after Jetpack plugin items - unless position is very low number (smaller than the number of menu items present in Jetpack plugin).
102 | */
103 | usort(
104 | self::$menu_items,
105 | function ( $a, $b ) {
106 | $position_a = empty( $a['position'] ) ? 0 : $a['position'];
107 | $position_b = empty( $b['position'] ) ? 0 : $b['position'];
108 | $result = $position_a <=> $position_b;
109 |
110 | if ( 0 === $result ) {
111 | $result = strcmp( $a['menu_title'], $b['menu_title'] );
112 | }
113 |
114 | return $result;
115 | }
116 | );
117 |
118 | foreach ( self::$menu_items as $menu_item ) {
119 | if ( ! current_user_can( $menu_item['capability'] ) ) {
120 | continue;
121 | }
122 |
123 | $can_see_toplevel_menu = true;
124 |
125 | add_submenu_page(
126 | 'jetpack',
127 | $menu_item['page_title'],
128 | $menu_item['menu_title'],
129 | $menu_item['capability'],
130 | $menu_item['menu_slug'],
131 | $menu_item['function'],
132 | $menu_item['position']
133 | );
134 | }
135 |
136 | if ( ! $jetpack_plugin_present ) {
137 | remove_submenu_page( 'jetpack', 'jetpack' );
138 | }
139 |
140 | if ( ! $can_see_toplevel_menu ) {
141 | remove_menu_page( 'jetpack' );
142 | }
143 | }
144 |
145 | /**
146 | * Adds a new submenu to the Jetpack Top level menu
147 | *
148 | * The parameters this method accepts are the same as @see add_submenu_page. This class will
149 | * aggreagate all menu items registered by stand-alone plugins and make sure they all go under the same
150 | * Jetpack top level menu. It will also handle the top level menu registration in case the Jetpack plugin is not present.
151 | *
152 | * @param string $page_title The text to be displayed in the title tags of the page when the menu
153 | * is selected.
154 | * @param string $menu_title The text to be used for the menu.
155 | * @param string $capability The capability required for this menu to be displayed to the user.
156 | * @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu
157 | * and only include lowercase alphanumeric, dashes, and underscores characters
158 | * to be compatible with sanitize_key().
159 | * @param callable|null $function The function to be called to output the content for this page.
160 | * @param int $position The position in the menu order this item should appear. Leave empty typically.
161 | *
162 | * @return string The resulting page's hook_suffix
163 | */
164 | public static function add_menu( $page_title, $menu_title, $capability, $menu_slug, $function, $position = null ) {
165 | self::init();
166 | self::$menu_items[] = compact( 'page_title', 'menu_title', 'capability', 'menu_slug', 'function', 'position' );
167 |
168 | /**
169 | * Let's return the page hook so consumers can use.
170 | * We know all pages will be under Jetpack top level menu page, so we can hardcode the first part of the string.
171 | * Using get_plugin_page_hookname here won't work because the top level page is not registered yet.
172 | */
173 | return 'jetpack_page_' . $menu_slug;
174 | }
175 |
176 | /**
177 | * Removes an already added submenu
178 | *
179 | * @param string $menu_slug The slug of the submenu to remove.
180 | *
181 | * @return array|false The removed submenu on success, false if not found.
182 | */
183 | public static function remove_menu( $menu_slug ) {
184 |
185 | foreach ( self::$menu_items as $index => $menu_item ) {
186 | if ( $menu_item['menu_slug'] === $menu_slug ) {
187 | unset( self::$menu_items[ $index ] );
188 |
189 | return $menu_item;
190 | }
191 | }
192 |
193 | return false;
194 | }
195 |
196 | /**
197 | * Gets the slug for the first item under the Jetpack top level menu
198 | *
199 | * @return string|null
200 | */
201 | public static function get_top_level_menu_item_slug() {
202 | global $submenu;
203 | if ( ! empty( $submenu['jetpack'] ) ) {
204 | $item = reset( $submenu['jetpack'] );
205 | if ( isset( $item[2] ) ) {
206 | return $item[2];
207 | }
208 | }
209 | }
210 |
211 | /**
212 | * Gets the URL for the first item under the Jetpack top level menu
213 | *
214 | * @param string $fallback If Jetpack menu is not there or no children is found, return this fallback instead. Default to admin_url().
215 | * @return string
216 | */
217 | public static function get_top_level_menu_item_url( $fallback = false ) {
218 | $slug = self::get_top_level_menu_item_slug();
219 |
220 | if ( $slug ) {
221 | $url = menu_page_url( $slug, false );
222 | return $url;
223 | }
224 |
225 | $url = $fallback ? $fallback : admin_url();
226 | return $url;
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/vendor/composer/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Copyright (c) Nils Adermann, Jordi Boggiano
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is furnished
9 | to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
22 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_classmap.php:
--------------------------------------------------------------------------------
1 | $baseDir . '/src/class-admin.php',
10 | 'Automattic\\JetpackBeta\\AutoupdateSelf' => $baseDir . '/src/class-autoupdateself.php',
11 | 'Automattic\\JetpackBeta\\CliCommand' => $baseDir . '/src/class-clicommand.php',
12 | 'Automattic\\JetpackBeta\\Hooks' => $baseDir . '/src/class-hooks.php',
13 | 'Automattic\\JetpackBeta\\ParsedownExt' => $baseDir . '/src/class-parsedownext.php',
14 | 'Automattic\\JetpackBeta\\Plugin' => $baseDir . '/src/class-plugin.php',
15 | 'Automattic\\JetpackBeta\\PluginDataException' => $baseDir . '/src/class-plugindataexception.php',
16 | 'Automattic\\JetpackBeta\\Utils' => $baseDir . '/src/class-utils.php',
17 | 'Automattic\\Jetpack\\Admin_UI\\Admin_Menu' => $vendorDir . '/automattic/jetpack-admin-ui/src/class-admin-menu.php',
18 | 'Automattic\\Jetpack\\Autoloader\\AutoloadFileWriter' => $vendorDir . '/automattic/jetpack-autoloader/src/AutoloadFileWriter.php',
19 | 'Automattic\\Jetpack\\Autoloader\\AutoloadGenerator' => $vendorDir . '/automattic/jetpack-autoloader/src/AutoloadGenerator.php',
20 | 'Automattic\\Jetpack\\Autoloader\\AutoloadProcessor' => $vendorDir . '/automattic/jetpack-autoloader/src/AutoloadProcessor.php',
21 | 'Automattic\\Jetpack\\Autoloader\\CustomAutoloaderPlugin' => $vendorDir . '/automattic/jetpack-autoloader/src/CustomAutoloaderPlugin.php',
22 | 'Automattic\\Jetpack\\Autoloader\\ManifestGenerator' => $vendorDir . '/automattic/jetpack-autoloader/src/ManifestGenerator.php',
23 | 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
24 | 'Composer\\Semver\\Comparator' => $vendorDir . '/composer/semver/src/Comparator.php',
25 | 'Composer\\Semver\\CompilingMatcher' => $vendorDir . '/composer/semver/src/CompilingMatcher.php',
26 | 'Composer\\Semver\\Constraint\\Bound' => $vendorDir . '/composer/semver/src/Constraint/Bound.php',
27 | 'Composer\\Semver\\Constraint\\Constraint' => $vendorDir . '/composer/semver/src/Constraint/Constraint.php',
28 | 'Composer\\Semver\\Constraint\\ConstraintInterface' => $vendorDir . '/composer/semver/src/Constraint/ConstraintInterface.php',
29 | 'Composer\\Semver\\Constraint\\MatchAllConstraint' => $vendorDir . '/composer/semver/src/Constraint/MatchAllConstraint.php',
30 | 'Composer\\Semver\\Constraint\\MatchNoneConstraint' => $vendorDir . '/composer/semver/src/Constraint/MatchNoneConstraint.php',
31 | 'Composer\\Semver\\Constraint\\MultiConstraint' => $vendorDir . '/composer/semver/src/Constraint/MultiConstraint.php',
32 | 'Composer\\Semver\\Interval' => $vendorDir . '/composer/semver/src/Interval.php',
33 | 'Composer\\Semver\\Intervals' => $vendorDir . '/composer/semver/src/Intervals.php',
34 | 'Composer\\Semver\\Semver' => $vendorDir . '/composer/semver/src/Semver.php',
35 | 'Composer\\Semver\\VersionParser' => $vendorDir . '/composer/semver/src/VersionParser.php',
36 | 'Parsedown' => $vendorDir . '/erusev/parsedown/Parsedown.php',
37 | );
38 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_namespaces.php:
--------------------------------------------------------------------------------
1 | array($vendorDir . '/erusev/parsedown'),
10 | );
11 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_psr4.php:
--------------------------------------------------------------------------------
1 | array($vendorDir . '/composer/semver/src'),
10 | 'Automattic\\Jetpack\\Autoloader\\' => array($vendorDir . '/automattic/jetpack-autoloader/src'),
11 | );
12 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | setClassMapAuthoritative(true);
35 | $loader->register(true);
36 |
37 | return $loader;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_static.php:
--------------------------------------------------------------------------------
1 |
11 | array (
12 | 'Composer\\Semver\\' => 16,
13 | ),
14 | 'A' =>
15 | array (
16 | 'Automattic\\Jetpack\\Autoloader\\' => 30,
17 | ),
18 | );
19 |
20 | public static $prefixDirsPsr4 = array (
21 | 'Composer\\Semver\\' =>
22 | array (
23 | 0 => __DIR__ . '/..' . '/composer/semver/src',
24 | ),
25 | 'Automattic\\Jetpack\\Autoloader\\' =>
26 | array (
27 | 0 => __DIR__ . '/..' . '/automattic/jetpack-autoloader/src',
28 | ),
29 | );
30 |
31 | public static $prefixesPsr0 = array (
32 | 'P' =>
33 | array (
34 | 'Parsedown' =>
35 | array (
36 | 0 => __DIR__ . '/..' . '/erusev/parsedown',
37 | ),
38 | ),
39 | );
40 |
41 | public static $classMap = array (
42 | 'Automattic\\JetpackBeta\\Admin' => __DIR__ . '/../..' . '/src/class-admin.php',
43 | 'Automattic\\JetpackBeta\\AutoupdateSelf' => __DIR__ . '/../..' . '/src/class-autoupdateself.php',
44 | 'Automattic\\JetpackBeta\\CliCommand' => __DIR__ . '/../..' . '/src/class-clicommand.php',
45 | 'Automattic\\JetpackBeta\\Hooks' => __DIR__ . '/../..' . '/src/class-hooks.php',
46 | 'Automattic\\JetpackBeta\\ParsedownExt' => __DIR__ . '/../..' . '/src/class-parsedownext.php',
47 | 'Automattic\\JetpackBeta\\Plugin' => __DIR__ . '/../..' . '/src/class-plugin.php',
48 | 'Automattic\\JetpackBeta\\PluginDataException' => __DIR__ . '/../..' . '/src/class-plugindataexception.php',
49 | 'Automattic\\JetpackBeta\\Utils' => __DIR__ . '/../..' . '/src/class-utils.php',
50 | 'Automattic\\Jetpack\\Admin_UI\\Admin_Menu' => __DIR__ . '/..' . '/automattic/jetpack-admin-ui/src/class-admin-menu.php',
51 | 'Automattic\\Jetpack\\Autoloader\\AutoloadFileWriter' => __DIR__ . '/..' . '/automattic/jetpack-autoloader/src/AutoloadFileWriter.php',
52 | 'Automattic\\Jetpack\\Autoloader\\AutoloadGenerator' => __DIR__ . '/..' . '/automattic/jetpack-autoloader/src/AutoloadGenerator.php',
53 | 'Automattic\\Jetpack\\Autoloader\\AutoloadProcessor' => __DIR__ . '/..' . '/automattic/jetpack-autoloader/src/AutoloadProcessor.php',
54 | 'Automattic\\Jetpack\\Autoloader\\CustomAutoloaderPlugin' => __DIR__ . '/..' . '/automattic/jetpack-autoloader/src/CustomAutoloaderPlugin.php',
55 | 'Automattic\\Jetpack\\Autoloader\\ManifestGenerator' => __DIR__ . '/..' . '/automattic/jetpack-autoloader/src/ManifestGenerator.php',
56 | 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
57 | 'Composer\\Semver\\Comparator' => __DIR__ . '/..' . '/composer/semver/src/Comparator.php',
58 | 'Composer\\Semver\\CompilingMatcher' => __DIR__ . '/..' . '/composer/semver/src/CompilingMatcher.php',
59 | 'Composer\\Semver\\Constraint\\Bound' => __DIR__ . '/..' . '/composer/semver/src/Constraint/Bound.php',
60 | 'Composer\\Semver\\Constraint\\Constraint' => __DIR__ . '/..' . '/composer/semver/src/Constraint/Constraint.php',
61 | 'Composer\\Semver\\Constraint\\ConstraintInterface' => __DIR__ . '/..' . '/composer/semver/src/Constraint/ConstraintInterface.php',
62 | 'Composer\\Semver\\Constraint\\MatchAllConstraint' => __DIR__ . '/..' . '/composer/semver/src/Constraint/MatchAllConstraint.php',
63 | 'Composer\\Semver\\Constraint\\MatchNoneConstraint' => __DIR__ . '/..' . '/composer/semver/src/Constraint/MatchNoneConstraint.php',
64 | 'Composer\\Semver\\Constraint\\MultiConstraint' => __DIR__ . '/..' . '/composer/semver/src/Constraint/MultiConstraint.php',
65 | 'Composer\\Semver\\Interval' => __DIR__ . '/..' . '/composer/semver/src/Interval.php',
66 | 'Composer\\Semver\\Intervals' => __DIR__ . '/..' . '/composer/semver/src/Intervals.php',
67 | 'Composer\\Semver\\Semver' => __DIR__ . '/..' . '/composer/semver/src/Semver.php',
68 | 'Composer\\Semver\\VersionParser' => __DIR__ . '/..' . '/composer/semver/src/VersionParser.php',
69 | 'Parsedown' => __DIR__ . '/..' . '/erusev/parsedown/Parsedown.php',
70 | );
71 |
72 | public static function getInitializer(ClassLoader $loader)
73 | {
74 | return \Closure::bind(function () use ($loader) {
75 | $loader->prefixLengthsPsr4 = ComposerStaticInit567fa3f555de8fd218dfdc1688bb97b5_betaⓥ4_1_4_alpha::$prefixLengthsPsr4;
76 | $loader->prefixDirsPsr4 = ComposerStaticInit567fa3f555de8fd218dfdc1688bb97b5_betaⓥ4_1_4_alpha::$prefixDirsPsr4;
77 | $loader->prefixesPsr0 = ComposerStaticInit567fa3f555de8fd218dfdc1688bb97b5_betaⓥ4_1_4_alpha::$prefixesPsr0;
78 | $loader->classMap = ComposerStaticInit567fa3f555de8fd218dfdc1688bb97b5_betaⓥ4_1_4_alpha::$classMap;
79 |
80 | }, null, ClassLoader::class);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/vendor/composer/installed.php:
--------------------------------------------------------------------------------
1 | array(
3 | 'name' => 'automattic/jetpack-beta',
4 | 'pretty_version' => 'dev-trunk',
5 | 'version' => 'dev-trunk',
6 | 'reference' => null,
7 | 'type' => 'wordpress-plugin',
8 | 'install_path' => __DIR__ . '/../../',
9 | 'aliases' => array(),
10 | 'dev' => false,
11 | ),
12 | 'versions' => array(
13 | 'automattic/jetpack-admin-ui' => array(
14 | 'pretty_version' => '0.5.10',
15 | 'version' => '0.5.10.0',
16 | 'reference' => 'b401350377de9ff16304bad0aefb4cbae0b21302',
17 | 'type' => 'jetpack-library',
18 | 'install_path' => __DIR__ . '/../automattic/jetpack-admin-ui',
19 | 'aliases' => array(),
20 | 'dev_requirement' => false,
21 | ),
22 | 'automattic/jetpack-autoloader' => array(
23 | 'pretty_version' => '5.0.7',
24 | 'version' => '5.0.7.0',
25 | 'reference' => '0a6cb86e686558422b04ed1befee2bb71c941250',
26 | 'type' => 'composer-plugin',
27 | 'install_path' => __DIR__ . '/../automattic/jetpack-autoloader',
28 | 'aliases' => array(),
29 | 'dev_requirement' => false,
30 | ),
31 | 'automattic/jetpack-beta' => array(
32 | 'pretty_version' => 'dev-trunk',
33 | 'version' => 'dev-trunk',
34 | 'reference' => null,
35 | 'type' => 'wordpress-plugin',
36 | 'install_path' => __DIR__ . '/../../',
37 | 'aliases' => array(),
38 | 'dev_requirement' => false,
39 | ),
40 | 'composer/semver' => array(
41 | 'pretty_version' => '3.4.3',
42 | 'version' => '3.4.3.0',
43 | 'reference' => '4313d26ada5e0c4edfbd1dc481a92ff7bff91f12',
44 | 'type' => 'library',
45 | 'install_path' => __DIR__ . '/./semver',
46 | 'aliases' => array(),
47 | 'dev_requirement' => false,
48 | ),
49 | 'erusev/parsedown' => array(
50 | 'pretty_version' => '1.7.4',
51 | 'version' => '1.7.4.0',
52 | 'reference' => 'cb17b6477dfff935958ba01325f2e8a2bfa6dab3',
53 | 'type' => 'library',
54 | 'install_path' => __DIR__ . '/../erusev/parsedown',
55 | 'aliases' => array(),
56 | 'dev_requirement' => false,
57 | ),
58 | ),
59 | );
60 |
--------------------------------------------------------------------------------
/vendor/composer/jetpack_autoload_classmap.php:
--------------------------------------------------------------------------------
1 | array(
10 | 'version' => '5.0.7',
11 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-autoloader.php'
12 | ),
13 | 'Autoloader_Handler' => array(
14 | 'version' => '5.0.7',
15 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-autoloader-handler.php'
16 | ),
17 | 'Autoloader_Locator' => array(
18 | 'version' => '5.0.7',
19 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-autoloader-locator.php'
20 | ),
21 | 'Automattic\\JetpackBeta\\Admin' => array(
22 | 'version' => 'dev-trunk',
23 | 'path' => $baseDir . '/src/class-admin.php'
24 | ),
25 | 'Automattic\\JetpackBeta\\AutoupdateSelf' => array(
26 | 'version' => 'dev-trunk',
27 | 'path' => $baseDir . '/src/class-autoupdateself.php'
28 | ),
29 | 'Automattic\\JetpackBeta\\CliCommand' => array(
30 | 'version' => 'dev-trunk',
31 | 'path' => $baseDir . '/src/class-clicommand.php'
32 | ),
33 | 'Automattic\\JetpackBeta\\Hooks' => array(
34 | 'version' => 'dev-trunk',
35 | 'path' => $baseDir . '/src/class-hooks.php'
36 | ),
37 | 'Automattic\\JetpackBeta\\ParsedownExt' => array(
38 | 'version' => 'dev-trunk',
39 | 'path' => $baseDir . '/src/class-parsedownext.php'
40 | ),
41 | 'Automattic\\JetpackBeta\\Plugin' => array(
42 | 'version' => 'dev-trunk',
43 | 'path' => $baseDir . '/src/class-plugin.php'
44 | ),
45 | 'Automattic\\JetpackBeta\\PluginDataException' => array(
46 | 'version' => 'dev-trunk',
47 | 'path' => $baseDir . '/src/class-plugindataexception.php'
48 | ),
49 | 'Automattic\\JetpackBeta\\Utils' => array(
50 | 'version' => 'dev-trunk',
51 | 'path' => $baseDir . '/src/class-utils.php'
52 | ),
53 | 'Automattic\\Jetpack\\Admin_UI\\Admin_Menu' => array(
54 | 'version' => '0.5.10.0',
55 | 'path' => $vendorDir . '/automattic/jetpack-admin-ui/src/class-admin-menu.php'
56 | ),
57 | 'Automattic\\Jetpack\\Autoloader\\AutoloadFileWriter' => array(
58 | 'version' => '5.0.7',
59 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/AutoloadFileWriter.php'
60 | ),
61 | 'Automattic\\Jetpack\\Autoloader\\AutoloadGenerator' => array(
62 | 'version' => '5.0.7',
63 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/AutoloadGenerator.php'
64 | ),
65 | 'Automattic\\Jetpack\\Autoloader\\AutoloadProcessor' => array(
66 | 'version' => '5.0.7',
67 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/AutoloadProcessor.php'
68 | ),
69 | 'Automattic\\Jetpack\\Autoloader\\CustomAutoloaderPlugin' => array(
70 | 'version' => '5.0.7',
71 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/CustomAutoloaderPlugin.php'
72 | ),
73 | 'Automattic\\Jetpack\\Autoloader\\ManifestGenerator' => array(
74 | 'version' => '5.0.7',
75 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/ManifestGenerator.php'
76 | ),
77 | 'Composer\\Semver\\Comparator' => array(
78 | 'version' => '3.4.3.0',
79 | 'path' => $vendorDir . '/composer/semver/src/Comparator.php'
80 | ),
81 | 'Composer\\Semver\\CompilingMatcher' => array(
82 | 'version' => '3.4.3.0',
83 | 'path' => $vendorDir . '/composer/semver/src/CompilingMatcher.php'
84 | ),
85 | 'Composer\\Semver\\Constraint\\Bound' => array(
86 | 'version' => '3.4.3.0',
87 | 'path' => $vendorDir . '/composer/semver/src/Constraint/Bound.php'
88 | ),
89 | 'Composer\\Semver\\Constraint\\Constraint' => array(
90 | 'version' => '3.4.3.0',
91 | 'path' => $vendorDir . '/composer/semver/src/Constraint/Constraint.php'
92 | ),
93 | 'Composer\\Semver\\Constraint\\ConstraintInterface' => array(
94 | 'version' => '3.4.3.0',
95 | 'path' => $vendorDir . '/composer/semver/src/Constraint/ConstraintInterface.php'
96 | ),
97 | 'Composer\\Semver\\Constraint\\MatchAllConstraint' => array(
98 | 'version' => '3.4.3.0',
99 | 'path' => $vendorDir . '/composer/semver/src/Constraint/MatchAllConstraint.php'
100 | ),
101 | 'Composer\\Semver\\Constraint\\MatchNoneConstraint' => array(
102 | 'version' => '3.4.3.0',
103 | 'path' => $vendorDir . '/composer/semver/src/Constraint/MatchNoneConstraint.php'
104 | ),
105 | 'Composer\\Semver\\Constraint\\MultiConstraint' => array(
106 | 'version' => '3.4.3.0',
107 | 'path' => $vendorDir . '/composer/semver/src/Constraint/MultiConstraint.php'
108 | ),
109 | 'Composer\\Semver\\Interval' => array(
110 | 'version' => '3.4.3.0',
111 | 'path' => $vendorDir . '/composer/semver/src/Interval.php'
112 | ),
113 | 'Composer\\Semver\\Intervals' => array(
114 | 'version' => '3.4.3.0',
115 | 'path' => $vendorDir . '/composer/semver/src/Intervals.php'
116 | ),
117 | 'Composer\\Semver\\Semver' => array(
118 | 'version' => '3.4.3.0',
119 | 'path' => $vendorDir . '/composer/semver/src/Semver.php'
120 | ),
121 | 'Composer\\Semver\\VersionParser' => array(
122 | 'version' => '3.4.3.0',
123 | 'path' => $vendorDir . '/composer/semver/src/VersionParser.php'
124 | ),
125 | 'Container' => array(
126 | 'version' => '5.0.7',
127 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-container.php'
128 | ),
129 | 'Hook_Manager' => array(
130 | 'version' => '5.0.7',
131 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-hook-manager.php'
132 | ),
133 | 'Latest_Autoloader_Guard' => array(
134 | 'version' => '5.0.7',
135 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-latest-autoloader-guard.php'
136 | ),
137 | 'Manifest_Reader' => array(
138 | 'version' => '5.0.7',
139 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-manifest-reader.php'
140 | ),
141 | 'PHP_Autoloader' => array(
142 | 'version' => '5.0.7',
143 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-php-autoloader.php'
144 | ),
145 | 'Parsedown' => array(
146 | 'version' => '1.7.4.0',
147 | 'path' => $vendorDir . '/erusev/parsedown/Parsedown.php'
148 | ),
149 | 'Path_Processor' => array(
150 | 'version' => '5.0.7',
151 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-path-processor.php'
152 | ),
153 | 'Plugin_Locator' => array(
154 | 'version' => '5.0.7',
155 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-plugin-locator.php'
156 | ),
157 | 'Plugins_Handler' => array(
158 | 'version' => '5.0.7',
159 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-plugins-handler.php'
160 | ),
161 | 'Shutdown_Handler' => array(
162 | 'version' => '5.0.7',
163 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-shutdown-handler.php'
164 | ),
165 | 'Version_Loader' => array(
166 | 'version' => '5.0.7',
167 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-version-loader.php'
168 | ),
169 | 'Version_Selector' => array(
170 | 'version' => '5.0.7',
171 | 'path' => $vendorDir . '/automattic/jetpack-autoloader/src/class-version-selector.php'
172 | ),
173 | );
174 |
--------------------------------------------------------------------------------
/vendor/composer/platform_check.php:
--------------------------------------------------------------------------------
1 | = 70200)) {
8 | $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.';
9 | }
10 |
11 | if ($issues) {
12 | if (!headers_sent()) {
13 | header('HTTP/1.1 500 Internal Server Error');
14 | }
15 | if (!ini_get('display_errors')) {
16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
17 | fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
18 | } elseif (!headers_sent()) {
19 | echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
20 | }
21 | }
22 | trigger_error(
23 | 'Composer detected issues in your platform: ' . implode(' ', $issues),
24 | E_USER_ERROR
25 | );
26 | }
27 |
--------------------------------------------------------------------------------
/vendor/composer/semver/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2015 Composer
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | of the Software, and to permit persons to whom the Software is furnished to do
8 | so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/vendor/composer/semver/README.md:
--------------------------------------------------------------------------------
1 | composer/semver
2 | ===============
3 |
4 | Semver (Semantic Versioning) library that offers utilities, version constraint parsing and validation.
5 |
6 | Originally written as part of [composer/composer](https://github.com/composer/composer),
7 | now extracted and made available as a stand-alone library.
8 |
9 | [](https://github.com/composer/semver/actions/workflows/continuous-integration.yml)
10 | [](https://github.com/composer/semver/actions/workflows/lint.yml)
11 | [](https://github.com/composer/semver/actions/workflows/phpstan.yml)
12 |
13 | Installation
14 | ------------
15 |
16 | Install the latest version with:
17 |
18 | ```bash
19 | composer require composer/semver
20 | ```
21 |
22 |
23 | Requirements
24 | ------------
25 |
26 | * PHP 5.3.2 is required but using the latest version of PHP is highly recommended.
27 |
28 |
29 | Version Comparison
30 | ------------------
31 |
32 | For details on how versions are compared, refer to the [Versions](https://getcomposer.org/doc/articles/versions.md)
33 | article in the documentation section of the [getcomposer.org](https://getcomposer.org) website.
34 |
35 |
36 | Basic usage
37 | -----------
38 |
39 | ### Comparator
40 |
41 | The [`Composer\Semver\Comparator`](https://github.com/composer/semver/blob/main/src/Comparator.php) class provides the following methods for comparing versions:
42 |
43 | * greaterThan($v1, $v2)
44 | * greaterThanOrEqualTo($v1, $v2)
45 | * lessThan($v1, $v2)
46 | * lessThanOrEqualTo($v1, $v2)
47 | * equalTo($v1, $v2)
48 | * notEqualTo($v1, $v2)
49 |
50 | Each function takes two version strings as arguments and returns a boolean. For example:
51 |
52 | ```php
53 | use Composer\Semver\Comparator;
54 |
55 | Comparator::greaterThan('1.25.0', '1.24.0'); // 1.25.0 > 1.24.0
56 | ```
57 |
58 | ### Semver
59 |
60 | The [`Composer\Semver\Semver`](https://github.com/composer/semver/blob/main/src/Semver.php) class provides the following methods:
61 |
62 | * satisfies($version, $constraints)
63 | * satisfiedBy(array $versions, $constraint)
64 | * sort($versions)
65 | * rsort($versions)
66 |
67 | ### Intervals
68 |
69 | The [`Composer\Semver\Intervals`](https://github.com/composer/semver/blob/main/src/Intervals.php) static class provides
70 | a few utilities to work with complex constraints or read version intervals from a constraint:
71 |
72 | ```php
73 | use Composer\Semver\Intervals;
74 |
75 | // Checks whether $candidate is a subset of $constraint
76 | Intervals::isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint);
77 |
78 | // Checks whether $a and $b have any intersection, equivalent to $a->matches($b)
79 | Intervals::haveIntersections(ConstraintInterface $a, ConstraintInterface $b);
80 |
81 | // Optimizes a complex multi constraint by merging all intervals down to the smallest
82 | // possible multi constraint. The drawbacks are this is not very fast, and the resulting
83 | // multi constraint will have no human readable prettyConstraint configured on it
84 | Intervals::compactConstraint(ConstraintInterface $constraint);
85 |
86 | // Creates an array of numeric intervals and branch constraints representing a given constraint
87 | Intervals::get(ConstraintInterface $constraint);
88 |
89 | // Clears the memoization cache when you are done processing constraints
90 | Intervals::clear()
91 | ```
92 |
93 | See the class docblocks for more details.
94 |
95 |
96 | License
97 | -------
98 |
99 | composer/semver is licensed under the MIT License, see the LICENSE file for details.
100 |
--------------------------------------------------------------------------------
/vendor/composer/semver/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "composer/semver",
3 | "description": "Semver library that offers utilities, version constraint parsing and validation.",
4 | "type": "library",
5 | "license": "MIT",
6 | "keywords": [
7 | "semver",
8 | "semantic",
9 | "versioning",
10 | "validation"
11 | ],
12 | "authors": [
13 | {
14 | "name": "Nils Adermann",
15 | "email": "naderman@naderman.de",
16 | "homepage": "http://www.naderman.de"
17 | },
18 | {
19 | "name": "Jordi Boggiano",
20 | "email": "j.boggiano@seld.be",
21 | "homepage": "http://seld.be"
22 | },
23 | {
24 | "name": "Rob Bast",
25 | "email": "rob.bast@gmail.com",
26 | "homepage": "http://robbast.nl"
27 | }
28 | ],
29 | "support": {
30 | "irc": "ircs://irc.libera.chat:6697/composer",
31 | "issues": "https://github.com/composer/semver/issues"
32 | },
33 | "require": {
34 | "php": "^5.3.2 || ^7.0 || ^8.0"
35 | },
36 | "require-dev": {
37 | "symfony/phpunit-bridge": "^3 || ^7",
38 | "phpstan/phpstan": "^1.11"
39 | },
40 | "autoload": {
41 | "psr-4": {
42 | "Composer\\Semver\\": "src"
43 | }
44 | },
45 | "autoload-dev": {
46 | "psr-4": {
47 | "Composer\\Semver\\": "tests"
48 | }
49 | },
50 | "extra": {
51 | "branch-alias": {
52 | "dev-main": "3.x-dev"
53 | }
54 | },
55 | "scripts": {
56 | "test": "SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor/bin/simple-phpunit",
57 | "phpstan": "@php vendor/bin/phpstan analyse"
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/Comparator.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver;
13 |
14 | use Composer\Semver\Constraint\Constraint;
15 |
16 | class Comparator
17 | {
18 | /**
19 | * Evaluates the expression: $version1 > $version2.
20 | *
21 | * @param string $version1
22 | * @param string $version2
23 | *
24 | * @return bool
25 | */
26 | public static function greaterThan($version1, $version2)
27 | {
28 | return self::compare($version1, '>', $version2);
29 | }
30 |
31 | /**
32 | * Evaluates the expression: $version1 >= $version2.
33 | *
34 | * @param string $version1
35 | * @param string $version2
36 | *
37 | * @return bool
38 | */
39 | public static function greaterThanOrEqualTo($version1, $version2)
40 | {
41 | return self::compare($version1, '>=', $version2);
42 | }
43 |
44 | /**
45 | * Evaluates the expression: $version1 < $version2.
46 | *
47 | * @param string $version1
48 | * @param string $version2
49 | *
50 | * @return bool
51 | */
52 | public static function lessThan($version1, $version2)
53 | {
54 | return self::compare($version1, '<', $version2);
55 | }
56 |
57 | /**
58 | * Evaluates the expression: $version1 <= $version2.
59 | *
60 | * @param string $version1
61 | * @param string $version2
62 | *
63 | * @return bool
64 | */
65 | public static function lessThanOrEqualTo($version1, $version2)
66 | {
67 | return self::compare($version1, '<=', $version2);
68 | }
69 |
70 | /**
71 | * Evaluates the expression: $version1 == $version2.
72 | *
73 | * @param string $version1
74 | * @param string $version2
75 | *
76 | * @return bool
77 | */
78 | public static function equalTo($version1, $version2)
79 | {
80 | return self::compare($version1, '==', $version2);
81 | }
82 |
83 | /**
84 | * Evaluates the expression: $version1 != $version2.
85 | *
86 | * @param string $version1
87 | * @param string $version2
88 | *
89 | * @return bool
90 | */
91 | public static function notEqualTo($version1, $version2)
92 | {
93 | return self::compare($version1, '!=', $version2);
94 | }
95 |
96 | /**
97 | * Evaluates the expression: $version1 $operator $version2.
98 | *
99 | * @param string $version1
100 | * @param string $operator
101 | * @param string $version2
102 | *
103 | * @return bool
104 | *
105 | * @phpstan-param Constraint::STR_OP_* $operator
106 | */
107 | public static function compare($version1, $operator, $version2)
108 | {
109 | $constraint = new Constraint($operator, $version2);
110 |
111 | return $constraint->matchSpecific(new Constraint('==', $version1), true);
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/CompilingMatcher.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver;
13 |
14 | use Composer\Semver\Constraint\Constraint;
15 | use Composer\Semver\Constraint\ConstraintInterface;
16 |
17 | /**
18 | * Helper class to evaluate constraint by compiling and reusing the code to evaluate
19 | */
20 | class CompilingMatcher
21 | {
22 | /**
23 | * @var array
24 | * @phpstan-var array
25 | */
26 | private static $compiledCheckerCache = array();
27 | /**
28 | * @var array
29 | * @phpstan-var array
30 | */
31 | private static $resultCache = array();
32 |
33 | /** @var bool */
34 | private static $enabled;
35 |
36 | /**
37 | * @phpstan-var array
38 | */
39 | private static $transOpInt = array(
40 | Constraint::OP_EQ => Constraint::STR_OP_EQ,
41 | Constraint::OP_LT => Constraint::STR_OP_LT,
42 | Constraint::OP_LE => Constraint::STR_OP_LE,
43 | Constraint::OP_GT => Constraint::STR_OP_GT,
44 | Constraint::OP_GE => Constraint::STR_OP_GE,
45 | Constraint::OP_NE => Constraint::STR_OP_NE,
46 | );
47 |
48 | /**
49 | * Clears the memoization cache once you are done
50 | *
51 | * @return void
52 | */
53 | public static function clear()
54 | {
55 | self::$resultCache = array();
56 | self::$compiledCheckerCache = array();
57 | }
58 |
59 | /**
60 | * Evaluates the expression: $constraint match $operator $version
61 | *
62 | * @param ConstraintInterface $constraint
63 | * @param int $operator
64 | * @phpstan-param Constraint::OP_* $operator
65 | * @param string $version
66 | *
67 | * @return bool
68 | */
69 | public static function match(ConstraintInterface $constraint, $operator, $version)
70 | {
71 | $resultCacheKey = $operator.$constraint.';'.$version;
72 |
73 | if (isset(self::$resultCache[$resultCacheKey])) {
74 | return self::$resultCache[$resultCacheKey];
75 | }
76 |
77 | if (self::$enabled === null) {
78 | self::$enabled = !\in_array('eval', explode(',', (string) ini_get('disable_functions')), true);
79 | }
80 | if (!self::$enabled) {
81 | return self::$resultCache[$resultCacheKey] = $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
82 | }
83 |
84 | $cacheKey = $operator.$constraint;
85 | if (!isset(self::$compiledCheckerCache[$cacheKey])) {
86 | $code = $constraint->compile($operator);
87 | self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
88 | } else {
89 | $function = self::$compiledCheckerCache[$cacheKey];
90 | }
91 |
92 | return self::$resultCache[$resultCacheKey] = $function($version, strpos($version, 'dev-') === 0);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/Constraint/Bound.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver\Constraint;
13 |
14 | class Bound
15 | {
16 | /**
17 | * @var string
18 | */
19 | private $version;
20 |
21 | /**
22 | * @var bool
23 | */
24 | private $isInclusive;
25 |
26 | /**
27 | * @param string $version
28 | * @param bool $isInclusive
29 | */
30 | public function __construct($version, $isInclusive)
31 | {
32 | $this->version = $version;
33 | $this->isInclusive = $isInclusive;
34 | }
35 |
36 | /**
37 | * @return string
38 | */
39 | public function getVersion()
40 | {
41 | return $this->version;
42 | }
43 |
44 | /**
45 | * @return bool
46 | */
47 | public function isInclusive()
48 | {
49 | return $this->isInclusive;
50 | }
51 |
52 | /**
53 | * @return bool
54 | */
55 | public function isZero()
56 | {
57 | return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
58 | }
59 |
60 | /**
61 | * @return bool
62 | */
63 | public function isPositiveInfinity()
64 | {
65 | return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
66 | }
67 |
68 | /**
69 | * Compares a bound to another with a given operator.
70 | *
71 | * @param Bound $other
72 | * @param string $operator
73 | *
74 | * @return bool
75 | */
76 | public function compareTo(Bound $other, $operator)
77 | {
78 | if (!\in_array($operator, array('<', '>'), true)) {
79 | throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
80 | }
81 |
82 | // If they are the same it doesn't matter
83 | if ($this == $other) {
84 | return false;
85 | }
86 |
87 | $compareResult = version_compare($this->getVersion(), $other->getVersion());
88 |
89 | // Not the same version means we don't need to check if the bounds are inclusive or not
90 | if (0 !== $compareResult) {
91 | return (('>' === $operator) ? 1 : -1) === $compareResult;
92 | }
93 |
94 | // Question we're answering here is "am I higher than $other?"
95 | return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
96 | }
97 |
98 | public function __toString()
99 | {
100 | return sprintf(
101 | '%s [%s]',
102 | $this->getVersion(),
103 | $this->isInclusive() ? 'inclusive' : 'exclusive'
104 | );
105 | }
106 |
107 | /**
108 | * @return self
109 | */
110 | public static function zero()
111 | {
112 | return new Bound('0.0.0.0-dev', true);
113 | }
114 |
115 | /**
116 | * @return self
117 | */
118 | public static function positiveInfinity()
119 | {
120 | return new Bound(PHP_INT_MAX.'.0.0.0', false);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/Constraint/ConstraintInterface.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver\Constraint;
13 |
14 | /**
15 | * DO NOT IMPLEMENT this interface. It is only meant for usage as a type hint
16 | * in libraries relying on composer/semver but creating your own constraint class
17 | * that implements this interface is not a supported use case and will cause the
18 | * composer/semver components to return unexpected results.
19 | */
20 | interface ConstraintInterface
21 | {
22 | /**
23 | * Checks whether the given constraint intersects in any way with this constraint
24 | *
25 | * @param ConstraintInterface $provider
26 | *
27 | * @return bool
28 | */
29 | public function matches(ConstraintInterface $provider);
30 |
31 | /**
32 | * Provides a compiled version of the constraint for the given operator
33 | * The compiled version must be a PHP expression.
34 | * Executor of compile version must provide 2 variables:
35 | * - $v = the string version to compare with
36 | * - $b = whether or not the version is a non-comparable branch (starts with "dev-")
37 | *
38 | * @see Constraint::OP_* for the list of available operators.
39 | * @example return '!$b && version_compare($v, '1.0', '>')';
40 | *
41 | * @param int $otherOperator one Constraint::OP_*
42 | *
43 | * @return string
44 | *
45 | * @phpstan-param Constraint::OP_* $otherOperator
46 | */
47 | public function compile($otherOperator);
48 |
49 | /**
50 | * @return Bound
51 | */
52 | public function getUpperBound();
53 |
54 | /**
55 | * @return Bound
56 | */
57 | public function getLowerBound();
58 |
59 | /**
60 | * @return string
61 | */
62 | public function getPrettyString();
63 |
64 | /**
65 | * @param string|null $prettyString
66 | *
67 | * @return void
68 | */
69 | public function setPrettyString($prettyString);
70 |
71 | /**
72 | * @return string
73 | */
74 | public function __toString();
75 | }
76 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/Constraint/MatchAllConstraint.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver\Constraint;
13 |
14 | /**
15 | * Defines the absence of a constraint.
16 | *
17 | * This constraint matches everything.
18 | */
19 | class MatchAllConstraint implements ConstraintInterface
20 | {
21 | /** @var string|null */
22 | protected $prettyString;
23 |
24 | /**
25 | * @param ConstraintInterface $provider
26 | *
27 | * @return bool
28 | */
29 | public function matches(ConstraintInterface $provider)
30 | {
31 | return true;
32 | }
33 |
34 | /**
35 | * {@inheritDoc}
36 | */
37 | public function compile($otherOperator)
38 | {
39 | return 'true';
40 | }
41 |
42 | /**
43 | * {@inheritDoc}
44 | */
45 | public function setPrettyString($prettyString)
46 | {
47 | $this->prettyString = $prettyString;
48 | }
49 |
50 | /**
51 | * {@inheritDoc}
52 | */
53 | public function getPrettyString()
54 | {
55 | if ($this->prettyString) {
56 | return $this->prettyString;
57 | }
58 |
59 | return (string) $this;
60 | }
61 |
62 | /**
63 | * {@inheritDoc}
64 | */
65 | public function __toString()
66 | {
67 | return '*';
68 | }
69 |
70 | /**
71 | * {@inheritDoc}
72 | */
73 | public function getUpperBound()
74 | {
75 | return Bound::positiveInfinity();
76 | }
77 |
78 | /**
79 | * {@inheritDoc}
80 | */
81 | public function getLowerBound()
82 | {
83 | return Bound::zero();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/Constraint/MatchNoneConstraint.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver\Constraint;
13 |
14 | /**
15 | * Blackhole of constraints, nothing escapes it
16 | */
17 | class MatchNoneConstraint implements ConstraintInterface
18 | {
19 | /** @var string|null */
20 | protected $prettyString;
21 |
22 | /**
23 | * @param ConstraintInterface $provider
24 | *
25 | * @return bool
26 | */
27 | public function matches(ConstraintInterface $provider)
28 | {
29 | return false;
30 | }
31 |
32 | /**
33 | * {@inheritDoc}
34 | */
35 | public function compile($otherOperator)
36 | {
37 | return 'false';
38 | }
39 |
40 | /**
41 | * {@inheritDoc}
42 | */
43 | public function setPrettyString($prettyString)
44 | {
45 | $this->prettyString = $prettyString;
46 | }
47 |
48 | /**
49 | * {@inheritDoc}
50 | */
51 | public function getPrettyString()
52 | {
53 | if ($this->prettyString) {
54 | return $this->prettyString;
55 | }
56 |
57 | return (string) $this;
58 | }
59 |
60 | /**
61 | * {@inheritDoc}
62 | */
63 | public function __toString()
64 | {
65 | return '[]';
66 | }
67 |
68 | /**
69 | * {@inheritDoc}
70 | */
71 | public function getUpperBound()
72 | {
73 | return new Bound('0.0.0.0-dev', false);
74 | }
75 |
76 | /**
77 | * {@inheritDoc}
78 | */
79 | public function getLowerBound()
80 | {
81 | return new Bound('0.0.0.0-dev', false);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/Interval.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver;
13 |
14 | use Composer\Semver\Constraint\Constraint;
15 |
16 | class Interval
17 | {
18 | /** @var Constraint */
19 | private $start;
20 | /** @var Constraint */
21 | private $end;
22 |
23 | public function __construct(Constraint $start, Constraint $end)
24 | {
25 | $this->start = $start;
26 | $this->end = $end;
27 | }
28 |
29 | /**
30 | * @return Constraint
31 | */
32 | public function getStart()
33 | {
34 | return $this->start;
35 | }
36 |
37 | /**
38 | * @return Constraint
39 | */
40 | public function getEnd()
41 | {
42 | return $this->end;
43 | }
44 |
45 | /**
46 | * @return Constraint
47 | */
48 | public static function fromZero()
49 | {
50 | static $zero;
51 |
52 | if (null === $zero) {
53 | $zero = new Constraint('>=', '0.0.0.0-dev');
54 | }
55 |
56 | return $zero;
57 | }
58 |
59 | /**
60 | * @return Constraint
61 | */
62 | public static function untilPositiveInfinity()
63 | {
64 | static $positiveInfinity;
65 |
66 | if (null === $positiveInfinity) {
67 | $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
68 | }
69 |
70 | return $positiveInfinity;
71 | }
72 |
73 | /**
74 | * @return self
75 | */
76 | public static function any()
77 | {
78 | return new self(self::fromZero(), self::untilPositiveInfinity());
79 | }
80 |
81 | /**
82 | * @return array{'names': string[], 'exclude': bool}
83 | */
84 | public static function anyDev()
85 | {
86 | // any == exclude nothing
87 | return array('names' => array(), 'exclude' => true);
88 | }
89 |
90 | /**
91 | * @return array{'names': string[], 'exclude': bool}
92 | */
93 | public static function noDev()
94 | {
95 | // nothing == no names included
96 | return array('names' => array(), 'exclude' => false);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/vendor/composer/semver/src/Semver.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view
9 | * the LICENSE file that was distributed with this source code.
10 | */
11 |
12 | namespace Composer\Semver;
13 |
14 | use Composer\Semver\Constraint\Constraint;
15 |
16 | class Semver
17 | {
18 | const SORT_ASC = 1;
19 | const SORT_DESC = -1;
20 |
21 | /** @var VersionParser */
22 | private static $versionParser;
23 |
24 | /**
25 | * Determine if given version satisfies given constraints.
26 | *
27 | * @param string $version
28 | * @param string $constraints
29 | *
30 | * @return bool
31 | */
32 | public static function satisfies($version, $constraints)
33 | {
34 | if (null === self::$versionParser) {
35 | self::$versionParser = new VersionParser();
36 | }
37 |
38 | $versionParser = self::$versionParser;
39 | $provider = new Constraint('==', $versionParser->normalize($version));
40 | $parsedConstraints = $versionParser->parseConstraints($constraints);
41 |
42 | return $parsedConstraints->matches($provider);
43 | }
44 |
45 | /**
46 | * Return all versions that satisfy given constraints.
47 | *
48 | * @param string[] $versions
49 | * @param string $constraints
50 | *
51 | * @return string[]
52 | */
53 | public static function satisfiedBy(array $versions, $constraints)
54 | {
55 | $versions = array_filter($versions, function ($version) use ($constraints) {
56 | return Semver::satisfies($version, $constraints);
57 | });
58 |
59 | return array_values($versions);
60 | }
61 |
62 | /**
63 | * Sort given array of versions.
64 | *
65 | * @param string[] $versions
66 | *
67 | * @return string[]
68 | */
69 | public static function sort(array $versions)
70 | {
71 | return self::usort($versions, self::SORT_ASC);
72 | }
73 |
74 | /**
75 | * Sort given array of versions in reverse.
76 | *
77 | * @param string[] $versions
78 | *
79 | * @return string[]
80 | */
81 | public static function rsort(array $versions)
82 | {
83 | return self::usort($versions, self::SORT_DESC);
84 | }
85 |
86 | /**
87 | * @param string[] $versions
88 | * @param int $direction
89 | *
90 | * @return string[]
91 | */
92 | private static function usort(array $versions, $direction)
93 | {
94 | if (null === self::$versionParser) {
95 | self::$versionParser = new VersionParser();
96 | }
97 |
98 | $versionParser = self::$versionParser;
99 | $normalized = array();
100 |
101 | // Normalize outside of usort() scope for minor performance increase.
102 | // Creates an array of arrays: [[normalized, key], ...]
103 | foreach ($versions as $key => $version) {
104 | $normalizedVersion = $versionParser->normalize($version);
105 | $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
106 | $normalized[] = array($normalizedVersion, $key);
107 | }
108 |
109 | usort($normalized, function (array $left, array $right) use ($direction) {
110 | if ($left[0] === $right[0]) {
111 | return 0;
112 | }
113 |
114 | if (Comparator::lessThan($left[0], $right[0])) {
115 | return -$direction;
116 | }
117 |
118 | return $direction;
119 | });
120 |
121 | // Recreate input array, using the original indexes which are now in sorted order.
122 | $sorted = array();
123 | foreach ($normalized as $item) {
124 | $sorted[] = $versions[$item[1]];
125 | }
126 |
127 | return $sorted;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/vendor/erusev/parsedown/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2018 Emanuil Rusev, erusev.com
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/vendor/erusev/parsedown/README.md:
--------------------------------------------------------------------------------
1 | > I also make [Caret](https://caret.io?ref=parsedown) - a Markdown editor for Mac and PC.
2 |
3 | ## Parsedown
4 |
5 | [](https://travis-ci.org/erusev/parsedown)
6 |
7 |
8 | Better Markdown Parser in PHP
9 |
10 | [Demo](http://parsedown.org/demo) |
11 | [Benchmarks](http://parsedown.org/speed) |
12 | [Tests](http://parsedown.org/tests/) |
13 | [Documentation](https://github.com/erusev/parsedown/wiki/)
14 |
15 | ### Features
16 |
17 | * One File
18 | * No Dependencies
19 | * Super Fast
20 | * Extensible
21 | * [GitHub flavored](https://help.github.com/articles/github-flavored-markdown)
22 | * Tested in 5.3 to 7.1 and in HHVM
23 | * [Markdown Extra extension](https://github.com/erusev/parsedown-extra)
24 |
25 | ### Installation
26 |
27 | Include `Parsedown.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown).
28 |
29 | ### Example
30 |
31 | ``` php
32 | $Parsedown = new Parsedown();
33 |
34 | echo $Parsedown->text('Hello _Parsedown_!'); # prints: Hello Parsedown!
35 | ```
36 |
37 | More examples in [the wiki](https://github.com/erusev/parsedown/wiki/) and in [this video tutorial](http://youtu.be/wYZBY8DEikI).
38 |
39 | ### Security
40 |
41 | Parsedown is capable of escaping user-input within the HTML that it generates. Additionally Parsedown will apply sanitisation to additional scripting vectors (such as scripting link destinations) that are introduced by the markdown syntax itself.
42 |
43 | To tell Parsedown that it is processing untrusted user-input, use the following:
44 | ```php
45 | $parsedown = new Parsedown;
46 | $parsedown->setSafeMode(true);
47 | ```
48 |
49 | If instead, you wish to allow HTML within untrusted user-input, but still want output to be free from XSS it is recommended that you make use of a HTML sanitiser that allows HTML tags to be whitelisted, like [HTML Purifier](http://htmlpurifier.org/).
50 |
51 | In both cases you should strongly consider employing defence-in-depth measures, like [deploying a Content-Security-Policy](https://scotthelme.co.uk/content-security-policy-an-introduction/) (a browser security feature) so that your page is likely to be safe even if an attacker finds a vulnerability in one of the first lines of defence above.
52 |
53 | #### Security of Parsedown Extensions
54 |
55 | Safe mode does not necessarily yield safe results when using extensions to Parsedown. Extensions should be evaluated on their own to determine their specific safety against XSS.
56 |
57 | ### Escaping HTML
58 | > ⚠️ **WARNING:** This method isn't safe from XSS!
59 |
60 | If you wish to escape HTML **in trusted input**, you can use the following:
61 | ```php
62 | $parsedown = new Parsedown;
63 | $parsedown->setMarkupEscaped(true);
64 | ```
65 |
66 | Beware that this still allows users to insert unsafe scripting vectors, such as links like `[xss](javascript:alert%281%29)`.
67 |
68 | ### Questions
69 |
70 | **How does Parsedown work?**
71 |
72 | It tries to read Markdown like a human. First, it looks at the lines. It’s interested in how the lines start. This helps it recognise blocks. It knows, for example, that if a line starts with a `-` then perhaps it belongs to a list. Once it recognises the blocks, it continues to the content. As it reads, it watches out for special characters. This helps it recognise inline elements (or inlines).
73 |
74 | We call this approach "line based". We believe that Parsedown is the first Markdown parser to use it. Since the release of Parsedown, other developers have used the same approach to develop other Markdown parsers in PHP and in other languages.
75 |
76 | **Is it compliant with CommonMark?**
77 |
78 | It passes most of the CommonMark tests. Most of the tests that don't pass deal with cases that are quite uncommon. Still, as CommonMark matures, compliance should improve.
79 |
80 | **Who uses it?**
81 |
82 | [Laravel Framework](https://laravel.com/), [Bolt CMS](http://bolt.cm/), [Grav CMS](http://getgrav.org/), [Herbie CMS](http://www.getherbie.org/), [Kirby CMS](http://getkirby.com/), [October CMS](http://octobercms.com/), [Pico CMS](http://picocms.org), [Statamic CMS](http://www.statamic.com/), [phpDocumentor](http://www.phpdoc.org/), [RaspberryPi.org](http://www.raspberrypi.org/), [Symfony demo](https://github.com/symfony/symfony-demo) and [more](https://packagist.org/packages/erusev/parsedown/dependents).
83 |
84 | **How can I help?**
85 |
86 | Use it, star it, share it and if you feel generous, [donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=528P3NZQMP8N2).
87 |
--------------------------------------------------------------------------------
/vendor/erusev/parsedown/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "erusev/parsedown",
3 | "description": "Parser for Markdown.",
4 | "keywords": ["markdown", "parser"],
5 | "homepage": "http://parsedown.org",
6 | "type": "library",
7 | "license": "MIT",
8 | "authors": [
9 | {
10 | "name": "Emanuil Rusev",
11 | "email": "hello@erusev.com",
12 | "homepage": "http://erusev.com"
13 | }
14 | ],
15 | "require": {
16 | "php": ">=5.3.0",
17 | "ext-mbstring": "*"
18 | },
19 | "require-dev": {
20 | "phpunit/phpunit": "^4.8.35"
21 | },
22 | "autoload": {
23 | "psr-0": {"Parsedown": ""}
24 | },
25 | "autoload-dev": {
26 | "psr-0": {
27 | "TestParsedown": "test/",
28 | "ParsedownTest": "test/",
29 | "CommonMarkTest": "test/",
30 | "CommonMarkTestWeak": "test/"
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-autoloader-handler.php:
--------------------------------------------------------------------------------
1 | php_autoloader = $php_autoloader;
57 | $this->hook_manager = $hook_manager;
58 | $this->manifest_reader = $manifest_reader;
59 | $this->version_selector = $version_selector;
60 | }
61 |
62 | /**
63 | * Checks to see whether or not an autoloader is currently in the process of initializing.
64 | *
65 | * @return bool
66 | */
67 | public function is_initializing() {
68 | // If no version has been set it means that no autoloader has started initializing yet.
69 | global $jetpack_autoloader_latest_version;
70 | if ( ! isset( $jetpack_autoloader_latest_version ) ) {
71 | return false;
72 | }
73 |
74 | // When the version is set but the classmap is not it ALWAYS means that this is the
75 | // latest autoloader and is being included by an older one.
76 | global $jetpack_packages_classmap;
77 | if ( empty( $jetpack_packages_classmap ) ) {
78 | return true;
79 | }
80 |
81 | // Version 2.4.0 added a new global and altered the reset semantics. We need to check
82 | // the other global as well since it may also point at initialization.
83 | // Note: We don't need to check for the class first because every autoloader that
84 | // will set the latest version global requires this class in the classmap.
85 | $replacing_version = $jetpack_packages_classmap[ AutoloadGenerator::class ]['version'];
86 | if ( $this->version_selector->is_dev_version( $replacing_version ) || version_compare( $replacing_version, '2.4.0.0', '>=' ) ) {
87 | global $jetpack_autoloader_loader;
88 | if ( ! isset( $jetpack_autoloader_loader ) ) {
89 | return true;
90 | }
91 | }
92 |
93 | return false;
94 | }
95 |
96 | /**
97 | * Activates an autoloader using the given plugins and activates it.
98 | *
99 | * @param string[] $plugins The plugins to initialize the autoloader for.
100 | */
101 | public function activate_autoloader( $plugins ) {
102 | global $jetpack_packages_psr4;
103 | $jetpack_packages_psr4 = array();
104 | $this->manifest_reader->read_manifests( $plugins, 'vendor/composer/jetpack_autoload_psr4.php', $jetpack_packages_psr4 );
105 |
106 | global $jetpack_packages_classmap;
107 | $jetpack_packages_classmap = array();
108 | $this->manifest_reader->read_manifests( $plugins, 'vendor/composer/jetpack_autoload_classmap.php', $jetpack_packages_classmap );
109 |
110 | global $jetpack_packages_filemap;
111 | $jetpack_packages_filemap = array();
112 | $this->manifest_reader->read_manifests( $plugins, 'vendor/composer/jetpack_autoload_filemap.php', $jetpack_packages_filemap );
113 |
114 | $loader = new Version_Loader(
115 | $this->version_selector,
116 | $jetpack_packages_classmap,
117 | $jetpack_packages_psr4,
118 | $jetpack_packages_filemap
119 | );
120 |
121 | $this->php_autoloader->register_autoloader( $loader );
122 |
123 | // Now that the autoloader is active we can load the filemap.
124 | $loader->load_filemap();
125 | }
126 |
127 | /**
128 | * Resets the active autoloader and all related global state.
129 | */
130 | public function reset_autoloader() {
131 | $this->php_autoloader->unregister_autoloader();
132 | $this->hook_manager->reset();
133 |
134 | // Clear all of the autoloader globals so that older autoloaders don't do anything strange.
135 | global $jetpack_autoloader_latest_version;
136 | $jetpack_autoloader_latest_version = null;
137 |
138 | global $jetpack_packages_classmap;
139 | $jetpack_packages_classmap = array(); // Must be array to avoid exceptions in old autoloaders!
140 |
141 | global $jetpack_packages_psr4;
142 | $jetpack_packages_psr4 = array(); // Must be array to avoid exceptions in old autoloaders!
143 |
144 | global $jetpack_packages_filemap;
145 | $jetpack_packages_filemap = array(); // Must be array to avoid exceptions in old autoloaders!
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-autoloader-locator.php:
--------------------------------------------------------------------------------
1 | version_selector = $version_selector;
33 | }
34 |
35 | /**
36 | * Finds the path to the plugin with the latest autoloader.
37 | *
38 | * @param array $plugin_paths An array of plugin paths.
39 | * @param string $latest_version The latest version reference. @phan-output-reference.
40 | *
41 | * @return string|null
42 | */
43 | public function find_latest_autoloader( $plugin_paths, &$latest_version ) {
44 | $latest_plugin = null;
45 |
46 | foreach ( $plugin_paths as $plugin_path ) {
47 | $version = $this->get_autoloader_version( $plugin_path );
48 | if ( ! $version || ! $this->version_selector->is_version_update_required( $latest_version, $version ) ) {
49 | continue;
50 | }
51 |
52 | $latest_version = $version;
53 | $latest_plugin = $plugin_path;
54 | }
55 |
56 | return $latest_plugin;
57 | }
58 |
59 | /**
60 | * Gets the path to the autoloader.
61 | *
62 | * @param string $plugin_path The path to the plugin.
63 | *
64 | * @return string
65 | */
66 | public function get_autoloader_path( $plugin_path ) {
67 | return trailingslashit( $plugin_path ) . 'vendor/autoload_packages.php';
68 | }
69 |
70 | /**
71 | * Gets the version for the autoloader.
72 | *
73 | * @param string $plugin_path The path to the plugin.
74 | *
75 | * @return string|null
76 | */
77 | public function get_autoloader_version( $plugin_path ) {
78 | $classmap = trailingslashit( $plugin_path ) . 'vendor/composer/jetpack_autoload_classmap.php';
79 | if ( ! file_exists( $classmap ) ) {
80 | return null;
81 | }
82 |
83 | $classmap = require $classmap;
84 | if ( isset( $classmap[ AutoloadGenerator::class ] ) ) {
85 | return $classmap[ AutoloadGenerator::class ]['version'];
86 | }
87 |
88 | return null;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-autoloader.php:
--------------------------------------------------------------------------------
1 | get( Autoloader_Handler::class );
35 |
36 | // If the autoloader is already initializing it means that it has included us as the latest.
37 | $was_included_by_autoloader = $autoloader_handler->is_initializing();
38 |
39 | /** @var Plugin_Locator $plugin_locator */
40 | $plugin_locator = $container->get( Plugin_Locator::class );
41 |
42 | /** @var Plugins_Handler $plugins_handler */
43 | $plugins_handler = $container->get( Plugins_Handler::class );
44 |
45 | // The current plugin is the one that we are attempting to initialize here.
46 | $current_plugin = $plugin_locator->find_current_plugin();
47 |
48 | // The active plugins are those that we were able to discover on the site. This list will not
49 | // include mu-plugins, those activated by code, or those who are hidden by filtering. We also
50 | // want to take care to not consider the current plugin unknown if it was included by an
51 | // autoloader. This avoids the case where a plugin will be marked "active" while deactivated
52 | // due to it having the latest autoloader.
53 | $active_plugins = $plugins_handler->get_active_plugins( true, ! $was_included_by_autoloader );
54 |
55 | // The cached plugins are all of those that were active or discovered by the autoloader during a previous request.
56 | // Note that it's possible this list will include plugins that have since been deactivated, but after a request
57 | // the cache should be updated and the deactivated plugins will be removed.
58 | $cached_plugins = $plugins_handler->get_cached_plugins();
59 |
60 | // We combine the active list and cached list to preemptively load classes for plugins that are
61 | // presently unknown but will be loaded during the request. While this may result in us considering packages in
62 | // deactivated plugins there shouldn't be any problems as a result and the eventual consistency is sufficient.
63 | $all_plugins = array_merge( $active_plugins, $cached_plugins );
64 |
65 | // In particular we also include the current plugin to address the case where it is the latest autoloader
66 | // but also unknown (and not cached). We don't want it in the active list because we don't know that it
67 | // is active but we need it in the all plugins list so that it is considered by the autoloader.
68 | $all_plugins[] = $current_plugin;
69 |
70 | // We require uniqueness in the array to avoid processing the same plugin more than once.
71 | $all_plugins = array_values( array_unique( $all_plugins ) );
72 |
73 | /** @var Latest_Autoloader_Guard $guard */
74 | $guard = $container->get( Latest_Autoloader_Guard::class );
75 | if ( $guard->should_stop_init( $current_plugin, $all_plugins, $was_included_by_autoloader ) ) {
76 | return;
77 | }
78 |
79 | // Initialize the autoloader using the handler now that we're ready.
80 | $autoloader_handler->activate_autoloader( $all_plugins );
81 |
82 | /** @var Hook_Manager $hook_manager */
83 | $hook_manager = $container->get( Hook_Manager::class );
84 |
85 | // Register a shutdown handler to clean up the autoloader.
86 | $hook_manager->add_action( 'shutdown', new Shutdown_Handler( $plugins_handler, $cached_plugins, $was_included_by_autoloader ) );
87 |
88 | // Register a plugins_loaded handler to check for conflicting autoloaders.
89 | $hook_manager->add_action( 'plugins_loaded', array( $guard, 'check_for_conflicting_autoloaders' ), 1 );
90 |
91 | // phpcs:enable Generic.Commenting.DocComment.MissingShort
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-container.php:
--------------------------------------------------------------------------------
1 | 'Hook_Manager',
25 | );
26 |
27 | /**
28 | * A map of all the dependencies we've registered with the container and created.
29 | *
30 | * @var array
31 | */
32 | protected $dependencies;
33 |
34 | /**
35 | * The constructor.
36 | */
37 | public function __construct() {
38 | $this->dependencies = array();
39 |
40 | $this->register_shared_dependencies();
41 | $this->register_dependencies();
42 | $this->initialize_globals();
43 | }
44 |
45 | /**
46 | * Gets a dependency out of the container.
47 | *
48 | * @param string $class The class to fetch.
49 | *
50 | * @return mixed
51 | * @throws \InvalidArgumentException When a class that isn't registered with the container is fetched.
52 | */
53 | public function get( $class ) {
54 | if ( ! isset( $this->dependencies[ $class ] ) ) {
55 | throw new \InvalidArgumentException( "Class '$class' is not registered with the container." );
56 | }
57 |
58 | return $this->dependencies[ $class ];
59 | }
60 |
61 | /**
62 | * Registers all of the dependencies that are shared between all instances of the autoloader.
63 | */
64 | private function register_shared_dependencies() {
65 | global $jetpack_autoloader_container_shared;
66 | if ( ! isset( $jetpack_autoloader_container_shared ) ) {
67 | $jetpack_autoloader_container_shared = array();
68 | }
69 |
70 | $key = self::SHARED_DEPENDENCY_KEYS[ Hook_Manager::class ];
71 | if ( ! isset( $jetpack_autoloader_container_shared[ $key ] ) ) {
72 | require_once __DIR__ . '/class-hook-manager.php';
73 | $jetpack_autoloader_container_shared[ $key ] = new Hook_Manager();
74 | }
75 | $this->dependencies[ Hook_Manager::class ] = &$jetpack_autoloader_container_shared[ $key ];
76 | }
77 |
78 | /**
79 | * Registers all of the dependencies with the container.
80 | */
81 | private function register_dependencies() {
82 | require_once __DIR__ . '/class-path-processor.php';
83 | $this->dependencies[ Path_Processor::class ] = new Path_Processor();
84 |
85 | require_once __DIR__ . '/class-plugin-locator.php';
86 | $this->dependencies[ Plugin_Locator::class ] = new Plugin_Locator(
87 | $this->get( Path_Processor::class )
88 | );
89 |
90 | require_once __DIR__ . '/class-version-selector.php';
91 | $this->dependencies[ Version_Selector::class ] = new Version_Selector();
92 |
93 | require_once __DIR__ . '/class-autoloader-locator.php';
94 | $this->dependencies[ Autoloader_Locator::class ] = new Autoloader_Locator(
95 | $this->get( Version_Selector::class )
96 | );
97 |
98 | require_once __DIR__ . '/class-php-autoloader.php';
99 | $this->dependencies[ PHP_Autoloader::class ] = new PHP_Autoloader();
100 |
101 | require_once __DIR__ . '/class-manifest-reader.php';
102 | $this->dependencies[ Manifest_Reader::class ] = new Manifest_Reader(
103 | $this->get( Version_Selector::class )
104 | );
105 |
106 | require_once __DIR__ . '/class-plugins-handler.php';
107 | $this->dependencies[ Plugins_Handler::class ] = new Plugins_Handler(
108 | $this->get( Plugin_Locator::class ),
109 | $this->get( Path_Processor::class )
110 | );
111 |
112 | require_once __DIR__ . '/class-autoloader-handler.php';
113 | $this->dependencies[ Autoloader_Handler::class ] = new Autoloader_Handler(
114 | $this->get( PHP_Autoloader::class ),
115 | $this->get( Hook_Manager::class ),
116 | $this->get( Manifest_Reader::class ),
117 | $this->get( Version_Selector::class )
118 | );
119 |
120 | require_once __DIR__ . '/class-latest-autoloader-guard.php';
121 | $this->dependencies[ Latest_Autoloader_Guard::class ] = new Latest_Autoloader_Guard(
122 | $this->get( Plugins_Handler::class ),
123 | $this->get( Autoloader_Handler::class ),
124 | $this->get( Autoloader_Locator::class )
125 | );
126 |
127 | // Register any classes that we will use elsewhere.
128 | require_once __DIR__ . '/class-version-loader.php';
129 | require_once __DIR__ . '/class-shutdown-handler.php';
130 | }
131 |
132 | /**
133 | * Initializes any of the globals needed by the autoloader.
134 | */
135 | private function initialize_globals() {
136 | /*
137 | * This global was retired in version 2.9. The value is set to 'false' to maintain
138 | * compatibility with older versions of the autoloader.
139 | */
140 | global $jetpack_autoloader_including_latest;
141 | $jetpack_autoloader_including_latest = false;
142 |
143 | // Not all plugins can be found using the locator. In cases where a plugin loads the autoloader
144 | // but was not discoverable, we will record them in this array to track them as "active".
145 | global $jetpack_autoloader_activating_plugins_paths;
146 | if ( ! isset( $jetpack_autoloader_activating_plugins_paths ) ) {
147 | $jetpack_autoloader_activating_plugins_paths = array();
148 | }
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-hook-manager.php:
--------------------------------------------------------------------------------
1 | registered_hooks = array();
29 | }
30 |
31 | /**
32 | * Adds an action to WordPress and registers it internally.
33 | *
34 | * @param string $tag The name of the action which is hooked.
35 | * @param callable $callable The function to call.
36 | * @param int $priority Used to specify the priority of the action.
37 | * @param int $accepted_args Used to specify the number of arguments the callable accepts.
38 | */
39 | public function add_action( $tag, $callable, $priority = 10, $accepted_args = 1 ) {
40 | $this->registered_hooks[ $tag ][] = array(
41 | 'priority' => $priority,
42 | 'callable' => $callable,
43 | );
44 |
45 | add_action( $tag, $callable, $priority, $accepted_args );
46 | }
47 |
48 | /**
49 | * Adds a filter to WordPress and registers it internally.
50 | *
51 | * @param string $tag The name of the filter which is hooked.
52 | * @param callable $callable The function to call.
53 | * @param int $priority Used to specify the priority of the filter.
54 | * @param int $accepted_args Used to specify the number of arguments the callable accepts.
55 | */
56 | public function add_filter( $tag, $callable, $priority = 10, $accepted_args = 1 ) {
57 | $this->registered_hooks[ $tag ][] = array(
58 | 'priority' => $priority,
59 | 'callable' => $callable,
60 | );
61 |
62 | add_filter( $tag, $callable, $priority, $accepted_args );
63 | }
64 |
65 | /**
66 | * Removes all of the registered hooks.
67 | */
68 | public function reset() {
69 | foreach ( $this->registered_hooks as $tag => $hooks ) {
70 | foreach ( $hooks as $hook ) {
71 | remove_filter( $tag, $hook['callable'], $hook['priority'] );
72 | }
73 | }
74 | $this->registered_hooks = array();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-latest-autoloader-guard.php:
--------------------------------------------------------------------------------
1 | plugins_handler = $plugins_handler;
47 | $this->autoloader_handler = $autoloader_handler;
48 | $this->autoloader_locator = $autoloader_locator;
49 | }
50 |
51 | /**
52 | * Indicates whether or not the autoloader should be initialized. Note that this function
53 | * has the side-effect of actually loading the latest autoloader in the event that this
54 | * is not it.
55 | *
56 | * @param string $current_plugin The current plugin we're checking.
57 | * @param string[] $plugins The active plugins to check for autoloaders in.
58 | * @param bool $was_included_by_autoloader Indicates whether or not this autoloader was included by another.
59 | *
60 | * @return bool True if we should stop initialization, otherwise false.
61 | */
62 | public function should_stop_init( $current_plugin, $plugins, $was_included_by_autoloader ) {
63 | global $jetpack_autoloader_latest_version;
64 |
65 | // We need to reset the autoloader when the plugins change because
66 | // that means the autoloader was generated with a different list.
67 | if ( $this->plugins_handler->have_plugins_changed( $plugins ) ) {
68 | $this->autoloader_handler->reset_autoloader();
69 | }
70 |
71 | // When the latest autoloader has already been found we don't need to search for it again.
72 | // We should take care however because this will also trigger if the autoloader has been
73 | // included by an older one.
74 | if ( isset( $jetpack_autoloader_latest_version ) && ! $was_included_by_autoloader ) {
75 | return true;
76 | }
77 |
78 | $latest_plugin = $this->autoloader_locator->find_latest_autoloader( $plugins, $jetpack_autoloader_latest_version );
79 | if ( isset( $latest_plugin ) && $latest_plugin !== $current_plugin ) {
80 | require $this->autoloader_locator->get_autoloader_path( $latest_plugin );
81 | return true;
82 | }
83 |
84 | return false;
85 | }
86 |
87 | /**
88 | * Check for conflicting autoloaders.
89 | *
90 | * A common source of strange and confusing problems is when another plugin
91 | * registers a Composer autoloader at a higher priority that us. If enabled,
92 | * check for this problem and warn about it.
93 | *
94 | * Called from the plugins_loaded hook.
95 | *
96 | * @since 3.1.0
97 | * @return void
98 | */
99 | public function check_for_conflicting_autoloaders() {
100 | if ( ! defined( 'JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS' ) || ! JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS ) {
101 | return;
102 | }
103 |
104 | global $jetpack_autoloader_loader;
105 | if ( ! isset( $jetpack_autoloader_loader ) ) {
106 | return;
107 | }
108 | $prefixes = array();
109 | foreach ( ( $jetpack_autoloader_loader->get_class_map() ?? array() ) as $classname => $data ) {
110 | $parts = explode( '\\', trim( $classname, '\\' ) );
111 | array_pop( $parts );
112 | while ( $parts ) {
113 | $prefixes[ implode( '\\', $parts ) . '\\' ] = true;
114 | array_pop( $parts );
115 | }
116 | }
117 | foreach ( ( $jetpack_autoloader_loader->get_psr4_map() ?? array() ) as $prefix => $data ) {
118 | $parts = explode( '\\', trim( $prefix, '\\' ) );
119 | while ( $parts ) {
120 | $prefixes[ implode( '\\', $parts ) . '\\' ] = true;
121 | array_pop( $parts );
122 | }
123 | }
124 |
125 | $autoload_chain = spl_autoload_functions();
126 | if ( ! $autoload_chain ) {
127 | return;
128 | }
129 |
130 | foreach ( $autoload_chain as $autoloader ) {
131 | // No need to check anything after us.
132 | if ( is_array( $autoloader ) && is_string( $autoloader[0] ) && substr( $autoloader[0], 0, strlen( __NAMESPACE__ ) + 1 ) === __NAMESPACE__ . '\\' ) {
133 | break;
134 | }
135 |
136 | // We can check Composer autoloaders easily enough.
137 | if ( is_array( $autoloader ) && $autoloader[0] instanceof \Composer\Autoload\ClassLoader && is_callable( array( $autoloader[0], 'getPrefixesPsr4' ) ) ) {
138 | $composer_autoloader = $autoloader[0];
139 | foreach ( $composer_autoloader->getClassMap() as $classname => $path ) {
140 | if ( $jetpack_autoloader_loader->find_class_file( $classname ) ) {
141 | $msg = "A Composer autoloader is registered with a higher priority than the Jetpack Autoloader and would also handle some of the classes we handle (e.g. $classname => $path). This may cause strange and confusing problems.";
142 | wp_trigger_error( '', $msg );
143 | continue 2;
144 | }
145 | }
146 | foreach ( $composer_autoloader->getPrefixesPsr4() as $prefix => $paths ) {
147 | if ( isset( $prefixes[ $prefix ] ) ) {
148 | $path = array_pop( $paths );
149 | $msg = "A Composer autoloader is registered with a higher priority than the Jetpack Autoloader and would also handle some of the namespaces we handle (e.g. $prefix => $path). This may cause strange and confusing problems.";
150 | wp_trigger_error( '', $msg );
151 | continue 2;
152 | }
153 | }
154 | foreach ( $composer_autoloader->getPrefixes() as $prefix => $paths ) {
155 | if ( isset( $prefixes[ $prefix ] ) ) {
156 | $path = array_pop( $paths );
157 | $msg = "A Composer autoloader is registered with a higher priority than the Jetpack Autoloader and would also handle some of the namespaces we handle (e.g. $prefix => $path). This may cause strange and confusing problems.";
158 | wp_trigger_error( '', $msg );
159 | continue 2;
160 | }
161 | }
162 | }
163 | }
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-manifest-reader.php:
--------------------------------------------------------------------------------
1 | version_selector = $version_selector;
31 | }
32 |
33 | /**
34 | * Reads all of the manifests in the given plugin paths.
35 | *
36 | * @param array $plugin_paths The paths to the plugins we're loading the manifest in.
37 | * @param string $manifest_path The path that we're loading the manifest from in each plugin.
38 | * @param array $path_map The path map to add the contents of the manifests to.
39 | *
40 | * @return array $path_map The path map we've built using the manifests in each plugin.
41 | */
42 | public function read_manifests( $plugin_paths, $manifest_path, &$path_map ) {
43 | $file_paths = array_map(
44 | function ( $path ) use ( $manifest_path ) {
45 | return trailingslashit( $path ) . $manifest_path;
46 | },
47 | $plugin_paths
48 | );
49 |
50 | foreach ( $file_paths as $path ) {
51 | $this->register_manifest( $path, $path_map );
52 | }
53 |
54 | return $path_map;
55 | }
56 |
57 | /**
58 | * Registers a plugin's manifest file with the path map.
59 | *
60 | * @param string $manifest_path The absolute path to the manifest that we're loading.
61 | * @param array $path_map The path map to add the contents of the manifest to.
62 | */
63 | protected function register_manifest( $manifest_path, &$path_map ) {
64 | if ( ! is_readable( $manifest_path ) ) {
65 | return;
66 | }
67 |
68 | $manifest = require $manifest_path;
69 | if ( ! is_array( $manifest ) ) {
70 | return;
71 | }
72 |
73 | foreach ( $manifest as $key => $data ) {
74 | $this->register_record( $key, $data, $path_map );
75 | }
76 | }
77 |
78 | /**
79 | * Registers an entry from the manifest in the path map.
80 | *
81 | * @param string $key The identifier for the entry we're registering.
82 | * @param array $data The data for the entry we're registering.
83 | * @param array $path_map The path map to add the contents of the manifest to.
84 | */
85 | protected function register_record( $key, $data, &$path_map ) {
86 | if ( isset( $path_map[ $key ]['version'] ) ) {
87 | $selected_version = $path_map[ $key ]['version'];
88 | } else {
89 | $selected_version = null;
90 | }
91 |
92 | if ( $this->version_selector->is_version_update_required( $selected_version, $data['version'] ) ) {
93 | $path_map[ $key ] = array(
94 | 'version' => $data['version'],
95 | 'path' => $data['path'],
96 | );
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-path-processor.php:
--------------------------------------------------------------------------------
1 | get_normalized_constants();
27 | foreach ( $constants as $constant => $constant_path ) {
28 | $len = strlen( $constant_path );
29 | if ( substr( $path, 0, $len ) !== $constant_path ) {
30 | continue;
31 | }
32 |
33 | return substr_replace( $path, '{{' . $constant . '}}', 0, $len );
34 | }
35 |
36 | return $path;
37 | }
38 |
39 | /**
40 | * Given a path this will replace any of the path constant tokens with the expanded path.
41 | *
42 | * @param string $tokenized_path The path we want to process.
43 | *
44 | * @return string The expanded path.
45 | */
46 | public function untokenize_path_constants( $tokenized_path ) {
47 | $tokenized_path = wp_normalize_path( $tokenized_path );
48 |
49 | $constants = $this->get_normalized_constants();
50 | foreach ( $constants as $constant => $constant_path ) {
51 | $constant = '{{' . $constant . '}}';
52 |
53 | $len = strlen( $constant );
54 | if ( substr( $tokenized_path, 0, $len ) !== $constant ) {
55 | continue;
56 | }
57 |
58 | return $this->get_real_path( substr_replace( $tokenized_path, $constant_path, 0, $len ) );
59 | }
60 |
61 | return $tokenized_path;
62 | }
63 |
64 | /**
65 | * Given a file and an array of places it might be, this will find the absolute path and return it.
66 | *
67 | * @param string $file The plugin or theme file to resolve.
68 | * @param array $directories_to_check The directories we should check for the file if it isn't an absolute path.
69 | *
70 | * @return string|false Returns the absolute path to the directory, otherwise false.
71 | */
72 | public function find_directory_with_autoloader( $file, $directories_to_check ) {
73 | $file = wp_normalize_path( $file );
74 |
75 | if ( ! $this->is_absolute_path( $file ) ) {
76 | $file = $this->find_absolute_plugin_path( $file, $directories_to_check );
77 | if ( ! isset( $file ) ) {
78 | return false;
79 | }
80 | }
81 |
82 | // We need the real path for consistency with __DIR__ paths.
83 | $file = $this->get_real_path( $file );
84 |
85 | // phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
86 | $directory = @is_file( $file ) ? dirname( $file ) : $file;
87 | if ( ! @is_file( $directory . '/vendor/composer/jetpack_autoload_classmap.php' ) ) {
88 | return false;
89 | }
90 | // phpcs:enable WordPress.PHP.NoSilencedErrors.Discouraged
91 |
92 | return $directory;
93 | }
94 |
95 | /**
96 | * Fetches an array of normalized paths keyed by the constant they came from.
97 | *
98 | * @return string[] The normalized paths keyed by the constant.
99 | */
100 | private function get_normalized_constants() {
101 | $raw_constants = array(
102 | // Order the constants from most-specific to least-specific.
103 | 'WP_PLUGIN_DIR',
104 | 'WPMU_PLUGIN_DIR',
105 | 'WP_CONTENT_DIR',
106 | 'ABSPATH',
107 | );
108 |
109 | $constants = array();
110 | foreach ( $raw_constants as $raw ) {
111 | if ( ! defined( $raw ) ) {
112 | continue;
113 | }
114 |
115 | $path = wp_normalize_path( constant( $raw ) );
116 | if ( isset( $path ) ) {
117 | $constants[ $raw ] = $path;
118 | }
119 | }
120 |
121 | return $constants;
122 | }
123 |
124 | /**
125 | * Indicates whether or not a path is absolute.
126 | *
127 | * @param string $path The path to check.
128 | *
129 | * @return bool True if the path is absolute, otherwise false.
130 | */
131 | private function is_absolute_path( $path ) {
132 | if ( empty( $path ) || 0 === strlen( $path ) || '.' === $path[0] ) {
133 | return false;
134 | }
135 |
136 | // Absolute paths on Windows may begin with a drive letter.
137 | if ( preg_match( '/^[a-zA-Z]:[\/\\\\]/', $path ) ) {
138 | return true;
139 | }
140 |
141 | // A path starting with / or \ is absolute; anything else is relative.
142 | return ( '/' === $path[0] || '\\' === $path[0] );
143 | }
144 |
145 | /**
146 | * Given a file and a list of directories to check, this method will try to figure out
147 | * the absolute path to the file in question.
148 | *
149 | * @param string $normalized_path The normalized path to the plugin or theme file to resolve.
150 | * @param array $directories_to_check The directories we should check for the file if it isn't an absolute path.
151 | *
152 | * @return string|null The absolute path to the plugin file, otherwise null.
153 | */
154 | private function find_absolute_plugin_path( $normalized_path, $directories_to_check ) {
155 | // We're only able to find the absolute path for plugin/theme PHP files.
156 | if ( ! is_string( $normalized_path ) || '.php' !== substr( $normalized_path, -4 ) ) {
157 | return null;
158 | }
159 |
160 | foreach ( $directories_to_check as $directory ) {
161 | $normalized_check = wp_normalize_path( trailingslashit( $directory ) ) . $normalized_path;
162 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
163 | if ( @is_file( $normalized_check ) ) {
164 | return $normalized_check;
165 | }
166 | }
167 |
168 | return null;
169 | }
170 |
171 | /**
172 | * Given a path this will figure out the real path that we should be using.
173 | *
174 | * @param string $path The path to resolve.
175 | *
176 | * @return string The resolved path.
177 | */
178 | private function get_real_path( $path ) {
179 | // We want to resolve symbolic links for consistency with __DIR__ paths.
180 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
181 | $real_path = @realpath( $path );
182 | if ( false === $real_path ) {
183 | // Let the autoloader deal with paths that don't exist.
184 | $real_path = $path;
185 | }
186 |
187 | // Using realpath will make it platform-specific so we must normalize it after.
188 | if ( $path !== $real_path ) {
189 | $real_path = wp_normalize_path( $real_path );
190 | }
191 |
192 | return $real_path;
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-php-autoloader.php:
--------------------------------------------------------------------------------
1 | unregister_autoloader();
25 |
26 | // Set the global so that it can be used to load classes.
27 | global $jetpack_autoloader_loader;
28 | $jetpack_autoloader_loader = $version_loader;
29 |
30 | // Ensure that the autoloader is first to avoid contention with others.
31 | spl_autoload_register( array( self::class, 'load_class' ), true, true );
32 | }
33 |
34 | /**
35 | * Unregisters the active autoloader so that it will no longer autoload classes.
36 | */
37 | public function unregister_autoloader() {
38 | // Remove any v2 autoloader that we've already registered.
39 | $autoload_chain = spl_autoload_functions();
40 | if ( ! $autoload_chain ) {
41 | return;
42 | }
43 | foreach ( $autoload_chain as $autoloader ) {
44 | // We can identify a v2 autoloader using the namespace.
45 | $namespace_check = null;
46 |
47 | // Functions are recorded as strings.
48 | if ( is_string( $autoloader ) ) {
49 | $namespace_check = $autoloader;
50 | } elseif ( is_array( $autoloader ) && is_string( $autoloader[0] ) ) {
51 | // Static method calls have the class as the first array element.
52 | $namespace_check = $autoloader[0];
53 | } else {
54 | // Since the autoloader has only ever been a function or a static method we don't currently need to check anything else.
55 | continue;
56 | }
57 |
58 | // Check for the namespace without the generated suffix.
59 | if ( 'Automattic\\Jetpack\\Autoloader\\jp' === substr( $namespace_check, 0, 32 ) ) {
60 | spl_autoload_unregister( $autoloader );
61 | }
62 | }
63 |
64 | // Clear the global now that the autoloader has been unregistered.
65 | global $jetpack_autoloader_loader;
66 | $jetpack_autoloader_loader = null;
67 | }
68 |
69 | /**
70 | * Loads a class file if one could be found.
71 | *
72 | * Note: This function is static so that the autoloader can be easily unregistered. If
73 | * it was a class method we would have to unwrap the object to check the namespace.
74 | *
75 | * @param string $class_name The name of the class to autoload.
76 | *
77 | * @return bool Indicates whether or not a class file was loaded.
78 | */
79 | public static function load_class( $class_name ) {
80 | global $jetpack_autoloader_loader;
81 | if ( ! isset( $jetpack_autoloader_loader ) ) {
82 | return false;
83 | }
84 |
85 | $file = $jetpack_autoloader_loader->find_class_file( $class_name );
86 | if ( ! isset( $file ) ) {
87 | return false;
88 | }
89 |
90 | // A common source of strange and confusing problems is when a vendor
91 | // file is autoloaded before all plugins have had a chance to register
92 | // with the autoloader. Detect that, if a development constant is set.
93 | if ( defined( 'JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS' ) && JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS &&
94 | ( strpos( $file, '/vendor/' ) !== false || strpos( $file, '/jetpack_vendor/' ) !== false ) &&
95 | is_callable( 'did_action' ) && ! did_action( 'plugins_loaded' )
96 | ) {
97 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_wp_debug_backtrace_summary -- This is a debug log message.
98 | $msg = "Jetpack Autoloader: Autoloading `$class_name` before the plugins_loaded hook may cause strange and confusing problems. " . wp_debug_backtrace_summary( '', 1 );
99 | wp_trigger_error( '', $msg );
100 | }
101 |
102 | require $file;
103 | return true;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-plugin-locator.php:
--------------------------------------------------------------------------------
1 | path_processor = $path_processor;
31 | }
32 |
33 | /**
34 | * Finds the path to the current plugin.
35 | *
36 | * @return string $path The path to the current plugin.
37 | *
38 | * @throws \RuntimeException If the current plugin does not have an autoloader.
39 | */
40 | public function find_current_plugin() {
41 | // Escape from `vendor/__DIR__` to root plugin directory.
42 | $plugin_directory = dirname( __DIR__, 2 );
43 |
44 | // Use the path processor to ensure that this is an autoloader we're referencing.
45 | $path = $this->path_processor->find_directory_with_autoloader( $plugin_directory, array() );
46 | if ( false === $path ) {
47 | throw new \RuntimeException( 'Failed to locate plugin ' . $plugin_directory );
48 | }
49 |
50 | return $path;
51 | }
52 |
53 | /**
54 | * Checks a given option for plugin paths.
55 | *
56 | * @param string $option_name The option that we want to check for plugin information.
57 | * @param bool $site_option Indicates whether or not we want to check the site option.
58 | *
59 | * @return array $plugin_paths The list of absolute paths we've found.
60 | */
61 | public function find_using_option( $option_name, $site_option = false ) {
62 | $raw = $site_option ? get_site_option( $option_name ) : get_option( $option_name );
63 | if ( false === $raw ) {
64 | return array();
65 | }
66 |
67 | return $this->convert_plugins_to_paths( $raw );
68 | }
69 |
70 | /**
71 | * Checks for plugins in the `action` request parameter.
72 | *
73 | * @param string[] $allowed_actions The actions that we're allowed to return plugins for.
74 | *
75 | * @return array $plugin_paths The list of absolute paths we've found.
76 | */
77 | public function find_using_request_action( $allowed_actions ) {
78 | /**
79 | * Note: we're not actually checking the nonce here because it's too early
80 | * in the execution. The pluggable functions are not yet loaded to give
81 | * plugins a chance to plug their versions. Therefore we're doing the bare
82 | * minimum: checking whether the nonce exists and it's in the right place.
83 | * The request will fail later if the nonce doesn't pass the check.
84 | */
85 | if ( empty( $_REQUEST['_wpnonce'] ) ) {
86 | return array();
87 | }
88 |
89 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated just below.
90 | $action = isset( $_REQUEST['action'] ) ? wp_unslash( $_REQUEST['action'] ) : false;
91 | if ( ! in_array( $action, $allowed_actions, true ) ) {
92 | return array();
93 | }
94 |
95 | $plugin_slugs = array();
96 | switch ( $action ) {
97 | case 'activate':
98 | case 'deactivate':
99 | if ( empty( $_REQUEST['plugin'] ) ) {
100 | break;
101 | }
102 |
103 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated by convert_plugins_to_paths.
104 | $plugin_slugs[] = wp_unslash( $_REQUEST['plugin'] );
105 | break;
106 |
107 | case 'activate-selected':
108 | case 'deactivate-selected':
109 | if ( empty( $_REQUEST['checked'] ) ) {
110 | break;
111 | }
112 |
113 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated by convert_plugins_to_paths.
114 | $plugin_slugs = wp_unslash( $_REQUEST['checked'] );
115 | break;
116 | }
117 |
118 | return $this->convert_plugins_to_paths( $plugin_slugs );
119 | }
120 |
121 | /**
122 | * Given an array of plugin slugs or paths, this will convert them to absolute paths and filter
123 | * out the plugins that are not directory plugins. Note that array keys will also be included
124 | * if they are plugin paths!
125 | *
126 | * @param string[] $plugins Plugin paths or slugs to filter.
127 | *
128 | * @return string[]
129 | */
130 | private function convert_plugins_to_paths( $plugins ) {
131 | if ( ! is_array( $plugins ) || empty( $plugins ) ) {
132 | return array();
133 | }
134 |
135 | // We're going to look for plugins in the standard directories.
136 | $path_constants = array( WP_PLUGIN_DIR, WPMU_PLUGIN_DIR );
137 |
138 | $plugin_paths = array();
139 | foreach ( $plugins as $key => $value ) {
140 | $path = $this->path_processor->find_directory_with_autoloader( $key, $path_constants );
141 | if ( $path ) {
142 | $plugin_paths[] = $path;
143 | }
144 |
145 | $path = $this->path_processor->find_directory_with_autoloader( $value, $path_constants );
146 | if ( $path ) {
147 | $plugin_paths[] = $path;
148 | }
149 | }
150 |
151 | return $plugin_paths;
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-plugins-handler.php:
--------------------------------------------------------------------------------
1 | plugin_locator = $plugin_locator;
43 | $this->path_processor = $path_processor;
44 | }
45 |
46 | /**
47 | * Gets all of the active plugins we can find.
48 | *
49 | * @param bool $include_deactivating When true, plugins deactivating this request will be considered active.
50 | * @param bool $record_unknown When true, the current plugin will be marked as active and recorded when unknown.
51 | *
52 | * @return string[]
53 | */
54 | public function get_active_plugins( $include_deactivating, $record_unknown ) {
55 | global $jetpack_autoloader_activating_plugins_paths;
56 |
57 | // We're going to build a unique list of plugins from a few different sources
58 | // to find all of our "active" plugins. While we need to return an integer
59 | // array, we're going to use an associative array internally to reduce
60 | // the amount of time that we're going to spend checking uniqueness
61 | // and merging different arrays together to form the output.
62 | $active_plugins = array();
63 |
64 | // Make sure that plugins which have activated this request are considered as "active" even though
65 | // they probably won't be present in any option.
66 | if ( is_array( $jetpack_autoloader_activating_plugins_paths ) ) {
67 | foreach ( $jetpack_autoloader_activating_plugins_paths as $path ) {
68 | $active_plugins[ $path ] = $path;
69 | }
70 | }
71 |
72 | // This option contains all of the plugins that have been activated.
73 | $plugins = $this->plugin_locator->find_using_option( 'active_plugins' );
74 | foreach ( $plugins as $path ) {
75 | $active_plugins[ $path ] = $path;
76 | }
77 |
78 | // This option contains all of the multisite plugins that have been activated.
79 | if ( is_multisite() ) {
80 | $plugins = $this->plugin_locator->find_using_option( 'active_sitewide_plugins', true );
81 | foreach ( $plugins as $path ) {
82 | $active_plugins[ $path ] = $path;
83 | }
84 | }
85 |
86 | // These actions contain plugins that are being activated/deactivated during this request.
87 | $plugins = $this->plugin_locator->find_using_request_action( array( 'activate', 'activate-selected', 'deactivate', 'deactivate-selected' ) );
88 | foreach ( $plugins as $path ) {
89 | $active_plugins[ $path ] = $path;
90 | }
91 |
92 | // When the current plugin isn't considered "active" there's a problem.
93 | // Since we're here, the plugin is active and currently being loaded.
94 | // We can support this case (mu-plugins and non-standard activation)
95 | // by adding the current plugin to the active list and marking it
96 | // as an unknown (activating) plugin. This also has the benefit
97 | // of causing a reset because the active plugins list has
98 | // been changed since it was saved in the global.
99 | $current_plugin = $this->plugin_locator->find_current_plugin();
100 | if ( $record_unknown && ! in_array( $current_plugin, $active_plugins, true ) ) {
101 | $active_plugins[ $current_plugin ] = $current_plugin;
102 | $jetpack_autoloader_activating_plugins_paths[] = $current_plugin;
103 | }
104 |
105 | // When deactivating plugins aren't desired we should entirely remove them from the active list.
106 | if ( ! $include_deactivating ) {
107 | // These actions contain plugins that are being deactivated during this request.
108 | $plugins = $this->plugin_locator->find_using_request_action( array( 'deactivate', 'deactivate-selected' ) );
109 | foreach ( $plugins as $path ) {
110 | unset( $active_plugins[ $path ] );
111 | }
112 | }
113 |
114 | // Transform the array so that we don't have to worry about the keys interacting with other array types later.
115 | return array_values( $active_plugins );
116 | }
117 |
118 | /**
119 | * Gets all of the cached plugins if there are any.
120 | *
121 | * @return string[]
122 | */
123 | public function get_cached_plugins() {
124 | $cached = get_transient( self::TRANSIENT_KEY );
125 | if ( ! is_array( $cached ) || empty( $cached ) ) {
126 | return array();
127 | }
128 |
129 | // We need to expand the tokens to an absolute path for this webserver.
130 | return array_map( array( $this->path_processor, 'untokenize_path_constants' ), $cached );
131 | }
132 |
133 | /**
134 | * Saves the plugin list to the cache.
135 | *
136 | * @param array $plugins The plugin list to save to the cache.
137 | */
138 | public function cache_plugins( $plugins ) {
139 | // We store the paths in a tokenized form so that that webservers with different absolute paths don't break.
140 | $plugins = array_map( array( $this->path_processor, 'tokenize_path_constants' ), $plugins );
141 |
142 | set_transient( self::TRANSIENT_KEY, $plugins );
143 | }
144 |
145 | /**
146 | * Checks to see whether or not the plugin list given has changed when compared to the
147 | * shared `$jetpack_autoloader_cached_plugin_paths` global. This allows us to deal
148 | * with cases where the active list may change due to filtering..
149 | *
150 | * @param string[] $plugins The plugins list to check against the global cache.
151 | *
152 | * @return bool True if the plugins have changed, otherwise false.
153 | */
154 | public function have_plugins_changed( $plugins ) {
155 | global $jetpack_autoloader_cached_plugin_paths;
156 |
157 | if ( $jetpack_autoloader_cached_plugin_paths !== $plugins ) {
158 | $jetpack_autoloader_cached_plugin_paths = $plugins;
159 | return true;
160 | }
161 |
162 | return false;
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-shutdown-handler.php:
--------------------------------------------------------------------------------
1 | plugins_handler = $plugins_handler;
47 | $this->cached_plugins = $cached_plugins;
48 | $this->was_included_by_autoloader = $was_included_by_autoloader;
49 | }
50 |
51 | /**
52 | * Handles the shutdown of the autoloader.
53 | */
54 | public function __invoke() {
55 | // Don't save a broken cache if an error happens during some plugin's initialization.
56 | if ( ! did_action( 'plugins_loaded' ) ) {
57 | // Ensure that the cache is emptied to prevent consecutive failures if the cache is to blame.
58 | if ( ! empty( $this->cached_plugins ) ) {
59 | $this->plugins_handler->cache_plugins( array() );
60 | }
61 |
62 | return;
63 | }
64 |
65 | // Load the active plugins fresh since the list we pulled earlier might not contain
66 | // plugins that were activated but did not reset the autoloader. This happens
67 | // when a plugin is in the cache but not "active" when the autoloader loads.
68 | // We also want to make sure that plugins which are deactivating are not
69 | // considered "active" so that they will be removed from the cache now.
70 | try {
71 | $active_plugins = $this->plugins_handler->get_active_plugins( false, ! $this->was_included_by_autoloader );
72 | } catch ( \Exception $ex ) {
73 | // When the package is deleted before shutdown it will throw an exception.
74 | // In the event this happens we should erase the cache.
75 | if ( ! empty( $this->cached_plugins ) ) {
76 | $this->plugins_handler->cache_plugins( array() );
77 | }
78 | return;
79 | }
80 |
81 | // The paths should be sorted for easy comparisons with those loaded from the cache.
82 | // Note we don't need to sort the cached entries because they're already sorted.
83 | sort( $active_plugins );
84 |
85 | // We don't want to waste time saving a cache that hasn't changed.
86 | if ( $this->cached_plugins === $active_plugins ) {
87 | return;
88 | }
89 |
90 | $this->plugins_handler->cache_plugins( $active_plugins );
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-version-loader.php:
--------------------------------------------------------------------------------
1 | version_selector = $version_selector;
55 | $this->classmap = $classmap;
56 | $this->psr4_map = $psr4_map;
57 | $this->filemap = $filemap;
58 | }
59 |
60 | /**
61 | * Fetch the classmap.
62 | *
63 | * @since 3.1.0
64 | * @return array
65 | */
66 | public function get_class_map() {
67 | return $this->classmap;
68 | }
69 |
70 | /**
71 | * Fetch the psr-4 mappings.
72 | *
73 | * @since 3.1.0
74 | * @return array
75 | */
76 | public function get_psr4_map() {
77 | return $this->psr4_map;
78 | }
79 |
80 | /**
81 | * Finds the file path for the given class.
82 | *
83 | * @param string $class_name The class to find.
84 | *
85 | * @return string|null $file_path The path to the file if found, null if no class was found.
86 | */
87 | public function find_class_file( $class_name ) {
88 | $data = $this->select_newest_file(
89 | $this->classmap[ $class_name ] ?? null,
90 | $this->find_psr4_file( $class_name )
91 | );
92 | if ( ! isset( $data ) ) {
93 | return null;
94 | }
95 |
96 | return $data['path'];
97 | }
98 |
99 | /**
100 | * Load all of the files in the filemap.
101 | */
102 | public function load_filemap() {
103 | if ( empty( $this->filemap ) ) {
104 | return;
105 | }
106 |
107 | foreach ( $this->filemap as $file_identifier => $file_data ) {
108 | if ( empty( $GLOBALS['__composer_autoload_files'][ $file_identifier ] ) ) {
109 | require_once $file_data['path'];
110 |
111 | $GLOBALS['__composer_autoload_files'][ $file_identifier ] = true;
112 | }
113 | }
114 | }
115 |
116 | /**
117 | * Compares different class sources and returns the newest.
118 | *
119 | * @param array|null $classmap_data The classmap class data.
120 | * @param array|null $psr4_data The PSR-4 class data.
121 | *
122 | * @return array|null $data
123 | */
124 | private function select_newest_file( $classmap_data, $psr4_data ) {
125 | if ( ! isset( $classmap_data ) ) {
126 | return $psr4_data;
127 | } elseif ( ! isset( $psr4_data ) ) {
128 | return $classmap_data;
129 | }
130 |
131 | if ( $this->version_selector->is_version_update_required( $classmap_data['version'], $psr4_data['version'] ) ) {
132 | return $psr4_data;
133 | }
134 |
135 | return $classmap_data;
136 | }
137 |
138 | /**
139 | * Finds the file for a given class in a PSR-4 namespace.
140 | *
141 | * @param string $class_name The class to find.
142 | *
143 | * @return array|null $data The version and path path to the file if found, null otherwise.
144 | */
145 | private function find_psr4_file( $class_name ) {
146 | if ( empty( $this->psr4_map ) ) {
147 | return null;
148 | }
149 |
150 | // Don't bother with classes that have no namespace.
151 | $class_index = strrpos( $class_name, '\\' );
152 | if ( ! $class_index ) {
153 | return null;
154 | }
155 | $class_for_path = str_replace( '\\', '/', $class_name );
156 |
157 | // Search for the namespace by iteratively cutting off the last segment until
158 | // we find a match. This allows us to check the most-specific namespaces
159 | // first as well as minimize the amount of time spent looking.
160 | for (
161 | $class_namespace = substr( $class_name, 0, $class_index );
162 | ! empty( $class_namespace );
163 | $class_namespace = substr( $class_namespace, 0, strrpos( $class_namespace, '\\' ) )
164 | ) {
165 | $namespace = $class_namespace . '\\';
166 | if ( ! isset( $this->psr4_map[ $namespace ] ) ) {
167 | continue;
168 | }
169 | $data = $this->psr4_map[ $namespace ];
170 |
171 | foreach ( $data['path'] as $path ) {
172 | $path .= '/' . substr( $class_for_path, strlen( $namespace ) ) . '.php';
173 | if ( file_exists( $path ) ) {
174 | return array(
175 | 'version' => $data['version'],
176 | 'path' => $path,
177 | );
178 | }
179 | }
180 | }
181 |
182 | return null;
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/vendor/jetpack-autoloader/class-version-selector.php:
--------------------------------------------------------------------------------
1 | is_dev_version( $selected_version ) ) {
37 | return false;
38 | }
39 |
40 | if ( $this->is_dev_version( $compare_version ) ) {
41 | if ( $use_dev_versions ) {
42 | return true;
43 | } else {
44 | return false;
45 | }
46 | }
47 |
48 | if ( version_compare( $selected_version, $compare_version, '<' ) ) {
49 | return true;
50 | }
51 |
52 | return false;
53 | }
54 |
55 | /**
56 | * Checks whether the given package version is a development version.
57 | *
58 | * @param String $version The package version.
59 | *
60 | * @return bool True if the version is a dev version, else false.
61 | */
62 | public function is_dev_version( $version ) {
63 | if ( 'dev-' === substr( $version, 0, 4 ) || '9999999-dev' === $version ) {
64 | return true;
65 | }
66 |
67 | return false;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------