@@ -77,27 +77,14 @@ function classifai_define( $name, $value ) {
77
77
require_once __DIR__ . '/config.php ' ;
78
78
79
79
/**
80
- * Loads the CLASSIFAI PHP autoloader if possible.
80
+ * Loads the autoloader if possible.
81
81
*
82
82
* @return bool True or false if autoloading was successful.
83
83
*/
84
84
function classifai_autoload () {
85
- if ( classifai_can_autoload () ) {
86
- require_once classifai_autoloader ();
87
-
88
- return true ;
89
- } else {
90
- return false ;
91
- }
92
- }
85
+ if ( file_exists ( CLASSIFAI_PLUGIN_DIR . '/vendor/autoload.php ' ) ) {
86
+ require_once CLASSIFAI_PLUGIN_DIR . '/vendor/autoload.php ' ;
93
87
94
- /**
95
- * In server mode we can autoload if autoloader file exists. For
96
- * test environments we prevent autoloading of the plugin to prevent
97
- * global pollution and for better performance.
98
- */
99
- function classifai_can_autoload () {
100
- if ( file_exists ( classifai_autoloader () ) ) {
101
88
return true ;
102
89
} else {
103
90
error_log ( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
@@ -108,32 +95,19 @@ function classifai_can_autoload() {
108
95
}
109
96
}
110
97
111
- /**
112
- * Default is Composer's autoloader
113
- */
114
- function classifai_autoloader () {
115
- if ( file_exists ( CLASSIFAI_PLUGIN_DIR . '/vendor/autoload.php ' ) ) {
116
- return CLASSIFAI_PLUGIN_DIR . '/vendor/autoload.php ' ;
117
- } else {
118
- return CLASSIFAI_PLUGIN_DIR . '/autoload.php ' ;
119
- }
120
- }
121
-
122
98
/**
123
99
* Gets the installation message error.
124
100
*
125
- * This was put in a function specifically because it's used both in WP-CLI and within an admin notice if not using
126
- * WP-CLI.
101
+ * Used both in a WP-CLI context and within an admin notice.
127
102
*
128
103
* @return string
129
104
*/
130
105
function get_error_install_message () {
131
- return esc_html__ ( 'Error: Please run $ composer install in the classifai plugin directory. ' , 'classifai ' );
106
+ return esc_html__ ( 'Error: Please run $ composer install in the ClassifAI plugin directory. ' , 'classifai ' );
132
107
}
133
108
134
109
/**
135
- * Plugin code entry point. Singleton instance is used to maintain a common single
136
- * instance of the plugin throughout the current request's lifecycle.
110
+ * Plugin code entry point.
137
111
*
138
112
* If autoloading failed an admin notice is shown and logged to
139
113
* the PHP error_log.
@@ -159,7 +133,6 @@ function classifai_autorun() {
159
133
}
160
134
}
161
135
162
-
163
136
/**
164
137
* Generate a notice if autoload fails.
165
138
*/
@@ -168,9 +141,8 @@ function classifai_autoload_notice() {
168
141
error_log ( get_error_install_message () ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
169
142
}
170
143
171
-
172
144
/**
173
- * Register an activation hook that we can hook into .
145
+ * Run functionality on plugin activation .
174
146
*/
175
147
function classifai_activation () {
176
148
set_transient ( 'classifai_activation_notice ' , 'classifai ' , HOUR_IN_SECONDS );
0 commit comments