PLUGIN_NAME_VERSION, 'db_version' => PLUGIN_NAME_DB_VERSION, ); add_option( 'nmsp_plugin_metadata', $plugin_metadata ); } /** * Any logic that needs executed when the plugin is deactivated. * * @since 1.0.0 * * @return void */ public static function plugin_deactivation(): void { // } /** * Check that the cache directory for Blade exists and * if not then attempt to create it. * * @since 1.0.0 * * @throws \Exception * * @return void */ public static function ensure_template_cache_dir_exists(): void { if ( ! file_exists( NMSP_PLUGIN_BASE_DIR . '/cache/blade/.gitignore' ) ) { try { mkdir( NMSP_PLUGIN_BASE_DIR . '/cache/blade', 0755, true ); } catch ( Exception $e ) { $error_payload = array( 'level' => 'critical', 'message' => $e->getMessage(), 'context' => array( 'file' => $e->getFile(), 'line' => $e->getLine(), ), ); error_log( json_encode( $error_payload, JSON_PRETTY_PRINT ) ); } } } /** * Return an instance of this plugin class. If it has * not been initialized, do so then return it. * * @since 1.0.0 * * @return \PluginNamespace\App */ public static function get_instance(): App { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof App ) ) { self::$instance = new App(); self::$instance->load_plugin_textdomain(); self::$instance->scaffold_plugin(); self::$instance->includes(); } return self::$instance; } /** * Load your translation files for this plugin. * * @since 1.0.0 * * @return void */ public function load_plugin_textdomain(): void { load_plugin_textdomain( 'nmsp-plugin-name-text-domain', false, 'languages' ); } /** * Steps to take when initializing this plugin?? * * @since 1.0.0 * * @return void */ public function scaffold_plugin(): void { if ( is_admin() ) { // admin only logic here } // other logic here } /** * Other files to include so that this plugin will * have a single entrypoint but be able to break * up code in a logical manor. * * @codeCoverageIgnore * * @since 1.0.0 * * @return void */ public function includes(): void { // Files to include on the admin. if ( is_admin() ) { require_once NMSP_PLUGIN_BASE_DIR . '/admin/nmsp-admin-functions.php'; require_once NMSP_PLUGIN_BASE_DIR . '/admin/nmsp-update-functions.php'; require_once NMSP_PLUGIN_BASE_DIR . '/admin/class-adminsettings.php'; } // Files to include on every request. // // Files to include that may be sub-namespaced. require_once __DIR__ . '/front/class-custompage.php'; } /** * Load BladeOne as the templating engine for the plugin. * * @since 1.0.0 * * @param \eftec\bladeone\BladeOne $blade * * @return void */ public function load_blade( BladeOne $blade ): void { $this->blade = $blade; } }