PluginProbe
Admin and Site Enhancements (ASE) / 9.0.2
Admin and Site Enhancements (ASE) v9.0.2
9.1.1 9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 All 273 releases
admin-site-enhancements / admin-site-enhancements.php
admin-site-enhancements.php
136 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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: 9.0.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 */
13 // If this file is called directly, abort.
14 if ( !defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 define( 'ASENHA_VERSION', '9.0.2' );
19 define( 'ASENHA_ID', 'asenha' );
20 define( 'ASENHA_SLUG', 'admin-site-enhancements' );
21 define( 'ASENHA_SLUG_U', 'admin_site_enhancements' );
22 define( 'ASENHA_URL', plugins_url( '/', __FILE__ ) ); // e.g. https://www.example.com/wp-content/plugins/this-plugin/
23 define( 'ASENHA_PATH', plugin_dir_path( __FILE__ ) ); // e.g. /home/user/apps/wp-root/wp-content/plugins/this-plugin/
24 // define( 'ASENHA_BASE', plugin_basename( __FILE__ ) ); // e.g. plugin-slug/this-file.php
25 // define( 'ASENHA_FILE', __FILE__ ); // /home/user/apps/wp-root/wp-content/plugins/this-plugin/this-file.php
26
27 /**
28 * Autoload classes defined by this plugin
29 *
30 * @param string $class_name e.g. \ASENHA\Classes\The_Name
31 * @since 1.0.0
32 */
33 function asenha_autoloader( $class_name ) {
34
35 $namespace = 'ASENHA';
36
37 // Only process classes within this plugin's namespace
38
39 if ( false !== strpos( $class_name, $namespace ) ) {
40
41 // Assemble file path where class is defined
42
43 // \ASENHA\Classes\The_Name => \Classes\The_Name
44 $path = str_replace( $namespace, "", $class_name );
45
46 // \Classes\The_Name => /classes/the_name
47 $path = str_replace( "\\", DIRECTORY_SEPARATOR, strtolower( $path ) );
48
49 // /classes/the_name => /classes/the-name.php
50 $path = str_replace( "_", "-", $path ) . '.php';
51
52 // /classes/the-name.php => /classes/class-the-name.php
53 $path = str_replace( "classes" . DIRECTORY_SEPARATOR, "classes" . DIRECTORY_SEPARATOR . "class-", $path );
54
55 // Remove first '/'
56 $path = substr( $path, 1 );
57
58 // Get /plugin-path/classes/class-the-name.php
59 $path = ASENHA_PATH . $path;
60
61 if ( file_exists( $path ) ) {
62 require_once( $path );
63 }
64
65 }
66
67 }
68
69 // Register autoloading classes
70 spl_autoload_register( 'asenha_autoloader' );
71
72 /**
73 * Code that runs on plugin activation
74 *
75 * @since 1.0.0
76 */
77 function asenha_on_activation() {
78 $activation = new ASENHA\Classes\Activation;
79 $activation->create_failed_logins_log_table();
80 $options = get_option( ASENHA_SLUG_U, array() );
81 if ( array_key_exists( 'disable_embeds', $options ) && $options['disable_embeds'] ) {
82 $options['disable_embeds_flush_rewrite_rules_needed'] = true;
83 }
84
85 update_option( ASENHA_SLUG_U, $options, true );
86 }
87
88 /**
89 * Code that runs on plugin deactivation
90 *
91 * @since 1.0.0
92 */
93 function asenha_on_deactivation() {
94 $deactivation = new ASENHA\Classes\Deactivation;
95 $deactivation->clear_failed_login_attempts_log_cleanup_schedule();
96 $deactivation->delete_failed_logins_log_table();
97 $options = get_option( ASENHA_SLUG_U, array() );
98 if ( array_key_exists( 'disable_embeds', $options ) && $options['disable_embeds'] ) {
99 $deactivation->disable_embeds_flush_rewrite_rules();
100 }
101 }
102
103 // Register code that runs on plugin activation
104 register_activation_hook( __FILE__, 'asenha_on_activation');
105
106 // Register code that runs on plugin deactivation
107 register_deactivation_hook( __FILE__, 'asenha_on_deactivation' );
108
109 // Load translations
110 function asenha_free_load_textdomain() {
111 load_plugin_textdomain( 'admin-site-enhancements', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
112 }
113 add_action( 'init', 'asenha_free_load_textdomain' );
114
115 // https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/
116 // Use when tracing which code is triggering the "_load_textdomain_just_in_time Called Incorrectly" notice
117 // add_action(
118 // 'doing_it_wrong_run',
119 // static function ( $function_name ) {
120 // if ( '_load_textdomain_just_in_time' === $function_name ) {
121 // debug_print_backtrace();
122 // }
123 // }
124 // );
125
126 // Functions for setting up admin menu, admin page, the settings sections and fields and other fondational stuff
127 require_once ASENHA_PATH . 'settings.php';
128
129 // Other required functions
130 require_once ASENHA_PATH . 'functions.php';
131
132 // Load vendor libraries
133 // require_once ASENHA_PATH . 'vendor/autoload.php';
134
135 // Bootstrap all the functionalities of this plugin
136 require_once ASENHA_PATH . 'bootstrap.php';