PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.0.4
WP Coder – Insert & Manage Code Snippets v3.0.4
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
wp-coder / classes / Admin / AdminInitializer.php

AdminInitializer.php in WP Coder – Insert & Manage Code Snippets 3.0.4, at classes/Admin/AdminInitializer.php

72 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPCoder\Admin;
4
5 defined( 'ABSPATH' ) || exit;
6
7 // Exit if accessed directly.
8 use WPCoder\WOW_Plugin;
9
10 class AdminInitializer {
11
12 public static function init(): void {
13 add_filter( 'plugin_action_links', [ __CLASS__, 'settings_link' ], 10, 2 );
14 add_filter( 'admin_footer_text', [ __CLASS__, 'footer_text' ] );
15 add_action( 'admin_menu', [ __CLASS__, 'add_admin_page' ] );
16 add_action( 'admin_enqueue_scripts', [ __CLASS__, 'admin_scripts' ] );
17 new AdminNotices;
18 new AdminActions;
19 }
20
21 public static function settings_link( $links, $file ) {
22 if ( false === strpos( $file, WOW_Plugin::basename() ) ) {
23 return $links;
24 }
25 $link = admin_url( 'admin.php?page=' . WOW_Plugin::SLUG );
26 $text = esc_attr__( 'Settings', 'wpcoder' );
27 $settings_link = '<a href="' . esc_url( $link ) . '">' . esc_attr( $text ) . '</a>';
28 array_unshift( $links, $settings_link );
29
30 return $links;
31 }
32
33 public static function footer_text( $footer_text ) {
34 global $pagenow;
35
36 if ( $pagenow === 'admin.php' && ( isset( $_GET['page'] ) && $_GET['page'] === WOW_Plugin::SLUG ) ) {
37 $text = sprintf(
38 __( 'Thank you for using <b>%2$s</b>! Please <a href="%1$s" target="_blank">rate us</a>', 'wpcoder' ),
39 esc_url( WOW_Plugin::PluginURL ),
40 esc_attr( WOW_Plugin::NAME )
41 );
42
43 return str_replace( '</span>', '', $footer_text ) . ' | ' . $text . '</span>';
44 }
45
46 return $footer_text;
47 }
48
49 public static function add_admin_page(): void {
50 $parent = 'wow-company';
51 $title = WOW_Plugin::NAME . ' version ' . WOW_Plugin::VERSION;
52 $menu_title = WOW_Plugin::NAME;
53 $capability = 'unfiltered_html';
54 $slug = WOW_Plugin::SLUG;
55 add_submenu_page( $parent, $title, $menu_title, $capability, $slug, [ __CLASS__, 'plugin_page' ] );
56 }
57
58 public static function plugin_page(): void {
59 do_action( WOW_Plugin::PREFIX . '_admin_page' );
60 }
61
62 public static function admin_scripts( $hook ): void {
63 $page = 'wow-plugins_page_' . WOW_Plugin::SLUG;
64
65 if ( $page !== $hook ) {
66 return;
67 }
68
69 do_action( WOW_Plugin::PREFIX . '_admin_load_styles_scripts' );
70 }
71
72 }