PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.5.9
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.5.9
1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / src / Admin / Menus.php
hostinger-reach / src / Admin Last commit date
Database 8 months ago Notices 4 months ago Surveys 8 months ago Menus.php 2 months ago Redirects.php 11 months ago
Menus.php
113 lines
1 <?php
2
3 namespace Hostinger\Reach\Admin;
4
5 use Hostinger\WpMenuManager\Menus as WpMenu;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 die;
9 }
10
11 class Menus {
12
13 public function init(): void {
14 add_action( 'admin_menu', array( $this, 'add_main_menu_page' ), 2 );
15 add_filter( 'hostinger_menu_subpages', array( $this, 'add_sub_menu_page' ), 20 );
16 add_filter( 'hostinger_admin_menu_bar_items', array( $this, 'add_admin_bar_items' ), 110 );
17 add_action( 'admin_menu', array( $this, 'maybe_remove_hostinger_menu' ), 999 );
18 }
19
20 public function maybe_remove_hostinger_menu(): void {
21 $submenus = apply_filters( 'hostinger_menu_subpages', array() );
22
23 $other_submenus = array_filter(
24 $submenus,
25 function ( $submenu ) {
26 return ( $submenu['menu_slug'] ?? '' ) !== 'hostinger-reach';
27 }
28 );
29
30 if ( empty( $other_submenus ) ) {
31 remove_menu_page( 'hostinger' );
32 }
33 }
34
35 public function add_main_menu_page(): void {
36 add_menu_page(
37 $this->get_title(),
38 $this->get_title(),
39 'manage_options',
40 'hostinger-reach',
41 array( $this, 'render_plugin_content' ),
42 $this->get_icon(),
43 1.5
44 );
45 }
46
47 public function add_sub_menu_page( array $submenus ): array {
48 $submenus[] = array(
49 'page_title' => $this->get_title(),
50 'menu_title' => __( 'Hostinger Reach', 'hostinger-reach' ),
51 'capability' => 'manage_options',
52 'menu_slug' => 'hostinger-reach',
53 'callback' => array( $this, 'render_plugin_content' ),
54 'menu_order' => 10,
55 );
56
57 return $submenus;
58 }
59
60 public function add_admin_bar_items( array $menu_items ): array {
61 if ( ! current_user_can( 'manage_options' ) ) {
62 return $menu_items;
63 }
64
65 $menu_items[] = array(
66 'id' => 'hostinger-reach',
67 'title' => esc_html( $this->get_title() ),
68 'href' => self::get_reach_admin_url(),
69 );
70
71 return $menu_items;
72 }
73
74 public function render_plugin_content(): void {
75 $allowed_tags = array_merge(
76 wp_kses_allowed_html( 'post' ),
77 array(
78 'svg' => array(
79 'xmlns' => true,
80 'width' => true,
81 'height' => true,
82 'viewbox' => true,
83 'fill' => true,
84 'class' => true,
85 'style' => true,
86 ),
87 'path' => array(
88 'fill-rule' => true,
89 'clip-rule' => true,
90 'd' => true,
91 'fill' => true,
92 ),
93 )
94 );
95 echo wp_kses( WpMenu::renderMenuNavigation(), $allowed_tags );
96 ?>
97 <div id="hostinger-reach-app" class="hostinger-reach-app"></div>
98 <?php
99 }
100
101 public static function get_reach_admin_url(): string {
102 return admin_url( 'admin.php?page=hostinger-reach' );
103 }
104
105 private function get_title(): string {
106 return __( 'Hostinger Reach', 'hostinger-reach' );
107 }
108
109 private function get_icon(): string {
110 return plugin_dir_url( dirname( __DIR__ ) ) . 'frontend/vue/assets/images/icons/reach-menu-logo.svg';
111 }
112 }
113