This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
footnotes/class/widgets/reference-container.php
Ben Goldsworthy 1284544556 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
2021-04-16 23:55:05 +01:00

79 lines
2 KiB
PHP

<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.EscapeOutput.OutputNotEscaped
/**
* Includes the Plugin Widget to put the Reference Container to the Widget area.
*
* @filesource
* @package footnotes
* @since 1.5.0
*/
/**
* Registers a Widget to put the Reference Container to the widget area.
*
* @since 1.5.0
*/
class Footnotes_Widget_Reference_Container extends Footnotes_Widget_Base {
/**
* Returns an unique ID as string used for the Widget Base ID.
*
* @since 1.5.0
* @return string
*/
protected function get_id() {
return 'footnotes_widget';
}
/**
* Returns the Public name of the Widget to be displayed in the Configuration page.
*
* @since 1.5.0
* @return string
*/
protected function get_name() {
return Footnotes_Config::PLUGIN_NAME;
}
/**
* Returns the Description of the child widget.
*
* @since 1.5.0
* @return string
*
* Edit: curly quotes 2.2.0
*/
protected function get_description() {
return __( 'The widget defines the position of the reference container if set to “widget area”.', 'footnotes' );
}
/**
* Outputs the Settings of the Widget.
*
* @since 1.5.0
* @param mixed $instance The instance of the widget.
* @return void
*
* Edit: curly quotes 2.2.0
*/
public function form( $instance ) {
echo __( 'The widget defines the position of the reference container if set to “widget area”.', 'footnotes' );
}
/**
* Outputs the Content of the Widget.
*
* @since 1.5.0
* @param mixed $args The widget's arguments.
* @param mixed $instance The instance of the widget.
*/
public function widget( $args, $instance ) {
global $g_obj_mci_footnotes;
// Reference container positioning is set to "widget area".
if ( 'widget' === Footnotes_Settings::instance()->get( Footnotes_Settings::REFERENCE_CONTAINER_POSITION ) ) {
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $g_obj_mci_footnotes->task->reference_container();
// phpcs:enable
}
}
}