Autofix 2845 errors with PHPCBF
This commit is contained in:
parent
ebbecdbf78
commit
2b6d7bf29b
6 changed files with 2304 additions and 2259 deletions
|
@ -23,7 +23,7 @@ class MCI_Footnotes_Layout_Init {
|
||||||
* @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.
|
||||||
|
@ -32,7 +32,7 @@ class MCI_Footnotes_Layout_Init {
|
||||||
* @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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -50,23 +50,23 @@ class MCI_Footnotes_Layout_Init {
|
||||||
*/
|
*/
|
||||||
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' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ class MCI_Footnotes_Layout_Init {
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,11 @@ class MCI_Footnotes_Layout_Init {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -112,8 +112,8 @@ class MCI_Footnotes_Layout_Init {
|
||||||
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();
|
||||||
|
@ -129,7 +129,7 @@ class MCI_Footnotes_Layout_Init {
|
||||||
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,15 +141,15 @@ class MCI_Footnotes_Layout_Init {
|
||||||
* @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>' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,51 +160,51 @@ class MCI_Footnotes_Layout_Init {
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
|
@ -99,8 +99,13 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param bool $p_bool_hasSubmitButton Should a Submit Button be displayed for this section, default: true.
|
* @param bool $p_bool_hasSubmitButton Should a Submit Button be displayed for this section, default: true.
|
||||||
* @return array Array describing the section.
|
* @return array Array describing the section.
|
||||||
*/
|
*/
|
||||||
protected function addSection($p_str_ID, $p_str_Title, $p_int_SettingsContainerIndex, $p_bool_hasSubmitButton = true) {
|
protected function addSection( $p_str_ID, $p_str_Title, $p_int_SettingsContainerIndex, $p_bool_hasSubmitButton = true ) {
|
||||||
return array("id" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_ID, "title" => $p_str_Title, "submit" => $p_bool_hasSubmitButton, "container" => $p_int_SettingsContainerIndex);
|
return array(
|
||||||
|
'id' => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_ID,
|
||||||
|
'title' => $p_str_Title,
|
||||||
|
'submit' => $p_bool_hasSubmitButton,
|
||||||
|
'container' => $p_int_SettingsContainerIndex,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,12 +119,12 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param string $p_str_CallbackFunctionName Class method name for callback.
|
* @param string $p_str_CallbackFunctionName Class method name for callback.
|
||||||
* @return array meta box description to be able to append a meta box to the output.
|
* @return array meta box description to be able to append a meta box to the output.
|
||||||
*/
|
*/
|
||||||
protected function addMetaBox($p_str_SectionID, $p_str_ID, $p_str_Title, $p_str_CallbackFunctionName) {
|
protected function addMetaBox( $p_str_SectionID, $p_str_ID, $p_str_Title, $p_str_CallbackFunctionName ) {
|
||||||
return array(
|
return array(
|
||||||
"parent" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_SectionID,
|
'parent' => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_SectionID,
|
||||||
"id" => $p_str_ID,
|
'id' => $p_str_ID,
|
||||||
"title" => $p_str_Title,
|
'title' => $p_str_Title,
|
||||||
"callback" => $p_str_CallbackFunctionName
|
'callback' => $p_str_CallbackFunctionName,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,12 +137,12 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
public function registerSubPage() {
|
public function registerSubPage() {
|
||||||
global $submenu;
|
global $submenu;
|
||||||
// any sub menu for our main menu exists
|
// any sub menu for our main menu exists
|
||||||
if (array_key_exists(plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG), $submenu)) {
|
if ( array_key_exists( plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ), $submenu ) ) {
|
||||||
// iterate through all sub menu entries of the ManFisher main menu
|
// iterate through all sub menu entries of the ManFisher main menu
|
||||||
foreach($submenu[plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG)] as $l_arr_SubMenu) {
|
foreach ( $submenu[ plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ) ] as $l_arr_SubMenu ) {
|
||||||
if ($l_arr_SubMenu[2] == plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug())) {
|
if ( $l_arr_SubMenu[2] == plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug() ) ) {
|
||||||
// remove that sub menu and add it again to move it to the bottom
|
// remove that sub menu and add it again to move it to the bottom
|
||||||
remove_submenu_page(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG .$this->getSubPageSlug());
|
remove_submenu_page( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +153,7 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
$this->getSubPageTitle(), // menu title
|
$this->getSubPageTitle(), // menu title
|
||||||
'manage_options', // capability
|
'manage_options', // capability
|
||||||
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), // menu slug
|
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), // menu slug
|
||||||
array($this, 'displayContent') // function
|
array( $this, 'displayContent' ) // function
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,16 +165,16 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
*/
|
*/
|
||||||
public function registerSections() {
|
public function registerSections() {
|
||||||
// iterate through each section
|
// iterate through each section
|
||||||
foreach($this->getSections() as $l_arr_Section) {
|
foreach ( $this->getSections() as $l_arr_Section ) {
|
||||||
// append tab to the tab-array
|
// append tab to the tab-array
|
||||||
$this->a_arr_Sections[$l_arr_Section["id"]] = $l_arr_Section;
|
$this->a_arr_Sections[ $l_arr_Section['id'] ] = $l_arr_Section;
|
||||||
add_settings_section(
|
add_settings_section(
|
||||||
$l_arr_Section["id"], // unique id
|
$l_arr_Section['id'], // unique id
|
||||||
"", //$l_arr_Section["title"], // title
|
'', // $l_arr_Section["title"], // title
|
||||||
array($this, 'Description'), // callback function for the description
|
array( $this, 'Description' ), // callback function for the description
|
||||||
$l_arr_Section["id"] // parent sub page slug
|
$l_arr_Section['id'] // parent sub page slug
|
||||||
);
|
);
|
||||||
$this->registerMetaBoxes($l_arr_Section["id"]);
|
$this->registerMetaBoxes( $l_arr_Section['id'] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,16 +185,16 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @param string $p_str_ParentID Parent section unique id.
|
* @param string $p_str_ParentID Parent section unique id.
|
||||||
*/
|
*/
|
||||||
private function registerMetaBoxes($p_str_ParentID) {
|
private function registerMetaBoxes( $p_str_ParentID ) {
|
||||||
// iterate through each meta box
|
// iterate through each meta box
|
||||||
foreach($this->getMetaBoxes() as $l_arr_MetaBox) {
|
foreach ( $this->getMetaBoxes() as $l_arr_MetaBox ) {
|
||||||
if ($l_arr_MetaBox["parent"] != $p_str_ParentID) {
|
if ( $l_arr_MetaBox['parent'] != $p_str_ParentID ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
add_meta_box(
|
add_meta_box(
|
||||||
$p_str_ParentID. "-" . $l_arr_MetaBox["id"], // unique id
|
$p_str_ParentID . '-' . $l_arr_MetaBox['id'], // unique id
|
||||||
$l_arr_MetaBox["title"], // meta box title
|
$l_arr_MetaBox['title'], // meta box title
|
||||||
array($this, $l_arr_MetaBox["callback"]), // callback function to display (echo) the content
|
array( $this, $l_arr_MetaBox['callback'] ), // callback function to display (echo) the content
|
||||||
$p_str_ParentID, // post type = parent section id
|
$p_str_ParentID, // post type = parent section id
|
||||||
'main' // context
|
'main' // context
|
||||||
);
|
);
|
||||||
|
@ -204,12 +209,11 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
*/
|
*/
|
||||||
private function appendScripts() {
|
private function appendScripts() {
|
||||||
// enable meta boxes layout and close functionality
|
// enable meta boxes layout and close functionality
|
||||||
wp_enqueue_script('postbox');
|
wp_enqueue_script( 'postbox' );
|
||||||
// add WordPress color picker layout
|
// add WordPress color picker layout
|
||||||
wp_enqueue_style('wp-color-picker');
|
wp_enqueue_style( 'wp-color-picker' );
|
||||||
// add WordPress color picker function
|
// add WordPress color picker function
|
||||||
wp_enqueue_script('wp-color-picker');
|
wp_enqueue_script( 'wp-color-picker' );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers and enqueues the dashboard stylesheet.
|
* Registers and enqueues the dashboard stylesheet.
|
||||||
|
@ -239,7 +243,7 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_enqueue_style('mci-footnotes-admin');
|
wp_enqueue_style( 'mci-footnotes-admin' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,15 +256,15 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
// register and enqueue scripts and styling
|
// register and enqueue scripts and styling
|
||||||
$this->appendScripts();
|
$this->appendScripts();
|
||||||
// get current section
|
// get current section
|
||||||
reset($this->a_arr_Sections);
|
reset( $this->a_arr_Sections );
|
||||||
$l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections);
|
$l_str_ActiveSectionID = isset( $_GET['t'] ) ? $_GET['t'] : key( $this->a_arr_Sections );
|
||||||
$l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID];
|
$l_arr_ActiveSection = $this->a_arr_Sections[ $l_str_ActiveSectionID ];
|
||||||
// store settings
|
// store settings
|
||||||
$l_bool_SettingsUpdated = false;
|
$l_bool_SettingsUpdated = false;
|
||||||
if (array_key_exists("save-settings", $_POST)) {
|
if ( array_key_exists( 'save-settings', $_POST ) ) {
|
||||||
if ($_POST["save-settings"] == "save") {
|
if ( $_POST['save-settings'] == 'save' ) {
|
||||||
unset($_POST["save-settings"]);
|
unset( $_POST['save-settings'] );
|
||||||
unset($_POST["submit"]);
|
unset( $_POST['submit'] );
|
||||||
$l_bool_SettingsUpdated = $this->saveSettings();
|
$l_bool_SettingsUpdated = $this->saveSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,29 +273,31 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
echo '<div class="wrap">';
|
echo '<div class="wrap">';
|
||||||
echo '<h2 class="nav-tab-wrapper">';
|
echo '<h2 class="nav-tab-wrapper">';
|
||||||
// iterate through all register sections
|
// iterate through all register sections
|
||||||
foreach ($this->a_arr_Sections as $l_str_ID => $l_arr_Description) {
|
foreach ( $this->a_arr_Sections as $l_str_ID => $l_arr_Description ) {
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
|
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
|
||||||
$l_arr_ActiveSection["id"] == $l_str_ID ? ' nav-tab-active' : '',
|
$l_arr_ActiveSection['id'] == $l_str_ID ? ' nav-tab-active' : '',
|
||||||
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), $l_str_ID, $l_arr_Description["title"]
|
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(),
|
||||||
|
$l_str_ID,
|
||||||
|
$l_arr_Description['title']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
echo '</h2><br/>';
|
echo '</h2><br/>';
|
||||||
|
|
||||||
if ($l_bool_SettingsUpdated) {
|
if ( $l_bool_SettingsUpdated ) {
|
||||||
echo sprintf('<div id="message" class="updated">%s</div>', __("Settings saved", MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
|
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', MCI_Footnotes_Config::C_STR_PLUGIN_NAME ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// form to submit the active section
|
// form to submit the active section
|
||||||
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
|
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
|
||||||
//settings_fields($l_arr_ActiveSection["container"]);
|
// settings_fields($l_arr_ActiveSection["container"]);
|
||||||
echo '<input type="hidden" name="save-settings" value="save" />';
|
echo '<input type="hidden" name="save-settings" value="save" />';
|
||||||
// outputs the settings field of the active section
|
// outputs the settings field of the active section
|
||||||
do_settings_sections($l_arr_ActiveSection["id"]);
|
do_settings_sections( $l_arr_ActiveSection['id'] );
|
||||||
do_meta_boxes($l_arr_ActiveSection["id"], 'main', NULL);
|
do_meta_boxes( $l_arr_ActiveSection['id'], 'main', null );
|
||||||
|
|
||||||
// add submit button to active section if defined
|
// add submit button to active section if defined
|
||||||
if ($l_arr_ActiveSection["submit"]) {
|
if ( $l_arr_ActiveSection['submit'] ) {
|
||||||
submit_button();
|
submit_button();
|
||||||
}
|
}
|
||||||
// close the form to submit data
|
// close the form to submit data
|
||||||
|
@ -300,11 +306,11 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
// output special javascript for the expand/collapse function of the meta boxes
|
// output special javascript for the expand/collapse function of the meta boxes
|
||||||
echo '<script type="text/javascript">';
|
echo '<script type="text/javascript">';
|
||||||
echo "jQuery(document).ready(function ($) {";
|
echo 'jQuery(document).ready(function ($) {';
|
||||||
echo 'jQuery(".mfmmf-color-picker").wpColorPicker();';
|
echo 'jQuery(".mfmmf-color-picker").wpColorPicker();';
|
||||||
echo "jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');";
|
echo "jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');";
|
||||||
echo "postboxes.add_postbox_toggles('" . $this->a_str_SubPageHook . "');";
|
echo "postboxes.add_postbox_toggles('" . $this->a_str_SubPageHook . "');";
|
||||||
echo "});";
|
echo '});';
|
||||||
echo '</script>';
|
echo '</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,22 +324,22 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
private function saveSettings() {
|
private function saveSettings() {
|
||||||
$l_arr_newSettings = array();
|
$l_arr_newSettings = array();
|
||||||
// get current section
|
// get current section
|
||||||
reset($this->a_arr_Sections);
|
reset( $this->a_arr_Sections );
|
||||||
$l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections);
|
$l_str_ActiveSectionID = isset( $_GET['t'] ) ? $_GET['t'] : key( $this->a_arr_Sections );
|
||||||
$l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID];
|
$l_arr_ActiveSection = $this->a_arr_Sections[ $l_str_ActiveSectionID ];
|
||||||
|
|
||||||
// iterate through each value that has to be in the specific container
|
// iterate through each value that has to be in the specific container
|
||||||
foreach(MCI_Footnotes_Settings::instance()->getDefaults($l_arr_ActiveSection["container"]) as $l_str_Key => $l_mixed_Value) {
|
foreach ( MCI_Footnotes_Settings::instance()->getDefaults( $l_arr_ActiveSection['container'] ) as $l_str_Key => $l_mixed_Value ) {
|
||||||
// setting is available in the POST array, use it
|
// setting is available in the POST array, use it
|
||||||
if (array_key_exists($l_str_Key, $_POST)) {
|
if ( array_key_exists( $l_str_Key, $_POST ) ) {
|
||||||
$l_arr_newSettings[$l_str_Key] = $_POST[$l_str_Key];
|
$l_arr_newSettings[ $l_str_Key ] = $_POST[ $l_str_Key ];
|
||||||
} else {
|
} else {
|
||||||
// setting is not defined in the POST array, define it to avoid the Default value
|
// setting is not defined in the POST array, define it to avoid the Default value
|
||||||
$l_arr_newSettings[$l_str_Key] = "";
|
$l_arr_newSettings[ $l_str_Key ] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update settings
|
// update settings
|
||||||
return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $l_arr_newSettings);
|
return MCI_Footnotes_Settings::instance()->saveOptions( $l_arr_ActiveSection['container'], $l_arr_newSettings );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,13 +360,13 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param string $p_str_SettingKeyName Settings Array key name.
|
* @param string $p_str_SettingKeyName Settings Array key name.
|
||||||
* @return array Contains Settings ID, Settings Name and Settings Value.
|
* @return array Contains Settings ID, Settings Name and Settings Value.
|
||||||
*/
|
*/
|
||||||
protected function LoadSetting($p_str_SettingKeyName) {
|
protected function LoadSetting( $p_str_SettingKeyName ) {
|
||||||
// get current section
|
// get current section
|
||||||
reset($this->a_arr_Sections);
|
reset( $this->a_arr_Sections );
|
||||||
$p_arr_Return = array();
|
$p_arr_Return = array();
|
||||||
$p_arr_Return["id"] = sprintf('%s', $p_str_SettingKeyName);
|
$p_arr_Return['id'] = sprintf( '%s', $p_str_SettingKeyName );
|
||||||
$p_arr_Return["name"] = sprintf('%s', $p_str_SettingKeyName);
|
$p_arr_Return['name'] = sprintf( '%s', $p_str_SettingKeyName );
|
||||||
$p_arr_Return["value"] = esc_attr(MCI_Footnotes_Settings::instance()->get($p_str_SettingKeyName));
|
$p_arr_Return['value'] = esc_attr( MCI_Footnotes_Settings::instance()->get( $p_str_SettingKeyName ) );
|
||||||
return $p_arr_Return;
|
return $p_arr_Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,8 +400,8 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param string $p_str_Text Message to be surrounded with simple html tag (span).
|
* @param string $p_str_Text Message to be surrounded with simple html tag (span).
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function addText($p_str_Text) {
|
protected function addText( $p_str_Text ) {
|
||||||
return sprintf('<span>%s</span>', $p_str_Text);
|
return sprintf( '<span>%s</span>', $p_str_Text );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -410,9 +416,9 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* Edited 2020-12-01T0159+0100..
|
* Edited 2020-12-01T0159+0100..
|
||||||
* @since 2.1.6 no colon
|
* @since 2.1.6 no colon
|
||||||
*/
|
*/
|
||||||
protected function addLabel($p_str_SettingName, $p_str_Caption) {
|
protected function addLabel( $p_str_SettingName, $p_str_Caption ) {
|
||||||
if (empty($p_str_Caption)) {
|
if ( empty( $p_str_Caption ) ) {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
// remove the colon causing localization issues with French,
|
// remove the colon causing localization issues with French,
|
||||||
// and with languages not using punctuation at all,
|
// and with languages not using punctuation at all,
|
||||||
|
@ -423,7 +429,7 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
// Add colon to label strings for inclusion in localization.
|
// Add colon to label strings for inclusion in localization.
|
||||||
// Colon after label is widely preferred best practice, mandatory per style guides.
|
// Colon after label is widely preferred best practice, mandatory per style guides.
|
||||||
// <https://softwareengineering.stackexchange.com/questions/234546/colons-in-internationalized-ui>
|
// <https://softwareengineering.stackexchange.com/questions/234546/colons-in-internationalized-ui>
|
||||||
return sprintf('<label for="%s">%s</label>', $p_str_SettingName, $p_str_Caption);
|
return sprintf( '<label for="%s">%s</label>', $p_str_SettingName, $p_str_Caption );
|
||||||
// ^ here deleted colon 2020-12-08T1546+0100
|
// ^ here deleted colon 2020-12-08T1546+0100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,16 +444,22 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param bool $p_bool_Hidden Set the input to be hidden, default false.
|
* @param bool $p_bool_Hidden Set the input to be hidden, default false.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function addTextBox($p_str_SettingName, $p_str_MaxLength = 999, $p_bool_Readonly = false, $p_bool_Hidden = false) {
|
protected function addTextBox( $p_str_SettingName, $p_str_MaxLength = 999, $p_bool_Readonly = false, $p_bool_Hidden = false ) {
|
||||||
$l_str_Style = "";
|
$l_str_Style = '';
|
||||||
// collect data for given settings field
|
// collect data for given settings field
|
||||||
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
|
$l_arr_Data = $this->LoadSetting( $p_str_SettingName );
|
||||||
if ($p_bool_Hidden) {
|
if ( $p_bool_Hidden ) {
|
||||||
$l_str_Style .= 'display:none;';
|
$l_str_Style .= 'display:none;';
|
||||||
}
|
}
|
||||||
return sprintf('<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s" %s/>',
|
return sprintf(
|
||||||
$l_arr_Data["name"], $l_arr_Data["id"], $p_str_MaxLength,
|
'<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s" %s/>',
|
||||||
$l_str_Style, $l_arr_Data["value"], $p_bool_Readonly ? 'readonly="readonly"' : '');
|
$l_arr_Data['name'],
|
||||||
|
$l_arr_Data['id'],
|
||||||
|
$p_str_MaxLength,
|
||||||
|
$l_str_Style,
|
||||||
|
$l_arr_Data['value'],
|
||||||
|
$p_bool_Readonly ? 'readonly="readonly"' : ''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,12 +470,15 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
|
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function addCheckbox($p_str_SettingName) {
|
protected function addCheckbox( $p_str_SettingName ) {
|
||||||
// collect data for given settings field
|
// collect data for given settings field
|
||||||
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
|
$l_arr_Data = $this->LoadSetting( $p_str_SettingName );
|
||||||
return sprintf('<input type="checkbox" name="%s" id="%s" %s/>',
|
return sprintf(
|
||||||
$l_arr_Data["name"], $l_arr_Data["id"],
|
'<input type="checkbox" name="%s" id="%s" %s/>',
|
||||||
MCI_Footnotes_Convert::toBool($l_arr_Data["value"]) ? 'checked="checked"' : '');
|
$l_arr_Data['name'],
|
||||||
|
$l_arr_Data['id'],
|
||||||
|
MCI_Footnotes_Convert::toBool( $l_arr_Data['value'] ) ? 'checked="checked"' : ''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -475,20 +490,26 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param array $p_arr_Options Possible options to be selected.
|
* @param array $p_arr_Options Possible options to be selected.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function addSelectBox($p_str_SettingName, $p_arr_Options) {
|
protected function addSelectBox( $p_str_SettingName, $p_arr_Options ) {
|
||||||
// collect data for given settings field
|
// collect data for given settings field
|
||||||
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
|
$l_arr_Data = $this->LoadSetting( $p_str_SettingName );
|
||||||
$l_str_Options = "";
|
$l_str_Options = '';
|
||||||
|
|
||||||
/* loop through all array keys */
|
/* loop through all array keys */
|
||||||
foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) {
|
foreach ( $p_arr_Options as $l_str_Value => $l_str_Caption ) {
|
||||||
$l_str_Options .= sprintf('<option value="%s" %s>%s</option>',
|
$l_str_Options .= sprintf(
|
||||||
|
'<option value="%s" %s>%s</option>',
|
||||||
$l_str_Value,
|
$l_str_Value,
|
||||||
$l_arr_Data["value"] == $l_str_Value ? "selected" : "",
|
$l_arr_Data['value'] == $l_str_Value ? 'selected' : '',
|
||||||
$l_str_Caption);
|
$l_str_Caption
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return sprintf('<select name="%s" id="%s">%s</select>',
|
return sprintf(
|
||||||
$l_arr_Data["name"], $l_arr_Data["id"], $l_str_Options);
|
'<select name="%s" id="%s">%s</select>',
|
||||||
|
$l_arr_Data['name'],
|
||||||
|
$l_arr_Data['id'],
|
||||||
|
$l_str_Options
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -499,11 +520,15 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param string $p_str_SettingName Name of the Settings key to pre fill the text area.
|
* @param string $p_str_SettingName Name of the Settings key to pre fill the text area.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function addTextArea($p_str_SettingName) {
|
protected function addTextArea( $p_str_SettingName ) {
|
||||||
// collect data for given settings field
|
// collect data for given settings field
|
||||||
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
|
$l_arr_Data = $this->LoadSetting( $p_str_SettingName );
|
||||||
return sprintf('<textarea name="%s" id="%s">%s</textarea>',
|
return sprintf(
|
||||||
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]);
|
'<textarea name="%s" id="%s">%s</textarea>',
|
||||||
|
$l_arr_Data['name'],
|
||||||
|
$l_arr_Data['id'],
|
||||||
|
$l_arr_Data['value']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -514,11 +539,15 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
|
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function addColorSelection($p_str_SettingName) {
|
protected function addColorSelection( $p_str_SettingName ) {
|
||||||
// collect data for given settings field
|
// collect data for given settings field
|
||||||
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
|
$l_arr_Data = $this->LoadSetting( $p_str_SettingName );
|
||||||
return sprintf('<input type="text" name="%s" id="%s" class="mfmmf-color-picker" value="%s"/>',
|
return sprintf(
|
||||||
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]);
|
'<input type="text" name="%s" id="%s" class="mfmmf-color-picker" value="%s"/>',
|
||||||
|
$l_arr_Data['name'],
|
||||||
|
$l_arr_Data['id'],
|
||||||
|
$l_arr_Data['value']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -535,17 +564,29 @@ abstract class MCI_Footnotes_LayoutEngine {
|
||||||
* Edited:
|
* Edited:
|
||||||
* @since 2.1.4 step argument and number_format() to allow decimals 2020-12-03T0631+0100..2020-12-12T1110+0100
|
* @since 2.1.4 step argument and number_format() to allow decimals 2020-12-03T0631+0100..2020-12-12T1110+0100
|
||||||
*/
|
*/
|
||||||
protected function addNumBox($p_str_SettingName, $p_in_Min, $p_int_Max, $p_bool_Deci = false ) {
|
protected function addNumBox( $p_str_SettingName, $p_in_Min, $p_int_Max, $p_bool_Deci = false ) {
|
||||||
// collect data for given settings field
|
// collect data for given settings field
|
||||||
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
|
$l_arr_Data = $this->LoadSetting( $p_str_SettingName );
|
||||||
|
|
||||||
if ($p_bool_Deci) {
|
if ( $p_bool_Deci ) {
|
||||||
$l_str_Value = number_format(floatval($l_arr_Data["value"]), 1);
|
$l_str_Value = number_format( floatval( $l_arr_Data['value'] ), 1 );
|
||||||
return sprintf('<input type="number" name="%s" id="%s" value="%s" step="0.1" min="%d" max="%d"/>',
|
return sprintf(
|
||||||
$l_arr_Data["name"], $l_arr_Data["id"], $l_str_Value, $p_in_Min, $p_int_Max);
|
'<input type="number" name="%s" id="%s" value="%s" step="0.1" min="%d" max="%d"/>',
|
||||||
|
$l_arr_Data['name'],
|
||||||
|
$l_arr_Data['id'],
|
||||||
|
$l_str_Value,
|
||||||
|
$p_in_Min,
|
||||||
|
$p_int_Max
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return sprintf('<input type="number" name="%s" id="%s" value="%d" min="%d" max="%d"/>',
|
return sprintf(
|
||||||
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"], $p_in_Min, $p_int_Max);
|
'<input type="number" name="%s" id="%s" value="%d" min="%d" max="%d"/>',
|
||||||
|
$l_arr_Data['name'],
|
||||||
|
$l_arr_Data['id'],
|
||||||
|
$l_arr_Data['value'],
|
||||||
|
$p_in_Min,
|
||||||
|
$p_int_Max
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getSubPageSlug() {
|
protected function getSubPageSlug() {
|
||||||
return "-diagnostics";
|
return '-diagnostics';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +45,7 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
||||||
* @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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +57,7 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
||||||
*/
|
*/
|
||||||
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 ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
||||||
*/
|
*/
|
||||||
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' ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,56 +82,56 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
||||||
*/
|
*/
|
||||||
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
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -75,11 +75,17 @@ abstract class MCI_Footnotes_WidgetBase extends WP_Widget {
|
||||||
* “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__,
|
||||||
|
'description' => $this->getDescription(),
|
||||||
|
);
|
||||||
|
$l_arr_ControlOptions = array(
|
||||||
|
'id_base' => strtolower( $this->getID() ),
|
||||||
|
'width' => $this->getWidgetWidth(),
|
||||||
|
);
|
||||||
// registers the Widget
|
// registers the Widget
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
strtolower($this->getID()), // unique ID for the widget, has to be lowercase
|
strtolower( $this->getID() ), // unique ID for the widget, has to be lowercase
|
||||||
$this->getName(), // Plugin name to be displayed
|
$this->getName(), // Plugin name to be displayed
|
||||||
$l_arr_WidgetOptions, // Optional Widget Options
|
$l_arr_WidgetOptions, // Optional Widget Options
|
||||||
$l_arr_ControlOptions // Optional Widget Control Options
|
$l_arr_ControlOptions // Optional Widget Control Options
|
||||||
|
|
|
@ -26,7 +26,7 @@ class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getID() {
|
protected function getID() {
|
||||||
return "footnotes_widget";
|
return 'footnotes_widget';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
|
||||||
* 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,8 +63,8 @@ class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
|
||||||
*
|
*
|
||||||
* 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,10 +75,10 @@ class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
|
||||||
* @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