Files
wp-plugin-starter-template-…/wp-plugin-starter-template.php
Marcus Quinn 1c1980bb22 chore: improve workflow names and fix CSS indentation consistency (#18)
* fix: resolve plugin class loading reliability issues

* fix: address CodeRabbit XSS and accessibility findings from PR #18

- admin/js/admin-scripts.js: replace HTML string interpolation in showNotice
  with DOM API construction and .text() to prevent XSS; whitelist type values
- admin/js/update-source-selector.js: replace .html(message) with .text(message)
  in showMessage to prevent XSS from AJAX response content
- admin/templates/modal.php: add role=dialog, aria-modal=true, aria-labelledby
  for screen reader semantics; replace <span> close control with <button> for
  keyboard operability and proper ARIA role
2026-03-16 18:40:09 +00:00

87 lines
3.0 KiB
PHP

<?php
/**
* Plugin Name: WordPress Plugin Starter Template
* Plugin URI: https://www.wpallstars.com
* Description: A comprehensive starter template for WordPress plugins with best practices for AI-assisted development.
* Version: 0.1.15
* Author: Your Name & The WPALLSTARS Team
* Author URI: https://www.wpallstars.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: wp-plugin-starter-template
* Domain Path: /languages
* GitHub Plugin URI: wpallstars/wp-plugin-starter-template-for-ai-coding
* GitHub Branch: main
* Primary Branch: main
* Release Branch: main
* Release Asset: true
* Requires at least: 5.0
* Requires PHP: 7.4
* Update URI: https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding
*
* Gitea Plugin URI: https://gitea.wpallstars.com/wpallstars/wp-plugin-starter-template-for-ai-coding
* Gitea Branch: main
* Gitea Languages: languages
*
* @package WPALLSTARS\PluginStarterTemplate
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// Define plugin constants.
define( 'WP_PLUGIN_STARTER_TEMPLATE_FILE', __FILE__ );
define( 'WP_PLUGIN_STARTER_TEMPLATE_PATH', plugin_dir_path( __FILE__ ) );
define( 'WP_PLUGIN_STARTER_TEMPLATE_URL', plugin_dir_url( __FILE__ ) );
define( 'WP_PLUGIN_STARTER_TEMPLATE_VERSION', '0.1.15' );
// Use namespace imports instead of require_once.
use WPALLSTARS\PluginStarterTemplate\Plugin;
// Register autoloader for plugin classes.
spl_autoload_register(
function ( $className ) {
// Plugin namespace prefix.
$prefix = 'WPALLSTARS\\PluginStarterTemplate\\';
// Check if the class uses our namespace.
$len = strlen( $prefix );
if ( strncmp( $prefix, $className, $len ) !== 0 ) {
return;
}
// Get the relative class name.
$relative_class = substr( $className, $len );
// Build class file path using WordPress-style class file names.
$relative_path = str_replace( '\\', '/', $relative_class );
$path_parts = explode( '/', $relative_path );
$class_name = array_pop( $path_parts );
$directory = '';
if ( ! empty( $path_parts ) ) {
$directory = implode( '/', $path_parts ) . '/';
}
$class_file = preg_replace( '/([a-z])([A-Z])/', '$1-$2', $class_name );
$class_file = 'class-' . strtolower( $class_file ) . '.php';
$file = WP_PLUGIN_STARTER_TEMPLATE_PATH . 'includes/' . $directory . $class_file;
// 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.
// Initialize the plugin and store the instance in a global variable.
$wpst_plugin = new Plugin( __FILE__, WP_PLUGIN_STARTER_TEMPLATE_VERSION );
// Initialize the plugin.
$wpst_plugin->init();