Fix code quality issues and WordPress naming conventions
This commit is contained in:
8
.github/workflows/wordpress-tests.yml
vendored
8
.github/workflows/wordpress-tests.yml
vendored
@@ -73,10 +73,10 @@ jobs:
|
||||
MYSQL_USER: wordpress
|
||||
MYSQL_PASSWORD: wordpress
|
||||
options: >
|
||||
--health-cmd="mysqladmin ping"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=3
|
||||
--health-cmd "mysqladmin ping"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 3
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -36,7 +36,7 @@ class Multisite {
|
||||
*
|
||||
* @return bool Always returns true.
|
||||
*/
|
||||
public function isMultisiteCompatible() {
|
||||
public function is_multisite_compatible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class Multisite {
|
||||
*
|
||||
* @return array An empty array as this is just a placeholder.
|
||||
*/
|
||||
public function getNetworkSites() {
|
||||
public function get_network_sites() {
|
||||
// This is just a placeholder method.
|
||||
// In a real implementation, you might use get_sites() or a custom query.
|
||||
return function_exists( 'get_sites' ) ? get_sites( array( 'public' => 1 ) ) : array();
|
||||
|
||||
@@ -83,7 +83,7 @@ class Plugin {
|
||||
*
|
||||
* @return string The plugin version.
|
||||
*/
|
||||
public function getVersion(): string {
|
||||
public function get_version(): string {
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class Plugin {
|
||||
*
|
||||
* @return Admin The admin instance.
|
||||
*/
|
||||
public function getAdmin(): Admin {
|
||||
public function get_admin(): Admin {
|
||||
return $this->admin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,32 +41,34 @@ define( 'WP_PLUGIN_STARTER_TEMPLATE_VERSION', '0.1.13' );
|
||||
use WPALLSTARS\PluginStarterTemplate\Plugin;
|
||||
|
||||
// Register autoloader for plugin classes.
|
||||
spl_autoload_register( function ( $class ) {
|
||||
// Plugin namespace prefix
|
||||
spl_autoload_register(
|
||||
function ( $className ) {
|
||||
// Plugin namespace prefix.
|
||||
$prefix = 'WPALLSTARS\\PluginStarterTemplate\\';
|
||||
|
||||
// Check if the class uses our namespace
|
||||
// Check if the class uses our namespace.
|
||||
$len = strlen( $prefix );
|
||||
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
|
||||
if ( strncmp( $prefix, $className, $len ) !== 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the relative class name
|
||||
$relative_class = substr( $class, $len );
|
||||
// Get the relative class name.
|
||||
$relative_class = substr( $className, $len );
|
||||
|
||||
// Convert namespace to path
|
||||
// Convert namespace to path.
|
||||
$file = WP_PLUGIN_STARTER_TEMPLATE_PATH . 'includes/' . str_replace( '\\', '/', $relative_class ) . '.php';
|
||||
|
||||
// Convert class name format to file name format
|
||||
// Convert class name format to file name format.
|
||||
$file = str_replace( 'class-', '', $file );
|
||||
$file = preg_replace( '/([a-z])([A-Z])/', '$1-$2', $file );
|
||||
$file = strtolower( $file );
|
||||
|
||||
// If the file exists, require it
|
||||
// If the file exists, require it.
|
||||
if ( file_exists( $file ) ) {
|
||||
require_once $file;
|
||||
}
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
// Plugin is multisite compatible - see .wiki/Testing-Framework.md for testing instructions.
|
||||
// For multisite-specific functionality, see the includes/Multisite directory.
|
||||
|
||||
Reference in New Issue
Block a user