Compare commits
No commits in common. "master" and "0.16" have entirely different histories.
80
CHANGELOG.md
80
CHANGELOG.md
@ -1,85 +1,5 @@
|
|||||||
# Notice Manager Changelog
|
# Notice Manager Changelog
|
||||||
|
|
||||||
## 0.27
|
|
||||||
|
|
||||||
Release date: Sep 7 2024
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- Composer config: `prepend-autoloader: false` - Give precedence to other composer installations if present.
|
|
||||||
|
|
||||||
## 0.26
|
|
||||||
|
|
||||||
Release date: Sep 1 2024
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Use Mutation Observer instead of deprecated `DOMNodeRemoved` event.
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Add method `NoticeManager.bootstrap()` to initialize Notice manager.
|
|
||||||
|
|
||||||
## 0.25
|
|
||||||
|
|
||||||
Release date: Feb 18 2024
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix fatal error `Class "WPHelper\MetaBox" not found` due to dependency `abuyoyo/adminmenupage` < 0.29 not requiring dependency `abuyoyo/metabox`.
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- Library WPHelper\AdminPage (`abuyoyo/adminmenupage`) updated to 0.29. Requires `abuyoyo/metabox`.
|
|
||||||
|
|
||||||
## 0.24
|
|
||||||
|
|
||||||
Release date: Oct 4 2023
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Set `WPHelper\PluginCore` option `update_checker` to true. If library Plugin-Update-Checker is installed, allows updates from repo.
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- Library WPHelper\PluginCore (`abuyoyo/plugincore`) updated to 0.27. Supports both Plugin-Update-Checker v5 and v4.
|
|
||||||
|
|
||||||
## 0.23
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix `.plugin-count` bullet styling issue.
|
|
||||||
- Fix 0-count panel caused by collecting `.hidden` notices.
|
|
||||||
- Fix wrong priority color `.plugin-count` bullet caused by collecting `.hidden` notices.
|
|
||||||
- Fix empty notices-panel removing all screen-meta-link panels.
|
|
||||||
|
|
||||||
## 0.22
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Do not collect `.theme-info` notices.
|
|
||||||
- Fix `vendor/autoload` include path.
|
|
||||||
|
|
||||||
## 0.21
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix PHP 8.2 deprecated optional parameter before required parameter. Fixed upstream in `abuyoyo/screen-meta-links ~0.13`.
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- Update library `abuyoyo/screen-meta-links` to version 0.13.
|
|
||||||
|
|
||||||
## 0.20
|
|
||||||
|
|
||||||
### Minor
|
|
||||||
- Just another version bump (composer.json as well).
|
|
||||||
|
|
||||||
## 0.19
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Add 'Distraction Free' option.
|
|
||||||
|
|
||||||
## 0.18
|
|
||||||
|
|
||||||
### Minor
|
|
||||||
- Version bump everywhere.
|
|
||||||
|
|
||||||
## 0.17
|
|
||||||
|
|
||||||
### Removed
|
|
||||||
- Remove plugin update checker.
|
|
||||||
- Remove 3rd party libraries.
|
|
||||||
|
|
||||||
## 0.16
|
## 0.16
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "abuyoyo/notice-manager",
|
"name": "abuyoyo/notice-manager",
|
||||||
"description": "Manage notices on WordPress admin pages. Adds 'Notices' screen-meta-link.",
|
"description": "Manage notices on WordPress admin pages. Adds 'Notices' screen-meta-link.",
|
||||||
"type": "wordpress-plugin",
|
"type": "wordpress-plugin",
|
||||||
"version": "0.27",
|
"version": "0.16",
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
@ -10,11 +10,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require":{
|
"require":{
|
||||||
"abuyoyo/screen-meta-links": "~0.13",
|
"abuyoyo/screen-meta-links": "~0.11",
|
||||||
"abuyoyo/plugincore": "~0.27",
|
"abuyoyo/plugincore": "~0.21"
|
||||||
"abuyoyo/adminmenupage": "~0.29"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"prepend-autoloader": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
134
composer.lock
generated
134
composer.lock
generated
@ -4,27 +4,24 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "b1a74cf1316f5dd317f70efeb60d9f4d",
|
"content-hash": "9554dcf8ad998875bf543a75631cb463",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "abuyoyo/adminmenupage",
|
"name": "abuyoyo/adminmenupage",
|
||||||
"version": "0.29",
|
"version": "0.20",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/abuyoyo/AdminMenuPage.git",
|
"url": "https://github.com/abuyoyo/AdminMenuPage.git",
|
||||||
"reference": "4cd47d5217ca25ed17af76f5fdbab3cab3b37ef8"
|
"reference": "07d98f2c1f0b71340aaf0fae0783dfecec201e97"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/4cd47d5217ca25ed17af76f5fdbab3cab3b37ef8",
|
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/07d98f2c1f0b71340aaf0fae0783dfecec201e97",
|
||||||
"reference": "4cd47d5217ca25ed17af76f5fdbab3cab3b37ef8",
|
"reference": "07d98f2c1f0b71340aaf0fae0783dfecec201e97",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
|
||||||
"abuyoyo/metabox": "~0.8"
|
|
||||||
},
|
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"abuyoyo/plugincore": "~0.26",
|
"abuyoyo/plugincore": "~0.18",
|
||||||
"cmb2/cmb2": "~2.9"
|
"cmb2/cmb2": "~2.9"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
@ -43,58 +40,27 @@
|
|||||||
"description": "WordPress admin menu page helper class",
|
"description": "WordPress admin menu page helper class",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/abuyoyo/AdminMenuPage/issues",
|
"issues": "https://github.com/abuyoyo/AdminMenuPage/issues",
|
||||||
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.29"
|
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.20"
|
||||||
},
|
},
|
||||||
"time": "2023-10-05T00:00:00+00:00"
|
"time": "2022-07-28T22:56:37+00:00"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "abuyoyo/metabox",
|
|
||||||
"version": "0.8",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/abuyoyo/MetaBox.git",
|
|
||||||
"reference": "98cb4c30db4c366c0d273985eb9c31ffa1cd78f9"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/abuyoyo/MetaBox/zipball/98cb4c30db4c366c0d273985eb9c31ffa1cd78f9",
|
|
||||||
"reference": "98cb4c30db4c366c0d273985eb9c31ffa1cd78f9",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"WPHelper\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"description": "WordPress metabox helper class",
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/abuyoyo/MetaBox/issues",
|
|
||||||
"source": "https://github.com/abuyoyo/MetaBox/tree/0.8"
|
|
||||||
},
|
|
||||||
"time": "2023-07-18T19:14:03+00:00"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "abuyoyo/plugincore",
|
"name": "abuyoyo/plugincore",
|
||||||
"version": "0.27",
|
"version": "0.21",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/abuyoyo/PluginCore.git",
|
"url": "https://github.com/abuyoyo/PluginCore.git",
|
||||||
"reference": "d730a674cbe2dc92e60ace8e25a2e0e3fdeee3e6"
|
"reference": "9c398bdf05dc2cecf30eb0ac53558b3d37ecc4aa"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/d730a674cbe2dc92e60ace8e25a2e0e3fdeee3e6",
|
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/9c398bdf05dc2cecf30eb0ac53558b3d37ecc4aa",
|
||||||
"reference": "d730a674cbe2dc92e60ace8e25a2e0e3fdeee3e6",
|
"reference": "9c398bdf05dc2cecf30eb0ac53558b3d37ecc4aa",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"suggest": {
|
"require": {
|
||||||
"abuyoyo/adminmenupage": "~0.27",
|
"abuyoyo/adminmenupage": "~0.20",
|
||||||
"yahnis-elsts/plugin-update-checker": "~5.2"
|
"yahnis-elsts/plugin-update-checker": "~4.12"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -109,22 +75,22 @@
|
|||||||
"description": "WordPress plugin core helper class",
|
"description": "WordPress plugin core helper class",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/abuyoyo/PluginCore/issues",
|
"issues": "https://github.com/abuyoyo/PluginCore/issues",
|
||||||
"source": "https://github.com/abuyoyo/PluginCore/tree/0.27"
|
"source": "https://github.com/abuyoyo/PluginCore/tree/0.21"
|
||||||
},
|
},
|
||||||
"time": "2022-10-03T00:00:00+00:00"
|
"time": "2022-08-05T00:00:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "abuyoyo/screen-meta-links",
|
"name": "abuyoyo/screen-meta-links",
|
||||||
"version": "0.13",
|
"version": "0.11",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/abuyoyo/screen-meta-links.git",
|
"url": "https://github.com/abuyoyo/screen-meta-links.git",
|
||||||
"reference": "b324cef9eb5825d04ffa17f771237b7deca5cd01"
|
"reference": "04e3c892f0c6095b4c31a489e06336f0917128d3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/abuyoyo/screen-meta-links/zipball/b324cef9eb5825d04ffa17f771237b7deca5cd01",
|
"url": "https://api.github.com/repos/abuyoyo/screen-meta-links/zipball/04e3c892f0c6095b4c31a489e06336f0917128d3",
|
||||||
"reference": "b324cef9eb5825d04ffa17f771237b7deca5cd01",
|
"reference": "04e3c892f0c6095b4c31a489e06336f0917128d3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
@ -135,10 +101,60 @@
|
|||||||
},
|
},
|
||||||
"description": "API for adding custom screen-meta-links alongside the 'Screen Options' and 'Help' links.",
|
"description": "API for adding custom screen-meta-links alongside the 'Screen Options' and 'Help' links.",
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/abuyoyo/screen-meta-links/tree/0.13",
|
"source": "https://github.com/abuyoyo/screen-meta-links/tree/0.11",
|
||||||
"issues": "https://github.com/abuyoyo/screen-meta-links/issues"
|
"issues": "https://github.com/abuyoyo/screen-meta-links/issues"
|
||||||
},
|
},
|
||||||
"time": "2023-08-08T22:37:03+00:00"
|
"time": "2022-05-18T01:18:24+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "yahnis-elsts/plugin-update-checker",
|
||||||
|
"version": "v4.13",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/YahnisElsts/plugin-update-checker.git",
|
||||||
|
"reference": "6eb27a6911e0e0880d09e5b11f577d3f688f7da7"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/6eb27a6911e0e0880d09e5b11f577d3f688f7da7",
|
||||||
|
"reference": "6eb27a6911e0e0880d09e5b11f577d3f688f7da7",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"php": ">=5.2.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"load-v4p13.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Yahnis Elsts",
|
||||||
|
"email": "whiteshadow@w-shadow.com",
|
||||||
|
"homepage": "http://w-shadow.com/",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.",
|
||||||
|
"homepage": "https://github.com/YahnisElsts/plugin-update-checker/",
|
||||||
|
"keywords": [
|
||||||
|
"automatic updates",
|
||||||
|
"plugin updates",
|
||||||
|
"theme updates",
|
||||||
|
"wordpress"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/YahnisElsts/plugin-update-checker/issues",
|
||||||
|
"source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v4.13"
|
||||||
|
},
|
||||||
|
"time": "2022-07-29T12:36:25+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
@ -146,8 +162,8 @@
|
|||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [],
|
"stability-flags": [],
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": true,
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.3.0"
|
"plugin-api-version": "2.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,181 +2,160 @@
|
|||||||
* NoticeManager class/module
|
* NoticeManager class/module
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const NoticeManager = function ($) {
|
var NoticeManager = (function ($, document) {
|
||||||
|
let options = window.notice_manager_options;
|
||||||
|
|
||||||
const selectors_notice = [
|
let selectors_notice = [
|
||||||
"div.notice",
|
"div.notice",
|
||||||
"div.updated",
|
"div.updated",
|
||||||
]
|
];
|
||||||
|
|
||||||
const selectors_warning = [
|
let selectors_warning = [
|
||||||
"div.notice-warning",
|
"div.notice-warning",
|
||||||
"div.update-nag",
|
"div.update-nag",
|
||||||
]
|
];
|
||||||
|
|
||||||
const selectors_error = [
|
let selectors_error = [
|
||||||
"div.error",
|
"div.error",
|
||||||
"div.notice-error",
|
"div.notice-error",
|
||||||
]
|
];
|
||||||
|
|
||||||
const selectors_all = selectors_notice.concat(selectors_warning, selectors_error)
|
let selectors_all = selectors_notice.concat(selectors_warning, selectors_error);
|
||||||
|
|
||||||
const selectors_skip = [
|
|
||||||
".inline",
|
|
||||||
".below-h2",
|
|
||||||
".theme-info .notice",
|
|
||||||
".hidden",
|
|
||||||
]
|
|
||||||
|
|
||||||
// wait function used with autoCollapse
|
// wait function used with autoCollapse
|
||||||
const wait = function (ms) {
|
let wait = function (ms) {
|
||||||
var dfd = $.Deferred()
|
var dfd = $.Deferred();
|
||||||
setTimeout(dfd.resolve, ms) //callback, timeout till callback
|
setTimeout(dfd.resolve, ms); //callback, timeout till callback
|
||||||
return dfd.promise()
|
return dfd.promise();
|
||||||
}
|
};
|
||||||
|
|
||||||
const options = window.notice_manager_options
|
let notices;
|
||||||
|
|
||||||
let notices
|
let button;
|
||||||
|
let panel;
|
||||||
|
let haveClosed; // set to true on first close/collect
|
||||||
|
let dismissNoticesButton;
|
||||||
|
|
||||||
let button
|
// bootstrap
|
||||||
let panel
|
// some of these need to run BEFORE document.ready - don't know why really
|
||||||
let dismissNoticesButton
|
button = $("#meta-link-notices");
|
||||||
|
panel = $("#meta-link-notices-wrap");
|
||||||
|
haveClosed = false;
|
||||||
|
dismissNoticesButton = $("#meta-link-notices-wrap button.notice-dismiss");
|
||||||
|
|
||||||
let haveClosed // set to true on first close/collect
|
dismissNoticesButton.on("click", () => {
|
||||||
let panelObserver
|
screenMeta.close(panel, button);
|
||||||
|
if (! haveClosed){
|
||||||
|
NoticeManager.collectNotices();
|
||||||
|
}
|
||||||
|
NoticeManager.addCounter();
|
||||||
|
});
|
||||||
|
|
||||||
|
//original wp focus on click function
|
||||||
|
button.on("focus.scroll-into-view", (e) => {
|
||||||
|
if (e.target.scrollIntoView) e.target.scrollIntoView(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
// scroll page to top when closing notice panel
|
||||||
|
// function used to work with $(this)
|
||||||
|
// using e.target instead
|
||||||
|
// not sure if this should perhaps be e.currentTarget
|
||||||
|
button.on("click", (e) => {
|
||||||
|
if ($(e.target).hasClass("screen-meta-active")) {
|
||||||
|
if (haveClosed) {
|
||||||
|
NoticeManager.addCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
// $(window).scrollTop(true);
|
||||||
|
} else {
|
||||||
|
NoticeManager.removeCounter();
|
||||||
|
|
||||||
|
// wait (500).then(function(){ //still jumpy sometimes - but scrolls to correct position 400 ~ 600
|
||||||
|
// $(window).scrollTop(true);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* document.on.ready
|
||||||
|
*/
|
||||||
|
$(() => {
|
||||||
|
|
||||||
|
console.log("NoticeManager.on.ready");
|
||||||
|
console.log("options");
|
||||||
|
console.log(options);
|
||||||
|
|
||||||
|
// bootstrap notices
|
||||||
|
// get all notices that are not explicitly marked as `.inline` or `.below-h2`
|
||||||
|
// we add .update-nag.inline for WordPress Update notice
|
||||||
|
notices = $( selectors_all.join(', ') )
|
||||||
|
.not(".inline, .below-h2")
|
||||||
|
.add("div.update-nag");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove panel if there are no notices on this page
|
||||||
|
*/
|
||||||
|
if (options.screen_panel) {
|
||||||
|
NoticeManager.maybeRemoveNoticesPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.screen_panel && options.auto_collect) {
|
||||||
|
NoticeManager.collectNotices();
|
||||||
|
} else {
|
||||||
|
if (options.above_title) {
|
||||||
|
NoticeManager.moveAboveTitle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* auto-open notices panel
|
||||||
|
*/
|
||||||
|
if (button.length) {
|
||||||
|
panel.toggle();
|
||||||
|
button.addClass("screen-meta-active");
|
||||||
|
screenMeta.open(panel, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* auto-close notices panel after short delay
|
||||||
|
* only auto-close if we have collected notices previously
|
||||||
|
* only auto-close if no error messages
|
||||||
|
*/
|
||||||
|
if (options.auto_collapse) {
|
||||||
|
wait(4000).then(() => {
|
||||||
|
if (haveClosed && NoticeManager.getNoticesTopPriority() != 'error') {
|
||||||
|
screenMeta.close(panel, button);
|
||||||
|
NoticeManager.addCounter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}); // end document.on.ready
|
||||||
|
|
||||||
|
// prevent jumpy scrollRestoration on reload page
|
||||||
|
// fixed below on 'beforeunload'
|
||||||
|
// if (history.scrollRestoration) {
|
||||||
|
// history.scrollRestoration = 'manual';
|
||||||
|
//}
|
||||||
|
/**
|
||||||
|
* Set history.scrollTop to prevent jump on page refresh when scrollRestoration = auto
|
||||||
|
*/
|
||||||
|
$(window).on("beforeunload", () => {
|
||||||
|
history.pushState(
|
||||||
|
{ scrollTop: document.body.scrollTop },
|
||||||
|
document.title,
|
||||||
|
document.location.pathname
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bootstrap: () => {
|
|
||||||
|
|
||||||
// Init selectors
|
|
||||||
button = $("#meta-link-notices")
|
|
||||||
panel = $("#meta-link-notices-wrap")
|
|
||||||
dismissNoticesButton = $("#meta-link-notices-wrap button.notice-dismiss")
|
|
||||||
|
|
||||||
// bootstrap notices
|
|
||||||
// get all notices that are not explicitly marked as `.inline` or `.below-h2`
|
|
||||||
// we add .update-nag.inline for WordPress Update notice
|
|
||||||
notices = $(selectors_all.join(', '))
|
|
||||||
.not(selectors_skip.join(', '))
|
|
||||||
.add("div.update-nag")
|
|
||||||
|
|
||||||
// Set state
|
|
||||||
haveClosed = false
|
|
||||||
|
|
||||||
dismissNoticesButton.on("click", () => {
|
|
||||||
screenMeta.close(panel, button)
|
|
||||||
if (!haveClosed) {
|
|
||||||
NoticeManager.collectNotices()
|
|
||||||
}
|
|
||||||
NoticeManager.addCounter()
|
|
||||||
})
|
|
||||||
|
|
||||||
//original wp focus on click function
|
|
||||||
button.on("focus.scroll-into-view", (e) => {
|
|
||||||
if (e.target.scrollIntoView) e.target.scrollIntoView(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
// scroll page to top when closing notice panel
|
|
||||||
// function used to work with $(this)
|
|
||||||
// using e.target instead
|
|
||||||
// not sure if this should perhaps be e.currentTarget
|
|
||||||
button.on("click", (e) => {
|
|
||||||
if ($(e.target).hasClass("screen-meta-active")) {
|
|
||||||
if (haveClosed) {
|
|
||||||
NoticeManager.addCounter()
|
|
||||||
}
|
|
||||||
|
|
||||||
// $(window).scrollTop(true)
|
|
||||||
} else {
|
|
||||||
NoticeManager.removeCounter()
|
|
||||||
|
|
||||||
// wait (500).then(function(){ //still jumpy sometimes - but scrolls to correct position 400 ~ 600
|
|
||||||
// $(window).scrollTop(true)
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// prevent jumpy scrollRestoration on reload page
|
|
||||||
// fixed below on 'beforeunload'
|
|
||||||
// if (history.scrollRestoration) {
|
|
||||||
// history.scrollRestoration = 'manual'
|
|
||||||
//}
|
|
||||||
/**
|
|
||||||
* Set history.scrollTop to prevent jump on page refresh when scrollRestoration = auto
|
|
||||||
*/
|
|
||||||
$(window).on('beforeunload', () => history.pushState(
|
|
||||||
{ scrollTop: document.body.scrollTop },
|
|
||||||
document.title,
|
|
||||||
document.location.pathname
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove panel if there are no notices on this page
|
|
||||||
*/
|
|
||||||
if (options.screen_panel) {
|
|
||||||
NoticeManager.maybeRemoveNoticesPanel()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.screen_panel && options.auto_collect) {
|
|
||||||
NoticeManager.collectNotices()
|
|
||||||
} else {
|
|
||||||
if (options.above_title) {
|
|
||||||
NoticeManager.moveAboveTitle()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* auto-open notices panel
|
|
||||||
*/
|
|
||||||
if (button.length && !options.distraction_free) {
|
|
||||||
panel.toggle()
|
|
||||||
button.addClass("screen-meta-active")
|
|
||||||
screenMeta.open(panel, button)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* auto-close notices panel after short delay
|
|
||||||
* only auto-close if we have collected notices previously
|
|
||||||
* only auto-close if no error messages
|
|
||||||
*/
|
|
||||||
if (options.auto_collapse && !options.distraction_free) {
|
|
||||||
wait(4000).then(() => {
|
|
||||||
if (haveClosed && NoticeManager.getNoticesTopPriority() != 'error') {
|
|
||||||
screenMeta.close(panel, button)
|
|
||||||
NoticeManager.addCounter()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.distraction_free) {
|
|
||||||
NoticeManager.addCounterWhenClosed()
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
getNotices: () => notices,
|
getNotices: () => notices,
|
||||||
|
|
||||||
getNoticesTopPriority: () => {
|
getNoticesTopPriority: () => {
|
||||||
if (notices.filter(":visible").filter(selectors_error.join(", ")).length)
|
if (notices.filter(":visible").filter(selectors_error.join(", ")).length)
|
||||||
return 'error'
|
return 'error';
|
||||||
if (notices.filter(":visible").filter(selectors_warning.join(", ")).length)
|
if (notices.filter(":visible").filter(selectors_warning.join(", ")).length)
|
||||||
return 'warning'
|
return 'warning';
|
||||||
return 'info'
|
return 'notice';
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* .filter(":visible") unreliable when closed
|
|
||||||
*
|
|
||||||
* @returns {string} top priority
|
|
||||||
*/
|
|
||||||
getNoticesTopPriorityWhenClosed: () => {
|
|
||||||
if (notices.filter(selectors_error.join(", ")).length)
|
|
||||||
return 'error'
|
|
||||||
if (notices.filter(selectors_warning.join(", ")).length)
|
|
||||||
return 'warning'
|
|
||||||
return 'info'
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,50 +163,39 @@ const NoticeManager = function ($) {
|
|||||||
* Remove dismiss-notices button.
|
* Remove dismiss-notices button.
|
||||||
*/
|
*/
|
||||||
collectNotices: () => {
|
collectNotices: () => {
|
||||||
notices.appendTo(".notice_container").eq(0)
|
notices.appendTo(".notice_container").eq(0);
|
||||||
$(".notice_container").removeClass("empty") // .empty removes padding
|
$(".notice_container").removeClass("empty"); // .empty removes padding
|
||||||
|
|
||||||
haveClosed = true // initial collection has occurred.
|
haveClosed = true; // initial collection has occurred.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When dismissible notices are dismissed, check if any notices are left on page.
|
* When dismissible notices are dismissed, check if any notices are left on page.
|
||||||
* If no notices are left - remove Notice Panel entirely
|
* If no notices are left - remove Notice Panel entirely
|
||||||
*/
|
*/
|
||||||
panelObserver = new MutationObserver(() => {
|
$(document).on(
|
||||||
notices = panel
|
"DOMNodeRemoved",
|
||||||
.find(selectors_all.join(", "))
|
"#meta-link-notices-wrap div.notice",
|
||||||
.filter(":visible")
|
() => {
|
||||||
NoticeManager.maybeRemoveNoticesPanel()
|
notices = panel
|
||||||
});
|
.find(selectors_all.join(", "))
|
||||||
panelObserver.observe(panel.get(0), { childList: true, subtree: true }); // only run once
|
.filter(":visible");
|
||||||
|
NoticeManager.maybeRemoveNoticesPanel();
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
addCounter: () => {
|
addCounter: () => {
|
||||||
if (!button.children('.plugin-count').length) {
|
if (!button.children('.plugin-count').length){
|
||||||
button.append(
|
button.append(
|
||||||
$("<span/>").text(notices.filter(":visible").length).attr({
|
$("<span/>").text(notices.filter(":visible").length).attr({
|
||||||
class: "plugin-count",
|
class: "plugin-count",
|
||||||
}).addClass(NoticeManager.getNoticesTopPriority())
|
}).addClass(NoticeManager.getNoticesTopPriority())
|
||||||
)
|
);
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cannot rely on filter(:visible)
|
|
||||||
*/
|
|
||||||
addCounterWhenClosed: () => {
|
|
||||||
if (!button.children('.plugin-count').length) {
|
|
||||||
button.append(
|
|
||||||
$("<span/>").text(notices.length).attr({
|
|
||||||
class: "plugin-count",
|
|
||||||
}).addClass(NoticeManager.getNoticesTopPriorityWhenClosed())
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
removeCounter: () => {
|
removeCounter: () => {
|
||||||
button.children(".plugin-count").remove()
|
button.children(".plugin-count").remove();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,14 +204,13 @@ const NoticeManager = function ($) {
|
|||||||
*/
|
*/
|
||||||
maybeRemoveNoticesPanel: () => {
|
maybeRemoveNoticesPanel: () => {
|
||||||
if (!notices.length) {
|
if (!notices.length) {
|
||||||
screenMeta.close(panel, button)
|
screenMeta.close(panel, button);
|
||||||
|
|
||||||
$("#meta-link-notices-link-wrap").detach()
|
$("#meta-link-notices-link-wrap").detach();
|
||||||
$("#meta-link-notices-wrap").detach()
|
$("#meta-link-notices-wrap").detach();
|
||||||
|
|
||||||
if ($("#screen-meta-links").children().length == 0) {
|
if (!$("#screen-meta-links").children().length)
|
||||||
$("#screen-meta-links").detach()
|
$("#screen-meta-links").detach();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -253,9 +220,7 @@ const NoticeManager = function ($) {
|
|||||||
* I HATE it when WordPress moves notices below title.
|
* I HATE it when WordPress moves notices below title.
|
||||||
*/
|
*/
|
||||||
moveAboveTitle: () => {
|
moveAboveTitle: () => {
|
||||||
notices.insertBefore(".wrap:first")
|
notices.insertBefore(".wrap:first");
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
}(jQuery);
|
}(jQuery,document) )
|
||||||
|
|
||||||
jQuery(NoticeManager.bootstrap);
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Plugin Name: Notice Manager
|
* Plugin Name: Notice Manager
|
||||||
* Description: Manage notices on WordPress admin pages. Adds 'Notices' screen-meta-link panel to collect notices from page.
|
* Description: Manage notices on WordPress admin pages. Adds 'Notices' screen-meta-link.
|
||||||
* Version: 0.27
|
* Version: 0.16
|
||||||
* Author: abuyoyo
|
* Author: abuyoyo
|
||||||
* Author URI: https://github.com/abuyoyo/
|
* Author URI: https://github.com/abuyoyo/
|
||||||
* Plugin URI: https://github.com/abuyoyo/notice-manager
|
* Plugin URI: https://github.com/abuyoyo/notice-manager
|
||||||
@ -10,31 +10,17 @@
|
|||||||
*/
|
*/
|
||||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||||
|
|
||||||
/**
|
|
||||||
* Dependencies
|
|
||||||
* Allow all other auto-loaders to fail before including our own.
|
|
||||||
*/
|
|
||||||
if (
|
|
||||||
! class_exists( 'WPHelper\PluginCore' )
|
|
||||||
||
|
|
||||||
! class_exists( 'WPHelper\AdminPage' )
|
|
||||||
||
|
|
||||||
! function_exists( 'wph_add_screen_meta_panel' )
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ){
|
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use WPHelper\PluginCore;
|
use WPHelper\PluginCore;
|
||||||
|
|
||||||
|
require_once 'vendor/autoload.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap plugin and admin page (Tools > Notice Manager)
|
* Bootstrap plugin and admin page (Tools > Notice Manager)
|
||||||
*/
|
*/
|
||||||
new PluginCore(
|
new PluginCore(
|
||||||
__FILE__,
|
__FILE__,
|
||||||
[
|
[
|
||||||
|
'update_checker' => true,
|
||||||
'action_links' => [
|
'action_links' => [
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'text' => 'Settings',
|
'text' => 'Settings',
|
||||||
@ -44,7 +30,7 @@ new PluginCore(
|
|||||||
'admin_page' => [
|
'admin_page' => [
|
||||||
'parent' => 'options',
|
'parent' => 'options',
|
||||||
'render' => 'settings-page', // built-in settings page
|
'render' => 'settings-page', // built-in settings page
|
||||||
// 'plugin_info' => true, // disable on public repo
|
'plugin_info' => true,
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'option_name' => 'notice_manager', // option_name used in wp_options table
|
'option_name' => 'notice_manager', // option_name used in wp_options table
|
||||||
'sections' => [
|
'sections' => [
|
||||||
@ -77,19 +63,12 @@ new PluginCore(
|
|||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'description' => 'If auto-collect is enabled - Notices panel will stay open for a few seconds on page load, and then close automatically. Panel will not auto-collapse if it contains `error` level notices.',
|
'description' => 'If auto-collect is enabled - Notices panel will stay open for a few seconds on page load, and then close automatically. Panel will not auto-collapse if it contains `error` level notices.',
|
||||||
],
|
],
|
||||||
[
|
]
|
||||||
'id' => 'distraction_free',
|
]
|
||||||
'title' => 'Distraction Free',
|
]
|
||||||
'type' => 'checkbox',
|
]
|
||||||
'description' => 'Notice Panel is closed on page load. Requires auto_collect.'
|
]
|
||||||
],
|
]
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'update_checker' => true, // If Plugin Update Checker library is available - allow updates/auto-updates.
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
require_once 'src/NoticeManager.php';
|
require_once 'src/NoticeManager.php';
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "notice-manager",
|
"name": "notice-manager",
|
||||||
"version": "0.18.0",
|
"version": "0.16.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "notice-manager",
|
"name": "notice-manager",
|
||||||
"version": "0.18.0",
|
"version": "0.16.0",
|
||||||
"description": "Manage notices on WordPress admin pages. Adds 'Notices' screen-meta-link.",
|
"description": "Manage notices on WordPress admin pages. Adds 'Notices' screen-meta-link.",
|
||||||
"author": "abuyoyo",
|
"author": "abuyoyo",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
86
vendor/abuyoyo/adminmenupage/CHANGELOG.md
vendored
86
vendor/abuyoyo/adminmenupage/CHANGELOG.md
vendored
@ -1,92 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
WPHelper\AdminMenuPage
|
WPHelper\AdminMenuPage
|
||||||
|
|
||||||
## 0.29
|
|
||||||
Release date: Oct 5 2023
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- `composer.json` - Require `abuyoyo/metabox`. WPHelper\Metabox has been a required library since 0.25.
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
- lib: WPHelper\Metabox (`abuyoyo/metabox`) ~0.8.
|
|
||||||
|
|
||||||
## 0.28
|
|
||||||
Release date: Oct 4 2023
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Option `parent` accepts `tools` as shorthand for `tools.php`.
|
|
||||||
- Add link to Install Plugin page in "CMB2 plugin missing" template.
|
|
||||||
|
|
||||||
## 0.27
|
|
||||||
Release date: Sep 10 2023
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix nav-tabs appearing on pages without `tab_group`.
|
|
||||||
|
|
||||||
## 0.26
|
|
||||||
Release date: Jun 20 2023
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Add `allow_on_front` setting to CMB2 pages. Hooks metabox on `cmb2_init` instead of `cmb2_admin_init`.
|
|
||||||
- If defined `WPH_DEBUG` add WPHelper classes debug information to plugin info meta box.
|
|
||||||
|
|
||||||
## 0.25
|
|
||||||
Release date: Jun 9 2023
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Non-CMB2 pages can be added to CMB2 tab groups. New options `tab_group` and `tab_title`
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- New method `render_plugin_info_meta_box`. Deprecate `render_plugin_info_box`.
|
|
||||||
- Plugin info meta box rendered using `WPHelper\MetaBox`.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix several PHP undefined variable warnings.
|
|
||||||
|
|
||||||
### Internal
|
|
||||||
- Setting pages/wrap template uses WordPress Core `do_meta_boxes` to render `side` meta boxes div.
|
|
||||||
- Add variables to `AdminPage::options()` array.
|
|
||||||
- Multiple code refactoring and template restructuring.
|
|
||||||
|
|
||||||
## 0.24
|
|
||||||
Release date: Jan 28 2023
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix plugin info meta box when no PluginCore is available.
|
|
||||||
- Fix PHP deprecated notice.
|
|
||||||
|
|
||||||
## 0.23
|
|
||||||
Release date: Jan 15 2023
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Add action hook `wphelper/plugin_info_meta_box/{$slug}` to modify and render plugin info meta box.
|
|
||||||
- Add support for `textarea` input field in SettingsPage.
|
|
||||||
- Add `sanitize_callback` option - allow plugins to supply their own sanitize function.
|
|
||||||
- Add `render` to fields - allow plugins to supply their own render callback for fields.
|
|
||||||
- Add `placeholder` to fields - allow plugins to supply placeholder values for fields.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix default value handling for fields.
|
|
||||||
|
|
||||||
### Internal
|
|
||||||
- Rename `tpl/` template parts.
|
|
||||||
- Minor changes and fixes.
|
|
||||||
|
|
||||||
## 0.22
|
|
||||||
Release date: Jan 1 2023
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix error when `plugin_info = true` but `plugin_core` is not set.
|
|
||||||
|
|
||||||
## 0.21
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Minor fixes.
|
|
||||||
|
|
||||||
## 0.20
|
## 0.20
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Add SettingsPage section option `description-container`. Accepts `card` div, `notice`, `notice-info` and `none`.
|
- Add SettingsPage section option `desciption-container`. Accepts `card` div, `notice`, `notice-info` and `none`.
|
||||||
- Sanitize SettingsPage text, url and email fields.
|
- Sanitize SettingsPage text, url and email fields.
|
||||||
|
|
||||||
## 0.19
|
## 0.19
|
||||||
@ -96,7 +14,7 @@ Release date: Jan 1 2023
|
|||||||
- CMB2_OptionsPage supports all admin menu top-level slugs.
|
- CMB2_OptionsPage supports all admin menu top-level slugs.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix PHP fatal error: cannot redeclare function `wph_extra_plugin_headers()`.
|
- Fixed PHP fatal error: cannot redeclare function `wph_extra_plugin_headers()`.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- If CMB2 plugin is not activated - show missing plugin card on `cmb2` and `cmb2-tabs` pages.
|
- If CMB2 plugin is not activated - show missing plugin card on `cmb2` and `cmb2-tabs` pages.
|
||||||
|
|||||||
3
vendor/abuyoyo/adminmenupage/README.md
vendored
3
vendor/abuyoyo/adminmenupage/README.md
vendored
@ -40,13 +40,14 @@ $args = [
|
|||||||
'icon_url' => $icon_url; // optional - icon url passed to add_menu_page/add_submenu_page
|
'icon_url' => $icon_url; // optional - icon url passed to add_menu_page/add_submenu_page
|
||||||
'position' => 4; // optional - passed to add_menu_page
|
'position' => 4; // optional - passed to add_menu_page
|
||||||
'scripts' => [ // optional - script parameters passed to enqueue_scripts. Will only enqueue scripts on admin page
|
'scripts' => [ // optional - script parameters passed to enqueue_scripts. Will only enqueue scripts on admin page
|
||||||
[ 'script_handle', 'js/my_script.js', ['jquery'], false, true ],
|
[ 'script_handle', 'js/myscript.js', ['jquery'], false, true ],
|
||||||
[ 'another_script', 'js/my_other_script.js', ['jquery', 'script_handle'], false, true ]
|
[ 'another_script', 'js/my_other_script.js', ['jquery', 'script_handle'], false, true ]
|
||||||
];
|
];
|
||||||
];
|
];
|
||||||
|
|
||||||
// Register the admin menu page.
|
// Register the admin menu page.
|
||||||
$admin_menu_page = new AdminPage( $args );
|
$admin_menu_page = new AdminPage( $args );
|
||||||
|
$admin_menu_page->setup();
|
||||||
|
|
||||||
// That's it. We're done.
|
// That's it. We're done.
|
||||||
// This function can be called from anywhere. No need to wrap in any hook.
|
// This function can be called from anywhere. No need to wrap in any hook.
|
||||||
|
|||||||
8
vendor/abuyoyo/adminmenupage/composer.json
vendored
8
vendor/abuyoyo/adminmenupage/composer.json
vendored
@ -2,14 +2,10 @@
|
|||||||
"name": "abuyoyo/adminmenupage",
|
"name": "abuyoyo/adminmenupage",
|
||||||
"description": "WordPress admin menu page helper class",
|
"description": "WordPress admin menu page helper class",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"version": "0.29",
|
"version": "0.20",
|
||||||
"time": "2023-10-05",
|
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"require": {
|
|
||||||
"abuyoyo/metabox": "~0.8"
|
|
||||||
},
|
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"abuyoyo/plugincore": "~0.26",
|
"abuyoyo/plugincore": "~0.18",
|
||||||
"cmb2/cmb2": "~2.9"
|
"cmb2/cmb2": "~2.9"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ namespace WPHelper;
|
|||||||
|
|
||||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||||
|
|
||||||
if ( ! class_exists( AdminMenuPage::class ) ):
|
if ( ! class_exists( 'WPHelper\AdminMenuPage' ) ):
|
||||||
/**
|
/**
|
||||||
* AdminMenuPage
|
* AdminMenuPage
|
||||||
*
|
*
|
||||||
|
|||||||
311
vendor/abuyoyo/adminmenupage/src/AdminPage.php
vendored
311
vendor/abuyoyo/adminmenupage/src/AdminPage.php
vendored
@ -1,15 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace WPHelper;
|
namespace WPHelper;
|
||||||
|
|
||||||
use CMB2_Options_Hookup;
|
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||||
|
|
||||||
use function add_menu_page;
|
use function add_menu_page;
|
||||||
use function add_options_page;
|
use function add_options_page;
|
||||||
use function add_submenu_page;
|
use function add_submenu_page;
|
||||||
|
|
||||||
if ( ! class_exists( AdminPage::class ) ):
|
if ( ! class_exists( 'WPHelper\AdminPage' ) ):
|
||||||
/**
|
/**
|
||||||
* AdminPage
|
* AdminPage
|
||||||
*
|
*
|
||||||
@ -39,7 +37,7 @@ class AdminPage
|
|||||||
protected $menu_title;
|
protected $menu_title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User capability required to view page.
|
* User capabailty required to view page.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -108,20 +106,6 @@ class AdminPage
|
|||||||
*/
|
*/
|
||||||
protected $wrap;
|
protected $wrap;
|
||||||
|
|
||||||
/**
|
|
||||||
* Tab Group
|
|
||||||
*
|
|
||||||
* @var string CMB2 tab group
|
|
||||||
*/
|
|
||||||
protected $tab_group;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tab Title
|
|
||||||
*
|
|
||||||
* @var string CMB2 tab title
|
|
||||||
*/
|
|
||||||
protected $tab_title;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render callback function.
|
* Render callback function.
|
||||||
*
|
*
|
||||||
@ -136,13 +120,6 @@ class AdminPage
|
|||||||
*/
|
*/
|
||||||
protected $scripts;
|
protected $scripts;
|
||||||
|
|
||||||
/**
|
|
||||||
* Settings
|
|
||||||
*
|
|
||||||
* @var array[] arrays of settings sections and fields
|
|
||||||
*/
|
|
||||||
protected $settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Styles
|
* Styles
|
||||||
*
|
*
|
||||||
@ -153,7 +130,7 @@ class AdminPage
|
|||||||
/**
|
/**
|
||||||
* Methods
|
* Methods
|
||||||
*
|
*
|
||||||
* @var Callable[] arrays of Callable methods to hook on `load-{$hook_suffix}`
|
* @var Callable[] arrays of Callbale methods to hook on `load-{$hook_suffix}`
|
||||||
*/
|
*/
|
||||||
protected $methods = [];
|
protected $methods = [];
|
||||||
|
|
||||||
@ -179,18 +156,11 @@ class AdminPage
|
|||||||
protected $settings_page;
|
protected $settings_page;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CMB2 custom settings page
|
* Delegate admin_menu hookup to CMB2 implementation
|
||||||
*
|
*
|
||||||
* @var CMB2_OptionsPage|CMB2_OptionsPage_Multi
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $cmb2_page;
|
protected $delegate_hookup = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugin Info Meta Box render object
|
|
||||||
*
|
|
||||||
* @var PluginInfoMetaBox
|
|
||||||
*/
|
|
||||||
protected $plugin_info_meta_box;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -208,13 +178,14 @@ class AdminPage
|
|||||||
if ( isset( $options->plugin_core ) )
|
if ( isset( $options->plugin_core ) )
|
||||||
$this->plugin_core( $options->plugin_core );
|
$this->plugin_core( $options->plugin_core );
|
||||||
|
|
||||||
$this->title( $options->title ?? null );
|
if ( isset( $options->title ) )
|
||||||
|
$this->title( $options->title );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo move this to bootstrap()
|
* @todo move this to bootstrap()
|
||||||
*/
|
*/
|
||||||
if ( ! isset( $options->menu_title ) )
|
if ( ! isset( $options->menu_title ) )
|
||||||
$options->menu_title = $this->title;
|
$options->menu_title = $options->title;
|
||||||
|
|
||||||
if ( isset( $options->menu_title ) )
|
if ( isset( $options->menu_title ) )
|
||||||
$this->menu_title( $options->menu_title );
|
$this->menu_title( $options->menu_title );
|
||||||
@ -222,7 +193,8 @@ class AdminPage
|
|||||||
if ( isset( $options->capability ) )
|
if ( isset( $options->capability ) )
|
||||||
$this->capability( $options->capability );
|
$this->capability( $options->capability );
|
||||||
|
|
||||||
$this->slug( $options->slug ?? null );
|
if ( isset( $options->slug ) )
|
||||||
|
$this->slug( $options->slug );
|
||||||
|
|
||||||
if ( isset( $options->plugin_info ) ){ // before render()
|
if ( isset( $options->plugin_info ) ){ // before render()
|
||||||
$this->plugin_info( $options->plugin_info );
|
$this->plugin_info( $options->plugin_info );
|
||||||
@ -232,16 +204,14 @@ class AdminPage
|
|||||||
$this->wrap( $options->wrap );
|
$this->wrap( $options->wrap );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $options->render_cb ) )
|
if ( isset( $options->render ) ) // dev
|
||||||
$this->render_cb( $options->render_cb );
|
|
||||||
|
|
||||||
if ( isset( $options->render_tpl ) ) // before render()
|
|
||||||
$this->render_tpl( $options->render_tpl );
|
|
||||||
|
|
||||||
// This runs last so we can have 'settings-page' with custom render_tpl
|
|
||||||
if ( isset( $options->render ) )
|
|
||||||
$this->render( $options->render );
|
$this->render( $options->render );
|
||||||
|
|
||||||
|
if ( isset( $options->render_cb ) ) // dev - deprecate?
|
||||||
|
$this->render_cb( $options->render_cb );
|
||||||
|
|
||||||
|
if ( isset( $options->render_tpl ) ) // dev - deprecate?
|
||||||
|
$this->render_tpl( $options->render_tpl );
|
||||||
|
|
||||||
if (true)
|
if (true)
|
||||||
$this->render(); // render anyway - will use default tpl if render is empty
|
$this->render(); // render anyway - will use default tpl if render is empty
|
||||||
@ -249,7 +219,6 @@ class AdminPage
|
|||||||
if (true)
|
if (true)
|
||||||
$this->wrap(); // set wrap anyway - will set to 'none' if empty
|
$this->wrap(); // set wrap anyway - will set to 'none' if empty
|
||||||
|
|
||||||
|
|
||||||
if ( isset( $options->parent ) )
|
if ( isset( $options->parent ) )
|
||||||
$this->parent( $options->parent );
|
$this->parent( $options->parent );
|
||||||
|
|
||||||
@ -259,11 +228,6 @@ class AdminPage
|
|||||||
if ( isset( $options->position ) )
|
if ( isset( $options->position ) )
|
||||||
$this->position( $options->position );
|
$this->position( $options->position );
|
||||||
|
|
||||||
if ( isset( $options->tab_group ) ){
|
|
||||||
$this->tab_group( $options->tab_group );
|
|
||||||
$this->tab_title( $options->tab_title ?? $options->submenu_title ?? $options->menu_title );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset( $options->scripts ) )
|
if ( isset( $options->scripts ) )
|
||||||
$this->scripts( $options->scripts );
|
$this->scripts( $options->scripts );
|
||||||
|
|
||||||
@ -289,8 +253,8 @@ class AdminPage
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private function title( $title=null ) {
|
private function title( $title ) {
|
||||||
$this->title = $title ?? ( isset( $this->plugin_core ) ? $this->plugin_core->title() : __METHOD__ );
|
$this->title = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -320,19 +284,7 @@ class AdminPage
|
|||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private function slug( $slug ) {
|
private function slug( $slug ) {
|
||||||
|
$this->slug = $slug;
|
||||||
$this->slug = $slug // if not empty
|
|
||||||
?: $this->settings['option_key'] // if isset option_key
|
|
||||||
?? (
|
|
||||||
isset( $this->plugin_core )
|
|
||||||
? (
|
|
||||||
method_exists( PluginCore::class, 'token' )
|
|
||||||
? $this->plugin_core->token() // PluginCore ~0.25
|
|
||||||
: str_replace('-','_', strtolower( $this->plugin_core->slug() ) ) // PluginCore <= 0.24
|
|
||||||
)
|
|
||||||
: 'slug' . time() // unique slug
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -348,10 +300,6 @@ class AdminPage
|
|||||||
case 'options-general.php':
|
case 'options-general.php':
|
||||||
$this->parent = 'options-general.php';
|
$this->parent = 'options-general.php';
|
||||||
break;
|
break;
|
||||||
case 'tools':
|
|
||||||
case 'tools.php':
|
|
||||||
$this->parent = 'tools.php';
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
break;
|
break;
|
||||||
@ -368,6 +316,7 @@ class AdminPage
|
|||||||
$this->icon_url = $icon_url;
|
$this->icon_url = $icon_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter - position
|
* Setter - position
|
||||||
* WordPress admin menu param
|
* WordPress admin menu param
|
||||||
@ -378,44 +327,6 @@ class AdminPage
|
|||||||
$this->position = $position;
|
$this->position = $position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter - tab_group
|
|
||||||
* CMB2 Tab Group - used by regular 'wrap' pages as well.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
private function tab_group( $tab_group ) {
|
|
||||||
$this->tab_group = $tab_group;
|
|
||||||
|
|
||||||
add_filter( 'cmb2_tab_group_tabs', [ $this, 'add_to_tab_group' ], 10, 2 );
|
|
||||||
add_action( 'cmb2_admin_init', function(){
|
|
||||||
/**
|
|
||||||
* When deactivating CMB2 and reactivating - got this fatal error:
|
|
||||||
*
|
|
||||||
* Fatal error: Uncaught Error: Argument 1 passed to CMB2_Options_Hookup::__construct()
|
|
||||||
* must be an instance of CMB2, bool given,
|
|
||||||
* called in \wp-content\plugins\cgv\inc\CGV.php on line 56
|
|
||||||
* in \wp-content\plugins\cmb2\includes\CMB2_Options_Hookup.php on line 39
|
|
||||||
*
|
|
||||||
* Validate cmb2_get_metabox did not return false.
|
|
||||||
*/
|
|
||||||
if ( $cmb = cmb2_get_metabox( $this->parent ) ){
|
|
||||||
$hookup = new CMB2_Options_Hookup( $cmb, $this->slug );
|
|
||||||
add_action ( "wphelper/adminpage/tab_nav/{$this->tab_group}", [ $hookup, 'options_page_tab_nav_output' ] );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter - tab_title
|
|
||||||
* CMB2 Tab Title - only set if tab_group.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
private function tab_title( $tab_title ) {
|
|
||||||
$this->tab_title = $tab_title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter - render
|
* Setter - render
|
||||||
* Sets render cb or tpl
|
* Sets render cb or tpl
|
||||||
@ -429,30 +340,34 @@ class AdminPage
|
|||||||
*/
|
*/
|
||||||
private function render( $render=null ) {
|
private function render( $render=null ) {
|
||||||
if ( 'settings-page' == $render ) {
|
if ( 'settings-page' == $render ) {
|
||||||
$this->render_tpl( __DIR__ . '/tpl/form-basic.php' );
|
$this->render_tpl( __DIR__ . '/tpl/settings-form.php' );
|
||||||
$this->render = $this->render ?? $render; // 'settings-page'
|
$this->render = $this->render ?? $render; // 'settings-page'
|
||||||
} else if ( 'cmb2' == $render || 'cmb2-tabs' == $render ) {
|
} else if ( 'cmb2' == $render || 'cmb2-tabs' == $render ) {
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
if ( ! defined( 'CMB2_LOADED' ) ){
|
if ( ! defined( 'CMB2_LOADED' ) ){
|
||||||
$this->render_tpl( __DIR__ . '/tpl/wrap-cmb2-unavailable.php' );
|
$this->render_tpl( __DIR__ . '/tpl/cmb2-unavailable.php' );
|
||||||
$this->render = $this->render ?? 'render_tpl';
|
$this->render = $this->render ?? 'render_tpl';
|
||||||
} else {
|
} else {
|
||||||
/**
|
$this->delegate_hookup = true;
|
||||||
* Render templates managed and included by CMB2_OptionsPage
|
|
||||||
* @see CMB2_OptionsPage::options_page_output()
|
if ( ! empty( $this->plugin_core ) || ! empty( $this->plugin_info ) ){
|
||||||
*/
|
$this->render_tpl( __DIR__ . '/tpl/cmb2_options_page-plugin_info.php' );
|
||||||
|
} else {
|
||||||
|
$this->render_tpl( __DIR__ . '/tpl/cmb2_options_page.php' );
|
||||||
|
}
|
||||||
|
|
||||||
$this->render = $this->render ?? $render; // 'cmb2' || 'cmb2-tabs'
|
$this->render = $this->render ?? $render; // 'cmb2' || 'cmb2-tabs'
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if( is_callable( $render ) ) {
|
} else if( is_callable( $render ) ) {
|
||||||
$this->render_cb( $render );
|
$this->render_cb( $render );
|
||||||
$this->render = $this->render ?? 'render_cb';
|
$this->render = $this->render ?? 'render_cb';
|
||||||
} else if ( is_readable( $render ?? '' ) ) {
|
} else if ( is_readable( $render ) ) {
|
||||||
$this->render_tpl( $render );
|
$this->render_tpl( $render );
|
||||||
$this->render = $this->render ?? 'render_tpl';
|
$this->render = $this->render ?? 'render_tpl';
|
||||||
} else {
|
} else {
|
||||||
$this->render_tpl( __DIR__ . '/tpl/wrap-default.php' );
|
$this->render_tpl( __DIR__ . '/tpl/default.php' );
|
||||||
$this->render = $this->render ?? 'render_tpl';
|
$this->render = $this->render ?? 'render_tpl';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,7 +376,7 @@ class AdminPage
|
|||||||
* Setter - render_cb
|
* Setter - render_cb
|
||||||
*
|
*
|
||||||
* if $this->render == 'render_cb'
|
* if $this->render == 'render_cb'
|
||||||
* set callback function in $this->render_cb
|
* set callback funtion in $this->render_cb
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -550,23 +465,11 @@ class AdminPage
|
|||||||
if( is_callable( $plugin_info ) )
|
if( is_callable( $plugin_info ) )
|
||||||
$this->plugin_info = $plugin_info;
|
$this->plugin_info = $plugin_info;
|
||||||
|
|
||||||
// if true-y value passed and plugin_core isset
|
// if true-y value passed and PluginCore class exists - set to true
|
||||||
else if ( ! empty( $plugin_info ) && ! empty( $this->plugin_core ) )
|
else if (!empty($plugin_info) && class_exists('WPHelper\PluginCore'))
|
||||||
$this->plugin_info = true;
|
$this->plugin_info = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add to tab group
|
|
||||||
*
|
|
||||||
* @hook cmb2_tab_group_tabs
|
|
||||||
*/
|
|
||||||
public function add_to_tab_group( $tabs, $tab_group ){
|
|
||||||
if ( $tab_group == $this->tab_group ){
|
|
||||||
$tabs[ $this->slug ] = $this->tab_title;
|
|
||||||
}
|
|
||||||
return $tabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter - scripts
|
* Setter - scripts
|
||||||
* Scripts to enqueue on admin page
|
* Scripts to enqueue on admin page
|
||||||
@ -598,7 +501,7 @@ class AdminPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
function plugin_core($plugin_core){
|
function plugin_core($plugin_core){
|
||||||
if ( $plugin_core instanceof PluginCore ){
|
if ( is_a( $plugin_core, 'WPHelper\PluginCore') ){
|
||||||
$this->plugin_core = $plugin_core;
|
$this->plugin_core = $plugin_core;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -622,18 +525,13 @@ class AdminPage
|
|||||||
'capability' => $this->capability,
|
'capability' => $this->capability,
|
||||||
'slug' => $this->slug,
|
'slug' => $this->slug,
|
||||||
'parent' => $this->parent,
|
'parent' => $this->parent,
|
||||||
'hook_suffix' => $this->hook_suffix,
|
|
||||||
'icon_url' => $this->icon_url,
|
'icon_url' => $this->icon_url,
|
||||||
'position' => $this->position,
|
'position' => $this->position,
|
||||||
'render' => $this->render, // render_cb | render_tpl | settings-page | cmb2 | cmb2-tabs
|
'render' => $this->render, // render_cb | render_tpl | settings-page | cmb2 | cmb2-tabs
|
||||||
'render_cb' => $this->render_cb,
|
'render_cb' => $this->render_cb,
|
||||||
'render_tpl' => $this->render_tpl,
|
'render_tpl' => $this->render_tpl,
|
||||||
'settings' => $this->settings,
|
'settings' => $this->settings,
|
||||||
'wrap' => $this->wrap,
|
|
||||||
'tab_group' => $this->tab_group,
|
|
||||||
'tab_title' => $this->tab_title,
|
|
||||||
'plugin_core' => $this->plugin_core,
|
'plugin_core' => $this->plugin_core,
|
||||||
'plugin_info' => $this->plugin_info,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
@ -672,30 +570,37 @@ class AdminPage
|
|||||||
if ( ! $this->capability )
|
if ( ! $this->capability )
|
||||||
$this->capability = 'manage_options';
|
$this->capability = 'manage_options';
|
||||||
|
|
||||||
add_action( "wphelper/adminpage/plugin_info_box/{$this->slug}" , [ $this , 'render_plugin_info_meta_box' ] );
|
if ( $this->render == 'settings-page' ){
|
||||||
|
|
||||||
/**
|
$this->settings_page = new SettingsPage($this);
|
||||||
* @todo Perhaps this can hook on admin_init - right after admin_menu has finished
|
$this->settings_page->setup();
|
||||||
* @todo CMB2 options-page does not return page_hook/hook_suffix - MUST validate
|
|
||||||
*/
|
|
||||||
add_action ( 'admin_init' , [ $this , '_bootstrap_admin_page' ] );
|
|
||||||
|
|
||||||
if ( in_array( $this->render, [ 'cmb2', 'cmb2-tabs' ] ) ){
|
}
|
||||||
|
|
||||||
$this->cmb2_page = $this->settings['options_type'] ?? '' == 'multi'
|
add_action( "wphelper/adminpage/plugin_info_box/{$this->slug}" , [ $this , 'render_plugin_info_box' ] );
|
||||||
? new CMB2_OptionsPage_Multi( $this )
|
|
||||||
: new CMB2_OptionsPage( $this );
|
// if ( $this->delegate_hookup ){
|
||||||
|
if ( 'cmb2' == $this->render || 'cmb2-tabs' == $this->render ){
|
||||||
|
|
||||||
|
if ( isset( $this->settings['options_type'] ) && $this->settings['options_type'] == 'multi' ) {
|
||||||
|
$this->cmb2_page = new CMB2_OptionsPage_Multi( $this );
|
||||||
|
} else {
|
||||||
|
$this->cmb2_page = new CMB2_OptionsPage( $this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Perhpaps this can hook on admin_init - right after admin_menu has finished
|
||||||
|
* @todo CMB2 options-page does not return page_hook/hook_suffix - MUST validate
|
||||||
|
*/
|
||||||
|
add_action ( 'admin_menu' , [ $this , '_bootstrap_admin_page' ], 12 );
|
||||||
|
|
||||||
// skip add_menu_page
|
// skip add_menu_page
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->render == 'settings-page' ){
|
// if ( ! $this->delegate_hookup ){
|
||||||
$this->settings_page = new SettingsPage($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action ( 'admin_menu' , [ $this , 'add_menu_page' ], 11 );
|
add_action ( 'admin_menu' , [ $this , 'add_menu_page' ], 11 );
|
||||||
add_action ( 'admin_menu' , [ $this , 'add_plugin_info_meta_box' ], 11 );
|
add_action ( 'admin_menu' , [ $this , '_bootstrap_admin_page' ], 12 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,21 +644,6 @@ class AdminPage
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function add_plugin_info_meta_box() {
|
|
||||||
$metabox_args = [
|
|
||||||
'id' => $this->slug . '_plugin_info_meta_box', // id is unique (in case a plugin uses $this->slug)
|
|
||||||
'title' => 'Plugin Info',
|
|
||||||
'context' => 'side',
|
|
||||||
'screens' => [ $this->get_hook_suffix() ],
|
|
||||||
// 'template',
|
|
||||||
'render' => [ $this , 'render_plugin_info_meta_box_inside' ],
|
|
||||||
];
|
|
||||||
( new MetaBox($metabox_args) )->add();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,6 +653,14 @@ class AdminPage
|
|||||||
*/
|
*/
|
||||||
public function validate_page_hook(){
|
public function validate_page_hook(){
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hack!
|
||||||
|
* This is ad hoc validation - should do this earlier
|
||||||
|
*/
|
||||||
|
if ( empty( $this->slug ) ){
|
||||||
|
$this->slug = $this->settings['option_key'];
|
||||||
|
}
|
||||||
|
|
||||||
if ( empty( $this->hook_suffix ) ){
|
if ( empty( $this->hook_suffix ) ){
|
||||||
$this->hook_suffix = get_plugin_page_hookname( $this->slug, $this->parent );
|
$this->hook_suffix = get_plugin_page_hookname( $this->slug, $this->parent );
|
||||||
}
|
}
|
||||||
@ -780,9 +678,14 @@ class AdminPage
|
|||||||
*
|
*
|
||||||
* @hook admin_menu priority 12
|
* @hook admin_menu priority 12
|
||||||
* @access private
|
* @access private
|
||||||
|
*
|
||||||
|
* @todo move this function to admin_init - after admin_menu has finished
|
||||||
*/
|
*/
|
||||||
public function _bootstrap_admin_page(){
|
public function _bootstrap_admin_page(){
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo perhaps run this on 'admin_init'
|
||||||
|
*/
|
||||||
$this->validate_page_hook();
|
$this->validate_page_hook();
|
||||||
|
|
||||||
add_action ( 'load-' . $this->hook_suffix , [ $this , '_admin_page_setup' ] );
|
add_action ( 'load-' . $this->hook_suffix , [ $this , '_admin_page_setup' ] );
|
||||||
@ -870,7 +773,7 @@ class AdminPage
|
|||||||
*/
|
*/
|
||||||
public function get_capability()
|
public function get_capability()
|
||||||
{
|
{
|
||||||
return $this->capability;
|
return $this->capabailty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -951,21 +854,19 @@ class AdminPage
|
|||||||
*/
|
*/
|
||||||
public function render_admin_page()
|
public function render_admin_page()
|
||||||
{
|
{
|
||||||
|
// @todo if render callback supplied - add shortcircuit hook here
|
||||||
|
// execute render callback and return early
|
||||||
|
|
||||||
// if wrap - 1. We collect output buffer
|
|
||||||
if ( 'none' != $this->wrap ){
|
if ( 'none' != $this->wrap ){
|
||||||
ob_start();
|
ob_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------[The McGuffin]---------------------------------//
|
|
||||||
if ( isset( $this->render_cb ) && is_callable( $this->render_cb ) ) {
|
if ( isset( $this->render_cb ) && is_callable( $this->render_cb ) ) {
|
||||||
call_user_func( $this->render_cb );
|
call_user_func( $this->render_cb );
|
||||||
} else if ( isset( $this->render_tpl ) && is_readable( $this->render_tpl ) ) {
|
} else if ( isset( $this->render_tpl ) && is_readable( $this->render_tpl ) ) {
|
||||||
include $this->render_tpl;
|
include $this->render_tpl;
|
||||||
}
|
}
|
||||||
//---------------------------[The McGuffin]---------------------------------//
|
|
||||||
|
|
||||||
// if wrap - 2. include chosen wrap template
|
|
||||||
if ( 'none' != $this->wrap ){
|
if ( 'none' != $this->wrap ){
|
||||||
$ob_content = ob_get_clean();
|
$ob_content = ob_get_clean();
|
||||||
|
|
||||||
@ -984,21 +885,7 @@ class AdminPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Render plugin info metabox
|
||||||
* @see render_plugin_info_meta_box()
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function render_plugin_info_box(){
|
|
||||||
|
|
||||||
_doing_it_wrong( __METHOD__, 'Deprecated. Use render_plugin_info_meta_box() instead.', '0.26' );
|
|
||||||
|
|
||||||
$this->render_plugin_info_meta_box();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render plugin info meta-box
|
|
||||||
*
|
*
|
||||||
* Call user-provided callable.
|
* Call user-provided callable.
|
||||||
* Or else attempt to create PluginInfoMetaBox class from $this->plugin_core and call its render function.
|
* Or else attempt to create PluginInfoMetaBox class from $this->plugin_core and call its render function.
|
||||||
@ -1008,55 +895,17 @@ class AdminPage
|
|||||||
* @todo See if this function should be public API or only run on action hook
|
* @todo See if this function should be public API or only run on action hook
|
||||||
* @todo deprecate public use - use wphelper/adminpage/plugin_info_box/{$this->slug} instead
|
* @todo deprecate public use - use wphelper/adminpage/plugin_info_box/{$this->slug} instead
|
||||||
*/
|
*/
|
||||||
public function render_plugin_info_meta_box(){
|
public function render_plugin_info_box(){
|
||||||
|
|
||||||
if ( isset( $this->plugin_info ) && is_callable( $this->plugin_info ) ) {
|
if ( isset( $this->plugin_info ) && is_callable( $this->plugin_info ) ) {
|
||||||
call_user_func( $this->plugin_info );
|
call_user_func( $this->plugin_info );
|
||||||
} else {
|
} else {
|
||||||
|
if ( ! empty( $this->plugin_core ) && empty( $this->plugin_info_meta_box ) ){
|
||||||
if (!$this->bootstrap_plugin_info_meta_box()){
|
$this->plugin_info_meta_box = new PluginInfoMetaBox( $this->plugin_core );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
$this->plugin_info_meta_box->plugin_info_box();
|
||||||
/**
|
|
||||||
* Allow plugins to modify plugin info meta box
|
|
||||||
*
|
|
||||||
* @since 0.23
|
|
||||||
*/
|
|
||||||
do_action( "wphelper/plugin_info_meta_box/{$this->plugin_core->slug()}" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function render_plugin_info_meta_box_inside(){
|
|
||||||
if ( isset( $this->plugin_info ) && is_callable( $this->plugin_info ) ) {
|
|
||||||
call_user_func( $this->plugin_info );
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (!$this->bootstrap_plugin_info_meta_box()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
do_action( "wphelper/plugin_info_meta_box/inside/{$this->plugin_core->slug()}" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap PluginInfoMetaBox
|
|
||||||
*/
|
|
||||||
private function bootstrap_plugin_info_meta_box() {
|
|
||||||
if ( empty( $this->plugin_info_meta_box ) && ! empty( $this->plugin_core ) ){
|
|
||||||
$this->plugin_info_meta_box = new PluginInfoMetaBox( $this->plugin_core );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no plugin_info_meta_box - return false
|
|
||||||
if ( empty( $this->plugin_info_meta_box ) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
@ -4,9 +4,9 @@ namespace WPHelper;
|
|||||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||||
|
|
||||||
use CMB2;
|
use CMB2;
|
||||||
use CMB2_Options_Hookup;
|
use CMB2_Options_Hook;
|
||||||
|
|
||||||
if ( ! class_exists( CMB2_OptionsPage::class ) ):
|
if ( ! class_exists( 'WPHelper\CMB2_OptionsPage' ) ):
|
||||||
/**
|
/**
|
||||||
* CMB2_OptionsPage
|
* CMB2_OptionsPage
|
||||||
*
|
*
|
||||||
@ -26,21 +26,11 @@ class CMB2_OptionsPage{
|
|||||||
*/
|
*/
|
||||||
public $admin_page;
|
public $admin_page;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array $fields
|
|
||||||
*/
|
|
||||||
protected $fields;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var CMB2 $cmb
|
* @var CMB2 $cmb
|
||||||
*/
|
*/
|
||||||
private $cmb;
|
private $cmb;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array $cmb2_options
|
|
||||||
*/
|
|
||||||
protected $cmb2_options;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AdminPage $admin_page
|
* @param AdminPage $admin_page
|
||||||
*/
|
*/
|
||||||
@ -58,8 +48,6 @@ class CMB2_OptionsPage{
|
|||||||
$settings['option_key'] ??= ( $settings['option_name'] ?? ( $settings['id'] ?? $admin_options['slug'] ) );
|
$settings['option_key'] ??= ( $settings['option_name'] ?? ( $settings['id'] ?? $admin_options['slug'] ) );
|
||||||
$settings['title'] ??= $admin_options['title'];
|
$settings['title'] ??= $admin_options['title'];
|
||||||
$settings['menu_title'] ??= $admin_options['menu_title'];
|
$settings['menu_title'] ??= $admin_options['menu_title'];
|
||||||
// @todo Only if cmb2-tabs
|
|
||||||
$settings['tab_title'] ??= $admin_options['tab_title'] ?? $settings['submenu_title'] ?? $settings['menu_title'];
|
|
||||||
$settings['parent_slug'] ??= $admin_options['parent'];
|
$settings['parent_slug'] ??= $admin_options['parent'];
|
||||||
$settings['position'] ??= $admin_options['position'];
|
$settings['position'] ??= $admin_options['position'];
|
||||||
$settings['icon_url'] ??= $admin_options['icon_url'];
|
$settings['icon_url'] ??= $admin_options['icon_url'];
|
||||||
@ -75,8 +63,7 @@ class CMB2_OptionsPage{
|
|||||||
/**
|
/**
|
||||||
* CMB2 only accepts url slug
|
* CMB2 only accepts url slug
|
||||||
*
|
*
|
||||||
* @todo export parent_slug conversion to dedicated method
|
* @todo export parent_slug convertion to dedicated method
|
||||||
* @todo perhaps move this to AdminPage::parent() method
|
|
||||||
*/
|
*/
|
||||||
switch ( $settings['parent_slug'] ) {
|
switch ( $settings['parent_slug'] ) {
|
||||||
case 'dashboard':
|
case 'dashboard':
|
||||||
@ -129,11 +116,11 @@ class CMB2_OptionsPage{
|
|||||||
$settings['tab_title'] ??= $settings['menu_title'];
|
$settings['tab_title'] ??= $settings['menu_title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fields = $settings['fields'] ?? [];
|
|
||||||
/**
|
|
||||||
* @todo revisit this - might not need to unset fields
|
|
||||||
*/
|
|
||||||
if ( isset( $settings['fields'] ) ){
|
if ( isset( $settings['fields'] ) ){
|
||||||
|
$this->fields = $settings['fields'];
|
||||||
|
/**
|
||||||
|
* @todo revisit this - might not need to unset fields
|
||||||
|
*/
|
||||||
unset( $settings['fields'] );
|
unset( $settings['fields'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,11 +179,7 @@ class CMB2_OptionsPage{
|
|||||||
// register parent pages before sub-menu pages
|
// register parent pages before sub-menu pages
|
||||||
$priority = empty( $settings['parent_slug'] ) ? 9 : 10;
|
$priority = empty( $settings['parent_slug'] ) ? 9 : 10;
|
||||||
|
|
||||||
if ( $settings['allow_on_front'] ?? false ){
|
add_action( 'cmb2_admin_init', [ $this, 'register_metabox' ], $priority );
|
||||||
add_action( 'cmb2_init', [ $this, 'register_metabox' ], $priority );
|
|
||||||
} else {
|
|
||||||
add_action( 'cmb2_admin_init', [ $this, 'register_metabox' ], $priority );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo add 'submenu' field and functionality to WPHelper\AdminPage
|
* @todo add 'submenu' field and functionality to WPHelper\AdminPage
|
||||||
@ -215,20 +198,12 @@ class CMB2_OptionsPage{
|
|||||||
/**
|
/**
|
||||||
* Display options-page output. To override, set 'display_cb' box property.
|
* Display options-page output. To override, set 'display_cb' box property.
|
||||||
*
|
*
|
||||||
* @param CMB2_Options_Hookup $hookup - instance of Options Page Hookup class (caller of this function)
|
* @param CMB2_Options_Hook $hookup - instance of Options Page Hookup class (caller of this function)
|
||||||
*
|
*
|
||||||
* @see CMB2_Options_Hookup
|
* @see CMB2_Options_Hook
|
||||||
*/
|
*/
|
||||||
public function options_page_output( $hookup ) {
|
public function options_page_output( $hookup ) {
|
||||||
|
include $this->admin_page->get_render_tpl();
|
||||||
$options = $this->admin_page->options();
|
|
||||||
|
|
||||||
if ( ! empty( $options['plugin_core'] ) || ! empty( $options['plugin_info'] ) ){
|
|
||||||
include __DIR__ . '/tpl/wrap-cmb2-sidebar.php';
|
|
||||||
} else {
|
|
||||||
include __DIR__ . '/tpl/wrap-cmb2-simple.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,13 +3,9 @@ namespace WPHelper;
|
|||||||
|
|
||||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||||
|
|
||||||
if ( ! class_exists( CMB2_OptionsPage_Multi::class ) ):
|
include_once __DIR__ . '/CMB2_Override_Meta.php';
|
||||||
|
|
||||||
// Require dependency CMB2_Override_Meta
|
|
||||||
if ( ! trait_exists( CMB2_Override_Meta::class ) ) {
|
|
||||||
require_once __DIR__ . '/CMB2_Override_Meta.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ( ! class_exists( 'WPHelper\CMB2_OptionsPage_Multi' ) ):
|
||||||
/**
|
/**
|
||||||
* CMB2_OptionsPage - MULTI
|
* CMB2_OptionsPage - MULTI
|
||||||
*
|
*
|
||||||
|
|||||||
@ -3,7 +3,7 @@ namespace WPHelper;
|
|||||||
|
|
||||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||||
|
|
||||||
if ( ! trait_exists( CMB2_Override_Meta::class ) ):
|
if ( ! trait_exists('CMB2_Override_Meta') ):
|
||||||
/**
|
/**
|
||||||
* CMB2 Options page override meta
|
* CMB2 Options page override meta
|
||||||
*
|
*
|
||||||
|
|||||||
@ -2,75 +2,27 @@
|
|||||||
namespace WPHelper;
|
namespace WPHelper;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use function get_plugin_data;
|
||||||
|
|
||||||
if ( ! class_exists( PluginInfoMetaBox::class ) ):
|
if ( ! class_exists( 'WPHelper\PluginInfoMetaBox' ) ):
|
||||||
/**
|
/**
|
||||||
* Plugin Info Metabox
|
* Plugin Info Metabox
|
||||||
*
|
*
|
||||||
* Get instance of PluginCore
|
* Get instance of PluginCore
|
||||||
* Render default plugin info box template.
|
* Render default plugin info box template.
|
||||||
*
|
|
||||||
* @since 0.14
|
|
||||||
*/
|
*/
|
||||||
class PluginInfoMetaBox{
|
class PluginInfoMetaBox{
|
||||||
|
|
||||||
private $tpl = '/tpl/plugin_info_meta_box.php';
|
private $tpl = '/tpl/plugin_info_meta_box.php';
|
||||||
|
|
||||||
private $tpl_inside = '/tpl/plugin_info_meta_box-inside.php';
|
|
||||||
|
|
||||||
private $tpl_debug = '/tpl/plugin_info_meta_box-wph_debug.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var PluginCore
|
* @var PluginCore
|
||||||
*/
|
*/
|
||||||
public $plugin_core;
|
private $plugin_core;
|
||||||
|
|
||||||
function __construct( PluginCore $plugin_core )
|
function __construct( PluginCore $plugin_core )
|
||||||
{
|
{
|
||||||
$this->plugin_core = $plugin_core;
|
$this->plugin_core = $plugin_core;
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow plugins to render or modify plugin info box
|
|
||||||
*
|
|
||||||
* Call: do_action('wphelper/plugin_info_meta_box/{$slug}')
|
|
||||||
* action used in AdminPage::render_plugin_info_meta_box()
|
|
||||||
*
|
|
||||||
* @since 0.23
|
|
||||||
*/
|
|
||||||
add_action( "wphelper/plugin_info_meta_box/{$this->plugin_core->slug()}", [ $this, 'plugin_info_box' ] );
|
|
||||||
|
|
||||||
add_action( "wphelper/plugin_info_meta_box/inside/{$this->plugin_core->slug()}", [ $this, 'inside' ] );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup args used in template.
|
|
||||||
*
|
|
||||||
* @todo move 'repo' setup to method from template
|
|
||||||
*/
|
|
||||||
function setup_template_args() {
|
|
||||||
|
|
||||||
$plugin_data = $this->plugin_core->plugin_data();
|
|
||||||
|
|
||||||
|
|
||||||
$last_update = $plugin_data['Last Update'] ?: $plugin_data['Release Date'];
|
|
||||||
$last_update = DateTime::createFromFormat('Y_m_d', $last_update);
|
|
||||||
|
|
||||||
if ($last_update) {
|
|
||||||
$diff = (int) abs( time() - $last_update->format('U') );
|
|
||||||
|
|
||||||
if ( $diff < (DAY_IN_SECONDS) ){
|
|
||||||
$update_message = 'Today';
|
|
||||||
}elseif ($diff < (2 * DAY_IN_SECONDS)){
|
|
||||||
$update_message = 'Yesterday';
|
|
||||||
}else{
|
|
||||||
$update_message = human_time_diff($last_update->format('U')) . ' ago';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$update_message = '';
|
|
||||||
}
|
|
||||||
return compact('plugin_data','update_message');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,36 +33,33 @@ class PluginInfoMetaBox{
|
|||||||
* @since iac_engine 1.1.0
|
* @since iac_engine 1.1.0
|
||||||
* @since iac_engine 1.2.0 plugin_info_box now a function
|
* @since iac_engine 1.2.0 plugin_info_box now a function
|
||||||
* @since iac_engine 1.3.0 use 'Last Update' header
|
* @since iac_engine 1.3.0 use 'Last Update' header
|
||||||
* @since 0.14 PluginInfoMetaBox::plugin_info_box()
|
|
||||||
*
|
|
||||||
* @todo rename method render()
|
|
||||||
*/
|
*/
|
||||||
function plugin_info_box(){
|
function plugin_info_box(){
|
||||||
$args = $this->setup_template_args();
|
|
||||||
extract($args);
|
$plugin_data = get_plugin_data( $this->plugin_core->file() , false ); // false = no markup (i think)
|
||||||
|
|
||||||
|
|
||||||
|
$last_update = $plugin_data['Last Update'] ?: $plugin_data['Release Date'];
|
||||||
|
$last_update = DateTime::createFromFormat('Y_m_d', $last_update);
|
||||||
|
|
||||||
|
// $last_update = new DateTime('now');
|
||||||
|
// $last_update->add(new DateInterval('P1D'));
|
||||||
|
// $last_update->add(new DateInterval('P2D'));
|
||||||
|
if ($last_update):
|
||||||
|
$diff = (int) abs( time() - $last_update->format('U') );
|
||||||
|
|
||||||
|
if ( $diff < (DAY_IN_SECONDS) ){
|
||||||
|
$update_message = 'Today';
|
||||||
|
}elseif ($diff < (2 * DAY_IN_SECONDS)){
|
||||||
|
$update_message = 'Yesterday';
|
||||||
|
}else{
|
||||||
|
$update_message = human_time_diff($last_update->format('U')) . ' ago';
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
$update_message = '';
|
||||||
|
endif;
|
||||||
|
|
||||||
include __DIR__ . $this->tpl;
|
include __DIR__ . $this->tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only print meta-box .inside
|
|
||||||
* No header.
|
|
||||||
*/
|
|
||||||
function inside(){
|
|
||||||
$args = $this->setup_template_args();
|
|
||||||
extract($args);
|
|
||||||
include __DIR__ . $this->tpl_inside;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WPHelper classes debug info
|
|
||||||
*
|
|
||||||
* Prints inside Plugin Info Meta Box
|
|
||||||
*
|
|
||||||
* @since 0.26
|
|
||||||
*/
|
|
||||||
function wph_debug() {
|
|
||||||
include __DIR__ . $this->tpl_debug;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
108
vendor/abuyoyo/adminmenupage/src/SettingsPage.php
vendored
108
vendor/abuyoyo/adminmenupage/src/SettingsPage.php
vendored
@ -9,7 +9,7 @@ use function add_settings_field;
|
|||||||
use function checked;
|
use function checked;
|
||||||
use function get_option;
|
use function get_option;
|
||||||
|
|
||||||
if ( ! class_exists( SettingsPage::class ) ):
|
if ( ! class_exists( 'WPHelper\SettingsPage' ) ):
|
||||||
/**
|
/**
|
||||||
* SettingsPage
|
* SettingsPage
|
||||||
*
|
*
|
||||||
@ -32,45 +32,38 @@ class SettingsPage{
|
|||||||
/**
|
/**
|
||||||
* Page slug to display sections
|
* Page slug to display sections
|
||||||
*
|
*
|
||||||
* @var string $page
|
* @var String $page
|
||||||
*/
|
*/
|
||||||
public $page;
|
protected $page;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* option_name key used in wp_options table
|
* option_name key used in wp_options table
|
||||||
*
|
*
|
||||||
* @var string $option_name
|
* @var String $option_name
|
||||||
*/
|
*/
|
||||||
protected $option_name;
|
protected $option_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* option_group used by register_setting() and settings_fields()
|
* option_group used by register_setting() and settings_fields()
|
||||||
*
|
*
|
||||||
* @var string $option_group
|
* @var String $option_group
|
||||||
*/
|
*/
|
||||||
public $option_group;
|
public $option_group;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sections
|
* Sections
|
||||||
*
|
*
|
||||||
* @var array[] $sections
|
* @var Array[] $sections
|
||||||
*/
|
*/
|
||||||
public $sections = [];
|
public $sections = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields
|
* Fields
|
||||||
*
|
*
|
||||||
* @var array[] $fields
|
* @var Array[] $fields
|
||||||
*/
|
*/
|
||||||
public $fields = [];
|
public $fields = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* Sanitize Callback
|
|
||||||
*
|
|
||||||
* @var Callable $sanitize_callback
|
|
||||||
*/
|
|
||||||
public $sanitize_callback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -96,20 +89,18 @@ class SettingsPage{
|
|||||||
|
|
||||||
$this->option_group = $settings['option_group'] ?? $this->page . '_option_group';
|
$this->option_group = $settings['option_group'] ?? $this->page . '_option_group';
|
||||||
|
|
||||||
$this->sanitize_callback = $settings['sanitize_callback'] ?? null;
|
foreach ( $settings['sections'] as $section ) {
|
||||||
|
|
||||||
// PHP Warning: foreach() argument must be of type array|object
|
|
||||||
foreach ( $settings['sections'] ?? [] as $section ) {
|
|
||||||
// extract fields
|
// extract fields
|
||||||
foreach ( $section['fields'] as $field ){
|
foreach ( $section['fields'] as $field ){
|
||||||
$field['section_id'] = $section['id']; // create back-reference in field to section. ( @see add_settings_field() )
|
$field['section_id'] = $section['id']; // create back-reference in field to section. ( @see add_settings_field() )
|
||||||
$field['name'] = $this->option_name . '[' . $field['id'] . ']';
|
|
||||||
$this->fields[] = $field;
|
$this->fields[] = $field;
|
||||||
}
|
}
|
||||||
unset( $section['fields'] );
|
unset( $section['fields'] );
|
||||||
$this->sections[] = $section; // save without fields
|
$this->sections[] = $section; // save without fields
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup() {
|
||||||
add_action( 'admin_init', [ $this, 'register_settings' ] );
|
add_action( 'admin_init', [ $this, 'register_settings' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +108,7 @@ class SettingsPage{
|
|||||||
register_setting(
|
register_setting(
|
||||||
$this->option_group, // $option_group - A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
|
$this->option_group, // $option_group - A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
|
||||||
$this->option_name, // $option_name - The name of an option to sanitize and save.
|
$this->option_name, // $option_name - The name of an option to sanitize and save.
|
||||||
$this->sanitize_callback ?? [ $this,'sanitize_settings' ] // callback ?? fallback // $sanitize_callback - A callback function that sanitizes the option's value. (see also: built-in php callbacks)
|
[ $this,'sanitize_settings' ] // $sanitize_callback - A callback function that sanitizes the option's value. (see also: built-in php callbacks)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $this->sections as $section ){
|
foreach ( $this->sections as $section ){
|
||||||
@ -134,7 +125,7 @@ class SettingsPage{
|
|||||||
add_settings_field(
|
add_settings_field(
|
||||||
$field['id'],
|
$field['id'],
|
||||||
$field['title'],
|
$field['title'],
|
||||||
$field['render'] ?? [ $this, "print_{$field['type']}" ],
|
[ $this, "print_{$field['type']}" ],
|
||||||
$this->page, // can built-in pages: (general, reading, writing, ...)
|
$this->page, // can built-in pages: (general, reading, writing, ...)
|
||||||
$field['section_id'],
|
$field['section_id'],
|
||||||
$field //send setting array as $args for print function
|
$field //send setting array as $args for print function
|
||||||
@ -144,8 +135,8 @@ class SettingsPage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print checkbox input field
|
* Print text input field
|
||||||
* Support field type 'checkbox'
|
* Support field type 'text'
|
||||||
*
|
*
|
||||||
* @since 0.11
|
* @since 0.11
|
||||||
*/
|
*/
|
||||||
@ -156,11 +147,10 @@ class SettingsPage{
|
|||||||
|
|
||||||
$input_tag = sprintf(
|
$input_tag = sprintf(
|
||||||
'<label for="%1$s">
|
'<label for="%1$s">
|
||||||
<input name="%2$s" type="checkbox" id="%1$s" aria-describedby="%1$s-description" value="1" %4$s />
|
<input name="%2$s[%1$s]" type="checkbox" id="%1$s" value="1" %4$s />
|
||||||
%3$s
|
%3$s</label>',
|
||||||
</label>',
|
|
||||||
$id,
|
$id,
|
||||||
$name,
|
$this->option_name,
|
||||||
$description,
|
$description,
|
||||||
checked( ( $options[$id] ?? false ), '1', false)
|
checked( ( $options[$id] ?? false ), '1', false)
|
||||||
);
|
);
|
||||||
@ -186,11 +176,10 @@ class SettingsPage{
|
|||||||
$options = get_option( $this->option_name );
|
$options = get_option( $this->option_name );
|
||||||
|
|
||||||
$input_tag = sprintf(
|
$input_tag = sprintf(
|
||||||
'<input name="%2$s" type="text" id="%1$s" aria-describedby="%1$s-description" value="%3$s" placeholder="%4$s" class="regular-text">',
|
'<input name="%2$s[%1$s]" type="text" id="%1$s" value="%3$s" class="regular-text">',
|
||||||
$id,
|
$id,
|
||||||
$name,
|
$this->option_name,
|
||||||
$options[$id] ?: $default ?? '',
|
$default
|
||||||
$placeholder ?? ''
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! empty( $description ) ) {
|
if ( ! empty( $description ) ) {
|
||||||
@ -222,11 +211,10 @@ class SettingsPage{
|
|||||||
$options = get_option( $this->option_name );
|
$options = get_option( $this->option_name );
|
||||||
|
|
||||||
$input_tag = sprintf(
|
$input_tag = sprintf(
|
||||||
'<input name="%2$s" type="url" id="%1$s" aria-describedby="%1$s-description" placeholder="%4$s" value="%3$s" class="regular-text code ">',
|
'<input name="%2$s[%1$s]" type="url" id="%1$s" value="%3$s" class="regular-text code ">',
|
||||||
$id,
|
$id,
|
||||||
$name,
|
$this->option_name,
|
||||||
$options[$id] ?: $default ?? '',
|
$default
|
||||||
$placeholder ?? ''
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! empty( $description ) ) {
|
if ( ! empty( $description ) ) {
|
||||||
@ -258,11 +246,10 @@ class SettingsPage{
|
|||||||
$options = get_option( $this->option_name );
|
$options = get_option( $this->option_name );
|
||||||
|
|
||||||
$input_tag = sprintf(
|
$input_tag = sprintf(
|
||||||
'<input name="%2$s" type="email" id="%1$s" aria-describedby="%1$s-description" placeholder="%4$s" value="%3$s" class="regular-text ltr">',
|
'<input name="%2$s[%1$s]" type="email" id="%1$s" aria-describedby="%1$s-description" value="%3$s" class="regular-text ltr">',
|
||||||
$id,
|
$id,
|
||||||
$name,
|
$this->option_name,
|
||||||
$options[$id] ?: $default ?? '',
|
$default
|
||||||
$placeholder ?? ''
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! empty( $description ) ) {
|
if ( ! empty( $description ) ) {
|
||||||
@ -282,42 +269,6 @@ class SettingsPage{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Print email input field
|
|
||||||
* Support field type 'email'
|
|
||||||
*
|
|
||||||
* @since 0.23
|
|
||||||
*/
|
|
||||||
function print_textarea( $field ){
|
|
||||||
extract($field);
|
|
||||||
|
|
||||||
$options = get_option( $this->option_name );
|
|
||||||
|
|
||||||
$textarea = sprintf(
|
|
||||||
'<textarea class="regular-text" rows="5" id="%1$s-description" name="%2$s" placeholder="%4$s">%3$s</textarea>',
|
|
||||||
$id,
|
|
||||||
$name,
|
|
||||||
$options[$id] ?: $default ?? '',
|
|
||||||
$placeholder ?? ''
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( ! empty( $description ) ) {
|
|
||||||
$textarea .= sprintf(
|
|
||||||
'<p class="description" id="%1$s-description">%2$s</p>',
|
|
||||||
$id,
|
|
||||||
$description
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow plugins to directly manipulate field HTML
|
|
||||||
*/
|
|
||||||
$textarea = apply_filters( 'wphelper/settings_page/textarea', $textarea, $field, $this->option_name, $options );
|
|
||||||
|
|
||||||
echo $textarea;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitizes entire $options array.
|
* Sanitizes entire $options array.
|
||||||
*/
|
*/
|
||||||
@ -325,25 +276,24 @@ class SettingsPage{
|
|||||||
$new_options = [];
|
$new_options = [];
|
||||||
|
|
||||||
foreach( $options as $id => $option ) {
|
foreach( $options as $id => $option ) {
|
||||||
$field = current(
|
$field = reset(
|
||||||
array_filter(
|
array_filter(
|
||||||
$this->fields,
|
$this->fields,
|
||||||
fn($item) => $item['id'] == $id
|
fn($item) => $item['id'] == $id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
switch ( $field['type'] ) {
|
switch ( $field['type'] ){
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
$new_options[$id] = $option == 1 ? 1 : 0;
|
$new_options[$id] = $option == 1 ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'textarea':
|
|
||||||
$new_options[$id] = sanitize_text_field( $option );
|
$new_options[$id] = sanitize_text_field( $option );
|
||||||
break;
|
break;
|
||||||
case 'email':
|
case 'email':
|
||||||
$new_options[$id] = sanitize_email( $option );
|
$new_options[$id] = sanitize_email( $option );
|
||||||
break;
|
break;
|
||||||
case 'url':
|
case 'url':
|
||||||
$new_options[$id] = esc_url_raw( $option );
|
$new_options[$id] = sanitize_url( $option );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Template for CMB2 page title
|
* Template for CMB2 page title
|
||||||
*
|
*
|
||||||
* @var WPHelper\CMB2_OptionsPage $this
|
* @var WPHelper\CMB2_Options_Page $this
|
||||||
*/
|
*/
|
||||||
if ( $this->cmb->prop( 'title' ) ) {
|
if ( $this->cmb->prop( 'title' ) ) {
|
||||||
echo '<h2>' . wp_kses_post( $this->cmb->prop( 'title' ) ) . '</h2>';
|
echo '<h2>' . wp_kses_post( $this->cmb->prop( 'title' ) ) . '</h2>';
|
||||||
@ -4,6 +4,6 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h3>CMB2 Plugin Missing</h3>
|
<h3>CMB2 Plugin Missing</h3>
|
||||||
<p>CMB2 plugin is required to display this page.
|
<p>CMB2 plugin is required to display this page.
|
||||||
<br>Please install and activate <a href="<?php echo admin_url('plugin-install.php?s=cmb2&tab=search') ?>">CMB2 plugin</a>.
|
<br>Download and activate CMB2 plugin.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -2,8 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* Template for CMB2 Options Page
|
* Template for CMB2 Options Page
|
||||||
*
|
*
|
||||||
* @var WPHelper\CMB2_OptionsPage $this
|
* @var WPHelper\CMB2_Options_Page $this
|
||||||
* @var CMB2_Options_Hookup $hookup
|
* @var CMB2_Options_Hook $hookup
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
@ -17,8 +17,8 @@
|
|||||||
</style>
|
</style>
|
||||||
<div class="wrap cmb2-options-page option-<?php echo esc_attr( sanitize_html_class( $hookup->option_key ) ); ?>">
|
<div class="wrap cmb2-options-page option-<?php echo esc_attr( sanitize_html_class( $hookup->option_key ) ); ?>">
|
||||||
|
|
||||||
<?php include 'title-cmb2.php' ?>
|
<?php include 'cmb-title.php' ?>
|
||||||
<?php include 'tab-nav-cmb2.php' ?>
|
<?php include 'tab-nav.php' ?>
|
||||||
|
|
||||||
<div id="poststuff">
|
<div id="poststuff">
|
||||||
<div id="post-body" class="metabox-holder columns-2">
|
<div id="post-body" class="metabox-holder columns-2">
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<!-- main content -->
|
<!-- main content -->
|
||||||
<div id="post-body-content">
|
<div id="post-body-content">
|
||||||
<div class="meta-box-sortables ui-sortable tabs-content">
|
<div class="meta-box-sortables ui-sortable tabs-content">
|
||||||
<?php include 'form-cmb2.php' ?>
|
<?php include 'cmb-form.php' ?>
|
||||||
</div><!-- .meta-box-sortables -->
|
</div><!-- .meta-box-sortables -->
|
||||||
</div><!-- #post-body-content -->
|
</div><!-- #post-body-content -->
|
||||||
|
|
||||||
13
vendor/abuyoyo/adminmenupage/src/tpl/cmb2_options_page.php
vendored
Normal file
13
vendor/abuyoyo/adminmenupage/src/tpl/cmb2_options_page.php
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Template for CMB2 Options Page
|
||||||
|
*
|
||||||
|
* @var WPHelper\CMB2_Options_Page $this
|
||||||
|
* @var CMB2_Options_Hook $hookup
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<div class="wrap cmb2-options-page option-<?php echo esc_attr( sanitize_html_class( $hookup->option_key ) ); ?>">
|
||||||
|
<?php include 'cmb-title.php' ?>
|
||||||
|
<?php include 'tab-nav.php' ?>
|
||||||
|
<?php include 'cmb-form.php' ?>
|
||||||
|
</div>
|
||||||
@ -1,10 +1,3 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* WordPress admin 'wrap' div
|
|
||||||
*
|
|
||||||
* @var WPHelper\AdminPage $this
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?= get_admin_page_title() ?></h1>
|
<h1><?= get_admin_page_title() ?></h1>
|
||||||
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Plugin Info Metabox - .inside
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<h3 style="font-weight: 100; font-size: 1.5em;"><?php echo $plugin_data['Name']; ?></h3>
|
|
||||||
<p>
|
|
||||||
<?php if ( ! empty( $plugin_data['Version'] ) ): ?>
|
|
||||||
Version: <?php echo $plugin_data['Version']; ?><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ( ! empty( $plugin_data['Author'] ) ): ?>
|
|
||||||
Author:
|
|
||||||
<?php if ( ! empty( $plugin_data['AuthorURI'] ) ): ?>
|
|
||||||
<a href="<?php echo $plugin_data['AuthorURI'] ?>"><?php echo $plugin_data['Author']; ?></a><br/>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php echo $plugin_data['Author']; ?><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ( ! empty( $plugin_data['UpdateURI'] ) || ! empty( $plugin_data['PluginURI'] ) ): ?>
|
|
||||||
Repo: <a href="<?php echo $plugin_data['UpdateURI'] ?: $plugin_data['PluginURI']; ?>">
|
|
||||||
<?php echo $plugin_data['TextDomain'] ?? $this->$plugin_core->slug(); ?>
|
|
||||||
</a><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ( ! empty( $update_message ) ): ?>
|
|
||||||
Last Updated: <?php echo $update_message; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Print WPHelper debug info in plugin info meta box
|
|
||||||
*
|
|
||||||
* @since 0.26
|
|
||||||
*/
|
|
||||||
if ( defined('WPH_DEBUG') && WPH_DEBUG ) {
|
|
||||||
/** @var WPHelper\PluginInfoMetaBox $this */
|
|
||||||
$this->wph_debug();
|
|
||||||
}
|
|
||||||
@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Plugin Info Metabox - .wph-debug
|
|
||||||
*
|
|
||||||
* @since 0.26
|
|
||||||
*/
|
|
||||||
|
|
||||||
use WPHelper\AdminPage;
|
|
||||||
use WPHelper\MetaBox;
|
|
||||||
use WPHelper\PluginCore;
|
|
||||||
use WPHelper\Utility\Singleton;
|
|
||||||
use WPHelper\DatabaseTable;
|
|
||||||
|
|
||||||
if (class_exists(AdminPage::class)){
|
|
||||||
$wph_admin_ref = new ReflectionClass(AdminPage::class);
|
|
||||||
$wph_admin_file = $wph_admin_ref->getFileName();
|
|
||||||
$wph_admin_composer = json_decode(file_get_contents( dirname( dirname( $wph_admin_file ) ) . '/composer.json' )) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists(PluginCore::class)){
|
|
||||||
$wph_pc_ref = new ReflectionClass(PluginCore::class);
|
|
||||||
$wph_pc_file = $wph_pc_ref->getFileName();
|
|
||||||
$wph_pc_composer = json_decode(file_get_contents( dirname( $wph_pc_file ) . '/composer.json' )) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists(MetaBox::class)){
|
|
||||||
$wph_mb_ref = new ReflectionClass(MetaBox::class);
|
|
||||||
$wph_mb_file = $wph_mb_ref->getFileName();
|
|
||||||
$wph_mb_composer = json_decode(file_get_contents( dirname( $wph_mb_file ) . '/composer.json' )) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trait_exists(Singleton::class)){
|
|
||||||
$wph_util_ref = new ReflectionClass(Singleton::class);
|
|
||||||
$wph_util_file = $wph_util_ref->getFileName();
|
|
||||||
$wph_util_composer = json_decode(file_get_contents( dirname( dirname( $wph_util_file ) ) . '/composer.json' )) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists(DatabaseTable::class)){
|
|
||||||
$wph_db_ref = new ReflectionClass(DatabaseTable::class);
|
|
||||||
$wph_db_file = $wph_db_ref->getFileName();
|
|
||||||
$wph_db_composer = json_decode(file_get_contents( dirname( $wph_db_file ) . '/composer.json' )) ;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<style>
|
|
||||||
.inside {
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<?php if ( ! empty( $wph_admin_composer ) ): ?>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
AdminPage: <?php echo $wph_admin_composer->version; ?><br/>
|
|
||||||
Location: <?php echo $wph_admin_file; ?><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ( ! empty( $wph_pc_composer ) ): ?>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
PluginCore: <?php echo $wph_pc_composer->version; ?><br/>
|
|
||||||
Location: <?php echo $wph_pc_file; ?><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ( ! empty( $wph_mb_composer ) ): ?>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
MetaBox: <?php echo $wph_mb_composer->version; ?><br/>
|
|
||||||
Location: <?php echo $wph_mb_file; ?><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ( ! empty( $wph_util_composer ) ): ?>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
Utility: <?php echo $wph_util_composer->version; ?><br/>
|
|
||||||
Location: <?php echo $wph_util_file; ?><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ( ! empty( $wph_db_composer ) ): ?>
|
|
||||||
<hr>
|
|
||||||
<p>
|
|
||||||
DatabaseTable: <?php echo $wph_db_composer->version; ?><br/>
|
|
||||||
Location: <?php echo $wph_db_file; ?><br/>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
</p>
|
|
||||||
@ -3,10 +3,25 @@
|
|||||||
* Plugin Info Metabox
|
* Plugin Info Metabox
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
|
<style>
|
||||||
|
#plugin_info h2 {
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
#plugin_info h3{
|
||||||
|
font-weight: 100;
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div id="plugin_info" class="postbox">
|
<div id="plugin_info" class="postbox">
|
||||||
<h2 style="border-bottom: 1px solid #eee;"><span>Plugin Info</span></h2>
|
<h2><span>Plugin Info</span></h2>
|
||||||
<div class="inside">
|
<div class="inside">
|
||||||
<?php include __DIR__ . '/plugin_info_meta_box-inside.php'; ?>
|
<h3><?=$plugin_data['Name'] ?></h3>
|
||||||
|
<p>
|
||||||
|
Version: <?= $plugin_data['Version'] ?><br/>
|
||||||
|
Author: <a href="<?= $plugin_data['AuthorURI'] ?>"><?= $plugin_data['Author'] ?></a><br/>
|
||||||
|
GitHub: <a href="<?= $plugin_data['PluginURI'] ?>"><?= $plugin_data['TextDomain'] ?></a><br/>
|
||||||
|
<?php if ( ! empty( $update_message ) ): ?>Last Updated: <?= $update_message ?><?php endif; ?>
|
||||||
|
</p>
|
||||||
</div><!-- .inside -->
|
</div><!-- .inside -->
|
||||||
|
|
||||||
</div><!-- .postbox -->
|
</div><!-- .postbox -->
|
||||||
@ -7,9 +7,8 @@
|
|||||||
?>
|
?>
|
||||||
<form method="post" action="options.php">
|
<form method="post" action="options.php">
|
||||||
<?php
|
<?php
|
||||||
/** @var WPHelper\AdminPage $this */
|
|
||||||
settings_fields( $this->settings_page->option_group );// Print hidden setting fields
|
settings_fields( $this->settings_page->option_group );// Print hidden setting fields
|
||||||
do_settings_sections( $this->settings_page->page );// Print title, info callback and form-table
|
do_settings_sections( $this->get_slug() );// Print title, info callback and form-table
|
||||||
submit_button();
|
submit_button();
|
||||||
?>
|
?>
|
||||||
</form>
|
</form>
|
||||||
@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Bootstrap WordPress core meta-boxes to generate metaboxes
|
|
||||||
*
|
|
||||||
* @var WPHelper\AdminPage $this
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<style>
|
|
||||||
/*
|
|
||||||
we don't actually have draggable/movable metaboxes
|
|
||||||
.hide-if-no-js / hidden classes would help
|
|
||||||
*/
|
|
||||||
.handle-actions {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.postbox .postbox-header .hndle {
|
|
||||||
cursor: unset;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Allow meta-boxes to hook to this page ('side' context).
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
do_action('add_meta_boxes', $this->get_hook_suffix(), 'side' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove 'Featured Image' meta-box added by core.
|
|
||||||
*
|
|
||||||
* @see register_and_do_post_meta_boxes() (wp-admin/includes/meta-boxes.php)
|
|
||||||
* @todo Investigate why $thumbnail_support returns true for our pages.
|
|
||||||
*/
|
|
||||||
remove_meta_box( 'postimagediv', $this->get_hook_suffix(), 'side' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render meta-boxes
|
|
||||||
*
|
|
||||||
* Renders div.meta-box-sortables
|
|
||||||
*/
|
|
||||||
do_meta_boxes( $this->get_hook_suffix(), 'side', null );
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Template - Tabs navigation row
|
|
||||||
*
|
|
||||||
* Print tabs navigation row.
|
|
||||||
*
|
|
||||||
* @var WPHelper\AdminPage $this
|
|
||||||
*/
|
|
||||||
do_action( "wphelper/adminpage/tab_nav/{$this->tab_group}" );
|
|
||||||
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Print tabs navigation row.
|
* Print tabs navigation row.
|
||||||
*
|
*
|
||||||
* @var CMB2_Options_Hookup $hookup
|
* @var CMB2_Options_Hook $hookup
|
||||||
*/
|
*/
|
||||||
if ( ! isset( $hookup ) ){
|
if ( ! isset( $hookup ) ){
|
||||||
return;
|
return;
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Template for CMB2 Options Page
|
|
||||||
*
|
|
||||||
* @var WPHelper\CMB2_OptionsPage $this
|
|
||||||
* @var CMB2_Options_Hookup $hookup
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
<div class="wrap cmb2-options-page option-<?php echo esc_attr( sanitize_html_class( $hookup->option_key ) ); ?>">
|
|
||||||
<?php include 'title-cmb2.php' ?>
|
|
||||||
<?php include 'tab-nav-cmb2.php' ?>
|
|
||||||
<?php include 'form-cmb2.php' ?>
|
|
||||||
</div>
|
|
||||||
@ -3,12 +3,12 @@
|
|||||||
* Template for CMB2 Options Page
|
* Template for CMB2 Options Page
|
||||||
*
|
*
|
||||||
* @var string $ob_content - Render template or callback
|
* @var string $ob_content - Render template or callback
|
||||||
* @var WPHelper\AdminPage $this
|
* @var AdminPage $this
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?= get_admin_page_title() ?></h1>
|
<h1><?= get_admin_page_title() ?></h1>
|
||||||
<?php include 'tab-nav-simple.php' ?>
|
<?php include 'tab-nav.php' ?>
|
||||||
<div id="poststuff">
|
<div id="poststuff">
|
||||||
<div id="post-body" class="metabox-holder columns-2">
|
<div id="post-body" class="metabox-holder columns-2">
|
||||||
|
|
||||||
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
<!-- sidebar -->
|
<!-- sidebar -->
|
||||||
<div id="postbox-container-1" class="postbox-container">
|
<div id="postbox-container-1" class="postbox-container">
|
||||||
<?php include 'sidebar-add-meta-boxes.php'; ?>
|
<div class="meta-box-sortables">
|
||||||
|
<?php do_action("wphelper/adminpage/plugin_info_box/{$this->get_slug()}"); ?>
|
||||||
|
</div><!-- .meta-box-sortables -->
|
||||||
</div><!-- #postbox-container-1 .postbox-container -->
|
</div><!-- #postbox-container-1 .postbox-container -->
|
||||||
</div><!-- #post-body -->
|
</div><!-- #post-body -->
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Simple wrap
|
* Simple wrap
|
||||||
*
|
|
||||||
* @var string $ob_content - Render template or callback
|
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?= get_admin_page_title() ?></h1>
|
<h1><?= get_admin_page_title() ?></h1>
|
||||||
<?php include 'tab-nav-simple.php' ?>
|
<?php include 'tab-nav.php' ?>
|
||||||
<?php echo $ob_content; ?>
|
<?php echo $ob_content; ?>
|
||||||
</div>
|
</div>
|
||||||
@ -1,38 +0,0 @@
|
|||||||
# Create Github Release
|
|
||||||
# v1.0
|
|
||||||
# Create Github release on tag push
|
|
||||||
# - Use tag name as release title
|
|
||||||
# - Use CHANGELOG.md log entry as body
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
# Sequence of patterns matched against refs/tags
|
|
||||||
tags:
|
|
||||||
- '*' # Match any tag
|
|
||||||
|
|
||||||
name: Create Release
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Create Release
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Get Changelog Entry
|
|
||||||
id: changelog_reader
|
|
||||||
uses: mindsers/changelog-reader-action@v1.1.0
|
|
||||||
with:
|
|
||||||
version: ${{ github.ref }}
|
|
||||||
path: ./CHANGELOG.md
|
|
||||||
- name: Create Release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref }}
|
|
||||||
release_name: ${{ github.ref }}
|
|
||||||
body: ${{ steps.changelog_reader.outputs.log_entry }} # This pulls from the GET CHANGELOG ENTRY step above, referencing it's ID to get its outputs object, which include a `log_entry`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
26
vendor/abuyoyo/metabox/CHANGELOG.md
vendored
26
vendor/abuyoyo/metabox/CHANGELOG.md
vendored
@ -1,26 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
WPHelper\MetaBox
|
|
||||||
|
|
||||||
## 0.8
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Fix `Metabox::render()` callback arguments. Callback is passed `$data_object` and `$box`.
|
|
||||||
|
|
||||||
## 0.7
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Validate `is_callable(render_cb)` before `call_user_func` call.
|
|
||||||
|
|
||||||
## 0.6
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Accept callable `render_cb` as well as readable `render_tpl` as render template.
|
|
||||||
|
|
||||||
## 0.5
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Basic Metabox API.
|
|
||||||
220
vendor/abuyoyo/metabox/MetaBox.php
vendored
220
vendor/abuyoyo/metabox/MetaBox.php
vendored
@ -1,220 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace WPHelper;
|
|
||||||
|
|
||||||
use function wp_parse_args;
|
|
||||||
use function add_action;
|
|
||||||
use function add_meta_box;
|
|
||||||
/**
|
|
||||||
* MetaBox
|
|
||||||
*
|
|
||||||
* Object-Oriented WordPress meta box creator.
|
|
||||||
*
|
|
||||||
* @author abuyoyo
|
|
||||||
* @version 0.8
|
|
||||||
*/
|
|
||||||
class MetaBox
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Screen context where the meta box should display.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ID of the meta box.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The display priority of the meta box.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $priority;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Screens where this meta box will appear.
|
|
||||||
*
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
private $screens;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path to the template used to display the content of the meta box.
|
|
||||||
*
|
|
||||||
* @var string filename
|
|
||||||
*/
|
|
||||||
private $render_tpl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path to the template used to display the content of the meta box.
|
|
||||||
*
|
|
||||||
* @var callable
|
|
||||||
*/
|
|
||||||
private $render_cb;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The title of the meta box.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $title;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook where this meta box will be added.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $hook;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Array of $args to be sent to callback function's second parameter
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $args;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param string $id
|
|
||||||
* @param string $template
|
|
||||||
* @param string $title
|
|
||||||
* @param string $context
|
|
||||||
* @param string $priority
|
|
||||||
* @param string[] $screens
|
|
||||||
*/
|
|
||||||
public function __construct($options)
|
|
||||||
{
|
|
||||||
// should throw error if required fields (id, title) not given
|
|
||||||
// template is actually optional
|
|
||||||
|
|
||||||
$defaults = [
|
|
||||||
'context' => 'advanced',
|
|
||||||
'priority' => 'default',
|
|
||||||
'screens' => [],
|
|
||||||
'args' => null,
|
|
||||||
'hook' => 'add_meta_boxes',
|
|
||||||
];
|
|
||||||
|
|
||||||
$options = wp_parse_args( $options, $defaults );
|
|
||||||
extract($options);
|
|
||||||
|
|
||||||
$this->context = $context;
|
|
||||||
$this->id = $id;
|
|
||||||
$this->priority = $priority;
|
|
||||||
$this->screens = $screens;
|
|
||||||
$this->render_tpl = isset( $template ) ? rtrim( $template, '/' ) : '';
|
|
||||||
$this->render_cb = $render ?? '';
|
|
||||||
$this->title = $title;
|
|
||||||
$this->hook = $hook;
|
|
||||||
$this->args = $args;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add metabox at given hook.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function add()
|
|
||||||
{
|
|
||||||
add_action( $this->hook, [ $this, 'wp_add_metabox' ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function wp_add_metabox(){
|
|
||||||
add_meta_box(
|
|
||||||
$this->id,
|
|
||||||
$this->title,
|
|
||||||
[ $this, 'render' ], // $this->render_tpl | $this->render_cb
|
|
||||||
$this->screens,
|
|
||||||
$this->context,
|
|
||||||
$this->priority,
|
|
||||||
$this->args
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the callable that will render the content of the meta box.
|
|
||||||
*
|
|
||||||
* @return callable
|
|
||||||
*/
|
|
||||||
public function get_callback()
|
|
||||||
{
|
|
||||||
return [ $this, 'render' ];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the screen context where the meta box should display.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_context()
|
|
||||||
{
|
|
||||||
return $this->context;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ID of the meta box.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_id()
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the display priority of the meta box.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_priority()
|
|
||||||
{
|
|
||||||
return $this->priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the screen(s) where the meta box will appear.
|
|
||||||
*
|
|
||||||
* @return array|string|WP_Screen
|
|
||||||
*/
|
|
||||||
public function get_screens()
|
|
||||||
{
|
|
||||||
return $this->screens;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the title of the meta box.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_title()
|
|
||||||
{
|
|
||||||
return $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the content of the meta box using a PHP template.
|
|
||||||
* Callback passed to to add_meta_box()
|
|
||||||
*
|
|
||||||
* @see do_meta_boxes()
|
|
||||||
*
|
|
||||||
* @param mixed $data_object Object that's the focus of the current screen. eg. WP_Post|WP_Comment
|
|
||||||
* @param array $box Meta-box data [id, title, callback, args] (@see global $wp_meta_boxes)
|
|
||||||
*/
|
|
||||||
public function render( $data_object, $box )
|
|
||||||
{
|
|
||||||
if ( ! is_readable( $this->render_tpl ) && ! is_callable( $this->render_cb ) ){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( is_callable( $this->render_cb ) ){
|
|
||||||
call_user_func( $this->render_cb, $data_object, $box );
|
|
||||||
} else if ( isset( $this->render_tpl ) ){
|
|
||||||
include $this->render_tpl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
vendor/abuyoyo/metabox/README.md
vendored
1
vendor/abuyoyo/metabox/README.md
vendored
@ -1 +0,0 @@
|
|||||||
# WPHelper\MetaBox
|
|
||||||
12
vendor/abuyoyo/metabox/composer.json
vendored
12
vendor/abuyoyo/metabox/composer.json
vendored
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "abuyoyo/metabox",
|
|
||||||
"description": "WordPress metabox helper class",
|
|
||||||
"type": "library",
|
|
||||||
"version": "0.8",
|
|
||||||
"license": "BSD-3-Clause",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"WPHelper\\" : ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
36
vendor/abuyoyo/plugincore/CHANGELOG.md
vendored
36
vendor/abuyoyo/plugincore/CHANGELOG.md
vendored
@ -1,41 +1,5 @@
|
|||||||
# WPHelper\PluginCore Changelog
|
# WPHelper\PluginCore Changelog
|
||||||
|
|
||||||
## 0.27
|
|
||||||
Release Date: Oct 3, 2023
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Support Plugin Update Checker v5 as well as v4. Create class alias `WPHelper\PucFactory` for `YahnisElsts\PluginUpdateChecker\v5\PucFactory` if available. Fallback to `Puc_v4_Factory`.
|
|
||||||
|
|
||||||
## 0.26
|
|
||||||
Release Date: Jun 9, 2023
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix passing PluginCore instance to AdminPage constructor in `admin_page()` method.
|
|
||||||
|
|
||||||
## 0.25
|
|
||||||
Release Date: Feb 3, 2023
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Property `token` and method `token`. Lowercase underscore token to be used as variable name.
|
|
||||||
|
|
||||||
## 0.24
|
|
||||||
Release Date: Jan 13, 2023
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Static `get_by_file` method. Get PluginCore instance by plugin filename.
|
|
||||||
|
|
||||||
## 0.23
|
|
||||||
Release Date: Aug 8, 2022
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Minor fixes.
|
|
||||||
|
|
||||||
## 0.22
|
|
||||||
Release Date: Aug 8, 2022
|
|
||||||
|
|
||||||
### Removed
|
|
||||||
- Remove all dependencies. No require.
|
|
||||||
|
|
||||||
## 0.21
|
## 0.21
|
||||||
Release Date: Aug 5, 2022
|
Release Date: Aug 5, 2022
|
||||||
|
|
||||||
|
|||||||
158
vendor/abuyoyo/plugincore/PluginCore.php
vendored
158
vendor/abuyoyo/plugincore/PluginCore.php
vendored
@ -1,23 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace WPHelper;
|
namespace WPHelper;
|
||||||
|
|
||||||
|
use Puc_v4_Factory;
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||||
|
|
||||||
if ( ! class_exists( 'WPHelper/PluginCore' ) ):
|
if( ! function_exists('get_plugin_data') ) {
|
||||||
|
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||||
// require dependency get_plugin_data()
|
|
||||||
if( ! function_exists( 'get_plugin_data' ) ) {
|
|
||||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! class_exists( 'WPHelper/PluginCore' ) ):
|
||||||
/**
|
/**
|
||||||
* PluginCore
|
* PluginCore
|
||||||
*
|
*
|
||||||
* Helper Class for creating WordPress Plugins
|
* Helper Class for creating WordPress Plugins
|
||||||
*
|
*
|
||||||
|
* Defines PLUGIN_PATH, PLUGIN_URL (etc.) constants
|
||||||
* (@see README.md)
|
* (@see README.md)
|
||||||
*
|
*
|
||||||
* @version 0.27
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
class PluginCore {
|
class PluginCore {
|
||||||
|
|
||||||
@ -41,11 +42,6 @@ class PluginCore {
|
|||||||
*/
|
*/
|
||||||
private $const;
|
private $const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $token;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -61,11 +57,6 @@ class PluginCore {
|
|||||||
*/
|
*/
|
||||||
private $plugin_basename;
|
private $plugin_basename;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array plugin header metadata
|
|
||||||
*/
|
|
||||||
private $plugin_data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var callable
|
* @var callable
|
||||||
*/
|
*/
|
||||||
@ -116,20 +107,19 @@ class PluginCore {
|
|||||||
*/
|
*/
|
||||||
private $update_branch;
|
private $update_branch;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static array of all PluginCore instances
|
* Static array of all PluginCore instances
|
||||||
* Used in PluginCore::get($slug)
|
* Used in PluginCore::get($slug)
|
||||||
*
|
*
|
||||||
* @var array[PluginCore] Instances of PluginCore
|
* @var array[PluginCore] Instances of PluginCore
|
||||||
*/
|
*/
|
||||||
private static $cores = [];
|
static $cores = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve instance of PluginCore by plugin slug.
|
* Retrieve instance of PluginCore by plugin slug.
|
||||||
*
|
*
|
||||||
* @since 0.5
|
|
||||||
*
|
|
||||||
* @param string $slug - Plugin slug
|
* @param string $slug - Plugin slug
|
||||||
* @return PluginCore - Instance of specific plugin.
|
* @return PluginCore - Instance of specific plugin.
|
||||||
*/
|
*/
|
||||||
@ -137,29 +127,6 @@ class PluginCore {
|
|||||||
return self::$cores[ $slug ] ?? null;
|
return self::$cores[ $slug ] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve instance of PluginCore by plugin __FILE__.
|
|
||||||
*
|
|
||||||
* @since 0.24
|
|
||||||
*
|
|
||||||
* @param string $filename - Plugin filename
|
|
||||||
* @return PluginCore - Instance of specific plugin.
|
|
||||||
*/
|
|
||||||
static public function get_by_file( $filename ) {
|
|
||||||
return current(
|
|
||||||
array_filter(
|
|
||||||
self::$cores,
|
|
||||||
fn($core) => $core->file() == $filename
|
|
||||||
)
|
|
||||||
) ?: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @since 0.1
|
|
||||||
* @since 0.2 Accept filename as first param and options array as optional param
|
|
||||||
*/
|
|
||||||
function __construct( $plugin_file, $options = null ) {
|
function __construct( $plugin_file, $options = null ) {
|
||||||
|
|
||||||
$this->plugin_file( $plugin_file );
|
$this->plugin_file( $plugin_file );
|
||||||
@ -174,8 +141,6 @@ class PluginCore {
|
|||||||
|
|
||||||
$this->const( $options->const ?? null ); // fallback: generate const from slug
|
$this->const( $options->const ?? null ); // fallback: generate const from slug
|
||||||
|
|
||||||
$this->token( $options->token ?? null ); // fallback: generate token from slug
|
|
||||||
|
|
||||||
if ( isset( $options->activate_cb ) )
|
if ( isset( $options->activate_cb ) )
|
||||||
$this->activate_cb( $options->activate_cb );
|
$this->activate_cb( $options->activate_cb );
|
||||||
|
|
||||||
@ -212,9 +177,6 @@ class PluginCore {
|
|||||||
* Register activation, deactivation, uninstall, upgrade hooks.
|
* Register activation, deactivation, uninstall, upgrade hooks.
|
||||||
* Init PUC update checker.
|
* Init PUC update checker.
|
||||||
*
|
*
|
||||||
* @since 0.1 setup()
|
|
||||||
* @since 0.21 bootstrap()
|
|
||||||
*
|
|
||||||
* @todo set plugin_dir_path, plugin_basename as accessible public variables (available thru methods atm)
|
* @todo set plugin_dir_path, plugin_basename as accessible public variables (available thru methods atm)
|
||||||
*/
|
*/
|
||||||
private function bootstrap() {
|
private function bootstrap() {
|
||||||
@ -254,11 +216,6 @@ class PluginCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register activation/deactivation/uninstall/upgrade hooks
|
|
||||||
*
|
|
||||||
* @since 0.5
|
|
||||||
*/
|
|
||||||
private function register_hooks() {
|
private function register_hooks() {
|
||||||
|
|
||||||
if ( ! empty( $this->activate_cb ) ) // && is_callable() ?
|
if ( ! empty( $this->activate_cb ) ) // && is_callable() ?
|
||||||
@ -279,8 +236,6 @@ class PluginCore {
|
|||||||
* Plugin title.
|
* Plugin title.
|
||||||
* If none provided - plugin header Title will be used.
|
* If none provided - plugin header Title will be used.
|
||||||
*
|
*
|
||||||
* @since 0.1
|
|
||||||
*
|
|
||||||
* @param string|null $title
|
* @param string|null $title
|
||||||
* @return string $this->title
|
* @return string $this->title
|
||||||
*/
|
*/
|
||||||
@ -291,8 +246,6 @@ class PluginCore {
|
|||||||
/**
|
/**
|
||||||
* Wrapper function for $this->title()
|
* Wrapper function for $this->title()
|
||||||
*
|
*
|
||||||
* @since 0.6
|
|
||||||
*
|
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function name( $title = null ) {
|
public function name( $title = null ) {
|
||||||
@ -305,8 +258,6 @@ class PluginCore {
|
|||||||
* Plugin slug.
|
* Plugin slug.
|
||||||
* If none provided - plugin file basename will be used
|
* If none provided - plugin file basename will be used
|
||||||
*
|
*
|
||||||
* @since 0.1
|
|
||||||
*
|
|
||||||
* @param string|null $slug
|
* @param string|null $slug
|
||||||
* @return string $this->slug
|
* @return string $this->slug
|
||||||
*/
|
*/
|
||||||
@ -318,8 +269,6 @@ class PluginCore {
|
|||||||
* Setter - plugin_file (also Getter - kinda)
|
* Setter - plugin_file (also Getter - kinda)
|
||||||
* Plugin file fully qualified path.
|
* Plugin file fully qualified path.
|
||||||
*
|
*
|
||||||
* @since 0.1
|
|
||||||
*
|
|
||||||
* @param string $plugin_file - Path to plugin file
|
* @param string $plugin_file - Path to plugin file
|
||||||
* @return string $this->plugin_file
|
* @return string $this->plugin_file
|
||||||
*/
|
*/
|
||||||
@ -332,8 +281,6 @@ class PluginCore {
|
|||||||
* Might have to rethink this
|
* Might have to rethink this
|
||||||
* used by test-plugin update_checker
|
* used by test-plugin update_checker
|
||||||
*
|
*
|
||||||
* @since 0.7
|
|
||||||
*
|
|
||||||
* @todo revisit this
|
* @todo revisit this
|
||||||
*/
|
*/
|
||||||
public function file() {
|
public function file() {
|
||||||
@ -343,11 +290,9 @@ class PluginCore {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter/Setter - plugin data array
|
* Getter/Setter - plugin data array
|
||||||
*
|
|
||||||
* @since 0.14
|
|
||||||
*/
|
*/
|
||||||
public function plugin_data() {
|
public function plugin_data() {
|
||||||
return $this->plugin_data ??= get_plugin_data( $this->plugin_file, false ); // false = no markup (i think)
|
return $this->plugin_data ??= get_plugin_data( $this->plugin_file, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -355,8 +300,6 @@ class PluginCore {
|
|||||||
* Prefix of plugin specific defines (PLUGIN_NAME_PATH etc.)
|
* Prefix of plugin specific defines (PLUGIN_NAME_PATH etc.)
|
||||||
* If not provided - plugin slug will be uppercase.
|
* If not provided - plugin slug will be uppercase.
|
||||||
*
|
*
|
||||||
* @since 0.4
|
|
||||||
*
|
|
||||||
* @param string|null $const (string should be uppercase)
|
* @param string|null $const (string should be uppercase)
|
||||||
* @return string $this->const
|
* @return string $this->const
|
||||||
*/
|
*/
|
||||||
@ -364,23 +307,8 @@ class PluginCore {
|
|||||||
return $this->const ??= $const ?: str_replace( '-', '_' , strtoupper( $this->slug() ) );
|
return $this->const ??= $const ?: str_replace( '-', '_' , strtoupper( $this->slug() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter/Setter - token
|
|
||||||
* Create a single-token slug (convert to underscore + lowercase).
|
|
||||||
*
|
|
||||||
* @since 0.25
|
|
||||||
*
|
|
||||||
* @param string|null $token (string will be normalized)
|
|
||||||
* @return string $this->token
|
|
||||||
*/
|
|
||||||
public function token( $token = null ) {
|
|
||||||
return $this->token ??= str_replace( '-', '_' , strtolower( $token ?: $this->slug() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter/setter
|
* Getter/setter
|
||||||
*
|
|
||||||
* @since 0.6
|
|
||||||
*/
|
*/
|
||||||
public function path() {
|
public function path() {
|
||||||
return $this->path ??= plugin_dir_path( $this->plugin_file );
|
return $this->path ??= plugin_dir_path( $this->plugin_file );
|
||||||
@ -388,8 +316,6 @@ class PluginCore {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter/Setter
|
* Getter/Setter
|
||||||
*
|
|
||||||
* @since 0.6
|
|
||||||
*/
|
*/
|
||||||
public function url() {
|
public function url() {
|
||||||
return $this->url ??= plugin_dir_url( $this->plugin_file );
|
return $this->url ??= plugin_dir_url( $this->plugin_file );
|
||||||
@ -397,8 +323,6 @@ class PluginCore {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter/Setter
|
* Getter/Setter
|
||||||
*
|
|
||||||
* @since 0.12
|
|
||||||
*/
|
*/
|
||||||
public function plugin_basename() {
|
public function plugin_basename() {
|
||||||
return $this->plugin_basename ??= plugin_basename( $this->plugin_file );
|
return $this->plugin_basename ??= plugin_basename( $this->plugin_file );
|
||||||
@ -409,8 +333,6 @@ class PluginCore {
|
|||||||
* Callback runs on 'register_activation_hook'
|
* Callback runs on 'register_activation_hook'
|
||||||
* PluginCore does not validate. Authors must ensure valid callback.
|
* PluginCore does not validate. Authors must ensure valid callback.
|
||||||
*
|
*
|
||||||
* @since 0.4
|
|
||||||
*
|
|
||||||
* @param callable $activate_cb - Activation callback
|
* @param callable $activate_cb - Activation callback
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
@ -424,8 +346,6 @@ class PluginCore {
|
|||||||
* Callback runs on 'register_deactivation_hook'
|
* Callback runs on 'register_deactivation_hook'
|
||||||
* PluginCore does not validate. Authors must ensure valid callback.
|
* PluginCore does not validate. Authors must ensure valid callback.
|
||||||
*
|
*
|
||||||
* @since 0.4
|
|
||||||
*
|
|
||||||
* @param callable $deactivate_cb - Deactivation callback.
|
* @param callable $deactivate_cb - Deactivation callback.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
@ -439,8 +359,6 @@ class PluginCore {
|
|||||||
* Callback runs on 'register_uninstall_hook'
|
* Callback runs on 'register_uninstall_hook'
|
||||||
* PluginCore does not validate. Authors must ensure valid callback.
|
* PluginCore does not validate. Authors must ensure valid callback.
|
||||||
*
|
*
|
||||||
* @since 0.4
|
|
||||||
*
|
|
||||||
* @param callable $uninstall_cb - Uninstall callback.
|
* @param callable $uninstall_cb - Uninstall callback.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
@ -457,8 +375,6 @@ class PluginCore {
|
|||||||
*
|
*
|
||||||
* PluginCore does not validate. Authors must ensure valid callback.
|
* PluginCore does not validate. Authors must ensure valid callback.
|
||||||
*
|
*
|
||||||
* @since 0.11
|
|
||||||
*
|
|
||||||
* @param callable $upgrade_cb - Upgrade callback.
|
* @param callable $upgrade_cb - Upgrade callback.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
@ -493,25 +409,24 @@ class PluginCore {
|
|||||||
*
|
*
|
||||||
* Construct AdminPage instance for plugin.
|
* Construct AdminPage instance for plugin.
|
||||||
*
|
*
|
||||||
* @since 0.14
|
|
||||||
* @since 0.17 - Pass instance of PluginCore to AdminPage (~0.14)
|
|
||||||
*
|
|
||||||
* @param array $admin_page - AdminPage settings array
|
* @param array $admin_page - AdminPage settings array
|
||||||
|
*
|
||||||
* @return AdminPage
|
* @return AdminPage
|
||||||
*/
|
*/
|
||||||
public function admin_page( $admin_page ) {
|
public function admin_page( $admin_page ) {
|
||||||
|
|
||||||
if ( ! class_exists( AdminPage::class ) )
|
if ( ! class_exists( 'WPHelper\AdminPage' ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! isset( $this->admin_page ) ){
|
// validate
|
||||||
|
$admin_page['slug'] ??= $this->slug();
|
||||||
|
$admin_page['title'] ??= $this->title();
|
||||||
|
|
||||||
// validate
|
$this->admin_page = new AdminPage( $admin_page );
|
||||||
$admin_page['slug'] ??= $this->slug();
|
|
||||||
$admin_page['title'] ??= $this->title();
|
|
||||||
$admin_page['plugin_core'] ??= $this;
|
|
||||||
|
|
||||||
$this->admin_page = new AdminPage( $admin_page );
|
// validate for older versions of AdminPage
|
||||||
|
if ( method_exists( $this->admin_page, 'plugin_core' ) ) {
|
||||||
|
$this->admin_page->plugin_core( $this ); // back-reference
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->admin_page;
|
return $this->admin_page;
|
||||||
@ -520,15 +435,13 @@ class PluginCore {
|
|||||||
/**
|
/**
|
||||||
* Setter
|
* Setter
|
||||||
*
|
*
|
||||||
* Setup info used by PucFactory
|
* Setup info used by Puc_v4_Factory
|
||||||
*
|
*
|
||||||
* set $update_checker (bool)
|
* set $update_checker (bool)
|
||||||
* set $update_repo_uri (string)
|
* set $update_repo_uri (string)
|
||||||
* set $update_auth (optional)
|
* set $update_auth (optional)
|
||||||
* set $update_branch (optional)
|
* set $update_branch (optional)
|
||||||
*
|
*
|
||||||
* @since 0.9
|
|
||||||
*
|
|
||||||
* @param bool|string|array $update_checker
|
* @param bool|string|array $update_checker
|
||||||
*/
|
*/
|
||||||
private function update_checker( $update_checker ) {
|
private function update_checker( $update_checker ) {
|
||||||
@ -577,35 +490,14 @@ class PluginCore {
|
|||||||
/**
|
/**
|
||||||
* Init Puc update checker instance
|
* Init Puc update checker instance
|
||||||
*
|
*
|
||||||
* @since 0.9 init_update_checker()
|
* @uses Puc_v4_Factory::buildUpdateChecker
|
||||||
* @since 0.21 build_update_checker()
|
|
||||||
* @since 0.27 Create class alias WPHelper\PucFactory - support plugin-update-checker v4 & v5
|
|
||||||
*
|
|
||||||
* @uses PucFactory::buildUpdateChecker
|
|
||||||
*/
|
*/
|
||||||
private function build_update_checker() {
|
private function build_update_checker() {
|
||||||
|
|
||||||
/**
|
if ( ! class_exists('Puc_v4_Factory') )
|
||||||
* Create class alias WPHelper\PucFactory
|
|
||||||
* Support YahnisElsts\PluginUpdateChecker v4 | v5
|
|
||||||
*
|
|
||||||
* @since 0.27
|
|
||||||
*/
|
|
||||||
if ( ! class_exists( 'WPHelper\PucFactory' ) ) {
|
|
||||||
if ( class_exists( 'YahnisElsts\PluginUpdateChecker\v5\PucFactory' ) ) {
|
|
||||||
$actual_puc = 'YahnisElsts\PluginUpdateChecker\v5\PucFactory';
|
|
||||||
} else if ( class_exists( 'Puc_v4_Factory' ) ) {
|
|
||||||
$actual_puc = 'Puc_v4_Factory';
|
|
||||||
}
|
|
||||||
if ( ! empty( $actual_puc ) ) {
|
|
||||||
class_alias( $actual_puc, 'WPHelper\PucFactory' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! class_exists( 'WPHelper\PucFactory' ) )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$update_checker = PucFactory::buildUpdateChecker(
|
$update_checker = Puc_v4_Factory::buildUpdateChecker(
|
||||||
$this->update_repo_uri,
|
$this->update_repo_uri,
|
||||||
$this->plugin_file,
|
$this->plugin_file,
|
||||||
$this->slug() // using slug()
|
$this->slug() // using slug()
|
||||||
@ -628,8 +520,6 @@ class PluginCore {
|
|||||||
* This function called on upgrader_process_complete
|
* This function called on upgrader_process_complete
|
||||||
* sanity-checks if our plugin was upgraded
|
* sanity-checks if our plugin was upgraded
|
||||||
* if so - calls upgrade_cb provided by our plugin
|
* if so - calls upgrade_cb provided by our plugin
|
||||||
*
|
|
||||||
* @since 0.12
|
|
||||||
*/
|
*/
|
||||||
public function upgrade_cb_wrapper( $upgrader_object, $options ) {
|
public function upgrade_cb_wrapper( $upgrader_object, $options ) {
|
||||||
if(
|
if(
|
||||||
|
|||||||
10
vendor/abuyoyo/plugincore/composer.json
vendored
10
vendor/abuyoyo/plugincore/composer.json
vendored
@ -2,12 +2,12 @@
|
|||||||
"name": "abuyoyo/plugincore",
|
"name": "abuyoyo/plugincore",
|
||||||
"description": "WordPress plugin core helper class",
|
"description": "WordPress plugin core helper class",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"version": "0.27",
|
"version": "0.21",
|
||||||
"time": "2022-10-03",
|
"time": "2022-08-05",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"suggest": {
|
"require": {
|
||||||
"yahnis-elsts/plugin-update-checker": "~5.2",
|
"yahnis-elsts/plugin-update-checker": "~4.12",
|
||||||
"abuyoyo/adminmenupage": "~0.27"
|
"abuyoyo/adminmenupage": "~0.20"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
10
vendor/abuyoyo/screen-meta-links/CHANGELOG.md
vendored
10
vendor/abuyoyo/screen-meta-links/CHANGELOG.md
vendored
@ -2,16 +2,6 @@
|
|||||||
|
|
||||||
API for adding custom `screen-meta-links` links and panels alongside the 'Screen Options' and 'Help' links on the WordPress admin page.
|
API for adding custom `screen-meta-links` links and panels alongside the 'Screen Options' and 'Help' links on the WordPress admin page.
|
||||||
|
|
||||||
## [0.13](https://github.com/abuyoyo/screen-meta-links/releases/tag/0.13)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix PHP 8.2 depreacted: Optional parameter declared before required parameter.
|
|
||||||
|
|
||||||
## [0.12](https://github.com/abuyoyo/screen-meta-links/releases/tag/0.12)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix PHP notice: Constant already defined.
|
|
||||||
|
|
||||||
## [0.11](https://github.com/abuyoyo/screen-meta-links/releases/tag/0.11)
|
## [0.11](https://github.com/abuyoyo/screen-meta-links/releases/tag/0.11)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Plugin Name: abuyoyo / Screen Meta Links
|
* Plugin Name: abuyoyo / Screen Meta Links
|
||||||
* Description: API for adding custom screen-meta-links alongside the "Screen Options" and "Help" links.
|
* Description: API for adding custom screen-meta-links alongside the "Screen Options" and "Help" links.
|
||||||
* Version: 0.13
|
* Version: 0.11
|
||||||
* Author: abuyoyo
|
* Author: abuyoyo
|
||||||
* Author URI: https://github.com/abuyoyo
|
* Author URI: https://github.com/abuyoyo
|
||||||
* Plugin URI: https://github.com/abuyoyo/screen-meta-links
|
* Plugin URI: https://github.com/abuyoyo/screen-meta-links
|
||||||
@ -16,9 +16,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
! defined( 'SML_FILE' ) && define ( 'SML_FILE', __FILE__ );
|
if ( ! defined( 'SML_FILE' ) ) define ( 'SML_FILE', __FILE__ );
|
||||||
! defined( 'SML_URL' ) && define ( 'SML_URL' , plugin_dir_url( __FILE__ ) );
|
if ( ! defined( 'SML_URL' ) ) define ( 'SML_URL', plugin_dir_url( __FILE__ ) );
|
||||||
! defined( 'SML_PATH' ) && define ( 'SML_PATH', plugin_dir_path( __FILE__ ) );
|
if ( ! defined( 'SML_PATH' ) ) define ( 'SML_PATH', plugin_dir_path( __FILE__ ) );
|
||||||
|
|
||||||
if ( ! class_exists('Screen_Meta_Links') ):
|
if ( ! class_exists('Screen_Meta_Links') ):
|
||||||
|
|
||||||
@ -352,15 +352,14 @@ if ( ! function_exists( 'wph_add_screen_meta_panel' ) ):
|
|||||||
* @param string $id - Link ID. Should be unique and a valid value for a HTML ID attribute.
|
* @param string $id - Link ID. Should be unique and a valid value for a HTML ID attribute.
|
||||||
* @param string $text - Link text.
|
* @param string $text - Link text.
|
||||||
* @param string $href - Optional. Link URL to be used if no panel is provided
|
* @param string $href - Optional. Link URL to be used if no panel is provided
|
||||||
* @param string|array $page - Optional. The page(s) where you want to add the link. Accepts wildcard '*'. If left empty will not add to any page.
|
* @param string|array $page - The page(s) where you want to add the link.
|
||||||
* @param array $attributes - Optional. Additional attributes for the link tag. Add 'aria-controls' => "{$id}-wrap" to toggle panel
|
* @param array $attributes - Optional. Additional attributes for the link tag. Add 'aria-controls' => "{$id}-wrap" to toggle panel
|
||||||
* @param callback $panel - Optional. Callback should print out screen-meta panel contents
|
* @param callback $panel - Optional. Callback should print out screen-meta panel contents
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @todo Remove $href parameter and functionailty
|
* @todo Remove $href parameter and functionailty
|
||||||
* @todo $page should not be optional. We need to remove $href first.
|
|
||||||
*/
|
*/
|
||||||
function wph_add_screen_meta_panel( $id, $text, $href = '', $page = '', $attributes = null, $panel = '' ){
|
function wph_add_screen_meta_panel($id, $text, $href = '', $page, $attributes = null, $panel=''){
|
||||||
|
|
||||||
static $sml_instance = null;
|
static $sml_instance = null;
|
||||||
if ( null === $sml_instance){
|
if ( null === $sml_instance){
|
||||||
|
|||||||
20
vendor/autoload.php
vendored
20
vendor/autoload.php
vendored
@ -2,24 +2,6 @@
|
|||||||
|
|
||||||
// autoload.php @generated by Composer
|
// autoload.php @generated by Composer
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50600) {
|
|
||||||
if (!headers_sent()) {
|
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
|
||||||
}
|
|
||||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
|
||||||
if (!ini_get('display_errors')) {
|
|
||||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
|
||||||
fwrite(STDERR, $err);
|
|
||||||
} elseif (!headers_sent()) {
|
|
||||||
echo $err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trigger_error(
|
|
||||||
$err,
|
|
||||||
E_USER_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInita13a895834453aad32a897cc456c73ff::getLoader();
|
return ComposerAutoloaderInit99e41faf4c8cd1b54927a50ca0e7ee5c::getLoader();
|
||||||
|
|||||||
166
vendor/composer/ClassLoader.php
vendored
166
vendor/composer/ClassLoader.php
vendored
@ -42,76 +42,30 @@ namespace Composer\Autoload;
|
|||||||
*/
|
*/
|
||||||
class ClassLoader
|
class ClassLoader
|
||||||
{
|
{
|
||||||
/** @var \Closure(string):void */
|
|
||||||
private static $includeFile;
|
|
||||||
|
|
||||||
/** @var string|null */
|
|
||||||
private $vendorDir;
|
private $vendorDir;
|
||||||
|
|
||||||
// PSR-4
|
// PSR-4
|
||||||
/**
|
|
||||||
* @var array<string, array<string, int>>
|
|
||||||
*/
|
|
||||||
private $prefixLengthsPsr4 = array();
|
private $prefixLengthsPsr4 = array();
|
||||||
/**
|
|
||||||
* @var array<string, list<string>>
|
|
||||||
*/
|
|
||||||
private $prefixDirsPsr4 = array();
|
private $prefixDirsPsr4 = array();
|
||||||
/**
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
private $fallbackDirsPsr4 = array();
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
// PSR-0
|
// PSR-0
|
||||||
/**
|
|
||||||
* List of PSR-0 prefixes
|
|
||||||
*
|
|
||||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
|
||||||
*
|
|
||||||
* @var array<string, array<string, list<string>>>
|
|
||||||
*/
|
|
||||||
private $prefixesPsr0 = array();
|
private $prefixesPsr0 = array();
|
||||||
/**
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
private $fallbackDirsPsr0 = array();
|
private $fallbackDirsPsr0 = array();
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $useIncludePath = false;
|
private $useIncludePath = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
private $classMap = array();
|
private $classMap = array();
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $classMapAuthoritative = false;
|
private $classMapAuthoritative = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, bool>
|
|
||||||
*/
|
|
||||||
private $missingClasses = array();
|
private $missingClasses = array();
|
||||||
|
|
||||||
/** @var string|null */
|
|
||||||
private $apcuPrefix;
|
private $apcuPrefix;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, self>
|
|
||||||
*/
|
|
||||||
private static $registeredLoaders = array();
|
private static $registeredLoaders = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string|null $vendorDir
|
|
||||||
*/
|
|
||||||
public function __construct($vendorDir = null)
|
public function __construct($vendorDir = null)
|
||||||
{
|
{
|
||||||
$this->vendorDir = $vendorDir;
|
$this->vendorDir = $vendorDir;
|
||||||
self::initializeIncludeClosure();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, list<string>>
|
|
||||||
*/
|
|
||||||
public function getPrefixes()
|
public function getPrefixes()
|
||||||
{
|
{
|
||||||
if (!empty($this->prefixesPsr0)) {
|
if (!empty($this->prefixesPsr0)) {
|
||||||
@ -121,42 +75,28 @@ class ClassLoader
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, list<string>>
|
|
||||||
*/
|
|
||||||
public function getPrefixesPsr4()
|
public function getPrefixesPsr4()
|
||||||
{
|
{
|
||||||
return $this->prefixDirsPsr4;
|
return $this->prefixDirsPsr4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
public function getFallbackDirs()
|
public function getFallbackDirs()
|
||||||
{
|
{
|
||||||
return $this->fallbackDirsPsr0;
|
return $this->fallbackDirsPsr0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
public function getFallbackDirsPsr4()
|
public function getFallbackDirsPsr4()
|
||||||
{
|
{
|
||||||
return $this->fallbackDirsPsr4;
|
return $this->fallbackDirsPsr4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string> Array of classname => path
|
|
||||||
*/
|
|
||||||
public function getClassMap()
|
public function getClassMap()
|
||||||
{
|
{
|
||||||
return $this->classMap;
|
return $this->classMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $classMap Class to filename map
|
* @param array $classMap Class to filename map
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function addClassMap(array $classMap)
|
public function addClassMap(array $classMap)
|
||||||
{
|
{
|
||||||
@ -171,25 +111,22 @@ class ClassLoader
|
|||||||
* Registers a set of PSR-0 directories for a given prefix, either
|
* Registers a set of PSR-0 directories for a given prefix, either
|
||||||
* appending or prepending to the ones previously set for this prefix.
|
* appending or prepending to the ones previously set for this prefix.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix
|
* @param string $prefix The prefix
|
||||||
* @param list<string>|string $paths The PSR-0 root directories
|
* @param array|string $paths The PSR-0 root directories
|
||||||
* @param bool $prepend Whether to prepend the directories
|
* @param bool $prepend Whether to prepend the directories
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function add($prefix, $paths, $prepend = false)
|
public function add($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
$paths = (array) $paths;
|
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
$paths,
|
(array) $paths,
|
||||||
$this->fallbackDirsPsr0
|
$this->fallbackDirsPsr0
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
$this->fallbackDirsPsr0,
|
$this->fallbackDirsPsr0,
|
||||||
$paths
|
(array) $paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,19 +135,19 @@ class ClassLoader
|
|||||||
|
|
||||||
$first = $prefix[0];
|
$first = $prefix[0];
|
||||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
$paths,
|
(array) $paths,
|
||||||
$this->prefixesPsr0[$first][$prefix]
|
$this->prefixesPsr0[$first][$prefix]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
$this->prefixesPsr0[$first][$prefix],
|
$this->prefixesPsr0[$first][$prefix],
|
||||||
$paths
|
(array) $paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,28 +156,25 @@ class ClassLoader
|
|||||||
* Registers a set of PSR-4 directories for a given namespace, either
|
* Registers a set of PSR-4 directories for a given namespace, either
|
||||||
* appending or prepending to the ones previously set for this namespace.
|
* appending or prepending to the ones previously set for this namespace.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param list<string>|string $paths The PSR-4 base directories
|
* @param array|string $paths The PSR-4 base directories
|
||||||
* @param bool $prepend Whether to prepend the directories
|
* @param bool $prepend Whether to prepend the directories
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function addPsr4($prefix, $paths, $prepend = false)
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
$paths = (array) $paths;
|
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
// Register directories for the root namespace.
|
// Register directories for the root namespace.
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
$paths,
|
(array) $paths,
|
||||||
$this->fallbackDirsPsr4
|
$this->fallbackDirsPsr4
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
$this->fallbackDirsPsr4,
|
$this->fallbackDirsPsr4,
|
||||||
$paths
|
(array) $paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
@ -250,18 +184,18 @@ class ClassLoader
|
|||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
}
|
}
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
} elseif ($prepend) {
|
} elseif ($prepend) {
|
||||||
// Prepend directories for an already registered namespace.
|
// Prepend directories for an already registered namespace.
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
$paths,
|
(array) $paths,
|
||||||
$this->prefixDirsPsr4[$prefix]
|
$this->prefixDirsPsr4[$prefix]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Append directories for an already registered namespace.
|
// Append directories for an already registered namespace.
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
$this->prefixDirsPsr4[$prefix],
|
$this->prefixDirsPsr4[$prefix],
|
||||||
$paths
|
(array) $paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,10 +204,8 @@ class ClassLoader
|
|||||||
* Registers a set of PSR-0 directories for a given prefix,
|
* Registers a set of PSR-0 directories for a given prefix,
|
||||||
* replacing any others previously set for this prefix.
|
* replacing any others previously set for this prefix.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix
|
* @param string $prefix The prefix
|
||||||
* @param list<string>|string $paths The PSR-0 base directories
|
* @param array|string $paths The PSR-0 base directories
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function set($prefix, $paths)
|
public function set($prefix, $paths)
|
||||||
{
|
{
|
||||||
@ -288,12 +220,10 @@ class ClassLoader
|
|||||||
* Registers a set of PSR-4 directories for a given namespace,
|
* Registers a set of PSR-4 directories for a given namespace,
|
||||||
* replacing any others previously set for this namespace.
|
* replacing any others previously set for this namespace.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param list<string>|string $paths The PSR-4 base directories
|
* @param array|string $paths The PSR-4 base directories
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setPsr4($prefix, $paths)
|
public function setPsr4($prefix, $paths)
|
||||||
{
|
{
|
||||||
@ -313,8 +243,6 @@ class ClassLoader
|
|||||||
* Turns on searching the include path for class files.
|
* Turns on searching the include path for class files.
|
||||||
*
|
*
|
||||||
* @param bool $useIncludePath
|
* @param bool $useIncludePath
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setUseIncludePath($useIncludePath)
|
public function setUseIncludePath($useIncludePath)
|
||||||
{
|
{
|
||||||
@ -337,8 +265,6 @@ class ClassLoader
|
|||||||
* that have not been registered with the class map.
|
* that have not been registered with the class map.
|
||||||
*
|
*
|
||||||
* @param bool $classMapAuthoritative
|
* @param bool $classMapAuthoritative
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||||
{
|
{
|
||||||
@ -359,8 +285,6 @@ class ClassLoader
|
|||||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||||
*
|
*
|
||||||
* @param string|null $apcuPrefix
|
* @param string|null $apcuPrefix
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setApcuPrefix($apcuPrefix)
|
public function setApcuPrefix($apcuPrefix)
|
||||||
{
|
{
|
||||||
@ -381,8 +305,6 @@ class ClassLoader
|
|||||||
* Registers this instance as an autoloader.
|
* Registers this instance as an autoloader.
|
||||||
*
|
*
|
||||||
* @param bool $prepend Whether to prepend the autoloader or not
|
* @param bool $prepend Whether to prepend the autoloader or not
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function register($prepend = false)
|
public function register($prepend = false)
|
||||||
{
|
{
|
||||||
@ -402,8 +324,6 @@ class ClassLoader
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters this instance as an autoloader.
|
* Unregisters this instance as an autoloader.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function unregister()
|
public function unregister()
|
||||||
{
|
{
|
||||||
@ -423,8 +343,7 @@ class ClassLoader
|
|||||||
public function loadClass($class)
|
public function loadClass($class)
|
||||||
{
|
{
|
||||||
if ($file = $this->findFile($class)) {
|
if ($file = $this->findFile($class)) {
|
||||||
$includeFile = self::$includeFile;
|
includeFile($file);
|
||||||
$includeFile($file);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -475,20 +394,15 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||||
*
|
*
|
||||||
* @return array<string, self>
|
* @return self[]
|
||||||
*/
|
*/
|
||||||
public static function getRegisteredLoaders()
|
public static function getRegisteredLoaders()
|
||||||
{
|
{
|
||||||
return self::$registeredLoaders;
|
return self::$registeredLoaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $class
|
|
||||||
* @param string $ext
|
|
||||||
* @return string|false
|
|
||||||
*/
|
|
||||||
private function findFileWithExtension($class, $ext)
|
private function findFileWithExtension($class, $ext)
|
||||||
{
|
{
|
||||||
// PSR-4 lookup
|
// PSR-4 lookup
|
||||||
@ -554,26 +468,14 @@ class ClassLoader
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* @return void
|
/**
|
||||||
*/
|
* Scope isolated include.
|
||||||
private static function initializeIncludeClosure()
|
*
|
||||||
{
|
* Prevents access to $this/self from included files.
|
||||||
if (self::$includeFile !== null) {
|
*/
|
||||||
return;
|
function includeFile($file)
|
||||||
}
|
{
|
||||||
|
include $file;
|
||||||
/**
|
|
||||||
* Scope isolated include.
|
|
||||||
*
|
|
||||||
* Prevents access to $this/self from included files.
|
|
||||||
*
|
|
||||||
* @param string $file
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
self::$includeFile = \Closure::bind(static function($file) {
|
|
||||||
include $file;
|
|
||||||
}, null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
44
vendor/composer/InstalledVersions.php
vendored
44
vendor/composer/InstalledVersions.php
vendored
@ -20,27 +20,12 @@ use Composer\Semver\VersionParser;
|
|||||||
*
|
*
|
||||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||||
*
|
*
|
||||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
* To require it's presence, you can require `composer-runtime-api ^2.0`
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class InstalledVersions
|
class InstalledVersions
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var mixed[]|null
|
|
||||||
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
|
||||||
*/
|
|
||||||
private static $installed;
|
private static $installed;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
private static $canGetVendors;
|
private static $canGetVendors;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array[]
|
|
||||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
||||||
*/
|
|
||||||
private static $installedByVendor = array();
|
private static $installedByVendor = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,7 +83,7 @@ class InstalledVersions
|
|||||||
{
|
{
|
||||||
foreach (self::getInstalled() as $installed) {
|
foreach (self::getInstalled() as $installed) {
|
||||||
if (isset($installed['versions'][$packageName])) {
|
if (isset($installed['versions'][$packageName])) {
|
||||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +104,7 @@ class InstalledVersions
|
|||||||
*/
|
*/
|
||||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||||
{
|
{
|
||||||
$constraint = $parser->parseConstraints((string) $constraint);
|
$constraint = $parser->parseConstraints($constraint);
|
||||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||||
|
|
||||||
return $provided->matches($constraint);
|
return $provided->matches($constraint);
|
||||||
@ -243,7 +228,7 @@ class InstalledVersions
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}
|
||||||
*/
|
*/
|
||||||
public static function getRootPackage()
|
public static function getRootPackage()
|
||||||
{
|
{
|
||||||
@ -257,7 +242,7 @@ class InstalledVersions
|
|||||||
*
|
*
|
||||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||||
* @return array[]
|
* @return array[]
|
||||||
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}
|
||||||
*/
|
*/
|
||||||
public static function getRawData()
|
public static function getRawData()
|
||||||
{
|
{
|
||||||
@ -280,7 +265,7 @@ class InstalledVersions
|
|||||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||||
*
|
*
|
||||||
* @return array[]
|
* @return array[]
|
||||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
|
||||||
*/
|
*/
|
||||||
public static function getAllRawData()
|
public static function getAllRawData()
|
||||||
{
|
{
|
||||||
@ -303,7 +288,7 @@ class InstalledVersions
|
|||||||
* @param array[] $data A vendor/composer/installed.php data set
|
* @param array[] $data A vendor/composer/installed.php data set
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>} $data
|
||||||
*/
|
*/
|
||||||
public static function reload($data)
|
public static function reload($data)
|
||||||
{
|
{
|
||||||
@ -313,7 +298,7 @@ class InstalledVersions
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[]
|
* @return array[]
|
||||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
|
||||||
*/
|
*/
|
||||||
private static function getInstalled()
|
private static function getInstalled()
|
||||||
{
|
{
|
||||||
@ -328,9 +313,7 @@ class InstalledVersions
|
|||||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||||
$installed[] = self::$installedByVendor[$vendorDir];
|
$installed[] = self::$installedByVendor[$vendorDir];
|
||||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||||
$required = require $vendorDir.'/composer/installed.php';
|
|
||||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
|
||||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||||
self::$installed = $installed[count($installed) - 1];
|
self::$installed = $installed[count($installed) - 1];
|
||||||
}
|
}
|
||||||
@ -342,17 +325,12 @@ class InstalledVersions
|
|||||||
// only require the installed.php file if this file is loaded from its dumped location,
|
// only require the installed.php file if this file is loaded from its dumped location,
|
||||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
self::$installed = require __DIR__ . '/installed.php';
|
||||||
$required = require __DIR__ . '/installed.php';
|
|
||||||
self::$installed = $required;
|
|
||||||
} else {
|
} else {
|
||||||
self::$installed = array();
|
self::$installed = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$installed[] = self::$installed;
|
||||||
if (self::$installed !== array()) {
|
|
||||||
$installed[] = self::$installed;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed;
|
return $installed;
|
||||||
}
|
}
|
||||||
|
|||||||
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// autoload_classmap.php @generated by Composer
|
// autoload_classmap.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|||||||
3
vendor/composer/autoload_files.php
vendored
3
vendor/composer/autoload_files.php
vendored
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
// autoload_files.php @generated by Composer
|
// autoload_files.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'8653524d908cf23a56335c6d210d6627' => $vendorDir . '/abuyoyo/adminmenupage/wph_admin_page.php',
|
'8653524d908cf23a56335c6d210d6627' => $vendorDir . '/abuyoyo/adminmenupage/wph_admin_page.php',
|
||||||
|
'7166494aeff09009178f278afd86c83f' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v4p13.php',
|
||||||
'd8f9115e9a479bb7bf2fea8e74fb82f0' => $vendorDir . '/abuyoyo/screen-meta-links/screen-meta-links.php',
|
'd8f9115e9a479bb7bf2fea8e74fb82f0' => $vendorDir . '/abuyoyo/screen-meta-links/screen-meta-links.php',
|
||||||
);
|
);
|
||||||
|
|||||||
2
vendor/composer/autoload_namespaces.php
vendored
2
vendor/composer/autoload_namespaces.php
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// autoload_namespaces.php @generated by Composer
|
// autoload_namespaces.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
|||||||
4
vendor/composer/autoload_psr4.php
vendored
4
vendor/composer/autoload_psr4.php
vendored
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
// autoload_psr4.php @generated by Composer
|
// autoload_psr4.php @generated by Composer
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
$vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'WPHelper\\' => array($vendorDir . '/abuyoyo/adminmenupage/src', $vendorDir . '/abuyoyo/metabox', $vendorDir . '/abuyoyo/plugincore'),
|
'WPHelper\\' => array($vendorDir . '/abuyoyo/adminmenupage/src', $vendorDir . '/abuyoyo/plugincore'),
|
||||||
);
|
);
|
||||||
|
|||||||
59
vendor/composer/autoload_real.php
vendored
59
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInita13a895834453aad32a897cc456c73ff
|
class ComposerAutoloaderInit99e41faf4c8cd1b54927a50ca0e7ee5c
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
@ -22,27 +22,54 @@ class ComposerAutoloaderInita13a895834453aad32a897cc456c73ff
|
|||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInita13a895834453aad32a897cc456c73ff', 'loadClassLoader'), true, true);
|
require __DIR__ . '/platform_check.php';
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInita13a895834453aad32a897cc456c73ff', 'loadClassLoader'));
|
|
||||||
|
|
||||||
require __DIR__ . '/autoload_static.php';
|
spl_autoload_register(array('ComposerAutoloaderInit99e41faf4c8cd1b54927a50ca0e7ee5c', 'loadClassLoader'), true, true);
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInita13a895834453aad32a897cc456c73ff::getInitializer($loader));
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||||
|
spl_autoload_unregister(array('ComposerAutoloaderInit99e41faf4c8cd1b54927a50ca0e7ee5c', 'loadClassLoader'));
|
||||||
|
|
||||||
|
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||||
|
if ($useStaticLoader) {
|
||||||
|
require __DIR__ . '/autoload_static.php';
|
||||||
|
|
||||||
|
call_user_func(\Composer\Autoload\ComposerStaticInit99e41faf4c8cd1b54927a50ca0e7ee5c::getInitializer($loader));
|
||||||
|
} else {
|
||||||
|
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||||
|
foreach ($map as $namespace => $path) {
|
||||||
|
$loader->set($namespace, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = require __DIR__ . '/autoload_psr4.php';
|
||||||
|
foreach ($map as $namespace => $path) {
|
||||||
|
$loader->setPsr4($namespace, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||||
|
if ($classMap) {
|
||||||
|
$loader->addClassMap($classMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$filesToLoad = \Composer\Autoload\ComposerStaticInita13a895834453aad32a897cc456c73ff::$files;
|
if ($useStaticLoader) {
|
||||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
$includeFiles = Composer\Autoload\ComposerStaticInit99e41faf4c8cd1b54927a50ca0e7ee5c::$files;
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
} else {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
|
}
|
||||||
require $file;
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
}
|
composerRequire99e41faf4c8cd1b54927a50ca0e7ee5c($fileIdentifier, $file);
|
||||||
}, null, null);
|
|
||||||
foreach ($filesToLoad as $fileIdentifier => $file) {
|
|
||||||
$requireFile($fileIdentifier, $file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function composerRequire99e41faf4c8cd1b54927a50ca0e7ee5c($fileIdentifier, $file)
|
||||||
|
{
|
||||||
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
|
require $file;
|
||||||
|
|
||||||
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
12
vendor/composer/autoload_static.php
vendored
12
vendor/composer/autoload_static.php
vendored
@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
namespace Composer\Autoload;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInita13a895834453aad32a897cc456c73ff
|
class ComposerStaticInit99e41faf4c8cd1b54927a50ca0e7ee5c
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'8653524d908cf23a56335c6d210d6627' => __DIR__ . '/..' . '/abuyoyo/adminmenupage/wph_admin_page.php',
|
'8653524d908cf23a56335c6d210d6627' => __DIR__ . '/..' . '/abuyoyo/adminmenupage/wph_admin_page.php',
|
||||||
|
'7166494aeff09009178f278afd86c83f' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v4p13.php',
|
||||||
'd8f9115e9a479bb7bf2fea8e74fb82f0' => __DIR__ . '/..' . '/abuyoyo/screen-meta-links/screen-meta-links.php',
|
'd8f9115e9a479bb7bf2fea8e74fb82f0' => __DIR__ . '/..' . '/abuyoyo/screen-meta-links/screen-meta-links.php',
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -22,8 +23,7 @@ class ComposerStaticInita13a895834453aad32a897cc456c73ff
|
|||||||
'WPHelper\\' =>
|
'WPHelper\\' =>
|
||||||
array (
|
array (
|
||||||
0 => __DIR__ . '/..' . '/abuyoyo/adminmenupage/src',
|
0 => __DIR__ . '/..' . '/abuyoyo/adminmenupage/src',
|
||||||
1 => __DIR__ . '/..' . '/abuyoyo/metabox',
|
1 => __DIR__ . '/..' . '/abuyoyo/plugincore',
|
||||||
2 => __DIR__ . '/..' . '/abuyoyo/plugincore',
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ class ComposerStaticInita13a895834453aad32a897cc456c73ff
|
|||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInita13a895834453aad32a897cc456c73ff::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInit99e41faf4c8cd1b54927a50ca0e7ee5c::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInita13a895834453aad32a897cc456c73ff::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInit99e41faf4c8cd1b54927a50ca0e7ee5c::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInita13a895834453aad32a897cc456c73ff::$classMap;
|
$loader->classMap = ComposerStaticInit99e41faf4c8cd1b54927a50ca0e7ee5c::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
|||||||
140
vendor/composer/installed.json
vendored
140
vendor/composer/installed.json
vendored
@ -2,27 +2,24 @@
|
|||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "abuyoyo/adminmenupage",
|
"name": "abuyoyo/adminmenupage",
|
||||||
"version": "0.29",
|
"version": "0.20",
|
||||||
"version_normalized": "0.29.0.0",
|
"version_normalized": "0.20.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/abuyoyo/AdminMenuPage.git",
|
"url": "https://github.com/abuyoyo/AdminMenuPage.git",
|
||||||
"reference": "4cd47d5217ca25ed17af76f5fdbab3cab3b37ef8"
|
"reference": "07d98f2c1f0b71340aaf0fae0783dfecec201e97"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/4cd47d5217ca25ed17af76f5fdbab3cab3b37ef8",
|
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/07d98f2c1f0b71340aaf0fae0783dfecec201e97",
|
||||||
"reference": "4cd47d5217ca25ed17af76f5fdbab3cab3b37ef8",
|
"reference": "07d98f2c1f0b71340aaf0fae0783dfecec201e97",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
|
||||||
"abuyoyo/metabox": "~0.8"
|
|
||||||
},
|
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"abuyoyo/plugincore": "~0.26",
|
"abuyoyo/plugincore": "~0.18",
|
||||||
"cmb2/cmb2": "~2.9"
|
"cmb2/cmb2": "~2.9"
|
||||||
},
|
},
|
||||||
"time": "2023-10-05T00:00:00+00:00",
|
"time": "2022-07-28T22:56:37+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -40,64 +37,30 @@
|
|||||||
"description": "WordPress admin menu page helper class",
|
"description": "WordPress admin menu page helper class",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/abuyoyo/AdminMenuPage/issues",
|
"issues": "https://github.com/abuyoyo/AdminMenuPage/issues",
|
||||||
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.29"
|
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.20"
|
||||||
},
|
},
|
||||||
"install-path": "../abuyoyo/adminmenupage"
|
"install-path": "../abuyoyo/adminmenupage"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "abuyoyo/metabox",
|
|
||||||
"version": "0.8",
|
|
||||||
"version_normalized": "0.8.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/abuyoyo/MetaBox.git",
|
|
||||||
"reference": "98cb4c30db4c366c0d273985eb9c31ffa1cd78f9"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/abuyoyo/MetaBox/zipball/98cb4c30db4c366c0d273985eb9c31ffa1cd78f9",
|
|
||||||
"reference": "98cb4c30db4c366c0d273985eb9c31ffa1cd78f9",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"time": "2023-07-18T19:14:03+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"WPHelper\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"description": "WordPress metabox helper class",
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/abuyoyo/MetaBox/issues",
|
|
||||||
"source": "https://github.com/abuyoyo/MetaBox/tree/0.8"
|
|
||||||
},
|
|
||||||
"install-path": "../abuyoyo/metabox"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "abuyoyo/plugincore",
|
"name": "abuyoyo/plugincore",
|
||||||
"version": "0.27",
|
"version": "0.21",
|
||||||
"version_normalized": "0.27.0.0",
|
"version_normalized": "0.21.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/abuyoyo/PluginCore.git",
|
"url": "https://github.com/abuyoyo/PluginCore.git",
|
||||||
"reference": "d730a674cbe2dc92e60ace8e25a2e0e3fdeee3e6"
|
"reference": "9c398bdf05dc2cecf30eb0ac53558b3d37ecc4aa"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/d730a674cbe2dc92e60ace8e25a2e0e3fdeee3e6",
|
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/9c398bdf05dc2cecf30eb0ac53558b3d37ecc4aa",
|
||||||
"reference": "d730a674cbe2dc92e60ace8e25a2e0e3fdeee3e6",
|
"reference": "9c398bdf05dc2cecf30eb0ac53558b3d37ecc4aa",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"suggest": {
|
"require": {
|
||||||
"abuyoyo/adminmenupage": "~0.27",
|
"abuyoyo/adminmenupage": "~0.20",
|
||||||
"yahnis-elsts/plugin-update-checker": "~5.2"
|
"yahnis-elsts/plugin-update-checker": "~4.12"
|
||||||
},
|
},
|
||||||
"time": "2022-10-03T00:00:00+00:00",
|
"time": "2022-08-05T00:00:00+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -112,26 +75,26 @@
|
|||||||
"description": "WordPress plugin core helper class",
|
"description": "WordPress plugin core helper class",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/abuyoyo/PluginCore/issues",
|
"issues": "https://github.com/abuyoyo/PluginCore/issues",
|
||||||
"source": "https://github.com/abuyoyo/PluginCore/tree/0.27"
|
"source": "https://github.com/abuyoyo/PluginCore/tree/0.21"
|
||||||
},
|
},
|
||||||
"install-path": "../abuyoyo/plugincore"
|
"install-path": "../abuyoyo/plugincore"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "abuyoyo/screen-meta-links",
|
"name": "abuyoyo/screen-meta-links",
|
||||||
"version": "0.13",
|
"version": "0.11",
|
||||||
"version_normalized": "0.13.0.0",
|
"version_normalized": "0.11.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/abuyoyo/screen-meta-links.git",
|
"url": "https://github.com/abuyoyo/screen-meta-links.git",
|
||||||
"reference": "b324cef9eb5825d04ffa17f771237b7deca5cd01"
|
"reference": "04e3c892f0c6095b4c31a489e06336f0917128d3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/abuyoyo/screen-meta-links/zipball/b324cef9eb5825d04ffa17f771237b7deca5cd01",
|
"url": "https://api.github.com/repos/abuyoyo/screen-meta-links/zipball/04e3c892f0c6095b4c31a489e06336f0917128d3",
|
||||||
"reference": "b324cef9eb5825d04ffa17f771237b7deca5cd01",
|
"reference": "04e3c892f0c6095b4c31a489e06336f0917128d3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"time": "2023-08-08T22:37:03+00:00",
|
"time": "2022-05-18T01:18:24+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -141,10 +104,63 @@
|
|||||||
},
|
},
|
||||||
"description": "API for adding custom screen-meta-links alongside the 'Screen Options' and 'Help' links.",
|
"description": "API for adding custom screen-meta-links alongside the 'Screen Options' and 'Help' links.",
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/abuyoyo/screen-meta-links/tree/0.13",
|
"source": "https://github.com/abuyoyo/screen-meta-links/tree/0.11",
|
||||||
"issues": "https://github.com/abuyoyo/screen-meta-links/issues"
|
"issues": "https://github.com/abuyoyo/screen-meta-links/issues"
|
||||||
},
|
},
|
||||||
"install-path": "../abuyoyo/screen-meta-links"
|
"install-path": "../abuyoyo/screen-meta-links"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "yahnis-elsts/plugin-update-checker",
|
||||||
|
"version": "v4.13",
|
||||||
|
"version_normalized": "4.13.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/YahnisElsts/plugin-update-checker.git",
|
||||||
|
"reference": "6eb27a6911e0e0880d09e5b11f577d3f688f7da7"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/6eb27a6911e0e0880d09e5b11f577d3f688f7da7",
|
||||||
|
"reference": "6eb27a6911e0e0880d09e5b11f577d3f688f7da7",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"php": ">=5.2.0"
|
||||||
|
},
|
||||||
|
"time": "2022-07-29T12:36:25+00:00",
|
||||||
|
"type": "library",
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"load-v4p13.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Yahnis Elsts",
|
||||||
|
"email": "whiteshadow@w-shadow.com",
|
||||||
|
"homepage": "http://w-shadow.com/",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.",
|
||||||
|
"homepage": "https://github.com/YahnisElsts/plugin-update-checker/",
|
||||||
|
"keywords": [
|
||||||
|
"automatic updates",
|
||||||
|
"plugin updates",
|
||||||
|
"theme updates",
|
||||||
|
"wordpress"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/YahnisElsts/plugin-update-checker/issues",
|
||||||
|
"source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v4.13"
|
||||||
|
},
|
||||||
|
"install-path": "../yahnis-elsts/plugin-update-checker"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
|||||||
50
vendor/composer/installed.php
vendored
50
vendor/composer/installed.php
vendored
@ -1,58 +1,58 @@
|
|||||||
<?php return array(
|
<?php return array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
'name' => 'abuyoyo/notice-manager',
|
'pretty_version' => '0.16',
|
||||||
'pretty_version' => '0.25',
|
'version' => '0.16.0.0',
|
||||||
'version' => '0.25.0.0',
|
|
||||||
'reference' => NULL,
|
|
||||||
'type' => 'wordpress-plugin',
|
'type' => 'wordpress-plugin',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
'reference' => NULL,
|
||||||
|
'name' => 'abuyoyo/notice-manager',
|
||||||
'dev' => true,
|
'dev' => true,
|
||||||
),
|
),
|
||||||
'versions' => array(
|
'versions' => array(
|
||||||
'abuyoyo/adminmenupage' => array(
|
'abuyoyo/adminmenupage' => array(
|
||||||
'pretty_version' => '0.29',
|
'pretty_version' => '0.20',
|
||||||
'version' => '0.29.0.0',
|
'version' => '0.20.0.0',
|
||||||
'reference' => '4cd47d5217ca25ed17af76f5fdbab3cab3b37ef8',
|
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../abuyoyo/adminmenupage',
|
'install_path' => __DIR__ . '/../abuyoyo/adminmenupage',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'dev_requirement' => false,
|
'reference' => '07d98f2c1f0b71340aaf0fae0783dfecec201e97',
|
||||||
),
|
|
||||||
'abuyoyo/metabox' => array(
|
|
||||||
'pretty_version' => '0.8',
|
|
||||||
'version' => '0.8.0.0',
|
|
||||||
'reference' => '98cb4c30db4c366c0d273985eb9c31ffa1cd78f9',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../abuyoyo/metabox',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'abuyoyo/notice-manager' => array(
|
'abuyoyo/notice-manager' => array(
|
||||||
'pretty_version' => '0.25',
|
'pretty_version' => '0.16',
|
||||||
'version' => '0.25.0.0',
|
'version' => '0.16.0.0',
|
||||||
'reference' => NULL,
|
|
||||||
'type' => 'wordpress-plugin',
|
'type' => 'wordpress-plugin',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
'reference' => NULL,
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'abuyoyo/plugincore' => array(
|
'abuyoyo/plugincore' => array(
|
||||||
'pretty_version' => '0.27',
|
'pretty_version' => '0.21',
|
||||||
'version' => '0.27.0.0',
|
'version' => '0.21.0.0',
|
||||||
'reference' => 'd730a674cbe2dc92e60ace8e25a2e0e3fdeee3e6',
|
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../abuyoyo/plugincore',
|
'install_path' => __DIR__ . '/../abuyoyo/plugincore',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
'reference' => '9c398bdf05dc2cecf30eb0ac53558b3d37ecc4aa',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'abuyoyo/screen-meta-links' => array(
|
'abuyoyo/screen-meta-links' => array(
|
||||||
'pretty_version' => '0.13',
|
'pretty_version' => '0.11',
|
||||||
'version' => '0.13.0.0',
|
'version' => '0.11.0.0',
|
||||||
'reference' => 'b324cef9eb5825d04ffa17f771237b7deca5cd01',
|
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../abuyoyo/screen-meta-links',
|
'install_path' => __DIR__ . '/../abuyoyo/screen-meta-links',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
'reference' => '04e3c892f0c6095b4c31a489e06336f0917128d3',
|
||||||
|
'dev_requirement' => false,
|
||||||
|
),
|
||||||
|
'yahnis-elsts/plugin-update-checker' => array(
|
||||||
|
'pretty_version' => 'v4.13',
|
||||||
|
'version' => '4.13.0.0',
|
||||||
|
'type' => 'library',
|
||||||
|
'install_path' => __DIR__ . '/../yahnis-elsts/plugin-update-checker',
|
||||||
|
'aliases' => array(),
|
||||||
|
'reference' => '6eb27a6911e0e0880d09e5b11f577d3f688f7da7',
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
26
vendor/composer/platform_check.php
vendored
Normal file
26
vendor/composer/platform_check.php
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// platform_check.php @generated by Composer
|
||||||
|
|
||||||
|
$issues = array();
|
||||||
|
|
||||||
|
if (!(PHP_VERSION_ID >= 50200)) {
|
||||||
|
$issues[] = 'Your Composer dependencies require a PHP version ">= 5.2.0". You are running ' . PHP_VERSION . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($issues) {
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
}
|
||||||
|
if (!ini_get('display_errors')) {
|
||||||
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
|
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||||
|
} elseif (!headers_sent()) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trigger_error(
|
||||||
|
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
}
|
||||||
15
vendor/yahnis-elsts/plugin-update-checker/.editorconfig
vendored
Normal file
15
vendor/yahnis-elsts/plugin-update-checker/.editorconfig
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[*]
|
||||||
|
charset=utf-8
|
||||||
|
end_of_line=lf
|
||||||
|
insert_final_newline=false
|
||||||
|
indent_style=tab
|
||||||
|
tab_width=4
|
||||||
|
|
||||||
|
[{phpunit.xml.dist,*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}]
|
||||||
|
indent_style=space
|
||||||
|
indent_size=4
|
||||||
|
|
||||||
|
[*.svg]
|
||||||
|
indent_style=space
|
||||||
|
indent_size=4
|
||||||
|
|
||||||
40
vendor/yahnis-elsts/plugin-update-checker/.gitignore
vendored
Normal file
40
vendor/yahnis-elsts/plugin-update-checker/.gitignore
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# The entire IDEA/PhpStorm directory
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
6
vendor/yahnis-elsts/plugin-update-checker/Puc/v4/Factory.php
vendored
Normal file
6
vendor/yahnis-elsts/plugin-update-checker/Puc/v4/Factory.php
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4_Factory', false) ):
|
||||||
|
|
||||||
|
class Puc_v4_Factory extends Puc_v4p13_Factory { }
|
||||||
|
|
||||||
|
endif;
|
||||||
70
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Autoloader.php
vendored
Normal file
70
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Autoloader.php
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_Autoloader', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Autoloader {
|
||||||
|
private $prefix = '';
|
||||||
|
private $rootDir = '';
|
||||||
|
private $libraryDir = '';
|
||||||
|
|
||||||
|
private $staticMap;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->rootDir = dirname(__FILE__) . '/';
|
||||||
|
|
||||||
|
if ( version_compare(PHP_VERSION, '5.3', '>=') && __NAMESPACE__ ) {
|
||||||
|
$namespaceWithSlash = __NAMESPACE__ . '\\';
|
||||||
|
} else {
|
||||||
|
$namespaceWithSlash = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$nameParts = explode('_', substr(__CLASS__, strlen($namespaceWithSlash)), 3);
|
||||||
|
$this->prefix = $namespaceWithSlash . $nameParts[0] . '_' . $nameParts[1] . '_';
|
||||||
|
|
||||||
|
$this->libraryDir = $this->rootDir . '../..';
|
||||||
|
if ( !self::isPhar() ) {
|
||||||
|
$this->libraryDir = realpath($this->libraryDir);
|
||||||
|
}
|
||||||
|
$this->libraryDir = $this->libraryDir . '/';
|
||||||
|
|
||||||
|
$this->staticMap = array(
|
||||||
|
$namespaceWithSlash . 'PucReadmeParser' => 'vendor/PucReadmeParser.php',
|
||||||
|
$namespaceWithSlash . 'Parsedown' => 'vendor/Parsedown.php',
|
||||||
|
$namespaceWithSlash . 'Puc_v4_Factory' => 'Puc/v4/Factory.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
spl_autoload_register(array($this, 'autoload'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this file is running as part of a Phar archive.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function isPhar() {
|
||||||
|
//Check if the current file path starts with "phar://".
|
||||||
|
static $pharProtocol = 'phar://';
|
||||||
|
return (substr(__FILE__, 0, strlen($pharProtocol)) === $pharProtocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function autoload($className) {
|
||||||
|
if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) {
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
include ($this->libraryDir . $this->staticMap[$className]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($className, $this->prefix) === 0) {
|
||||||
|
$path = substr($className, strlen($this->prefix));
|
||||||
|
$path = str_replace('_', '/', $path);
|
||||||
|
$path = $this->rootDir . $path . '.php';
|
||||||
|
|
||||||
|
if (file_exists($path)) {
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
include $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
190
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/Extension.php
vendored
Normal file
190
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/Extension.php
vendored
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_DebugBar_Extension', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_DebugBar_Extension {
|
||||||
|
const RESPONSE_BODY_LENGTH_LIMIT = 4000;
|
||||||
|
|
||||||
|
/** @var Puc_v4p13_UpdateChecker */
|
||||||
|
protected $updateChecker;
|
||||||
|
protected $panelClass = 'Puc_v4p13_DebugBar_Panel';
|
||||||
|
|
||||||
|
public function __construct($updateChecker, $panelClass = null) {
|
||||||
|
$this->updateChecker = $updateChecker;
|
||||||
|
if ( isset($panelClass) ) {
|
||||||
|
$this->panelClass = $panelClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare(PHP_VERSION, '5.3', '>=') && (strpos($this->panelClass, '\\') === false) ) {
|
||||||
|
$this->panelClass = __NAMESPACE__ . '\\' . $this->panelClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter('debug_bar_panels', array($this, 'addDebugBarPanel'));
|
||||||
|
add_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies'));
|
||||||
|
|
||||||
|
add_action('wp_ajax_puc_v4_debug_check_now', array($this, 'ajaxCheckNow'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the PUC Debug Bar panel.
|
||||||
|
*
|
||||||
|
* @param array $panels
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function addDebugBarPanel($panels) {
|
||||||
|
if ( $this->updateChecker->userCanInstallUpdates() ) {
|
||||||
|
$panels[] = new $this->panelClass($this->updateChecker);
|
||||||
|
}
|
||||||
|
return $panels;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enqueue our Debug Bar scripts and styles.
|
||||||
|
*/
|
||||||
|
public function enqueuePanelDependencies() {
|
||||||
|
wp_enqueue_style(
|
||||||
|
'puc-debug-bar-style-v4',
|
||||||
|
$this->getLibraryUrl("/css/puc-debug-bar.css"),
|
||||||
|
array('debug-bar'),
|
||||||
|
'20171124'
|
||||||
|
);
|
||||||
|
|
||||||
|
wp_enqueue_script(
|
||||||
|
'puc-debug-bar-js-v4',
|
||||||
|
$this->getLibraryUrl("/js/debug-bar.js"),
|
||||||
|
array('jquery'),
|
||||||
|
'20201209'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run an update check and output the result. Useful for making sure that
|
||||||
|
* the update checking process works as expected.
|
||||||
|
*/
|
||||||
|
public function ajaxCheckNow() {
|
||||||
|
if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->preAjaxRequest();
|
||||||
|
$update = $this->updateChecker->checkForUpdates();
|
||||||
|
if ( $update !== null ) {
|
||||||
|
echo "An update is available:";
|
||||||
|
echo '<pre>', htmlentities(print_r($update, true)), '</pre>';
|
||||||
|
} else {
|
||||||
|
echo 'No updates found.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = $this->updateChecker->getLastRequestApiErrors();
|
||||||
|
if ( !empty($errors) ) {
|
||||||
|
printf('<p>The update checker encountered %d API error%s.</p>', count($errors), (count($errors) > 1) ? 's' : '');
|
||||||
|
|
||||||
|
foreach (array_values($errors) as $num => $item) {
|
||||||
|
$wpError = $item['error'];
|
||||||
|
/** @var WP_Error $wpError */
|
||||||
|
printf('<h4>%d) %s</h4>', $num + 1, esc_html($wpError->get_error_message()));
|
||||||
|
|
||||||
|
echo '<dl>';
|
||||||
|
printf('<dt>Error code:</dt><dd><code>%s</code></dd>', esc_html($wpError->get_error_code()));
|
||||||
|
|
||||||
|
if ( isset($item['url']) ) {
|
||||||
|
printf('<dt>Requested URL:</dt><dd><code>%s</code></dd>', esc_html($item['url']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($item['httpResponse']) ) {
|
||||||
|
if ( is_wp_error($item['httpResponse']) ) {
|
||||||
|
$httpError = $item['httpResponse'];
|
||||||
|
/** @var WP_Error $httpError */
|
||||||
|
printf(
|
||||||
|
'<dt>WordPress HTTP API error:</dt><dd>%s (<code>%s</code>)</dd>',
|
||||||
|
esc_html($httpError->get_error_message()),
|
||||||
|
esc_html($httpError->get_error_code())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//Status code.
|
||||||
|
printf(
|
||||||
|
'<dt>HTTP status:</dt><dd><code>%d %s</code></dd>',
|
||||||
|
wp_remote_retrieve_response_code($item['httpResponse']),
|
||||||
|
wp_remote_retrieve_response_message($item['httpResponse'])
|
||||||
|
);
|
||||||
|
|
||||||
|
//Headers.
|
||||||
|
echo '<dt>Response headers:</dt><dd><pre>';
|
||||||
|
foreach (wp_remote_retrieve_headers($item['httpResponse']) as $name => $value) {
|
||||||
|
printf("%s: %s\n", esc_html($name), esc_html($value));
|
||||||
|
}
|
||||||
|
echo '</pre></dd>';
|
||||||
|
|
||||||
|
//Body.
|
||||||
|
$body = wp_remote_retrieve_body($item['httpResponse']);
|
||||||
|
if ( $body === '' ) {
|
||||||
|
$body = '(Empty response.)';
|
||||||
|
} else if ( strlen($body) > self::RESPONSE_BODY_LENGTH_LIMIT ) {
|
||||||
|
$length = strlen($body);
|
||||||
|
$body = substr($body, 0, self::RESPONSE_BODY_LENGTH_LIMIT)
|
||||||
|
. sprintf("\n(Long string truncated. Total length: %d bytes.)", $length);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf('<dt>Response body:</dt><dd><pre>%s</pre></dd>', esc_html($body));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '<dl>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check access permissions and enable error display (for debugging).
|
||||||
|
*/
|
||||||
|
protected function preAjaxRequest() {
|
||||||
|
if ( !$this->updateChecker->userCanInstallUpdates() ) {
|
||||||
|
die('Access denied');
|
||||||
|
}
|
||||||
|
check_ajax_referer('puc-ajax');
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
@ini_set('display_errors', 'On');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove hooks that were added by this extension.
|
||||||
|
*/
|
||||||
|
public function removeHooks() {
|
||||||
|
remove_filter('debug_bar_panels', array($this, 'addDebugBarPanel'));
|
||||||
|
remove_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies'));
|
||||||
|
remove_action('wp_ajax_puc_v4_debug_check_now', array($this, 'ajaxCheckNow'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $filePath
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getLibraryUrl($filePath) {
|
||||||
|
$absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/'));
|
||||||
|
|
||||||
|
//Where is the library located inside the WordPress directory structure?
|
||||||
|
$absolutePath = Puc_v4p13_Factory::normalizePath($absolutePath);
|
||||||
|
|
||||||
|
$pluginDir = Puc_v4p13_Factory::normalizePath(WP_PLUGIN_DIR);
|
||||||
|
$muPluginDir = Puc_v4p13_Factory::normalizePath(WPMU_PLUGIN_DIR);
|
||||||
|
$themeDir = Puc_v4p13_Factory::normalizePath(get_theme_root());
|
||||||
|
|
||||||
|
if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
|
||||||
|
//It's part of a plugin.
|
||||||
|
return plugins_url(basename($absolutePath), $absolutePath);
|
||||||
|
} else if ( strpos($absolutePath, $themeDir) === 0 ) {
|
||||||
|
//It's part of a theme.
|
||||||
|
$relativePath = substr($absolutePath, strlen($themeDir) + 1);
|
||||||
|
$template = substr($relativePath, 0, strpos($relativePath, '/'));
|
||||||
|
$baseUrl = get_theme_root_uri($template);
|
||||||
|
|
||||||
|
if ( !empty($baseUrl) && $relativePath ) {
|
||||||
|
return $baseUrl . '/' . $relativePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
165
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/Panel.php
vendored
Normal file
165
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/Panel.php
vendored
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_DebugBar_Panel extends Debug_Bar_Panel {
|
||||||
|
/** @var Puc_v4p13_UpdateChecker */
|
||||||
|
protected $updateChecker;
|
||||||
|
|
||||||
|
private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
|
||||||
|
|
||||||
|
public function __construct($updateChecker) {
|
||||||
|
$this->updateChecker = $updateChecker;
|
||||||
|
$title = sprintf(
|
||||||
|
'<span class="puc-debug-menu-link-%s">PUC (%s)</span>',
|
||||||
|
esc_attr($this->updateChecker->getUniqueName('uid')),
|
||||||
|
$this->updateChecker->slug
|
||||||
|
);
|
||||||
|
parent::__construct($title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
printf(
|
||||||
|
'<div class="puc-debug-bar-panel-v4" id="%1$s" data-slug="%2$s" data-uid="%3$s" data-nonce="%4$s">',
|
||||||
|
esc_attr($this->updateChecker->getUniqueName('debug-bar-panel')),
|
||||||
|
esc_attr($this->updateChecker->slug),
|
||||||
|
esc_attr($this->updateChecker->getUniqueName('uid')),
|
||||||
|
esc_attr(wp_create_nonce('puc-ajax'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->displayConfiguration();
|
||||||
|
$this->displayStatus();
|
||||||
|
$this->displayCurrentUpdate();
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function displayConfiguration() {
|
||||||
|
echo '<h3>Configuration</h3>';
|
||||||
|
echo '<table class="puc-debug-data">';
|
||||||
|
$this->displayConfigHeader();
|
||||||
|
$this->row('Slug', htmlentities($this->updateChecker->slug));
|
||||||
|
$this->row('DB option', htmlentities($this->updateChecker->optionName));
|
||||||
|
|
||||||
|
$requestInfoButton = $this->getMetadataButton();
|
||||||
|
$this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $this->responseBox);
|
||||||
|
|
||||||
|
$scheduler = $this->updateChecker->scheduler;
|
||||||
|
if ( $scheduler->checkPeriod > 0 ) {
|
||||||
|
$this->row('Automatic checks', 'Every ' . $scheduler->checkPeriod . ' hours');
|
||||||
|
} else {
|
||||||
|
$this->row('Automatic checks', 'Disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($scheduler->throttleRedundantChecks) ) {
|
||||||
|
if ( $scheduler->throttleRedundantChecks && ($scheduler->checkPeriod > 0) ) {
|
||||||
|
$this->row(
|
||||||
|
'Throttling',
|
||||||
|
sprintf(
|
||||||
|
'Enabled. If an update is already available, check for updates every %1$d hours instead of every %2$d hours.',
|
||||||
|
$scheduler->throttledCheckPeriod,
|
||||||
|
$scheduler->checkPeriod
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->row('Throttling', 'Disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updateChecker->onDisplayConfiguration($this);
|
||||||
|
|
||||||
|
echo '</table>';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function displayConfigHeader() {
|
||||||
|
//Do nothing. This should be implemented in subclasses.
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getMetadataButton() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function displayStatus() {
|
||||||
|
echo '<h3>Status</h3>';
|
||||||
|
echo '<table class="puc-debug-data">';
|
||||||
|
$state = $this->updateChecker->getUpdateState();
|
||||||
|
$checkNowButton = '';
|
||||||
|
if ( function_exists('get_submit_button') ) {
|
||||||
|
$checkNowButton = get_submit_button(
|
||||||
|
'Check Now',
|
||||||
|
'secondary',
|
||||||
|
'puc-check-now-button',
|
||||||
|
false,
|
||||||
|
array('id' => $this->updateChecker->getUniqueName('check-now-button'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $state->getLastCheck() > 0 ) {
|
||||||
|
$this->row('Last check', $this->formatTimeWithDelta($state->getLastCheck()) . ' ' . $checkNowButton . $this->responseBox);
|
||||||
|
} else {
|
||||||
|
$this->row('Last check', 'Never');
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextCheck = wp_next_scheduled($this->updateChecker->scheduler->getCronHookName());
|
||||||
|
$this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck));
|
||||||
|
|
||||||
|
if ( $state->getCheckedVersion() !== '' ) {
|
||||||
|
$this->row('Checked version', htmlentities($state->getCheckedVersion()));
|
||||||
|
$this->row('Cached update', $state->getUpdate());
|
||||||
|
}
|
||||||
|
$this->row('Update checker class', htmlentities(get_class($this->updateChecker)));
|
||||||
|
echo '</table>';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function displayCurrentUpdate() {
|
||||||
|
$update = $this->updateChecker->getUpdate();
|
||||||
|
if ( $update !== null ) {
|
||||||
|
echo '<h3>An Update Is Available</h3>';
|
||||||
|
echo '<table class="puc-debug-data">';
|
||||||
|
$fields = $this->getUpdateFields();
|
||||||
|
foreach($fields as $field) {
|
||||||
|
if ( property_exists($update, $field) ) {
|
||||||
|
$this->row(ucwords(str_replace('_', ' ', $field)), htmlentities($update->$field));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '</table>';
|
||||||
|
} else {
|
||||||
|
echo '<h3>No updates currently available</h3>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getUpdateFields() {
|
||||||
|
return array('version', 'download_url', 'slug',);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formatTimeWithDelta($unixTime) {
|
||||||
|
if ( empty($unixTime) ) {
|
||||||
|
return 'Never';
|
||||||
|
}
|
||||||
|
|
||||||
|
$delta = time() - $unixTime;
|
||||||
|
$result = human_time_diff(time(), $unixTime);
|
||||||
|
if ( $delta < 0 ) {
|
||||||
|
$result = 'after ' . $result;
|
||||||
|
} else {
|
||||||
|
$result = $result . ' ago';
|
||||||
|
}
|
||||||
|
$result .= ' (' . $this->formatTimestamp($unixTime) . ')';
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formatTimestamp($unixTime) {
|
||||||
|
return gmdate('Y-m-d H:i:s', $unixTime + (get_option('gmt_offset') * 3600));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function row($name, $value) {
|
||||||
|
if ( is_object($value) || is_array($value) ) {
|
||||||
|
$value = '<pre>' . htmlentities(print_r($value, true)) . '</pre>';
|
||||||
|
} else if ($value === null) {
|
||||||
|
$value = '<code>null</code>';
|
||||||
|
}
|
||||||
|
printf('<tr><th scope="row">%1$s</th> <td>%2$s</td></tr>', $name, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
33
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/PluginExtension.php
vendored
Normal file
33
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/PluginExtension.php
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_DebugBar_PluginExtension', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_DebugBar_PluginExtension extends Puc_v4p13_DebugBar_Extension {
|
||||||
|
/** @var Puc_v4p13_Plugin_UpdateChecker */
|
||||||
|
protected $updateChecker;
|
||||||
|
|
||||||
|
public function __construct($updateChecker) {
|
||||||
|
parent::__construct($updateChecker, 'Puc_v4p13_DebugBar_PluginPanel');
|
||||||
|
|
||||||
|
add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request plugin info and output it.
|
||||||
|
*/
|
||||||
|
public function ajaxRequestInfo() {
|
||||||
|
if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->preAjaxRequest();
|
||||||
|
$info = $this->updateChecker->requestInfo();
|
||||||
|
if ( $info !== null ) {
|
||||||
|
echo 'Successfully retrieved plugin info from the metadata URL:';
|
||||||
|
echo '<pre>', htmlentities(print_r($info, true)), '</pre>';
|
||||||
|
} else {
|
||||||
|
echo 'Failed to retrieve plugin info from the metadata URL.';
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
38
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/PluginPanel.php
vendored
Normal file
38
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/PluginPanel.php
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_DebugBar_PluginPanel', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_DebugBar_PluginPanel extends Puc_v4p13_DebugBar_Panel {
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Plugin_UpdateChecker
|
||||||
|
*/
|
||||||
|
protected $updateChecker;
|
||||||
|
|
||||||
|
protected function displayConfigHeader() {
|
||||||
|
$this->row('Plugin file', htmlentities($this->updateChecker->pluginFile));
|
||||||
|
parent::displayConfigHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getMetadataButton() {
|
||||||
|
$requestInfoButton = '';
|
||||||
|
if ( function_exists('get_submit_button') ) {
|
||||||
|
$requestInfoButton = get_submit_button(
|
||||||
|
'Request Info',
|
||||||
|
'secondary',
|
||||||
|
'puc-request-info-button',
|
||||||
|
false,
|
||||||
|
array('id' => $this->updateChecker->getUniqueName('request-info-button'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $requestInfoButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getUpdateFields() {
|
||||||
|
return array_merge(
|
||||||
|
parent::getUpdateFields(),
|
||||||
|
array('homepage', 'upgrade_notice', 'tested',)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
21
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/ThemePanel.php
vendored
Normal file
21
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/DebugBar/ThemePanel.php
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_DebugBar_ThemePanel', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_DebugBar_ThemePanel extends Puc_v4p13_DebugBar_Panel {
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Theme_UpdateChecker
|
||||||
|
*/
|
||||||
|
protected $updateChecker;
|
||||||
|
|
||||||
|
protected function displayConfigHeader() {
|
||||||
|
$this->row('Theme directory', htmlentities($this->updateChecker->directoryName));
|
||||||
|
parent::displayConfigHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getUpdateFields() {
|
||||||
|
return array_merge(parent::getUpdateFields(), array('details_url'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
369
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Factory.php
vendored
Normal file
369
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Factory.php
vendored
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Factory', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A factory that builds update checker instances.
|
||||||
|
*
|
||||||
|
* When multiple versions of the same class have been loaded (e.g. PluginUpdateChecker 4.0
|
||||||
|
* and 4.1), this factory will always use the latest available minor version. Register class
|
||||||
|
* versions by calling {@link PucFactory::addVersion()}.
|
||||||
|
*
|
||||||
|
* At the moment it can only build instances of the UpdateChecker class. Other classes are
|
||||||
|
* intended mainly for internal use and refer directly to specific implementations.
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_Factory {
|
||||||
|
protected static $classVersions = array();
|
||||||
|
protected static $sorted = false;
|
||||||
|
|
||||||
|
protected static $myMajorVersion = '';
|
||||||
|
protected static $latestCompatibleVersion = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper method for buildUpdateChecker() that reads the metadata URL from the plugin or theme header.
|
||||||
|
*
|
||||||
|
* @param string $fullPath Full path to the main plugin file or the theme's style.css.
|
||||||
|
* @param array $args Optional arguments. Keys should match the argument names of the buildUpdateChecker() method.
|
||||||
|
* @return Puc_v4p13_Plugin_UpdateChecker|Puc_v4p13_Theme_UpdateChecker|Puc_v4p13_Vcs_BaseChecker
|
||||||
|
*/
|
||||||
|
public static function buildFromHeader($fullPath, $args = array()) {
|
||||||
|
$fullPath = self::normalizePath($fullPath);
|
||||||
|
|
||||||
|
//Set up defaults.
|
||||||
|
$defaults = array(
|
||||||
|
'metadataUrl' => '',
|
||||||
|
'slug' => '',
|
||||||
|
'checkPeriod' => 12,
|
||||||
|
'optionName' => '',
|
||||||
|
'muPluginFile' => '',
|
||||||
|
);
|
||||||
|
$args = array_merge($defaults, array_intersect_key($args, $defaults));
|
||||||
|
extract($args, EXTR_SKIP);
|
||||||
|
|
||||||
|
//Check for the service URI
|
||||||
|
if ( empty($metadataUrl) ) {
|
||||||
|
$metadataUrl = self::getServiceURI($fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpUndefinedVariableInspection These variables are created by extract(), above. */
|
||||||
|
return self::buildUpdateChecker($metadataUrl, $fullPath, $slug, $checkPeriod, $optionName, $muPluginFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of the update checker.
|
||||||
|
*
|
||||||
|
* This method automatically detects if you're using it for a plugin or a theme and chooses
|
||||||
|
* the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
|
||||||
|
*
|
||||||
|
* @see Puc_v4p13_UpdateChecker::__construct
|
||||||
|
*
|
||||||
|
* @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
|
||||||
|
* @param string $fullPath Full path to the main plugin file or to the theme directory.
|
||||||
|
* @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
|
||||||
|
* @param int $checkPeriod How often to check for updates (in hours).
|
||||||
|
* @param string $optionName Where to store book-keeping info about update checks.
|
||||||
|
* @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
|
||||||
|
* @return Puc_v4p13_Plugin_UpdateChecker|Puc_v4p13_Theme_UpdateChecker|Puc_v4p13_Vcs_BaseChecker
|
||||||
|
*/
|
||||||
|
public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
|
||||||
|
$fullPath = self::normalizePath($fullPath);
|
||||||
|
$id = null;
|
||||||
|
|
||||||
|
//Plugin or theme?
|
||||||
|
$themeDirectory = self::getThemeDirectoryName($fullPath);
|
||||||
|
if ( self::isPluginFile($fullPath) ) {
|
||||||
|
$type = 'Plugin';
|
||||||
|
$id = $fullPath;
|
||||||
|
} else if ( $themeDirectory !== null ) {
|
||||||
|
$type = 'Theme';
|
||||||
|
$id = $themeDirectory;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(sprintf(
|
||||||
|
'The update checker cannot determine if "%s" is a plugin or a theme. ' .
|
||||||
|
'This is a bug. Please contact the PUC developer.',
|
||||||
|
htmlentities($fullPath)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Which hosting service does the URL point to?
|
||||||
|
$service = self::getVcsService($metadataUrl);
|
||||||
|
|
||||||
|
$apiClass = null;
|
||||||
|
if ( empty($service) ) {
|
||||||
|
//The default is to get update information from a remote JSON file.
|
||||||
|
$checkerClass = $type . '_UpdateChecker';
|
||||||
|
} else {
|
||||||
|
//You can also use a VCS repository like GitHub.
|
||||||
|
$checkerClass = 'Vcs_' . $type . 'UpdateChecker';
|
||||||
|
$apiClass = $service . 'Api';
|
||||||
|
}
|
||||||
|
|
||||||
|
$checkerClass = self::getCompatibleClassVersion($checkerClass);
|
||||||
|
if ( $checkerClass === null ) {
|
||||||
|
trigger_error(
|
||||||
|
sprintf(
|
||||||
|
'PUC %s does not support updates for %ss %s',
|
||||||
|
htmlentities(self::$latestCompatibleVersion),
|
||||||
|
strtolower($type),
|
||||||
|
$service ? ('hosted on ' . htmlentities($service)) : 'using JSON metadata'
|
||||||
|
),
|
||||||
|
E_USER_ERROR
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the current namespace to the class name(s).
|
||||||
|
if ( version_compare(PHP_VERSION, '5.3', '>=') ) {
|
||||||
|
$checkerClass = __NAMESPACE__ . '\\' . $checkerClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset($apiClass) ) {
|
||||||
|
//Plain old update checker.
|
||||||
|
return new $checkerClass($metadataUrl, $id, $slug, $checkPeriod, $optionName, $muPluginFile);
|
||||||
|
} else {
|
||||||
|
//VCS checker + an API client.
|
||||||
|
$apiClass = self::getCompatibleClassVersion($apiClass);
|
||||||
|
if ( $apiClass === null ) {
|
||||||
|
trigger_error(sprintf(
|
||||||
|
'PUC %s does not support %s',
|
||||||
|
htmlentities(self::$latestCompatibleVersion),
|
||||||
|
htmlentities($service)
|
||||||
|
), E_USER_ERROR);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare(PHP_VERSION, '5.3', '>=') && (strpos($apiClass, '\\') === false) ) {
|
||||||
|
$apiClass = __NAMESPACE__ . '\\' . $apiClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new $checkerClass(
|
||||||
|
new $apiClass($metadataUrl),
|
||||||
|
$id,
|
||||||
|
$slug,
|
||||||
|
$checkPeriod,
|
||||||
|
$optionName,
|
||||||
|
$muPluginFile
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Normalize a filesystem path. Introduced in WP 3.9.
|
||||||
|
* Copying here allows use of the class on earlier versions.
|
||||||
|
* This version adapted from WP 4.8.2 (unchanged since 4.5.0)
|
||||||
|
*
|
||||||
|
* @param string $path Path to normalize.
|
||||||
|
* @return string Normalized path.
|
||||||
|
*/
|
||||||
|
public static function normalizePath($path) {
|
||||||
|
if ( function_exists('wp_normalize_path') ) {
|
||||||
|
return wp_normalize_path($path);
|
||||||
|
}
|
||||||
|
$path = str_replace('\\', '/', $path);
|
||||||
|
$path = preg_replace('|(?<=.)/+|', '/', $path);
|
||||||
|
if ( substr($path, 1, 1) === ':' ) {
|
||||||
|
$path = ucfirst($path);
|
||||||
|
}
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the path points to a plugin file.
|
||||||
|
*
|
||||||
|
* @param string $absolutePath Normalized path.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function isPluginFile($absolutePath) {
|
||||||
|
//Is the file inside the "plugins" or "mu-plugins" directory?
|
||||||
|
$pluginDir = self::normalizePath(WP_PLUGIN_DIR);
|
||||||
|
$muPluginDir = self::normalizePath(WPMU_PLUGIN_DIR);
|
||||||
|
if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Is it a file at all? Caution: is_file() can fail if the parent dir. doesn't have the +x permission set.
|
||||||
|
if ( !is_file($absolutePath) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Does it have a valid plugin header?
|
||||||
|
//This is a last-ditch check for plugins symlinked from outside the WP root.
|
||||||
|
if ( function_exists('get_file_data') ) {
|
||||||
|
$headers = get_file_data($absolutePath, array('Name' => 'Plugin Name'), 'plugin');
|
||||||
|
return !empty($headers['Name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the theme's directory from a full path to a file inside that directory.
|
||||||
|
* E.g. "/abc/public_html/wp-content/themes/foo/whatever.php" => "foo".
|
||||||
|
*
|
||||||
|
* Note that subdirectories are currently not supported. For example,
|
||||||
|
* "/xyz/wp-content/themes/my-theme/includes/whatever.php" => NULL.
|
||||||
|
*
|
||||||
|
* @param string $absolutePath Normalized path.
|
||||||
|
* @return string|null Directory name, or NULL if the path doesn't point to a theme.
|
||||||
|
*/
|
||||||
|
protected static function getThemeDirectoryName($absolutePath) {
|
||||||
|
if ( is_file($absolutePath) ) {
|
||||||
|
$absolutePath = dirname($absolutePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( file_exists($absolutePath . '/style.css') ) {
|
||||||
|
return basename($absolutePath);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the service URI from the file header.
|
||||||
|
*
|
||||||
|
* @param string $fullPath
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function getServiceURI($fullPath) {
|
||||||
|
//Look for the URI
|
||||||
|
if ( is_readable($fullPath) ) {
|
||||||
|
$seek = array(
|
||||||
|
'github' => 'GitHub URI',
|
||||||
|
'gitlab' => 'GitLab URI',
|
||||||
|
'bucket' => 'BitBucket URI',
|
||||||
|
);
|
||||||
|
$seek = apply_filters('puc_get_source_uri', $seek);
|
||||||
|
$data = get_file_data($fullPath, $seek);
|
||||||
|
foreach ($data as $key => $uri) {
|
||||||
|
if ( $uri ) {
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//URI was not found so throw an error.
|
||||||
|
throw new RuntimeException(
|
||||||
|
sprintf('Unable to locate URI in header of "%s"', htmlentities($fullPath))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the hosting service that the URL points to.
|
||||||
|
*
|
||||||
|
* @param string $metadataUrl
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
private static function getVcsService($metadataUrl) {
|
||||||
|
$service = null;
|
||||||
|
|
||||||
|
//Which hosting service does the URL point to?
|
||||||
|
$host = parse_url($metadataUrl, PHP_URL_HOST);
|
||||||
|
$path = parse_url($metadataUrl, PHP_URL_PATH);
|
||||||
|
|
||||||
|
//Check if the path looks like "/user-name/repository".
|
||||||
|
//For GitLab.com it can also be "/user/group1/group2/.../repository".
|
||||||
|
$repoRegex = '@^/?([^/]+?)/([^/#?&]+?)/?$@';
|
||||||
|
if ( $host === 'gitlab.com' ) {
|
||||||
|
$repoRegex = '@^/?(?:[^/#?&]++/){1,20}(?:[^/#?&]++)/?$@';
|
||||||
|
}
|
||||||
|
if ( preg_match($repoRegex, $path) ) {
|
||||||
|
$knownServices = array(
|
||||||
|
'github.com' => 'GitHub',
|
||||||
|
'bitbucket.org' => 'BitBucket',
|
||||||
|
'gitlab.com' => 'GitLab',
|
||||||
|
);
|
||||||
|
if ( isset($knownServices[$host]) ) {
|
||||||
|
$service = $knownServices[$host];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return apply_filters('puc_get_vcs_service', $service, $host, $path, $metadataUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest version of the specified class that has the same major version number
|
||||||
|
* as this factory class.
|
||||||
|
*
|
||||||
|
* @param string $class Partial class name.
|
||||||
|
* @return string|null Full class name.
|
||||||
|
*/
|
||||||
|
protected static function getCompatibleClassVersion($class) {
|
||||||
|
if ( isset(self::$classVersions[$class][self::$latestCompatibleVersion]) ) {
|
||||||
|
return self::$classVersions[$class][self::$latestCompatibleVersion];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the specific class name for the latest available version of a class.
|
||||||
|
*
|
||||||
|
* @param string $class
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public static function getLatestClassVersion($class) {
|
||||||
|
if ( !self::$sorted ) {
|
||||||
|
self::sortVersions();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset(self::$classVersions[$class]) ) {
|
||||||
|
return reset(self::$classVersions[$class]);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort available class versions in descending order (i.e. newest first).
|
||||||
|
*/
|
||||||
|
protected static function sortVersions() {
|
||||||
|
foreach ( self::$classVersions as $class => $versions ) {
|
||||||
|
uksort($versions, array(__CLASS__, 'compareVersions'));
|
||||||
|
self::$classVersions[$class] = $versions;
|
||||||
|
}
|
||||||
|
self::$sorted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function compareVersions($a, $b) {
|
||||||
|
return -version_compare($a, $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a version of a class.
|
||||||
|
*
|
||||||
|
* @access private This method is only for internal use by the library.
|
||||||
|
*
|
||||||
|
* @param string $generalClass Class name without version numbers, e.g. 'PluginUpdateChecker'.
|
||||||
|
* @param string $versionedClass Actual class name, e.g. 'PluginUpdateChecker_1_2'.
|
||||||
|
* @param string $version Version number, e.g. '1.2'.
|
||||||
|
*/
|
||||||
|
public static function addVersion($generalClass, $versionedClass, $version) {
|
||||||
|
if ( empty(self::$myMajorVersion) ) {
|
||||||
|
$className = (version_compare(PHP_VERSION, '5.3', '>=') && __NAMESPACE__)
|
||||||
|
? substr(__CLASS__, strlen(__NAMESPACE__) + 1)
|
||||||
|
: __CLASS__;
|
||||||
|
|
||||||
|
$nameParts = explode('_', $className, 3);
|
||||||
|
self::$myMajorVersion = substr(ltrim($nameParts[1], 'v'), 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Store the greatest version number that matches our major version.
|
||||||
|
$components = explode('.', $version);
|
||||||
|
if ( $components[0] === self::$myMajorVersion ) {
|
||||||
|
|
||||||
|
if (
|
||||||
|
empty(self::$latestCompatibleVersion)
|
||||||
|
|| version_compare($version, self::$latestCompatibleVersion, '>')
|
||||||
|
) {
|
||||||
|
self::$latestCompatibleVersion = $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset(self::$classVersions[$generalClass]) ) {
|
||||||
|
self::$classVersions[$generalClass] = array();
|
||||||
|
}
|
||||||
|
self::$classVersions[$generalClass][$version] = $versionedClass;
|
||||||
|
self::$sorted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
103
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/InstalledPackage.php
vendored
Normal file
103
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/InstalledPackage.php
vendored
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_InstalledPackage', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a currently installed plugin or theme.
|
||||||
|
*
|
||||||
|
* Not to be confused with the "package" field in WP update API responses that contains
|
||||||
|
* the download URL of a the new version.
|
||||||
|
*/
|
||||||
|
abstract class Puc_v4p13_InstalledPackage {
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_UpdateChecker
|
||||||
|
*/
|
||||||
|
protected $updateChecker;
|
||||||
|
|
||||||
|
public function __construct($updateChecker) {
|
||||||
|
$this->updateChecker = $updateChecker;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the currently installed version of the plugin or theme.
|
||||||
|
*
|
||||||
|
* @return string|null Version number.
|
||||||
|
*/
|
||||||
|
abstract public function getInstalledVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the full path of the plugin or theme directory (without a trailing slash).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function getAbsoluteDirectoryPath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a regular file exists in the package's directory.
|
||||||
|
*
|
||||||
|
* @param string $relativeFileName File name relative to the package directory.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function fileExists($relativeFileName) {
|
||||||
|
return is_file(
|
||||||
|
$this->getAbsoluteDirectoryPath()
|
||||||
|
. DIRECTORY_SEPARATOR
|
||||||
|
. ltrim($relativeFileName, '/\\')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
* File header parsing
|
||||||
|
* -------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse plugin or theme metadata from the header comment.
|
||||||
|
*
|
||||||
|
* This is basically a simplified version of the get_file_data() function from /wp-includes/functions.php.
|
||||||
|
* It's intended as a utility for subclasses that detect updates by parsing files in a VCS.
|
||||||
|
*
|
||||||
|
* @param string|null $content File contents.
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getFileHeader($content) {
|
||||||
|
$content = (string)$content;
|
||||||
|
|
||||||
|
//WordPress only looks at the first 8 KiB of the file, so we do the same.
|
||||||
|
$content = substr($content, 0, 8192);
|
||||||
|
//Normalize line endings.
|
||||||
|
$content = str_replace("\r", "\n", $content);
|
||||||
|
|
||||||
|
$headers = $this->getHeaderNames();
|
||||||
|
$results = array();
|
||||||
|
foreach ($headers as $field => $name) {
|
||||||
|
$success = preg_match('/^[ \t\/*#@]*' . preg_quote($name, '/') . ':(.*)$/mi', $content, $matches);
|
||||||
|
|
||||||
|
if ( ($success === 1) && $matches[1] ) {
|
||||||
|
$value = $matches[1];
|
||||||
|
if ( function_exists('_cleanup_header_comment') ) {
|
||||||
|
$value = _cleanup_header_comment($value);
|
||||||
|
}
|
||||||
|
$results[$field] = $value;
|
||||||
|
} else {
|
||||||
|
$results[$field] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array Format: ['HeaderKey' => 'Header Name']
|
||||||
|
*/
|
||||||
|
abstract protected function getHeaderNames();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a specific plugin or theme header.
|
||||||
|
*
|
||||||
|
* @param string $headerName
|
||||||
|
* @return string Either the value of the header, or an empty string if the header doesn't exist.
|
||||||
|
*/
|
||||||
|
abstract public function getHeaderValue($headerName);
|
||||||
|
|
||||||
|
}
|
||||||
|
endif;
|
||||||
132
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Metadata.php
vendored
Normal file
132
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Metadata.php
vendored
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Metadata', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A base container for holding information about updates and plugin metadata.
|
||||||
|
*
|
||||||
|
* @author Janis Elsts
|
||||||
|
* @copyright 2016
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
abstract class Puc_v4p13_Metadata {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of this class from a JSON document.
|
||||||
|
*
|
||||||
|
* @abstract
|
||||||
|
* @param string $json
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function fromJson(/** @noinspection PhpUnusedParameterInspection */ $json) {
|
||||||
|
throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $json
|
||||||
|
* @param self $target
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected static function createFromJson($json, $target) {
|
||||||
|
/** @var StdClass $apiResponse */
|
||||||
|
$apiResponse = json_decode($json);
|
||||||
|
if ( empty($apiResponse) || !is_object($apiResponse) ){
|
||||||
|
$errorMessage = "Failed to parse update metadata. Try validating your .json file with http://jsonlint.com/";
|
||||||
|
do_action('puc_api_error', new WP_Error('puc-invalid-json', $errorMessage));
|
||||||
|
trigger_error($errorMessage, E_USER_NOTICE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$valid = $target->validateMetadata($apiResponse);
|
||||||
|
if ( is_wp_error($valid) ){
|
||||||
|
do_action('puc_api_error', $valid);
|
||||||
|
trigger_error($valid->get_error_message(), E_USER_NOTICE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(get_object_vars($apiResponse) as $key => $value){
|
||||||
|
$target->$key = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No validation by default! Subclasses should check that the required fields are present.
|
||||||
|
*
|
||||||
|
* @param StdClass $apiResponse
|
||||||
|
* @return bool|WP_Error
|
||||||
|
*/
|
||||||
|
protected function validateMetadata(/** @noinspection PhpUnusedParameterInspection */ $apiResponse) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance by copying the necessary fields from another object.
|
||||||
|
*
|
||||||
|
* @abstract
|
||||||
|
* @param StdClass|self $object The source object.
|
||||||
|
* @return self The new copy.
|
||||||
|
*/
|
||||||
|
public static function fromObject(/** @noinspection PhpUnusedParameterInspection */ $object) {
|
||||||
|
throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of StdClass that can later be converted back to an
|
||||||
|
* update or info container. Useful for serialization and caching, as it
|
||||||
|
* avoids the "incomplete object" problem if the cached value is loaded
|
||||||
|
* before this class.
|
||||||
|
*
|
||||||
|
* @return StdClass
|
||||||
|
*/
|
||||||
|
public function toStdClass() {
|
||||||
|
$object = new stdClass();
|
||||||
|
$this->copyFields($this, $object);
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the metadata into the format used by WordPress core.
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
abstract public function toWpFormat();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy known fields from one object to another.
|
||||||
|
*
|
||||||
|
* @param StdClass|self $from
|
||||||
|
* @param StdClass|self $to
|
||||||
|
*/
|
||||||
|
protected function copyFields($from, $to) {
|
||||||
|
$fields = $this->getFieldNames();
|
||||||
|
|
||||||
|
if ( property_exists($from, 'slug') && !empty($from->slug) ) {
|
||||||
|
//Let plugins add extra fields without having to create subclasses.
|
||||||
|
$fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
if ( property_exists($from, $field) ) {
|
||||||
|
$to->$field = $from->$field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
protected function getFieldNames() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $tag
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getPrefixedFilter($tag) {
|
||||||
|
return 'puc_' . $tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
100
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/OAuthSignature.php
vendored
Normal file
100
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/OAuthSignature.php
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_OAuthSignature', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A basic signature generator for zero-legged OAuth 1.0.
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_OAuthSignature {
|
||||||
|
private $consumerKey = '';
|
||||||
|
private $consumerSecret = '';
|
||||||
|
|
||||||
|
public function __construct($consumerKey, $consumerSecret) {
|
||||||
|
$this->consumerKey = $consumerKey;
|
||||||
|
$this->consumerSecret = $consumerSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sign a URL using OAuth 1.0.
|
||||||
|
*
|
||||||
|
* @param string $url The URL to be signed. It may contain query parameters.
|
||||||
|
* @param string $method HTTP method such as "GET", "POST" and so on.
|
||||||
|
* @return string The signed URL.
|
||||||
|
*/
|
||||||
|
public function sign($url, $method = 'GET') {
|
||||||
|
$parameters = array();
|
||||||
|
|
||||||
|
//Parse query parameters.
|
||||||
|
$query = parse_url($url, PHP_URL_QUERY);
|
||||||
|
if ( !empty($query) ) {
|
||||||
|
parse_str($query, $parsedParams);
|
||||||
|
if ( is_array($parameters) ) {
|
||||||
|
$parameters = $parsedParams;
|
||||||
|
}
|
||||||
|
//Remove the query string from the URL. We'll replace it later.
|
||||||
|
$url = substr($url, 0, strpos($url, '?'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$parameters = array_merge(
|
||||||
|
$parameters,
|
||||||
|
array(
|
||||||
|
'oauth_consumer_key' => $this->consumerKey,
|
||||||
|
'oauth_nonce' => $this->nonce(),
|
||||||
|
'oauth_signature_method' => 'HMAC-SHA1',
|
||||||
|
'oauth_timestamp' => time(),
|
||||||
|
'oauth_version' => '1.0',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
unset($parameters['oauth_signature']);
|
||||||
|
|
||||||
|
//Parameters must be sorted alphabetically before signing.
|
||||||
|
ksort($parameters);
|
||||||
|
|
||||||
|
//The most complicated part of the request - generating the signature.
|
||||||
|
//The string to sign contains the HTTP method, the URL path, and all of
|
||||||
|
//our query parameters. Everything is URL encoded. Then we concatenate
|
||||||
|
//them with ampersands into a single string to hash.
|
||||||
|
$encodedVerb = urlencode($method);
|
||||||
|
$encodedUrl = urlencode($url);
|
||||||
|
$encodedParams = urlencode(http_build_query($parameters, '', '&'));
|
||||||
|
|
||||||
|
$stringToSign = $encodedVerb . '&' . $encodedUrl . '&' . $encodedParams;
|
||||||
|
|
||||||
|
//Since we only have one OAuth token (the consumer secret) we only have
|
||||||
|
//to use it as our HMAC key. However, we still have to append an & to it
|
||||||
|
//as if we were using it with additional tokens.
|
||||||
|
$secret = urlencode($this->consumerSecret) . '&';
|
||||||
|
|
||||||
|
//The signature is a hash of the consumer key and the base string. Note
|
||||||
|
//that we have to get the raw output from hash_hmac and base64 encode
|
||||||
|
//the binary data result.
|
||||||
|
$parameters['oauth_signature'] = base64_encode(hash_hmac('sha1', $stringToSign, $secret, true));
|
||||||
|
|
||||||
|
return ($url . '?' . http_build_query($parameters));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a random nonce.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function nonce() {
|
||||||
|
$mt = microtime();
|
||||||
|
|
||||||
|
$rand = null;
|
||||||
|
if ( is_callable('random_bytes') ) {
|
||||||
|
try {
|
||||||
|
$rand = random_bytes(16);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
//Fall back to mt_rand (below).
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( $rand === null ) {
|
||||||
|
$rand = mt_rand();
|
||||||
|
}
|
||||||
|
|
||||||
|
return md5($mt . '_' . $rand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
132
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Info.php
vendored
Normal file
132
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Info.php
vendored
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Plugin_Info', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A container class for holding and transforming various plugin metadata.
|
||||||
|
*
|
||||||
|
* @author Janis Elsts
|
||||||
|
* @copyright 2016
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_Plugin_Info extends Puc_v4p13_Metadata {
|
||||||
|
//Most fields map directly to the contents of the plugin's info.json file.
|
||||||
|
//See the relevant docs for a description of their meaning.
|
||||||
|
public $name;
|
||||||
|
public $slug;
|
||||||
|
public $version;
|
||||||
|
public $homepage;
|
||||||
|
public $sections = array();
|
||||||
|
public $download_url;
|
||||||
|
|
||||||
|
public $banners;
|
||||||
|
public $icons = array();
|
||||||
|
public $translations = array();
|
||||||
|
|
||||||
|
public $author;
|
||||||
|
public $author_homepage;
|
||||||
|
|
||||||
|
public $requires;
|
||||||
|
public $tested;
|
||||||
|
public $requires_php;
|
||||||
|
public $upgrade_notice;
|
||||||
|
|
||||||
|
public $rating;
|
||||||
|
public $num_ratings;
|
||||||
|
public $downloaded;
|
||||||
|
public $active_installs;
|
||||||
|
public $last_updated;
|
||||||
|
|
||||||
|
public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything.
|
||||||
|
|
||||||
|
public $filename; //Plugin filename relative to the plugins directory.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of Plugin Info from JSON-encoded plugin info
|
||||||
|
* returned by an external update API.
|
||||||
|
*
|
||||||
|
* @param string $json Valid JSON string representing plugin info.
|
||||||
|
* @return self|null New instance of Plugin Info, or NULL on error.
|
||||||
|
*/
|
||||||
|
public static function fromJson($json){
|
||||||
|
$instance = new self();
|
||||||
|
|
||||||
|
if ( !parent::createFromJson($json, $instance) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//json_decode decodes assoc. arrays as objects. We want them as arrays.
|
||||||
|
$instance->sections = (array)$instance->sections;
|
||||||
|
$instance->icons = (array)$instance->icons;
|
||||||
|
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Very, very basic validation.
|
||||||
|
*
|
||||||
|
* @param StdClass $apiResponse
|
||||||
|
* @return bool|WP_Error
|
||||||
|
*/
|
||||||
|
protected function validateMetadata($apiResponse) {
|
||||||
|
if (
|
||||||
|
!isset($apiResponse->name, $apiResponse->version)
|
||||||
|
|| empty($apiResponse->name)
|
||||||
|
|| empty($apiResponse->version)
|
||||||
|
) {
|
||||||
|
return new WP_Error(
|
||||||
|
'puc-invalid-metadata',
|
||||||
|
"The plugin metadata file does not contain the required 'name' and/or 'version' keys."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform plugin info into the format used by the native WordPress.org API
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function toWpFormat(){
|
||||||
|
$info = new stdClass;
|
||||||
|
|
||||||
|
//The custom update API is built so that many fields have the same name and format
|
||||||
|
//as those returned by the native WordPress.org API. These can be assigned directly.
|
||||||
|
$sameFormat = array(
|
||||||
|
'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
|
||||||
|
'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated',
|
||||||
|
'requires_php',
|
||||||
|
);
|
||||||
|
foreach($sameFormat as $field){
|
||||||
|
if ( isset($this->$field) ) {
|
||||||
|
$info->$field = $this->$field;
|
||||||
|
} else {
|
||||||
|
$info->$field = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Other fields need to be renamed and/or transformed.
|
||||||
|
$info->download_link = $this->download_url;
|
||||||
|
$info->author = $this->getFormattedAuthor();
|
||||||
|
$info->sections = array_merge(array('description' => ''), $this->sections);
|
||||||
|
|
||||||
|
if ( !empty($this->banners) ) {
|
||||||
|
//WP expects an array with two keys: "high" and "low". Both are optional.
|
||||||
|
//Docs: https://wordpress.org/plugins/about/faq/#banners
|
||||||
|
$info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners;
|
||||||
|
$info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFormattedAuthor() {
|
||||||
|
if ( !empty($this->author_homepage) ){
|
||||||
|
/** @noinspection HtmlUnknownTarget */
|
||||||
|
return sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author);
|
||||||
|
}
|
||||||
|
return $this->author;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
184
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Package.php
vendored
Normal file
184
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Package.php
vendored
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Plugin_Package', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Plugin_Package extends Puc_v4p13_InstalledPackage {
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Plugin_UpdateChecker
|
||||||
|
*/
|
||||||
|
protected $updateChecker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Full path of the main plugin file.
|
||||||
|
*/
|
||||||
|
protected $pluginAbsolutePath = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Plugin basename.
|
||||||
|
*/
|
||||||
|
private $pluginFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
private $cachedInstalledVersion = null;
|
||||||
|
|
||||||
|
public function __construct($pluginAbsolutePath, $updateChecker) {
|
||||||
|
$this->pluginAbsolutePath = $pluginAbsolutePath;
|
||||||
|
$this->pluginFile = plugin_basename($this->pluginAbsolutePath);
|
||||||
|
|
||||||
|
parent::__construct($updateChecker);
|
||||||
|
|
||||||
|
//Clear the version number cache when something - anything - is upgraded or WP clears the update cache.
|
||||||
|
add_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
|
||||||
|
add_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInstalledVersion() {
|
||||||
|
if ( isset($this->cachedInstalledVersion) ) {
|
||||||
|
return $this->cachedInstalledVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pluginHeader = $this->getPluginHeader();
|
||||||
|
if ( isset($pluginHeader['Version']) ) {
|
||||||
|
$this->cachedInstalledVersion = $pluginHeader['Version'];
|
||||||
|
return $pluginHeader['Version'];
|
||||||
|
} else {
|
||||||
|
//This can happen if the filename points to something that is not a plugin.
|
||||||
|
$this->updateChecker->triggerError(
|
||||||
|
sprintf(
|
||||||
|
"Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.",
|
||||||
|
$this->updateChecker->pluginFile
|
||||||
|
),
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the cached plugin version. This method can be set up as a filter (hook) and will
|
||||||
|
* return the filter argument unmodified.
|
||||||
|
*
|
||||||
|
* @param mixed $filterArgument
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function clearCachedVersion($filterArgument = null) {
|
||||||
|
$this->cachedInstalledVersion = null;
|
||||||
|
return $filterArgument;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAbsoluteDirectoryPath() {
|
||||||
|
return dirname($this->pluginAbsolutePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a specific plugin or theme header.
|
||||||
|
*
|
||||||
|
* @param string $headerName
|
||||||
|
* @param string $defaultValue
|
||||||
|
* @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty.
|
||||||
|
*/
|
||||||
|
public function getHeaderValue($headerName, $defaultValue = '') {
|
||||||
|
$headers = $this->getPluginHeader();
|
||||||
|
if ( isset($headers[$headerName]) && ($headers[$headerName] !== '') ) {
|
||||||
|
return $headers[$headerName];
|
||||||
|
}
|
||||||
|
return $defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeaderNames() {
|
||||||
|
return array(
|
||||||
|
'Name' => 'Plugin Name',
|
||||||
|
'PluginURI' => 'Plugin URI',
|
||||||
|
'Version' => 'Version',
|
||||||
|
'Description' => 'Description',
|
||||||
|
'Author' => 'Author',
|
||||||
|
'AuthorURI' => 'Author URI',
|
||||||
|
'TextDomain' => 'Text Domain',
|
||||||
|
'DomainPath' => 'Domain Path',
|
||||||
|
'Network' => 'Network',
|
||||||
|
|
||||||
|
//The newest WordPress version that this plugin requires or has been tested with.
|
||||||
|
//We support several different formats for compatibility with other libraries.
|
||||||
|
'Tested WP' => 'Tested WP',
|
||||||
|
'Requires WP' => 'Requires WP',
|
||||||
|
'Tested up to' => 'Tested up to',
|
||||||
|
'Requires at least' => 'Requires at least',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the translated plugin title.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPluginTitle() {
|
||||||
|
$title = '';
|
||||||
|
$header = $this->getPluginHeader();
|
||||||
|
if ( $header && !empty($header['Name']) && isset($header['TextDomain']) ) {
|
||||||
|
$title = translate($header['Name'], $header['TextDomain']);
|
||||||
|
}
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin's metadata from its file header.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getPluginHeader() {
|
||||||
|
if ( !is_file($this->pluginAbsolutePath) ) {
|
||||||
|
//This can happen if the plugin filename is wrong.
|
||||||
|
$this->updateChecker->triggerError(
|
||||||
|
sprintf(
|
||||||
|
"Can't to read the plugin header for '%s'. The file does not exist.",
|
||||||
|
$this->updateChecker->pluginFile
|
||||||
|
),
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !function_exists('get_plugin_data') ) {
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
require_once(ABSPATH . '/wp-admin/includes/plugin.php');
|
||||||
|
}
|
||||||
|
return get_plugin_data($this->pluginAbsolutePath, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeHooks() {
|
||||||
|
remove_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
|
||||||
|
remove_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the plugin file is inside the mu-plugins directory.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isMuPlugin() {
|
||||||
|
static $cachedResult = null;
|
||||||
|
|
||||||
|
if ( $cachedResult === null ) {
|
||||||
|
if ( !defined('WPMU_PLUGIN_DIR') || !is_string(WPMU_PLUGIN_DIR) ) {
|
||||||
|
$cachedResult = false;
|
||||||
|
return $cachedResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Convert both paths to the canonical form before comparison.
|
||||||
|
$muPluginDir = realpath(WPMU_PLUGIN_DIR);
|
||||||
|
$pluginPath = realpath($this->pluginAbsolutePath);
|
||||||
|
//If realpath() fails, just normalize the syntax instead.
|
||||||
|
if (($muPluginDir === false) || ($pluginPath === false)) {
|
||||||
|
$muPluginDir = Puc_v4p13_Factory::normalizePath(WPMU_PLUGIN_DIR);
|
||||||
|
$pluginPath = Puc_v4p13_Factory::normalizePath($this->pluginAbsolutePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cachedResult = (strpos($pluginPath, $muPluginDir) === 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cachedResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
278
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Ui.php
vendored
Normal file
278
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Ui.php
vendored
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Plugin_Ui', false) ):
|
||||||
|
/**
|
||||||
|
* Additional UI elements for plugins.
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_Plugin_Ui {
|
||||||
|
private $updateChecker;
|
||||||
|
private $manualCheckErrorTransient = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Puc_v4p13_Plugin_UpdateChecker $updateChecker
|
||||||
|
*/
|
||||||
|
public function __construct($updateChecker) {
|
||||||
|
$this->updateChecker = $updateChecker;
|
||||||
|
$this->manualCheckErrorTransient = $this->updateChecker->getUniqueName('manual_check_errors');
|
||||||
|
|
||||||
|
add_action('admin_init', array($this, 'onAdminInit'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onAdminInit() {
|
||||||
|
if ( $this->updateChecker->userCanInstallUpdates() ) {
|
||||||
|
$this->handleManualCheck();
|
||||||
|
|
||||||
|
add_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10, 3);
|
||||||
|
add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2);
|
||||||
|
add_action('all_admin_notices', array($this, 'displayManualCheckResult'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a "View Details" link to the plugin row in the "Plugins" page. By default,
|
||||||
|
* the new link will appear before the "Visit plugin site" link (if present).
|
||||||
|
*
|
||||||
|
* You can change the link text by using the "puc_view_details_link-$slug" filter.
|
||||||
|
* Returning an empty string from the filter will disable the link.
|
||||||
|
*
|
||||||
|
* You can change the position of the link using the
|
||||||
|
* "puc_view_details_link_position-$slug" filter.
|
||||||
|
* Returning 'before' or 'after' will place the link immediately before/after
|
||||||
|
* the "Visit plugin site" link.
|
||||||
|
* Returning 'append' places the link after any existing links at the time of the hook.
|
||||||
|
* Returning 'replace' replaces the "Visit plugin site" link.
|
||||||
|
* Returning anything else disables the link when there is a "Visit plugin site" link.
|
||||||
|
*
|
||||||
|
* If there is no "Visit plugin site" link 'append' is always used!
|
||||||
|
*
|
||||||
|
* @param array $pluginMeta Array of meta links.
|
||||||
|
* @param string $pluginFile
|
||||||
|
* @param array $pluginData Array of plugin header data.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function addViewDetailsLink($pluginMeta, $pluginFile, $pluginData = array()) {
|
||||||
|
if ( $this->isMyPluginFile($pluginFile) && !isset($pluginData['slug']) ) {
|
||||||
|
$linkText = apply_filters($this->updateChecker->getUniqueName('view_details_link'), __('View details'));
|
||||||
|
if ( !empty($linkText) ) {
|
||||||
|
$viewDetailsLinkPosition = 'append';
|
||||||
|
|
||||||
|
//Find the "Visit plugin site" link (if present).
|
||||||
|
$visitPluginSiteLinkIndex = count($pluginMeta) - 1;
|
||||||
|
if ( $pluginData['PluginURI'] ) {
|
||||||
|
$escapedPluginUri = esc_url($pluginData['PluginURI']);
|
||||||
|
foreach ($pluginMeta as $linkIndex => $existingLink) {
|
||||||
|
if ( strpos($existingLink, $escapedPluginUri) !== false ) {
|
||||||
|
$visitPluginSiteLinkIndex = $linkIndex;
|
||||||
|
$viewDetailsLinkPosition = apply_filters(
|
||||||
|
$this->updateChecker->getUniqueName('view_details_link_position'),
|
||||||
|
'before'
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewDetailsLink = sprintf('<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
|
||||||
|
esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin=' . urlencode($this->updateChecker->slug) .
|
||||||
|
'&TB_iframe=true&width=600&height=550')),
|
||||||
|
esc_attr(sprintf(__('More information about %s'), $pluginData['Name'])),
|
||||||
|
esc_attr($pluginData['Name']),
|
||||||
|
$linkText
|
||||||
|
);
|
||||||
|
switch ($viewDetailsLinkPosition) {
|
||||||
|
case 'before':
|
||||||
|
array_splice($pluginMeta, $visitPluginSiteLinkIndex, 0, $viewDetailsLink);
|
||||||
|
break;
|
||||||
|
case 'after':
|
||||||
|
array_splice($pluginMeta, $visitPluginSiteLinkIndex + 1, 0, $viewDetailsLink);
|
||||||
|
break;
|
||||||
|
case 'replace':
|
||||||
|
$pluginMeta[$visitPluginSiteLinkIndex] = $viewDetailsLink;
|
||||||
|
break;
|
||||||
|
case 'append':
|
||||||
|
default:
|
||||||
|
$pluginMeta[] = $viewDetailsLink;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pluginMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
|
||||||
|
* the new link will appear after the "Visit plugin site" link if present, otherwise
|
||||||
|
* after the "View plugin details" link.
|
||||||
|
*
|
||||||
|
* You can change the link text by using the "puc_manual_check_link-$slug" filter.
|
||||||
|
* Returning an empty string from the filter will disable the link.
|
||||||
|
*
|
||||||
|
* @param array $pluginMeta Array of meta links.
|
||||||
|
* @param string $pluginFile
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function addCheckForUpdatesLink($pluginMeta, $pluginFile) {
|
||||||
|
if ( $this->isMyPluginFile($pluginFile) ) {
|
||||||
|
$linkUrl = wp_nonce_url(
|
||||||
|
add_query_arg(
|
||||||
|
array(
|
||||||
|
'puc_check_for_updates' => 1,
|
||||||
|
'puc_slug' => $this->updateChecker->slug,
|
||||||
|
),
|
||||||
|
self_admin_url('plugins.php')
|
||||||
|
),
|
||||||
|
'puc_check_for_updates'
|
||||||
|
);
|
||||||
|
|
||||||
|
$linkText = apply_filters(
|
||||||
|
$this->updateChecker->getUniqueName('manual_check_link'),
|
||||||
|
__('Check for updates', 'plugin-update-checker')
|
||||||
|
);
|
||||||
|
if ( !empty($linkText) ) {
|
||||||
|
/** @noinspection HtmlUnknownTarget */
|
||||||
|
$pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pluginMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isMyPluginFile($pluginFile) {
|
||||||
|
return ($pluginFile == $this->updateChecker->pluginFile)
|
||||||
|
|| (!empty($this->updateChecker->muPluginFile) && ($pluginFile == $this->updateChecker->muPluginFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for updates when the user clicks the "Check for updates" link.
|
||||||
|
*
|
||||||
|
* @see self::addCheckForUpdatesLink()
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handleManualCheck() {
|
||||||
|
$shouldCheck =
|
||||||
|
isset($_GET['puc_check_for_updates'], $_GET['puc_slug'])
|
||||||
|
&& $_GET['puc_slug'] == $this->updateChecker->slug
|
||||||
|
&& check_admin_referer('puc_check_for_updates');
|
||||||
|
|
||||||
|
if ( $shouldCheck ) {
|
||||||
|
$update = $this->updateChecker->checkForUpdates();
|
||||||
|
$status = ($update === null) ? 'no_update' : 'update_available';
|
||||||
|
$lastRequestApiErrors = $this->updateChecker->getLastRequestApiErrors();
|
||||||
|
|
||||||
|
if ( ($update === null) && !empty($lastRequestApiErrors) ) {
|
||||||
|
//Some errors are not critical. For example, if PUC tries to retrieve the readme.txt
|
||||||
|
//file from GitHub and gets a 404, that's an API error, but it doesn't prevent updates
|
||||||
|
//from working. Maybe the plugin simply doesn't have a readme.
|
||||||
|
//Let's only show important errors.
|
||||||
|
$foundCriticalErrors = false;
|
||||||
|
$questionableErrorCodes = array(
|
||||||
|
'puc-github-http-error',
|
||||||
|
'puc-gitlab-http-error',
|
||||||
|
'puc-bitbucket-http-error',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($lastRequestApiErrors as $item) {
|
||||||
|
$wpError = $item['error'];
|
||||||
|
/** @var WP_Error $wpError */
|
||||||
|
if ( !in_array($wpError->get_error_code(), $questionableErrorCodes) ) {
|
||||||
|
$foundCriticalErrors = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $foundCriticalErrors ) {
|
||||||
|
$status = 'error';
|
||||||
|
set_site_transient($this->manualCheckErrorTransient, $lastRequestApiErrors, 60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_redirect(add_query_arg(
|
||||||
|
array(
|
||||||
|
'puc_update_check_result' => $status,
|
||||||
|
'puc_slug' => $this->updateChecker->slug,
|
||||||
|
),
|
||||||
|
self_admin_url('plugins.php')
|
||||||
|
));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the results of a manual update check.
|
||||||
|
*
|
||||||
|
* @see self::handleManualCheck()
|
||||||
|
*
|
||||||
|
* You can change the result message by using the "puc_manual_check_message-$slug" filter.
|
||||||
|
*/
|
||||||
|
public function displayManualCheckResult() {
|
||||||
|
if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->updateChecker->slug) ) {
|
||||||
|
$status = strval($_GET['puc_update_check_result']);
|
||||||
|
$title = $this->updateChecker->getInstalledPackage()->getPluginTitle();
|
||||||
|
$noticeClass = 'updated notice-success';
|
||||||
|
$details = '';
|
||||||
|
|
||||||
|
if ( $status == 'no_update' ) {
|
||||||
|
$message = sprintf(_x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title);
|
||||||
|
} else if ( $status == 'update_available' ) {
|
||||||
|
$message = sprintf(_x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title);
|
||||||
|
} else if ( $status === 'error' ) {
|
||||||
|
$message = sprintf(_x('Could not determine if updates are available for %s.', 'the plugin title', 'plugin-update-checker'), $title);
|
||||||
|
$noticeClass = 'error notice-error';
|
||||||
|
|
||||||
|
$details = $this->formatManualCheckErrors(get_site_transient($this->manualCheckErrorTransient));
|
||||||
|
delete_site_transient($this->manualCheckErrorTransient);
|
||||||
|
} else {
|
||||||
|
$message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status));
|
||||||
|
$noticeClass = 'error notice-error';
|
||||||
|
}
|
||||||
|
printf(
|
||||||
|
'<div class="notice %s is-dismissible"><p>%s</p>%s</div>',
|
||||||
|
$noticeClass,
|
||||||
|
apply_filters($this->updateChecker->getUniqueName('manual_check_message'), $message, $status),
|
||||||
|
$details
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the list of errors that were thrown during an update check.
|
||||||
|
*
|
||||||
|
* @param array $errors
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function formatManualCheckErrors($errors) {
|
||||||
|
if ( empty($errors) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
$showAsList = count($errors) > 1;
|
||||||
|
if ( $showAsList ) {
|
||||||
|
$output .= '<ol>';
|
||||||
|
$formatString = '<li>%1$s <code>%2$s</code></li>';
|
||||||
|
} else {
|
||||||
|
$formatString = '<p>%1$s <code>%2$s</code></p>';
|
||||||
|
}
|
||||||
|
foreach ($errors as $item) {
|
||||||
|
$wpError = $item['error'];
|
||||||
|
/** @var WP_Error $wpError */
|
||||||
|
$output .= sprintf(
|
||||||
|
$formatString,
|
||||||
|
$wpError->get_error_message(),
|
||||||
|
$wpError->get_error_code()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ( $showAsList ) {
|
||||||
|
$output .= '</ol>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeHooks() {
|
||||||
|
remove_action('admin_init', array($this, 'onAdminInit'));
|
||||||
|
remove_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10);
|
||||||
|
remove_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10);
|
||||||
|
remove_action('all_admin_notices', array($this, 'displayManualCheckResult'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endif;
|
||||||
112
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Update.php
vendored
Normal file
112
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/Update.php
vendored
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Plugin_Update', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple container class for holding information about an available update.
|
||||||
|
*
|
||||||
|
* @author Janis Elsts
|
||||||
|
* @copyright 2016
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_Plugin_Update extends Puc_v4p13_Update {
|
||||||
|
public $id = 0;
|
||||||
|
public $homepage;
|
||||||
|
public $upgrade_notice;
|
||||||
|
public $tested;
|
||||||
|
public $requires_php = false;
|
||||||
|
public $icons = array();
|
||||||
|
public $filename; //Plugin filename relative to the plugins directory.
|
||||||
|
|
||||||
|
protected static $extraFields = array(
|
||||||
|
'id', 'homepage', 'tested', 'requires_php', 'upgrade_notice', 'icons', 'filename',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of PluginUpdate from its JSON-encoded representation.
|
||||||
|
*
|
||||||
|
* @param string $json
|
||||||
|
* @return Puc_v4p13_Plugin_Update|null
|
||||||
|
*/
|
||||||
|
public static function fromJson($json){
|
||||||
|
//Since update-related information is simply a subset of the full plugin info,
|
||||||
|
//we can parse the update JSON as if it was a plugin info string, then copy over
|
||||||
|
//the parts that we care about.
|
||||||
|
$pluginInfo = Puc_v4p13_Plugin_Info::fromJson($json);
|
||||||
|
if ( $pluginInfo !== null ) {
|
||||||
|
return self::fromPluginInfo($pluginInfo);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of PluginUpdate based on an instance of PluginInfo.
|
||||||
|
* Basically, this just copies a subset of fields from one object to another.
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_Plugin_Info $info
|
||||||
|
* @return Puc_v4p13_Plugin_Update
|
||||||
|
*/
|
||||||
|
public static function fromPluginInfo($info){
|
||||||
|
return self::fromObject($info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance by copying the necessary fields from another object.
|
||||||
|
*
|
||||||
|
* @param StdClass|Puc_v4p13_Plugin_Info|Puc_v4p13_Plugin_Update $object The source object.
|
||||||
|
* @return Puc_v4p13_Plugin_Update The new copy.
|
||||||
|
*/
|
||||||
|
public static function fromObject($object) {
|
||||||
|
$update = new self();
|
||||||
|
$update->copyFields($object, $update);
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
protected function getFieldNames() {
|
||||||
|
return array_merge(parent::getFieldNames(), self::$extraFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the update into the format used by WordPress native plugin API.
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function toWpFormat() {
|
||||||
|
$update = parent::toWpFormat();
|
||||||
|
|
||||||
|
$update->id = $this->id;
|
||||||
|
$update->url = $this->homepage;
|
||||||
|
$update->tested = $this->tested;
|
||||||
|
$update->requires_php = $this->requires_php;
|
||||||
|
$update->plugin = $this->filename;
|
||||||
|
|
||||||
|
if ( !empty($this->upgrade_notice) ) {
|
||||||
|
$update->upgrade_notice = $this->upgrade_notice;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($this->icons) && is_array($this->icons) ) {
|
||||||
|
//This should be an array with up to 4 keys: 'svg', '1x', '2x' and 'default'.
|
||||||
|
//Docs: https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-icons
|
||||||
|
$icons = array_intersect_key(
|
||||||
|
$this->icons,
|
||||||
|
array('svg' => true, '1x' => true, '2x' => true, 'default' => true)
|
||||||
|
);
|
||||||
|
if ( !empty($icons) ) {
|
||||||
|
$update->icons = $icons;
|
||||||
|
|
||||||
|
//It appears that the 'default' icon isn't used anywhere in WordPress 4.9,
|
||||||
|
//but lets set it just in case a future release needs it.
|
||||||
|
if ( !isset($update->icons['default']) ) {
|
||||||
|
$update->icons['default'] = current($update->icons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
414
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/UpdateChecker.php
vendored
Normal file
414
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Plugin/UpdateChecker.php
vendored
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Plugin_UpdateChecker', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom plugin update checker.
|
||||||
|
*
|
||||||
|
* @author Janis Elsts
|
||||||
|
* @copyright 2018
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_Plugin_UpdateChecker extends Puc_v4p13_UpdateChecker {
|
||||||
|
protected $updateTransient = 'update_plugins';
|
||||||
|
protected $translationType = 'plugin';
|
||||||
|
|
||||||
|
public $pluginAbsolutePath = ''; //Full path of the main plugin file.
|
||||||
|
public $pluginFile = ''; //Plugin filename relative to the plugins directory. Many WP APIs use this to identify plugins.
|
||||||
|
public $muPluginFile = ''; //For MU plugins, the plugin filename relative to the mu-plugins directory.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Plugin_Package
|
||||||
|
*/
|
||||||
|
protected $package;
|
||||||
|
|
||||||
|
private $extraUi = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param string $metadataUrl The URL of the plugin's metadata file.
|
||||||
|
* @param string $pluginFile Fully qualified path to the main plugin file.
|
||||||
|
* @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
|
||||||
|
* @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
|
||||||
|
* @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
|
||||||
|
* @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory.
|
||||||
|
*/
|
||||||
|
public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = ''){
|
||||||
|
$this->pluginAbsolutePath = $pluginFile;
|
||||||
|
$this->pluginFile = plugin_basename($this->pluginAbsolutePath);
|
||||||
|
$this->muPluginFile = $muPluginFile;
|
||||||
|
|
||||||
|
//If no slug is specified, use the name of the main plugin file as the slug.
|
||||||
|
//For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
|
||||||
|
if ( empty($slug) ){
|
||||||
|
$slug = basename($this->pluginFile, '.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Plugin slugs must be unique.
|
||||||
|
$slugCheckFilter = 'puc_is_slug_in_use-' . $slug;
|
||||||
|
$slugUsedBy = apply_filters($slugCheckFilter, false);
|
||||||
|
if ( $slugUsedBy ) {
|
||||||
|
$this->triggerError(sprintf(
|
||||||
|
'Plugin slug "%s" is already in use by %s. Slugs must be unique.',
|
||||||
|
htmlentities($slug),
|
||||||
|
htmlentities($slugUsedBy)
|
||||||
|
), E_USER_ERROR);
|
||||||
|
}
|
||||||
|
add_filter($slugCheckFilter, array($this, 'getAbsolutePath'));
|
||||||
|
|
||||||
|
parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName);
|
||||||
|
|
||||||
|
//Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume
|
||||||
|
//it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir).
|
||||||
|
if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) {
|
||||||
|
$this->muPluginFile = $this->pluginFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
//To prevent a crash during plugin uninstallation, remove updater hooks when the user removes the plugin.
|
||||||
|
//Details: https://github.com/YahnisElsts/plugin-update-checker/issues/138#issuecomment-335590964
|
||||||
|
add_action('uninstall_' . $this->pluginFile, array($this, 'removeHooks'));
|
||||||
|
|
||||||
|
$this->extraUi = new Puc_v4p13_Plugin_Ui($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of the scheduler.
|
||||||
|
*
|
||||||
|
* @param int $checkPeriod
|
||||||
|
* @return Puc_v4p13_Scheduler
|
||||||
|
*/
|
||||||
|
protected function createScheduler($checkPeriod) {
|
||||||
|
$scheduler = new Puc_v4p13_Scheduler($this, $checkPeriod, array('load-plugins.php'));
|
||||||
|
register_deactivation_hook($this->pluginFile, array($scheduler, 'removeUpdaterCron'));
|
||||||
|
return $scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install the hooks required to run periodic update checks and inject update info
|
||||||
|
* into WP data structures.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function installHooks(){
|
||||||
|
//Override requests for plugin information
|
||||||
|
add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
|
||||||
|
|
||||||
|
parent::installHooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove update checker hooks.
|
||||||
|
*
|
||||||
|
* The intent is to prevent a fatal error that can happen if the plugin has an uninstall
|
||||||
|
* hook. During uninstallation, WP includes the main plugin file (which creates a PUC instance),
|
||||||
|
* the uninstall hook runs, WP deletes the plugin files and then updates some transients.
|
||||||
|
* If PUC hooks are still around at this time, they could throw an error while trying to
|
||||||
|
* autoload classes from files that no longer exist.
|
||||||
|
*
|
||||||
|
* The "site_transient_{$transient}" filter is the main problem here, but let's also remove
|
||||||
|
* most other PUC hooks to be safe.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public function removeHooks() {
|
||||||
|
parent::removeHooks();
|
||||||
|
$this->extraUi->removeHooks();
|
||||||
|
$this->package->removeHooks();
|
||||||
|
|
||||||
|
remove_filter('plugins_api', array($this, 'injectInfo'), 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve plugin info from the configured API endpoint.
|
||||||
|
*
|
||||||
|
* @uses wp_remote_get()
|
||||||
|
*
|
||||||
|
* @param array $queryArgs Additional query arguments to append to the request. Optional.
|
||||||
|
* @return Puc_v4p13_Plugin_Info
|
||||||
|
*/
|
||||||
|
public function requestInfo($queryArgs = array()) {
|
||||||
|
list($pluginInfo, $result) = $this->requestMetadata('Puc_v4p13_Plugin_Info', 'request_info', $queryArgs);
|
||||||
|
|
||||||
|
if ( $pluginInfo !== null ) {
|
||||||
|
/** @var Puc_v4p13_Plugin_Info $pluginInfo */
|
||||||
|
$pluginInfo->filename = $this->pluginFile;
|
||||||
|
$pluginInfo->slug = $this->slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pluginInfo = apply_filters($this->getUniqueName('request_info_result'), $pluginInfo, $result);
|
||||||
|
return $pluginInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the latest update (if any) from the configured API endpoint.
|
||||||
|
*
|
||||||
|
* @uses PluginUpdateChecker::requestInfo()
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Update|null An instance of Plugin_Update, or NULL when no updates are available.
|
||||||
|
*/
|
||||||
|
public function requestUpdate() {
|
||||||
|
//For the sake of simplicity, this function just calls requestInfo()
|
||||||
|
//and transforms the result accordingly.
|
||||||
|
$pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
|
||||||
|
if ( $pluginInfo === null ){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$update = Puc_v4p13_Plugin_Update::fromPluginInfo($pluginInfo);
|
||||||
|
|
||||||
|
$update = $this->filterUpdateResult($update);
|
||||||
|
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intercept plugins_api() calls that request information about our plugin and
|
||||||
|
* use the configured API endpoint to satisfy them.
|
||||||
|
*
|
||||||
|
* @see plugins_api()
|
||||||
|
*
|
||||||
|
* @param mixed $result
|
||||||
|
* @param string $action
|
||||||
|
* @param array|object $args
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function injectInfo($result, $action = null, $args = null){
|
||||||
|
$relevant = ($action == 'plugin_information') && isset($args->slug) && (
|
||||||
|
($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile))
|
||||||
|
);
|
||||||
|
if ( !$relevant ) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pluginInfo = $this->requestInfo();
|
||||||
|
$this->fixSupportedWordpressVersion($pluginInfo);
|
||||||
|
|
||||||
|
$pluginInfo = apply_filters($this->getUniqueName('pre_inject_info'), $pluginInfo);
|
||||||
|
if ( $pluginInfo ) {
|
||||||
|
return $pluginInfo->toWpFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function shouldShowUpdates() {
|
||||||
|
//No update notifications for mu-plugins unless explicitly enabled. The MU plugin file
|
||||||
|
//is usually different from the main plugin file so the update wouldn't show up properly anyway.
|
||||||
|
return !$this->isUnknownMuPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stdClass|null $updates
|
||||||
|
* @param stdClass $updateToAdd
|
||||||
|
* @return stdClass
|
||||||
|
*/
|
||||||
|
protected function addUpdateToList($updates, $updateToAdd) {
|
||||||
|
if ( $this->package->isMuPlugin() ) {
|
||||||
|
//WP does not support automatic update installation for mu-plugins, but we can
|
||||||
|
//still display a notice.
|
||||||
|
$updateToAdd->package = null;
|
||||||
|
}
|
||||||
|
return parent::addUpdateToList($updates, $updateToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stdClass|null $updates
|
||||||
|
* @return stdClass|null
|
||||||
|
*/
|
||||||
|
protected function removeUpdateFromList($updates) {
|
||||||
|
$updates = parent::removeUpdateFromList($updates);
|
||||||
|
if ( !empty($this->muPluginFile) && isset($updates, $updates->response) ) {
|
||||||
|
unset($updates->response[$this->muPluginFile]);
|
||||||
|
}
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For plugins, the update array is indexed by the plugin filename relative to the "plugins"
|
||||||
|
* directory. Example: "plugin-name/plugin.php".
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getUpdateListKey() {
|
||||||
|
if ( $this->package->isMuPlugin() ) {
|
||||||
|
return $this->muPluginFile;
|
||||||
|
}
|
||||||
|
return $this->pluginFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getNoUpdateItemFields() {
|
||||||
|
return array_merge(
|
||||||
|
parent::getNoUpdateItemFields(),
|
||||||
|
array(
|
||||||
|
'id' => $this->pluginFile,
|
||||||
|
'slug' => $this->slug,
|
||||||
|
'plugin' => $this->pluginFile,
|
||||||
|
'icons' => array(),
|
||||||
|
'banners' => array(),
|
||||||
|
'banners_rtl' => array(),
|
||||||
|
'tested' => '',
|
||||||
|
'compatibility' => new stdClass(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for isBeingUpgraded().
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
* @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isPluginBeingUpgraded($upgrader = null) {
|
||||||
|
return $this->isBeingUpgraded($upgrader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there an update being installed for this plugin, right now?
|
||||||
|
*
|
||||||
|
* @param WP_Upgrader|null $upgrader
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isBeingUpgraded($upgrader = null) {
|
||||||
|
return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the details of the currently available update, if any.
|
||||||
|
*
|
||||||
|
* If no updates are available, or if the last known update version is below or equal
|
||||||
|
* to the currently installed version, this method will return NULL.
|
||||||
|
*
|
||||||
|
* Uses cached update data. To retrieve update information straight from
|
||||||
|
* the metadata URL, call requestUpdate() instead.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Plugin_Update|null
|
||||||
|
*/
|
||||||
|
public function getUpdate() {
|
||||||
|
$update = parent::getUpdate();
|
||||||
|
if ( isset($update) ) {
|
||||||
|
/** @var Puc_v4p13_Plugin_Update $update */
|
||||||
|
$update->filename = $this->pluginFile;
|
||||||
|
}
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the translated plugin title.
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPluginTitle() {
|
||||||
|
return $this->package->getPluginTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current user has the required permissions to install updates.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function userCanInstallUpdates() {
|
||||||
|
return current_user_can('update_plugins');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the plugin file is inside the mu-plugins directory.
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isMuPlugin() {
|
||||||
|
return $this->package->isMuPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MU plugins are partially supported, but only when we know which file in mu-plugins
|
||||||
|
* corresponds to this plugin.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isUnknownMuPlugin() {
|
||||||
|
return empty($this->muPluginFile) && $this->package->isMuPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get absolute path to the main plugin file.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAbsolutePath() {
|
||||||
|
return $this->pluginAbsolutePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback for filtering query arguments.
|
||||||
|
*
|
||||||
|
* The callback function should take one argument - an associative array of query arguments.
|
||||||
|
* It should return a modified array of query arguments.
|
||||||
|
*
|
||||||
|
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||||
|
*
|
||||||
|
* @param callable $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addQueryArgFilter($callback){
|
||||||
|
$this->addFilter('request_info_query_args', $callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback for filtering arguments passed to wp_remote_get().
|
||||||
|
*
|
||||||
|
* The callback function should take one argument - an associative array of arguments -
|
||||||
|
* and return a modified array or arguments. See the WP documentation on wp_remote_get()
|
||||||
|
* for details on what arguments are available and how they work.
|
||||||
|
*
|
||||||
|
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||||
|
*
|
||||||
|
* @param callable $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addHttpRequestArgFilter($callback) {
|
||||||
|
$this->addFilter('request_info_options', $callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback for filtering the plugin info retrieved from the external API.
|
||||||
|
*
|
||||||
|
* The callback function should take two arguments. If the plugin info was retrieved
|
||||||
|
* successfully, the first argument passed will be an instance of PluginInfo. Otherwise,
|
||||||
|
* it will be NULL. The second argument will be the corresponding return value of
|
||||||
|
* wp_remote_get (see WP docs for details).
|
||||||
|
*
|
||||||
|
* The callback function should return a new or modified instance of PluginInfo or NULL.
|
||||||
|
*
|
||||||
|
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||||
|
*
|
||||||
|
* @param callable $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addResultFilter($callback) {
|
||||||
|
$this->addFilter('request_info_result', $callback, 10, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createDebugBarExtension() {
|
||||||
|
return new Puc_v4p13_DebugBar_PluginExtension($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a package instance that represents this plugin or theme.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_InstalledPackage
|
||||||
|
*/
|
||||||
|
protected function createInstalledPackage() {
|
||||||
|
return new Puc_v4p13_Plugin_Package($this->pluginAbsolutePath, $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Puc_v4p13_Plugin_Package
|
||||||
|
*/
|
||||||
|
public function getInstalledPackage() {
|
||||||
|
return $this->package;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
266
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Scheduler.php
vendored
Normal file
266
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Scheduler.php
vendored
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Scheduler', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The scheduler decides when and how often to check for updates.
|
||||||
|
* It calls @see Puc_v4p13_UpdateChecker::checkForUpdates() to perform the actual checks.
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_Scheduler {
|
||||||
|
public $checkPeriod = 12; //How often to check for updates (in hours).
|
||||||
|
public $throttleRedundantChecks = false; //Check less often if we already know that an update is available.
|
||||||
|
public $throttledCheckPeriod = 72;
|
||||||
|
|
||||||
|
protected $hourlyCheckHooks = array('load-update.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_UpdateChecker
|
||||||
|
*/
|
||||||
|
protected $updateChecker;
|
||||||
|
|
||||||
|
private $cronHook = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scheduler constructor.
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_UpdateChecker $updateChecker
|
||||||
|
* @param int $checkPeriod How often to check for updates (in hours).
|
||||||
|
* @param array $hourlyHooks
|
||||||
|
*/
|
||||||
|
public function __construct($updateChecker, $checkPeriod, $hourlyHooks = array('load-plugins.php')) {
|
||||||
|
$this->updateChecker = $updateChecker;
|
||||||
|
$this->checkPeriod = $checkPeriod;
|
||||||
|
|
||||||
|
//Set up the periodic update checks
|
||||||
|
$this->cronHook = $this->updateChecker->getUniqueName('cron_check_updates');
|
||||||
|
if ( $this->checkPeriod > 0 ){
|
||||||
|
|
||||||
|
//Trigger the check via Cron.
|
||||||
|
//Try to use one of the default schedules if possible as it's less likely to conflict
|
||||||
|
//with other plugins and their custom schedules.
|
||||||
|
$defaultSchedules = array(
|
||||||
|
1 => 'hourly',
|
||||||
|
12 => 'twicedaily',
|
||||||
|
24 => 'daily',
|
||||||
|
);
|
||||||
|
if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) {
|
||||||
|
$scheduleName = $defaultSchedules[$this->checkPeriod];
|
||||||
|
} else {
|
||||||
|
//Use a custom cron schedule.
|
||||||
|
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
||||||
|
add_filter('cron_schedules', array($this, '_addCustomSchedule'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) {
|
||||||
|
//Randomly offset the schedule to help prevent update server traffic spikes. Without this
|
||||||
|
//most checks may happen during times of day when people are most likely to install new plugins.
|
||||||
|
$firstCheckTime = time() - rand(0, max($this->checkPeriod * 3600 - 15 * 60, 1));
|
||||||
|
$firstCheckTime = apply_filters(
|
||||||
|
$this->updateChecker->getUniqueName('first_check_time'),
|
||||||
|
$firstCheckTime
|
||||||
|
);
|
||||||
|
wp_schedule_event($firstCheckTime, $scheduleName, $this->cronHook);
|
||||||
|
}
|
||||||
|
add_action($this->cronHook, array($this, 'maybeCheckForUpdates'));
|
||||||
|
|
||||||
|
//In case Cron is disabled or unreliable, we also manually trigger
|
||||||
|
//the periodic checks while the user is browsing the Dashboard.
|
||||||
|
add_action( 'admin_init', array($this, 'maybeCheckForUpdates') );
|
||||||
|
|
||||||
|
//Like WordPress itself, we check more often on certain pages.
|
||||||
|
/** @see wp_update_plugins */
|
||||||
|
add_action('load-update-core.php', array($this, 'maybeCheckForUpdates'));
|
||||||
|
//"load-update.php" and "load-plugins.php" or "load-themes.php".
|
||||||
|
$this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks);
|
||||||
|
foreach($this->hourlyCheckHooks as $hook) {
|
||||||
|
add_action($hook, array($this, 'maybeCheckForUpdates'));
|
||||||
|
}
|
||||||
|
//This hook fires after a bulk update is complete.
|
||||||
|
add_action('upgrader_process_complete', array($this, 'upgraderProcessComplete'), 11, 2);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//Periodic checks are disabled.
|
||||||
|
wp_clear_scheduled_hook($this->cronHook);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs upon the WP action upgrader_process_complete.
|
||||||
|
*
|
||||||
|
* We look at the parameters to decide whether to call maybeCheckForUpdates() or not.
|
||||||
|
* We also check if the update checker has been removed by the update.
|
||||||
|
*
|
||||||
|
* @param WP_Upgrader $upgrader WP_Upgrader instance
|
||||||
|
* @param array $upgradeInfo extra information about the upgrade
|
||||||
|
*/
|
||||||
|
public function upgraderProcessComplete(
|
||||||
|
/** @noinspection PhpUnusedParameterInspection */
|
||||||
|
$upgrader, $upgradeInfo
|
||||||
|
) {
|
||||||
|
//Cancel all further actions if the current version of PUC has been deleted or overwritten
|
||||||
|
//by a different version during the upgrade. If we try to do anything more in that situation,
|
||||||
|
//we could trigger a fatal error by trying to autoload a deleted class.
|
||||||
|
clearstatcache();
|
||||||
|
if ( !file_exists(__FILE__) ) {
|
||||||
|
$this->removeHooks();
|
||||||
|
$this->updateChecker->removeHooks();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Sanity check and limitation to relevant types.
|
||||||
|
if (
|
||||||
|
!is_array($upgradeInfo) || !isset($upgradeInfo['type'], $upgradeInfo['action'])
|
||||||
|
|| 'update' !== $upgradeInfo['action'] || !in_array($upgradeInfo['type'], array('plugin', 'theme'))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Filter out notifications of upgrades that should have no bearing upon whether or not our
|
||||||
|
//current info is up-to-date.
|
||||||
|
if ( is_a($this->updateChecker, 'Puc_v4p13_Theme_UpdateChecker') ) {
|
||||||
|
if ( 'theme' !== $upgradeInfo['type'] || !isset($upgradeInfo['themes']) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Letting too many things going through for checks is not a real problem, so we compare widely.
|
||||||
|
if ( !in_array(
|
||||||
|
strtolower($this->updateChecker->directoryName),
|
||||||
|
array_map('strtolower', $upgradeInfo['themes'])
|
||||||
|
) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_a($this->updateChecker, 'Puc_v4p13_Plugin_UpdateChecker') ) {
|
||||||
|
if ( 'plugin' !== $upgradeInfo['type'] || !isset($upgradeInfo['plugins']) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Themes pass in directory names in the information array, but plugins use the relative plugin path.
|
||||||
|
if ( !in_array(
|
||||||
|
strtolower($this->updateChecker->directoryName),
|
||||||
|
array_map('dirname', array_map('strtolower', $upgradeInfo['plugins']))
|
||||||
|
) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->maybeCheckForUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for updates if the configured check interval has already elapsed.
|
||||||
|
* Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron.
|
||||||
|
*
|
||||||
|
* You can override the default behaviour by using the "puc_check_now-$slug" filter.
|
||||||
|
* The filter callback will be passed three parameters:
|
||||||
|
* - Current decision. TRUE = check updates now, FALSE = don't check now.
|
||||||
|
* - Last check time as a Unix timestamp.
|
||||||
|
* - Configured check period in hours.
|
||||||
|
* Return TRUE to check for updates immediately, or FALSE to cancel.
|
||||||
|
*
|
||||||
|
* This method is declared public because it's a hook callback. Calling it directly is not recommended.
|
||||||
|
*/
|
||||||
|
public function maybeCheckForUpdates() {
|
||||||
|
if ( empty($this->checkPeriod) ){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$state = $this->updateChecker->getUpdateState();
|
||||||
|
$shouldCheck = ($state->timeSinceLastCheck() >= $this->getEffectiveCheckPeriod());
|
||||||
|
|
||||||
|
//Let plugin authors substitute their own algorithm.
|
||||||
|
$shouldCheck = apply_filters(
|
||||||
|
$this->updateChecker->getUniqueName('check_now'),
|
||||||
|
$shouldCheck,
|
||||||
|
$state->getLastCheck(),
|
||||||
|
$this->checkPeriod
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( $shouldCheck ) {
|
||||||
|
$this->updateChecker->checkForUpdates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the actual check period based on the current status and environment.
|
||||||
|
*
|
||||||
|
* @return int Check period in seconds.
|
||||||
|
*/
|
||||||
|
protected function getEffectiveCheckPeriod() {
|
||||||
|
$currentFilter = current_filter();
|
||||||
|
if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) {
|
||||||
|
//Check more often when the user visits "Dashboard -> Updates" or does a bulk update.
|
||||||
|
$period = 60;
|
||||||
|
} else if ( in_array($currentFilter, $this->hourlyCheckHooks) ) {
|
||||||
|
//Also check more often on /wp-admin/update.php and the "Plugins" or "Themes" page.
|
||||||
|
$period = 3600;
|
||||||
|
} else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) {
|
||||||
|
//Check less frequently if it's already known that an update is available.
|
||||||
|
$period = $this->throttledCheckPeriod * 3600;
|
||||||
|
} else if ( defined('DOING_CRON') && constant('DOING_CRON') ) {
|
||||||
|
//WordPress cron schedules are not exact, so lets do an update check even
|
||||||
|
//if slightly less than $checkPeriod hours have elapsed since the last check.
|
||||||
|
$cronFuzziness = 20 * 60;
|
||||||
|
$period = $this->checkPeriod * 3600 - $cronFuzziness;
|
||||||
|
} else {
|
||||||
|
$period = $this->checkPeriod * 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $period;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add our custom schedule to the array of Cron schedules used by WP.
|
||||||
|
*
|
||||||
|
* @param array $schedules
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function _addCustomSchedule($schedules) {
|
||||||
|
if ( $this->checkPeriod && ($this->checkPeriod > 0) ){
|
||||||
|
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
||||||
|
$schedules[$scheduleName] = array(
|
||||||
|
'interval' => $this->checkPeriod * 3600,
|
||||||
|
'display' => sprintf('Every %d hours', $this->checkPeriod),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $schedules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the scheduled cron event that the library uses to check for updates.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function removeUpdaterCron() {
|
||||||
|
wp_clear_scheduled_hook($this->cronHook);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCronHookName() {
|
||||||
|
return $this->cronHook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove most hooks added by the scheduler.
|
||||||
|
*/
|
||||||
|
public function removeHooks() {
|
||||||
|
remove_filter('cron_schedules', array($this, '_addCustomSchedule'));
|
||||||
|
remove_action('admin_init', array($this, 'maybeCheckForUpdates'));
|
||||||
|
remove_action('load-update-core.php', array($this, 'maybeCheckForUpdates'));
|
||||||
|
|
||||||
|
if ( $this->cronHook !== null ) {
|
||||||
|
remove_action($this->cronHook, array($this, 'maybeCheckForUpdates'));
|
||||||
|
}
|
||||||
|
if ( !empty($this->hourlyCheckHooks) ) {
|
||||||
|
foreach ($this->hourlyCheckHooks as $hook) {
|
||||||
|
remove_action($hook, array($this, 'maybeCheckForUpdates'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
216
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/StateStore.php
vendored
Normal file
216
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/StateStore.php
vendored
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_StateStore', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_StateStore {
|
||||||
|
/**
|
||||||
|
* @var int Last update check timestamp.
|
||||||
|
*/
|
||||||
|
protected $lastCheck = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Version number.
|
||||||
|
*/
|
||||||
|
protected $checkedVersion = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Update|null Cached update.
|
||||||
|
*/
|
||||||
|
protected $update = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Site option name.
|
||||||
|
*/
|
||||||
|
private $optionName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Whether we've already tried to load the state from the database.
|
||||||
|
*/
|
||||||
|
private $isLoaded = false;
|
||||||
|
|
||||||
|
public function __construct($optionName) {
|
||||||
|
$this->optionName = $optionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get time elapsed since the last update check.
|
||||||
|
*
|
||||||
|
* If there are no recorded update checks, this method returns a large arbitrary number
|
||||||
|
* (i.e. time since the Unix epoch).
|
||||||
|
*
|
||||||
|
* @return int Elapsed time in seconds.
|
||||||
|
*/
|
||||||
|
public function timeSinceLastCheck() {
|
||||||
|
$this->lazyLoad();
|
||||||
|
return time() - $this->lastCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getLastCheck() {
|
||||||
|
$this->lazyLoad();
|
||||||
|
return $this->lastCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time of the last update check to the current timestamp.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setLastCheckToNow() {
|
||||||
|
$this->lazyLoad();
|
||||||
|
$this->lastCheck = time();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return null|Puc_v4p13_Update
|
||||||
|
*/
|
||||||
|
public function getUpdate() {
|
||||||
|
$this->lazyLoad();
|
||||||
|
return $this->update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Puc_v4p13_Update|null $update
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setUpdate(Puc_v4p13_Update $update = null) {
|
||||||
|
$this->lazyLoad();
|
||||||
|
$this->update = $update;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCheckedVersion() {
|
||||||
|
$this->lazyLoad();
|
||||||
|
return $this->checkedVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $version
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCheckedVersion($version) {
|
||||||
|
$this->lazyLoad();
|
||||||
|
$this->checkedVersion = strval($version);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get translation updates.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getTranslations() {
|
||||||
|
$this->lazyLoad();
|
||||||
|
if ( isset($this->update, $this->update->translations) ) {
|
||||||
|
return $this->update->translations;
|
||||||
|
}
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set translation updates.
|
||||||
|
*
|
||||||
|
* @param array $translationUpdates
|
||||||
|
*/
|
||||||
|
public function setTranslations($translationUpdates) {
|
||||||
|
$this->lazyLoad();
|
||||||
|
if ( isset($this->update) ) {
|
||||||
|
$this->update->translations = $translationUpdates;
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
$state = new stdClass();
|
||||||
|
|
||||||
|
$state->lastCheck = $this->lastCheck;
|
||||||
|
$state->checkedVersion = $this->checkedVersion;
|
||||||
|
|
||||||
|
if ( isset($this->update)) {
|
||||||
|
$state->update = $this->update->toStdClass();
|
||||||
|
|
||||||
|
$updateClass = get_class($this->update);
|
||||||
|
$state->updateClass = $updateClass;
|
||||||
|
$prefix = $this->getLibPrefix();
|
||||||
|
if ( Puc_v4p13_Utils::startsWith($updateClass, $prefix) ) {
|
||||||
|
$state->updateBaseClass = substr($updateClass, strlen($prefix));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update_site_option($this->optionName, $state);
|
||||||
|
$this->isLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function lazyLoad() {
|
||||||
|
if ( !$this->isLoaded ) {
|
||||||
|
$this->load();
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function load() {
|
||||||
|
$this->isLoaded = true;
|
||||||
|
|
||||||
|
$state = get_site_option($this->optionName, null);
|
||||||
|
|
||||||
|
if ( !is_object($state) ) {
|
||||||
|
$this->lastCheck = 0;
|
||||||
|
$this->checkedVersion = '';
|
||||||
|
$this->update = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->lastCheck = intval(Puc_v4p13_Utils::get($state, 'lastCheck', 0));
|
||||||
|
$this->checkedVersion = Puc_v4p13_Utils::get($state, 'checkedVersion', '');
|
||||||
|
$this->update = null;
|
||||||
|
|
||||||
|
if ( isset($state->update) ) {
|
||||||
|
//This mess is due to the fact that the want the update class from this version
|
||||||
|
//of the library, not the version that saved the update.
|
||||||
|
|
||||||
|
$updateClass = null;
|
||||||
|
if ( isset($state->updateBaseClass) ) {
|
||||||
|
$updateClass = $this->getLibPrefix() . $state->updateBaseClass;
|
||||||
|
} else if ( isset($state->updateClass) ) {
|
||||||
|
$updateClass = $state->updateClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ($updateClass !== null) && class_exists($updateClass) ) {
|
||||||
|
$this->update = call_user_func(array($updateClass, 'fromObject'), $state->update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete() {
|
||||||
|
delete_site_option($this->optionName);
|
||||||
|
|
||||||
|
$this->lastCheck = 0;
|
||||||
|
$this->checkedVersion = '';
|
||||||
|
$this->update = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getLibPrefix() {
|
||||||
|
$lastSlashPos = strrpos(__CLASS__, '\\');
|
||||||
|
if ( $lastSlashPos !== false ) {
|
||||||
|
$namespacePrefix = substr(__CLASS__, 0, $lastSlashPos + 1);
|
||||||
|
$className = substr(__CLASS__, $lastSlashPos + 1);
|
||||||
|
} else {
|
||||||
|
$namespacePrefix = '';
|
||||||
|
$className = __CLASS__;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts = explode('_', $className, 3);
|
||||||
|
return $namespacePrefix . $parts[0] . '_' . $parts[1] . '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
65
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Theme/Package.php
vendored
Normal file
65
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Theme/Package.php
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Theme_Package', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Theme_Package extends Puc_v4p13_InstalledPackage {
|
||||||
|
/**
|
||||||
|
* @var string Theme directory name.
|
||||||
|
*/
|
||||||
|
protected $stylesheet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var WP_Theme Theme object.
|
||||||
|
*/
|
||||||
|
protected $theme;
|
||||||
|
|
||||||
|
public function __construct($stylesheet, $updateChecker) {
|
||||||
|
$this->stylesheet = $stylesheet;
|
||||||
|
$this->theme = wp_get_theme($this->stylesheet);
|
||||||
|
|
||||||
|
parent::__construct($updateChecker);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInstalledVersion() {
|
||||||
|
return $this->theme->get('Version');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAbsoluteDirectoryPath() {
|
||||||
|
if ( method_exists($this->theme, 'get_stylesheet_directory') ) {
|
||||||
|
return $this->theme->get_stylesheet_directory(); //Available since WP 3.4.
|
||||||
|
}
|
||||||
|
return get_theme_root($this->stylesheet) . '/' . $this->stylesheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a specific plugin or theme header.
|
||||||
|
*
|
||||||
|
* @param string $headerName
|
||||||
|
* @param string $defaultValue
|
||||||
|
* @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty.
|
||||||
|
*/
|
||||||
|
public function getHeaderValue($headerName, $defaultValue = '') {
|
||||||
|
$value = $this->theme->get($headerName);
|
||||||
|
if ( ($headerName === false) || ($headerName === '') ) {
|
||||||
|
return $defaultValue;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeaderNames() {
|
||||||
|
return array(
|
||||||
|
'Name' => 'Theme Name',
|
||||||
|
'ThemeURI' => 'Theme URI',
|
||||||
|
'Description' => 'Description',
|
||||||
|
'Author' => 'Author',
|
||||||
|
'AuthorURI' => 'Author URI',
|
||||||
|
'Version' => 'Version',
|
||||||
|
'Template' => 'Template',
|
||||||
|
'Status' => 'Status',
|
||||||
|
'Tags' => 'Tags',
|
||||||
|
'TextDomain' => 'Text Domain',
|
||||||
|
'DomainPath' => 'Domain Path',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
84
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Theme/Update.php
vendored
Normal file
84
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Theme/Update.php
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_Theme_Update', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Theme_Update extends Puc_v4p13_Update {
|
||||||
|
public $details_url = '';
|
||||||
|
|
||||||
|
protected static $extraFields = array('details_url');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the metadata into the format used by WordPress core.
|
||||||
|
* Note the inconsistency: WP stores plugin updates as objects and theme updates as arrays.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toWpFormat() {
|
||||||
|
$update = array(
|
||||||
|
'theme' => $this->slug,
|
||||||
|
'new_version' => $this->version,
|
||||||
|
'url' => $this->details_url,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( !empty($this->download_url) ) {
|
||||||
|
$update['package'] = $this->download_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance of Theme_Update from its JSON-encoded representation.
|
||||||
|
*
|
||||||
|
* @param string $json Valid JSON string representing a theme information object.
|
||||||
|
* @return self New instance of ThemeUpdate, or NULL on error.
|
||||||
|
*/
|
||||||
|
public static function fromJson($json) {
|
||||||
|
$instance = new self();
|
||||||
|
if ( !parent::createFromJson($json, $instance) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance by copying the necessary fields from another object.
|
||||||
|
*
|
||||||
|
* @param StdClass|Puc_v4p13_Theme_Update $object The source object.
|
||||||
|
* @return Puc_v4p13_Theme_Update The new copy.
|
||||||
|
*/
|
||||||
|
public static function fromObject($object) {
|
||||||
|
$update = new self();
|
||||||
|
$update->copyFields($object, $update);
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic validation.
|
||||||
|
*
|
||||||
|
* @param StdClass $apiResponse
|
||||||
|
* @return bool|WP_Error
|
||||||
|
*/
|
||||||
|
protected function validateMetadata($apiResponse) {
|
||||||
|
$required = array('version', 'details_url');
|
||||||
|
foreach($required as $key) {
|
||||||
|
if ( !isset($apiResponse->$key) || empty($apiResponse->$key) ) {
|
||||||
|
return new WP_Error(
|
||||||
|
'tuc-invalid-metadata',
|
||||||
|
sprintf('The theme metadata is missing the required "%s" key.', $key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFieldNames() {
|
||||||
|
return array_merge(parent::getFieldNames(), self::$extraFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPrefixedFilter($tag) {
|
||||||
|
return parent::getPrefixedFilter($tag) . '_theme';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
152
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Theme/UpdateChecker.php
vendored
Normal file
152
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Theme/UpdateChecker.php
vendored
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_Theme_UpdateChecker', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Theme_UpdateChecker extends Puc_v4p13_UpdateChecker {
|
||||||
|
protected $filterSuffix = 'theme';
|
||||||
|
protected $updateTransient = 'update_themes';
|
||||||
|
protected $translationType = 'theme';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Theme directory name.
|
||||||
|
*/
|
||||||
|
protected $stylesheet;
|
||||||
|
|
||||||
|
public function __construct($metadataUrl, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
|
||||||
|
if ( $stylesheet === null ) {
|
||||||
|
$stylesheet = get_stylesheet();
|
||||||
|
}
|
||||||
|
$this->stylesheet = $stylesheet;
|
||||||
|
|
||||||
|
parent::__construct(
|
||||||
|
$metadataUrl,
|
||||||
|
$stylesheet,
|
||||||
|
$customSlug ? $customSlug : $stylesheet,
|
||||||
|
$checkPeriod,
|
||||||
|
$optionName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For themes, the update array is indexed by theme directory name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getUpdateListKey() {
|
||||||
|
return $this->directoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the latest update (if any) from the configured API endpoint.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Update|null An instance of Update, or NULL when no updates are available.
|
||||||
|
*/
|
||||||
|
public function requestUpdate() {
|
||||||
|
list($themeUpdate, $result) = $this->requestMetadata('Puc_v4p13_Theme_Update', 'request_update');
|
||||||
|
|
||||||
|
if ( $themeUpdate !== null ) {
|
||||||
|
/** @var Puc_v4p13_Theme_Update $themeUpdate */
|
||||||
|
$themeUpdate->slug = $this->slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
$themeUpdate = $this->filterUpdateResult($themeUpdate, $result);
|
||||||
|
return $themeUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getNoUpdateItemFields() {
|
||||||
|
return array_merge(
|
||||||
|
parent::getNoUpdateItemFields(),
|
||||||
|
array(
|
||||||
|
'theme' => $this->directoryName,
|
||||||
|
'requires' => '',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userCanInstallUpdates() {
|
||||||
|
return current_user_can('update_themes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of the scheduler.
|
||||||
|
*
|
||||||
|
* @param int $checkPeriod
|
||||||
|
* @return Puc_v4p13_Scheduler
|
||||||
|
*/
|
||||||
|
protected function createScheduler($checkPeriod) {
|
||||||
|
return new Puc_v4p13_Scheduler($this, $checkPeriod, array('load-themes.php'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there an update being installed right now for this theme?
|
||||||
|
*
|
||||||
|
* @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isBeingUpgraded($upgrader = null) {
|
||||||
|
return $this->upgraderStatus->isThemeBeingUpgraded($this->stylesheet, $upgrader);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createDebugBarExtension() {
|
||||||
|
return new Puc_v4p13_DebugBar_Extension($this, 'Puc_v4p13_DebugBar_ThemePanel');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback for filtering query arguments.
|
||||||
|
*
|
||||||
|
* The callback function should take one argument - an associative array of query arguments.
|
||||||
|
* It should return a modified array of query arguments.
|
||||||
|
*
|
||||||
|
* @param callable $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addQueryArgFilter($callback){
|
||||||
|
$this->addFilter('request_update_query_args', $callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback for filtering arguments passed to wp_remote_get().
|
||||||
|
*
|
||||||
|
* The callback function should take one argument - an associative array of arguments -
|
||||||
|
* and return a modified array or arguments. See the WP documentation on wp_remote_get()
|
||||||
|
* for details on what arguments are available and how they work.
|
||||||
|
*
|
||||||
|
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||||
|
*
|
||||||
|
* @param callable $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addHttpRequestArgFilter($callback) {
|
||||||
|
$this->addFilter('request_update_options', $callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback for filtering theme updates retrieved from the external API.
|
||||||
|
*
|
||||||
|
* The callback function should take two arguments. If the theme update was retrieved
|
||||||
|
* successfully, the first argument passed will be an instance of Theme_Update. Otherwise,
|
||||||
|
* it will be NULL. The second argument will be the corresponding return value of
|
||||||
|
* wp_remote_get (see WP docs for details).
|
||||||
|
*
|
||||||
|
* The callback function should return a new or modified instance of Theme_Update or NULL.
|
||||||
|
*
|
||||||
|
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
||||||
|
*
|
||||||
|
* @param callable $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addResultFilter($callback) {
|
||||||
|
$this->addFilter('request_update_result', $callback, 10, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a package instance that represents this plugin or theme.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_InstalledPackage
|
||||||
|
*/
|
||||||
|
protected function createInstalledPackage() {
|
||||||
|
return new Puc_v4p13_Theme_Package($this->stylesheet, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
34
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Update.php
vendored
Normal file
34
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Update.php
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Update', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple container class for holding information about an available update.
|
||||||
|
*
|
||||||
|
* @author Janis Elsts
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
abstract class Puc_v4p13_Update extends Puc_v4p13_Metadata {
|
||||||
|
public $slug;
|
||||||
|
public $version;
|
||||||
|
public $download_url;
|
||||||
|
public $translations = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
protected function getFieldNames() {
|
||||||
|
return array('slug', 'version', 'download_url', 'translations');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toWpFormat() {
|
||||||
|
$update = new stdClass();
|
||||||
|
|
||||||
|
$update->slug = $this->slug;
|
||||||
|
$update->new_version = $this->version;
|
||||||
|
$update->package = $this->download_url;
|
||||||
|
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
997
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/UpdateChecker.php
vendored
Normal file
997
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/UpdateChecker.php
vendored
Normal file
@ -0,0 +1,997 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_UpdateChecker', false) ):
|
||||||
|
|
||||||
|
abstract class Puc_v4p13_UpdateChecker {
|
||||||
|
protected $filterSuffix = '';
|
||||||
|
protected $updateTransient = '';
|
||||||
|
protected $translationType = ''; //"plugin" or "theme".
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to TRUE to enable error reporting. Errors are raised using trigger_error()
|
||||||
|
* and should be logged to the standard PHP error log.
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $debugMode = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Where to store the update info.
|
||||||
|
*/
|
||||||
|
public $optionName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The URL of the metadata file.
|
||||||
|
*/
|
||||||
|
public $metadataUrl = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Plugin or theme directory name.
|
||||||
|
*/
|
||||||
|
public $directoryName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The slug that will be used in update checker hooks and remote API requests.
|
||||||
|
* Usually matches the directory name unless the plugin/theme directory has been renamed.
|
||||||
|
*/
|
||||||
|
public $slug = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_InstalledPackage
|
||||||
|
*/
|
||||||
|
protected $package;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Scheduler
|
||||||
|
*/
|
||||||
|
public $scheduler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_UpgraderStatus
|
||||||
|
*/
|
||||||
|
protected $upgraderStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_StateStore
|
||||||
|
*/
|
||||||
|
protected $updateState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array List of API errors triggered during the last checkForUpdates() call.
|
||||||
|
*/
|
||||||
|
protected $lastRequestApiErrors = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|mixed The default is 0 because parse_url() can return NULL or FALSE.
|
||||||
|
*/
|
||||||
|
protected $cachedMetadataHost = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_DebugBar_Extension|null
|
||||||
|
*/
|
||||||
|
protected $debugBarExtension = null;
|
||||||
|
|
||||||
|
public function __construct($metadataUrl, $directoryName, $slug = null, $checkPeriod = 12, $optionName = '') {
|
||||||
|
$this->debugMode = (bool)(constant('WP_DEBUG'));
|
||||||
|
$this->metadataUrl = $metadataUrl;
|
||||||
|
$this->directoryName = $directoryName;
|
||||||
|
$this->slug = !empty($slug) ? $slug : $this->directoryName;
|
||||||
|
|
||||||
|
$this->optionName = $optionName;
|
||||||
|
if ( empty($this->optionName) ) {
|
||||||
|
//BC: Initially the library only supported plugin updates and didn't use type prefixes
|
||||||
|
//in the option name. Lets use the same prefix-less name when possible.
|
||||||
|
if ( $this->filterSuffix === '' ) {
|
||||||
|
$this->optionName = 'external_updates-' . $this->slug;
|
||||||
|
} else {
|
||||||
|
$this->optionName = $this->getUniqueName('external_updates');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->package = $this->createInstalledPackage();
|
||||||
|
$this->scheduler = $this->createScheduler($checkPeriod);
|
||||||
|
$this->upgraderStatus = new Puc_v4p13_UpgraderStatus();
|
||||||
|
$this->updateState = new Puc_v4p13_StateStore($this->optionName);
|
||||||
|
|
||||||
|
if ( did_action('init') ) {
|
||||||
|
$this->loadTextDomain();
|
||||||
|
} else {
|
||||||
|
add_action('init', array($this, 'loadTextDomain'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->installHooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public function loadTextDomain() {
|
||||||
|
//We're not using load_plugin_textdomain() or its siblings because figuring out where
|
||||||
|
//the library is located (plugin, mu-plugin, theme, custom wp-content paths) is messy.
|
||||||
|
$domain = 'plugin-update-checker';
|
||||||
|
$locale = apply_filters(
|
||||||
|
'plugin_locale',
|
||||||
|
(is_admin() && function_exists('get_user_locale')) ? get_user_locale() : get_locale(),
|
||||||
|
$domain
|
||||||
|
);
|
||||||
|
|
||||||
|
$moFile = $domain . '-' . $locale . '.mo';
|
||||||
|
$path = realpath(dirname(__FILE__) . '/../../languages');
|
||||||
|
|
||||||
|
if ($path && file_exists($path)) {
|
||||||
|
load_textdomain($domain, $path . '/' . $moFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function installHooks() {
|
||||||
|
//Insert our update info into the update array maintained by WP.
|
||||||
|
add_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate'));
|
||||||
|
|
||||||
|
//Insert translation updates into the update list.
|
||||||
|
add_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates'));
|
||||||
|
|
||||||
|
//Clear translation updates when WP clears the update cache.
|
||||||
|
//This needs to be done directly because the library doesn't actually remove obsolete plugin updates,
|
||||||
|
//it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O.
|
||||||
|
add_action(
|
||||||
|
'delete_site_transient_' . $this->updateTransient,
|
||||||
|
array($this, 'clearCachedTranslationUpdates')
|
||||||
|
);
|
||||||
|
|
||||||
|
//Rename the update directory to be the same as the existing directory.
|
||||||
|
if ( $this->directoryName !== '.' ) {
|
||||||
|
add_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Allow HTTP requests to the metadata URL even if it's on a local host.
|
||||||
|
add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2);
|
||||||
|
|
||||||
|
//DebugBar integration.
|
||||||
|
if ( did_action('plugins_loaded') ) {
|
||||||
|
$this->maybeInitDebugBar();
|
||||||
|
} else {
|
||||||
|
add_action('plugins_loaded', array($this, 'maybeInitDebugBar'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove hooks that were added by this update checker instance.
|
||||||
|
*/
|
||||||
|
public function removeHooks() {
|
||||||
|
remove_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate'));
|
||||||
|
remove_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates'));
|
||||||
|
remove_action(
|
||||||
|
'delete_site_transient_' . $this->updateTransient,
|
||||||
|
array($this, 'clearCachedTranslationUpdates')
|
||||||
|
);
|
||||||
|
|
||||||
|
remove_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10);
|
||||||
|
remove_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10);
|
||||||
|
remove_action('plugins_loaded', array($this, 'maybeInitDebugBar'));
|
||||||
|
|
||||||
|
remove_action('init', array($this, 'loadTextDomain'));
|
||||||
|
|
||||||
|
if ( $this->scheduler ) {
|
||||||
|
$this->scheduler->removeHooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->debugBarExtension ) {
|
||||||
|
$this->debugBarExtension->removeHooks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current user has the required permissions to install updates.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
abstract public function userCanInstallUpdates();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicitly allow HTTP requests to the metadata URL.
|
||||||
|
*
|
||||||
|
* WordPress has a security feature where the HTTP API will reject all requests that are sent to
|
||||||
|
* another site hosted on the same server as the current site (IP match), a local host, or a local
|
||||||
|
* IP, unless the host exactly matches the current site.
|
||||||
|
*
|
||||||
|
* This feature is opt-in (at least in WP 4.4). Apparently some people enable it.
|
||||||
|
*
|
||||||
|
* That can be a problem when you're developing your plugin and you decide to host the update information
|
||||||
|
* on the same server as your test site. Update requests will mysteriously fail.
|
||||||
|
*
|
||||||
|
* We fix that by adding an exception for the metadata host.
|
||||||
|
*
|
||||||
|
* @param bool $allow
|
||||||
|
* @param string $host
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function allowMetadataHost($allow, $host) {
|
||||||
|
if ( $this->cachedMetadataHost === 0 ) {
|
||||||
|
$this->cachedMetadataHost = parse_url($this->metadataUrl, PHP_URL_HOST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( is_string($this->cachedMetadataHost) && (strtolower($host) === strtolower($this->cachedMetadataHost)) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return $allow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a package instance that represents this plugin or theme.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_InstalledPackage
|
||||||
|
*/
|
||||||
|
abstract protected function createInstalledPackage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Puc_v4p13_InstalledPackage
|
||||||
|
*/
|
||||||
|
public function getInstalledPackage() {
|
||||||
|
return $this->package;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of the scheduler.
|
||||||
|
*
|
||||||
|
* This is implemented as a method to make it possible for plugins to subclass the update checker
|
||||||
|
* and substitute their own scheduler.
|
||||||
|
*
|
||||||
|
* @param int $checkPeriod
|
||||||
|
* @return Puc_v4p13_Scheduler
|
||||||
|
*/
|
||||||
|
abstract protected function createScheduler($checkPeriod);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for updates. The results are stored in the DB option specified in $optionName.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Update|null
|
||||||
|
*/
|
||||||
|
public function checkForUpdates() {
|
||||||
|
$installedVersion = $this->getInstalledVersion();
|
||||||
|
//Fail silently if we can't find the plugin/theme or read its header.
|
||||||
|
if ( $installedVersion === null ) {
|
||||||
|
$this->triggerError(
|
||||||
|
sprintf('Skipping update check for %s - installed version unknown.', $this->slug),
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Start collecting API errors.
|
||||||
|
$this->lastRequestApiErrors = array();
|
||||||
|
add_action('puc_api_error', array($this, 'collectApiErrors'), 10, 4);
|
||||||
|
|
||||||
|
$state = $this->updateState;
|
||||||
|
$state->setLastCheckToNow()
|
||||||
|
->setCheckedVersion($installedVersion)
|
||||||
|
->save(); //Save before checking in case something goes wrong
|
||||||
|
|
||||||
|
$state->setUpdate($this->requestUpdate());
|
||||||
|
$state->save();
|
||||||
|
|
||||||
|
//Stop collecting API errors.
|
||||||
|
remove_action('puc_api_error', array($this, 'collectApiErrors'), 10);
|
||||||
|
|
||||||
|
return $this->getUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the update checker state from the DB.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_StateStore
|
||||||
|
*/
|
||||||
|
public function getUpdateState() {
|
||||||
|
return $this->updateState->lazyLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset update checker state - i.e. last check time, cached update data and so on.
|
||||||
|
*
|
||||||
|
* Call this when your plugin is being uninstalled, or if you want to
|
||||||
|
* clear the update cache.
|
||||||
|
*/
|
||||||
|
public function resetUpdateState() {
|
||||||
|
$this->updateState->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the details of the currently available update, if any.
|
||||||
|
*
|
||||||
|
* If no updates are available, or if the last known update version is below or equal
|
||||||
|
* to the currently installed version, this method will return NULL.
|
||||||
|
*
|
||||||
|
* Uses cached update data. To retrieve update information straight from
|
||||||
|
* the metadata URL, call requestUpdate() instead.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Update|null
|
||||||
|
*/
|
||||||
|
public function getUpdate() {
|
||||||
|
$update = $this->updateState->getUpdate();
|
||||||
|
|
||||||
|
//Is there an update available?
|
||||||
|
if ( isset($update) ) {
|
||||||
|
//Check if the update is actually newer than the currently installed version.
|
||||||
|
$installedVersion = $this->getInstalledVersion();
|
||||||
|
if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ){
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the latest update (if any) from the configured API endpoint.
|
||||||
|
*
|
||||||
|
* Subclasses should run the update through filterUpdateResult before returning it.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Update An instance of Update, or NULL when no updates are available.
|
||||||
|
*/
|
||||||
|
abstract public function requestUpdate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the result of a requestUpdate() call.
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_Update|null $update
|
||||||
|
* @param array|WP_Error|null $httpResult The value returned by wp_remote_get(), if any.
|
||||||
|
* @return Puc_v4p13_Update
|
||||||
|
*/
|
||||||
|
protected function filterUpdateResult($update, $httpResult = null) {
|
||||||
|
//Let plugins/themes modify the update.
|
||||||
|
$update = apply_filters($this->getUniqueName('request_update_result'), $update, $httpResult);
|
||||||
|
|
||||||
|
$this->fixSupportedWordpressVersion($update);
|
||||||
|
|
||||||
|
if ( isset($update, $update->translations) ) {
|
||||||
|
//Keep only those translation updates that apply to this site.
|
||||||
|
$update->translations = $this->filterApplicableTranslations($update->translations);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "Tested up to" field in the plugin metadata is supposed to be in the form of "major.minor",
|
||||||
|
* while WordPress core's list_plugin_updates() expects the $update->tested field to be an exact
|
||||||
|
* version, e.g. "major.minor.patch", to say it's compatible. In other case it shows
|
||||||
|
* "Compatibility: Unknown".
|
||||||
|
* The function mimics how wordpress.org API crafts the "tested" field out of "Tested up to".
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_Metadata|null $update
|
||||||
|
*/
|
||||||
|
protected function fixSupportedWordpressVersion(Puc_v4p13_Metadata $update = null) {
|
||||||
|
if ( !isset($update->tested) || !preg_match('/^\d++\.\d++$/', $update->tested) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$actualWpVersions = array();
|
||||||
|
|
||||||
|
$wpVersion = $GLOBALS['wp_version'];
|
||||||
|
|
||||||
|
if ( function_exists('get_core_updates') ) {
|
||||||
|
$coreUpdates = get_core_updates();
|
||||||
|
if ( is_array($coreUpdates) ) {
|
||||||
|
foreach ($coreUpdates as $coreUpdate) {
|
||||||
|
if ( isset($coreUpdate->current) ) {
|
||||||
|
$actualWpVersions[] = $coreUpdate->current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$actualWpVersions[] = $wpVersion;
|
||||||
|
|
||||||
|
$actualWpPatchNumber = null;
|
||||||
|
foreach ($actualWpVersions as $version) {
|
||||||
|
if ( preg_match('/^(?P<majorMinor>\d++\.\d++)(?:\.(?P<patch>\d++))?/', $version, $versionParts) ) {
|
||||||
|
if ( $versionParts['majorMinor'] === $update->tested ) {
|
||||||
|
$patch = isset($versionParts['patch']) ? intval($versionParts['patch']) : 0;
|
||||||
|
if ( $actualWpPatchNumber === null ) {
|
||||||
|
$actualWpPatchNumber = $patch;
|
||||||
|
} else {
|
||||||
|
$actualWpPatchNumber = max($actualWpPatchNumber, $patch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( $actualWpPatchNumber === null ) {
|
||||||
|
$actualWpPatchNumber = 999;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $actualWpPatchNumber > 0 ) {
|
||||||
|
$update->tested .= '.' . $actualWpPatchNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the currently installed version of the plugin or theme.
|
||||||
|
*
|
||||||
|
* @return string|null Version number.
|
||||||
|
*/
|
||||||
|
public function getInstalledVersion() {
|
||||||
|
return $this->package->getInstalledVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the full path of the plugin or theme directory.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAbsoluteDirectoryPath() {
|
||||||
|
return $this->package->getAbsoluteDirectoryPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger a PHP error, but only when $debugMode is enabled.
|
||||||
|
*
|
||||||
|
* @param string $message
|
||||||
|
* @param int $errorType
|
||||||
|
*/
|
||||||
|
public function triggerError($message, $errorType) {
|
||||||
|
if ( $this->isDebugModeEnabled() ) {
|
||||||
|
trigger_error($message, $errorType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isDebugModeEnabled() {
|
||||||
|
if ( $this->debugMode === null ) {
|
||||||
|
$this->debugMode = (bool)(constant('WP_DEBUG'));
|
||||||
|
}
|
||||||
|
return $this->debugMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the full name of an update checker filter, action or DB entry.
|
||||||
|
*
|
||||||
|
* This method adds the "puc_" prefix and the "-$slug" suffix to the filter name.
|
||||||
|
* For example, "pre_inject_update" becomes "puc_pre_inject_update-plugin-slug".
|
||||||
|
*
|
||||||
|
* @param string $baseTag
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUniqueName($baseTag) {
|
||||||
|
$name = 'puc_' . $baseTag;
|
||||||
|
if ( $this->filterSuffix !== '' ) {
|
||||||
|
$name .= '_' . $this->filterSuffix;
|
||||||
|
}
|
||||||
|
return $name . '-' . $this->slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store API errors that are generated when checking for updates.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @param WP_Error $error
|
||||||
|
* @param array|null $httpResponse
|
||||||
|
* @param string|null $url
|
||||||
|
* @param string|null $slug
|
||||||
|
*/
|
||||||
|
public function collectApiErrors($error, $httpResponse = null, $url = null, $slug = null) {
|
||||||
|
if ( isset($slug) && ($slug !== $this->slug) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->lastRequestApiErrors[] = array(
|
||||||
|
'error' => $error,
|
||||||
|
'httpResponse' => $httpResponse,
|
||||||
|
'url' => $url,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getLastRequestApiErrors() {
|
||||||
|
return $this->lastRequestApiErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
* PUC filters and filter utilities
|
||||||
|
* -------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a callback for one of the update checker filters.
|
||||||
|
*
|
||||||
|
* Identical to add_filter(), except it automatically adds the "puc_" prefix
|
||||||
|
* and the "-$slug" suffix to the filter name. For example, "request_info_result"
|
||||||
|
* becomes "puc_request_info_result-your_plugin_slug".
|
||||||
|
*
|
||||||
|
* @param string $tag
|
||||||
|
* @param callable $callback
|
||||||
|
* @param int $priority
|
||||||
|
* @param int $acceptedArgs
|
||||||
|
*/
|
||||||
|
public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) {
|
||||||
|
add_filter($this->getUniqueName($tag), $callback, $priority, $acceptedArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
* Inject updates
|
||||||
|
* -------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert the latest update (if any) into the update list maintained by WP.
|
||||||
|
*
|
||||||
|
* @param stdClass $updates Update list.
|
||||||
|
* @return stdClass Modified update list.
|
||||||
|
*/
|
||||||
|
public function injectUpdate($updates) {
|
||||||
|
//Is there an update to insert?
|
||||||
|
$update = $this->getUpdate();
|
||||||
|
|
||||||
|
if ( !$this->shouldShowUpdates() ) {
|
||||||
|
$update = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($update) ) {
|
||||||
|
//Let plugins filter the update info before it's passed on to WordPress.
|
||||||
|
$update = apply_filters($this->getUniqueName('pre_inject_update'), $update);
|
||||||
|
$updates = $this->addUpdateToList($updates, $update->toWpFormat());
|
||||||
|
} else {
|
||||||
|
//Clean up any stale update info.
|
||||||
|
$updates = $this->removeUpdateFromList($updates);
|
||||||
|
//Add a placeholder item to the "no_update" list to enable auto-update support.
|
||||||
|
//If we don't do this, the option to enable automatic updates will only show up
|
||||||
|
//when an update is available.
|
||||||
|
$updates = $this->addNoUpdateItem($updates);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stdClass|null $updates
|
||||||
|
* @param stdClass|array $updateToAdd
|
||||||
|
* @return stdClass
|
||||||
|
*/
|
||||||
|
protected function addUpdateToList($updates, $updateToAdd) {
|
||||||
|
if ( !is_object($updates) ) {
|
||||||
|
$updates = new stdClass();
|
||||||
|
$updates->response = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$updates->response[$this->getUpdateListKey()] = $updateToAdd;
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param stdClass|null $updates
|
||||||
|
* @return stdClass|null
|
||||||
|
*/
|
||||||
|
protected function removeUpdateFromList($updates) {
|
||||||
|
if ( isset($updates, $updates->response) ) {
|
||||||
|
unset($updates->response[$this->getUpdateListKey()]);
|
||||||
|
}
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See this post for more information:
|
||||||
|
* @link https://make.wordpress.org/core/2020/07/30/recommended-usage-of-the-updates-api-to-support-the-auto-updates-ui-for-plugins-and-themes-in-wordpress-5-5/
|
||||||
|
*
|
||||||
|
* @param stdClass|null $updates
|
||||||
|
* @return stdClass
|
||||||
|
*/
|
||||||
|
protected function addNoUpdateItem($updates) {
|
||||||
|
if ( !is_object($updates) ) {
|
||||||
|
$updates = new stdClass();
|
||||||
|
$updates->response = array();
|
||||||
|
$updates->no_update = array();
|
||||||
|
} else if ( !isset($updates->no_update) ) {
|
||||||
|
$updates->no_update = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$updates->no_update[$this->getUpdateListKey()] = (object) $this->getNoUpdateItemFields();
|
||||||
|
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclasses should override this method to add fields that are specific to plugins or themes.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getNoUpdateItemFields() {
|
||||||
|
return array(
|
||||||
|
'new_version' => $this->getInstalledVersion(),
|
||||||
|
'url' => '',
|
||||||
|
'package' => '',
|
||||||
|
'requires_php' => '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the key that will be used when adding updates to the update list that's maintained
|
||||||
|
* by the WordPress core. The list is always an associative array, but the key is different
|
||||||
|
* for plugins and themes.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract protected function getUpdateListKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should we show available updates?
|
||||||
|
*
|
||||||
|
* Usually the answer is "yes", but there are exceptions. For example, WordPress doesn't
|
||||||
|
* support automatic updates installation for mu-plugins, so PUC usually won't show update
|
||||||
|
* notifications in that case. See the plugin-specific subclass for details.
|
||||||
|
*
|
||||||
|
* Note: This method only applies to updates that are displayed (or not) in the WordPress
|
||||||
|
* admin. It doesn't affect APIs like requestUpdate and getUpdate.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function shouldShowUpdates() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
* JSON-based update API
|
||||||
|
* -------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve plugin or theme metadata from the JSON document at $this->metadataUrl.
|
||||||
|
*
|
||||||
|
* @param string $metaClass Parse the JSON as an instance of this class. It must have a static fromJson method.
|
||||||
|
* @param string $filterRoot
|
||||||
|
* @param array $queryArgs Additional query arguments.
|
||||||
|
* @return array [Puc_v4p13_Metadata|null, array|WP_Error] A metadata instance and the value returned by wp_remote_get().
|
||||||
|
*/
|
||||||
|
protected function requestMetadata($metaClass, $filterRoot, $queryArgs = array()) {
|
||||||
|
//Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
|
||||||
|
$queryArgs = array_merge(
|
||||||
|
array(
|
||||||
|
'installed_version' => strval($this->getInstalledVersion()),
|
||||||
|
'php' => phpversion(),
|
||||||
|
'locale' => get_locale(),
|
||||||
|
),
|
||||||
|
$queryArgs
|
||||||
|
);
|
||||||
|
$queryArgs = apply_filters($this->getUniqueName($filterRoot . '_query_args'), $queryArgs);
|
||||||
|
|
||||||
|
//Various options for the wp_remote_get() call. Plugins can filter these, too.
|
||||||
|
$options = array(
|
||||||
|
'timeout' => 10, //seconds
|
||||||
|
'headers' => array(
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$options = apply_filters($this->getUniqueName($filterRoot . '_options'), $options);
|
||||||
|
|
||||||
|
//The metadata file should be at 'http://your-api.com/url/here/$slug/info.json'
|
||||||
|
$url = $this->metadataUrl;
|
||||||
|
if ( !empty($queryArgs) ){
|
||||||
|
$url = add_query_arg($queryArgs, $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = wp_remote_get($url, $options);
|
||||||
|
|
||||||
|
$result = apply_filters($this->getUniqueName('request_metadata_http_result'), $result, $url, $options);
|
||||||
|
|
||||||
|
//Try to parse the response
|
||||||
|
$status = $this->validateApiResponse($result);
|
||||||
|
$metadata = null;
|
||||||
|
if ( !is_wp_error($status) ){
|
||||||
|
if ( version_compare(PHP_VERSION, '5.3', '>=') && (strpos($metaClass, '\\') === false) ) {
|
||||||
|
$metaClass = __NAMESPACE__ . '\\' . $metaClass;
|
||||||
|
}
|
||||||
|
$metadata = call_user_func(array($metaClass, 'fromJson'), $result['body']);
|
||||||
|
} else {
|
||||||
|
do_action('puc_api_error', $status, $result, $url, $this->slug);
|
||||||
|
$this->triggerError(
|
||||||
|
sprintf('The URL %s does not point to a valid metadata file. ', $url)
|
||||||
|
. $status->get_error_message(),
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($metadata, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if $result is a successful update API response.
|
||||||
|
*
|
||||||
|
* @param array|WP_Error $result
|
||||||
|
* @return true|WP_Error
|
||||||
|
*/
|
||||||
|
protected function validateApiResponse($result) {
|
||||||
|
if ( is_wp_error($result) ) { /** @var WP_Error $result */
|
||||||
|
return new WP_Error($result->get_error_code(), 'WP HTTP Error: ' . $result->get_error_message());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset($result['response']['code']) ) {
|
||||||
|
return new WP_Error(
|
||||||
|
'puc_no_response_code',
|
||||||
|
'wp_remote_get() returned an unexpected result.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $result['response']['code'] !== 200 ) {
|
||||||
|
return new WP_Error(
|
||||||
|
'puc_unexpected_response_code',
|
||||||
|
'HTTP response code is ' . $result['response']['code'] . ' (expected: 200)'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty($result['body']) ) {
|
||||||
|
return new WP_Error('puc_empty_response', 'The metadata file appears to be empty.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
* Language packs / Translation updates
|
||||||
|
* -------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter a list of translation updates and return a new list that contains only updates
|
||||||
|
* that apply to the current site.
|
||||||
|
*
|
||||||
|
* @param array $translations
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function filterApplicableTranslations($translations) {
|
||||||
|
$languages = array_flip(array_values(get_available_languages()));
|
||||||
|
$installedTranslations = $this->getInstalledTranslations();
|
||||||
|
|
||||||
|
$applicableTranslations = array();
|
||||||
|
foreach ($translations as $translation) {
|
||||||
|
//Does it match one of the available core languages?
|
||||||
|
$isApplicable = array_key_exists($translation->language, $languages);
|
||||||
|
//Is it more recent than an already-installed translation?
|
||||||
|
if ( isset($installedTranslations[$translation->language]) ) {
|
||||||
|
$updateTimestamp = strtotime($translation->updated);
|
||||||
|
$installedTimestamp = strtotime($installedTranslations[$translation->language]['PO-Revision-Date']);
|
||||||
|
$isApplicable = $updateTimestamp > $installedTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $isApplicable ) {
|
||||||
|
$applicableTranslations[] = $translation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $applicableTranslations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of installed translations for this plugin or theme.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getInstalledTranslations() {
|
||||||
|
if ( !function_exists('wp_get_installed_translations') ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$installedTranslations = wp_get_installed_translations($this->translationType . 's');
|
||||||
|
if ( isset($installedTranslations[$this->directoryName]) ) {
|
||||||
|
$installedTranslations = $installedTranslations[$this->directoryName];
|
||||||
|
} else {
|
||||||
|
$installedTranslations = array();
|
||||||
|
}
|
||||||
|
return $installedTranslations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert translation updates into the list maintained by WordPress.
|
||||||
|
*
|
||||||
|
* @param stdClass $updates
|
||||||
|
* @return stdClass
|
||||||
|
*/
|
||||||
|
public function injectTranslationUpdates($updates) {
|
||||||
|
$translationUpdates = $this->getTranslationUpdates();
|
||||||
|
if ( empty($translationUpdates) ) {
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Being defensive.
|
||||||
|
if ( !is_object($updates) ) {
|
||||||
|
$updates = new stdClass();
|
||||||
|
}
|
||||||
|
if ( !isset($updates->translations) ) {
|
||||||
|
$updates->translations = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
//In case there's a name collision with a plugin or theme hosted on wordpress.org,
|
||||||
|
//remove any preexisting updates that match our thing.
|
||||||
|
$updates->translations = array_values(array_filter(
|
||||||
|
$updates->translations,
|
||||||
|
array($this, 'isNotMyTranslation')
|
||||||
|
));
|
||||||
|
|
||||||
|
//Add our updates to the list.
|
||||||
|
foreach($translationUpdates as $update) {
|
||||||
|
$convertedUpdate = array_merge(
|
||||||
|
array(
|
||||||
|
'type' => $this->translationType,
|
||||||
|
'slug' => $this->directoryName,
|
||||||
|
'autoupdate' => 0,
|
||||||
|
//AFAICT, WordPress doesn't actually use the "version" field for anything.
|
||||||
|
//But lets make sure it's there, just in case.
|
||||||
|
'version' => isset($update->version) ? $update->version : ('1.' . strtotime($update->updated)),
|
||||||
|
),
|
||||||
|
(array)$update
|
||||||
|
);
|
||||||
|
|
||||||
|
$updates->translations[] = $convertedUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of available translation updates.
|
||||||
|
*
|
||||||
|
* This method will return an empty array if there are no updates.
|
||||||
|
* Uses cached update data.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getTranslationUpdates() {
|
||||||
|
return $this->updateState->getTranslations();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all cached translation updates.
|
||||||
|
*
|
||||||
|
* @see wp_clean_update_cache
|
||||||
|
*/
|
||||||
|
public function clearCachedTranslationUpdates() {
|
||||||
|
$this->updateState->setTranslations(array());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter callback. Keeps only translations that *don't* match this plugin or theme.
|
||||||
|
*
|
||||||
|
* @param array $translation
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isNotMyTranslation($translation) {
|
||||||
|
$isMatch = isset($translation['type'], $translation['slug'])
|
||||||
|
&& ($translation['type'] === $this->translationType)
|
||||||
|
&& ($translation['slug'] === $this->directoryName);
|
||||||
|
|
||||||
|
return !$isMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
* Fix directory name when installing updates
|
||||||
|
* -------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename the update directory to match the existing plugin/theme directory.
|
||||||
|
*
|
||||||
|
* When WordPress installs a plugin or theme update, it assumes that the ZIP file will contain
|
||||||
|
* exactly one directory, and that the directory name will be the same as the directory where
|
||||||
|
* the plugin or theme is currently installed.
|
||||||
|
*
|
||||||
|
* GitHub and other repositories provide ZIP downloads, but they often use directory names like
|
||||||
|
* "project-branch" or "project-tag-hash". We need to change the name to the actual plugin folder.
|
||||||
|
*
|
||||||
|
* This is a hook callback. Don't call it from a plugin.
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
*
|
||||||
|
* @param string $source The directory to copy to /wp-content/plugins or /wp-content/themes. Usually a subdirectory of $remoteSource.
|
||||||
|
* @param string $remoteSource WordPress has extracted the update to this directory.
|
||||||
|
* @param WP_Upgrader $upgrader
|
||||||
|
* @return string|WP_Error
|
||||||
|
*/
|
||||||
|
public function fixDirectoryName($source, $remoteSource, $upgrader) {
|
||||||
|
global $wp_filesystem;
|
||||||
|
/** @var WP_Filesystem_Base $wp_filesystem */
|
||||||
|
|
||||||
|
//Basic sanity checks.
|
||||||
|
if ( !isset($source, $remoteSource, $upgrader, $upgrader->skin, $wp_filesystem) ) {
|
||||||
|
return $source;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If WordPress is upgrading anything other than our plugin/theme, leave the directory name unchanged.
|
||||||
|
if ( !$this->isBeingUpgraded($upgrader) ) {
|
||||||
|
return $source;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rename the source to match the existing directory.
|
||||||
|
$correctedSource = trailingslashit($remoteSource) . $this->directoryName . '/';
|
||||||
|
if ( $source !== $correctedSource ) {
|
||||||
|
//The update archive should contain a single directory that contains the rest of plugin/theme files.
|
||||||
|
//Otherwise, WordPress will try to copy the entire working directory ($source == $remoteSource).
|
||||||
|
//We can't rename $remoteSource because that would break WordPress code that cleans up temporary files
|
||||||
|
//after update.
|
||||||
|
if ( $this->isBadDirectoryStructure($remoteSource) ) {
|
||||||
|
return new WP_Error(
|
||||||
|
'puc-incorrect-directory-structure',
|
||||||
|
sprintf(
|
||||||
|
'The directory structure of the update is incorrect. All files should be inside ' .
|
||||||
|
'a directory named <span class="code">%s</span>, not at the root of the ZIP archive.',
|
||||||
|
htmlentities($this->slug)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var WP_Upgrader_Skin $upgrader ->skin */
|
||||||
|
$upgrader->skin->feedback(sprintf(
|
||||||
|
'Renaming %s to %s…',
|
||||||
|
'<span class="code">' . basename($source) . '</span>',
|
||||||
|
'<span class="code">' . $this->directoryName . '</span>'
|
||||||
|
));
|
||||||
|
|
||||||
|
if ( $wp_filesystem->move($source, $correctedSource, true) ) {
|
||||||
|
$upgrader->skin->feedback('Directory successfully renamed.');
|
||||||
|
return $correctedSource;
|
||||||
|
} else {
|
||||||
|
return new WP_Error(
|
||||||
|
'puc-rename-failed',
|
||||||
|
'Unable to rename the update to match the existing directory.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $source;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there an update being installed right now, for this plugin or theme?
|
||||||
|
*
|
||||||
|
* @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
abstract public function isBeingUpgraded($upgrader = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for incorrect update directory structure. An update must contain a single directory,
|
||||||
|
* all other files should be inside that directory.
|
||||||
|
*
|
||||||
|
* @param string $remoteSource Directory path.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isBadDirectoryStructure($remoteSource) {
|
||||||
|
global $wp_filesystem;
|
||||||
|
/** @var WP_Filesystem_Base $wp_filesystem */
|
||||||
|
|
||||||
|
$sourceFiles = $wp_filesystem->dirlist($remoteSource);
|
||||||
|
if ( is_array($sourceFiles) ) {
|
||||||
|
$sourceFiles = array_keys($sourceFiles);
|
||||||
|
$firstFilePath = trailingslashit($remoteSource) . $sourceFiles[0];
|
||||||
|
return (count($sourceFiles) > 1) || (!$wp_filesystem->is_dir($firstFilePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Assume it's fine.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
* DebugBar integration
|
||||||
|
* -------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the update checker Debug Bar plugin/add-on thingy.
|
||||||
|
*/
|
||||||
|
public function maybeInitDebugBar() {
|
||||||
|
if ( class_exists('Debug_Bar', false) && file_exists(dirname(__FILE__) . '/DebugBar') ) {
|
||||||
|
$this->debugBarExtension = $this->createDebugBarExtension();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createDebugBarExtension() {
|
||||||
|
return new Puc_v4p13_DebugBar_Extension($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display additional configuration details in the Debug Bar panel.
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_DebugBar_Panel $panel
|
||||||
|
*/
|
||||||
|
public function onDisplayConfiguration($panel) {
|
||||||
|
//Do nothing. Subclasses can use this to add additional info to the panel.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
199
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/UpgraderStatus.php
vendored
Normal file
199
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/UpgraderStatus.php
vendored
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_UpgraderStatus', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A utility class that helps figure out which plugin or theme WordPress is upgrading.
|
||||||
|
*
|
||||||
|
* It may seem strange to have a separate class just for that, but the task is surprisingly complicated.
|
||||||
|
* Core classes like Plugin_Upgrader don't expose the plugin file name during an in-progress update (AFAICT).
|
||||||
|
* This class uses a few workarounds and heuristics to get the file name.
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_UpgraderStatus {
|
||||||
|
private $currentType = null; //"plugin" or "theme".
|
||||||
|
private $currentId = null; //Plugin basename or theme directory name.
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
//Keep track of which plugin/theme WordPress is currently upgrading.
|
||||||
|
add_filter('upgrader_pre_install', array($this, 'setUpgradedThing'), 10, 2);
|
||||||
|
add_filter('upgrader_package_options', array($this, 'setUpgradedPluginFromOptions'), 10, 1);
|
||||||
|
add_filter('upgrader_post_install', array($this, 'clearUpgradedThing'), 10, 1);
|
||||||
|
add_action('upgrader_process_complete', array($this, 'clearUpgradedThing'), 10, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there and update being installed RIGHT NOW, for a specific plugin?
|
||||||
|
*
|
||||||
|
* Caution: This method is unreliable. WordPress doesn't make it easy to figure out what it is upgrading,
|
||||||
|
* and upgrader implementations are liable to change without notice.
|
||||||
|
*
|
||||||
|
* @param string $pluginFile The plugin to check.
|
||||||
|
* @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
|
||||||
|
* @return bool True if the plugin identified by $pluginFile is being upgraded.
|
||||||
|
*/
|
||||||
|
public function isPluginBeingUpgraded($pluginFile, $upgrader = null) {
|
||||||
|
return $this->isBeingUpgraded('plugin', $pluginFile, $upgrader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is there an update being installed for a specific theme?
|
||||||
|
*
|
||||||
|
* @param string $stylesheet Theme directory name.
|
||||||
|
* @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isThemeBeingUpgraded($stylesheet, $upgrader = null) {
|
||||||
|
return $this->isBeingUpgraded('theme', $stylesheet, $upgrader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a specific theme or plugin is being upgraded.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $id
|
||||||
|
* @param Plugin_Upgrader|WP_Upgrader|null $upgrader
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isBeingUpgraded($type, $id, $upgrader = null) {
|
||||||
|
if ( isset($upgrader) ) {
|
||||||
|
list($currentType, $currentId) = $this->getThingBeingUpgradedBy($upgrader);
|
||||||
|
if ( $currentType !== null ) {
|
||||||
|
$this->currentType = $currentType;
|
||||||
|
$this->currentId = $currentId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ($this->currentType === $type) && ($this->currentId === $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Figure out which theme or plugin is being upgraded by a WP_Upgrader instance.
|
||||||
|
*
|
||||||
|
* Returns an array with two items. The first item is the type of the thing that's being
|
||||||
|
* upgraded: "plugin" or "theme". The second item is either the plugin basename or
|
||||||
|
* the theme directory name. If we can't determine what the upgrader is doing, both items
|
||||||
|
* will be NULL.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* ['plugin', 'plugin-dir-name/plugin.php']
|
||||||
|
* ['theme', 'theme-dir-name']
|
||||||
|
*
|
||||||
|
* @param Plugin_Upgrader|WP_Upgrader $upgrader
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getThingBeingUpgradedBy($upgrader) {
|
||||||
|
if ( !isset($upgrader, $upgrader->skin) ) {
|
||||||
|
return array(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Figure out which plugin or theme is being upgraded.
|
||||||
|
$pluginFile = null;
|
||||||
|
$themeDirectoryName = null;
|
||||||
|
|
||||||
|
$skin = $upgrader->skin;
|
||||||
|
if ( isset($skin->theme_info) && ($skin->theme_info instanceof WP_Theme) ) {
|
||||||
|
$themeDirectoryName = $skin->theme_info->get_stylesheet();
|
||||||
|
} elseif ( $skin instanceof Plugin_Upgrader_Skin ) {
|
||||||
|
if ( isset($skin->plugin) && is_string($skin->plugin) && ($skin->plugin !== '') ) {
|
||||||
|
$pluginFile = $skin->plugin;
|
||||||
|
}
|
||||||
|
} elseif ( $skin instanceof Theme_Upgrader_Skin ) {
|
||||||
|
if ( isset($skin->theme) && is_string($skin->theme) && ($skin->theme !== '') ) {
|
||||||
|
$themeDirectoryName = $skin->theme;
|
||||||
|
}
|
||||||
|
} elseif ( isset($skin->plugin_info) && is_array($skin->plugin_info) ) {
|
||||||
|
//This case is tricky because Bulk_Plugin_Upgrader_Skin (etc) doesn't actually store the plugin
|
||||||
|
//filename anywhere. Instead, it has the plugin headers in $plugin_info. So the best we can
|
||||||
|
//do is compare those headers to the headers of installed plugins.
|
||||||
|
$pluginFile = $this->identifyPluginByHeaders($skin->plugin_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $pluginFile !== null ) {
|
||||||
|
return array('plugin', $pluginFile);
|
||||||
|
} elseif ( $themeDirectoryName !== null ) {
|
||||||
|
return array('theme', $themeDirectoryName);
|
||||||
|
}
|
||||||
|
return array(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identify an installed plugin based on its headers.
|
||||||
|
*
|
||||||
|
* @param array $searchHeaders The plugin file header to look for.
|
||||||
|
* @return string|null Plugin basename ("foo/bar.php"), or NULL if we can't identify the plugin.
|
||||||
|
*/
|
||||||
|
private function identifyPluginByHeaders($searchHeaders) {
|
||||||
|
if ( !function_exists('get_plugins') ){
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$installedPlugins = get_plugins();
|
||||||
|
$matches = array();
|
||||||
|
foreach($installedPlugins as $pluginBasename => $headers) {
|
||||||
|
$diff1 = array_diff_assoc($headers, $searchHeaders);
|
||||||
|
$diff2 = array_diff_assoc($searchHeaders, $headers);
|
||||||
|
if ( empty($diff1) && empty($diff2) ) {
|
||||||
|
$matches[] = $pluginBasename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//It's possible (though very unlikely) that there could be two plugins with identical
|
||||||
|
//headers. In that case, we can't unambiguously identify the plugin that's being upgraded.
|
||||||
|
if ( count($matches) !== 1 ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reset($matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @param mixed $input
|
||||||
|
* @param array $hookExtra
|
||||||
|
* @return mixed Returns $input unaltered.
|
||||||
|
*/
|
||||||
|
public function setUpgradedThing($input, $hookExtra) {
|
||||||
|
if ( !empty($hookExtra['plugin']) && is_string($hookExtra['plugin']) ) {
|
||||||
|
$this->currentId = $hookExtra['plugin'];
|
||||||
|
$this->currentType = 'plugin';
|
||||||
|
} elseif ( !empty($hookExtra['theme']) && is_string($hookExtra['theme']) ) {
|
||||||
|
$this->currentId = $hookExtra['theme'];
|
||||||
|
$this->currentType = 'theme';
|
||||||
|
} else {
|
||||||
|
$this->currentType = null;
|
||||||
|
$this->currentId = null;
|
||||||
|
}
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function setUpgradedPluginFromOptions($options) {
|
||||||
|
if ( isset($options['hook_extra']['plugin']) && is_string($options['hook_extra']['plugin']) ) {
|
||||||
|
$this->currentType = 'plugin';
|
||||||
|
$this->currentId = $options['hook_extra']['plugin'];
|
||||||
|
} else {
|
||||||
|
$this->currentType = null;
|
||||||
|
$this->currentId = null;
|
||||||
|
}
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
* @param mixed $input
|
||||||
|
* @return mixed Returns $input unaltered.
|
||||||
|
*/
|
||||||
|
public function clearUpgradedThing($input = null) {
|
||||||
|
$this->currentId = null;
|
||||||
|
$this->currentType = null;
|
||||||
|
return $input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
69
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Utils.php
vendored
Normal file
69
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Utils.php
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_Utils', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Utils {
|
||||||
|
/**
|
||||||
|
* Get a value from a nested array or object based on a path.
|
||||||
|
*
|
||||||
|
* @param array|object|null $collection Get an entry from this array.
|
||||||
|
* @param array|string $path A list of array keys in hierarchy order, or a string path like "foo.bar.baz".
|
||||||
|
* @param mixed $default The value to return if the specified path is not found.
|
||||||
|
* @param string $separator Path element separator. Only applies to string paths.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function get($collection, $path, $default = null, $separator = '.') {
|
||||||
|
if ( is_string($path) ) {
|
||||||
|
$path = explode($separator, $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Follow the $path into $input as far as possible.
|
||||||
|
$currentValue = $collection;
|
||||||
|
foreach ($path as $node) {
|
||||||
|
if ( is_array($currentValue) && isset($currentValue[$node]) ) {
|
||||||
|
$currentValue = $currentValue[$node];
|
||||||
|
} else if ( is_object($currentValue) && isset($currentValue->$node) ) {
|
||||||
|
$currentValue = $currentValue->$node;
|
||||||
|
} else {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the first array element that is not empty.
|
||||||
|
*
|
||||||
|
* @param array $values
|
||||||
|
* @param mixed|null $default Returns this value if there are no non-empty elements.
|
||||||
|
* @return mixed|null
|
||||||
|
*/
|
||||||
|
public static function findNotEmpty($values, $default = null) {
|
||||||
|
if ( empty($values) ) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($values as $value) {
|
||||||
|
if ( !empty($value) ) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the input string starts with the specified prefix.
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @param string $prefix
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function startsWith($input, $prefix) {
|
||||||
|
$length = strlen($prefix);
|
||||||
|
return (substr($input, 0, $length) === $prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
302
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/Api.php
vendored
Normal file
302
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/Api.php
vendored
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Vcs_Api') ):
|
||||||
|
|
||||||
|
abstract class Puc_v4p13_Vcs_Api {
|
||||||
|
protected $tagNameProperty = 'name';
|
||||||
|
protected $slug = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $repositoryUrl = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var mixed Authentication details for private repositories. Format depends on service.
|
||||||
|
*/
|
||||||
|
protected $credentials = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The filter tag that's used to filter options passed to wp_remote_get.
|
||||||
|
* For example, "puc_request_info_options-slug" or "puc_request_update_options_theme-slug".
|
||||||
|
*/
|
||||||
|
protected $httpFilterName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $localDirectory = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puc_v4p13_Vcs_Api constructor.
|
||||||
|
*
|
||||||
|
* @param string $repositoryUrl
|
||||||
|
* @param array|string|null $credentials
|
||||||
|
*/
|
||||||
|
public function __construct($repositoryUrl, $credentials = null) {
|
||||||
|
$this->repositoryUrl = $repositoryUrl;
|
||||||
|
$this->setAuthentication($credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRepositoryUrl() {
|
||||||
|
return $this->repositoryUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Figure out which reference (i.e tag or branch) contains the latest version.
|
||||||
|
*
|
||||||
|
* @param string $configBranch Start looking in this branch.
|
||||||
|
* @return null|Puc_v4p13_Vcs_Reference
|
||||||
|
*/
|
||||||
|
abstract public function chooseReference($configBranch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the readme.txt file from the remote repository and parse it
|
||||||
|
* according to the plugin readme standard.
|
||||||
|
*
|
||||||
|
* @param string $ref Tag or branch name.
|
||||||
|
* @return array Parsed readme.
|
||||||
|
*/
|
||||||
|
public function getRemoteReadme($ref = 'master') {
|
||||||
|
$fileContents = $this->getRemoteFile($this->getLocalReadmeName(), $ref);
|
||||||
|
if ( empty($fileContents) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$parser = new PucReadmeParser();
|
||||||
|
return $parser->parse_readme_contents($fileContents);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the case-sensitive name of the local readme.txt file.
|
||||||
|
*
|
||||||
|
* In most cases it should just be called "readme.txt", but some plugins call it "README.txt",
|
||||||
|
* "README.TXT", or even "Readme.txt". Most VCS are case-sensitive so we need to know the correct
|
||||||
|
* capitalization.
|
||||||
|
*
|
||||||
|
* Defaults to "readme.txt" (all lowercase).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLocalReadmeName() {
|
||||||
|
static $fileName = null;
|
||||||
|
if ( $fileName !== null ) {
|
||||||
|
return $fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileName = 'readme.txt';
|
||||||
|
if ( isset($this->localDirectory) ) {
|
||||||
|
$files = scandir($this->localDirectory);
|
||||||
|
if ( !empty($files) ) {
|
||||||
|
foreach ($files as $possibleFileName) {
|
||||||
|
if ( strcasecmp($possibleFileName, 'readme.txt') === 0 ) {
|
||||||
|
$fileName = $possibleFileName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a branch.
|
||||||
|
*
|
||||||
|
* @param string $branchName
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
abstract public function getBranch($branchName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific tag.
|
||||||
|
*
|
||||||
|
* @param string $tagName
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
abstract public function getTag($tagName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tag that looks like the highest version number.
|
||||||
|
* (Implementations should skip pre-release versions if possible.)
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
abstract public function getLatestTag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a tag name string looks like a version number.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function looksLikeVersion($name) {
|
||||||
|
//Tag names may be prefixed with "v", e.g. "v1.2.3".
|
||||||
|
$name = ltrim($name, 'v');
|
||||||
|
|
||||||
|
//The version string must start with a number.
|
||||||
|
if ( !is_numeric(substr($name, 0, 1)) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//The goal is to accept any SemVer-compatible or "PHP-standardized" version number.
|
||||||
|
return (preg_match('@^(\d{1,5}?)(\.\d{1,10}?){0,4}?($|[abrdp+_\-]|\s)@i', $name) === 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a tag appears to be named like a version number.
|
||||||
|
*
|
||||||
|
* @param stdClass $tag
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isVersionTag($tag) {
|
||||||
|
$property = $this->tagNameProperty;
|
||||||
|
return isset($tag->$property) && $this->looksLikeVersion($tag->$property);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort a list of tags as if they were version numbers.
|
||||||
|
* Tags that don't look like version number will be removed.
|
||||||
|
*
|
||||||
|
* @param stdClass[] $tags Array of tag objects.
|
||||||
|
* @return stdClass[] Filtered array of tags sorted in descending order.
|
||||||
|
*/
|
||||||
|
protected function sortTagsByVersion($tags) {
|
||||||
|
//Keep only those tags that look like version numbers.
|
||||||
|
$versionTags = array_filter($tags, array($this, 'isVersionTag'));
|
||||||
|
//Sort them in descending order.
|
||||||
|
usort($versionTags, array($this, 'compareTagNames'));
|
||||||
|
|
||||||
|
return $versionTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two tags as if they were version number.
|
||||||
|
*
|
||||||
|
* @param stdClass $tag1 Tag object.
|
||||||
|
* @param stdClass $tag2 Another tag object.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function compareTagNames($tag1, $tag2) {
|
||||||
|
$property = $this->tagNameProperty;
|
||||||
|
if ( !isset($tag1->$property) ) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ( !isset($tag2->$property) ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return -version_compare(ltrim($tag1->$property, 'v'), ltrim($tag2->$property, 'v'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a file from a specific branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $path File name.
|
||||||
|
* @param string $ref
|
||||||
|
* @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
|
||||||
|
*/
|
||||||
|
abstract public function getRemoteFile($path, $ref = 'master');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timestamp of the latest commit that changed the specified branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $ref Reference name (e.g. branch or tag).
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
abstract public function getLatestCommitTime($ref);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of the changelog file from the repository.
|
||||||
|
*
|
||||||
|
* @param string $ref
|
||||||
|
* @param string $localDirectory Full path to the local plugin or theme directory.
|
||||||
|
* @return null|string The HTML contents of the changelog.
|
||||||
|
*/
|
||||||
|
public function getRemoteChangelog($ref, $localDirectory) {
|
||||||
|
$filename = $this->findChangelogName($localDirectory);
|
||||||
|
if ( empty($filename) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$changelog = $this->getRemoteFile($filename, $ref);
|
||||||
|
if ( $changelog === null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpUndefinedClassInspection */
|
||||||
|
return Parsedown::instance()->text($changelog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guess the name of the changelog file.
|
||||||
|
*
|
||||||
|
* @param string $directory
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
protected function findChangelogName($directory = null) {
|
||||||
|
if ( !isset($directory) ) {
|
||||||
|
$directory = $this->localDirectory;
|
||||||
|
}
|
||||||
|
if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$possibleNames = array('CHANGES.md', 'CHANGELOG.md', 'changes.md', 'changelog.md');
|
||||||
|
$files = scandir($directory);
|
||||||
|
$foundNames = array_intersect($possibleNames, $files);
|
||||||
|
|
||||||
|
if ( !empty($foundNames) ) {
|
||||||
|
return reset($foundNames);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set authentication credentials.
|
||||||
|
*
|
||||||
|
* @param $credentials
|
||||||
|
*/
|
||||||
|
public function setAuthentication($credentials) {
|
||||||
|
$this->credentials = $credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAuthenticationEnabled() {
|
||||||
|
return !empty($this->credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $url
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function signDownloadUrl($url) {
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $filterName
|
||||||
|
*/
|
||||||
|
public function setHttpFilterName($filterName) {
|
||||||
|
$this->httpFilterName = $filterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $directory
|
||||||
|
*/
|
||||||
|
public function setLocalDirectory($directory) {
|
||||||
|
if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) {
|
||||||
|
$this->localDirectory = null;
|
||||||
|
} else {
|
||||||
|
$this->localDirectory = $directory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $slug
|
||||||
|
*/
|
||||||
|
public function setSlug($slug) {
|
||||||
|
$this->slug = $slug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
27
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/BaseChecker.php
vendored
Normal file
27
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/BaseChecker.php
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
if ( !interface_exists('Puc_v4p13_Vcs_BaseChecker', false) ):
|
||||||
|
|
||||||
|
interface Puc_v4p13_Vcs_BaseChecker {
|
||||||
|
/**
|
||||||
|
* Set the repository branch to use for updates. Defaults to 'master'.
|
||||||
|
*
|
||||||
|
* @param string $branch
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setBranch($branch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set authentication credentials.
|
||||||
|
*
|
||||||
|
* @param array|string $credentials
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setAuthentication($credentials);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Puc_v4p13_Vcs_Api
|
||||||
|
*/
|
||||||
|
public function getVcsApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
273
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/BitBucketApi.php
vendored
Normal file
273
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/BitBucketApi.php
vendored
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Vcs_BitBucketApi', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Vcs_BitBucketApi extends Puc_v4p13_Vcs_Api {
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_OAuthSignature
|
||||||
|
*/
|
||||||
|
private $oauth = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
public function __construct($repositoryUrl, $credentials = array()) {
|
||||||
|
$path = parse_url($repositoryUrl, PHP_URL_PATH);
|
||||||
|
if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
|
||||||
|
$this->username = $matches['username'];
|
||||||
|
$this->repository = $matches['repository'];
|
||||||
|
} else {
|
||||||
|
throw new InvalidArgumentException('Invalid BitBucket repository URL: "' . $repositoryUrl . '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($repositoryUrl, $credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Figure out which reference (i.e tag or branch) contains the latest version.
|
||||||
|
*
|
||||||
|
* @param string $configBranch Start looking in this branch.
|
||||||
|
* @return null|Puc_v4p13_Vcs_Reference
|
||||||
|
*/
|
||||||
|
public function chooseReference($configBranch) {
|
||||||
|
$updateSource = null;
|
||||||
|
|
||||||
|
//Check if there's a "Stable tag: 1.2.3" header that points to a valid tag.
|
||||||
|
$updateSource = $this->getStableTag($configBranch);
|
||||||
|
|
||||||
|
//Look for version-like tags.
|
||||||
|
if ( !$updateSource && ($configBranch === 'master' || $configBranch === 'main') ) {
|
||||||
|
$updateSource = $this->getLatestTag();
|
||||||
|
}
|
||||||
|
//If all else fails, use the specified branch itself.
|
||||||
|
if ( !$updateSource ) {
|
||||||
|
$updateSource = $this->getBranch($configBranch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updateSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBranch($branchName) {
|
||||||
|
$branch = $this->api('/refs/branches/' . $branchName);
|
||||||
|
if ( is_wp_error($branch) || empty($branch) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//The "/src/{stuff}/{path}" endpoint doesn't seem to handle branch names that contain slashes.
|
||||||
|
//If we don't encode the slash, we get a 404. If we encode it as "%2F", we get a 401.
|
||||||
|
//To avoid issues, if the branch name is not URL-safe, let's use the commit hash instead.
|
||||||
|
$ref = $branch->name;
|
||||||
|
if ((urlencode($ref) !== $ref) && isset($branch->target->hash)) {
|
||||||
|
$ref = $branch->target->hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $ref,
|
||||||
|
'updated' => $branch->target->date,
|
||||||
|
'downloadUrl' => $this->getDownloadUrl($branch->name),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific tag.
|
||||||
|
*
|
||||||
|
* @param string $tagName
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
public function getTag($tagName) {
|
||||||
|
$tag = $this->api('/refs/tags/' . $tagName);
|
||||||
|
if ( is_wp_error($tag) || empty($tag) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $tag->name,
|
||||||
|
'version' => ltrim($tag->name, 'v'),
|
||||||
|
'updated' => $tag->target->date,
|
||||||
|
'downloadUrl' => $this->getDownloadUrl($tag->name),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tag that looks like the highest version number.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
public function getLatestTag() {
|
||||||
|
$tags = $this->api('/refs/tags?sort=-target.date');
|
||||||
|
if ( !isset($tags, $tags->values) || !is_array($tags->values) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Filter and sort the list of tags.
|
||||||
|
$versionTags = $this->sortTagsByVersion($tags->values);
|
||||||
|
|
||||||
|
//Return the first result.
|
||||||
|
if ( !empty($versionTags) ) {
|
||||||
|
$tag = $versionTags[0];
|
||||||
|
return new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $tag->name,
|
||||||
|
'version' => ltrim($tag->name, 'v'),
|
||||||
|
'updated' => $tag->target->date,
|
||||||
|
'downloadUrl' => $this->getDownloadUrl($tag->name),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tag/ref specified by the "Stable tag" header in the readme.txt of a given branch.
|
||||||
|
*
|
||||||
|
* @param string $branch
|
||||||
|
* @return null|Puc_v4p13_Vcs_Reference
|
||||||
|
*/
|
||||||
|
protected function getStableTag($branch) {
|
||||||
|
$remoteReadme = $this->getRemoteReadme($branch);
|
||||||
|
if ( !empty($remoteReadme['stable_tag']) ) {
|
||||||
|
$tag = $remoteReadme['stable_tag'];
|
||||||
|
|
||||||
|
//You can explicitly opt out of using tags by setting "Stable tag" to
|
||||||
|
//"trunk" or the name of the current branch.
|
||||||
|
if ( ($tag === $branch) || ($tag === 'trunk') ) {
|
||||||
|
return $this->getBranch($branch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getTag($tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $ref
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getDownloadUrl($ref) {
|
||||||
|
return sprintf(
|
||||||
|
'https://bitbucket.org/%s/%s/get/%s.zip',
|
||||||
|
$this->username,
|
||||||
|
$this->repository,
|
||||||
|
$ref
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a file from a specific branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $path File name.
|
||||||
|
* @param string $ref
|
||||||
|
* @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
|
||||||
|
*/
|
||||||
|
public function getRemoteFile($path, $ref = 'master') {
|
||||||
|
$response = $this->api('src/' . $ref . '/' . ltrim($path));
|
||||||
|
if ( is_wp_error($response) || !is_string($response) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timestamp of the latest commit that changed the specified branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $ref Reference name (e.g. branch or tag).
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getLatestCommitTime($ref) {
|
||||||
|
$response = $this->api('commits/' . $ref);
|
||||||
|
if ( isset($response->values, $response->values[0], $response->values[0]->date) ) {
|
||||||
|
return $response->values[0]->date;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a BitBucket API 2.0 request.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param string $version
|
||||||
|
* @return mixed|WP_Error
|
||||||
|
*/
|
||||||
|
public function api($url, $version = '2.0') {
|
||||||
|
$url = ltrim($url, '/');
|
||||||
|
$isSrcResource = Puc_v4p13_Utils::startsWith($url, 'src/');
|
||||||
|
|
||||||
|
$url = implode('/', array(
|
||||||
|
'https://api.bitbucket.org',
|
||||||
|
$version,
|
||||||
|
'repositories',
|
||||||
|
$this->username,
|
||||||
|
$this->repository,
|
||||||
|
$url
|
||||||
|
));
|
||||||
|
$baseUrl = $url;
|
||||||
|
|
||||||
|
if ( $this->oauth ) {
|
||||||
|
$url = $this->oauth->sign($url,'GET');
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = array('timeout' => 10);
|
||||||
|
if ( !empty($this->httpFilterName) ) {
|
||||||
|
$options = apply_filters($this->httpFilterName, $options);
|
||||||
|
}
|
||||||
|
$response = wp_remote_get($url, $options);
|
||||||
|
if ( is_wp_error($response) ) {
|
||||||
|
do_action('puc_api_error', $response, null, $url, $this->slug);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$code = wp_remote_retrieve_response_code($response);
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
if ( $code === 200 ) {
|
||||||
|
if ( $isSrcResource ) {
|
||||||
|
//Most responses are JSON-encoded, but src resources just
|
||||||
|
//return raw file contents.
|
||||||
|
$document = $body;
|
||||||
|
} else {
|
||||||
|
$document = json_decode($body);
|
||||||
|
}
|
||||||
|
return $document;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = new WP_Error(
|
||||||
|
'puc-bitbucket-http-error',
|
||||||
|
sprintf('BitBucket API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code)
|
||||||
|
);
|
||||||
|
do_action('puc_api_error', $error, $response, $url, $this->slug);
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $credentials
|
||||||
|
*/
|
||||||
|
public function setAuthentication($credentials) {
|
||||||
|
parent::setAuthentication($credentials);
|
||||||
|
|
||||||
|
if ( !empty($credentials) && !empty($credentials['consumer_key']) ) {
|
||||||
|
$this->oauth = new Puc_v4p13_OAuthSignature(
|
||||||
|
$credentials['consumer_key'],
|
||||||
|
$credentials['consumer_secret']
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->oauth = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function signDownloadUrl($url) {
|
||||||
|
//Add authentication data to download URLs. Since OAuth signatures incorporate
|
||||||
|
//timestamps, we have to do this immediately before inserting the update. Otherwise
|
||||||
|
//authentication could fail due to a stale timestamp.
|
||||||
|
if ( $this->oauth ) {
|
||||||
|
$url = $this->oauth->sign($url);
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
441
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/GitHubApi.php
vendored
Normal file
441
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/GitHubApi.php
vendored
Normal file
@ -0,0 +1,441 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_Vcs_GitHubApi', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Vcs_GitHubApi extends Puc_v4p13_Vcs_Api {
|
||||||
|
/**
|
||||||
|
* @var string GitHub username.
|
||||||
|
*/
|
||||||
|
protected $userName;
|
||||||
|
/**
|
||||||
|
* @var string GitHub repository name.
|
||||||
|
*/
|
||||||
|
protected $repositoryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Either a fully qualified repository URL, or just "user/repo-name".
|
||||||
|
*/
|
||||||
|
protected $repositoryUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string GitHub authentication token. Optional.
|
||||||
|
*/
|
||||||
|
protected $accessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Whether to download release assets instead of the auto-generated source code archives.
|
||||||
|
*/
|
||||||
|
protected $releaseAssetsEnabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null Regular expression that's used to filter release assets by name. Optional.
|
||||||
|
*/
|
||||||
|
protected $assetFilterRegex = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|null The unchanging part of a release asset URL. Used to identify download attempts.
|
||||||
|
*/
|
||||||
|
protected $assetApiBaseUrl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $downloadFilterAdded = false;
|
||||||
|
|
||||||
|
public function __construct($repositoryUrl, $accessToken = null) {
|
||||||
|
$path = parse_url($repositoryUrl, PHP_URL_PATH);
|
||||||
|
if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
|
||||||
|
$this->userName = $matches['username'];
|
||||||
|
$this->repositoryName = $matches['repository'];
|
||||||
|
} else {
|
||||||
|
throw new InvalidArgumentException('Invalid GitHub repository URL: "' . $repositoryUrl . '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($repositoryUrl, $accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest release from GitHub.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
public function getLatestRelease() {
|
||||||
|
$release = $this->api('/repos/:user/:repo/releases/latest');
|
||||||
|
if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reference = new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $release->tag_name,
|
||||||
|
'version' => ltrim($release->tag_name, 'v'), //Remove the "v" prefix from "v1.2.3".
|
||||||
|
'downloadUrl' => $release->zipball_url,
|
||||||
|
'updated' => $release->created_at,
|
||||||
|
'apiResponse' => $release,
|
||||||
|
));
|
||||||
|
|
||||||
|
if ( isset($release->assets[0]) ) {
|
||||||
|
$reference->downloadCount = $release->assets[0]->download_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->releaseAssetsEnabled && isset($release->assets, $release->assets[0]) ) {
|
||||||
|
//Use the first release asset that matches the specified regular expression.
|
||||||
|
$matchingAssets = array_filter($release->assets, array($this, 'matchesAssetFilter'));
|
||||||
|
if ( !empty($matchingAssets) ) {
|
||||||
|
if ( $this->isAuthenticationEnabled() ) {
|
||||||
|
/**
|
||||||
|
* Keep in mind that we'll need to add an "Accept" header to download this asset.
|
||||||
|
*
|
||||||
|
* @see setUpdateDownloadHeaders()
|
||||||
|
*/
|
||||||
|
$reference->downloadUrl = $matchingAssets[0]->url;
|
||||||
|
} else {
|
||||||
|
//It seems that browser_download_url only works for public repositories.
|
||||||
|
//Using an access_token doesn't help. Maybe OAuth would work?
|
||||||
|
$reference->downloadUrl = $matchingAssets[0]->browser_download_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reference->downloadCount = $matchingAssets[0]->download_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($release->body) ) {
|
||||||
|
/** @noinspection PhpUndefinedClassInspection */
|
||||||
|
$reference->changelog = Parsedown::instance()->text($release->body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tag that looks like the highest version number.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
public function getLatestTag() {
|
||||||
|
$tags = $this->api('/repos/:user/:repo/tags');
|
||||||
|
|
||||||
|
if ( is_wp_error($tags) || !is_array($tags) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$versionTags = $this->sortTagsByVersion($tags);
|
||||||
|
if ( empty($versionTags) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tag = $versionTags[0];
|
||||||
|
return new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $tag->name,
|
||||||
|
'version' => ltrim($tag->name, 'v'),
|
||||||
|
'downloadUrl' => $tag->zipball_url,
|
||||||
|
'apiResponse' => $tag,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a branch by name.
|
||||||
|
*
|
||||||
|
* @param string $branchName
|
||||||
|
* @return null|Puc_v4p13_Vcs_Reference
|
||||||
|
*/
|
||||||
|
public function getBranch($branchName) {
|
||||||
|
$branch = $this->api('/repos/:user/:repo/branches/' . $branchName);
|
||||||
|
if ( is_wp_error($branch) || empty($branch) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reference = new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $branch->name,
|
||||||
|
'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name),
|
||||||
|
'apiResponse' => $branch,
|
||||||
|
));
|
||||||
|
|
||||||
|
if ( isset($branch->commit, $branch->commit->commit, $branch->commit->commit->author->date) ) {
|
||||||
|
$reference->updated = $branch->commit->commit->author->date;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest commit that changed the specified file.
|
||||||
|
*
|
||||||
|
* @param string $filename
|
||||||
|
* @param string $ref Reference name (e.g. branch or tag).
|
||||||
|
* @return StdClass|null
|
||||||
|
*/
|
||||||
|
public function getLatestCommit($filename, $ref = 'master') {
|
||||||
|
$commits = $this->api(
|
||||||
|
'/repos/:user/:repo/commits',
|
||||||
|
array(
|
||||||
|
'path' => $filename,
|
||||||
|
'sha' => $ref,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ( !is_wp_error($commits) && isset($commits[0]) ) {
|
||||||
|
return $commits[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timestamp of the latest commit that changed the specified branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $ref Reference name (e.g. branch or tag).
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getLatestCommitTime($ref) {
|
||||||
|
$commits = $this->api('/repos/:user/:repo/commits', array('sha' => $ref));
|
||||||
|
if ( !is_wp_error($commits) && isset($commits[0]) ) {
|
||||||
|
return $commits[0]->commit->author->date;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a GitHub API request.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param array $queryParams
|
||||||
|
* @return mixed|WP_Error
|
||||||
|
*/
|
||||||
|
protected function api($url, $queryParams = array()) {
|
||||||
|
$baseUrl = $url;
|
||||||
|
$url = $this->buildApiUrl($url, $queryParams);
|
||||||
|
|
||||||
|
$options = array('timeout' => 10);
|
||||||
|
if ( $this->isAuthenticationEnabled() ) {
|
||||||
|
$options['headers'] = array('Authorization' => $this->getAuthorizationHeader());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($this->httpFilterName) ) {
|
||||||
|
$options = apply_filters($this->httpFilterName, $options);
|
||||||
|
}
|
||||||
|
$response = wp_remote_get($url, $options);
|
||||||
|
if ( is_wp_error($response) ) {
|
||||||
|
do_action('puc_api_error', $response, null, $url, $this->slug);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$code = wp_remote_retrieve_response_code($response);
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
if ( $code === 200 ) {
|
||||||
|
$document = json_decode($body);
|
||||||
|
return $document;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = new WP_Error(
|
||||||
|
'puc-github-http-error',
|
||||||
|
sprintf('GitHub API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code)
|
||||||
|
);
|
||||||
|
do_action('puc_api_error', $error, $response, $url, $this->slug);
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a fully qualified URL for an API request.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param array $queryParams
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function buildApiUrl($url, $queryParams) {
|
||||||
|
$variables = array(
|
||||||
|
'user' => $this->userName,
|
||||||
|
'repo' => $this->repositoryName,
|
||||||
|
);
|
||||||
|
foreach ($variables as $name => $value) {
|
||||||
|
$url = str_replace('/:' . $name, '/' . urlencode($value), $url);
|
||||||
|
}
|
||||||
|
$url = 'https://api.github.com' . $url;
|
||||||
|
|
||||||
|
if ( !empty($queryParams) ) {
|
||||||
|
$url = add_query_arg($queryParams, $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a file from a specific branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $path File name.
|
||||||
|
* @param string $ref
|
||||||
|
* @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
|
||||||
|
*/
|
||||||
|
public function getRemoteFile($path, $ref = 'master') {
|
||||||
|
$apiUrl = '/repos/:user/:repo/contents/' . $path;
|
||||||
|
$response = $this->api($apiUrl, array('ref' => $ref));
|
||||||
|
|
||||||
|
if ( is_wp_error($response) || !isset($response->content) || ($response->encoding !== 'base64') ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return base64_decode($response->content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a URL to download a ZIP archive of the specified branch/tag/etc.
|
||||||
|
*
|
||||||
|
* @param string $ref
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function buildArchiveDownloadUrl($ref = 'master') {
|
||||||
|
$url = sprintf(
|
||||||
|
'https://api.github.com/repos/%1$s/%2$s/zipball/%3$s',
|
||||||
|
urlencode($this->userName),
|
||||||
|
urlencode($this->repositoryName),
|
||||||
|
urlencode($ref)
|
||||||
|
);
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific tag.
|
||||||
|
*
|
||||||
|
* @param string $tagName
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getTag($tagName) {
|
||||||
|
//The current GitHub update checker doesn't use getTag, so I didn't bother to implement it.
|
||||||
|
throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAuthentication($credentials) {
|
||||||
|
parent::setAuthentication($credentials);
|
||||||
|
$this->accessToken = is_string($credentials) ? $credentials : null;
|
||||||
|
|
||||||
|
//Optimization: Instead of filtering all HTTP requests, let's do it only when
|
||||||
|
//WordPress is about to download an update.
|
||||||
|
add_filter('upgrader_pre_download', array($this, 'addHttpRequestFilter'), 10, 1); //WP 3.7+
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Figure out which reference (i.e tag or branch) contains the latest version.
|
||||||
|
*
|
||||||
|
* @param string $configBranch Start looking in this branch.
|
||||||
|
* @return null|Puc_v4p13_Vcs_Reference
|
||||||
|
*/
|
||||||
|
public function chooseReference($configBranch) {
|
||||||
|
$updateSource = null;
|
||||||
|
|
||||||
|
if ( $configBranch === 'master' ) {
|
||||||
|
//Use the latest release.
|
||||||
|
$updateSource = $this->getLatestRelease();
|
||||||
|
if ( $updateSource === null ) {
|
||||||
|
//Failing that, use the tag with the highest version number.
|
||||||
|
$updateSource = $this->getLatestTag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Alternatively, just use the branch itself.
|
||||||
|
if ( empty($updateSource) ) {
|
||||||
|
$updateSource = $this->getBranch($configBranch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updateSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable updating via release assets.
|
||||||
|
*
|
||||||
|
* If the latest release contains no usable assets, the update checker
|
||||||
|
* will fall back to using the automatically generated ZIP archive.
|
||||||
|
*
|
||||||
|
* Private repositories will only work with WordPress 3.7 or later.
|
||||||
|
*
|
||||||
|
* @param string|null $fileNameRegex Optional. Use only those assets where the file name matches this regex.
|
||||||
|
*/
|
||||||
|
public function enableReleaseAssets($fileNameRegex = null) {
|
||||||
|
$this->releaseAssetsEnabled = true;
|
||||||
|
$this->assetFilterRegex = $fileNameRegex;
|
||||||
|
$this->assetApiBaseUrl = sprintf(
|
||||||
|
'//api.github.com/repos/%1$s/%2$s/releases/assets/',
|
||||||
|
$this->userName,
|
||||||
|
$this->repositoryName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does this asset match the file name regex?
|
||||||
|
*
|
||||||
|
* @param stdClass $releaseAsset
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function matchesAssetFilter($releaseAsset) {
|
||||||
|
if ( $this->assetFilterRegex === null ) {
|
||||||
|
//The default is to accept all assets.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return isset($releaseAsset->name) && preg_match($this->assetFilterRegex, $releaseAsset->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @param bool $result
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function addHttpRequestFilter($result) {
|
||||||
|
if ( !$this->downloadFilterAdded && $this->isAuthenticationEnabled() ) {
|
||||||
|
add_filter('http_request_args', array($this, 'setUpdateDownloadHeaders'), 10, 2);
|
||||||
|
add_action('requests-requests.before_redirect', array($this, 'removeAuthHeaderFromRedirects'), 10, 4);
|
||||||
|
$this->downloadFilterAdded = true;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the HTTP headers that are necessary to download updates from private repositories.
|
||||||
|
*
|
||||||
|
* See GitHub docs:
|
||||||
|
* @link https://developer.github.com/v3/repos/releases/#get-a-single-release-asset
|
||||||
|
* @link https://developer.github.com/v3/auth/#basic-authentication
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @param array $requestArgs
|
||||||
|
* @param string $url
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function setUpdateDownloadHeaders($requestArgs, $url = '') {
|
||||||
|
//Is WordPress trying to download one of our release assets?
|
||||||
|
if ( $this->releaseAssetsEnabled && (strpos($url, $this->assetApiBaseUrl) !== false) ) {
|
||||||
|
$requestArgs['headers']['Accept'] = 'application/octet-stream';
|
||||||
|
}
|
||||||
|
//Use Basic authentication, but only if the download is from our repository.
|
||||||
|
$repoApiBaseUrl = $this->buildApiUrl('/repos/:user/:repo/', array());
|
||||||
|
if ( $this->isAuthenticationEnabled() && (strpos($url, $repoApiBaseUrl)) === 0 ) {
|
||||||
|
$requestArgs['headers']['Authorization'] = $this->getAuthorizationHeader();
|
||||||
|
}
|
||||||
|
return $requestArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When following a redirect, the Requests library will automatically forward
|
||||||
|
* the authorization header to other hosts. We don't want that because it breaks
|
||||||
|
* AWS downloads and can leak authorization information.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @param string $location
|
||||||
|
* @param array $headers
|
||||||
|
*/
|
||||||
|
public function removeAuthHeaderFromRedirects(&$location, &$headers) {
|
||||||
|
$repoApiBaseUrl = $this->buildApiUrl('/repos/:user/:repo/', array());
|
||||||
|
if ( strpos($location, $repoApiBaseUrl) === 0 ) {
|
||||||
|
return; //This request is going to GitHub, so it's fine.
|
||||||
|
}
|
||||||
|
//Remove the header.
|
||||||
|
if ( isset($headers['Authorization']) ) {
|
||||||
|
unset($headers['Authorization']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the value of the "Authorization" header.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getAuthorizationHeader() {
|
||||||
|
return 'Basic ' . base64_encode($this->userName . ':' . $this->accessToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
400
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/GitLabApi.php
vendored
Normal file
400
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/GitLabApi.php
vendored
Normal file
@ -0,0 +1,400 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_Vcs_GitLabApi', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Vcs_GitLabApi extends Puc_v4p13_Vcs_Api {
|
||||||
|
/**
|
||||||
|
* @var string GitLab username.
|
||||||
|
*/
|
||||||
|
protected $userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string GitLab server host.
|
||||||
|
*/
|
||||||
|
protected $repositoryHost;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Protocol used by this GitLab server: "http" or "https".
|
||||||
|
*/
|
||||||
|
protected $repositoryProtocol = 'https';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string GitLab repository name.
|
||||||
|
*/
|
||||||
|
protected $repositoryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string GitLab authentication token. Optional.
|
||||||
|
*/
|
||||||
|
protected $accessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Whether to download release assets instead of the auto-generated source code archives.
|
||||||
|
*/
|
||||||
|
protected $releaseAssetsEnabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Whether to download release asset package rather than release asset source.
|
||||||
|
*/
|
||||||
|
protected $releasePackageEnabled = false;
|
||||||
|
|
||||||
|
public function __construct($repositoryUrl, $accessToken = null, $subgroup = null) {
|
||||||
|
//Parse the repository host to support custom hosts.
|
||||||
|
$port = parse_url($repositoryUrl, PHP_URL_PORT);
|
||||||
|
if ( !empty($port) ) {
|
||||||
|
$port = ':' . $port;
|
||||||
|
}
|
||||||
|
$this->repositoryHost = parse_url($repositoryUrl, PHP_URL_HOST) . $port;
|
||||||
|
|
||||||
|
if ( $this->repositoryHost !== 'gitlab.com' ) {
|
||||||
|
$this->repositoryProtocol = parse_url($repositoryUrl, PHP_URL_SCHEME);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Find the repository information
|
||||||
|
$path = parse_url($repositoryUrl, PHP_URL_PATH);
|
||||||
|
if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
|
||||||
|
$this->userName = $matches['username'];
|
||||||
|
$this->repositoryName = $matches['repository'];
|
||||||
|
} elseif ( ($this->repositoryHost === 'gitlab.com') ) {
|
||||||
|
//This is probably a repository in a subgroup, e.g. "/organization/category/repo".
|
||||||
|
$parts = explode('/', trim($path, '/'));
|
||||||
|
if ( count($parts) < 3 ) {
|
||||||
|
throw new InvalidArgumentException('Invalid GitLab.com repository URL: "' . $repositoryUrl . '"');
|
||||||
|
}
|
||||||
|
$lastPart = array_pop($parts);
|
||||||
|
$this->userName = implode('/', $parts);
|
||||||
|
$this->repositoryName = $lastPart;
|
||||||
|
} else {
|
||||||
|
//There could be subgroups in the URL: gitlab.domain.com/group/subgroup/subgroup2/repository
|
||||||
|
if ( $subgroup !== null ) {
|
||||||
|
$path = str_replace(trailingslashit($subgroup), '', $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is not a traditional url, it could be gitlab is in a deeper subdirectory.
|
||||||
|
//Get the path segments.
|
||||||
|
$segments = explode('/', untrailingslashit(ltrim($path, '/')));
|
||||||
|
|
||||||
|
//We need at least /user-name/repository-name/
|
||||||
|
if ( count($segments) < 2 ) {
|
||||||
|
throw new InvalidArgumentException('Invalid GitLab repository URL: "' . $repositoryUrl . '"');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the username and repository name.
|
||||||
|
$usernameRepo = array_splice($segments, -2, 2);
|
||||||
|
$this->userName = $usernameRepo[0];
|
||||||
|
$this->repositoryName = $usernameRepo[1];
|
||||||
|
|
||||||
|
//Append the remaining segments to the host if there are segments left.
|
||||||
|
if ( count($segments) > 0 ) {
|
||||||
|
$this->repositoryHost = trailingslashit($this->repositoryHost) . implode('/', $segments);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add subgroups to username.
|
||||||
|
if ( $subgroup !== null ) {
|
||||||
|
$this->userName = $usernameRepo[0] . '/' . untrailingslashit($subgroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($repositoryUrl, $accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the latest release from GitLab.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
public function getLatestRelease() {
|
||||||
|
$releases = $this->api('/:id/releases');
|
||||||
|
if ( is_wp_error($releases) || empty($releases) || !is_array($releases) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($releases as $release) {
|
||||||
|
if ( true !== $release->upcoming_release ) {
|
||||||
|
break 1; //Break the loop on the first release we find that isn't an upcoming release
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reference = new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $release->tag_name,
|
||||||
|
'version' => ltrim($release->tag_name, 'v'), //Remove the "v" prefix from "v1.2.3".
|
||||||
|
'downloadUrl' => '',
|
||||||
|
'updated' => $release->released_at,
|
||||||
|
'apiResponse' => $release,
|
||||||
|
));
|
||||||
|
$download_url = false;
|
||||||
|
|
||||||
|
if ( $this->releasePackageEnabled && isset($release->assets, $release->assets->links) ) {
|
||||||
|
/**
|
||||||
|
* Use the first asset LINK that is a zip format file generated by a Gitlab Release Pipeline
|
||||||
|
*
|
||||||
|
* @link https://gist.github.com/timwiel/9dfd3526c768efad4973254085e065ce
|
||||||
|
*/
|
||||||
|
foreach ($release->assets->links as $link) {
|
||||||
|
//TODO: Check the "format" property instead of the URL suffix.
|
||||||
|
if ( 'zip' === substr($link->url, -3) ) {
|
||||||
|
$download_url = $link->url;
|
||||||
|
break 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( empty( $download_url ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ( ! empty( $this->accessToken ) ) {
|
||||||
|
$download_url = add_query_arg('private_token', $this->accessToken, $download_url);
|
||||||
|
}
|
||||||
|
$reference->downloadUrl = $download_url;
|
||||||
|
return $reference;
|
||||||
|
|
||||||
|
} elseif ( isset($release->assets) ) {
|
||||||
|
/**
|
||||||
|
* Use the first asset SOURCE file that is a zip format from a Gitlab Release which should be a zip file
|
||||||
|
*/
|
||||||
|
foreach ($release->assets->sources as $source) {
|
||||||
|
if ( 'zip' === $source->format ) {
|
||||||
|
$download_url = $source->url;
|
||||||
|
break 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( empty( $download_url ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ( ! empty( $this->accessToken ) ) {
|
||||||
|
$download_url = add_query_arg('private_token', $this->accessToken, $download_url);
|
||||||
|
}
|
||||||
|
$reference->downloadUrl = $download_url;
|
||||||
|
return $reference;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//If we get this far without a return then obviosuly noi release download urls were found
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tag that looks like the highest version number.
|
||||||
|
*
|
||||||
|
* @return Puc_v4p13_Vcs_Reference|null
|
||||||
|
*/
|
||||||
|
public function getLatestTag() {
|
||||||
|
$tags = $this->api('/:id/repository/tags');
|
||||||
|
if ( is_wp_error($tags) || empty($tags) || !is_array($tags) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$versionTags = $this->sortTagsByVersion($tags);
|
||||||
|
if ( empty($versionTags) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tag = $versionTags[0];
|
||||||
|
return new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $tag->name,
|
||||||
|
'version' => ltrim($tag->name, 'v'),
|
||||||
|
'downloadUrl' => $this->buildArchiveDownloadUrl($tag->name),
|
||||||
|
'apiResponse' => $tag,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a branch by name.
|
||||||
|
*
|
||||||
|
* @param string $branchName
|
||||||
|
* @return null|Puc_v4p13_Vcs_Reference
|
||||||
|
*/
|
||||||
|
public function getBranch($branchName) {
|
||||||
|
$branch = $this->api('/:id/repository/branches/' . $branchName);
|
||||||
|
if ( is_wp_error($branch) || empty($branch) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reference = new Puc_v4p13_Vcs_Reference(array(
|
||||||
|
'name' => $branch->name,
|
||||||
|
'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name),
|
||||||
|
'apiResponse' => $branch,
|
||||||
|
));
|
||||||
|
|
||||||
|
if ( isset($branch->commit, $branch->commit->committed_date) ) {
|
||||||
|
$reference->updated = $branch->commit->committed_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the timestamp of the latest commit that changed the specified branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $ref Reference name (e.g. branch or tag).
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getLatestCommitTime($ref) {
|
||||||
|
$commits = $this->api('/:id/repository/commits/', array('ref_name' => $ref));
|
||||||
|
if ( is_wp_error($commits) || !is_array($commits) || !isset($commits[0]) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $commits[0]->committed_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a GitLab API request.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param array $queryParams
|
||||||
|
* @return mixed|WP_Error
|
||||||
|
*/
|
||||||
|
protected function api($url, $queryParams = array()) {
|
||||||
|
$baseUrl = $url;
|
||||||
|
$url = $this->buildApiUrl($url, $queryParams);
|
||||||
|
|
||||||
|
$options = array('timeout' => 10);
|
||||||
|
if ( !empty($this->httpFilterName) ) {
|
||||||
|
$options = apply_filters($this->httpFilterName, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = wp_remote_get($url, $options);
|
||||||
|
if ( is_wp_error($response) ) {
|
||||||
|
do_action('puc_api_error', $response, null, $url, $this->slug);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$code = wp_remote_retrieve_response_code($response);
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
if ( $code === 200 ) {
|
||||||
|
return json_decode($body);
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = new WP_Error(
|
||||||
|
'puc-gitlab-http-error',
|
||||||
|
sprintf('GitLab API error. URL: "%s", HTTP status code: %d.', $baseUrl, $code)
|
||||||
|
);
|
||||||
|
do_action('puc_api_error', $error, $response, $url, $this->slug);
|
||||||
|
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a fully qualified URL for an API request.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @param array $queryParams
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function buildApiUrl($url, $queryParams) {
|
||||||
|
$variables = array(
|
||||||
|
'user' => $this->userName,
|
||||||
|
'repo' => $this->repositoryName,
|
||||||
|
'id' => $this->userName . '/' . $this->repositoryName,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($variables as $name => $value) {
|
||||||
|
$url = str_replace("/:{$name}", '/' . urlencode($value), $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = substr($url, 1);
|
||||||
|
$url = sprintf('%1$s://%2$s/api/v4/projects/%3$s', $this->repositoryProtocol, $this->repositoryHost, $url);
|
||||||
|
|
||||||
|
if ( !empty($this->accessToken) ) {
|
||||||
|
$queryParams['private_token'] = $this->accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($queryParams) ) {
|
||||||
|
$url = add_query_arg($queryParams, $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of a file from a specific branch or tag.
|
||||||
|
*
|
||||||
|
* @param string $path File name.
|
||||||
|
* @param string $ref
|
||||||
|
* @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
|
||||||
|
*/
|
||||||
|
public function getRemoteFile($path, $ref = 'master') {
|
||||||
|
$response = $this->api('/:id/repository/files/' . $path, array('ref' => $ref));
|
||||||
|
if ( is_wp_error($response) || !isset($response->content) || $response->encoding !== 'base64' ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base64_decode($response->content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a URL to download a ZIP archive of the specified branch/tag/etc.
|
||||||
|
*
|
||||||
|
* @param string $ref
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function buildArchiveDownloadUrl($ref = 'master') {
|
||||||
|
$url = sprintf(
|
||||||
|
'%1$s://%2$s/api/v4/projects/%3$s/repository/archive.zip',
|
||||||
|
$this->repositoryProtocol,
|
||||||
|
$this->repositoryHost,
|
||||||
|
urlencode($this->userName . '/' . $this->repositoryName)
|
||||||
|
);
|
||||||
|
$url = add_query_arg('sha', urlencode($ref), $url);
|
||||||
|
|
||||||
|
if ( !empty($this->accessToken) ) {
|
||||||
|
$url = add_query_arg('private_token', $this->accessToken, $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific tag.
|
||||||
|
*
|
||||||
|
* @param string $tagName
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getTag($tagName) {
|
||||||
|
throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Figure out which reference (i.e tag or branch) contains the latest version.
|
||||||
|
*
|
||||||
|
* @param string $configBranch Start looking in this branch.
|
||||||
|
* @return null|Puc_v4p13_Vcs_Reference
|
||||||
|
*/
|
||||||
|
public function chooseReference($configBranch) {
|
||||||
|
|
||||||
|
if ( $configBranch === 'main' || $configBranch === 'master' ) {
|
||||||
|
//Use the latest release.
|
||||||
|
$updateSource = $this->getLatestRelease();
|
||||||
|
if ( $updateSource === null ) {
|
||||||
|
//Failing that, use the tag with the highest version number.
|
||||||
|
$updateSource = $this->getLatestTag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Alternatively, just use the branch itself.
|
||||||
|
if ( empty($updateSource) ) {
|
||||||
|
$updateSource = $this->getBranch($configBranch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $updateSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAuthentication($credentials) {
|
||||||
|
parent::setAuthentication($credentials);
|
||||||
|
$this->accessToken = is_string($credentials) ? $credentials : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enableReleaseAssets() {
|
||||||
|
$this->releaseAssetsEnabled = true;
|
||||||
|
$this->releasePackageEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enableReleasePackages() {
|
||||||
|
$this->releaseAssetsEnabled = false;
|
||||||
|
$this->releasePackageEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
293
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/PluginUpdateChecker.php
vendored
Normal file
293
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/PluginUpdateChecker.php
vendored
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Vcs_PluginUpdateChecker') ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Vcs_PluginUpdateChecker extends Puc_v4p13_Plugin_UpdateChecker implements Puc_v4p13_Vcs_BaseChecker {
|
||||||
|
/**
|
||||||
|
* @var string The branch where to look for updates. Defaults to "master".
|
||||||
|
*/
|
||||||
|
protected $branch = 'master';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Vcs_Api Repository API client.
|
||||||
|
*/
|
||||||
|
protected $api = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puc_v4p13_Vcs_PluginUpdateChecker constructor.
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_Vcs_Api $api
|
||||||
|
* @param string $pluginFile
|
||||||
|
* @param string $slug
|
||||||
|
* @param int $checkPeriod
|
||||||
|
* @param string $optionName
|
||||||
|
* @param string $muPluginFile
|
||||||
|
*/
|
||||||
|
public function __construct($api, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
|
||||||
|
$this->api = $api;
|
||||||
|
$this->api->setHttpFilterName($this->getUniqueName('request_info_options'));
|
||||||
|
|
||||||
|
parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile);
|
||||||
|
|
||||||
|
$this->api->setSlug($this->slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function requestInfo($unusedParameter = null) {
|
||||||
|
//We have to make several remote API requests to gather all the necessary info
|
||||||
|
//which can take a while on slow networks.
|
||||||
|
if ( function_exists('set_time_limit') ) {
|
||||||
|
@set_time_limit(60);
|
||||||
|
}
|
||||||
|
|
||||||
|
$api = $this->api;
|
||||||
|
$api->setLocalDirectory($this->package->getAbsoluteDirectoryPath());
|
||||||
|
|
||||||
|
$info = new Puc_v4p13_Plugin_Info();
|
||||||
|
$info->filename = $this->pluginFile;
|
||||||
|
$info->slug = $this->slug;
|
||||||
|
|
||||||
|
$this->setInfoFromHeader($this->package->getPluginHeader(), $info);
|
||||||
|
$this->setIconsFromLocalAssets($info);
|
||||||
|
$this->setBannersFromLocalAssets($info);
|
||||||
|
|
||||||
|
//Pick a branch or tag.
|
||||||
|
$updateSource = $api->chooseReference($this->branch);
|
||||||
|
if ( $updateSource ) {
|
||||||
|
$ref = $updateSource->name;
|
||||||
|
$info->version = $updateSource->version;
|
||||||
|
$info->last_updated = $updateSource->updated;
|
||||||
|
$info->download_url = $updateSource->downloadUrl;
|
||||||
|
|
||||||
|
if ( !empty($updateSource->changelog) ) {
|
||||||
|
$info->sections['changelog'] = $updateSource->changelog;
|
||||||
|
}
|
||||||
|
if ( isset($updateSource->downloadCount) ) {
|
||||||
|
$info->downloaded = $updateSource->downloadCount;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//There's probably a network problem or an authentication error.
|
||||||
|
do_action(
|
||||||
|
'puc_api_error',
|
||||||
|
new WP_Error(
|
||||||
|
'puc-no-update-source',
|
||||||
|
'Could not retrieve version information from the repository. '
|
||||||
|
. 'This usually means that the update checker either can\'t connect '
|
||||||
|
. 'to the repository or it\'s configured incorrectly.'
|
||||||
|
),
|
||||||
|
null, null, $this->slug
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get headers from the main plugin file in this branch/tag. Its "Version" header and other metadata
|
||||||
|
//are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
|
||||||
|
$mainPluginFile = basename($this->pluginFile);
|
||||||
|
$remotePlugin = $api->getRemoteFile($mainPluginFile, $ref);
|
||||||
|
if ( !empty($remotePlugin) ) {
|
||||||
|
$remoteHeader = $this->package->getFileHeader($remotePlugin);
|
||||||
|
$this->setInfoFromHeader($remoteHeader, $info);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Try parsing readme.txt. If it's formatted according to WordPress.org standards, it will contain
|
||||||
|
//a lot of useful information like the required/tested WP version, changelog, and so on.
|
||||||
|
if ( $this->readmeTxtExistsLocally() ) {
|
||||||
|
$this->setInfoFromRemoteReadme($ref, $info);
|
||||||
|
}
|
||||||
|
|
||||||
|
//The changelog might be in a separate file.
|
||||||
|
if ( empty($info->sections['changelog']) ) {
|
||||||
|
$info->sections['changelog'] = $api->getRemoteChangelog($ref, $this->package->getAbsoluteDirectoryPath());
|
||||||
|
if ( empty($info->sections['changelog']) ) {
|
||||||
|
$info->sections['changelog'] = __('There is no changelog available.', 'plugin-update-checker');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty($info->last_updated) ) {
|
||||||
|
//Fetch the latest commit that changed the tag or branch and use it as the "last_updated" date.
|
||||||
|
$latestCommitTime = $api->getLatestCommitTime($ref);
|
||||||
|
if ( $latestCommitTime !== null ) {
|
||||||
|
$info->last_updated = $latestCommitTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = apply_filters($this->getUniqueName('request_info_result'), $info, null);
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the currently installed version has a readme.txt file.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function readmeTxtExistsLocally() {
|
||||||
|
return $this->package->fileExists($this->api->getLocalReadmeName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy plugin metadata from a file header to a Plugin Info object.
|
||||||
|
*
|
||||||
|
* @param array $fileHeader
|
||||||
|
* @param Puc_v4p13_Plugin_Info $pluginInfo
|
||||||
|
*/
|
||||||
|
protected function setInfoFromHeader($fileHeader, $pluginInfo) {
|
||||||
|
$headerToPropertyMap = array(
|
||||||
|
'Version' => 'version',
|
||||||
|
'Name' => 'name',
|
||||||
|
'PluginURI' => 'homepage',
|
||||||
|
'Author' => 'author',
|
||||||
|
'AuthorName' => 'author',
|
||||||
|
'AuthorURI' => 'author_homepage',
|
||||||
|
|
||||||
|
'Requires WP' => 'requires',
|
||||||
|
'Tested WP' => 'tested',
|
||||||
|
'Requires at least' => 'requires',
|
||||||
|
'Tested up to' => 'tested',
|
||||||
|
|
||||||
|
'Requires PHP' => 'requires_php',
|
||||||
|
);
|
||||||
|
foreach ($headerToPropertyMap as $headerName => $property) {
|
||||||
|
if ( isset($fileHeader[$headerName]) && !empty($fileHeader[$headerName]) ) {
|
||||||
|
$pluginInfo->$property = $fileHeader[$headerName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !empty($fileHeader['Description']) ) {
|
||||||
|
$pluginInfo->sections['description'] = $fileHeader['Description'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy plugin metadata from the remote readme.txt file.
|
||||||
|
*
|
||||||
|
* @param string $ref GitHub tag or branch where to look for the readme.
|
||||||
|
* @param Puc_v4p13_Plugin_Info $pluginInfo
|
||||||
|
*/
|
||||||
|
protected function setInfoFromRemoteReadme($ref, $pluginInfo) {
|
||||||
|
$readme = $this->api->getRemoteReadme($ref);
|
||||||
|
if ( empty($readme) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($readme['sections']) ) {
|
||||||
|
$pluginInfo->sections = array_merge($pluginInfo->sections, $readme['sections']);
|
||||||
|
}
|
||||||
|
if ( !empty($readme['tested_up_to']) ) {
|
||||||
|
$pluginInfo->tested = $readme['tested_up_to'];
|
||||||
|
}
|
||||||
|
if ( !empty($readme['requires_at_least']) ) {
|
||||||
|
$pluginInfo->requires = $readme['requires_at_least'];
|
||||||
|
}
|
||||||
|
if ( !empty($readme['requires_php']) ) {
|
||||||
|
$pluginInfo->requires_php = $readme['requires_php'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($readme['upgrade_notice'], $readme['upgrade_notice'][$pluginInfo->version]) ) {
|
||||||
|
$pluginInfo->upgrade_notice = $readme['upgrade_notice'][$pluginInfo->version];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add icons from the currently installed version to a Plugin Info object.
|
||||||
|
*
|
||||||
|
* The icons should be in a subdirectory named "assets". Supported image formats
|
||||||
|
* and file names are described here:
|
||||||
|
* @link https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-icons
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_Plugin_Info $pluginInfo
|
||||||
|
*/
|
||||||
|
protected function setIconsFromLocalAssets($pluginInfo) {
|
||||||
|
$icons = $this->getLocalAssetUrls(array(
|
||||||
|
'icon.svg' => 'svg',
|
||||||
|
'icon-256x256.png' => '2x',
|
||||||
|
'icon-256x256.jpg' => '2x',
|
||||||
|
'icon-128x128.png' => '1x',
|
||||||
|
'icon-128x128.jpg' => '1x',
|
||||||
|
));
|
||||||
|
|
||||||
|
if ( !empty($icons) ) {
|
||||||
|
//The "default" key seems to be used only as last-resort fallback in WP core (5.8/5.9),
|
||||||
|
//but we'll set it anyway in case some code somewhere needs it.
|
||||||
|
reset($icons);
|
||||||
|
$firstKey = key($icons);
|
||||||
|
$icons['default'] = $icons[$firstKey];
|
||||||
|
|
||||||
|
$pluginInfo->icons = $icons;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add banners from the currently installed version to a Plugin Info object.
|
||||||
|
*
|
||||||
|
* The banners should be in a subdirectory named "assets". Supported image formats
|
||||||
|
* and file names are described here:
|
||||||
|
* @link https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-headers
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_Plugin_Info $pluginInfo
|
||||||
|
*/
|
||||||
|
protected function setBannersFromLocalAssets($pluginInfo) {
|
||||||
|
$banners = $this->getLocalAssetUrls(array(
|
||||||
|
'banner-772x250.png' => 'high',
|
||||||
|
'banner-772x250.jpg' => 'high',
|
||||||
|
'banner-1544x500.png' => 'low',
|
||||||
|
'banner-1544x500.jpg' => 'low',
|
||||||
|
));
|
||||||
|
|
||||||
|
if ( !empty($banners) ) {
|
||||||
|
$pluginInfo->banners = $banners;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $filesToKeys
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function getLocalAssetUrls($filesToKeys) {
|
||||||
|
$assetDirectory = $this->package->getAbsoluteDirectoryPath() . DIRECTORY_SEPARATOR . 'assets';
|
||||||
|
if ( !is_dir($assetDirectory) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$assetBaseUrl = trailingslashit(plugins_url('', $assetDirectory . '/imaginary.file'));
|
||||||
|
|
||||||
|
$foundAssets = array();
|
||||||
|
foreach ($filesToKeys as $fileName => $key) {
|
||||||
|
$fullBannerPath = $assetDirectory . DIRECTORY_SEPARATOR . $fileName;
|
||||||
|
if ( !isset($icons[$key]) && is_file($fullBannerPath) ) {
|
||||||
|
$foundAssets[$key] = $assetBaseUrl . $fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $foundAssets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBranch($branch) {
|
||||||
|
$this->branch = $branch;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAuthentication($credentials) {
|
||||||
|
$this->api->setAuthentication($credentials);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVcsApi() {
|
||||||
|
return $this->api;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdate() {
|
||||||
|
$update = parent::getUpdate();
|
||||||
|
|
||||||
|
if ( isset($update) && !empty($update->download_url) ) {
|
||||||
|
$update->download_url = $this->api->signDownloadUrl($update->download_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onDisplayConfiguration($panel) {
|
||||||
|
parent::onDisplayConfiguration($panel);
|
||||||
|
$panel->row('Branch', $this->branch);
|
||||||
|
$panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
|
||||||
|
$panel->row('API client', get_class($this->api));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
49
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/Reference.php
vendored
Normal file
49
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/Reference.php
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
if ( !class_exists('Puc_v4p13_Vcs_Reference', false) ):
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a VCS branch or tag. It's intended as a read only, short-lived container
|
||||||
|
* that only exists to provide a limited degree of type checking.
|
||||||
|
*
|
||||||
|
* @property string $name
|
||||||
|
* @property string|null version
|
||||||
|
* @property string $downloadUrl
|
||||||
|
* @property string $updated
|
||||||
|
*
|
||||||
|
* @property string|null $changelog
|
||||||
|
* @property int|null $downloadCount
|
||||||
|
*/
|
||||||
|
class Puc_v4p13_Vcs_Reference {
|
||||||
|
private $properties = array();
|
||||||
|
|
||||||
|
public function __construct($properties = array()) {
|
||||||
|
$this->properties = $properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return mixed|null
|
||||||
|
*/
|
||||||
|
public function __get($name) {
|
||||||
|
return array_key_exists($name, $this->properties) ? $this->properties[$name] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param mixed $value
|
||||||
|
*/
|
||||||
|
public function __set($name, $value) {
|
||||||
|
$this->properties[$name] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function __isset($name) {
|
||||||
|
return isset($this->properties[$name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
118
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/ThemeUpdateChecker.php
vendored
Normal file
118
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Vcs/ThemeUpdateChecker.php
vendored
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !class_exists('Puc_v4p13_Vcs_ThemeUpdateChecker', false) ):
|
||||||
|
|
||||||
|
class Puc_v4p13_Vcs_ThemeUpdateChecker extends Puc_v4p13_Theme_UpdateChecker implements Puc_v4p13_Vcs_BaseChecker {
|
||||||
|
/**
|
||||||
|
* @var string The branch where to look for updates. Defaults to "master".
|
||||||
|
*/
|
||||||
|
protected $branch = 'master';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p13_Vcs_Api Repository API client.
|
||||||
|
*/
|
||||||
|
protected $api = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puc_v4p13_Vcs_ThemeUpdateChecker constructor.
|
||||||
|
*
|
||||||
|
* @param Puc_v4p13_Vcs_Api $api
|
||||||
|
* @param null $stylesheet
|
||||||
|
* @param null $customSlug
|
||||||
|
* @param int $checkPeriod
|
||||||
|
* @param string $optionName
|
||||||
|
*/
|
||||||
|
public function __construct($api, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
|
||||||
|
$this->api = $api;
|
||||||
|
$this->api->setHttpFilterName($this->getUniqueName('request_update_options'));
|
||||||
|
|
||||||
|
parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName);
|
||||||
|
|
||||||
|
$this->api->setSlug($this->slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function requestUpdate() {
|
||||||
|
$api = $this->api;
|
||||||
|
$api->setLocalDirectory($this->package->getAbsoluteDirectoryPath());
|
||||||
|
|
||||||
|
$update = new Puc_v4p13_Theme_Update();
|
||||||
|
$update->slug = $this->slug;
|
||||||
|
|
||||||
|
//Figure out which reference (tag or branch) we'll use to get the latest version of the theme.
|
||||||
|
$updateSource = $api->chooseReference($this->branch);
|
||||||
|
if ( $updateSource ) {
|
||||||
|
$ref = $updateSource->name;
|
||||||
|
$update->download_url = $updateSource->downloadUrl;
|
||||||
|
} else {
|
||||||
|
do_action(
|
||||||
|
'puc_api_error',
|
||||||
|
new WP_Error(
|
||||||
|
'puc-no-update-source',
|
||||||
|
'Could not retrieve version information from the repository. '
|
||||||
|
. 'This usually means that the update checker either can\'t connect '
|
||||||
|
. 'to the repository or it\'s configured incorrectly.'
|
||||||
|
),
|
||||||
|
null, null, $this->slug
|
||||||
|
);
|
||||||
|
$ref = $this->branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get headers from the main stylesheet in this branch/tag. Its "Version" header and other metadata
|
||||||
|
//are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
|
||||||
|
$remoteHeader = $this->package->getFileHeader($api->getRemoteFile('style.css', $ref));
|
||||||
|
$update->version = Puc_v4p13_Utils::findNotEmpty(array(
|
||||||
|
$remoteHeader['Version'],
|
||||||
|
Puc_v4p13_Utils::get($updateSource, 'version'),
|
||||||
|
));
|
||||||
|
|
||||||
|
//The details URL defaults to the Theme URI header or the repository URL.
|
||||||
|
$update->details_url = Puc_v4p13_Utils::findNotEmpty(array(
|
||||||
|
$remoteHeader['ThemeURI'],
|
||||||
|
$this->package->getHeaderValue('ThemeURI'),
|
||||||
|
$this->metadataUrl,
|
||||||
|
));
|
||||||
|
|
||||||
|
if ( empty($update->version) ) {
|
||||||
|
//It looks like we didn't find a valid update after all.
|
||||||
|
$update = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$update = $this->filterUpdateResult($update);
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: This is duplicated code. Both theme and plugin subclasses that use VCS share these methods.
|
||||||
|
|
||||||
|
public function setBranch($branch) {
|
||||||
|
$this->branch = $branch;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAuthentication($credentials) {
|
||||||
|
$this->api->setAuthentication($credentials);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVcsApi() {
|
||||||
|
return $this->api;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdate() {
|
||||||
|
$update = parent::getUpdate();
|
||||||
|
|
||||||
|
if ( isset($update) && !empty($update->download_url) ) {
|
||||||
|
$update->download_url = $this->api->signDownloadUrl($update->download_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onDisplayConfiguration($panel) {
|
||||||
|
parent::onDisplayConfiguration($panel);
|
||||||
|
$panel->row('Branch', $this->branch);
|
||||||
|
$panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
|
||||||
|
$panel->row('API client', get_class($this->api));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endif;
|
||||||
326
vendor/yahnis-elsts/plugin-update-checker/README.md
vendored
Normal file
326
vendor/yahnis-elsts/plugin-update-checker/README.md
vendored
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
Plugin Update Checker
|
||||||
|
=====================
|
||||||
|
|
||||||
|
This is a custom update checker library for WordPress plugins and themes. It lets you add automatic update notifications and one-click upgrades to your commercial plugins, private themes, and so on. All you need to do is put your plugin/theme details in a JSON file, place the file on your server, and pass the URL to the library. The library periodically checks the URL to see if there's a new version available and displays an update notification to the user if necessary.
|
||||||
|
|
||||||
|
From the users' perspective, it works just like with plugins and themes hosted on WordPress.org. The update checker uses the default upgrade UI that is familiar to most WordPress users.
|
||||||
|
|
||||||
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||||
|
**Table of Contents**
|
||||||
|
|
||||||
|
- [Getting Started](#getting-started)
|
||||||
|
- [Self-hosted Plugins and Themes](#self-hosted-plugins-and-themes)
|
||||||
|
- [How to Release an Update](#how-to-release-an-update)
|
||||||
|
- [Notes](#notes)
|
||||||
|
- [GitHub Integration](#github-integration)
|
||||||
|
- [How to Release an Update](#how-to-release-an-update-1)
|
||||||
|
- [Notes](#notes-1)
|
||||||
|
- [BitBucket Integration](#bitbucket-integration)
|
||||||
|
- [How to Release an Update](#how-to-release-an-update-2)
|
||||||
|
- [GitLab Integration](#gitlab-integration)
|
||||||
|
- [How to Release a GitLab Update](#how-to-release-a-gitlab-update)
|
||||||
|
- [License Management](#license-management)
|
||||||
|
- [Resources](#resources)
|
||||||
|
|
||||||
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
|
||||||
|
Getting Started
|
||||||
|
---------------
|
||||||
|
|
||||||
|
*Note:* In each of the below examples, part of the instructions are to create an instance of the update checker class. It's recommended to do this either during the `plugins_loaded` action or outside of any hooks. If you do it only during an `admin_*` action, then updates will not be visible to a wide variety of WordPress maanagement tools; they will only be visible to logged-in users on dashboard pages.
|
||||||
|
|
||||||
|
### Self-hosted Plugins and Themes
|
||||||
|
|
||||||
|
1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
|
||||||
|
2. Go to the `examples` subdirectory and open the .json file that fits your project type. Replace the placeholder data with your plugin/theme details.
|
||||||
|
- Plugin example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name" : "Plugin Name",
|
||||||
|
"version" : "2.0",
|
||||||
|
"download_url" : "http://example.com/plugin-name-2.0.zip",
|
||||||
|
"sections" : {
|
||||||
|
"description" : "Plugin description here. You can use HTML."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This is a minimal example that leaves out optional fields. See [this table](https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing) for a full list of supported fields and their descriptions.
|
||||||
|
- Theme example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "2.0",
|
||||||
|
"details_url": "http://example.com/version-2.0-details.html",
|
||||||
|
"download_url": "http://example.com/example-theme-2.0.zip"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This is actually a complete example that shows all theme-related fields. `version` and `download_url` should be self-explanatory. The `details_url` key specifies the page that the user will see if they click the "View version 1.2.3 details" link in an update notification.
|
||||||
|
3. Upload the JSON file to a publicly accessible location.
|
||||||
|
4. Add the following code to the main plugin file or to the `functions.php` file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
require 'path/to/plugin-update-checker/plugin-update-checker.php';
|
||||||
|
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
|
||||||
|
'http://example.com/path/to/details.json',
|
||||||
|
__FILE__, //Full path to the main plugin file or functions.php.
|
||||||
|
'unique-plugin-or-theme-slug'
|
||||||
|
);
|
||||||
|
```
|
||||||
|
Note: If you're using the Composer autoloader, you don't need to explicitly `require` the library.
|
||||||
|
|
||||||
|
#### How to Release an Update
|
||||||
|
|
||||||
|
Change the `version` number in the JSON file and make sure that `download_url` points to the latest version. Update the other fields if necessary. Tip: You can use [wp-update-server](https://github.com/YahnisElsts/wp-update-server) to automate this process.
|
||||||
|
|
||||||
|
By default, the library will check the specified URL for changes every 12 hours. You can force it to check immediately by clicking the "Check for updates" link on the "Plugins" page (it's next to the "Visit plugin site" link). Themes don't have that link, but you can also trigger an update check like this:
|
||||||
|
|
||||||
|
1. Install [Debug Bar](https://srd.wordpress.org/plugins/debug-bar/).
|
||||||
|
2. Click the "Debug" menu in the Admin Bar (a.k.a Toolbar).
|
||||||
|
3. Open the "PUC (your-slug)" panel.
|
||||||
|
4. Click the "Check Now" button.
|
||||||
|
|
||||||
|
#### Notes
|
||||||
|
- The second argument passed to `buildUpdateChecker` must be the absolute path to the main plugin file or any file in the theme directory. If you followed the "getting started" instructions, you can just use the `__FILE__` constant.
|
||||||
|
- The third argument - i.e. the slug - is optional but recommended. In most cases, the slug should be the same as the name of your plugin directory. For example, if your plugin lives in `/wp-content/plugins/my-plugin`, set the slug to `my-plugin`. If the slug is omitted, the update checker will use the name of the main plugin file as the slug (e.g. `my-cool-plugin.php` → `my-cool-plugin`). This can lead to conflicts if your plugin has a generic file name like `plugin.php`.
|
||||||
|
|
||||||
|
This doesn't affect themes because PUC uses the theme directory name as the default slug. Still, if you're planning to use the slug in your own code - e.g. to filter updates or override update checker behaviour - it can be a good idea to set it explicitly.
|
||||||
|
|
||||||
|
### GitHub Integration
|
||||||
|
|
||||||
|
1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
|
||||||
|
2. Add the following code to the main plugin file or `functions.php`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
require 'plugin-update-checker/plugin-update-checker.php';
|
||||||
|
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
|
||||||
|
'https://github.com/user-name/repo-name/',
|
||||||
|
__FILE__,
|
||||||
|
'unique-plugin-or-theme-slug'
|
||||||
|
);
|
||||||
|
|
||||||
|
//Set the branch that contains the stable release.
|
||||||
|
$myUpdateChecker->setBranch('stable-branch-name');
|
||||||
|
|
||||||
|
//Optional: If you're using a private repository, specify the access token like this:
|
||||||
|
$myUpdateChecker->setAuthentication('your-token-here');
|
||||||
|
```
|
||||||
|
3. Plugins only: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. The contents of this file will be shown when the user clicks the "View version 1.2.3 details" link.
|
||||||
|
|
||||||
|
#### How to Release an Update
|
||||||
|
|
||||||
|
This library supports a couple of different ways to release updates on GitHub. Pick the one that best fits your workflow.
|
||||||
|
|
||||||
|
- **GitHub releases**
|
||||||
|
|
||||||
|
Create a new release using the "Releases" feature on GitHub. The tag name and release title don't matter. The description is optional, but if you do provide one, it will be displayed when the user clicks the "View version x.y.z details" link on the "Plugins" page. Note that PUC ignores releases marked as "This is a pre-release".
|
||||||
|
|
||||||
|
If you want to use release assets, call the `enableReleaseAssets()` method after creating the update checker instance:
|
||||||
|
```php
|
||||||
|
$myUpdateChecker->getVcsApi()->enableReleaseAssets();
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Tags**
|
||||||
|
|
||||||
|
To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. That's it.
|
||||||
|
|
||||||
|
PUC doesn't require strict adherence to [SemVer](http://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitHub releases or branches instead.
|
||||||
|
|
||||||
|
- **Stable branch**
|
||||||
|
|
||||||
|
Point the update checker at a stable, production-ready branch:
|
||||||
|
```php
|
||||||
|
$updateChecker->setBranch('branch-name');
|
||||||
|
```
|
||||||
|
PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version.
|
||||||
|
|
||||||
|
Caveat: If you set the branch to `master` (the default), the update checker will look for recent releases and tags first. It'll only use the `master` branch if it doesn't find anything else suitable.
|
||||||
|
|
||||||
|
#### Notes
|
||||||
|
|
||||||
|
The library will pull update details from the following parts of a release/tag/branch:
|
||||||
|
|
||||||
|
- Version number
|
||||||
|
- The "Version" plugin header.
|
||||||
|
- The latest GitHub release or tag name.
|
||||||
|
- Changelog
|
||||||
|
- The "Changelog" section of `readme.txt`.
|
||||||
|
- One of the following files:
|
||||||
|
CHANGES.md, CHANGELOG.md, changes.md, changelog.md
|
||||||
|
- GitHub release notes.
|
||||||
|
- Required and tested WordPress versions
|
||||||
|
- The "Requires at least" and "Tested up to" fields in `readme.txt`.
|
||||||
|
- The following plugin headers:
|
||||||
|
`Required WP`, `Tested WP`, `Requires at least`, `Tested up to`
|
||||||
|
- "Last updated" timestamp
|
||||||
|
- The creation timestamp of the latest GitHub release.
|
||||||
|
- The latest commit in the selected tag or branch.
|
||||||
|
- Number of downloads
|
||||||
|
- The `download_count` statistic of the latest release.
|
||||||
|
- If you're not using GitHub releases, there will be no download stats.
|
||||||
|
- Other plugin details - author, homepage URL, description
|
||||||
|
- The "Description" section of `readme.txt`.
|
||||||
|
- Remote plugin headers (i.e. the latest version on GitHub).
|
||||||
|
- Local plugin headers (i.e. the currently installed version).
|
||||||
|
- Ratings, banners, screenshots
|
||||||
|
- Not supported.
|
||||||
|
|
||||||
|
### BitBucket Integration
|
||||||
|
|
||||||
|
1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
|
||||||
|
2. Add the following code to the main plugin file or `functions.php`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
require 'plugin-update-checker/plugin-update-checker.php';
|
||||||
|
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
|
||||||
|
'https://bitbucket.org/user-name/repo-name',
|
||||||
|
__FILE__,
|
||||||
|
'unique-plugin-or-theme-slug'
|
||||||
|
);
|
||||||
|
|
||||||
|
//Optional: If you're using a private repository, create an OAuth consumer
|
||||||
|
//and set the authentication credentials like this:
|
||||||
|
//Note: For now you need to check "This is a private consumer" when
|
||||||
|
//creating the consumer to work around #134:
|
||||||
|
// https://github.com/YahnisElsts/plugin-update-checker/issues/134
|
||||||
|
$myUpdateChecker->setAuthentication(array(
|
||||||
|
'consumer_key' => '...',
|
||||||
|
'consumer_secret' => '...',
|
||||||
|
));
|
||||||
|
|
||||||
|
//Optional: Set the branch that contains the stable release.
|
||||||
|
$myUpdateChecker->setBranch('stable-branch-name');
|
||||||
|
```
|
||||||
|
3. Optional: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. For plugins, the contents of this file will be shown when the user clicks the "View version 1.2.3 details" link.
|
||||||
|
|
||||||
|
#### How to Release an Update
|
||||||
|
|
||||||
|
BitBucket doesn't have an equivalent to GitHub's releases, so the process is slightly different. You can use any of the following approaches:
|
||||||
|
|
||||||
|
- **`Stable tag` header**
|
||||||
|
|
||||||
|
This is the recommended approach if you're using tags to mark each version. Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. Set the "stable tag" header to the tag that represents the latest release. Example:
|
||||||
|
```text
|
||||||
|
Stable tag: v1.2.3
|
||||||
|
```
|
||||||
|
The tag doesn't have to start with a "v" or follow any particular format. You can use any name you like as long as it's a valid Git tag.
|
||||||
|
|
||||||
|
Tip: If you explicitly set a stable branch, the update checker will look for a `readme.txt` in that branch. Otherwise it will only look at the `master` branch.
|
||||||
|
|
||||||
|
- **Tags**
|
||||||
|
|
||||||
|
You can skip the "stable tag" bit and just create a new Git tag named `v1.2.3` or `1.2.3`. The update checker will look at the most recent tags and pick the one that looks like the highest version number.
|
||||||
|
|
||||||
|
PUC doesn't require strict adherence to [SemVer](http://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions.
|
||||||
|
|
||||||
|
- **Stable branch**
|
||||||
|
|
||||||
|
Point the update checker at a stable, production-ready branch:
|
||||||
|
```php
|
||||||
|
$updateChecker->setBranch('branch-name');
|
||||||
|
```
|
||||||
|
PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. Caveat: If you set the branch to `master`, the update checker will still look for tags first.
|
||||||
|
|
||||||
|
### GitLab Integration
|
||||||
|
|
||||||
|
1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
|
||||||
|
2. Add the following code to the main plugin file or `functions.php` and define how you want to check for updates from Gitlab (refer to: [Gitlab: How to Release an Update](#how-to-release-a-gitlab-update)):
|
||||||
|
|
||||||
|
```php
|
||||||
|
require 'plugin-update-checker/plugin-update-checker.php';
|
||||||
|
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
|
||||||
|
'https://gitlab.com/user-name/repo-name/',
|
||||||
|
__FILE__,
|
||||||
|
'unique-plugin-or-theme-slug'
|
||||||
|
);
|
||||||
|
|
||||||
|
//Optional: If you're using a private repository, specify the access token like this:
|
||||||
|
$myUpdateChecker->setAuthentication('your-token-here');
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, if you're using a self-hosted GitLab instance, initialize the update checker like this:
|
||||||
|
```php
|
||||||
|
$myUpdateChecker = new Puc_v4p13_Vcs_PluginUpdateChecker(
|
||||||
|
new Puc_v4p13_Vcs_GitLabApi('https://myserver.com/user-name/repo-name/'),
|
||||||
|
__FILE__,
|
||||||
|
'unique-plugin-or-theme-slug'
|
||||||
|
);
|
||||||
|
//Optional: Add setAuthentication(...) and setBranch(...) as shown above.
|
||||||
|
```
|
||||||
|
If you're using a self-hosted GitLab instance and [subgroups or nested groups](https://docs.gitlab.com/ce/user/group/subgroups/index.html), you have to tell the update checker which parts of the URL are subgroups:
|
||||||
|
```php
|
||||||
|
$myUpdateChecker = new Puc_v4p13_Vcs_PluginUpdateChecker(
|
||||||
|
new Puc_v4p13_Vcs_GitLabApi('https://myserver.com/group-name/subgroup-level1/subgroup-level2/subgroup-level3/repo-name/', null, 'subgroup-level1/subgroup-level2/subgroup-level3'),
|
||||||
|
__FILE__,
|
||||||
|
'unique-plugin-or-theme-slug'
|
||||||
|
);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Plugins only: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/readme.txt) to your repository. The contents of this file will be shown when the user clicks the "View version 1.2.3 details" link.
|
||||||
|
|
||||||
|
#### How to Release a GitLab Update
|
||||||
|
A Gitlab repository can be checked for updates in 4 different ways.
|
||||||
|
|
||||||
|
1. **Stable branch** (other than `master` or `main`):
|
||||||
|
- Point the update checker at any stable, production-ready branch and PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version.
|
||||||
|
- Add the following code:
|
||||||
|
```php
|
||||||
|
//Add the following code to your main plugin file or `functions.php` file to check for updates from a custom branch
|
||||||
|
$myUpdateChecker->setBranch('stable-branch-name');
|
||||||
|
```
|
||||||
|
- Caveats:
|
||||||
|
- If you set the branch to `main` (the default) or `master` (the historical default), the update checker will look for recent releases and tags first. It'll only use the `main` or `master` branch if it doesn't find anything else suitable.
|
||||||
|
|
||||||
|
2. **GitLab Releases using Generic Packages**:
|
||||||
|
- Use a Gitlab CI/CD Pipeline to automatically generate your update on release using a Generic Package. The benefit of using Generic Package assets over the Source Code assets is that the code can already be built and production ready.
|
||||||
|
- Add the following code:
|
||||||
|
```php
|
||||||
|
//Add the following code to your main plugin file or `functions.php` file to check for a new update from releases using generic packages
|
||||||
|
$myUpdateChecker->getVcsApi()->enableReleasePackages();
|
||||||
|
```
|
||||||
|
- PUC will periodically check the release version (i.e. the tag name of the release) and will display a notification if the release is a greater version than the installed version.
|
||||||
|
- The release tag name should loosely follow [SemVer](http://semver.org/) but these are all valid release names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5` However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead.
|
||||||
|
- For more information about *Gitlab Release Generic Packages* refer to the following links:
|
||||||
|
- [Gitlab CI/CD Release Documentation](https://docs.gitlab.com/ee/user/project/releases/#create-release-from-gitlab-ci)
|
||||||
|
- [Gitlab Release Assets as Generic Package Documentation](https://gitlab.com/gitlab-org/release-cli/-/tree/master/docs/examples/release-assets-as-generic-package/)
|
||||||
|
- [Example .gitlab-ci.yml file using Release Generic Packages for generating a update package from the Sensei-LMS wordpress plugin](https://gist.github.com/timwiel/9dfd3526c768efad4973254085e065ce)
|
||||||
|
|
||||||
|
|
||||||
|
3. **GitLab Releases using Source Code Assets**:
|
||||||
|
- Create a new release using the "Releases" feature on Gitlab.
|
||||||
|
- Add the following code:
|
||||||
|
```php
|
||||||
|
//Add the following code to your main plugin file or `functions.php` file to check for a new update from releases using release assets
|
||||||
|
$myUpdateChecker->getVcsApi()->enableReleaseAssets();
|
||||||
|
```
|
||||||
|
- PUC will periodically check the release version (based on release tag name) and display a notification if the release version is greater than the installed version.
|
||||||
|
- The release name should loosely follow [SemVer](http://semver.org/) but these are all valid release names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5` However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead.
|
||||||
|
|
||||||
|
|
||||||
|
4. **Tags** (this is the default option):
|
||||||
|
- To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`.
|
||||||
|
- Optionally, add the following code:
|
||||||
|
```php
|
||||||
|
//Add the following code to your main plugin file or `functions.php` file to check for updates from the default branch
|
||||||
|
$myUpdateChecker->setBranch('master'); //or 'main'
|
||||||
|
```
|
||||||
|
- PUC doesn't require strict adherence to [SemVer](http://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead.
|
||||||
|
|
||||||
|
License Management
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Currently, the update checker doesn't have any built-in license management features. It only provides some hooks that you can use to, for example, append license keys to update requests (`$updateChecker->addQueryArgFilter()`). If you're looking for ways to manage and verify licenses, please post your feedback in [this issue](https://github.com/YahnisElsts/plugin-update-checker/issues/222).
|
||||||
|
|
||||||
|
Resources
|
||||||
|
---------
|
||||||
|
|
||||||
|
- [This blog post](http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-plugin/) has more information about the update checker API. *Slightly out of date.*
|
||||||
|
- [Debug Bar](https://wordpress.org/plugins/debug-bar/) - useful for testing and debugging the update checker.
|
||||||
|
- [Update format reference](https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing) - describes all fields supported by the JSON-based update information format used by the update checker. Only covers plugins. Themes use a similar but more limited format.
|
||||||
|
- [Securing download links](http://w-shadow.com/blog/2013/03/19/plugin-updates-securing-download-links/) - a general overview.
|
||||||
|
- [A GUI for entering download credentials](http://open-tools.net/documentation/tutorial-automatic-updates.html#wordpress)
|
||||||
|
- [Theme Update Checker](http://w-shadow.com/blog/2011/06/02/automatic-updates-for-commercial-themes/) - an older, theme-only variant of this update checker.
|
||||||
23
vendor/yahnis-elsts/plugin-update-checker/composer.json
vendored
Normal file
23
vendor/yahnis-elsts/plugin-update-checker/composer.json
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "yahnis-elsts/plugin-update-checker",
|
||||||
|
"type": "library",
|
||||||
|
"description": "A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.",
|
||||||
|
"keywords": ["wordpress", "plugin updates", "automatic updates", "theme updates"],
|
||||||
|
"homepage": "https://github.com/YahnisElsts/plugin-update-checker/",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Yahnis Elsts",
|
||||||
|
"email": "whiteshadow@w-shadow.com",
|
||||||
|
"homepage": "http://w-shadow.com/",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.2.0",
|
||||||
|
"ext-json": "*"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": ["load-v4p13.php"]
|
||||||
|
}
|
||||||
|
}
|
||||||
70
vendor/yahnis-elsts/plugin-update-checker/css/puc-debug-bar.css
vendored
Normal file
70
vendor/yahnis-elsts/plugin-update-checker/css/puc-debug-bar.css
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
.puc-debug-bar-panel-v4 pre {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Style the debug data table to match "widefat" table style used by WordPress. */
|
||||||
|
table.puc-debug-data {
|
||||||
|
width: 100%;
|
||||||
|
clear: both;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
border-spacing: 0;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
|
||||||
|
border-radius: 3px;
|
||||||
|
border: 1px solid #dfdfdf;
|
||||||
|
border-collapse: separate;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.puc-debug-data * {
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.puc-debug-data th {
|
||||||
|
width: 11em;
|
||||||
|
padding: 7px 7px 8px;
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
font-family: "Georgia", "Times New Roman", "Bitstream Charter", "Times", serif;
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.3em;
|
||||||
|
text-shadow: rgba(255, 255, 255, 0.804) 0 1px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.puc-debug-data td, table.puc-debug-data th {
|
||||||
|
border-width: 1px 0;
|
||||||
|
border-style: solid;
|
||||||
|
|
||||||
|
border-top-color: #fff;
|
||||||
|
border-bottom-color: #dfdfdf;
|
||||||
|
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.puc-debug-data td {
|
||||||
|
color: #555;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 4px 7px 2px;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.puc-ajax-response {
|
||||||
|
border: 1px solid #dfdfdf;
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 0.5em;
|
||||||
|
margin: 5px 0;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.puc-ajax-nonce {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.puc-ajax-response dt {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.puc-ajax-response dd {
|
||||||
|
margin: 0 0 1em;
|
||||||
|
}
|
||||||
52
vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json
vendored
Normal file
52
vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"name": "My Example Plugin",
|
||||||
|
"version": "2.0",
|
||||||
|
"download_url": "http://example.com/updates/example-plugin.zip",
|
||||||
|
|
||||||
|
"homepage": "http://example.com/",
|
||||||
|
"requires": "4.5",
|
||||||
|
"tested": "4.8",
|
||||||
|
"last_updated": "2017-01-01 16:17:00",
|
||||||
|
"upgrade_notice": "Here's why you should upgrade...",
|
||||||
|
|
||||||
|
"author": "Janis Elsts",
|
||||||
|
"author_homepage": "http://example.com/",
|
||||||
|
|
||||||
|
"sections": {
|
||||||
|
"description": "(Required) Plugin description. Basic HTML can be used in all sections.",
|
||||||
|
"installation": "(Recommended) Installation instructions.",
|
||||||
|
"changelog": "(Recommended) Changelog. <p>This section will be displayed by default when the user clicks 'View version x.y.z details'.</p>",
|
||||||
|
"custom_section": "This is a custom section labeled 'Custom Section'."
|
||||||
|
},
|
||||||
|
|
||||||
|
"icons" : {
|
||||||
|
"1x" : "http://w-shadow.com/files/external-update-example/assets/icon-128x128.png",
|
||||||
|
"2x" : "http://w-shadow.com/files/external-update-example/assets/icon-256x256.png"
|
||||||
|
},
|
||||||
|
|
||||||
|
"banners": {
|
||||||
|
"low": "http://w-shadow.com/files/external-update-example/assets/banner-772x250.png",
|
||||||
|
"high": "http://w-shadow.com/files/external-update-example/assets/banner-1544x500.png"
|
||||||
|
},
|
||||||
|
|
||||||
|
"translations": [
|
||||||
|
{
|
||||||
|
"language": "fr_FR",
|
||||||
|
"version": "4.0",
|
||||||
|
"updated": "2016-04-22 23:22:42",
|
||||||
|
"package": "http://example.com/updates/translations/french-language-pack.zip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "de_DE",
|
||||||
|
"version": "5.0",
|
||||||
|
"updated": "2016-04-22 23:22:42",
|
||||||
|
"package": "http://example.com/updates/translations/german-language-pack.zip"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"rating": 90,
|
||||||
|
"num_ratings": 123,
|
||||||
|
|
||||||
|
"downloaded": 1234,
|
||||||
|
"active_installs": 12345
|
||||||
|
}
|
||||||
5
vendor/yahnis-elsts/plugin-update-checker/examples/theme.json
vendored
Normal file
5
vendor/yahnis-elsts/plugin-update-checker/examples/theme.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0",
|
||||||
|
"details_url": "http://example.com/version-2.0-details.html",
|
||||||
|
"download_url": "http://example.com/example-theme-2.0.zip"
|
||||||
|
}
|
||||||
52
vendor/yahnis-elsts/plugin-update-checker/js/debug-bar.js
vendored
Normal file
52
vendor/yahnis-elsts/plugin-update-checker/js/debug-bar.js
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
jQuery(function($) {
|
||||||
|
|
||||||
|
function runAjaxAction(button, action) {
|
||||||
|
button = $(button);
|
||||||
|
var panel = button.closest('.puc-debug-bar-panel-v4');
|
||||||
|
var responseBox = button.closest('td').find('.puc-ajax-response');
|
||||||
|
|
||||||
|
responseBox.text('Processing...').show();
|
||||||
|
$.post(
|
||||||
|
ajaxurl,
|
||||||
|
{
|
||||||
|
action : action,
|
||||||
|
uid : panel.data('uid'),
|
||||||
|
_wpnonce: panel.data('nonce')
|
||||||
|
},
|
||||||
|
function(data) {
|
||||||
|
responseBox.html(data);
|
||||||
|
},
|
||||||
|
'html'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.puc-debug-bar-panel-v4 input[name="puc-check-now-button"]').on('click', function() {
|
||||||
|
runAjaxAction(this, 'puc_v4_debug_check_now');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.puc-debug-bar-panel-v4 input[name="puc-request-info-button"]').on('click', function() {
|
||||||
|
runAjaxAction(this, 'puc_v4_debug_request_info');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Debug Bar uses the panel class name as part of its link and container IDs. This means we can
|
||||||
|
// end up with multiple identical IDs if more than one plugin uses the update checker library.
|
||||||
|
// Fix it by replacing the class name with the plugin slug.
|
||||||
|
var panels = $('#debug-menu-targets').find('.puc-debug-bar-panel-v4');
|
||||||
|
panels.each(function() {
|
||||||
|
var panel = $(this);
|
||||||
|
var uid = panel.data('uid');
|
||||||
|
var target = panel.closest('.debug-menu-target');
|
||||||
|
|
||||||
|
//Change the panel wrapper ID.
|
||||||
|
target.attr('id', 'debug-menu-target-puc-' + uid);
|
||||||
|
|
||||||
|
//Change the menu link ID as well and point it at the new target ID.
|
||||||
|
$('#debug-bar-menu').find('.puc-debug-menu-link-' + uid)
|
||||||
|
.closest('.debug-menu-link')
|
||||||
|
.attr('id', 'debug-menu-link-puc-' + uid)
|
||||||
|
.attr('href', '#' + target.attr('id'));
|
||||||
|
});
|
||||||
|
});
|
||||||
BIN
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ca.mo
vendored
Normal file
BIN
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ca.mo
vendored
Normal file
Binary file not shown.
48
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ca.po
vendored
Normal file
48
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ca.po
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: plugin-update-checker\n"
|
||||||
|
"POT-Creation-Date: 2017-11-24 17:02+0200\n"
|
||||||
|
"PO-Revision-Date: 2019-09-25 18:15+0200\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Generator: Poedit 2.2.3\n"
|
||||||
|
"X-Poedit-Basepath: ..\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"X-Poedit-SourceCharset: UTF-8\n"
|
||||||
|
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language: ca\n"
|
||||||
|
"X-Poedit-SearchPath-0: .\n"
|
||||||
|
|
||||||
|
#: Puc/v4p3/Plugin/UpdateChecker.php:395
|
||||||
|
msgid "Check for updates"
|
||||||
|
msgstr "Comprova si hi ha actualitzacions"
|
||||||
|
|
||||||
|
#: Puc/v4p3/Plugin/UpdateChecker.php:548
|
||||||
|
#, php-format
|
||||||
|
msgctxt "the plugin title"
|
||||||
|
msgid "The %s plugin is up to date."
|
||||||
|
msgstr "L’extensió %s està actualitzada."
|
||||||
|
|
||||||
|
#: Puc/v4p3/Plugin/UpdateChecker.php:550
|
||||||
|
#, php-format
|
||||||
|
msgctxt "the plugin title"
|
||||||
|
msgid "A new version of the %s plugin is available."
|
||||||
|
msgstr "Una nova versió de l’extensió %s està disponible."
|
||||||
|
|
||||||
|
#: Puc/v4p3/Plugin/UpdateChecker.php:552
|
||||||
|
#, php-format
|
||||||
|
msgctxt "the plugin title"
|
||||||
|
msgid "Could not determine if updates are available for %s."
|
||||||
|
msgstr "No s’ha pogut determinar si hi ha actualitzacions per a %s."
|
||||||
|
|
||||||
|
#: Puc/v4p3/Plugin/UpdateChecker.php:558
|
||||||
|
#, php-format
|
||||||
|
msgid "Unknown update checker status \"%s\""
|
||||||
|
msgstr "Estat del comprovador d’actualitzacions desconegut \"%s\""
|
||||||
|
|
||||||
|
#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
|
||||||
|
msgid "There is no changelog available."
|
||||||
|
msgstr "No hi ha cap registre de canvis disponible."
|
||||||
BIN
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo
vendored
Normal file
BIN
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo
vendored
Normal file
Binary file not shown.
45
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po
vendored
Normal file
45
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: plugin-update-checker\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2017-05-20 10:53+0300\n"
|
||||||
|
"PO-Revision-Date: 2017-07-05 15:39+0000\n"
|
||||||
|
"Last-Translator: Vojtěch Sajdl <vojtech@sajdl.com>\n"
|
||||||
|
"Language-Team: Czech (Czech Republic)\n"
|
||||||
|
"Language: cs-CZ\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Loco-Source-Locale: cs_CZ\n"
|
||||||
|
"X-Generator: Loco - https://localise.biz/\n"
|
||||||
|
"X-Poedit-Basepath: ..\n"
|
||||||
|
"X-Poedit-SourceCharset: UTF-8\n"
|
||||||
|
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
|
||||||
|
"X-Poedit-SearchPath-0: .\n"
|
||||||
|
"X-Loco-Parser: loco_parse_po"
|
||||||
|
|
||||||
|
#: Puc/v4p1/Plugin/UpdateChecker.php:358
|
||||||
|
msgid "Check for updates"
|
||||||
|
msgstr "Zkontrolovat aktualizace"
|
||||||
|
|
||||||
|
#: Puc/v4p1/Plugin/UpdateChecker.php:405
|
||||||
|
#, php-format
|
||||||
|
msgctxt "the plugin title"
|
||||||
|
msgid "The %s plugin is up to date."
|
||||||
|
msgstr "Plugin %s je aktuální."
|
||||||
|
|
||||||
|
#: Puc/v4p1/Plugin/UpdateChecker.php:407
|
||||||
|
#, php-format
|
||||||
|
msgctxt "the plugin title"
|
||||||
|
msgid "A new version of the %s plugin is available."
|
||||||
|
msgstr "Nová verze pluginu %s je dostupná."
|
||||||
|
|
||||||
|
#: Puc/v4p1/Plugin/UpdateChecker.php:409
|
||||||
|
#, php-format
|
||||||
|
msgid "Unknown update checker status \"%s\""
|
||||||
|
msgstr "Neznámý status kontroly aktualizací \"%s\""
|
||||||
|
|
||||||
|
#: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
|
||||||
|
msgid "There is no changelog available."
|
||||||
|
msgstr "Changelog není dostupný."
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user