Autofix 2845 errors with PHPCBF
This commit is contained in:
parent
ebbecdbf78
commit
2b6d7bf29b
6 changed files with 2304 additions and 2259 deletions
|
@ -1,212 +1,212 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Includes the Plugin settings menu.
|
* Includes the Plugin settings menu.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0 12.09.14 10:26
|
* @since 1.5.0 12.09.14 10:26
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the Settings interface of the Plugin.
|
* Handles the Settings interface of the Plugin.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class MCI_Footnotes_Layout_Init {
|
class MCI_Footnotes_Layout_Init {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slug for the Plugin main menu.
|
* Slug for the Plugin main menu.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const C_STR_MAIN_MENU_SLUG = "mfmmf";
|
const C_STR_MAIN_MENU_SLUG = 'mfmmf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin main menu name.
|
* Plugin main menu name.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const C_STR_MAIN_MENU_TITLE = "ManFisher";
|
const C_STR_MAIN_MENU_TITLE = 'ManFisher';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $a_arr_SubPageClasses = array();
|
private $a_arr_SubPageClasses = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor. Initializes all WordPress hooks for the Plugin Settings.
|
* Class Constructor. Initializes all WordPress hooks for the Plugin Settings.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
// iterate through each class define in the current script
|
// iterate through each class define in the current script
|
||||||
foreach(get_declared_classes() as $l_str_ClassName) {
|
foreach ( get_declared_classes() as $l_str_ClassName ) {
|
||||||
// accept only child classes of the layout engine
|
// accept only child classes of the layout engine
|
||||||
if(is_subclass_of($l_str_ClassName, 'MCI_Footnotes_LayoutEngine')) {
|
if ( is_subclass_of( $l_str_ClassName, 'MCI_Footnotes_LayoutEngine' ) ) {
|
||||||
/** @var MCI_Footnotes_LayoutEngine $l_obj_Class */
|
/** @var MCI_Footnotes_LayoutEngine $l_obj_Class */
|
||||||
$l_obj_Class = new $l_str_ClassName();
|
$l_obj_Class = new $l_str_ClassName();
|
||||||
// append new instance of the layout engine sub class
|
// append new instance of the layout engine sub class
|
||||||
$this->a_arr_SubPageClasses[$l_obj_Class->getPriority()] = $l_obj_Class;
|
$this->a_arr_SubPageClasses[ $l_obj_Class->getPriority() ] = $l_obj_Class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ksort($this->a_arr_SubPageClasses);
|
ksort( $this->a_arr_SubPageClasses );
|
||||||
|
|
||||||
// register hooks/actions
|
// register hooks/actions
|
||||||
add_action('admin_init', array($this, 'initializeSettings'));
|
add_action( 'admin_init', array( $this, 'initializeSettings' ) );
|
||||||
add_action('admin_menu', array($this, 'registerMainMenu'));
|
add_action( 'admin_menu', array( $this, 'registerMainMenu' ) );
|
||||||
// register AJAX callbacks for Plugin information
|
// register AJAX callbacks for Plugin information
|
||||||
add_action("wp_ajax_nopriv_footnotes_getPluginInfo", array($this, "getPluginMetaInformation"));
|
add_action( 'wp_ajax_nopriv_footnotes_getPluginInfo', array( $this, 'getPluginMetaInformation' ) );
|
||||||
add_action("wp_ajax_footnotes_getPluginInfo", array($this, "getPluginMetaInformation"));
|
add_action( 'wp_ajax_footnotes_getPluginInfo', array( $this, 'getPluginMetaInformation' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes all sub pages and registers the settings.
|
* Initializes all sub pages and registers the settings.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function initializeSettings() {
|
public function initializeSettings() {
|
||||||
MCI_Footnotes_Settings::instance()->RegisterSettings();
|
MCI_Footnotes_Settings::instance()->RegisterSettings();
|
||||||
// iterate though each sub class of the layout engine and register their sections
|
// iterate though each sub class of the layout engine and register their sections
|
||||||
/** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
|
/** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
|
||||||
foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) {
|
foreach ( $this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass ) {
|
||||||
$l_obj_LayoutEngineSubClass->registerSections();
|
$l_obj_LayoutEngineSubClass->registerSections();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the new main menu for the WordPress dashboard.
|
* Registers the new main menu for the WordPress dashboard.
|
||||||
* Registers all sub menu pages for the new main menu.
|
* Registers all sub menu pages for the new main menu.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @see http://codex.wordpress.org/Function_Reference/add_menu_page
|
* @see http://codex.wordpress.org/Function_Reference/add_menu_page
|
||||||
*/
|
*/
|
||||||
public function registerMainMenu() {
|
public function registerMainMenu() {
|
||||||
global $menu;
|
global $menu;
|
||||||
// iterate through each main menu
|
// iterate through each main menu
|
||||||
foreach($menu as $l_arr_MainMenu) {
|
foreach ( $menu as $l_arr_MainMenu ) {
|
||||||
// iterate through each main menu attribute
|
// iterate through each main menu attribute
|
||||||
foreach($l_arr_MainMenu as $l_str_Attribute) {
|
foreach ( $l_arr_MainMenu as $l_str_Attribute ) {
|
||||||
// main menu already added, append sub pages and stop
|
// main menu already added, append sub pages and stop
|
||||||
if ($l_str_Attribute == self::C_STR_MAIN_MENU_SLUG) {
|
if ( $l_str_Attribute == self::C_STR_MAIN_MENU_SLUG ) {
|
||||||
$this->registerSubPages();
|
$this->registerSubPages();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a new main menu page to the WordPress dashboard
|
// add a new main menu page to the WordPress dashboard
|
||||||
add_menu_page(
|
add_menu_page(
|
||||||
self::C_STR_MAIN_MENU_TITLE, // page title
|
self::C_STR_MAIN_MENU_TITLE, // page title
|
||||||
self::C_STR_MAIN_MENU_TITLE, // menu title
|
self::C_STR_MAIN_MENU_TITLE, // menu title
|
||||||
'manage_options', // capability
|
'manage_options', // capability
|
||||||
self::C_STR_MAIN_MENU_SLUG, // menu slug
|
self::C_STR_MAIN_MENU_SLUG, // menu slug
|
||||||
array($this, "displayOtherPlugins"), // function
|
array( $this, 'displayOtherPlugins' ), // function
|
||||||
plugins_url('footnotes/img/main-menu.png'), // icon url
|
plugins_url( 'footnotes/img/main-menu.png' ), // icon url
|
||||||
null // position
|
null // position
|
||||||
);
|
);
|
||||||
$this->registerSubPages();
|
$this->registerSubPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers all SubPages for this Plugin.
|
* Registers all SubPages for this Plugin.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
private function registerSubPages() {
|
private function registerSubPages() {
|
||||||
// first registered sub menu page MUST NOT contain a unique slug suffix
|
// first registered sub menu page MUST NOT contain a unique slug suffix
|
||||||
// iterate though each sub class of the layout engine and register their sub page
|
// iterate though each sub class of the layout engine and register their sub page
|
||||||
/** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
|
/** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
|
||||||
foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) {
|
foreach ( $this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass ) {
|
||||||
$l_obj_LayoutEngineSubClass->registerSubPage();
|
$l_obj_LayoutEngineSubClass->registerSubPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays other Plugins from the developers.
|
* Displays other Plugins from the developers.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function displayOtherPlugins() {
|
public function displayOtherPlugins() {
|
||||||
printf("<br/><br/>");
|
printf( '<br/><br/>' );
|
||||||
// load template file
|
// load template file
|
||||||
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "manfisher");
|
$l_obj_Template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'manfisher' );
|
||||||
echo $l_obj_Template->getContent();
|
echo $l_obj_Template->getContent();
|
||||||
|
|
||||||
printf('<em>visit <a href="https://cheret.de/plugins/footnotes-2/" target="_blank">Mark Cheret</a></em>');
|
printf( '<em>visit <a href="https://cheret.de/plugins/footnotes-2/" target="_blank">Mark Cheret</a></em>' );
|
||||||
printf("<br/><br/>");
|
printf( '<br/><br/>' );
|
||||||
|
|
||||||
printf('</div>');
|
printf( '</div>' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin.
|
* AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function getPluginMetaInformation() {
|
public function getPluginMetaInformation() {
|
||||||
// get plugin internal name from POST data
|
// get plugin internal name from POST data
|
||||||
$l_str_PluginName = array_key_exists("plugin", $_POST) ? $_POST["plugin"] : null;
|
$l_str_PluginName = array_key_exists( 'plugin', $_POST ) ? $_POST['plugin'] : null;
|
||||||
if (empty($l_str_PluginName)) {
|
if ( empty( $l_str_PluginName ) ) {
|
||||||
echo json_encode(array("error" => "Plugin name invalid."));
|
echo json_encode( array( 'error' => 'Plugin name invalid.' ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$l_str_Url = "https://api.wordpress.org/plugins/info/1.0/".$l_str_PluginName.".json";
|
$l_str_Url = 'https://api.wordpress.org/plugins/info/1.0/' . $l_str_PluginName . '.json';
|
||||||
// call URL and collect data
|
// call URL and collect data
|
||||||
$l_arr_Response = wp_remote_get($l_str_Url);
|
$l_arr_Response = wp_remote_get( $l_str_Url );
|
||||||
// check if response is valid
|
// check if response is valid
|
||||||
if (is_wp_error($l_arr_Response)) {
|
if ( is_wp_error( $l_arr_Response ) ) {
|
||||||
echo json_encode(array("error" => "Error receiving Plugin Information from WordPress."));
|
echo json_encode( array( 'error' => 'Error receiving Plugin Information from WordPress.' ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (!array_key_exists("body", $l_arr_Response)) {
|
if ( ! array_key_exists( 'body', $l_arr_Response ) ) {
|
||||||
echo json_encode(array("error" => "Error reading WordPress API response message."));
|
echo json_encode( array( 'error' => 'Error reading WordPress API response message.' ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// get the body of the response
|
// get the body of the response
|
||||||
$l_str_Response = $l_arr_Response["body"];
|
$l_str_Response = $l_arr_Response['body'];
|
||||||
// get plugin object
|
// get plugin object
|
||||||
$l_arr_Plugin = json_decode($l_str_Response, true);
|
$l_arr_Plugin = json_decode( $l_str_Response, true );
|
||||||
if (empty($l_arr_Plugin)) {
|
if ( empty( $l_arr_Plugin ) ) {
|
||||||
echo json_encode(array("error" => "Error reading Plugin meta information.<br/>URL: " . $l_str_Url . "<br/>Response: " . $l_str_Response));
|
echo json_encode( array( 'error' => 'Error reading Plugin meta information.<br/>URL: ' . $l_str_Url . '<br/>Response: ' . $l_str_Response ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$l_int_NumRatings = array_key_exists("num_ratings", $l_arr_Plugin) ? intval($l_arr_Plugin["num_ratings"]) : 0;
|
$l_int_NumRatings = array_key_exists( 'num_ratings', $l_arr_Plugin ) ? intval( $l_arr_Plugin['num_ratings'] ) : 0;
|
||||||
$l_int_Rating = array_key_exists("rating", $l_arr_Plugin) ? floatval($l_arr_Plugin["rating"]) : 0.0;
|
$l_int_Rating = array_key_exists( 'rating', $l_arr_Plugin ) ? floatval( $l_arr_Plugin['rating'] ) : 0.0;
|
||||||
$l_int_Stars = round(5 * $l_int_Rating / 100.0, 1);
|
$l_int_Stars = round( 5 * $l_int_Rating / 100.0, 1 );
|
||||||
|
|
||||||
// return Plugin information as JSON encoded string
|
// return Plugin information as JSON encoded string
|
||||||
echo json_encode(
|
echo json_encode(
|
||||||
array(
|
array(
|
||||||
"error" => "",
|
'error' => '',
|
||||||
"PluginDescription" => array_key_exists("short_description", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["short_description"]) : "Error reading Plugin information",
|
'PluginDescription' => array_key_exists( 'short_description', $l_arr_Plugin ) ? html_entity_decode( $l_arr_Plugin['short_description'] ) : 'Error reading Plugin information',
|
||||||
"PluginAuthor" => array_key_exists("author", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["author"]) : "unknown",
|
'PluginAuthor' => array_key_exists( 'author', $l_arr_Plugin ) ? html_entity_decode( $l_arr_Plugin['author'] ) : 'unknown',
|
||||||
"PluginRatingText" => $l_int_Stars . " " . __("rating based on", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . " " . $l_int_NumRatings . " " . __("ratings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'PluginRatingText' => $l_int_Stars . ' ' . __( 'rating based on', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ) . ' ' . $l_int_NumRatings . ' ' . __( 'ratings', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"PluginRating1" => $l_int_Stars >= 0.5 ? "star-full" : "star-empty",
|
'PluginRating1' => $l_int_Stars >= 0.5 ? 'star-full' : 'star-empty',
|
||||||
"PluginRating2" => $l_int_Stars >= 1.5 ? "star-full" : "star-empty",
|
'PluginRating2' => $l_int_Stars >= 1.5 ? 'star-full' : 'star-empty',
|
||||||
"PluginRating3" => $l_int_Stars >= 2.5 ? "star-full" : "star-empty",
|
'PluginRating3' => $l_int_Stars >= 2.5 ? 'star-full' : 'star-empty',
|
||||||
"PluginRating4" => $l_int_Stars >= 3.5 ? "star-full" : "star-empty",
|
'PluginRating4' => $l_int_Stars >= 3.5 ? 'star-full' : 'star-empty',
|
||||||
"PluginRating5" => $l_int_Stars >= 4.5 ? "star-full" : "star-empty",
|
'PluginRating5' => $l_int_Stars >= 4.5 ? 'star-full' : 'star-empty',
|
||||||
"PluginRating" => $l_int_NumRatings,
|
'PluginRating' => $l_int_NumRatings,
|
||||||
"PluginLastUpdated" => array_key_exists("last_updated", $l_arr_Plugin) ? $l_arr_Plugin["last_updated"] : "unknown",
|
'PluginLastUpdated' => array_key_exists( 'last_updated', $l_arr_Plugin ) ? $l_arr_Plugin['last_updated'] : 'unknown',
|
||||||
"PluginDownloads" => array_key_exists("downloaded", $l_arr_Plugin) ? $l_arr_Plugin["downloaded"] : "---"
|
'PluginDownloads' => array_key_exists( 'downloaded', $l_arr_Plugin ) ? $l_arr_Plugin['downloaded'] : '---',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,140 +1,140 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Includes the Plugin Class to display Diagnostics.
|
* Includes the Plugin Class to display Diagnostics.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0 14.09.14 14:47
|
* @since 1.5.0 14.09.14 14:47
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays Diagnostics of the web server, PHP and WordPress.
|
* Displays Diagnostics of the web server, PHP and WordPress.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Priority index. Lower numbers have a higher Priority.
|
* Returns a Priority index. Lower numbers have a higher Priority.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getPriority() {
|
public function getPriority() {
|
||||||
return 999;
|
return 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unique slug of the sub page.
|
* Returns the unique slug of the sub page.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getSubPageSlug() {
|
protected function getSubPageSlug() {
|
||||||
return "-diagnostics";
|
return '-diagnostics';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the title of the sub page.
|
* Returns the title of the sub page.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getSubPageTitle() {
|
protected function getSubPageTitle() {
|
||||||
return __("Diagnostics", MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
|
return __( 'Diagnostics', MCI_Footnotes_Config::C_STR_PLUGIN_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of all registered sections for the sub page.
|
* Returns an array of all registered sections for the sub page.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getSections() {
|
protected function getSections() {
|
||||||
return array(
|
return array(
|
||||||
$this->addSection("diagnostics", __("Diagnostics", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false)
|
$this->addSection( 'diagnostics', __( 'Diagnostics', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ), null, false ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of all registered meta boxes for each section of the sub page.
|
* Returns an array of all registered meta boxes for each section of the sub page.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getMetaBoxes() {
|
protected function getMetaBoxes() {
|
||||||
return array(
|
return array(
|
||||||
$this->addMetaBox("diagnostics", "diagnostics", __("Displays information about the web server, PHP and WordPress", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Diagnostics")
|
$this->addMetaBox( 'diagnostics', 'diagnostics', __( 'Displays information about the web server, PHP and WordPress', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ), 'Diagnostics' ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a diagnostics about the web server, php and WordPress.
|
* Displays a diagnostics about the web server, php and WordPress.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function Diagnostics() {
|
public function Diagnostics() {
|
||||||
global $wp_version;
|
global $wp_version;
|
||||||
$l_str_PhpExtensions = "";
|
$l_str_PhpExtensions = '';
|
||||||
// iterate through each PHP extension
|
// iterate through each PHP extension
|
||||||
foreach (get_loaded_extensions() as $l_int_Index => $l_str_Extension) {
|
foreach ( get_loaded_extensions() as $l_int_Index => $l_str_Extension ) {
|
||||||
if ($l_int_Index > 0) {
|
if ( $l_int_Index > 0 ) {
|
||||||
$l_str_PhpExtensions .= ' | ';
|
$l_str_PhpExtensions .= ' | ';
|
||||||
}
|
}
|
||||||
$l_str_PhpExtensions .= $l_str_Extension . ' ' . phpversion($l_str_Extension);
|
$l_str_PhpExtensions .= $l_str_Extension . ' ' . phpversion( $l_str_Extension );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var WP_Theme $l_obj_CurrentTheme */
|
/** @var WP_Theme $l_obj_CurrentTheme */
|
||||||
$l_obj_CurrentTheme = wp_get_theme();
|
$l_obj_CurrentTheme = wp_get_theme();
|
||||||
|
|
||||||
$l_str_WordPressPlugins = "";
|
$l_str_WordPressPlugins = '';
|
||||||
// iterate through each installed WordPress Plugin
|
// iterate through each installed WordPress Plugin
|
||||||
foreach (get_plugins() as $l_arr_Plugin) {
|
foreach ( get_plugins() as $l_arr_Plugin ) {
|
||||||
$l_str_WordPressPlugins .= '<tr>';
|
$l_str_WordPressPlugins .= '<tr>';
|
||||||
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin["Name"] . '</td>';
|
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin['Name'] . '</td>';
|
||||||
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin["Version"] . ' [' . $l_arr_Plugin["PluginURI"] . ']' . '</td>';
|
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin['Version'] . ' [' . $l_arr_Plugin['PluginURI'] . ']' . '</td>';
|
||||||
$l_str_WordPressPlugins .= '</tr>';
|
$l_str_WordPressPlugins .= '</tr>';
|
||||||
}
|
}
|
||||||
// load template file
|
// load template file
|
||||||
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "diagnostics");
|
$l_obj_Template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'diagnostics' );
|
||||||
// replace all placeholders
|
// replace all placeholders
|
||||||
$l_obj_Template->replace(
|
$l_obj_Template->replace(
|
||||||
array(
|
array(
|
||||||
"label-server" => __("Server name", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-server' => __( 'Server name', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"server" => $_SERVER["SERVER_NAME"],
|
'server' => $_SERVER['SERVER_NAME'],
|
||||||
|
|
||||||
"label-php" => __("PHP version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-php' => __( 'PHP version', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"php" => phpversion(),
|
'php' => phpversion(),
|
||||||
|
|
||||||
"label-user-agent" => __("User agent", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-user-agent' => __( 'User agent', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"user-agent" => $_SERVER["HTTP_USER_AGENT"],
|
'user-agent' => $_SERVER['HTTP_USER_AGENT'],
|
||||||
|
|
||||||
"label-max-execution-time" => __("Max execution time", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-max-execution-time' => __( 'Max execution time', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"max-execution-time" => ini_get('max_execution_time') . ' ' . __('seconds', MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'max-execution-time' => ini_get( 'max_execution_time' ) . ' ' . __( 'seconds', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
|
|
||||||
"label-memory-limit" => __("Memory limit", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-memory-limit' => __( 'Memory limit', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"memory-limit" => ini_get('memory_limit'),
|
'memory-limit' => ini_get( 'memory_limit' ),
|
||||||
|
|
||||||
"label-php-extensions" => __("PHP extensions", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-php-extensions' => __( 'PHP extensions', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"php-extensions" => $l_str_PhpExtensions,
|
'php-extensions' => $l_str_PhpExtensions,
|
||||||
|
|
||||||
"label-wordpress" => __("WordPress version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-wordpress' => __( 'WordPress version', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"wordpress" => $wp_version,
|
'wordpress' => $wp_version,
|
||||||
|
|
||||||
"label-theme" => __("Active Theme", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
'label-theme' => __( 'Active Theme', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ),
|
||||||
"theme" => $l_obj_CurrentTheme->get("Name") . " " . $l_obj_CurrentTheme->get("Version") . ", " . $l_obj_CurrentTheme->get("Author"). " [" . $l_obj_CurrentTheme->get("AuthorURI") . "]",
|
'theme' => $l_obj_CurrentTheme->get( 'Name' ) . ' ' . $l_obj_CurrentTheme->get( 'Version' ) . ', ' . $l_obj_CurrentTheme->get( 'Author' ) . ' [' . $l_obj_CurrentTheme->get( 'AuthorURI' ) . ']',
|
||||||
|
|
||||||
"plugins" => $l_str_WordPressPlugins
|
'plugins' => $l_str_WordPressPlugins,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// display template with replaced placeholders
|
// display template with replaced placeholders
|
||||||
echo $l_obj_Template->getContent();
|
echo $l_obj_Template->getContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,88 +1,94 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Widget base.
|
* Widget base.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @date 14.09.14 14:30
|
* @date 14.09.14 14:30
|
||||||
*
|
*
|
||||||
* @lastmodified 2021-02-18T0306+0100
|
* @lastmodified 2021-02-18T0306+0100
|
||||||
* @date 2021-02-18T0240+0100
|
* @date 2021-02-18T0240+0100
|
||||||
* @since 1.6.4 Update: replace deprecated function WP_Widget() with recommended __construct(), thanks to @dartiss code contribution.
|
* @since 1.6.4 Update: replace deprecated function WP_Widget() with recommended __construct(), thanks to @dartiss code contribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Class for all Plugin Widgets. Registers each Widget to WordPress.
|
* Base Class for all Plugin Widgets. Registers each Widget to WordPress.
|
||||||
* The following Methods MUST be overwritten in each sub class:
|
* The following Methods MUST be overwritten in each sub class:
|
||||||
* **public function widget($args, $instance)** -> echo the Widget Content
|
* **public function widget($args, $instance)** -> echo the Widget Content
|
||||||
* **public function form($instance)** -> echo the Settings of the Widget
|
* **public function form($instance)** -> echo the Settings of the Widget
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
abstract class MCI_Footnotes_WidgetBase extends WP_Widget {
|
abstract class MCI_Footnotes_WidgetBase extends WP_Widget {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unique ID as string used for the Widget Base ID.
|
* Returns an unique ID as string used for the Widget Base ID.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function getID();
|
abstract protected function getID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Public name of child Widget to be displayed in the Configuration page.
|
* Returns the Public name of child Widget to be displayed in the Configuration page.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function getName();
|
abstract protected function getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Description of the child widget.
|
* Returns the Description of the child widget.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function getDescription();
|
abstract protected function getDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the width of the Widget. Default width is 250 pixel.
|
* Returns the width of the Widget. Default width is 250 pixel.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
protected function getWidgetWidth() {
|
protected function getWidgetWidth() {
|
||||||
return 250;
|
return 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor. Registers the child Widget to WordPress.
|
* Class Constructor. Registers the child Widget to WordPress.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*
|
*
|
||||||
* - Update: replace deprecated function WP_Widget() with recommended __construct(), thanks to @dartiss code contribution.
|
* - Update: replace deprecated function WP_Widget() with recommended __construct(), thanks to @dartiss code contribution.
|
||||||
*
|
*
|
||||||
* @since 1.6.4
|
* @since 1.6.4
|
||||||
* @contributor @dartiss
|
* @contributor @dartiss
|
||||||
* @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class/widgets/base.php?rev=1445720
|
* @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class/widgets/base.php?rev=1445720
|
||||||
* “The called constructor method for WP_Widget in MCI_Footnotes_Widget_ReferenceContainer is deprecated since version 4.3.0! Use __construct() instead.”
|
* “The called constructor method for WP_Widget in MCI_Footnotes_Widget_ReferenceContainer is deprecated since version 4.3.0! Use __construct() instead.”
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$l_arr_WidgetOptions = array("classname" => __CLASS__, "description" => $this->getDescription());
|
$l_arr_WidgetOptions = array(
|
||||||
$l_arr_ControlOptions = array("id_base" => strtolower($this->getID()), "width" => $this->getWidgetWidth());
|
'classname' => __CLASS__,
|
||||||
// registers the Widget
|
'description' => $this->getDescription(),
|
||||||
parent::__construct(
|
);
|
||||||
strtolower($this->getID()), // unique ID for the widget, has to be lowercase
|
$l_arr_ControlOptions = array(
|
||||||
$this->getName(), // Plugin name to be displayed
|
'id_base' => strtolower( $this->getID() ),
|
||||||
$l_arr_WidgetOptions, // Optional Widget Options
|
'width' => $this->getWidgetWidth(),
|
||||||
$l_arr_ControlOptions // Optional Widget Control Options
|
);
|
||||||
);
|
// registers the Widget
|
||||||
}
|
parent::__construct(
|
||||||
}
|
strtolower( $this->getID() ), // unique ID for the widget, has to be lowercase
|
||||||
|
$this->getName(), // Plugin name to be displayed
|
||||||
|
$l_arr_WidgetOptions, // Optional Widget Options
|
||||||
|
$l_arr_ControlOptions // Optional Widget Control Options
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,85 +1,85 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Includes the Plugin Widget to put the Reference Container to the Widget area.
|
* Includes the Plugin Widget to put the Reference Container to the Widget area.
|
||||||
*
|
*
|
||||||
* @filesource
|
* @filesource
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0 14.09.14 14:26
|
* @since 1.5.0 14.09.14 14:26
|
||||||
*
|
*
|
||||||
* Edited 2.2.0 2020-12-12T2131+0100
|
* Edited 2.2.0 2020-12-12T2131+0100
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a Widget to put the Reference Container to the widget area.
|
* Registers a Widget to put the Reference Container to the widget area.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
|
class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unique ID as string used for the Widget Base ID.
|
* Returns an unique ID as string used for the Widget Base ID.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getID() {
|
protected function getID() {
|
||||||
return "footnotes_widget";
|
return 'footnotes_widget';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Public name of the Widget to be displayed in the Configuration page.
|
* Returns the Public name of the Widget to be displayed in the Configuration page.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getName() {
|
protected function getName() {
|
||||||
return MCI_Footnotes_Config::C_STR_PLUGIN_NAME;
|
return MCI_Footnotes_Config::C_STR_PLUGIN_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Description of the child widget.
|
* Returns the Description of the child widget.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* Edit: curly quotes 2.2.0 2020-12-12T2130+0100
|
* Edit: curly quotes 2.2.0 2020-12-12T2130+0100
|
||||||
*/
|
*/
|
||||||
protected function getDescription() {
|
protected function getDescription() {
|
||||||
return __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
|
return __( 'The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outputs the Settings of the Widget.
|
* Outputs the Settings of the Widget.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @param mixed $instance
|
* @param mixed $instance
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* Edit: curly quotes 2.2.0 2020-12-12T2130+0100
|
* Edit: curly quotes 2.2.0 2020-12-12T2130+0100
|
||||||
*/
|
*/
|
||||||
public function form($instance) {
|
public function form( $instance ) {
|
||||||
echo __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
|
echo __( 'The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Outputs the Content of the Widget.
|
* Outputs the Content of the Widget.
|
||||||
*
|
*
|
||||||
* @author Stefan Herndler
|
* @author Stefan Herndler
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @param mixed $args
|
* @param mixed $args
|
||||||
* @param mixed $instance
|
* @param mixed $instance
|
||||||
*/
|
*/
|
||||||
public function widget($args, $instance) {
|
public function widget( $args, $instance ) {
|
||||||
global $g_obj_MCI_Footnotes;
|
global $g_obj_MCI_Footnotes;
|
||||||
// reference container positioning is set to "widget area"
|
// reference container positioning is set to "widget area"
|
||||||
if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "widget") {
|
if ( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION ) == 'widget' ) {
|
||||||
echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer();
|
echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue