composer.lock + vendor
This commit is contained in:
parent
4229406ec8
commit
9d574615e8
30
composer.lock
generated
30
composer.lock
generated
@ -4,24 +4,24 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c7eb351b97392f663e147702dbc845b9",
|
||||
"content-hash": "d8561fb20f4729b2675b8aeef402b4aa",
|
||||
"packages": [
|
||||
{
|
||||
"name": "abuyoyo/adminmenupage",
|
||||
"version": "0.21",
|
||||
"version": "0.25",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/abuyoyo/AdminMenuPage.git",
|
||||
"reference": "d05a9e9977d7e7c4ba3c913993493fefba4359d6"
|
||||
"reference": "487d262aec77a9a3ce04fa762e9048f30d22f123"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/d05a9e9977d7e7c4ba3c913993493fefba4359d6",
|
||||
"reference": "d05a9e9977d7e7c4ba3c913993493fefba4359d6",
|
||||
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/487d262aec77a9a3ce04fa762e9048f30d22f123",
|
||||
"reference": "487d262aec77a9a3ce04fa762e9048f30d22f123",
|
||||
"shasum": ""
|
||||
},
|
||||
"suggest": {
|
||||
"abuyoyo/plugincore": "~0.18",
|
||||
"abuyoyo/plugincore": "~0.26",
|
||||
"cmb2/cmb2": "~2.9"
|
||||
},
|
||||
"type": "library",
|
||||
@ -40,26 +40,26 @@
|
||||
"description": "WordPress admin menu page helper class",
|
||||
"support": {
|
||||
"issues": "https://github.com/abuyoyo/AdminMenuPage/issues",
|
||||
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.21"
|
||||
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.25"
|
||||
},
|
||||
"time": "2022-08-06T13:42:37+00:00"
|
||||
"time": "2023-06-09T00:00:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "abuyoyo/plugincore",
|
||||
"version": "0.23",
|
||||
"version": "0.26",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/abuyoyo/PluginCore.git",
|
||||
"reference": "0a5809d6722a2abf0bdaf23f73bd3875b00fd2a4"
|
||||
"reference": "77f7d5451bdff4bda6c9766847b215bdeaca96d6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/0a5809d6722a2abf0bdaf23f73bd3875b00fd2a4",
|
||||
"reference": "0a5809d6722a2abf0bdaf23f73bd3875b00fd2a4",
|
||||
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/77f7d5451bdff4bda6c9766847b215bdeaca96d6",
|
||||
"reference": "77f7d5451bdff4bda6c9766847b215bdeaca96d6",
|
||||
"shasum": ""
|
||||
},
|
||||
"suggest": {
|
||||
"abuyoyo/adminmenupage": "~0.20",
|
||||
"abuyoyo/adminmenupage": "~0.25",
|
||||
"yahnis-elsts/plugin-update-checker": "~4.12"
|
||||
},
|
||||
"type": "library",
|
||||
@ -75,9 +75,9 @@
|
||||
"description": "WordPress plugin core helper class",
|
||||
"support": {
|
||||
"issues": "https://github.com/abuyoyo/PluginCore/issues",
|
||||
"source": "https://github.com/abuyoyo/PluginCore/tree/0.23"
|
||||
"source": "https://github.com/abuyoyo/PluginCore/tree/0.26"
|
||||
},
|
||||
"time": "2022-08-06T00:00:00+00:00"
|
||||
"time": "2022-06-09T00:00:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "abuyoyo/screen-meta-links",
|
||||
|
||||
52
vendor/abuyoyo/adminmenupage/CHANGELOG.md
vendored
52
vendor/abuyoyo/adminmenupage/CHANGELOG.md
vendored
@ -1,6 +1,54 @@
|
||||
# Changelog
|
||||
WPHelper\AdminMenuPage
|
||||
|
||||
## 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 temlate 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
|
||||
@ -9,7 +57,7 @@ WPHelper\AdminMenuPage
|
||||
## 0.20
|
||||
|
||||
### Added
|
||||
- Add SettingsPage section option `desciption-container`. Accepts `card` div, `notice`, `notice-info` and `none`.
|
||||
- Add SettingsPage section option `description-container`. Accepts `card` div, `notice`, `notice-info` and `none`.
|
||||
- Sanitize SettingsPage text, url and email fields.
|
||||
|
||||
## 0.19
|
||||
@ -19,7 +67,7 @@ WPHelper\AdminMenuPage
|
||||
- CMB2_OptionsPage supports all admin menu top-level slugs.
|
||||
|
||||
### Fixed
|
||||
- Fixed PHP fatal error: cannot redeclare function `wph_extra_plugin_headers()`.
|
||||
- Fix PHP fatal error: cannot redeclare function `wph_extra_plugin_headers()`.
|
||||
|
||||
### Changed
|
||||
- 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,14 +40,13 @@ $args = [
|
||||
'icon_url' => $icon_url; // optional - icon url passed to add_menu_page/add_submenu_page
|
||||
'position' => 4; // optional - passed to add_menu_page
|
||||
'scripts' => [ // optional - script parameters passed to enqueue_scripts. Will only enqueue scripts on admin page
|
||||
[ 'script_handle', 'js/myscript.js', ['jquery'], false, true ],
|
||||
[ 'script_handle', 'js/my_script.js', ['jquery'], false, true ],
|
||||
[ 'another_script', 'js/my_other_script.js', ['jquery', 'script_handle'], false, true ]
|
||||
];
|
||||
];
|
||||
|
||||
// Register the admin menu page.
|
||||
$admin_menu_page = new AdminPage( $args );
|
||||
$admin_menu_page->setup();
|
||||
|
||||
// That's it. We're done.
|
||||
// This function can be called from anywhere. No need to wrap in any hook.
|
||||
|
||||
5
vendor/abuyoyo/adminmenupage/composer.json
vendored
5
vendor/abuyoyo/adminmenupage/composer.json
vendored
@ -2,10 +2,11 @@
|
||||
"name": "abuyoyo/adminmenupage",
|
||||
"description": "WordPress admin menu page helper class",
|
||||
"type": "library",
|
||||
"version": "0.21",
|
||||
"version": "0.25",
|
||||
"time": "2023-06-09",
|
||||
"license": "BSD-3-Clause",
|
||||
"suggest": {
|
||||
"abuyoyo/plugincore": "~0.18",
|
||||
"abuyoyo/plugincore": "~0.26",
|
||||
"cmb2/cmb2": "~2.9"
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
@ -3,7 +3,7 @@ namespace WPHelper;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||
|
||||
if ( ! class_exists( 'WPHelper\AdminMenuPage' ) ):
|
||||
if ( ! class_exists( AdminMenuPage::class ) ):
|
||||
/**
|
||||
* AdminMenuPage
|
||||
*
|
||||
|
||||
297
vendor/abuyoyo/adminmenupage/src/AdminPage.php
vendored
297
vendor/abuyoyo/adminmenupage/src/AdminPage.php
vendored
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
namespace WPHelper;
|
||||
|
||||
use CMB2_Options_Hookup;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||
|
||||
use function add_menu_page;
|
||||
use function add_options_page;
|
||||
use function add_submenu_page;
|
||||
|
||||
if ( ! class_exists( 'WPHelper\AdminPage' ) ):
|
||||
if ( ! class_exists( AdminPage::class ) ):
|
||||
/**
|
||||
* AdminPage
|
||||
*
|
||||
@ -106,6 +108,20 @@ class AdminPage
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@ -120,6 +136,13 @@ class AdminPage
|
||||
*/
|
||||
protected $scripts;
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @var array[] arrays of settings sections and fields
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* Styles
|
||||
*
|
||||
@ -156,11 +179,18 @@ class AdminPage
|
||||
protected $settings_page;
|
||||
|
||||
/**
|
||||
* Delegate admin_menu hookup to CMB2 implementation
|
||||
* CMB2 custom settings page
|
||||
*
|
||||
* @var boolean
|
||||
* @var CMB2_OptionsPage|CMB2_OptionsPage_Multi
|
||||
*/
|
||||
protected $delegate_hookup = false;
|
||||
protected $cmb2_page;
|
||||
|
||||
/**
|
||||
* Plugin Info Meta Box render object
|
||||
*
|
||||
* @var PluginInfoMetaBox
|
||||
*/
|
||||
protected $plugin_info_meta_box;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -178,14 +208,13 @@ class AdminPage
|
||||
if ( isset( $options->plugin_core ) )
|
||||
$this->plugin_core( $options->plugin_core );
|
||||
|
||||
if ( isset( $options->title ) )
|
||||
$this->title( $options->title );
|
||||
$this->title( $options->title ?? null );
|
||||
|
||||
/**
|
||||
* @todo move this to bootstrap()
|
||||
*/
|
||||
if ( ! isset( $options->menu_title ) )
|
||||
$options->menu_title = $options->title;
|
||||
$options->menu_title = $this->title;
|
||||
|
||||
if ( isset( $options->menu_title ) )
|
||||
$this->menu_title( $options->menu_title );
|
||||
@ -193,8 +222,7 @@ class AdminPage
|
||||
if ( isset( $options->capability ) )
|
||||
$this->capability( $options->capability );
|
||||
|
||||
if ( isset( $options->slug ) )
|
||||
$this->slug( $options->slug );
|
||||
$this->slug( $options->slug ?? null );
|
||||
|
||||
if ( isset( $options->plugin_info ) ){ // before render()
|
||||
$this->plugin_info( $options->plugin_info );
|
||||
@ -204,21 +232,24 @@ class AdminPage
|
||||
$this->wrap( $options->wrap );
|
||||
}
|
||||
|
||||
if ( isset( $options->render ) ) // dev
|
||||
$this->render( $options->render );
|
||||
|
||||
if ( isset( $options->render_cb ) ) // dev - deprecate?
|
||||
if ( isset( $options->render_cb ) )
|
||||
$this->render_cb( $options->render_cb );
|
||||
|
||||
if ( isset( $options->render_tpl ) ) // dev - deprecate?
|
||||
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 );
|
||||
|
||||
|
||||
if (true)
|
||||
$this->render(); // render anyway - will use default tpl if render is empty
|
||||
|
||||
if (true)
|
||||
$this->wrap(); // set wrap anyway - will set to 'none' if empty
|
||||
|
||||
|
||||
if ( isset( $options->parent ) )
|
||||
$this->parent( $options->parent );
|
||||
|
||||
@ -228,6 +259,11 @@ class AdminPage
|
||||
if ( isset( $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 ) )
|
||||
$this->scripts( $options->scripts );
|
||||
|
||||
@ -253,8 +289,8 @@ class AdminPage
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private function title( $title ) {
|
||||
$this->title = $title;
|
||||
private function title( $title=null ) {
|
||||
$this->title = $title ?? ( isset( $this->plugin_core ) ? $this->plugin_core->title() : __METHOD__ );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,7 +320,19 @@ class AdminPage
|
||||
* @access private
|
||||
*/
|
||||
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
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,7 +364,6 @@ class AdminPage
|
||||
$this->icon_url = $icon_url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setter - position
|
||||
* WordPress admin menu param
|
||||
@ -327,6 +374,44 @@ class AdminPage
|
||||
$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', [ $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
|
||||
* Sets render cb or tpl
|
||||
@ -340,34 +425,30 @@ class AdminPage
|
||||
*/
|
||||
private function render( $render=null ) {
|
||||
if ( 'settings-page' == $render ) {
|
||||
$this->render_tpl( __DIR__ . '/tpl/settings-form.php' );
|
||||
$this->render_tpl( __DIR__ . '/tpl/form-basic.php' );
|
||||
$this->render = $this->render ?? $render; // 'settings-page'
|
||||
} else if ( 'cmb2' == $render || 'cmb2-tabs' == $render ) {
|
||||
|
||||
// validate
|
||||
if ( ! defined( 'CMB2_LOADED' ) ){
|
||||
$this->render_tpl( __DIR__ . '/tpl/cmb2-unavailable.php' );
|
||||
$this->render_tpl( __DIR__ . '/tpl/wrap-cmb2-unavailable.php' );
|
||||
$this->render = $this->render ?? 'render_tpl';
|
||||
} else {
|
||||
$this->delegate_hookup = true;
|
||||
|
||||
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' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render templates managed and included by CMB2_OptionsPage
|
||||
* @see CMB2_OptionsPage::options_page_output()
|
||||
*/
|
||||
$this->render = $this->render ?? $render; // 'cmb2' || 'cmb2-tabs'
|
||||
}
|
||||
|
||||
} else if( is_callable( $render ) ) {
|
||||
$this->render_cb( $render );
|
||||
$this->render = $this->render ?? 'render_cb';
|
||||
} else if ( is_readable( $render ) ) {
|
||||
} else if ( is_readable( $render ?? '' ) ) {
|
||||
$this->render_tpl( $render );
|
||||
$this->render = $this->render ?? 'render_tpl';
|
||||
} else {
|
||||
$this->render_tpl( __DIR__ . '/tpl/default.php' );
|
||||
$this->render_tpl( __DIR__ . '/tpl/wrap-default.php' );
|
||||
$this->render = $this->render ?? 'render_tpl';
|
||||
}
|
||||
}
|
||||
@ -465,11 +546,23 @@ class AdminPage
|
||||
if( is_callable( $plugin_info ) )
|
||||
$this->plugin_info = $plugin_info;
|
||||
|
||||
// if true-y value passed and PluginCore class exists - set to true
|
||||
else if (!empty($plugin_info) && class_exists('WPHelper\PluginCore'))
|
||||
// if true-y value passed and plugin_core isset
|
||||
else if ( ! empty( $plugin_info ) && ! empty( $this->plugin_core ) )
|
||||
$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
|
||||
* Scripts to enqueue on admin page
|
||||
@ -501,7 +594,7 @@ class AdminPage
|
||||
}
|
||||
|
||||
function plugin_core($plugin_core){
|
||||
if ( is_a( $plugin_core, 'WPHelper\PluginCore') ){
|
||||
if ( $plugin_core instanceof PluginCore ){
|
||||
$this->plugin_core = $plugin_core;
|
||||
}
|
||||
}
|
||||
@ -525,13 +618,18 @@ class AdminPage
|
||||
'capability' => $this->capability,
|
||||
'slug' => $this->slug,
|
||||
'parent' => $this->parent,
|
||||
'hook_suffix' => $this->hook_suffix,
|
||||
'icon_url' => $this->icon_url,
|
||||
'position' => $this->position,
|
||||
'render' => $this->render, // render_cb | render_tpl | settings-page | cmb2 | cmb2-tabs
|
||||
'render_cb' => $this->render_cb,
|
||||
'render_tpl' => $this->render_tpl,
|
||||
'settings' => $this->settings,
|
||||
'wrap' => $this->wrap,
|
||||
'tab_group' => $this->tab_group,
|
||||
'tab_title' => $this->tab_title,
|
||||
'plugin_core' => $this->plugin_core,
|
||||
'plugin_info' => $this->plugin_info,
|
||||
];
|
||||
|
||||
return $options;
|
||||
@ -570,37 +668,30 @@ class AdminPage
|
||||
if ( ! $this->capability )
|
||||
$this->capability = 'manage_options';
|
||||
|
||||
if ( $this->render == 'settings-page' ){
|
||||
add_action( "wphelper/adminpage/plugin_info_box/{$this->slug}" , [ $this , 'render_plugin_info_meta_box' ] );
|
||||
|
||||
$this->settings_page = new SettingsPage($this);
|
||||
$this->settings_page->setup();
|
||||
/**
|
||||
* @todo Perhaps 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_init' , [ $this , '_bootstrap_admin_page' ] );
|
||||
|
||||
}
|
||||
if ( in_array( $this->render, [ 'cmb2', 'cmb2-tabs' ] ) ){
|
||||
|
||||
add_action( "wphelper/adminpage/plugin_info_box/{$this->slug}" , [ $this , 'render_plugin_info_box' ] );
|
||||
|
||||
// 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 Perhaps 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 );
|
||||
$this->cmb2_page = $this->settings['options_type'] ?? '' == 'multi'
|
||||
? new CMB2_OptionsPage_Multi( $this )
|
||||
: new CMB2_OptionsPage( $this );
|
||||
|
||||
// skip add_menu_page
|
||||
return;
|
||||
}
|
||||
|
||||
// if ( ! $this->delegate_hookup ){
|
||||
if ( $this->render == 'settings-page' ){
|
||||
$this->settings_page = new SettingsPage($this);
|
||||
}
|
||||
|
||||
add_action ( 'admin_menu' , [ $this , 'add_menu_page' ], 11 );
|
||||
add_action ( 'admin_menu' , [ $this , '_bootstrap_admin_page' ], 12 );
|
||||
add_action ( 'admin_menu' , [ $this , 'add_plugin_info_meta_box' ], 11 );
|
||||
|
||||
}
|
||||
|
||||
@ -644,6 +735,21 @@ class AdminPage
|
||||
);
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
@ -653,14 +759,6 @@ class AdminPage
|
||||
*/
|
||||
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 ) ){
|
||||
$this->hook_suffix = get_plugin_page_hookname( $this->slug, $this->parent );
|
||||
}
|
||||
@ -678,14 +776,9 @@ class AdminPage
|
||||
*
|
||||
* @hook admin_menu priority 12
|
||||
* @access private
|
||||
*
|
||||
* @todo move this function to admin_init - after admin_menu has finished
|
||||
*/
|
||||
public function _bootstrap_admin_page(){
|
||||
|
||||
/**
|
||||
* @todo perhaps run this on 'admin_init'
|
||||
*/
|
||||
$this->validate_page_hook();
|
||||
|
||||
add_action ( 'load-' . $this->hook_suffix , [ $this , '_admin_page_setup' ] );
|
||||
@ -854,19 +947,21 @@ class AdminPage
|
||||
*/
|
||||
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 ){
|
||||
ob_start();
|
||||
}
|
||||
|
||||
//---------------------------[The McGuffin]---------------------------------//
|
||||
if ( isset( $this->render_cb ) && is_callable( $this->render_cb ) ) {
|
||||
call_user_func( $this->render_cb );
|
||||
} else if ( isset( $this->render_tpl ) && is_readable( $this->render_tpl ) ) {
|
||||
include $this->render_tpl;
|
||||
}
|
||||
//---------------------------[The McGuffin]---------------------------------//
|
||||
|
||||
// if wrap - 2. include chosen wrap template
|
||||
if ( 'none' != $this->wrap ){
|
||||
$ob_content = ob_get_clean();
|
||||
|
||||
@ -885,7 +980,21 @@ 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.
|
||||
* Or else attempt to create PluginInfoMetaBox class from $this->plugin_core and call its render function.
|
||||
@ -895,17 +1004,55 @@ class AdminPage
|
||||
* @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
|
||||
*/
|
||||
public function render_plugin_info_box(){
|
||||
public function render_plugin_info_meta_box(){
|
||||
|
||||
if ( isset( $this->plugin_info ) && is_callable( $this->plugin_info ) ) {
|
||||
call_user_func( $this->plugin_info );
|
||||
} else {
|
||||
if ( ! empty( $this->plugin_core ) && empty( $this->plugin_info_meta_box ) ){
|
||||
$this->plugin_info_meta_box = new PluginInfoMetaBox( $this->plugin_core );
|
||||
|
||||
if (!$this->bootstrap_plugin_info_meta_box()){
|
||||
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;
|
||||
@ -4,9 +4,9 @@ namespace WPHelper;
|
||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||
|
||||
use CMB2;
|
||||
use CMB2_Options_Hook;
|
||||
use CMB2_Options_Hookup;
|
||||
|
||||
if ( ! class_exists( 'WPHelper\CMB2_OptionsPage' ) ):
|
||||
if ( ! class_exists( CMB2_OptionsPage::class ) ):
|
||||
/**
|
||||
* CMB2_OptionsPage
|
||||
*
|
||||
@ -26,11 +26,21 @@ class CMB2_OptionsPage{
|
||||
*/
|
||||
public $admin_page;
|
||||
|
||||
/**
|
||||
* @var array $fields
|
||||
*/
|
||||
protected $fields;
|
||||
|
||||
/**
|
||||
* @var CMB2 $cmb
|
||||
*/
|
||||
private $cmb;
|
||||
|
||||
/**
|
||||
* @var array $cmb2_options
|
||||
*/
|
||||
protected $cmb2_options;
|
||||
|
||||
/**
|
||||
* @param AdminPage $admin_page
|
||||
*/
|
||||
@ -48,6 +58,8 @@ class CMB2_OptionsPage{
|
||||
$settings['option_key'] ??= ( $settings['option_name'] ?? ( $settings['id'] ?? $admin_options['slug'] ) );
|
||||
$settings['title'] ??= $admin_options['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['position'] ??= $admin_options['position'];
|
||||
$settings['icon_url'] ??= $admin_options['icon_url'];
|
||||
@ -63,7 +75,8 @@ class CMB2_OptionsPage{
|
||||
/**
|
||||
* CMB2 only accepts url slug
|
||||
*
|
||||
* @todo export parent_slug convertion to dedicated method
|
||||
* @todo export parent_slug conversion to dedicated method
|
||||
* @todo perhaps move this to AdminPage::parent() method
|
||||
*/
|
||||
switch ( $settings['parent_slug'] ) {
|
||||
case 'dashboard':
|
||||
@ -116,11 +129,11 @@ class CMB2_OptionsPage{
|
||||
$settings['tab_title'] ??= $settings['menu_title'];
|
||||
}
|
||||
|
||||
$this->fields = $settings['fields'] ?? [];
|
||||
/**
|
||||
* @todo revisit this - might not need to unset fields
|
||||
*/
|
||||
if ( isset( $settings['fields'] ) ){
|
||||
$this->fields = $settings['fields'];
|
||||
/**
|
||||
* @todo revisit this - might not need to unset fields
|
||||
*/
|
||||
unset( $settings['fields'] );
|
||||
}
|
||||
|
||||
@ -198,12 +211,20 @@ class CMB2_OptionsPage{
|
||||
/**
|
||||
* Display options-page output. To override, set 'display_cb' box property.
|
||||
*
|
||||
* @param CMB2_Options_Hook $hookup - instance of Options Page Hookup class (caller of this function)
|
||||
* @param CMB2_Options_Hookup $hookup - instance of Options Page Hookup class (caller of this function)
|
||||
*
|
||||
* @see CMB2_Options_Hook
|
||||
* @see CMB2_Options_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,9 +3,13 @@ namespace WPHelper;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||
|
||||
include_once __DIR__ . '/CMB2_Override_Meta.php';
|
||||
if ( ! class_exists( CMB2_OptionsPage_Multi::class ) ):
|
||||
|
||||
// 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
|
||||
*
|
||||
|
||||
@ -3,7 +3,7 @@ namespace WPHelper;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||
|
||||
if ( ! trait_exists('CMB2_Override_Meta') ):
|
||||
if ( ! trait_exists( CMB2_Override_Meta::class ) ):
|
||||
/**
|
||||
* CMB2 Options page override meta
|
||||
*
|
||||
|
||||
@ -2,27 +2,72 @@
|
||||
namespace WPHelper;
|
||||
|
||||
use DateTime;
|
||||
use function get_plugin_data;
|
||||
|
||||
if ( ! class_exists( 'WPHelper\PluginInfoMetaBox' ) ):
|
||||
if ( ! class_exists( PluginInfoMetaBox::class ) ):
|
||||
/**
|
||||
* Plugin Info Metabox
|
||||
*
|
||||
* Get instance of PluginCore
|
||||
* Render default plugin info box template.
|
||||
*
|
||||
* @since 0.14
|
||||
*/
|
||||
class PluginInfoMetaBox{
|
||||
|
||||
private $tpl = '/tpl/plugin_info_meta_box.php';
|
||||
|
||||
private $tpl_inside = '/tpl/plugin_info_meta_box-inside.php';
|
||||
|
||||
/**
|
||||
* @var PluginCore
|
||||
*/
|
||||
private $plugin_core;
|
||||
public $plugin_core;
|
||||
|
||||
function __construct( PluginCore $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');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,33 +78,25 @@ class PluginInfoMetaBox{
|
||||
* @since iac_engine 1.1.0
|
||||
* @since iac_engine 1.2.0 plugin_info_box now a function
|
||||
* @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(){
|
||||
|
||||
$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;
|
||||
|
||||
$args = $this->setup_template_args();
|
||||
extract($args);
|
||||
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;
|
||||
}
|
||||
}
|
||||
endif;
|
||||
@ -9,7 +9,7 @@ use function add_settings_field;
|
||||
use function checked;
|
||||
use function get_option;
|
||||
|
||||
if ( ! class_exists( 'WPHelper\SettingsPage' ) ):
|
||||
if ( ! class_exists( SettingsPage::class ) ):
|
||||
/**
|
||||
* SettingsPage
|
||||
*
|
||||
@ -64,6 +64,13 @@ class SettingsPage{
|
||||
*/
|
||||
public $fields = [];
|
||||
|
||||
/**
|
||||
* Sanitize Callback
|
||||
*
|
||||
* @var Callable $sanitize_callback
|
||||
*/
|
||||
public $sanitize_callback;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@ -89,18 +96,20 @@ class SettingsPage{
|
||||
|
||||
$this->option_group = $settings['option_group'] ?? $this->page . '_option_group';
|
||||
|
||||
foreach ( $settings['sections'] as $section ) {
|
||||
$this->sanitize_callback = $settings['sanitize_callback'] ?? null;
|
||||
|
||||
// PHP Warning: foreach() argument must be of type array|object
|
||||
foreach ( $settings['sections'] ?? [] as $section ) {
|
||||
// extract fields
|
||||
foreach ( $section['fields'] as $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;
|
||||
}
|
||||
unset( $section['fields'] );
|
||||
$this->sections[] = $section; // save without fields
|
||||
}
|
||||
}
|
||||
|
||||
function setup() {
|
||||
add_action( 'admin_init', [ $this, 'register_settings' ] );
|
||||
}
|
||||
|
||||
@ -108,7 +117,7 @@ class SettingsPage{
|
||||
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_name, // $option_name - The name of an option to sanitize and save.
|
||||
[ $this,'sanitize_settings' ] // $sanitize_callback - A callback function that sanitizes the option's value. (see also: built-in php callbacks)
|
||||
$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)
|
||||
);
|
||||
|
||||
foreach ( $this->sections as $section ){
|
||||
@ -125,7 +134,7 @@ class SettingsPage{
|
||||
add_settings_field(
|
||||
$field['id'],
|
||||
$field['title'],
|
||||
[ $this, "print_{$field['type']}" ],
|
||||
$field['render'] ?? [ $this, "print_{$field['type']}" ],
|
||||
$this->page, // can built-in pages: (general, reading, writing, ...)
|
||||
$field['section_id'],
|
||||
$field //send setting array as $args for print function
|
||||
@ -135,8 +144,8 @@ class SettingsPage{
|
||||
}
|
||||
|
||||
/**
|
||||
* Print text input field
|
||||
* Support field type 'text'
|
||||
* Print checkbox input field
|
||||
* Support field type 'checkbox'
|
||||
*
|
||||
* @since 0.11
|
||||
*/
|
||||
@ -147,10 +156,11 @@ class SettingsPage{
|
||||
|
||||
$input_tag = sprintf(
|
||||
'<label for="%1$s">
|
||||
<input name="%2$s[%1$s]" type="checkbox" id="%1$s" value="1" %4$s />
|
||||
%3$s</label>',
|
||||
<input name="%2$s" type="checkbox" id="%1$s" aria-describedby="%1$s-description" value="1" %4$s />
|
||||
%3$s
|
||||
</label>',
|
||||
$id,
|
||||
$this->option_name,
|
||||
$name,
|
||||
$description,
|
||||
checked( ( $options[$id] ?? false ), '1', false)
|
||||
);
|
||||
@ -176,10 +186,11 @@ class SettingsPage{
|
||||
$options = get_option( $this->option_name );
|
||||
|
||||
$input_tag = sprintf(
|
||||
'<input name="%2$s[%1$s]" type="text" id="%1$s" value="%3$s" class="regular-text">',
|
||||
'<input name="%2$s" type="text" id="%1$s" aria-describedby="%1$s-description" value="%3$s" placeholder="%4$s" class="regular-text">',
|
||||
$id,
|
||||
$this->option_name,
|
||||
$default
|
||||
$name,
|
||||
$options[$id] ?: $default ?? '',
|
||||
$placeholder ?? ''
|
||||
);
|
||||
|
||||
if ( ! empty( $description ) ) {
|
||||
@ -211,10 +222,11 @@ class SettingsPage{
|
||||
$options = get_option( $this->option_name );
|
||||
|
||||
$input_tag = sprintf(
|
||||
'<input name="%2$s[%1$s]" type="url" id="%1$s" value="%3$s" class="regular-text code ">',
|
||||
'<input name="%2$s" type="url" id="%1$s" aria-describedby="%1$s-description" placeholder="%4$s" value="%3$s" class="regular-text code ">',
|
||||
$id,
|
||||
$this->option_name,
|
||||
$default
|
||||
$name,
|
||||
$options[$id] ?: $default ?? '',
|
||||
$placeholder ?? ''
|
||||
);
|
||||
|
||||
if ( ! empty( $description ) ) {
|
||||
@ -246,10 +258,11 @@ class SettingsPage{
|
||||
$options = get_option( $this->option_name );
|
||||
|
||||
$input_tag = sprintf(
|
||||
'<input name="%2$s[%1$s]" type="email" id="%1$s" aria-describedby="%1$s-description" value="%3$s" class="regular-text ltr">',
|
||||
'<input name="%2$s" type="email" id="%1$s" aria-describedby="%1$s-description" placeholder="%4$s" value="%3$s" class="regular-text ltr">',
|
||||
$id,
|
||||
$this->option_name,
|
||||
$default
|
||||
$name,
|
||||
$options[$id] ?: $default ?? '',
|
||||
$placeholder ?? ''
|
||||
);
|
||||
|
||||
if ( ! empty( $description ) ) {
|
||||
@ -269,6 +282,42 @@ 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.
|
||||
*/
|
||||
@ -276,17 +325,18 @@ class SettingsPage{
|
||||
$new_options = [];
|
||||
|
||||
foreach( $options as $id => $option ) {
|
||||
$field = reset(
|
||||
$field = current(
|
||||
array_filter(
|
||||
$this->fields,
|
||||
fn($item) => $item['id'] == $id
|
||||
)
|
||||
);
|
||||
switch ( $field['type'] ){
|
||||
switch ( $field['type'] ) {
|
||||
case 'checkbox':
|
||||
$new_options[$id] = $option == 1 ? 1 : 0;
|
||||
break;
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
$new_options[$id] = sanitize_text_field( $option );
|
||||
break;
|
||||
case 'email':
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
<?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>
|
||||
27
vendor/abuyoyo/adminmenupage/src/tpl/plugin_info_meta_box-inside.php
vendored
Normal file
27
vendor/abuyoyo/adminmenupage/src/tpl/plugin_info_meta_box-inside.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?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>
|
||||
@ -3,25 +3,10 @@
|
||||
* 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">
|
||||
<h2><span>Plugin Info</span></h2>
|
||||
<h2 style="border-bottom: 1px solid #eee;"><span>Plugin Info</span></h2>
|
||||
<div class="inside">
|
||||
<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>
|
||||
<?php include __DIR__ . '/plugin_info_meta_box-inside.php'; ?>
|
||||
</div><!-- .inside -->
|
||||
|
||||
</div><!-- .postbox -->
|
||||
41
vendor/abuyoyo/adminmenupage/src/tpl/sidebar-add-meta-boxes.php
vendored
Normal file
41
vendor/abuyoyo/adminmenupage/src/tpl/sidebar-add-meta-boxes.php
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
<?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 );
|
||||
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Print tabs navigation row.
|
||||
*
|
||||
* @var CMB2_Options_Hook $hookup
|
||||
* @var CMB2_Options_Hookup $hookup
|
||||
*/
|
||||
if ( ! isset( $hookup ) ){
|
||||
return;
|
||||
5
vendor/abuyoyo/adminmenupage/src/tpl/tab-nav-simple.php
vendored
Normal file
5
vendor/abuyoyo/adminmenupage/src/tpl/tab-nav-simple.php
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
do_action ( 'wphelper/adminpage/tab_nav' );
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Template for CMB2 page title
|
||||
*
|
||||
* @var WPHelper\CMB2_Options_Page $this
|
||||
* @var WPHelper\CMB2_OptionsPage $this
|
||||
*/
|
||||
if ( $this->cmb->prop( 'title' ) ) {
|
||||
echo '<h2>' . wp_kses_post( $this->cmb->prop( 'title' ) ) . '</h2>';
|
||||
@ -2,8 +2,8 @@
|
||||
/**
|
||||
* Template for CMB2 Options Page
|
||||
*
|
||||
* @var WPHelper\CMB2_Options_Page $this
|
||||
* @var CMB2_Options_Hook $hookup
|
||||
* @var WPHelper\CMB2_OptionsPage $this
|
||||
* @var CMB2_Options_Hookup $hookup
|
||||
*/
|
||||
?>
|
||||
<style>
|
||||
@ -17,8 +17,8 @@
|
||||
</style>
|
||||
<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 'title-cmb2.php' ?>
|
||||
<?php include 'tab-nav-cmb2.php' ?>
|
||||
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
@ -26,7 +26,7 @@
|
||||
<!-- main content -->
|
||||
<div id="post-body-content">
|
||||
<div class="meta-box-sortables ui-sortable tabs-content">
|
||||
<?php include 'cmb-form.php' ?>
|
||||
<?php include 'form-cmb2.php' ?>
|
||||
</div><!-- .meta-box-sortables -->
|
||||
</div><!-- #post-body-content -->
|
||||
|
||||
13
vendor/abuyoyo/adminmenupage/src/tpl/wrap-cmb2-simple.php
vendored
Normal file
13
vendor/abuyoyo/adminmenupage/src/tpl/wrap-cmb2-simple.php
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<?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>
|
||||
@ -1,3 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress admin 'wrap' div
|
||||
*
|
||||
* @var WPHelper\AdminPage $this
|
||||
*/
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?= get_admin_page_title() ?></h1>
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
* Template for CMB2 Options Page
|
||||
*
|
||||
* @var string $ob_content - Render template or callback
|
||||
* @var AdminPage $this
|
||||
* @var WPHelper\AdminPage $this
|
||||
*/
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?= get_admin_page_title() ?></h1>
|
||||
<?php include 'tab-nav.php' ?>
|
||||
<?php include 'tab-nav-simple.php' ?>
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
|
||||
@ -21,9 +21,7 @@
|
||||
|
||||
<!-- sidebar -->
|
||||
<div id="postbox-container-1" class="postbox-container">
|
||||
<div class="meta-box-sortables">
|
||||
<?php do_action("wphelper/adminpage/plugin_info_box/{$this->get_slug()}"); ?>
|
||||
</div><!-- .meta-box-sortables -->
|
||||
<?php include 'sidebar-add-meta-boxes.php'; ?>
|
||||
</div><!-- #postbox-container-1 .postbox-container -->
|
||||
</div><!-- #post-body -->
|
||||
<div class="clear"></div>
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Simple wrap
|
||||
*
|
||||
* @var string $ob_content - Render template or callback
|
||||
*/
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?= get_admin_page_title() ?></h1>
|
||||
<?php include 'tab-nav.php' ?>
|
||||
<?php include 'tab-nav-simple.php' ?>
|
||||
<?php echo $ob_content; ?>
|
||||
</div>
|
||||
18
vendor/abuyoyo/plugincore/CHANGELOG.md
vendored
18
vendor/abuyoyo/plugincore/CHANGELOG.md
vendored
@ -1,5 +1,23 @@
|
||||
# WPHelper\PluginCore Changelog
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
138
vendor/abuyoyo/plugincore/PluginCore.php
vendored
138
vendor/abuyoyo/plugincore/PluginCore.php
vendored
@ -1,24 +1,25 @@
|
||||
<?php
|
||||
namespace WPHelper;
|
||||
|
||||
use Puc_v4_Factory;
|
||||
use Puc_v4_Factory as PucFactory;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'No soup for you!' );
|
||||
|
||||
if ( ! class_exists( 'WPHelper/PluginCore' ) ):
|
||||
|
||||
// require dependency get_plugin_data()
|
||||
if( ! function_exists('get_plugin_data') ) {
|
||||
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WPHelper/PluginCore' ) ):
|
||||
/**
|
||||
* PluginCore
|
||||
*
|
||||
* Helper Class for creating WordPress Plugins
|
||||
*
|
||||
* Defines PLUGIN_PATH, PLUGIN_URL (etc.) constants
|
||||
* (@see README.md)
|
||||
*
|
||||
* @version 0.23
|
||||
* @version 0.26
|
||||
*/
|
||||
class PluginCore {
|
||||
|
||||
@ -42,6 +43,11 @@ class PluginCore {
|
||||
*/
|
||||
private $const;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $token;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -57,6 +63,11 @@ class PluginCore {
|
||||
*/
|
||||
private $plugin_basename;
|
||||
|
||||
/**
|
||||
* @var array plugin header metadata
|
||||
*/
|
||||
private $plugin_data;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
@ -107,19 +118,20 @@ class PluginCore {
|
||||
*/
|
||||
private $update_branch;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Static array of all PluginCore instances
|
||||
* Used in PluginCore::get($slug)
|
||||
*
|
||||
* @var array[PluginCore] Instances of PluginCore
|
||||
*/
|
||||
static $cores = [];
|
||||
private static $cores = [];
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve instance of PluginCore by plugin slug.
|
||||
*
|
||||
* @since 0.5
|
||||
*
|
||||
* @param string $slug - Plugin slug
|
||||
* @return PluginCore - Instance of specific plugin.
|
||||
*/
|
||||
@ -127,6 +139,29 @@ class PluginCore {
|
||||
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 ) {
|
||||
|
||||
$this->plugin_file( $plugin_file );
|
||||
@ -141,6 +176,8 @@ class PluginCore {
|
||||
|
||||
$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 ) )
|
||||
$this->activate_cb( $options->activate_cb );
|
||||
|
||||
@ -177,6 +214,9 @@ class PluginCore {
|
||||
* Register activation, deactivation, uninstall, upgrade hooks.
|
||||
* 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)
|
||||
*/
|
||||
private function bootstrap() {
|
||||
@ -216,6 +256,11 @@ class PluginCore {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register activation/deactivation/uninstall/upgrade hooks
|
||||
*
|
||||
* @since 0.5
|
||||
*/
|
||||
private function register_hooks() {
|
||||
|
||||
if ( ! empty( $this->activate_cb ) ) // && is_callable() ?
|
||||
@ -236,6 +281,8 @@ class PluginCore {
|
||||
* Plugin title.
|
||||
* If none provided - plugin header Title will be used.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param string|null $title
|
||||
* @return string $this->title
|
||||
*/
|
||||
@ -246,6 +293,8 @@ class PluginCore {
|
||||
/**
|
||||
* Wrapper function for $this->title()
|
||||
*
|
||||
* @since 0.6
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function name( $title = null ) {
|
||||
@ -258,6 +307,8 @@ class PluginCore {
|
||||
* Plugin slug.
|
||||
* If none provided - plugin file basename will be used
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param string|null $slug
|
||||
* @return string $this->slug
|
||||
*/
|
||||
@ -269,6 +320,8 @@ class PluginCore {
|
||||
* Setter - plugin_file (also Getter - kinda)
|
||||
* Plugin file fully qualified path.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param string $plugin_file - Path to plugin file
|
||||
* @return string $this->plugin_file
|
||||
*/
|
||||
@ -281,6 +334,8 @@ class PluginCore {
|
||||
* Might have to rethink this
|
||||
* used by test-plugin update_checker
|
||||
*
|
||||
* @since 0.7
|
||||
*
|
||||
* @todo revisit this
|
||||
*/
|
||||
public function file() {
|
||||
@ -290,9 +345,11 @@ class PluginCore {
|
||||
|
||||
/**
|
||||
* Getter/Setter - plugin data array
|
||||
*
|
||||
* @since 0.14
|
||||
*/
|
||||
public function plugin_data() {
|
||||
return $this->plugin_data ??= get_plugin_data( $this->plugin_file, false);
|
||||
return $this->plugin_data ??= get_plugin_data( $this->plugin_file, false ); // false = no markup (i think)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -300,6 +357,8 @@ class PluginCore {
|
||||
* Prefix of plugin specific defines (PLUGIN_NAME_PATH etc.)
|
||||
* If not provided - plugin slug will be uppercase.
|
||||
*
|
||||
* @since 0.4
|
||||
*
|
||||
* @param string|null $const (string should be uppercase)
|
||||
* @return string $this->const
|
||||
*/
|
||||
@ -307,8 +366,23 @@ class PluginCore {
|
||||
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
|
||||
*
|
||||
* @since 0.6
|
||||
*/
|
||||
public function path() {
|
||||
return $this->path ??= plugin_dir_path( $this->plugin_file );
|
||||
@ -316,6 +390,8 @@ class PluginCore {
|
||||
|
||||
/**
|
||||
* Getter/Setter
|
||||
*
|
||||
* @since 0.6
|
||||
*/
|
||||
public function url() {
|
||||
return $this->url ??= plugin_dir_url( $this->plugin_file );
|
||||
@ -323,6 +399,8 @@ class PluginCore {
|
||||
|
||||
/**
|
||||
* Getter/Setter
|
||||
*
|
||||
* @since 0.12
|
||||
*/
|
||||
public function plugin_basename() {
|
||||
return $this->plugin_basename ??= plugin_basename( $this->plugin_file );
|
||||
@ -333,6 +411,8 @@ class PluginCore {
|
||||
* Callback runs on 'register_activation_hook'
|
||||
* PluginCore does not validate. Authors must ensure valid callback.
|
||||
*
|
||||
* @since 0.4
|
||||
*
|
||||
* @param callable $activate_cb - Activation callback
|
||||
*
|
||||
* @access private
|
||||
@ -346,6 +426,8 @@ class PluginCore {
|
||||
* Callback runs on 'register_deactivation_hook'
|
||||
* PluginCore does not validate. Authors must ensure valid callback.
|
||||
*
|
||||
* @since 0.4
|
||||
*
|
||||
* @param callable $deactivate_cb - Deactivation callback.
|
||||
*
|
||||
* @access private
|
||||
@ -359,6 +441,8 @@ class PluginCore {
|
||||
* Callback runs on 'register_uninstall_hook'
|
||||
* PluginCore does not validate. Authors must ensure valid callback.
|
||||
*
|
||||
* @since 0.4
|
||||
*
|
||||
* @param callable $uninstall_cb - Uninstall callback.
|
||||
*
|
||||
* @access private
|
||||
@ -375,6 +459,8 @@ class PluginCore {
|
||||
*
|
||||
* PluginCore does not validate. Authors must ensure valid callback.
|
||||
*
|
||||
* @since 0.11
|
||||
*
|
||||
* @param callable $upgrade_cb - Upgrade callback.
|
||||
*
|
||||
* @access private
|
||||
@ -409,24 +495,25 @@ class PluginCore {
|
||||
*
|
||||
* Construct AdminPage instance for plugin.
|
||||
*
|
||||
* @param array $admin_page - AdminPage settings array
|
||||
* @since 0.14
|
||||
* @since 0.17 - Pass instance of PluginCore to AdminPage (~0.14)
|
||||
*
|
||||
* @param array $admin_page - AdminPage settings array
|
||||
* @return AdminPage
|
||||
*/
|
||||
public function admin_page( $admin_page ) {
|
||||
|
||||
if ( ! class_exists( 'WPHelper\AdminPage' ) )
|
||||
if ( ! class_exists( AdminPage::class ) )
|
||||
return;
|
||||
|
||||
// validate
|
||||
$admin_page['slug'] ??= $this->slug();
|
||||
$admin_page['title'] ??= $this->title();
|
||||
if ( ! isset( $this->admin_page ) ){
|
||||
|
||||
$this->admin_page = new AdminPage( $admin_page );
|
||||
// validate
|
||||
$admin_page['slug'] ??= $this->slug();
|
||||
$admin_page['title'] ??= $this->title();
|
||||
$admin_page['plugin_core'] ??= $this;
|
||||
|
||||
// validate for older versions of AdminPage
|
||||
if ( method_exists( $this->admin_page, 'plugin_core' ) ) {
|
||||
$this->admin_page->plugin_core( $this ); // back-reference
|
||||
$this->admin_page = new AdminPage( $admin_page );
|
||||
}
|
||||
|
||||
return $this->admin_page;
|
||||
@ -435,13 +522,15 @@ class PluginCore {
|
||||
/**
|
||||
* Setter
|
||||
*
|
||||
* Setup info used by Puc_v4_Factory
|
||||
* Setup info used by PucFactory
|
||||
*
|
||||
* set $update_checker (bool)
|
||||
* set $update_repo_uri (string)
|
||||
* set $update_auth (optional)
|
||||
* set $update_branch (optional)
|
||||
*
|
||||
* @since 0.9
|
||||
*
|
||||
* @param bool|string|array $update_checker
|
||||
*/
|
||||
private function update_checker( $update_checker ) {
|
||||
@ -490,14 +579,17 @@ class PluginCore {
|
||||
/**
|
||||
* Init Puc update checker instance
|
||||
*
|
||||
* @uses Puc_v4_Factory::buildUpdateChecker
|
||||
* @since 0.9 init_update_checker()
|
||||
* @since 0.21 build_update_checker()
|
||||
*
|
||||
* @uses PucFactory::buildUpdateChecker
|
||||
*/
|
||||
private function build_update_checker() {
|
||||
|
||||
if ( ! class_exists('Puc_v4_Factory') )
|
||||
if ( ! class_exists( PucFactory::class ) )
|
||||
return;
|
||||
|
||||
$update_checker = Puc_v4_Factory::buildUpdateChecker(
|
||||
$update_checker = PucFactory::buildUpdateChecker(
|
||||
$this->update_repo_uri,
|
||||
$this->plugin_file,
|
||||
$this->slug() // using slug()
|
||||
@ -520,6 +612,8 @@ class PluginCore {
|
||||
* This function called on upgrader_process_complete
|
||||
* sanity-checks if our plugin was upgraded
|
||||
* if so - calls upgrade_cb provided by our plugin
|
||||
*
|
||||
* @since 0.12
|
||||
*/
|
||||
public function upgrade_cb_wrapper( $upgrader_object, $options ) {
|
||||
if(
|
||||
|
||||
6
vendor/abuyoyo/plugincore/composer.json
vendored
6
vendor/abuyoyo/plugincore/composer.json
vendored
@ -2,12 +2,12 @@
|
||||
"name": "abuyoyo/plugincore",
|
||||
"description": "WordPress plugin core helper class",
|
||||
"type": "library",
|
||||
"version": "0.23",
|
||||
"time": "2022-08-06",
|
||||
"version": "0.26",
|
||||
"time": "2022-06-09",
|
||||
"license": "BSD-3-Clause",
|
||||
"suggest": {
|
||||
"yahnis-elsts/plugin-update-checker": "~4.12",
|
||||
"abuyoyo/adminmenupage": "~0.20"
|
||||
"abuyoyo/adminmenupage": "~0.25"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
34
vendor/composer/installed.json
vendored
34
vendor/composer/installed.json
vendored
@ -2,26 +2,26 @@
|
||||
"packages": [
|
||||
{
|
||||
"name": "abuyoyo/adminmenupage",
|
||||
"version": "0.21",
|
||||
"version_normalized": "0.21.0.0",
|
||||
"version": "0.25",
|
||||
"version_normalized": "0.25.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/abuyoyo/AdminMenuPage.git",
|
||||
"reference": "d05a9e9977d7e7c4ba3c913993493fefba4359d6"
|
||||
"reference": "487d262aec77a9a3ce04fa762e9048f30d22f123"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/d05a9e9977d7e7c4ba3c913993493fefba4359d6",
|
||||
"reference": "d05a9e9977d7e7c4ba3c913993493fefba4359d6",
|
||||
"url": "https://api.github.com/repos/abuyoyo/AdminMenuPage/zipball/487d262aec77a9a3ce04fa762e9048f30d22f123",
|
||||
"reference": "487d262aec77a9a3ce04fa762e9048f30d22f123",
|
||||
"shasum": ""
|
||||
},
|
||||
"suggest": {
|
||||
"abuyoyo/plugincore": "~0.18",
|
||||
"abuyoyo/plugincore": "~0.26",
|
||||
"cmb2/cmb2": "~2.9"
|
||||
},
|
||||
"time": "2022-08-06T13:42:37+00:00",
|
||||
"time": "2023-06-09T00:00:00+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"installation-source": "source",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"wph_admin_page.php"
|
||||
@ -37,30 +37,30 @@
|
||||
"description": "WordPress admin menu page helper class",
|
||||
"support": {
|
||||
"issues": "https://github.com/abuyoyo/AdminMenuPage/issues",
|
||||
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.21"
|
||||
"source": "https://github.com/abuyoyo/AdminMenuPage/tree/0.25"
|
||||
},
|
||||
"install-path": "../abuyoyo/adminmenupage"
|
||||
},
|
||||
{
|
||||
"name": "abuyoyo/plugincore",
|
||||
"version": "0.23",
|
||||
"version_normalized": "0.23.0.0",
|
||||
"version": "0.26",
|
||||
"version_normalized": "0.26.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/abuyoyo/PluginCore.git",
|
||||
"reference": "0a5809d6722a2abf0bdaf23f73bd3875b00fd2a4"
|
||||
"reference": "77f7d5451bdff4bda6c9766847b215bdeaca96d6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/0a5809d6722a2abf0bdaf23f73bd3875b00fd2a4",
|
||||
"reference": "0a5809d6722a2abf0bdaf23f73bd3875b00fd2a4",
|
||||
"url": "https://api.github.com/repos/abuyoyo/PluginCore/zipball/77f7d5451bdff4bda6c9766847b215bdeaca96d6",
|
||||
"reference": "77f7d5451bdff4bda6c9766847b215bdeaca96d6",
|
||||
"shasum": ""
|
||||
},
|
||||
"suggest": {
|
||||
"abuyoyo/adminmenupage": "~0.20",
|
||||
"abuyoyo/adminmenupage": "~0.25",
|
||||
"yahnis-elsts/plugin-update-checker": "~4.12"
|
||||
},
|
||||
"time": "2022-08-06T00:00:00+00:00",
|
||||
"time": "2022-06-09T00:00:00+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -75,7 +75,7 @@
|
||||
"description": "WordPress plugin core helper class",
|
||||
"support": {
|
||||
"issues": "https://github.com/abuyoyo/PluginCore/issues",
|
||||
"source": "https://github.com/abuyoyo/PluginCore/tree/0.23"
|
||||
"source": "https://github.com/abuyoyo/PluginCore/tree/0.26"
|
||||
},
|
||||
"install-path": "../abuyoyo/plugincore"
|
||||
},
|
||||
|
||||
12
vendor/composer/installed.php
vendored
12
vendor/composer/installed.php
vendored
@ -11,12 +11,12 @@
|
||||
),
|
||||
'versions' => array(
|
||||
'abuyoyo/adminmenupage' => array(
|
||||
'pretty_version' => '0.21',
|
||||
'version' => '0.21.0.0',
|
||||
'pretty_version' => '0.25',
|
||||
'version' => '0.25.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../abuyoyo/adminmenupage',
|
||||
'aliases' => array(),
|
||||
'reference' => 'd05a9e9977d7e7c4ba3c913993493fefba4359d6',
|
||||
'reference' => '487d262aec77a9a3ce04fa762e9048f30d22f123',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'abuyoyo/notice-manager' => array(
|
||||
@ -29,12 +29,12 @@
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'abuyoyo/plugincore' => array(
|
||||
'pretty_version' => '0.23',
|
||||
'version' => '0.23.0.0',
|
||||
'pretty_version' => '0.26',
|
||||
'version' => '0.26.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../abuyoyo/plugincore',
|
||||
'aliases' => array(),
|
||||
'reference' => '0a5809d6722a2abf0bdaf23f73bd3875b00fd2a4',
|
||||
'reference' => '77f7d5451bdff4bda6c9766847b215bdeaca96d6',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'abuyoyo/screen-meta-links' => array(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user