register(); } /** * Register services * * @return void */ public function register() { $services = $this->get_services(); if ( $services ) { foreach ( $services as $service ) { /* * A service file can be absent from an installed copy even though the * list above still names it — an incomplete update, or a file dropped * during a copy. Without this check `new $service()` throws a fatal * Error during plugin bootstrap, which takes down the whole site, * admin included, so the user cannot even deactivate the plugin. * Skip the missing service instead and keep the rest running. */ if ( ! class_exists( $service ) ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log sprintf( 'Aisentic: service class "%s" listed by %s was not found. The plugin install may be incomplete.', $service, static::class ) ); } continue; } $object = new $service(); $object->register(); } } } /** * Get services * * @return array service lists */ abstract public function get_services(); }