\Classes\The_Name $path = str_replace( $namespace, "", $class_name ); // \Classes\The_Name => /classes/the_name $path = str_replace( "\\", DIRECTORY_SEPARATOR, strtolower( $path ) ); // /classes/the_name => /classes/the-name.php $path = str_replace( "_", "-", $path ) . '.php'; // /classes/the-name.php => /classes/class-the-name.php $path = str_replace( "classes" . DIRECTORY_SEPARATOR, "classes" . DIRECTORY_SEPARATOR . "class-", $path ); // Remove first '/' $path = substr( $path, 1 ); // Get /plugin-path/classes/class-the-name.php $path = ASENHA_PATH . $path; if ( file_exists( $path ) ) { require_once( $path ); } } } // Register autoloading classes spl_autoload_register( 'asenha_autoloader' ); /** * Code that runs on plugin activation * * @since 1.0.0 */ function asenha_on_activation() { $activation = new ASENHA\Classes\Activation; $activation->create_failed_logins_log_table(); $options = get_option( ASENHA_SLUG_U, array() ); if ( array_key_exists( 'disable_embeds', $options ) && $options['disable_embeds'] ) { $options['disable_embeds_flush_rewrite_rules_needed'] = true; } update_option( ASENHA_SLUG_U, $options, true ); } /** * Code that runs on plugin deactivation * * @since 1.0.0 */ function asenha_on_deactivation() { $deactivation = new ASENHA\Classes\Deactivation; $deactivation->clear_failed_login_attempts_log_cleanup_schedule(); $deactivation->delete_failed_logins_log_table(); $options = get_option( ASENHA_SLUG_U, array() ); if ( array_key_exists( 'disable_embeds', $options ) && $options['disable_embeds'] ) { $deactivation->disable_embeds_flush_rewrite_rules(); } } // Register code that runs on plugin activation register_activation_hook( __FILE__, 'asenha_on_activation'); // Register code that runs on plugin deactivation register_deactivation_hook( __FILE__, 'asenha_on_deactivation' ); // Load translations function asenha_free_load_textdomain() { load_plugin_textdomain( 'admin-site-enhancements', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } add_action( 'init', 'asenha_free_load_textdomain' ); // https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/ // Use when tracing which code is triggering the "_load_textdomain_just_in_time Called Incorrectly" notice // add_action( // 'doing_it_wrong_run', // static function ( $function_name ) { // if ( '_load_textdomain_just_in_time' === $function_name ) { // debug_print_backtrace(); // } // } // ); // Functions for setting up admin menu, admin page, the settings sections and fields and other fondational stuff require_once ASENHA_PATH . 'settings.php'; // Other required functions require_once ASENHA_PATH . 'functions.php'; // Load vendor libraries // require_once ASENHA_PATH . 'vendor/autoload.php'; // Bootstrap all the functionalities of this plugin require_once ASENHA_PATH . 'bootstrap.php';