PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 6.0
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v6.0
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / classes / Admin / AdminInitializer.php

AdminInitializer.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 6.0, 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 FloatingButton\Admin;
4
5 defined( 'ABSPATH' ) || exit;
6
7 // Exit if accessed directly.
8 use FloatingButton\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', 'floating-button' );
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>', 'floating-button' ),
39 esc_url( WOW_Plugin::info('url') ),
40 esc_attr( WOW_Plugin::info('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::info('name') . ' version ' . WOW_Plugin::info('version');
52 $menu_title = WOW_Plugin::info('name');
53 $capability = 'manage_options';
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 }