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. * * @package PluginNamespace\App * @since 1.0.0 * * @return void */ public static function plugin_deactivation(): void { // phpcs:disable // phpcs:enable } /** * Check that the cache directory for Blade exists and * if not then attempt to create it. * * @package PluginNamespace\App * @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 $exp ) { $error_payload = array( 'level' => 'critical', 'message' => $exp->getMessage(), 'context' => array( 'file' => $exp->getFile(), 'line' => $exp->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. * * @package PluginNamespace\App * @since 1.0.0 * * @return \PluginNamespace\App */ public static function get_instance(): App { if ( ! ( 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. * * @package PluginNamespace\App * @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?? * * @package PluginNamespace\App * @since 1.0.0 * * @return void */ public function scaffold_plugin(): void { // phpcs:disable if ( is_admin() ) { // admin only logic here, remove phpcs calls around this } // phpcs:enable // other logic here add_filter( 'network_admin_plugin_action_links_nmsp-plugin-name/nmsp-plugin-name.php', array( $this, 'filter_plugin_action_links' ) ); add_filter( 'plugin_action_links_nmsp-plugin-name/nmsp-plugin-name.php', array( $this, 'filter_plugin_action_links' ) ); } /** * 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 * * @package PluginNamespace\App * @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'; } /** * Description. * * @package PluginNamespace\App * @since 1.0.0 * * @param array $actions * * @return array */ public function filter_plugin_action_links( array $actions = array() ): array { $plugin_settings_url = admin_url( 'admin.php?page=nmsp-plugin-name-menu-slug' ); return array_merge( array( 'settings' => '' . esc_html__( 'Settings', 'nmsp-plugin-name-text-domain' ) . '', ), $actions ); } /** * Load BladeOne as the templating engine for the plugin. * * @package PluginNamespace\App * @since 1.0.0 * * @param \eftec\bladeone\BladeOne $blade * * @return void */ public function load_blade( BladeOne $blade ): void { $this->blade = $blade; } }