admin-site-enhancements
Last commit date
assets
2 years ago
classes
2 years ago
includes
2 years ago
vendor
2 years ago
LICENSE.md
2 years ago
README.md
2 years ago
admin-site-enhancements.php
2 years ago
bootstrap.php
2 years ago
functions.php
2 years ago
settings.php
2 years ago
admin-site-enhancements.php
112 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Plugin Name: Admin and Site Enhancements (ASE) |
| 5 | * Plugin URI: https://www.wpase.com/plugin-uri |
| 6 | * Description: Easily enable enhancements and features that usually require multiple plugins. |
| 7 | * Version: 6.2.2 |
| 8 | * Author: wpase.com |
| 9 | * Author URI: https://www.wpase.com/author-uri |
| 10 | * License: GPL-2.0+ |
| 11 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 12 | * Text Domain: admin-site-enhancements |
| 13 | * Domain Path: /languages |
| 14 | * |
| 15 | */ |
| 16 | // If this file is called directly, abort. |
| 17 | if ( !defined( 'ABSPATH' ) ) { |
| 18 | exit; |
| 19 | } |
| 20 | |
| 21 | define( 'ASENHA_VERSION', '6.2.2' ); |
| 22 | define( 'ASENHA_ID', 'asenha' ); |
| 23 | define( 'ASENHA_SLUG', 'admin-site-enhancements' ); |
| 24 | define( 'ASENHA_SLUG_U', 'admin_site_enhancements' ); |
| 25 | define( 'ASENHA_URL', plugins_url( '/', __FILE__ ) ); // e.g. https://www.example.com/wp-content/plugins/this-plugin/ |
| 26 | define( 'ASENHA_PATH', plugin_dir_path( __FILE__ ) ); // e.g. /home/user/apps/wp-root/wp-content/plugins/this-plugin/ |
| 27 | // define( 'ASENHA_BASE', plugin_basename( __FILE__ ) ); // e.g. plugin-slug/this-file.php |
| 28 | // define( 'ASENHA_FILE', __FILE__ ); // /home/user/apps/wp-root/wp-content/plugins/this-plugin/this-file.php |
| 29 | |
| 30 | /** |
| 31 | * Autoload classes defined by this plugin |
| 32 | * |
| 33 | * @param string $class_name e.g. \ASENHA\Classes\The_Name |
| 34 | * @since 1.0.0 |
| 35 | */ |
| 36 | function asenha_autoloader( $class_name ) { |
| 37 | |
| 38 | $namespace = 'ASENHA'; |
| 39 | |
| 40 | // Only process classes within this plugin's namespace |
| 41 | |
| 42 | if ( false !== strpos( $class_name, $namespace ) ) { |
| 43 | |
| 44 | // Assemble file path where class is defined |
| 45 | |
| 46 | // \ASENHA\Classes\The_Name => \Classes\The_Name |
| 47 | $path = str_replace( $namespace, "", $class_name ); |
| 48 | |
| 49 | // \Classes\The_Name => /classes/the_name |
| 50 | $path = str_replace( "\\", DIRECTORY_SEPARATOR, strtolower( $path ) ); |
| 51 | |
| 52 | // /classes/the_name => /classes/the-name.php |
| 53 | $path = str_replace( "_", "-", $path ) . '.php'; |
| 54 | |
| 55 | // /classes/the-name.php => /classes/class-the-name.php |
| 56 | $path = str_replace( "classes" . DIRECTORY_SEPARATOR, "classes" . DIRECTORY_SEPARATOR . "class-", $path ); |
| 57 | |
| 58 | // Remove first '/' |
| 59 | $path = substr( $path, 1 ); |
| 60 | |
| 61 | // Get /plugin-path/classes/class-the-name.php |
| 62 | $path = ASENHA_PATH . $path; |
| 63 | |
| 64 | if ( file_exists( $path ) ) { |
| 65 | require_once( $path ); |
| 66 | } |
| 67 | |
| 68 | } |
| 69 | |
| 70 | } |
| 71 | |
| 72 | // Register autoloading classes |
| 73 | spl_autoload_register( 'asenha_autoloader' ); |
| 74 | |
| 75 | /** |
| 76 | * Code that runs on plugin activation |
| 77 | * |
| 78 | * @since 1.0.0 |
| 79 | */ |
| 80 | function asenha_on_activation() { |
| 81 | $activation = new ASENHA\Classes\Activation; |
| 82 | $activation->create_failed_logins_log_table(); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Code that runs on plugin deactivation |
| 87 | * |
| 88 | * @since 1.0.0 |
| 89 | */ |
| 90 | function asenha_on_deactivation() { |
| 91 | $deactivation = new ASENHA\Classes\Deactivation; |
| 92 | $deactivation->delete_failed_logins_log_table(); |
| 93 | } |
| 94 | |
| 95 | // Register code that runs on plugin activation |
| 96 | register_activation_hook( __FILE__, 'asenha_on_activation'); |
| 97 | |
| 98 | // Register code that runs on plugin deactivation |
| 99 | register_deactivation_hook( __FILE__, 'asenha_on_deactivation' ); |
| 100 | |
| 101 | // Functions for setting up admin menu, admin page, the settings sections and fields and other fondational stuff |
| 102 | require_once ASENHA_PATH . 'settings.php'; |
| 103 | |
| 104 | // Other required functions |
| 105 | require_once ASENHA_PATH . 'functions.php'; |
| 106 | |
| 107 | // Load vendor libraries |
| 108 | require_once ASENHA_PATH . 'vendor/autoload.php'; |
| 109 | |
| 110 | // Bootstrap all the functionalities of this plugin |
| 111 | require_once ASENHA_PATH . 'bootstrap.php'; |
| 112 |