Version Description
- 16 Jun 2020 =
- Fixed : Fatal error due to missing vendor library folder
Download this release
Release Info
Developer | kevinB |
Plugin | Capability Manager Enhanced |
Version | 1.9.12 |
Comparing to | |
See all releases |
Code changes from version 1.9.10 to 1.9.12
- capsman-enhanced.php +5 -5
- readme.txt +7 -1
- vendor/composer/installed.json +6 -6
- vendor/publishpress/wordpress-version-notices/README.md +46 -4
- vendor/publishpress/wordpress-version-notices/assets/css/menu-item.css +38 -0
- vendor/publishpress/wordpress-version-notices/codeception.dist.yml +3 -0
- vendor/publishpress/wordpress-version-notices/codeception.yml +3 -0
- vendor/publishpress/wordpress-version-notices/includes.php +4 -1
- vendor/publishpress/wordpress-version-notices/src/Module/MenuLink/Module.php +187 -0
- vendor/publishpress/wordpress-version-notices/src/ServicesProvider.php +5 -0
- vendor/publishpress/wordpress-version-notices/templates/menu-link/menu-link-script.php +13 -0
- vendor/publishpress/wordpress-version-notices/templates/menu-link/redirect-page.php +15 -0
capsman-enhanced.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: PublishPress Capabilities
|
4 |
* Plugin URI: https://publishpress.com/capability-manager/
|
5 |
* Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
|
6 |
-
* Version: 1.9.
|
7 |
* Author: PublishPress
|
8 |
* Author URI: https://publishpress.com/
|
9 |
* Text Domain: capsman-enhanced
|
@@ -25,13 +25,13 @@
|
|
25 |
* @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2020 PublishPress
|
26 |
* @license GNU General Public License version 3
|
27 |
* @link https://publishpress.com/
|
28 |
-
* @version 1.9.
|
29 |
*/
|
30 |
|
31 |
if (!defined('CAPSMAN_VERSION')) {
|
32 |
-
define('CAPSMAN_VERSION', '1.9.
|
33 |
-
define('CAPSMAN_ENH_VERSION', '1.9.
|
34 |
-
define('PUBLISHPRESS_CAPS_VERSION', '1.9.
|
35 |
}
|
36 |
|
37 |
foreach (get_option('active_plugins') as $plugin_file) {
|
3 |
* Plugin Name: PublishPress Capabilities
|
4 |
* Plugin URI: https://publishpress.com/capability-manager/
|
5 |
* Description: Manage WordPress role definitions, per-site or network-wide. Organizes post capabilities by post type and operation.
|
6 |
+
* Version: 1.9.12
|
7 |
* Author: PublishPress
|
8 |
* Author URI: https://publishpress.com/
|
9 |
* Text Domain: capsman-enhanced
|
25 |
* @copyright Copyright (C) 2009, 2010 Jordi Canals; modifications Copyright (C) 2020 PublishPress
|
26 |
* @license GNU General Public License version 3
|
27 |
* @link https://publishpress.com/
|
28 |
+
* @version 1.9.12
|
29 |
*/
|
30 |
|
31 |
if (!defined('CAPSMAN_VERSION')) {
|
32 |
+
define('CAPSMAN_VERSION', '1.9.12');
|
33 |
+
define('CAPSMAN_ENH_VERSION', '1.9.12');
|
34 |
+
define('PUBLISHPRESS_CAPS_VERSION', '1.9.12');
|
35 |
}
|
36 |
|
37 |
foreach (get_option('active_plugins') as $plugin_file) {
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: user roles, capabilities, permissions, authors, editors, post types, taxon
|
|
7 |
Requires at least: 4.9.7
|
8 |
Tested up to: 5.5
|
9 |
Requires PHP: 5.6.20
|
10 |
-
Stable tag: 1.9.
|
11 |
License: GPLv3
|
12 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
13 |
|
@@ -114,6 +114,12 @@ Fixed : Non-administrators with user editing capabilities could add new Administ
|
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
= 1.9.10 - 1 Jun 2020 =
|
118 |
* Fixed : PublishPress Permissions - Type / Taxonomy settings incorrectly synchronized under some conditions
|
119 |
|
7 |
Requires at least: 4.9.7
|
8 |
Tested up to: 5.5
|
9 |
Requires PHP: 5.6.20
|
10 |
+
Stable tag: 1.9.12
|
11 |
License: GPLv3
|
12 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
13 |
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
= 1.9.12 - 16 Jun 2020 =
|
118 |
+
* Fixed : Fatal error due to missing vendor library folder
|
119 |
+
|
120 |
+
= 1.9.11 - 16 Jun 2020 =
|
121 |
+
* Fixed : Upgrade menu links were not displayed
|
122 |
+
|
123 |
= 1.9.10 - 1 Jun 2020 =
|
124 |
* Fixed : PublishPress Permissions - Type / Taxonomy settings incorrectly synchronized under some conditions
|
125 |
|
vendor/composer/installed.json
CHANGED
@@ -104,17 +104,17 @@
|
|
104 |
},
|
105 |
{
|
106 |
"name": "publishpress/wordpress-version-notices",
|
107 |
-
"version": "dev-
|
108 |
-
"version_normalized": "dev
|
109 |
"source": {
|
110 |
"type": "git",
|
111 |
"url": "https://github.com/publishpress/WordPress-Version-Notices.git",
|
112 |
-
"reference": "
|
113 |
},
|
114 |
"dist": {
|
115 |
"type": "zip",
|
116 |
-
"url": "https://api.github.com/repos/publishpress/WordPress-Version-Notices/zipball/
|
117 |
-
"reference": "
|
118 |
"shasum": ""
|
119 |
},
|
120 |
"require": {
|
@@ -124,7 +124,7 @@
|
|
124 |
"require-dev": {
|
125 |
"lucatume/wp-browser": "^2.2"
|
126 |
},
|
127 |
-
"time": "2020-04-
|
128 |
"type": "library",
|
129 |
"installation-source": "dist",
|
130 |
"autoload": {
|
104 |
},
|
105 |
{
|
106 |
"name": "publishpress/wordpress-version-notices",
|
107 |
+
"version": "dev-master",
|
108 |
+
"version_normalized": "9999999-dev",
|
109 |
"source": {
|
110 |
"type": "git",
|
111 |
"url": "https://github.com/publishpress/WordPress-Version-Notices.git",
|
112 |
+
"reference": "45e6cb0f302165f3df820ff01c4f267f0b22517d"
|
113 |
},
|
114 |
"dist": {
|
115 |
"type": "zip",
|
116 |
+
"url": "https://api.github.com/repos/publishpress/WordPress-Version-Notices/zipball/45e6cb0f302165f3df820ff01c4f267f0b22517d",
|
117 |
+
"reference": "45e6cb0f302165f3df820ff01c4f267f0b22517d",
|
118 |
"shasum": ""
|
119 |
},
|
120 |
"require": {
|
124 |
"require-dev": {
|
125 |
"lucatume/wp-browser": "^2.2"
|
126 |
},
|
127 |
+
"time": "2020-04-08T13:59:53+00:00",
|
128 |
"type": "library",
|
129 |
"installation-source": "dist",
|
130 |
"autoload": {
|
vendor/publishpress/wordpress-version-notices/README.md
CHANGED
@@ -15,11 +15,15 @@ $ composer update --no-dev
|
|
15 |
|
16 |
Due to a conflict in the tests we didn't register the include file in the Composer's autoload for now. You can manually require it and add a filter for the settings.
|
17 |
|
18 |
-
|
|
|
19 |
if (!defined('PP_VERSION_NOTICES_LOADED')) {
|
20 |
require_once __DIR__ . '/vendor/publishpress/wordpress-version-notices/includes.php';
|
21 |
}
|
22 |
|
|
|
|
|
|
|
23 |
add_filter(\PPVersionNotices\Module\TopNotice\Module::SETTINGS_FILTER, function ($settings) {
|
24 |
$settings['dumb-plugin-one'] = [
|
25 |
'message' => 'You\'re using Dumb Plugin One Free. Please, %supgrade to pro%s.',
|
@@ -37,11 +41,49 @@ add_filter(\PPVersionNotices\Module\TopNotice\Module::SETTINGS_FILTER, function
|
|
37 |
});
|
38 |
```
|
39 |
|
40 |
-
|
41 |
|
42 |
* message: Type the respective message for the banner, adding the button text between '%s'. This string will be used as format for `sprint` .
|
43 |
-
* link: The full link for the button
|
44 |
-
* screen: An array of screen parameters used to decide what page should display the banner. Each item of the array can be a boolean or an array with a key-value array specifying the required params from the screen (WP_Screen) object. You can bypass the library's filter algorithm adding a `true` item to it. This allows you to create your own function to check the screen returning a boolean value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
## Testing
|
47 |
|
15 |
|
16 |
Due to a conflict in the tests we didn't register the include file in the Composer's autoload for now. You can manually require it and add a filter for the settings.
|
17 |
|
18 |
+
### Loading the library
|
19 |
+
|
20 |
if (!defined('PP_VERSION_NOTICES_LOADED')) {
|
21 |
require_once __DIR__ . '/vendor/publishpress/wordpress-version-notices/includes.php';
|
22 |
}
|
23 |
|
24 |
+
### Top Notice
|
25 |
+
|
26 |
+
```php
|
27 |
add_filter(\PPVersionNotices\Module\TopNotice\Module::SETTINGS_FILTER, function ($settings) {
|
28 |
$settings['dumb-plugin-one'] = [
|
29 |
'message' => 'You\'re using Dumb Plugin One Free. Please, %supgrade to pro%s.',
|
41 |
});
|
42 |
```
|
43 |
|
44 |
+
#### Params
|
45 |
|
46 |
* message: Type the respective message for the banner, adding the button text between '%s'. This string will be used as format for `sprint` .
|
47 |
+
* link: The full link for the button.
|
48 |
+
* screen: An array of screen parameters used to decide what page should display the banner. Each item of the array can be a boolean or an array with a key-value array specifying the required params from the screen (WP_Screen) object. You can bypass the library's filter algorithm adding a `true` item to it. This allows you to create your own function to check the screen returning a boolean value.
|
49 |
+
|
50 |
+
### Menu link
|
51 |
+
|
52 |
+
```php
|
53 |
+
add_filter(\PPVersionNotices\Module\MenuLink\Module::SETTINGS_FILTER, function ($settings) {
|
54 |
+
$settings['dumb-plugin-one'] = [
|
55 |
+
'label' => 'Upgrade',
|
56 |
+
'link' => 'http://example.com/upgrade',
|
57 |
+
'parent' => 'parent-menu-alias'
|
58 |
+
];
|
59 |
+
|
60 |
+
return $settings;
|
61 |
+
});
|
62 |
+
```
|
63 |
+
|
64 |
+
If the plugin has alternative parent menus (in case some modules are disabled) you can specify a set of valid menus as parent. The first that is found as parent menu is used as the parent.
|
65 |
+
|
66 |
+
```php
|
67 |
+
add_filter(\PPVersionNotices\Module\MenuLink\Module::SETTINGS_FILTER, function ($settings) {
|
68 |
+
$settings['dumb-plugin-one'] = [
|
69 |
+
'label' => 'Upgrade',
|
70 |
+
'link' => 'http://example.com/upgrade',
|
71 |
+
'parent' => [
|
72 |
+
'parent-menu-alias-1',
|
73 |
+
'parent-menu-alias-2',
|
74 |
+
'parent-menu-alias-3',
|
75 |
+
]
|
76 |
+
];
|
77 |
+
|
78 |
+
return $settings;
|
79 |
+
});
|
80 |
+
```
|
81 |
+
|
82 |
+
#### Params
|
83 |
+
|
84 |
+
* label: Type the respective label for the menu item.
|
85 |
+
* link: The full link for the menu link.
|
86 |
+
* parent: The parent menu we should add the link. A string or an array.
|
87 |
|
88 |
## Testing
|
89 |
|
vendor/publishpress/wordpress-version-notices/assets/css/menu-item.css
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.pp-version-notice-upgrade-menu-item {
|
2 |
+
font-weight: bold !important;
|
3 |
+
color: #FEB123 !important;
|
4 |
+
font-weight: bold;
|
5 |
+
}
|
6 |
+
|
7 |
+
.pp-version-notice-upgrade-menu-item-page {
|
8 |
+
padding: 10px;
|
9 |
+
width: calc(100% - 40px);
|
10 |
+
margin-top: 20px;
|
11 |
+
text-align: center;
|
12 |
+
}
|
13 |
+
|
14 |
+
.pp-version-notice-upgrade-menu-item-page .spin {
|
15 |
+
-webkit-animation: spin 1000ms infinite linear;
|
16 |
+
animation: spin 1000ms infinite linear;
|
17 |
+
color: #635A93;
|
18 |
+
}
|
19 |
+
@-webkit-keyframes spin {
|
20 |
+
0% {
|
21 |
+
-webkit-transform: rotate(0deg);
|
22 |
+
transform: rotate(0deg);
|
23 |
+
}
|
24 |
+
100% {
|
25 |
+
-webkit-transform: rotate(359deg);
|
26 |
+
transform: rotate(359deg);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
@keyframes spin {
|
30 |
+
0% {
|
31 |
+
-webkit-transform: rotate(0deg);
|
32 |
+
transform: rotate(0deg);
|
33 |
+
}
|
34 |
+
100% {
|
35 |
+
-webkit-transform: rotate(359deg);
|
36 |
+
transform: rotate(359deg);
|
37 |
+
}
|
38 |
+
}
|
vendor/publishpress/wordpress-version-notices/codeception.dist.yml
CHANGED
@@ -18,3 +18,6 @@ extensions:
|
|
18 |
- Codeception\Command\GenerateWPXMLRPC
|
19 |
params:
|
20 |
- .env.testing
|
|
|
|
|
|
18 |
- Codeception\Command\GenerateWPXMLRPC
|
19 |
params:
|
20 |
- .env.testing
|
21 |
+
settings:
|
22 |
+
report_useless_tests: true
|
23 |
+
bootstrap: bootstrap.php
|
vendor/publishpress/wordpress-version-notices/codeception.yml
CHANGED
@@ -18,3 +18,6 @@ extensions:
|
|
18 |
- Codeception\Command\GenerateWPXMLRPC
|
19 |
params:
|
20 |
- .env.testing
|
|
|
|
|
|
18 |
- Codeception\Command\GenerateWPXMLRPC
|
19 |
params:
|
20 |
- .env.testing
|
21 |
+
settings:
|
22 |
+
report_useless_tests: true
|
23 |
+
bootstrap: bootstrap.php
|
vendor/publishpress/wordpress-version-notices/includes.php
CHANGED
@@ -27,7 +27,7 @@ use Pimple\Container;
|
|
27 |
use PPVersionNotices\ServicesProvider;
|
28 |
|
29 |
if (!defined('PP_VERSION_NOTICES_LOADED')) {
|
30 |
-
define('PP_VERSION_NOTICES_VERSION', '1.
|
31 |
define('PP_VERSION_NOTICES_BASE_PATH', __DIR__);
|
32 |
define('PP_VERSION_NOTICES_BASE_URL', untrailingslashit(plugin_dir_url(__FILE__)));
|
33 |
define('PP_VERSION_NOTICES_SRC_PATH', PP_VERSION_NOTICES_BASE_PATH . '/src');
|
@@ -51,5 +51,8 @@ if (!defined('PP_VERSION_NOTICES_LOADED')) {
|
|
51 |
$module = $container['module_top_notice'];
|
52 |
$module->init();
|
53 |
|
|
|
|
|
|
|
54 |
define('PP_VERSION_NOTICES_LOADED', true);
|
55 |
}
|
27 |
use PPVersionNotices\ServicesProvider;
|
28 |
|
29 |
if (!defined('PP_VERSION_NOTICES_LOADED')) {
|
30 |
+
define('PP_VERSION_NOTICES_VERSION', '1.1.1');
|
31 |
define('PP_VERSION_NOTICES_BASE_PATH', __DIR__);
|
32 |
define('PP_VERSION_NOTICES_BASE_URL', untrailingslashit(plugin_dir_url(__FILE__)));
|
33 |
define('PP_VERSION_NOTICES_SRC_PATH', PP_VERSION_NOTICES_BASE_PATH . '/src');
|
51 |
$module = $container['module_top_notice'];
|
52 |
$module->init();
|
53 |
|
54 |
+
$module = $container['module_menu_link'];
|
55 |
+
$module->init();
|
56 |
+
|
57 |
define('PP_VERSION_NOTICES_LOADED', true);
|
58 |
}
|
vendor/publishpress/wordpress-version-notices/src/Module/MenuLink/Module.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (c) 2020 PublishPress
|
4 |
+
*
|
5 |
+
* GNU General Public License, Free Software Foundation <https://www.gnu.org/licenses/gpl-3.0.html>
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
+
*
|
20 |
+
* @package PPVersionNotices
|
21 |
+
* @category Core
|
22 |
+
* @author PublishPress
|
23 |
+
* @copyright Copyright (c) 2020 PublishPress. All rights reserved.
|
24 |
+
**/
|
25 |
+
|
26 |
+
namespace PPVersionNotices\Module\MenuLink;
|
27 |
+
|
28 |
+
use PPVersionNotices\Template\TemplateLoaderInterface;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Class Module
|
32 |
+
*
|
33 |
+
* @package PPVersionNotices
|
34 |
+
*/
|
35 |
+
class Module
|
36 |
+
{
|
37 |
+
const SETTINGS_FILTER = 'pp_version_notice_menu_link_settings';
|
38 |
+
|
39 |
+
const STYLE_HANDLE = 'pp-version-notice-menu-link-style';
|
40 |
+
|
41 |
+
const MENU_SLUG_SUFFIX = '-menu-upgrade-link';
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @var TemplateLoaderInterface
|
45 |
+
*/
|
46 |
+
private $templateLoader;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @var array
|
50 |
+
*/
|
51 |
+
private $globalSettings = [];
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @var array
|
55 |
+
*/
|
56 |
+
private $urlsMap = [];
|
57 |
+
|
58 |
+
public function __construct(TemplateLoaderInterface $templateLoader)
|
59 |
+
{
|
60 |
+
$this->templateLoader = $templateLoader;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function init()
|
64 |
+
{
|
65 |
+
add_action('admin_enqueue_scripts', [$this, 'adminEnqueueStyle']);
|
66 |
+
add_action('init', [$this, 'collectTheSettings'], 5);
|
67 |
+
add_action('admin_menu', [$this, 'addMenuLink'], 20);
|
68 |
+
add_action('admin_print_scripts', [$this, 'setUpgradeMenuLink'], 9999);
|
69 |
+
}
|
70 |
+
|
71 |
+
public function collectTheSettings()
|
72 |
+
{
|
73 |
+
if (is_admin()) {
|
74 |
+
$this->globalSettings = apply_filters(self::SETTINGS_FILTER, []);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
public function adminEnqueueStyle()
|
79 |
+
{
|
80 |
+
wp_enqueue_style(
|
81 |
+
self::STYLE_HANDLE,
|
82 |
+
PP_VERSION_NOTICES_BASE_URL . '/assets/css/menu-item.css',
|
83 |
+
false,
|
84 |
+
PP_VERSION_NOTICES_VERSION
|
85 |
+
);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @param array $settings
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
private function getSubmenuSlug($settings)
|
94 |
+
{
|
95 |
+
return $settings['parent'] . self::MENU_SLUG_SUFFIX;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function addMenuLink()
|
99 |
+
{
|
100 |
+
global $submenu;
|
101 |
+
|
102 |
+
$templateLoader = $this->templateLoader;
|
103 |
+
|
104 |
+
foreach ($this->globalSettings as $pluginName => $settings) {
|
105 |
+
if (is_array($settings['parent'])) {
|
106 |
+
foreach ($settings['parent'] as $parent) {
|
107 |
+
$menuPageURL = menu_page_url($parent, false);
|
108 |
+
|
109 |
+
if (!empty($menuPageURL)) {
|
110 |
+
$settings['parent'] = $parent;
|
111 |
+
|
112 |
+
break;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
if (!empty($settings['parent'])) {
|
118 |
+
$submenuSlug = $this->getSubmenuSlug($settings);
|
119 |
+
|
120 |
+
add_submenu_page(
|
121 |
+
$settings['parent'],
|
122 |
+
$settings['label'],
|
123 |
+
$settings['label'],
|
124 |
+
'read',
|
125 |
+
$submenuSlug,
|
126 |
+
function () use ($settings, $templateLoader) {
|
127 |
+
$context = [
|
128 |
+
'message' => __(
|
129 |
+
'Amazing! We are redirecting you to our site...',
|
130 |
+
'wordpress-version-notices'
|
131 |
+
),
|
132 |
+
'link' => $settings['link']
|
133 |
+
];
|
134 |
+
|
135 |
+
$templateLoader->displayOutput('menu-link', 'redirect-page', $context);
|
136 |
+
},
|
137 |
+
9999
|
138 |
+
);
|
139 |
+
|
140 |
+
$this->urlsMap[$pluginName] = [
|
141 |
+
'slug' => $submenuSlug,
|
142 |
+
'localUrl' => menu_page_url($submenuSlug, false),
|
143 |
+
'redirectTo' => $settings['link'],
|
144 |
+
];
|
145 |
+
|
146 |
+
// Add the CSS class to change the item color and add a reference to the respective URL.
|
147 |
+
$newItemIndex = $this->getUpgradeMenuItemIndex($submenu[$settings['parent']], $settings);
|
148 |
+
|
149 |
+
if (false !== $newItemIndex) {
|
150 |
+
$submenu[$settings['parent']][$newItemIndex][4] = 'pp-version-notice-upgrade-menu-item ' . $pluginName;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
private function getUpgradeMenuItemIndex($submenuItems, $settings)
|
157 |
+
{
|
158 |
+
foreach ($submenuItems as $index => $item) {
|
159 |
+
if ($item[0] === $settings['label'] && $item[2] === $this->getSubmenuSlug($settings)) {
|
160 |
+
return $index;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
return false;
|
165 |
+
}
|
166 |
+
|
167 |
+
public function setUpgradeMenuLink()
|
168 |
+
{
|
169 |
+
if (empty($this->urlsMap)) {
|
170 |
+
return;
|
171 |
+
}
|
172 |
+
|
173 |
+
$convertedUrlsMap = [];
|
174 |
+
|
175 |
+
foreach ($this->urlsMap as $pluginName => $urlData) {
|
176 |
+
$urlData['pluginName'] = $pluginName;
|
177 |
+
|
178 |
+
$convertedUrlsMap[] = $urlData;
|
179 |
+
}
|
180 |
+
|
181 |
+
$context = [
|
182 |
+
'convertedUrlsMap' => $convertedUrlsMap,
|
183 |
+
];
|
184 |
+
|
185 |
+
$this->templateLoader->displayOutput('menu-link', 'menu-link-script', $context);
|
186 |
+
}
|
187 |
+
}
|
vendor/publishpress/wordpress-version-notices/src/ServicesProvider.php
CHANGED
@@ -28,6 +28,7 @@ namespace PPVersionNotices;
|
|
28 |
use Pimple\Container;
|
29 |
use Pimple\ServiceProviderInterface;
|
30 |
use PPVersionNotices\Module\TopNotice\Module as TopNoticeModule;
|
|
|
31 |
use PPVersionNotices\Template\TemplateLoader;
|
32 |
|
33 |
class ServicesProvider implements ServiceProviderInterface
|
@@ -42,6 +43,10 @@ class ServicesProvider implements ServiceProviderInterface
|
|
42 |
return new TopNoticeModule($c['template_loader']);
|
43 |
};
|
44 |
|
|
|
|
|
|
|
|
|
45 |
$pimple['template_loader'] = function (Container $c) {
|
46 |
return new TemplateLoader($c['TEMPLATES_PATH']);
|
47 |
};
|
28 |
use Pimple\Container;
|
29 |
use Pimple\ServiceProviderInterface;
|
30 |
use PPVersionNotices\Module\TopNotice\Module as TopNoticeModule;
|
31 |
+
use PPVersionNotices\Module\MenuLink\Module as MenuLinkModule;
|
32 |
use PPVersionNotices\Template\TemplateLoader;
|
33 |
|
34 |
class ServicesProvider implements ServiceProviderInterface
|
43 |
return new TopNoticeModule($c['template_loader']);
|
44 |
};
|
45 |
|
46 |
+
$pimple['module_menu_link'] = function (Container $c) {
|
47 |
+
return new MenuLinkModule($c['template_loader']);
|
48 |
+
};
|
49 |
+
|
50 |
$pimple['template_loader'] = function (Container $c) {
|
51 |
return new TemplateLoader($c['TEMPLATES_PATH']);
|
52 |
};
|
vendor/publishpress/wordpress-version-notices/templates/menu-link/menu-link-script.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="application/javascript">
|
2 |
+
jQuery(function ($) {
|
3 |
+
var linksMap = JSON.parse('<?php echo json_encode($convertedUrlsMap); ?>'),
|
4 |
+
urlData = null;
|
5 |
+
|
6 |
+
// Remove the domain and admin folder from the URL to match the menu's url.
|
7 |
+
for (var i = 0; i < linksMap.length; i++) {
|
8 |
+
urlData = linksMap[i];
|
9 |
+
|
10 |
+
$('a.pp-version-notice-upgrade-menu-item.' + urlData.pluginName).attr('target', '_blank').attr('href', urlData.redirectTo);
|
11 |
+
}
|
12 |
+
});
|
13 |
+
</script>
|
vendor/publishpress/wordpress-version-notices/templates/menu-link/redirect-page.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="pp-version-notice-upgrade-menu-item-page">
|
2 |
+
<p>
|
3 |
+
<span class="dashicons dashicons-smiley spin bounce"></span>
|
4 |
+
<div class="message"><?php echo esc_html($message); ?></div>
|
5 |
+
</p>
|
6 |
+
|
7 |
+
<script type="application/javascript">
|
8 |
+
window.setTimeout(
|
9 |
+
function () {
|
10 |
+
window.location.replace("<?php echo esc_url($link); ?>");
|
11 |
+
},
|
12 |
+
600
|
13 |
+
);
|
14 |
+
</script>
|
15 |
+
</div>
|