' . esc_attr( $text ) . ''; array_unshift( $links, $settings_link ); return $links; } public static function footer_text( $footer_text ) { global $pagenow; if ( $pagenow === 'admin.php' && ( isset( $_GET['page'] ) && $_GET['page'] === WPCoder::SLUG ) ) { $text = sprintf( __( 'Thank you for using %2$s! Please rate us', 'wpcoder' ), esc_url( WPCoder::PluginURL ), esc_attr( WPCoder::info( 'name' ) ) ); return str_replace( '', '', $footer_text ) . ' | ' . $text . ''; } return $footer_text; } public static function add_admin_page(): void { $icon = 'data:image/svg+xml;base64,' . base64_encode( self::icon() ); $parent = 'wp-coder'; $title = WPCoder::info( 'name' ) . ' version ' . WPCoder::info( 'version' ); $main_title = WPCoder::info( 'name' ); $menu_title = 'All Codes'; $capability = 'unfiltered_html'; $slug = WPCoder::SLUG; $url_update = 'https://wpcoder.pro/pricing/?utm_source=wordpress&utm_medium=admin-menu&utm_campaign=upgrade-to-pro'; add_menu_page( $main_title, $main_title, 'unfiltered_html', $slug, [ __CLASS__, 'plugin_page' ], $icon ); add_submenu_page( $slug, $title, $menu_title, $capability, $slug, [ __CLASS__, 'plugin_page' ] ); add_submenu_page( $slug, $title, 'Add new', $capability, $slug . '-settings', [ __CLASS__, 'settings' ] ); add_submenu_page( $slug, $title, 'Snippets', $capability, $slug . '-snippets', [ __CLASS__, 'snippets' ] ); add_submenu_page( $slug, $title, 'Tools', $capability, $slug . '-tools', [ __CLASS__, 'tools' ] ); add_submenu_page( $slug, $title, 'Global PHP', $capability, $slug . '-global', [ __CLASS__, 'global_php' ] ); add_submenu_page( $slug, $title, 'Import / Export', $capability, $slug . '-import-export', [ __CLASS__, 'import_export' ] ); add_submenu_page( $slug, $title, 'Support', $capability, $slug . '-support', [ __CLASS__, 'support' ] ); add_submenu_page( $slug, $title, 'Upgrade to Pro', $capability, $url_update ); } public static function icon(): string { return '48px_code'; } public static function plugin_page(): void { $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/1.list.php'; if ( file_exists( $page_path ) ) { require_once $page_path; } } public static function settings(): void { $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/2.settings.php'; if ( file_exists( $page_path ) ) { require_once $page_path; } } public static function snippets() { $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/3.snippets.php'; if ( file_exists( $page_path ) ) { require_once $page_path; } } public static function global_php() { $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/global-php.php'; if ( file_exists( $page_path ) ) { require_once $page_path; } } public static function tools() { $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/4.tools.php'; if ( file_exists( $page_path ) ) { require_once $page_path; } } public static function import_export() { $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/4.import-export.php'; if ( file_exists( $page_path ) ) { require_once $page_path; } } public static function support() { $page_path = DashboardHelper::get_folder_path( 'pages' ) . '/4.support.php'; if ( file_exists( $page_path ) ) { require_once $page_path; } } public static function admin_scripts( $hook ): void { // $page = 'toplevel_page_' . WPCoder::SLUG; $assets_url = WPCoder::url() . 'assets/'; wp_enqueue_style( 'wowp-general-admin', $assets_url . 'css/admin-general.css' ); $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; if ( strpos( $page, WPCoder::SLUG ) === false ) { return; } do_action( WPCoder::PREFIX . '_admin_load_styles_scripts' ); } }