Revert "refactor: remove Hungarian notation and MCI
prefixes"
This reverts commit 1284544556
.
This commit is contained in:
parent
c0672461b0
commit
2f809f4fe9
15 changed files with 1710 additions and 1710 deletions
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract class Footnotes_Layout_Engine {
|
||||
abstract class MCI_Footnotes_Layout_Engine {
|
||||
|
||||
/**
|
||||
* Stores the Hook connection string for the child sub page.
|
||||
|
@ -27,7 +27,7 @@ abstract class Footnotes_Layout_Engine {
|
|||
* @since 1.5.0
|
||||
* @var null|string
|
||||
*/
|
||||
protected $sub_page_hook = null;
|
||||
protected $a_str_sub_page_hook = null;
|
||||
|
||||
/**
|
||||
* Stores all Sections for the child sub page.
|
||||
|
@ -35,7 +35,7 @@ abstract class Footnotes_Layout_Engine {
|
|||
* @since 1.5.0
|
||||
* @var array
|
||||
*/
|
||||
protected $sections = array();
|
||||
protected $a_arr_sections = array();
|
||||
|
||||
/**
|
||||
* Returns a Priority index. Lower numbers have a higher Priority.
|
||||
|
@ -81,18 +81,18 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Returns an array describing a sub page section.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @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.
|
||||
* @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.
|
||||
* @return array Array describing the section.
|
||||
*/
|
||||
protected function add_section( $id, $title, $settings_container_index, $has_submit_button = true ) {
|
||||
protected function add_section( $p_str_id, $p_str_title, $p_int_settings_container_index, $p_bool_has_submit_button = true ) {
|
||||
return array(
|
||||
'id' => Footnotes_Config::PLUGIN_NAME . '-' . $id,
|
||||
'title' => $title,
|
||||
'submit' => $has_submit_button,
|
||||
'container' => $settings_container_index,
|
||||
'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,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -100,18 +100,18 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Returns an array describing a meta box.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @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.
|
||||
* @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.
|
||||
* @return array meta box description to be able to append a meta box to the output.
|
||||
*/
|
||||
protected function add_meta_box( $section_id, $id, $title, $callback_function_name ) {
|
||||
protected function add_meta_box( $p_str_section_id, $p_str_id, $p_str_title, $p_str_callback_function_name ) {
|
||||
return array(
|
||||
'parent' => Footnotes_Config::PLUGIN_NAME . '-' . $section_id,
|
||||
'id' => $id,
|
||||
'title' => $title,
|
||||
'callback' => $callback_function_name,
|
||||
'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,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -123,20 +123,20 @@ abstract class Footnotes_Layout_Engine {
|
|||
public function register_sub_page() {
|
||||
global $submenu;
|
||||
|
||||
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() );
|
||||
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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->sub_page_hook = add_submenu_page(
|
||||
Footnotes_Layout_Init::MAIN_MENU_SLUG,
|
||||
$this->a_str_sub_page_hook = add_submenu_page(
|
||||
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG,
|
||||
$this->get_sub_page_title(),
|
||||
$this->get_sub_page_title(),
|
||||
'manage_options',
|
||||
Footnotes_Layout_Init::MAIN_MENU_SLUG . $this->get_sub_page_slug(),
|
||||
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug(),
|
||||
array( $this, 'display_content' )
|
||||
);
|
||||
}
|
||||
|
@ -147,16 +147,16 @@ abstract class Footnotes_Layout_Engine {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sections() {
|
||||
foreach ( $this->get_sections() as $section ) {
|
||||
foreach ( $this->get_sections() as $l_arr_section ) {
|
||||
// Append tab to the tab-array.
|
||||
$this->sections[ $section['id'] ] = $section;
|
||||
$this->a_arr_sections[ $l_arr_section['id'] ] = $l_arr_section;
|
||||
add_settings_section(
|
||||
$section['id'],
|
||||
$l_arr_section['id'],
|
||||
'',
|
||||
array( $this, 'Description' ),
|
||||
$section['id']
|
||||
$l_arr_section['id']
|
||||
);
|
||||
$this->register_meta_boxes( $section['id'] );
|
||||
$this->register_meta_boxes( $l_arr_section['id'] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,19 +164,19 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Registers all Meta boxes for a sub page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $parent_id Parent section unique id.
|
||||
* @param string $p_str_parent_id Parent section unique id.
|
||||
*/
|
||||
private function register_meta_boxes( $parent_id ) {
|
||||
private function register_meta_boxes( $p_str_parent_id ) {
|
||||
// Iterate through each meta box.
|
||||
foreach ( $this->get_meta_boxes() as $meta_box ) {
|
||||
if ( $parent_id !== $meta_box['parent'] ) {
|
||||
foreach ( $this->get_meta_boxes() as $l_arr_meta_box ) {
|
||||
if ( $p_str_parent_id !== $l_arr_meta_box['parent'] ) {
|
||||
continue;
|
||||
}
|
||||
add_meta_box(
|
||||
$parent_id . '-' . $meta_box['id'],
|
||||
$meta_box['title'],
|
||||
array( $this, $meta_box['callback'] ),
|
||||
$parent_id,
|
||||
$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,
|
||||
'main'
|
||||
);
|
||||
}
|
||||
|
@ -211,11 +211,11 @@ abstract class Footnotes_Layout_Engine {
|
|||
*/
|
||||
if ( true === PRODUCTION_ENV ) {
|
||||
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), FOOTNOTES_VERSION );
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), C_STR_FOOTNOTES_VERSION );
|
||||
|
||||
} else {
|
||||
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.css' ), array(), FOOTNOTES_VERSION );
|
||||
wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.css' ), array(), C_STR_FOOTNOTES_VERSION );
|
||||
|
||||
}
|
||||
|
||||
|
@ -234,17 +234,17 @@ abstract class Footnotes_Layout_Engine {
|
|||
// TODO: add nonce verification.
|
||||
|
||||
// Get the current section.
|
||||
reset( $this->sections );
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
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 ];
|
||||
|
||||
// Store settings.
|
||||
$settings_updated = false;
|
||||
$l_bool_settings_updated = false;
|
||||
if ( array_key_exists( 'save-settings', $_POST ) ) {
|
||||
if ( 'save' === $_POST['save-settings'] ) {
|
||||
unset( $_POST['save-settings'] );
|
||||
unset( $_POST['submit'] );
|
||||
$settings_updated = $this->save_settings();
|
||||
$l_bool_settings_updated = $this->save_settings();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,19 +252,19 @@ abstract class Footnotes_Layout_Engine {
|
|||
echo '<div class="wrap">';
|
||||
echo '<h2 class="nav-tab-wrapper">';
|
||||
// Iterate through all register sections.
|
||||
foreach ( $this->sections as $id => $description ) {
|
||||
$tab_active = ( $id === $active_section['id'] ) ? ' nav-tab-active' : '';
|
||||
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' : '';
|
||||
echo sprintf(
|
||||
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
|
||||
( $id === $active_section['id'] ) ? ' nav-tab-active' : '',
|
||||
Footnotes_Layout_Init::MAIN_MENU_SLUG,
|
||||
$id,
|
||||
$description['title']
|
||||
( $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']
|
||||
);
|
||||
}
|
||||
echo '</h2><br/>';
|
||||
|
||||
if ( $settings_updated ) {
|
||||
if ( $l_bool_settings_updated ) {
|
||||
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) );
|
||||
}
|
||||
|
||||
|
@ -272,11 +272,11 @@ abstract class 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( $active_section['id'] );
|
||||
do_meta_boxes( $active_section['id'], 'main', null );
|
||||
do_settings_sections( $l_arr_active_section['id'] );
|
||||
do_meta_boxes( $l_arr_active_section['id'], 'main', null );
|
||||
|
||||
// Add submit button to active section if defined.
|
||||
if ( $active_section['submit'] ) {
|
||||
if ( $l_arr_active_section['submit'] ) {
|
||||
submit_button();
|
||||
}
|
||||
echo '</form>';
|
||||
|
@ -287,7 +287,7 @@ abstract class 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->sub_page_hook . "');";
|
||||
echo "postboxes.add_postbox_toggles('" . $this->a_str_sub_page_hook . "');";
|
||||
echo '});';
|
||||
echo '</script>';
|
||||
}
|
||||
|
@ -301,25 +301,25 @@ abstract class Footnotes_Layout_Engine {
|
|||
* @return bool
|
||||
*/
|
||||
private function save_settings() {
|
||||
$new_settings = array();
|
||||
$l_arr_new_settings = array();
|
||||
|
||||
// TODO: add nonce verification.
|
||||
|
||||
// Get current section.
|
||||
reset( $this->sections );
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
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 ];
|
||||
|
||||
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 ] );
|
||||
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 ] );
|
||||
} else {
|
||||
// Setting is not defined in the POST array, define it to avoid the Default value.
|
||||
$new_settings[ $key ] = '';
|
||||
$l_arr_new_settings[ $l_str_key ] = '';
|
||||
}
|
||||
}
|
||||
// Update settings.
|
||||
return Footnotes_Settings::instance()->save_options( $active_section['container'], $new_settings );
|
||||
return MCI_Footnotes_Settings::instance()->save_options( $l_arr_active_section['container'], $l_arr_new_settings );
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
|
||||
|
@ -336,7 +336,7 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Loads specific setting and returns an array with the keys [id, name, value].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $setting_key_name Settings Array key name.
|
||||
* @param string $p_str_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 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( $setting_key_name ) {
|
||||
protected function load_setting( $p_str_setting_key_name ) {
|
||||
// Get current section.
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,23 +388,23 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Returns a simple text inside html <span> text.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $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
|
||||
*/
|
||||
protected function add_text( $text ) {
|
||||
return sprintf( '<span>%s</span>', $text );
|
||||
protected function add_text( $p_str_text ) {
|
||||
return sprintf( '<span>%s</span>', $p_str_text );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html tag for an input/select label.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $setting_name Name of the Settings key to connect the Label with the input/select field.
|
||||
* @param string $caption Label caption.
|
||||
* @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.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_label( $setting_name, $caption ) {
|
||||
if ( empty( $caption ) ) {
|
||||
protected function add_label( $p_str_setting_name, $p_str_caption ) {
|
||||
if ( empty( $p_str_caption ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -418,34 +418,34 @@ abstract class 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>', $setting_name, $caption );
|
||||
return sprintf( '<label for="%s">%s</label>', $p_str_setting_name, $p_str_caption );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the html tag for an input [type = text].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @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.
|
||||
* @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.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_text_box( $setting_name, $max_length = 999, $readonly = false, $hidden = false ) {
|
||||
$style = '';
|
||||
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 = '';
|
||||
// Collect data for given settings field.
|
||||
$data = $this->load_setting( $setting_name );
|
||||
if ( $hidden ) {
|
||||
$style .= 'display:none;';
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
if ( $p_bool_hidden ) {
|
||||
$l_str_style .= 'display:none;';
|
||||
}
|
||||
return sprintf(
|
||||
'<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s" %s/>',
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$max_length,
|
||||
$style,
|
||||
$data['value'],
|
||||
$readonly ? 'readonly="readonly"' : ''
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$p_str_max_length,
|
||||
$l_str_style,
|
||||
$l_arr_data['value'],
|
||||
$p_bool_readonly ? 'readonly="readonly"' : ''
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -453,17 +453,17 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Returns the html tag for an input [type = checkbox].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $setting_name Name of the Settings key to pre load the input field.
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_checkbox( $setting_name ) {
|
||||
protected function add_checkbox( $p_str_setting_name ) {
|
||||
// Collect data for given settings field.
|
||||
$data = $this->load_setting( $setting_name );
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
return sprintf(
|
||||
'<input type="checkbox" name="%s" id="%s" %s/>',
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
Footnotes_Convert::to_bool( $data['value'] ) ? 'checked="checked"' : ''
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
MCI_Footnotes_Convert::to_bool( $l_arr_data['value'] ) ? 'checked="checked"' : ''
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -477,33 +477,33 @@ abstract class Footnotes_Layout_Engine {
|
|||
* @reporter @lolzim
|
||||
*
|
||||
* @since 2.5.13
|
||||
* @param string $setting_name Name of the Settings key to pre select the current value.
|
||||
* @param array $options Possible options to be selected.
|
||||
* @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.
|
||||
* @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( $setting_name, $options ) {
|
||||
protected function add_select_box( $p_str_setting_name, $p_arr_options ) {
|
||||
// Collect data for given settings field.
|
||||
$data = $this->load_setting( $setting_name );
|
||||
$select_options = '';
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
$l_str_options = '';
|
||||
|
||||
// Loop through all array keys.
|
||||
foreach ( $options as $value => $caption ) {
|
||||
$select_options .= sprintf(
|
||||
foreach ( $p_arr_options as $l_str_value => $l_str_caption ) {
|
||||
$l_str_options .= sprintf(
|
||||
'<option value="%s" %s>%s</option>',
|
||||
$value,
|
||||
$l_str_value,
|
||||
// Only check for equality, not identity, WRT backlink symbol arrows.
|
||||
$value == $data['value'] ? 'selected' : '',
|
||||
$caption
|
||||
$l_str_value == $l_arr_data['value'] ? 'selected' : '',
|
||||
$l_str_caption
|
||||
);
|
||||
}
|
||||
return sprintf(
|
||||
'<select name="%s" id="%s">%s</select>',
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$select_options
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_str_options
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -511,17 +511,17 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Returns the html tag for a text area.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $setting_name Name of the Settings key to pre fill the text area.
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre fill the text area.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_textarea( $setting_name ) {
|
||||
protected function add_textarea( $p_str_setting_name ) {
|
||||
// Collect data for given settings field.
|
||||
$data = $this->load_setting( $setting_name );
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
return sprintf(
|
||||
'<textarea name="%s" id="%s">%s</textarea>',
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$data['value']
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_arr_data['value']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -529,17 +529,17 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Returns the html tag for an input [type = text] with color selection class.
|
||||
*
|
||||
* @since 1.5.6
|
||||
* @param string $setting_name Name of the Settings key to pre load the input field.
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
|
||||
* @return string
|
||||
*/
|
||||
protected function add_color_selection( $setting_name ) {
|
||||
protected function add_color_selection( $p_str_setting_name ) {
|
||||
// Collect data for given settings field.
|
||||
$data = $this->load_setting( $setting_name );
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
return sprintf(
|
||||
'<input type="text" name="%s" id="%s" class="footnotes-color-picker" value="%s"/>',
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$data['value']
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_arr_data['value']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -547,37 +547,37 @@ abstract class Footnotes_Layout_Engine {
|
|||
* Returns the html tag for an input [type = num].
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @param string $setting_name Name of the Settings key to pre load the input field.
|
||||
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
|
||||
* @param int $p_in_min Minimum value.
|
||||
* @param int $max Maximum value.
|
||||
* @param bool $deci true if 0.1 steps and floating to string, false if integer (default).
|
||||
* @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).
|
||||
* @return string
|
||||
*
|
||||
* Edited:
|
||||
* @since 2.1.4 step argument and number_format() to allow decimals ..
|
||||
*/
|
||||
protected function add_num_box( $setting_name, $p_in_min, $max, $deci = false ) {
|
||||
protected function add_num_box( $p_str_setting_name, $p_in_min, $p_int_max, $p_bool_deci = false ) {
|
||||
// Collect data for given settings field.
|
||||
$data = $this->load_setting( $setting_name );
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
|
||||
if ( $deci ) {
|
||||
$value = number_format( floatval( $data['value'] ), 1 );
|
||||
if ( $p_bool_deci ) {
|
||||
$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"/>',
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$value,
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_str_value,
|
||||
$p_in_min,
|
||||
$max
|
||||
$p_int_max
|
||||
);
|
||||
} else {
|
||||
return sprintf(
|
||||
'<input type="number" name="%s" id="%s" value="%d" min="%d" max="%d"/>',
|
||||
$data['name'],
|
||||
$data['id'],
|
||||
$data['value'],
|
||||
$l_arr_data['name'],
|
||||
$l_arr_data['id'],
|
||||
$l_arr_data['value'],
|
||||
$p_in_min,
|
||||
$max
|
||||
$p_int_max
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue