mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-08-31 03:53:15 +08:00
phpDoc-Documentation
This commit is contained in:
parent
544f8050c7
commit
5cf5063d46
2 changed files with 109 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
.idea
|
|
||||||
.idea/workspace.xml
|
.idea/workspace.xml
|
||||||
|
|
|
@ -1,31 +1,64 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* MainWP Child Plugin Pages
|
||||||
|
*
|
||||||
|
* This file handles all the pages & subpages for the
|
||||||
|
* MainWP Child Plugin.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace MainWP\Child;
|
namespace MainWP\Child;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MainWP_Pages
|
||||||
|
* @package MainWP\Child
|
||||||
|
*/
|
||||||
class MainWP_Pages {
|
class MainWP_Pages {
|
||||||
|
|
||||||
protected static $instance = null;
|
/**
|
||||||
|
* @static
|
||||||
|
* @var null Holds the Public static instance of MainWP_Child_Install.
|
||||||
|
*/
|
||||||
|
protected static $instance = null;
|
||||||
|
|
||||||
public static $subPages;
|
/**
|
||||||
public static $subPagesLoaded = false;
|
* @static
|
||||||
|
* @var array MainWP Child Plugin subppages.
|
||||||
|
*/
|
||||||
|
public static $subPages;
|
||||||
|
|
||||||
public static $brandingTitle = null;
|
/**
|
||||||
|
* Whether or not MainWP Child Plugin subpages should be loaded. Default: false.
|
||||||
|
*
|
||||||
|
* @var bool true|false.
|
||||||
|
*/
|
||||||
|
public static $subPagesLoaded = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method get_class_name()
|
* @var null Branding Title.
|
||||||
*
|
*/
|
||||||
* Get Class Name.
|
public static $brandingTitle = null;
|
||||||
*
|
|
||||||
* @return object
|
/**
|
||||||
*/
|
* Get Class Name.
|
||||||
|
*
|
||||||
|
* @return string Class name.
|
||||||
|
*/
|
||||||
public static function get_class_name() {
|
public static function get_class_name() {
|
||||||
return __CLASS__;
|
return __CLASS__;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct() {
|
/**
|
||||||
|
* MainWP_Pages constructor.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_instance() {
|
/**
|
||||||
|
* Create public static instance of MainWP_Pages.
|
||||||
|
*
|
||||||
|
* @return MainWP_Pages|null
|
||||||
|
*/
|
||||||
|
public static function get_instance() {
|
||||||
if ( null === self::$instance ) {
|
if ( null === self::$instance ) {
|
||||||
self::$instance = new self();
|
self::$instance = new self();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +66,10 @@ class MainWP_Pages {
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init() {
|
/**
|
||||||
|
* Set up constants with default values, unless user overrides.
|
||||||
|
*/
|
||||||
|
public function init() {
|
||||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
||||||
add_action( 'admin_head', array( &$this, 'admin_head' ) );
|
add_action( 'admin_head', array( &$this, 'admin_head' ) );
|
||||||
add_action( 'admin_notices', array( &$this, 'admin_notice' ) );
|
add_action( 'admin_notices', array( &$this, 'admin_notice' ) );
|
||||||
|
@ -41,7 +77,14 @@ class MainWP_Pages {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function admin_notice() {
|
/**
|
||||||
|
* MainWP Child Plugin Admin Notice
|
||||||
|
*
|
||||||
|
* This notice is displayed immediately after installation or disconnection.
|
||||||
|
*
|
||||||
|
* @return string Admin message html.
|
||||||
|
*/
|
||||||
|
public function admin_notice() {
|
||||||
// Admin Notice...
|
// Admin Notice...
|
||||||
if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::is_admin() && is_admin() ) {
|
if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::is_admin() && is_admin() ) {
|
||||||
$branding_opts = MainWP_Child_Branding::instance()->get_branding_options();
|
$branding_opts = MainWP_Child_Branding::instance()->get_branding_options();
|
||||||
|
@ -67,7 +110,12 @@ class MainWP_Pages {
|
||||||
MainWP_Child_Server_Information_Render::render_warnings();
|
MainWP_Child_Server_Information_Render::render_warnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function admin_menu() {
|
/**
|
||||||
|
* Admin menu settings.
|
||||||
|
*
|
||||||
|
* Add and remove Admin Menu Items dependant upon Branding settings.
|
||||||
|
*/
|
||||||
|
public function admin_menu() {
|
||||||
$branding_opts = MainWP_Child_Branding::instance()->get_branding_options();
|
$branding_opts = MainWP_Child_Branding::instance()->get_branding_options();
|
||||||
$is_hide = isset( $branding_opts['hide'] ) ? $branding_opts['hide'] : '';
|
$is_hide = isset( $branding_opts['hide'] ) ? $branding_opts['hide'] : '';
|
||||||
$cancelled_branding = $branding_opts['cancelled_branding'];
|
$cancelled_branding = $branding_opts['cancelled_branding'];
|
||||||
|
@ -119,7 +167,12 @@ class MainWP_Pages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function init_pages( $child_menu_title ) {
|
/**
|
||||||
|
* Initiate MainWP Child Plugin pages.
|
||||||
|
*
|
||||||
|
* @param $child_menu_title New MainWP Child Plugin title defined in branding settings.
|
||||||
|
*/
|
||||||
|
private function init_pages($child_menu_title ) {
|
||||||
|
|
||||||
$settingsPage = add_submenu_page( 'options-general.php', $child_menu_title, $child_menu_title, 'manage_options', 'mainwp_child_tab', array( &$this, 'render_pages' ) );
|
$settingsPage = add_submenu_page( 'options-general.php', $child_menu_title, $child_menu_title, 'manage_options', 'mainwp_child_tab', array( &$this, 'render_pages' ) );
|
||||||
|
|
||||||
|
@ -178,7 +231,14 @@ class MainWP_Pages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function plugin_row_meta( $plugin_meta, $plugin_file ) {
|
/**
|
||||||
|
* MainWP Child Plugin meta data.
|
||||||
|
*
|
||||||
|
* @param $plugin_meta Plugin meta.
|
||||||
|
* @param $plugin_file Plugin file.
|
||||||
|
* @return mixed The filtered value after all hooked functions are applied to it.
|
||||||
|
*/
|
||||||
|
public function plugin_row_meta($plugin_meta, $plugin_file ) {
|
||||||
global $mainWPChild;
|
global $mainWPChild;
|
||||||
if ( $mainWPChild->plugin_slug !== $plugin_file ) {
|
if ( $mainWPChild->plugin_slug !== $plugin_file ) {
|
||||||
return $plugin_meta;
|
return $plugin_meta;
|
||||||
|
@ -186,7 +246,13 @@ class MainWP_Pages {
|
||||||
return apply_filters( 'mainwp_child_plugin_row_meta', $plugin_meta, $plugin_file, $mainWPChild->plugin_slug );
|
return apply_filters( 'mainwp_child_plugin_row_meta', $plugin_meta, $plugin_file, $mainWPChild->plugin_slug );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_pages( $shownPage ) {
|
/**
|
||||||
|
* Render MainWP Child Plugin pages.
|
||||||
|
*
|
||||||
|
* @param $shownPage Page that has been shown.
|
||||||
|
* @return string Page html.
|
||||||
|
*/
|
||||||
|
public function render_pages($shownPage ) {
|
||||||
$shownPage = '';
|
$shownPage = '';
|
||||||
if ( isset( $_GET['tab'] ) ) {
|
if ( isset( $_GET['tab'] ) ) {
|
||||||
$shownPage = $_GET['tab'];
|
$shownPage = $_GET['tab'];
|
||||||
|
@ -258,7 +324,14 @@ class MainWP_Pages {
|
||||||
self::render_footer();
|
self::render_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function render_header( $shownPage, $subpage = true ) {
|
/**
|
||||||
|
* Render page header.
|
||||||
|
*
|
||||||
|
* @param $shownPage Page shown.
|
||||||
|
* @param bool $subpage Whether or not a subpage. Default: true.
|
||||||
|
* @return string Header html.
|
||||||
|
*/
|
||||||
|
public static function render_header($shownPage, $subpage = true ) {
|
||||||
if ( isset( $_GET['tab'] ) ) {
|
if ( isset( $_GET['tab'] ) ) {
|
||||||
$shownPage = $_GET['tab'];
|
$shownPage = $_GET['tab'];
|
||||||
}
|
}
|
||||||
|
@ -413,15 +486,22 @@ class MainWP_Pages {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function render_footer() {
|
/**
|
||||||
|
* Render page footer.
|
||||||
|
* @return string Footer html.
|
||||||
|
*/
|
||||||
|
public static function render_footer() {
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function admin_head() {
|
* Render Admin Header.
|
||||||
|
* @return string Admin header html.
|
||||||
|
*/
|
||||||
|
public function admin_head() {
|
||||||
if ( isset( $_GET['page'] ) && 'mainwp_child_tab' == $_GET['page'] ) {
|
if ( isset( $_GET['page'] ) && 'mainwp_child_tab' == $_GET['page'] ) {
|
||||||
?>
|
?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
@ -448,7 +528,12 @@ class MainWP_Pages {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function render_settings() {
|
|
||||||
|
/**
|
||||||
|
* Render Connection Settings Sub Page.
|
||||||
|
* @return Connection Settings subpage html.
|
||||||
|
*/
|
||||||
|
public function render_settings() {
|
||||||
if ( isset( $_POST['submit'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'child-settings' ) ) {
|
if ( isset( $_POST['submit'] ) && isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'child-settings' ) ) {
|
||||||
if ( isset( $_POST['requireUniqueSecurityId'] ) ) {
|
if ( isset( $_POST['requireUniqueSecurityId'] ) ) {
|
||||||
MainWP_Helper::update_option( 'mainwp_child_uniqueId', MainWP_Helper::rand_string( 8 ) );
|
MainWP_Helper::update_option( 'mainwp_child_uniqueId', MainWP_Helper::rand_string( 8 ) );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue