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/includes.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

40 lines
1.1 KiB
PHP

<?php
/**
* Includes all common files.
*
* @filesource
* @package footnotes
* @since 1.5.0 14.09.14 13:40
*/
/**
* Requires (`require_once`) all `*.php` files inside a specific Directory.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $directory Absolute Directory path to lookup for `*.php` files.
*/
function mci_footnotes_require_php_files( $directory ) {
// Append slash at the end of the Directory if not exist.
if ( '/' !== substr( $directory, -1 ) ) {
$directory .= '/';
}
// Get all PHP files inside Directory.
$files = scandir( $directory );
// Iterate through each class.
foreach ( $files as $file_name ) {
// Skip all non-PHP files.
if ( '.php' !== strtolower( substr( $file_name, -4 ) ) ) {
continue;
}
// phpcs:disable Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpIncludeInspection */
require_once $directory . $file_name;
// phpcs:enable
}
}
mci_footnotes_require_php_files( dirname( __FILE__ ) . '/class' );
mci_footnotes_require_php_files( dirname( __FILE__ ) . '/class/dashboard' );
mci_footnotes_require_php_files( dirname( __FILE__ ) . '/class/widgets' );