refactor: remove Hungarian notation and MCI
prefixes
I had to use some RegEx-fu for this. Specifically: ```bash find ./{footnotes.php,includes.php,class/} -type f -name "*.php" -exec sed -i 's/\(p\|l\|a\)_\(str\|bool\|int\|obj\|flo\|arr\)_//g' {} \; find ./{footnotes.php,includes.php,class/} -type f -name "*.php" -exec sed -i 's/MCI_Footnotes/Footnotes/g' {} \; find ./{footnotes.php,includes.php,class/} -type f -name "*.php" -exec sed -i 's/C_\(INT\|STR\|FLO\)_//g' {} \; ``` This should have covered all the bases. In my testing I encountered one error caused by these changes. In the `add_select_box` function in `/class/dashboard/layout.php`, there was a function parameter called `$p_arr_options` and a variable called `$l_str_options`. Removing the Hungarian notation caused an error as these two variables were both now called `$options`. This has been fixed, and I like to think that that will have been the only naming conflict, but I think it is more likely that there maybe others. Further testing is required before I am happy calling this release-ready. Close #34, progress #36
This commit is contained in:
parent
df7160fad8
commit
1284544556
15 changed files with 1710 additions and 1710 deletions
|
@ -14,14 +14,14 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes_Config {
|
||||
class Footnotes_Config {
|
||||
/**
|
||||
* Internal Plugin name.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_PLUGIN_NAME = 'footnotes';
|
||||
const PLUGIN_NAME = 'footnotes';
|
||||
|
||||
/**
|
||||
* Public Plugin name.
|
||||
|
@ -31,7 +31,7 @@ class MCI_Footnotes_Config {
|
|||
*
|
||||
* edited classes for v2.0.4
|
||||
*/
|
||||
const C_STR_PLUGIN_PUBLIC_NAME = '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
|
||||
const PLUGIN_PUBLIC_NAME = '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
|
||||
|
||||
/**
|
||||
* Public Plugin name for dashboard heading
|
||||
|
@ -45,7 +45,7 @@ class MCI_Footnotes_Config {
|
|||
* @since 2.0.4
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_PLUGIN_HEADING_NAME = '<span class="footnotes_logo_heading footnotes_logo_part1_heading">foot</span><span class="footnotes_logo_heading footnotes_logo_part2_heading">notes</span>';
|
||||
const PLUGIN_HEADING_NAME = '<span class="footnotes_logo_heading footnotes_logo_part1_heading">foot</span><span class="footnotes_logo_heading footnotes_logo_part2_heading">notes</span>';
|
||||
|
||||
/**
|
||||
* Html tag for the LOVE symbol.
|
||||
|
@ -53,7 +53,7 @@ class MCI_Footnotes_Config {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_LOVE_SYMBOL = '<span style="color:#ff6d3b; font-weight:bold;">♥</span>';
|
||||
const LOVE_SYMBOL = '<span style="color:#ff6d3b; font-weight:bold;">♥</span>';
|
||||
|
||||
/**
|
||||
* HTML code for the 'love' symbol used in dashboard heading
|
||||
|
@ -61,7 +61,7 @@ class MCI_Footnotes_Config {
|
|||
* @since 2.0.4
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_LOVE_SYMBOL_HEADING = '<span class="footnotes_heart_heading">♥</span>';
|
||||
const LOVE_SYMBOL_HEADING = '<span class="footnotes_heart_heading">♥</span>';
|
||||
|
||||
/**
|
||||
* Short code to DON'T display the 'LOVE ME' slug on certain pages.
|
||||
|
@ -69,5 +69,5 @@ class MCI_Footnotes_Config {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_NO_LOVE_SLUG = '[[no footnotes: love]]';
|
||||
const NO_LOVE_SLUG = '[[no footnotes: love]]';
|
||||
}
|
||||
|
|
|
@ -14,34 +14,34 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes_Convert {
|
||||
class Footnotes_Convert {
|
||||
|
||||
/**
|
||||
* Converts a integer into the user-defined counter style for the footnotes.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param int $p_int_index Index to be converted.
|
||||
* @param string $p_str_convert_style Style of the new/converted Index.
|
||||
* @param int $index Index to be converted.
|
||||
* @param string $convert_style Style of the new/converted Index.
|
||||
* @return string Converted Index as string in the defined counter style.
|
||||
*
|
||||
* Edited:
|
||||
* @since 2.2.0 lowercase Roman numerals supported
|
||||
*/
|
||||
public static function index( $p_int_index, $p_str_convert_style = 'arabic_plain' ) {
|
||||
switch ( $p_str_convert_style ) {
|
||||
public static function index( $index, $convert_style = 'arabic_plain' ) {
|
||||
switch ( $convert_style ) {
|
||||
case 'romanic':
|
||||
return self::to_romanic( $p_int_index, true );
|
||||
return self::to_romanic( $index, true );
|
||||
case 'roman_low':
|
||||
return self::to_romanic( $p_int_index, false );
|
||||
return self::to_romanic( $index, false );
|
||||
case 'latin_high':
|
||||
return self::to_latin( $p_int_index, true );
|
||||
return self::to_latin( $index, true );
|
||||
case 'latin_low':
|
||||
return self::to_latin( $p_int_index, false );
|
||||
return self::to_latin( $index, false );
|
||||
case 'arabic_leading':
|
||||
return self::to_arabic_leading( $p_int_index );
|
||||
return self::to_arabic_leading( $index );
|
||||
case 'arabic_plain':
|
||||
default:
|
||||
return $p_int_index;
|
||||
return $index;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,62 +50,62 @@ class MCI_Footnotes_Convert {
|
|||
* Function available from A to ZZ ( means 676 footnotes at 1 page possible).
|
||||
*
|
||||
* @since 1.0-gamma
|
||||
* @param int $p_int_value Value/Index to be converted.
|
||||
* @param bool $p_bool_upper_case True to convert the value to upper case letter, otherwise to lower case.
|
||||
* @param int $value Value/Index to be converted.
|
||||
* @param bool $upper_case True to convert the value to upper case letter, otherwise to lower case.
|
||||
* @return string
|
||||
*/
|
||||
private static function to_latin( $p_int_value, $p_bool_upper_case ) {
|
||||
private static function to_latin( $value, $upper_case ) {
|
||||
// Output string.
|
||||
$l_str_return = '';
|
||||
$l_int_offset = 0;
|
||||
$return = '';
|
||||
$offset = 0;
|
||||
// Check if the value is higher then 26 = Z.
|
||||
while ( $p_int_value > 26 ) {
|
||||
while ( $value > 26 ) {
|
||||
// Increase offset and reduce counter.
|
||||
$l_int_offset++;
|
||||
$p_int_value -= 26;
|
||||
$offset++;
|
||||
$value -= 26;
|
||||
}
|
||||
// If offset set (more then Z), then add a new letter in front.
|
||||
if ( $l_int_offset > 0 ) {
|
||||
$l_str_return = chr( $l_int_offset + 64 );
|
||||
if ( $offset > 0 ) {
|
||||
$return = chr( $offset + 64 );
|
||||
}
|
||||
// Add the origin letter.
|
||||
$l_str_return .= chr( $p_int_value + 64 );
|
||||
$return .= chr( $value + 64 );
|
||||
// Return the latin character representing the integer.
|
||||
if ( $p_bool_upper_case ) {
|
||||
return strtoupper( $l_str_return );
|
||||
if ( $upper_case ) {
|
||||
return strtoupper( $return );
|
||||
}
|
||||
return strtolower( $l_str_return );
|
||||
return strtolower( $return );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an integer to a leading-0 integer.
|
||||
*
|
||||
* @since 1.0-gamma
|
||||
* @param int $p_int_value Value/Index to be converted.
|
||||
* @param int $value Value/Index to be converted.
|
||||
* @return string Value with a leading zero.
|
||||
*/
|
||||
private static function to_arabic_leading( $p_int_value ) {
|
||||
private static function to_arabic_leading( $value ) {
|
||||
// Add a leading 0 if number lower then 10.
|
||||
if ( $p_int_value < 10 ) {
|
||||
return '0' . $p_int_value;
|
||||
if ( $value < 10 ) {
|
||||
return '0' . $value;
|
||||
}
|
||||
return $p_int_value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an integer to a romanic letter.
|
||||
*
|
||||
* @since 1.0-gamma
|
||||
* @param int $p_int_value Value/Index to be converted.
|
||||
* @param bool $p_bool_upper_case Whether to uppercase.
|
||||
* @param int $value Value/Index to be converted.
|
||||
* @param bool $upper_case Whether to uppercase.
|
||||
* @return string
|
||||
*
|
||||
* Edited:
|
||||
* @since 2.2.0 optionally lowercase (code from Latin)
|
||||
*/
|
||||
private static function to_romanic( $p_int_value, $p_bool_upper_case ) {
|
||||
private static function to_romanic( $value, $upper_case ) {
|
||||
// Table containing all necessary romanic letters.
|
||||
$l_arr_romanic_letters = array(
|
||||
$romanic_letters = array(
|
||||
'M' => 1000,
|
||||
'CM' => 900,
|
||||
'D' => 500,
|
||||
|
@ -121,36 +121,36 @@ class MCI_Footnotes_Convert {
|
|||
'I' => 1,
|
||||
);
|
||||
// Return value.
|
||||
$l_str_return = '';
|
||||
$return = '';
|
||||
// Iterate through integer value until it is reduced to 0.
|
||||
while ( $p_int_value > 0 ) {
|
||||
foreach ( $l_arr_romanic_letters as $l_str_romanic => $l_int_arabic ) {
|
||||
if ( $p_int_value >= $l_int_arabic ) {
|
||||
$p_int_value -= $l_int_arabic;
|
||||
$l_str_return .= $l_str_romanic;
|
||||
while ( $value > 0 ) {
|
||||
foreach ( $romanic_letters as $romanic => $arabic ) {
|
||||
if ( $value >= $arabic ) {
|
||||
$value -= $arabic;
|
||||
$return .= $romanic;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Return romanic letters as string.
|
||||
if ( $p_bool_upper_case ) {
|
||||
return strtoupper( $l_str_return );
|
||||
if ( $upper_case ) {
|
||||
return strtoupper( $return );
|
||||
}
|
||||
return strtolower( $l_str_return );
|
||||
return strtolower( $return );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string depending on its value to a boolean.
|
||||
*
|
||||
* @since 1.0-beta
|
||||
* @param string $p_str_value String to be converted to boolean.
|
||||
* @param string $value String to be converted to boolean.
|
||||
* @return bool Boolean representing the string.
|
||||
*/
|
||||
public static function to_bool( $p_str_value ) {
|
||||
public static function to_bool( $value ) {
|
||||
// Convert string to lower-case to make it easier.
|
||||
$p_str_value = strtolower( $p_str_value );
|
||||
$value = strtolower( $value );
|
||||
// Check if string seems to contain a "true" value.
|
||||
switch ( $p_str_value ) {
|
||||
switch ( $value ) {
|
||||
case 'checked':
|
||||
case 'yes':
|
||||
case 'true':
|
||||
|
@ -166,22 +166,22 @@ class MCI_Footnotes_Convert {
|
|||
* Get a html Array short code depending on Arrow-Array key index.
|
||||
*
|
||||
* @since 1.3.2
|
||||
* @param int $p_int_index Index representing the Arrow. If empty all Arrows are specified.
|
||||
* @param int $index Index representing the Arrow. If empty all Arrows are specified.
|
||||
* @return array|string Array of all Arrows if Index is empty otherwise html tag of a specific arrow.
|
||||
*/
|
||||
public static function get_arrow( $p_int_index = -1 ) {
|
||||
public static function get_arrow( $index = -1 ) {
|
||||
// Define all possible arrows.
|
||||
$l_arr_arrows = array( '↑', '↥', '↟', '↩', '↲', '↵', '⇑', '⇡', '⇧', '↑' );
|
||||
$arrows = array( '↑', '↥', '↟', '↩', '↲', '↵', '⇑', '⇡', '⇧', '↑' );
|
||||
// Convert index to an integer.
|
||||
if ( ! is_int( $p_int_index ) ) {
|
||||
$p_int_index = intval( $p_int_index );
|
||||
if ( ! is_int( $index ) ) {
|
||||
$index = intval( $index );
|
||||
}
|
||||
// Return the whole arrow array.
|
||||
if ( $p_int_index < 0 || $p_int_index > count( $l_arr_arrows ) ) {
|
||||
return $l_arr_arrows;
|
||||
if ( $index < 0 || $index > count( $arrows ) ) {
|
||||
return $arrows;
|
||||
}
|
||||
// Return a single arrow.
|
||||
return $l_arr_arrows[ $p_int_index ];
|
||||
return $arrows[ $index ];
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_dump
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes_Layout_Init {
|
||||
class Footnotes_Layout_Init {
|
||||
|
||||
/**
|
||||
* Slug for the Plugin main menu.
|
||||
|
@ -20,7 +20,7 @@ class MCI_Footnotes_Layout_Init {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_MAIN_MENU_SLUG = 'footnotes';
|
||||
const MAIN_MENU_SLUG = 'footnotes';
|
||||
|
||||
/**
|
||||
* Plugin main menu name.
|
||||
|
@ -28,7 +28,7 @@ class MCI_Footnotes_Layout_Init {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_MAIN_MENU_TITLE = 'ManFisher';
|
||||
const MAIN_MENU_TITLE = 'ManFisher';
|
||||
|
||||
/**
|
||||
* Contains the settings layoutEngine
|
||||
|
@ -44,7 +44,7 @@ class MCI_Footnotes_Layout_Init {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->settings_page = new MCI_Footnotes_Layout_Settings();
|
||||
$this->settings_page = new Footnotes_Layout_Settings();
|
||||
|
||||
// Register hooks/actions.
|
||||
add_action( 'admin_menu', array( $this, 'register_options_submenu' ) );
|
||||
|
@ -60,7 +60,7 @@ class MCI_Footnotes_Layout_Init {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function initialize_settings() {
|
||||
MCI_Footnotes_Settings::instance()->register_settings();
|
||||
Footnotes_Settings::instance()->register_settings();
|
||||
$this->settings_page->register_sections();
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class MCI_Footnotes_Layout_Init {
|
|||
add_submenu_page(
|
||||
'options-general.php',
|
||||
'footnotes Settings',
|
||||
self::C_STR_MAIN_MENU_SLUG,
|
||||
self::MAIN_MENU_SLUG,
|
||||
'manage_options',
|
||||
'footnotes',
|
||||
array( $this->settings_page, 'display_content' )
|
||||
|
@ -93,53 +93,53 @@ class MCI_Footnotes_Layout_Init {
|
|||
|
||||
// Get plugin internal name from POST data.
|
||||
if ( isset( $_POST['plugin'] ) ) {
|
||||
$l_str_plugin_name = wp_unslash( $_POST['plugin'] );
|
||||
$plugin_name = wp_unslash( $_POST['plugin'] );
|
||||
}
|
||||
|
||||
if ( empty( $l_str_plugin_name ) ) {
|
||||
if ( empty( $plugin_name ) ) {
|
||||
echo wp_json_encode( array( 'error' => 'Plugin name invalid.' ) );
|
||||
exit;
|
||||
}
|
||||
$l_str_url = 'https://api.wordpress.org/plugins/info/1.0/' . $l_str_plugin_name . '.json';
|
||||
$url = 'https://api.wordpress.org/plugins/info/1.0/' . $plugin_name . '.json';
|
||||
// Call URL and collect data.
|
||||
$l_arr_response = wp_remote_get( $l_str_url );
|
||||
$response = wp_remote_get( $url );
|
||||
// Check if response is valid.
|
||||
if ( is_wp_error( $l_arr_response ) ) {
|
||||
if ( is_wp_error( $response ) ) {
|
||||
echo wp_json_encode( array( 'error' => 'Error receiving Plugin Information from WordPress.' ) );
|
||||
exit;
|
||||
}
|
||||
if ( ! array_key_exists( 'body', $l_arr_response ) ) {
|
||||
if ( ! array_key_exists( 'body', $response ) ) {
|
||||
echo wp_json_encode( array( 'error' => 'Error reading WordPress API response message.' ) );
|
||||
exit;
|
||||
}
|
||||
// Get the body of the response.
|
||||
$l_str_response = $l_arr_response['body'];
|
||||
$response = $response['body'];
|
||||
// Get plugin object.
|
||||
$l_arr_plugin = json_decode( $l_str_response, true );
|
||||
if ( empty( $l_arr_plugin ) ) {
|
||||
echo wp_json_encode( array( 'error' => 'Error reading Plugin meta information.<br/>URL: ' . $l_str_url . '<br/>Response: ' . $l_str_response ) );
|
||||
$plugin = json_decode( $response, true );
|
||||
if ( empty( $plugin ) ) {
|
||||
echo wp_json_encode( array( 'error' => 'Error reading Plugin meta information.<br/>URL: ' . $url . '<br/>Response: ' . $response ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$l_int_num_ratings = 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_stars = round( 5 * $l_int_rating / 100.0, 1 );
|
||||
$num_ratings = array_key_exists( 'num_ratings', $plugin ) ? intval( $plugin['num_ratings'] ) : 0;
|
||||
$rating = array_key_exists( 'rating', $plugin ) ? floatval( $plugin['rating'] ) : 0.0;
|
||||
$stars = round( 5 * $rating / 100.0, 1 );
|
||||
|
||||
// Return Plugin information as JSON encoded string.
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
'error' => '',
|
||||
'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',
|
||||
'PluginRatingText' => $l_int_stars . ' ' . __( 'rating based on', 'footnotes' ) . ' ' . $l_int_num_ratings . ' ' . __( 'ratings', 'footnotes' ),
|
||||
'PluginRating1' => $l_int_stars >= 0.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',
|
||||
'PluginRating4' => $l_int_stars >= 3.5 ? 'star-full' : 'star-empty',
|
||||
'PluginRating5' => $l_int_stars >= 4.5 ? 'star-full' : 'star-empty',
|
||||
'PluginRating' => $l_int_num_ratings,
|
||||
'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'] : '---',
|
||||
'PluginDescription' => array_key_exists( 'short_description', $plugin ) ? html_entity_decode( $plugin['short_description'] ) : 'Error reading Plugin information',
|
||||
'PluginAuthor' => array_key_exists( 'author', $plugin ) ? html_entity_decode( $plugin['author'] ) : 'unknown',
|
||||
'PluginRatingText' => $stars . ' ' . __( 'rating based on', 'footnotes' ) . ' ' . $num_ratings . ' ' . __( 'ratings', 'footnotes' ),
|
||||
'PluginRating1' => $stars >= 0.5 ? 'star-full' : 'star-empty',
|
||||
'PluginRating2' => $stars >= 1.5 ? 'star-full' : 'star-empty',
|
||||
'PluginRating3' => $stars >= 2.5 ? 'star-full' : 'star-empty',
|
||||
'PluginRating4' => $stars >= 3.5 ? 'star-full' : 'star-empty',
|
||||
'PluginRating5' => $stars >= 4.5 ? 'star-full' : 'star-empty',
|
||||
'PluginRating' => $num_ratings,
|
||||
'PluginLastUpdated' => array_key_exists( 'last_updated', $plugin ) ? $plugin['last_updated'] : 'unknown',
|
||||
'PluginDownloads' => array_key_exists( 'downloaded', $plugin ) ? $plugin['downloaded'] : '---',
|
||||
)
|
||||
);
|
||||
exit;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract class MCI_Footnotes_Layout_Engine {
|
||||
abstract class Footnotes_Layout_Engine {
|
||||
|
||||
/**
|
||||
* Stores the Hook connection string for the child sub page.
|
||||
|
@ -27,7 +27,7 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* @since 1.5.0
|
||||
* @var null|string
|
||||
*/
|
||||
protected $a_str_sub_page_hook = null;
|
||||
protected $sub_page_hook = null;
|
||||
|
||||
/**
|
||||
* Stores all Sections for the child sub page.
|
||||
|
@ -35,7 +35,7 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* @since 1.5.0
|
||||
* @var array
|
||||
*/
|
||||
protected $a_arr_sections = array();
|
||||
protected $sections = array();
|
||||
|
||||
/**
|
||||
* Returns a Priority index. Lower numbers have a higher Priority.
|
||||
|
@ -81,18 +81,18 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Returns an array describing a sub page section.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_id Unique ID suffix.
|
||||
* @param string $p_str_title Title of the section.
|
||||
* @param int $p_int_settings_container_index Settings Container Index.
|
||||
* @param bool $p_bool_has_submit_button Should a Submit Button be displayed for this section, default: true.
|
||||
* @param string $id Unique ID suffix.
|
||||
* @param string $title Title of the section.
|
||||
* @param int $settings_container_index Settings Container Index.
|
||||
* @param bool $has_submit_button Should a Submit Button be displayed for this section, default: true.
|
||||
* @return array Array describing the section.
|
||||
*/
|
||||
protected function add_section( $p_str_id, $p_str_title, $p_int_settings_container_index, $p_bool_has_submit_button = true ) {
|
||||
protected function add_section( $id, $title, $settings_container_index, $has_submit_button = true ) {
|
||||
return array(
|
||||
'id' => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_id,
|
||||
'title' => $p_str_title,
|
||||
'submit' => $p_bool_has_submit_button,
|
||||
'container' => $p_int_settings_container_index,
|
||||
'id' => Footnotes_Config::PLUGIN_NAME . '-' . $id,
|
||||
'title' => $title,
|
||||
'submit' => $has_submit_button,
|
||||
'container' => $settings_container_index,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -100,18 +100,18 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Returns an array describing a meta box.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_section_id Parent Section ID.
|
||||
* @param string $p_str_id Unique ID suffix.
|
||||
* @param string $p_str_title Title for the meta box.
|
||||
* @param string $p_str_callback_function_name Class method name for callback.
|
||||
* @param string $section_id Parent Section ID.
|
||||
* @param string $id Unique ID suffix.
|
||||
* @param string $title Title for the meta box.
|
||||
* @param string $callback_function_name Class method name for callback.
|
||||
* @return array meta box description to be able to append a meta box to the output.
|
||||
*/
|
||||
protected function add_meta_box( $p_str_section_id, $p_str_id, $p_str_title, $p_str_callback_function_name ) {
|
||||
protected function add_meta_box( $section_id, $id, $title, $callback_function_name ) {
|
||||
return array(
|
||||
'parent' => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_section_id,
|
||||
'id' => $p_str_id,
|
||||
'title' => $p_str_title,
|
||||
'callback' => $p_str_callback_function_name,
|
||||
'parent' => Footnotes_Config::PLUGIN_NAME . '-' . $section_id,
|
||||
'id' => $id,
|
||||
'title' => $title,
|
||||
'callback' => $callback_function_name,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -123,20 +123,20 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
public function register_sub_page() {
|
||||
global $submenu;
|
||||
|
||||
if ( array_key_exists( plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ), $submenu ) ) {
|
||||
foreach ( $submenu[ plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ) ] as $l_arr_sub_menu ) {
|
||||
if ( plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug() ) === $l_arr_sub_menu[2] ) {
|
||||
remove_submenu_page( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug() );
|
||||
if ( array_key_exists( plugin_basename( Footnotes_Layout_Init::MAIN_MENU_SLUG ), $submenu ) ) {
|
||||
foreach ( $submenu[ plugin_basename( Footnotes_Layout_Init::MAIN_MENU_SLUG ) ] as $sub_menu ) {
|
||||
if ( plugin_basename( Footnotes_Layout_Init::MAIN_MENU_SLUG . $this->get_sub_page_slug() ) === $sub_menu[2] ) {
|
||||
remove_submenu_page( Footnotes_Layout_Init::MAIN_MENU_SLUG, Footnotes_Layout_Init::MAIN_MENU_SLUG . $this->get_sub_page_slug() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->a_str_sub_page_hook = add_submenu_page(
|
||||
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG,
|
||||
$this->sub_page_hook = add_submenu_page(
|
||||
Footnotes_Layout_Init::MAIN_MENU_SLUG,
|
||||
$this->get_sub_page_title(),
|
||||
$this->get_sub_page_title(),
|
||||
'manage_options',
|
||||
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug(),
|
||||
Footnotes_Layout_Init::MAIN_MENU_SLUG . $this->get_sub_page_slug(),
|
||||
array( $this, 'display_content' )
|
||||
);
|
||||
}
|
||||
|
@ -147,16 +147,16 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sections() {
|
||||
foreach ( $this->get_sections() as $l_arr_section ) {
|
||||
foreach ( $this->get_sections() as $section ) {
|
||||
// Append tab to the tab-array.
|
||||
$this->a_arr_sections[ $l_arr_section['id'] ] = $l_arr_section;
|
||||
$this->sections[ $section['id'] ] = $section;
|
||||
add_settings_section(
|
||||
$l_arr_section['id'],
|
||||
$section['id'],
|
||||
'',
|
||||
array( $this, 'Description' ),
|
||||
$l_arr_section['id']
|
||||
$section['id']
|
||||
);
|
||||
$this->register_meta_boxes( $l_arr_section['id'] );
|
||||
$this->register_meta_boxes( $section['id'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,19 +164,19 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Registers all Meta boxes for a sub page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_parent_id Parent section unique id.
|
||||
* @param string $parent_id Parent section unique id.
|
||||
*/
|
||||
private function register_meta_boxes( $p_str_parent_id ) {
|
||||
private function register_meta_boxes( $parent_id ) {
|
||||
// Iterate through each meta box.
|
||||
foreach ( $this->get_meta_boxes() as $l_arr_meta_box ) {
|
||||
if ( $p_str_parent_id !== $l_arr_meta_box['parent'] ) {
|
||||
foreach ( $this->get_meta_boxes() as $meta_box ) {
|
||||
if ( $parent_id !== $meta_box['parent'] ) {
|
||||
continue;
|
||||
}
|
||||
add_meta_box(
|
||||
$p_str_parent_id . '-' . $l_arr_meta_box['id'],
|
||||
$l_arr_meta_box['title'],
|
||||
array( $this, $l_arr_meta_box['callback'] ),
|
||||
$p_str_parent_id,
|
||||
$parent_id . '-' . $meta_box['id'],
|
||||
$meta_box['title'],
|
||||
array( $this, $meta_box['callback'] ),
|
||||
$parent_id,
|
||||
'main'
|
||||
);
|
||||
}
|
||||
|
@ -211,11 +211,11 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
*/
|
||||
if ( true === PRODUCTION_ENV ) {
|
||||
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), C_STR_FOOTNOTES_VERSION );
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), FOOTNOTES_VERSION );
|
||||
|
||||
} else {
|
||||
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.css' ), array(), C_STR_FOOTNOTES_VERSION );
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.css' ), array(), FOOTNOTES_VERSION );
|
||||
|
||||
}
|
||||
|
||||
|
@ -234,17 +234,17 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
// TODO: add nonce verification.
|
||||
|
||||
// Get the current section.
|
||||
reset( $this->a_arr_sections );
|
||||
$l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->a_arr_sections );
|
||||
$l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ];
|
||||
reset( $this->sections );
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
|
||||
// Store settings.
|
||||
$l_bool_settings_updated = false;
|
||||
$settings_updated = false;
|
||||
if ( array_key_exists( 'save-settings', $_POST ) ) {
|
||||
if ( 'save' === $_POST['save-settings'] ) {
|
||||
unset( $_POST['save-settings'] );
|
||||
unset( $_POST['submit'] );
|
||||
$l_bool_settings_updated = $this->save_settings();
|
||||
$settings_updated = $this->save_settings();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,19 +252,19 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
echo '<div class="wrap">';
|
||||
echo '<h2 class="nav-tab-wrapper">';
|
||||
// Iterate through all register sections.
|
||||
foreach ( $this->a_arr_sections as $l_str_id => $l_arr_description ) {
|
||||
$l_str_tab_active = ( $l_str_id === $l_arr_active_section['id'] ) ? ' nav-tab-active' : '';
|
||||
foreach ( $this->sections as $id => $description ) {
|
||||
$tab_active = ( $id === $active_section['id'] ) ? ' nav-tab-active' : '';
|
||||
echo sprintf(
|
||||
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
|
||||
( $l_str_id === $l_arr_active_section['id'] ) ? ' nav-tab-active' : '',
|
||||
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG,
|
||||
$l_str_id,
|
||||
$l_arr_description['title']
|
||||
( $id === $active_section['id'] ) ? ' nav-tab-active' : '',
|
||||
Footnotes_Layout_Init::MAIN_MENU_SLUG,
|
||||
$id,
|
||||
$description['title']
|
||||
);
|
||||
}
|
||||
echo '</h2><br/>';
|
||||
|
||||
if ( $l_bool_settings_updated ) {
|
||||
if ( $settings_updated ) {
|
||||
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) );
|
||||
}
|
||||
|
||||
|
@ -272,11 +272,11 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
|
||||
echo '<input type="hidden" name="save-settings" value="save" />';
|
||||
// Outputs the settings field of the active section.
|
||||
do_settings_sections( $l_arr_active_section['id'] );
|
||||
do_meta_boxes( $l_arr_active_section['id'], 'main', null );
|
||||
do_settings_sections( $active_section['id'] );
|
||||
do_meta_boxes( $active_section['id'], 'main', null );
|
||||
|
||||
// Add submit button to active section if defined.
|
||||
if ( $l_arr_active_section['submit'] ) {
|
||||
if ( $active_section['submit'] ) {
|
||||
submit_button();
|
||||
}
|
||||
echo '</form>';
|
||||
|
@ -287,7 +287,7 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
echo 'jQuery(document).ready(function ($) {';
|
||||
echo 'jQuery(".footnotes-color-picker").wpColorPicker();';
|
||||
echo "jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');";
|
||||
echo "postboxes.add_postbox_toggles('" . $this->a_str_sub_page_hook . "');";
|
||||
echo "postboxes.add_postbox_toggles('" . $this->sub_page_hook . "');";
|
||||
echo '});';
|
||||
echo '</script>';
|
||||
}
|
||||
|
@ -301,25 +301,25 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* @return bool
|
||||
*/
|
||||
private function save_settings() {
|
||||
$l_arr_new_settings = array();
|
||||
$new_settings = array();
|
||||
|
||||
// TODO: add nonce verification.
|
||||
|
||||
// Get current section.
|
||||
reset( $this->a_arr_sections );
|
||||
$l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->a_arr_sections );
|
||||
$l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ];
|
||||
reset( $this->sections );
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
|
||||
foreach ( MCI_Footnotes_Settings::instance()->get_defaults( $l_arr_active_section['container'] ) as $l_str_key => $l_mixed_value ) {
|
||||
if ( array_key_exists( $l_str_key, $_POST ) ) {
|
||||
$l_arr_new_settings[ $l_str_key ] = wp_unslash( $_POST[ $l_str_key ] );
|
||||
foreach ( Footnotes_Settings::instance()->get_defaults( $active_section['container'] ) as $key => $l_mixed_value ) {
|
||||
if ( array_key_exists( $key, $_POST ) ) {
|
||||
$new_settings[ $key ] = wp_unslash( $_POST[ $key ] );
|
||||
} else {
|
||||
// Setting is not defined in the POST array, define it to avoid the Default value.
|
||||
$l_arr_new_settings[ $l_str_key ] = '';
|
||||
$new_settings[ $key ] = '';
|
||||
}
|
||||
}
|
||||
// Update settings.
|
||||
return MCI_Footnotes_Settings::instance()->save_options( $l_arr_active_section['container'], $l_arr_new_settings );
|
||||
return Footnotes_Settings::instance()->save_options( $active_section['container'], $new_settings );
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
|
||||
|
@ -336,7 +336,7 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Loads specific setting and returns an array with the keys [id, name, value].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_setting_key_name Settings Array key name.
|
||||
* @param string $setting_key_name Settings Array key name.
|
||||
* @return array Contains Settings ID, Settings Name and Settings Value.
|
||||
*
|
||||
* @since 2.5.11 Remove escapement function.
|
||||
|
@ -354,14 +354,14 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* This is the only instance of esc_|kses|sanitize in the pre-2.5.11 codebase.
|
||||
* Removing this did not fix the quotation mark backslash escapement bug.
|
||||
*/
|
||||
protected function load_setting( $p_str_setting_key_name ) {
|
||||
protected function load_setting( $setting_key_name ) {
|
||||
// Get current section.
|
||||
reset( $this->a_arr_sections );
|
||||
$p_arr_return = array();
|
||||
$p_arr_return['id'] = sprintf( '%s', $p_str_setting_key_name );
|
||||
$p_arr_return['name'] = sprintf( '%s', $p_str_setting_key_name );
|
||||
$p_arr_return['value'] = esc_attr( MCI_Footnotes_Settings::instance()->get( $p_str_setting_key_name ) );
|
||||
return $p_arr_return;
|
||||
reset( $this->sections );
|
||||
$return = array();
|
||||
$return['id'] = sprintf( '%s', $setting_key_name );
|
||||
$return['name'] = sprintf( '%s', $setting_key_name );
|
||||
$return['value'] = esc_attr( Footnotes_Settings::instance()->get( $setting_key_name ) );
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,23 +388,23 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Returns a simple text inside html <span> text.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_text Message to be surrounded with simple html tag (span).
|
||||
* @param string $text Message to be surrounded with simple html tag (span).
|
||||
* @return string
|
||||
*/
|
||||
protected function add_text( $p_str_text ) {
|
||||
return sprintf( '<span>%s</span>', $p_str_text );
|
||||
protected function add_text( $text ) {
|
||||
return sprintf( '<span>%s</span>', $text );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html tag for an input/select label.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_setting_name Name of the Settings key to connect the Label with the input/select field.
|
||||
* @param string $p_str_caption Label caption.
|
||||
* @param string $setting_name Name of the Settings key to connect the Label with the input/select field.
|
||||
* @param string $caption Label caption.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_label( $p_str_setting_name, $p_str_caption ) {
|
||||
if ( empty( $p_str_caption ) ) {
|
||||
protected function add_label( $setting_name, $caption ) {
|
||||
if ( empty( $caption ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -418,34 +418,34 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* label is widely preferred best practice, mandatory per
|
||||
* [style guides](https://softwareengineering.stackexchange.com/questions/234546/colons-in-internationalized-ui).
|
||||
*/
|
||||
return sprintf( '<label for="%s">%s</label>', $p_str_setting_name, $p_str_caption );
|
||||
return sprintf( '<label for="%s">%s</label>', $setting_name, $caption );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html tag for an input [type = text].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
|
||||
* @param int $p_str_max_length Maximum length of the input, default 999 characters.
|
||||
* @param bool $p_bool_readonly Set the input to be read only, default false.
|
||||
* @param bool $p_bool_hidden Set the input to be hidden, default false.
|
||||
* @param string $setting_name Name of the Settings key to pre load the input field.
|
||||
* @param int $max_length Maximum length of the input, default 999 characters.
|
||||
* @param bool $readonly Set the input to be read only, default false.
|
||||
* @param bool $hidden Set the input to be hidden, default false.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_text_box( $p_str_setting_name, $p_str_max_length = 999, $p_bool_readonly = false, $p_bool_hidden = false ) {
|
||||
$l_str_style = '';
|
||||
protected function add_text_box( $setting_name, $max_length = 999, $readonly = false, $hidden = false ) {
|
||||
$style = '';
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
if ( $p_bool_hidden ) {
|
||||
$l_str_style .= 'display:none;';
|
||||
$data = $this->load_setting( $setting_name );
|
||||
if ( $hidden ) {
|
||||
$style .= 'display:none;';
|
||||
}
|
||||
return sprintf(
|
||||
'<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s" %s/>',
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$p_str_max_length,
|
||||
$l_str_style,
|
||||
$l_arr_data['value'],
|
||||
$p_bool_readonly ? 'readonly="readonly"' : ''
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$max_length,
|
||||
$style,
|
||||
$data['value'],
|
||||
$readonly ? 'readonly="readonly"' : ''
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -453,17 +453,17 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Returns the html tag for an input [type = checkbox].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
|
||||
* @param string $setting_name Name of the Settings key to pre load the input field.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_checkbox( $p_str_setting_name ) {
|
||||
protected function add_checkbox( $setting_name ) {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
$data = $this->load_setting( $setting_name );
|
||||
return sprintf(
|
||||
'<input type="checkbox" name="%s" id="%s" %s/>',
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
MCI_Footnotes_Convert::to_bool( $l_arr_data['value'] ) ? 'checked="checked"' : ''
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
Footnotes_Convert::to_bool( $data['value'] ) ? 'checked="checked"' : ''
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -477,33 +477,33 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* @reporter @lolzim
|
||||
*
|
||||
* @since 2.5.13
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre select the current value.
|
||||
* @param array $p_arr_options Possible options to be selected.
|
||||
* @param string $setting_name Name of the Settings key to pre select the current value.
|
||||
* @param array $options Possible options to be selected.
|
||||
* @return string
|
||||
*
|
||||
* @since 2.5.15 Bugfix: Dashboard: General settings: Footnote start and end short codes: debug select box for shortcodes with pointy brackets.
|
||||
* @since 2.6.1 Restore esc_attr() in load_setting(), remove htmlspecialchars() here.
|
||||
*/
|
||||
protected function add_select_box( $p_str_setting_name, $p_arr_options ) {
|
||||
protected function add_select_box( $setting_name, $options ) {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
$l_str_options = '';
|
||||
$data = $this->load_setting( $setting_name );
|
||||
$select_options = '';
|
||||
|
||||
// Loop through all array keys.
|
||||
foreach ( $p_arr_options as $l_str_value => $l_str_caption ) {
|
||||
$l_str_options .= sprintf(
|
||||
foreach ( $options as $value => $caption ) {
|
||||
$select_options .= sprintf(
|
||||
'<option value="%s" %s>%s</option>',
|
||||
$l_str_value,
|
||||
$value,
|
||||
// Only check for equality, not identity, WRT backlink symbol arrows.
|
||||
$l_str_value == $l_arr_data['value'] ? 'selected' : '',
|
||||
$l_str_caption
|
||||
$value == $data['value'] ? 'selected' : '',
|
||||
$caption
|
||||
);
|
||||
}
|
||||
return sprintf(
|
||||
'<select name="%s" id="%s">%s</select>',
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_str_options
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$select_options
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -511,17 +511,17 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Returns the html tag for a text area.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre fill the text area.
|
||||
* @param string $setting_name Name of the Settings key to pre fill the text area.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_textarea( $p_str_setting_name ) {
|
||||
protected function add_textarea( $setting_name ) {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
$data = $this->load_setting( $setting_name );
|
||||
return sprintf(
|
||||
'<textarea name="%s" id="%s">%s</textarea>',
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_arr_data['value']
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$data['value']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -529,17 +529,17 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Returns the html tag for an input [type = text] with color selection class.
|
||||
*
|
||||
* @since 1.5.6
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
|
||||
* @param string $setting_name Name of the Settings key to pre load the input field.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_color_selection( $p_str_setting_name ) {
|
||||
protected function add_color_selection( $setting_name ) {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
$data = $this->load_setting( $setting_name );
|
||||
return sprintf(
|
||||
'<input type="text" name="%s" id="%s" class="footnotes-color-picker" value="%s"/>',
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_arr_data['value']
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$data['value']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -547,37 +547,37 @@ abstract class MCI_Footnotes_Layout_Engine {
|
|||
* Returns the html tag for an input [type = num].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
|
||||
* @param string $setting_name Name of the Settings key to pre load the input field.
|
||||
* @param int $p_in_min Minimum value.
|
||||
* @param int $p_int_max Maximum value.
|
||||
* @param bool $p_bool_deci true if 0.1 steps and floating to string, false if integer (default).
|
||||
* @param int $max Maximum value.
|
||||
* @param bool $deci true if 0.1 steps and floating to string, false if integer (default).
|
||||
* @return string
|
||||
*
|
||||
* Edited:
|
||||
* @since 2.1.4 step argument and number_format() to allow decimals ..
|
||||
*/
|
||||
protected function add_num_box( $p_str_setting_name, $p_in_min, $p_int_max, $p_bool_deci = false ) {
|
||||
protected function add_num_box( $setting_name, $p_in_min, $max, $deci = false ) {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
$data = $this->load_setting( $setting_name );
|
||||
|
||||
if ( $p_bool_deci ) {
|
||||
$l_str_value = number_format( floatval( $l_arr_data['value'] ), 1 );
|
||||
if ( $deci ) {
|
||||
$value = number_format( floatval( $data['value'] ), 1 );
|
||||
return sprintf(
|
||||
'<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,
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$value,
|
||||
$p_in_min,
|
||||
$p_int_max
|
||||
$max
|
||||
);
|
||||
} else {
|
||||
return sprintf(
|
||||
'<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'],
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$data['value'],
|
||||
$p_in_min,
|
||||
$p_int_max
|
||||
$max
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
102
class/init.php
102
class/init.php
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes {
|
||||
class Footnotes {
|
||||
|
||||
/**
|
||||
* The Plugin task.
|
||||
|
@ -21,7 +21,7 @@ class MCI_Footnotes {
|
|||
* @since 1.5.0
|
||||
* @var Task $task The Plugin task.
|
||||
*/
|
||||
public $a_obj_task = null;
|
||||
public $task = null;
|
||||
|
||||
/**
|
||||
* Flag for using tooltips.
|
||||
|
@ -30,7 +30,7 @@ class MCI_Footnotes {
|
|||
*
|
||||
* @var bool $tooltips_enabled Whether tooltips are enabled or not.
|
||||
*/
|
||||
public static $a_bool_tooltips_enabled = false;
|
||||
public static $tooltips_enabled = false;
|
||||
|
||||
/**
|
||||
* Allows to determine whether alternative tooltips are enabled.
|
||||
|
@ -46,7 +46,7 @@ class MCI_Footnotes {
|
|||
* @contributor Patrizia Lutz @misfist
|
||||
* @var bool
|
||||
*/
|
||||
public static $a_bool_alternative_tooltips_enabled = false;
|
||||
public static $alternative_tooltips_enabled = false;
|
||||
|
||||
/**
|
||||
* Allows to determine whether AMP compatibility mode is enabled.
|
||||
|
@ -68,7 +68,7 @@ class MCI_Footnotes {
|
|||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $a_bool_amp_enabled = false;
|
||||
public static $amp_enabled = false;
|
||||
|
||||
/**
|
||||
* Allows to determine the script mode among jQuery or plain JS.
|
||||
|
@ -86,7 +86,7 @@ class MCI_Footnotes {
|
|||
* @var str 'js' Plain JavaScript.
|
||||
* 'jquery' Use jQuery libraries.
|
||||
*/
|
||||
public static $a_str_script_mode = 'js';
|
||||
public static $script_mode = 'js';
|
||||
|
||||
/**
|
||||
* Executes the Plugin.
|
||||
|
@ -105,9 +105,9 @@ class MCI_Footnotes {
|
|||
*/
|
||||
public function run() {
|
||||
// Register language.
|
||||
MCI_Footnotes_Language::register_hooks();
|
||||
Footnotes_Language::register_hooks();
|
||||
// Register Button hooks.
|
||||
MCI_Footnotes_WYSIWYG::register_hooks();
|
||||
Footnotes_WYSIWYG::register_hooks();
|
||||
// Register general hooks.
|
||||
Hooks::register_hooks();
|
||||
|
||||
|
@ -153,7 +153,7 @@ class MCI_Footnotes {
|
|||
* Also, the visibility of initialize_widgets() is not private any longer.
|
||||
*/
|
||||
public function initialize_widgets() {
|
||||
register_widget( 'MCI_Footnotes_Widget_Reference_container' );
|
||||
register_widget( 'Footnotes_Widget_Reference_container' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,7 +162,7 @@ class MCI_Footnotes {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
private function initialize_dashboard() {
|
||||
new MCI_Footnotes_Layout_Init();
|
||||
new Footnotes_Layout_Init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,8 +171,8 @@ class MCI_Footnotes {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
private function initialize_task() {
|
||||
$this->a_obj_task = new MCI_Footnotes_Task();
|
||||
$this->a_obj_task->register_hooks();
|
||||
$this->task = new Footnotes_Task();
|
||||
$this->task->register_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,10 +200,10 @@ class MCI_Footnotes {
|
|||
* The condition about tooltips was missing, only the not-alternative-tooltips part was present.
|
||||
*/
|
||||
// Set conditions re-used for stylesheet enqueuing and in class/task.php.
|
||||
self::$a_bool_amp_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_AMP_COMPATIBILITY_ENABLE ) );
|
||||
self::$a_bool_tooltips_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ) );
|
||||
self::$a_bool_alternative_tooltips_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ) );
|
||||
self::$a_str_script_mode = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE );
|
||||
self::$amp_enabled = Footnotes_Convert::to_bool( Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_AMP_COMPATIBILITY_ENABLE ) );
|
||||
self::$tooltips_enabled = Footnotes_Convert::to_bool( Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_MOUSE_OVER_BOX_ENABLED ) );
|
||||
self::$alternative_tooltips_enabled = Footnotes_Convert::to_bool( Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ) );
|
||||
self::$script_mode = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE );
|
||||
|
||||
/**
|
||||
* Enqueues the jQuery library registered by WordPress.
|
||||
|
@ -220,15 +220,15 @@ class MCI_Footnotes {
|
|||
* After adding the alternative reference container, jQuery has become optional,
|
||||
* but still enabled by default.
|
||||
*/
|
||||
if ( ! self::$a_bool_amp_enabled ) {
|
||||
if ( ! self::$amp_enabled ) {
|
||||
|
||||
if ( 'jquery' === self::$a_str_script_mode || ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) ) {
|
||||
if ( 'jquery' === self::$script_mode || ( self::$tooltips_enabled && ! self::$alternative_tooltips_enabled ) ) {
|
||||
|
||||
wp_enqueue_script( 'jquery' );
|
||||
|
||||
}
|
||||
|
||||
if ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) {
|
||||
if ( self::$tooltips_enabled && ! self::$alternative_tooltips_enabled ) {
|
||||
|
||||
/**
|
||||
* Enqueues the jQuery Tools library shipped with the plugin.
|
||||
|
@ -329,58 +329,58 @@ class MCI_Footnotes {
|
|||
* Plugin version number is needed for busting browser caches after each plugin update.
|
||||
*
|
||||
* @since 2.1.4 automate passing version number for cache busting.
|
||||
* The constant C_STR_FOOTNOTES_VERSION is defined at start of footnotes.php.
|
||||
* The constant FOOTNOTES_VERSION is defined at start of footnotes.php.
|
||||
*
|
||||
* The media scope argument 'all' is the default.
|
||||
* No need to use '-css' in the handle, as this is appended automatically.
|
||||
*/
|
||||
// Set tooltip mode for use in stylesheet name.
|
||||
if ( self::$a_bool_tooltips_enabled ) {
|
||||
if ( self::$tooltips_enabled ) {
|
||||
|
||||
if ( self::$a_bool_amp_enabled ) {
|
||||
$l_str_tooltip_mode_short = 'ampt';
|
||||
$l_str_tooltip_mode_long = 'amp-tooltips';
|
||||
if ( self::$amp_enabled ) {
|
||||
$tooltip_mode_short = 'ampt';
|
||||
$tooltip_mode_long = 'amp-tooltips';
|
||||
|
||||
} elseif ( self::$a_bool_alternative_tooltips_enabled ) {
|
||||
$l_str_tooltip_mode_short = 'altt';
|
||||
$l_str_tooltip_mode_long = 'alternative-tooltips';
|
||||
} elseif ( self::$alternative_tooltips_enabled ) {
|
||||
$tooltip_mode_short = 'altt';
|
||||
$tooltip_mode_long = 'alternative-tooltips';
|
||||
|
||||
} else {
|
||||
$l_str_tooltip_mode_short = 'jqtt';
|
||||
$l_str_tooltip_mode_long = 'jquery-tooltips';
|
||||
$tooltip_mode_short = 'jqtt';
|
||||
$tooltip_mode_long = 'jquery-tooltips';
|
||||
|
||||
}
|
||||
} else {
|
||||
$l_str_tooltip_mode_short = 'nott';
|
||||
$l_str_tooltip_mode_long = 'no-tooltips';
|
||||
$tooltip_mode_short = 'nott';
|
||||
$tooltip_mode_long = 'no-tooltips';
|
||||
}
|
||||
|
||||
// Set basic responsive page layout mode for use in stylesheet name.
|
||||
$l_str_page_layout_option = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT );
|
||||
switch ( $l_str_page_layout_option ) {
|
||||
$page_layout_option = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_PAGE_LAYOUT_SUPPORT );
|
||||
switch ( $page_layout_option ) {
|
||||
case 'reference-container':
|
||||
$l_str_layout_mode = '1';
|
||||
$layout_mode = '1';
|
||||
break;
|
||||
case 'entry-content':
|
||||
$l_str_layout_mode = '2';
|
||||
$layout_mode = '2';
|
||||
break;
|
||||
case 'main-content':
|
||||
$l_str_layout_mode = '3';
|
||||
$layout_mode = '3';
|
||||
break;
|
||||
case 'none':
|
||||
default:
|
||||
$l_str_layout_mode = '0';
|
||||
$layout_mode = '0';
|
||||
break;
|
||||
}
|
||||
|
||||
// Enqueue the tailored united minified stylesheet.
|
||||
wp_enqueue_style(
|
||||
'mci-footnotes-' . $l_str_tooltip_mode_long . '-pagelayout-' . $l_str_page_layout_option,
|
||||
'mci-footnotes-' . $tooltip_mode_long . '-pagelayout-' . $page_layout_option,
|
||||
plugins_url(
|
||||
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_tooltip_mode_short . 'brpl' . $l_str_layout_mode . '.min.css'
|
||||
Footnotes_Config::PLUGIN_NAME . '/css/footnotes-' . $tooltip_mode_short . 'brpl' . $layout_mode . '.min.css'
|
||||
),
|
||||
array(),
|
||||
C_STR_FOOTNOTES_VERSION,
|
||||
FOOTNOTES_VERSION,
|
||||
'all'
|
||||
);
|
||||
|
||||
|
@ -395,7 +395,7 @@ class MCI_Footnotes {
|
|||
*/
|
||||
wp_enqueue_style(
|
||||
'mci-footnotes-common',
|
||||
plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-common.css' ),
|
||||
plugins_url( Footnotes_Config::PLUGIN_NAME . '/css/dev-common.css' ),
|
||||
array(),
|
||||
filemtime(
|
||||
plugin_dir_path(
|
||||
|
@ -405,7 +405,7 @@ class MCI_Footnotes {
|
|||
);
|
||||
wp_enqueue_style(
|
||||
'mci-footnotes-tooltips',
|
||||
plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips.css' ),
|
||||
plugins_url( Footnotes_Config::PLUGIN_NAME . '/css/dev-tooltips.css' ),
|
||||
array(),
|
||||
filemtime(
|
||||
plugin_dir_path(
|
||||
|
@ -414,10 +414,10 @@ class MCI_Footnotes {
|
|||
)
|
||||
);
|
||||
|
||||
if ( self::$a_bool_amp_enabled ) {
|
||||
if ( self::$amp_enabled ) {
|
||||
wp_enqueue_style(
|
||||
'mci-footnotes-amp',
|
||||
plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-amp-tooltips.css' ),
|
||||
plugins_url( Footnotes_Config::PLUGIN_NAME . '/css/dev-amp-tooltips.css' ),
|
||||
array(),
|
||||
filemtime(
|
||||
plugin_dir_path(
|
||||
|
@ -427,10 +427,10 @@ class MCI_Footnotes {
|
|||
);
|
||||
}
|
||||
|
||||
if ( self::$a_bool_alternative_tooltips_enabled ) {
|
||||
if ( self::$alternative_tooltips_enabled ) {
|
||||
wp_enqueue_style(
|
||||
'mci-footnotes-alternative',
|
||||
plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips-alternative.css' ),
|
||||
plugins_url( Footnotes_Config::PLUGIN_NAME . '/css/dev-tooltips-alternative.css' ),
|
||||
array(),
|
||||
filemtime(
|
||||
plugin_dir_path(
|
||||
|
@ -440,18 +440,18 @@ class MCI_Footnotes {
|
|||
);
|
||||
}
|
||||
|
||||
$l_str_page_layout_option = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT );
|
||||
if ( 'none' !== $l_str_page_layout_option ) {
|
||||
$page_layout_option = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_PAGE_LAYOUT_SUPPORT );
|
||||
if ( 'none' !== $page_layout_option ) {
|
||||
wp_enqueue_style(
|
||||
'mci-footnotes-layout-' . $l_str_page_layout_option,
|
||||
'mci-footnotes-layout-' . $page_layout_option,
|
||||
plugins_url(
|
||||
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-layout-' . $l_str_page_layout_option . '.css'
|
||||
Footnotes_Config::PLUGIN_NAME . '/css/dev-layout-' . $page_layout_option . '.css'
|
||||
),
|
||||
array(),
|
||||
filemtime(
|
||||
plugin_dir_path(
|
||||
dirname( __FILE__, 1 )
|
||||
) . 'css/dev-layout-' . $l_str_page_layout_option . '.css'
|
||||
) . 'css/dev-layout-' . $page_layout_option . '.css'
|
||||
),
|
||||
'all'
|
||||
);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes_Language {
|
||||
class Footnotes_Language {
|
||||
|
||||
/**
|
||||
* Register WordPress Hook.
|
||||
|
@ -23,7 +23,7 @@ class MCI_Footnotes_Language {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static function register_hooks() {
|
||||
add_action( 'plugins_loaded', array( 'MCI_Footnotes_Language', 'load_text_domain' ) );
|
||||
add_action( 'plugins_loaded', array( 'Footnotes_Language', 'load_text_domain' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ class MCI_Footnotes_Language {
|
|||
* Loads a specific text domain.
|
||||
*
|
||||
* @since 1.5.1
|
||||
* @param string $p_str_language_code Language Code to load a specific text domain.
|
||||
* @param string $language_code Language Code to load a specific text domain.
|
||||
* @return bool
|
||||
*
|
||||
*
|
||||
|
@ -87,11 +87,11 @@ class MCI_Footnotes_Language {
|
|||
* “The .mo file should be named based on the text domain with a dash, and then the locale exactly.”
|
||||
* @see wp-includes/l10n.php:857
|
||||
*/
|
||||
private static function load( $p_str_language_code ) {
|
||||
private static function load( $language_code ) {
|
||||
return load_plugin_textdomain(
|
||||
MCI_Footnotes_Config::C_STR_PLUGIN_NAME,
|
||||
Footnotes_Config::PLUGIN_NAME,
|
||||
false,
|
||||
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/languages'
|
||||
Footnotes_Config::PLUGIN_NAME . '/languages'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
1446
class/task.php
1446
class/task.php
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes_Template {
|
||||
class Footnotes_Template {
|
||||
|
||||
/**
|
||||
* Directory name for dashboard templates.
|
||||
|
@ -24,7 +24,7 @@ class MCI_Footnotes_Template {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_DASHBOARD = 'dashboard';
|
||||
const DASHBOARD = 'dashboard';
|
||||
|
||||
/**
|
||||
* Directory name for public templates.
|
||||
|
@ -32,7 +32,7 @@ class MCI_Footnotes_Template {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
const C_STR_PUBLIC = 'public';
|
||||
const PUBLIC = 'public';
|
||||
|
||||
/**
|
||||
* Contains the content of the template after initialize.
|
||||
|
@ -40,7 +40,7 @@ class MCI_Footnotes_Template {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
private $a_str_original_content = '';
|
||||
private $original_content = '';
|
||||
|
||||
/**
|
||||
* Contains the content of the template after initialize with replaced place holders.
|
||||
|
@ -48,7 +48,7 @@ class MCI_Footnotes_Template {
|
|||
* @since 1.5.0
|
||||
* @var string
|
||||
*/
|
||||
private $a_str_replaced_content = '';
|
||||
private $replaced_content = '';
|
||||
|
||||
/**
|
||||
* Plugin Directory
|
||||
|
@ -63,9 +63,9 @@ class MCI_Footnotes_Template {
|
|||
* Class Constructor. Reads and loads the template file without replace any placeholder.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_file_type Template file type (take a look on the Class constants).
|
||||
* @param string $p_str_file_name Template file name inside the Template directory without the file extension.
|
||||
* @param string $p_str_extension Optional Template file extension (default: html).
|
||||
* @param string $file_type Template file type (take a look on the Class constants).
|
||||
* @param string $file_name Template file name inside the Template directory without the file extension.
|
||||
* @param string $extension Optional Template file extension (default: html).
|
||||
*
|
||||
* - Adding: Templates: support for custom templates in sibling folder, thanks to @misfist issue report.
|
||||
*
|
||||
|
@ -74,9 +74,9 @@ class MCI_Footnotes_Template {
|
|||
* @reporter @misfist
|
||||
* @link https://wordpress.org/support/topic/template-override-filter/
|
||||
*/
|
||||
public function __construct( $p_str_file_type, $p_str_file_name, $p_str_extension = 'html' ) {
|
||||
public function __construct( $file_type, $file_name, $extension = 'html' ) {
|
||||
// No template file type and/or file name set.
|
||||
if ( empty( $p_str_file_type ) || empty( $p_str_file_name ) ) {
|
||||
if ( empty( $file_type ) || empty( $file_name ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ class MCI_Footnotes_Template {
|
|||
*
|
||||
* @since 2.4.0d3
|
||||
*/
|
||||
$template = $this->get_template( $p_str_file_type, $p_str_file_name, $p_str_extension );
|
||||
$template = $this->get_template( $file_type, $file_name, $extension );
|
||||
if ( $template ) {
|
||||
$this->process_template( $template );
|
||||
} else {
|
||||
|
@ -105,21 +105,21 @@ class MCI_Footnotes_Template {
|
|||
* Replace all placeholders specified in array.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param array $p_arr_placeholders Placeholders (key = placeholder, value = value).
|
||||
* @param array $placeholders Placeholders (key = placeholder, value = value).
|
||||
* @return bool True on Success, False if Placeholders invalid.
|
||||
*/
|
||||
public function replace( $p_arr_placeholders ) {
|
||||
public function replace( $placeholders ) {
|
||||
// No placeholders set.
|
||||
if ( empty( $p_arr_placeholders ) ) {
|
||||
if ( empty( $placeholders ) ) {
|
||||
return false;
|
||||
}
|
||||
// Template content is empty.
|
||||
if ( empty( $this->a_str_replaced_content ) ) {
|
||||
if ( empty( $this->replaced_content ) ) {
|
||||
return false;
|
||||
}
|
||||
// Iterate through each placeholder and replace it with its value.
|
||||
foreach ( $p_arr_placeholders as $l_str_placeholder => $l_str_value ) {
|
||||
$this->a_str_replaced_content = str_replace( '[[' . $l_str_placeholder . ']]', $l_str_value, $this->a_str_replaced_content );
|
||||
foreach ( $placeholders as $placeholder => $value ) {
|
||||
$this->replaced_content = str_replace( '[[' . $placeholder . ']]', $value, $this->replaced_content );
|
||||
}
|
||||
// Success.
|
||||
return true;
|
||||
|
@ -131,7 +131,7 @@ class MCI_Footnotes_Template {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function reload() {
|
||||
$this->a_str_replaced_content = $this->a_str_original_content;
|
||||
$this->replaced_content = $this->original_content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,7 +141,7 @@ class MCI_Footnotes_Template {
|
|||
* @return string Template content with replaced placeholders.
|
||||
*/
|
||||
public function get_content() {
|
||||
return $this->a_str_replaced_content;
|
||||
return $this->replaced_content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,14 +160,14 @@ class MCI_Footnotes_Template {
|
|||
*/
|
||||
public function process_template( $template ) {
|
||||
// phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
|
||||
$this->a_str_original_content = preg_replace( '#<!--.+?-->#s', '', file_get_contents( $template ) );
|
||||
$this->original_content = preg_replace( '#<!--.+?-->#s', '', file_get_contents( $template ) );
|
||||
// phpcs:enable
|
||||
$this->a_str_original_content = preg_replace( '#/\*\*.+?\*/#s', '', $this->a_str_original_content );
|
||||
$this->a_str_original_content = str_replace( "\n", '', $this->a_str_original_content );
|
||||
$this->a_str_original_content = str_replace( "\r", '', $this->a_str_original_content );
|
||||
$this->a_str_original_content = str_replace( "\t", ' ', $this->a_str_original_content );
|
||||
$this->a_str_original_content = preg_replace( '# +#', ' ', $this->a_str_original_content );
|
||||
$this->a_str_original_content = str_replace( ' >', '>', $this->a_str_original_content );
|
||||
$this->original_content = preg_replace( '#/\*\*.+?\*/#s', '', $this->original_content );
|
||||
$this->original_content = str_replace( "\n", '', $this->original_content );
|
||||
$this->original_content = str_replace( "\r", '', $this->original_content );
|
||||
$this->original_content = str_replace( "\t", ' ', $this->original_content );
|
||||
$this->original_content = preg_replace( '# +#', ' ', $this->original_content );
|
||||
$this->original_content = str_replace( ' >', '>', $this->original_content );
|
||||
$this->reload();
|
||||
}
|
||||
|
||||
|
@ -182,12 +182,12 @@ class MCI_Footnotes_Template {
|
|||
* @contributor @misfist
|
||||
* @link https://wordpress.org/support/topic/template-override-filter/#post-13864301
|
||||
*
|
||||
* @param string $p_str_file_type The file type of the template.
|
||||
* @param string $p_str_file_name The file name of the template.
|
||||
* @param string $p_str_extension The file extension of the template.
|
||||
* @param string $file_type The file type of the template.
|
||||
* @param string $file_name The file name of the template.
|
||||
* @param string $extension The file extension of the template.
|
||||
* @return mixed false | template path
|
||||
*/
|
||||
public function get_template( $p_str_file_type, $p_str_file_name, $p_str_extension = 'html' ) {
|
||||
public function get_template( $file_type, $file_name, $extension = 'html' ) {
|
||||
$located = false;
|
||||
|
||||
/**
|
||||
|
@ -200,7 +200,7 @@ class MCI_Footnotes_Template {
|
|||
*/
|
||||
$template_directory = apply_filters( 'mci_footnotes_template_directory', 'footnotes/templates/' );
|
||||
$custom_directory = apply_filters( 'mci_footnotes_custom_template_directory', 'footnotes-custom/' );
|
||||
$template_name = $p_str_file_type . '/' . $p_str_file_name . '.' . $p_str_extension;
|
||||
$template_name = $file_type . '/' . $file_name . '.' . $extension;
|
||||
|
||||
/**
|
||||
* Look in active theme.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* @author Stefan Herndler
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract class MCI_Footnotes_Widget_Base extends WP_Widget {
|
||||
abstract class Footnotes_Widget_Base extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Returns an unique ID as string used for the Widget Base ID.
|
||||
|
@ -64,14 +64,14 @@ abstract class MCI_Footnotes_Widget_Base extends WP_Widget {
|
|||
* @since 1.6.4
|
||||
* @contributor @dartiss
|
||||
* @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 Footnotes_Widget_ReferenceContainer is deprecated since version 4.3.0! Use __construct() instead.”
|
||||
*/
|
||||
public function __construct() {
|
||||
$l_arr_widget_options = array(
|
||||
$widget_options = array(
|
||||
'classname' => __CLASS__,
|
||||
'description' => $this->get_description(),
|
||||
);
|
||||
$l_arr_control_options = array(
|
||||
$control_options = array(
|
||||
'id_base' => strtolower( $this->get_id() ),
|
||||
'width' => $this->get_widget_width(),
|
||||
);
|
||||
|
@ -79,8 +79,8 @@ abstract class MCI_Footnotes_Widget_Base extends WP_Widget {
|
|||
parent::__construct(
|
||||
strtolower( $this->get_id() ), // Unique ID for the widget, has to be lowercase.
|
||||
$this->get_name(), // Plugin name to be displayed.
|
||||
$l_arr_widget_options, // Optional Widget Options.
|
||||
$l_arr_control_options // Optional Widget Control Options.
|
||||
$widget_options, // Optional Widget Options.
|
||||
$control_options // Optional Widget Control Options.
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes_Widget_Reference_Container extends MCI_Footnotes_Widget_Base {
|
||||
class Footnotes_Widget_Reference_Container extends Footnotes_Widget_Base {
|
||||
|
||||
/**
|
||||
* Returns an unique ID as string used for the Widget Base ID.
|
||||
|
@ -31,7 +31,7 @@ class MCI_Footnotes_Widget_Reference_Container extends MCI_Footnotes_Widget_Base
|
|||
* @return string
|
||||
*/
|
||||
protected function get_name() {
|
||||
return MCI_Footnotes_Config::C_STR_PLUGIN_NAME;
|
||||
return Footnotes_Config::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,9 +69,9 @@ class MCI_Footnotes_Widget_Reference_Container extends MCI_Footnotes_Widget_Base
|
|||
public function widget( $args, $instance ) {
|
||||
global $g_obj_mci_footnotes;
|
||||
// Reference container positioning is set to "widget area".
|
||||
if ( 'widget' === MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION ) ) {
|
||||
if ( 'widget' === Footnotes_Settings::instance()->get( Footnotes_Settings::REFERENCE_CONTAINER_POSITION ) ) {
|
||||
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo $g_obj_mci_footnotes->a_obj_task->reference_container();
|
||||
echo $g_obj_mci_footnotes->task->reference_container();
|
||||
// phpcs:enable
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class MCI_Footnotes_WYSIWYG {
|
||||
class Footnotes_WYSIWYG {
|
||||
|
||||
/**
|
||||
* Registers Button hooks.
|
||||
|
@ -28,16 +28,16 @@ class MCI_Footnotes_WYSIWYG {
|
|||
* @return void
|
||||
*/
|
||||
public static function register_hooks() {
|
||||
add_filter( 'mce_buttons', array( 'MCI_Footnotes_WYSIWYG', 'new_visual_editor_button' ) );
|
||||
add_action( 'admin_print_footer_scripts', array( 'MCI_Footnotes_WYSIWYG', 'new_plain_text_editor_button' ) );
|
||||
add_filter( 'mce_buttons', array( 'Footnotes_WYSIWYG', 'new_visual_editor_button' ) );
|
||||
add_action( 'admin_print_footer_scripts', array( 'Footnotes_WYSIWYG', 'new_plain_text_editor_button' ) );
|
||||
|
||||
add_filter( 'mce_external_plugins', array( 'MCI_Footnotes_WYSIWYG', 'include_scripts' ) );
|
||||
add_filter( 'mce_external_plugins', array( 'Footnotes_WYSIWYG', 'include_scripts' ) );
|
||||
|
||||
// phpcs:disable
|
||||
// 'footnotes_getTags' must match its instance in wysiwyg-editor.js.
|
||||
// 'footnotes_getTags' must match its instance in editor-button.html.
|
||||
add_action( 'wp_ajax_nopriv_footnotes_getTags', array( 'MCI_Footnotes_WYSIWYG', 'ajax_callback' ) );
|
||||
add_action( 'wp_ajax_footnotes_getTags', array( 'MCI_Footnotes_WYSIWYG', 'ajax_callback' ) );
|
||||
add_action( 'wp_ajax_nopriv_footnotes_getTags', array( 'Footnotes_WYSIWYG', 'ajax_callback' ) );
|
||||
add_action( 'wp_ajax_footnotes_getTags', array( 'Footnotes_WYSIWYG', 'ajax_callback' ) );
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,12 @@ class MCI_Footnotes_WYSIWYG {
|
|||
* Append a new Button to the WYSIWYG editor of Posts and Pages.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param array $p_arr_buttons pre defined Buttons from WordPress.
|
||||
* @param array $buttons pre defined Buttons from WordPress.
|
||||
* @return array
|
||||
*/
|
||||
public static function new_visual_editor_button( $p_arr_buttons ) {
|
||||
array_push( $p_arr_buttons, MCI_Footnotes_Config::C_STR_PLUGIN_NAME );
|
||||
return $p_arr_buttons;
|
||||
public static function new_visual_editor_button( $buttons ) {
|
||||
array_push( $buttons, Footnotes_Config::PLUGIN_NAME );
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,9 +60,9 @@ class MCI_Footnotes_WYSIWYG {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static function new_plain_text_editor_button() {
|
||||
$l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'editor-button' );
|
||||
$template = new Footnotes_Template( Footnotes_Template::DASHBOARD, 'editor-button' );
|
||||
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo $l_obj_template->get_content();
|
||||
echo $template->get_content();
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
|
@ -70,12 +70,12 @@ class MCI_Footnotes_WYSIWYG {
|
|||
* Includes the Plugins WYSIWYG editor script.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param array $p_arr_plugins Scripts to be included to the editor.
|
||||
* @param array $plugins Scripts to be included to the editor.
|
||||
* @return array
|
||||
*/
|
||||
public static function include_scripts( $p_arr_plugins ) {
|
||||
$p_arr_plugins[ MCI_Footnotes_Config::C_STR_PLUGIN_NAME ] = plugins_url( '/../js/wysiwyg-editor.js', __FILE__ );
|
||||
return $p_arr_plugins;
|
||||
public static function include_scripts( $plugins ) {
|
||||
$plugins[ Footnotes_Config::PLUGIN_NAME ] = plugins_url( '/../js/wysiwyg-editor.js', __FILE__ );
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,16 +86,16 @@ class MCI_Footnotes_WYSIWYG {
|
|||
*/
|
||||
public static function ajax_callback() {
|
||||
// Get start and end tag for the footnotes short code.
|
||||
$l_str_starting_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
|
||||
$l_str_ending_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END );
|
||||
if ( 'userdefined' === $l_str_starting_tag || 'userdefined' === $l_str_ending_tag ) {
|
||||
$l_str_starting_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
|
||||
$l_str_ending_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
|
||||
$starting_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_START );
|
||||
$ending_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_END );
|
||||
if ( 'userdefined' === $starting_tag || 'userdefined' === $ending_tag ) {
|
||||
$starting_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
|
||||
$ending_tag = Footnotes_Settings::instance()->get( Footnotes_Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
|
||||
}
|
||||
echo json_encode(
|
||||
array(
|
||||
'start' => htmlspecialchars( $l_str_starting_tag ),
|
||||
'end' => htmlspecialchars( $l_str_ending_tag ),
|
||||
'start' => htmlspecialchars( $starting_tag ),
|
||||
'end' => htmlspecialchars( $ending_tag ),
|
||||
)
|
||||
);
|
||||
exit;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* @since 2.5.3 (Hungarian)
|
||||
* @var str
|
||||
*/
|
||||
define( 'C_STR_FOOTNOTES_VERSION', '2.7.1' );
|
||||
define( 'FOOTNOTES_VERSION', '2.7.1' );
|
||||
|
||||
/**
|
||||
* Defines the current environment ('development' or 'production').
|
||||
|
@ -108,10 +108,10 @@ define( 'PRODUCTION_ENV', false );
|
|||
require_once dirname( __FILE__ ) . '/includes.php';
|
||||
|
||||
// Add Plugin Links to the "installed plugins" page.
|
||||
$l_str_plugin_file = 'footnotes/footnotes.php';
|
||||
add_filter( "plugin_action_links_{$l_str_plugin_file}", array( 'Hooks', 'get_plugin_links' ), 10, 2 );
|
||||
$plugin_file = 'footnotes/footnotes.php';
|
||||
add_filter( "plugin_action_links_{$plugin_file}", array( 'Hooks', 'get_plugin_links' ), 10, 2 );
|
||||
|
||||
// Initialize the Plugin.
|
||||
$g_obj_mci_footnotes = new MCI_Footnotes();
|
||||
$g_obj_mci_footnotes = new Footnotes();
|
||||
// Run the Plugin.
|
||||
$g_obj_mci_footnotes->run();
|
||||
|
|
16
includes.php
16
includes.php
|
@ -12,24 +12,24 @@
|
|||
*
|
||||
* @author Stefan Herndler
|
||||
* @since 1.5.0
|
||||
* @param string $p_str_directory Absolute Directory path to lookup for `*.php` files.
|
||||
* @param string $directory Absolute Directory path to lookup for `*.php` files.
|
||||
*/
|
||||
function mci_footnotes_require_php_files( $p_str_directory ) {
|
||||
function mci_footnotes_require_php_files( $directory ) {
|
||||
// Append slash at the end of the Directory if not exist.
|
||||
if ( '/' !== substr( $p_str_directory, -1 ) ) {
|
||||
$p_str_directory .= '/';
|
||||
if ( '/' !== substr( $directory, -1 ) ) {
|
||||
$directory .= '/';
|
||||
}
|
||||
// Get all PHP files inside Directory.
|
||||
$l_arr_files = scandir( $p_str_directory );
|
||||
$files = scandir( $directory );
|
||||
// Iterate through each class.
|
||||
foreach ( $l_arr_files as $l_str_file_name ) {
|
||||
foreach ( $files as $file_name ) {
|
||||
// Skip all non-PHP files.
|
||||
if ( '.php' !== strtolower( substr( $l_str_file_name, -4 ) ) ) {
|
||||
if ( '.php' !== strtolower( substr( $file_name, -4 ) ) ) {
|
||||
continue;
|
||||
}
|
||||
// phpcs:disable Generic.Commenting.DocComment.MissingShort
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require_once $p_str_directory . $l_str_file_name;
|
||||
require_once $directory . $file_name;
|
||||
// phpcs:enable
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue