PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.8.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.8.0
1.8.0 1.7.2 1.7.1 1.7.0 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 9 months ago Notices 6 months ago Surveys 9 months ago Menus.php 3 days ago Redirects.php 1 year ago
Menus.php
116 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 } else {
33 // Hostinger parent already lists Reach — drop the standalone duplicate.
34 remove_menu_page( 'hostinger-reach' );
35 }
36 }
37
38 public function add_main_menu_page(): void {
39 add_menu_page(
40 $this->get_title(),
41 $this->get_title(),
42 'manage_options',
43 'hostinger-reach',
44 array( $this, 'render_plugin_content' ),
45 $this->get_icon(),
46 1.5
47 );
48 }
49
50 public function add_sub_menu_page( array $submenus ): array {
51 $submenus[] = array(
52 'page_title' => $this->get_title(),
53 'menu_title' => $this->get_title(),
54 'capability' => 'manage_options',
55 'menu_slug' => 'hostinger-reach',
56 'callback' => array( $this, 'render_plugin_content' ),
57 'menu_order' => 10,
58 );
59
60 return $submenus;
61 }
62
63 public function add_admin_bar_items( array $menu_items ): array {
64 if ( ! current_user_can( 'manage_options' ) ) {
65 return $menu_items;
66 }
67
68 $menu_items[] = array(
69 'id' => 'hostinger-reach',
70 'title' => esc_html( $this->get_title() ),
71 'href' => self::get_reach_admin_url(),
72 );
73
74 return $menu_items;
75 }
76
77 public function render_plugin_content(): void {
78 $allowed_tags = array_merge(
79 wp_kses_allowed_html( 'post' ),
80 array(
81 'svg' => array(
82 'xmlns' => true,
83 'width' => true,
84 'height' => true,
85 'viewbox' => true,
86 'fill' => true,
87 'class' => true,
88 'style' => true,
89 ),
90 'path' => array(
91 'fill-rule' => true,
92 'clip-rule' => true,
93 'd' => true,
94 'fill' => true,
95 ),
96 )
97 );
98 echo wp_kses( WpMenu::renderMenuNavigation(), $allowed_tags );
99 ?>
100 <div id="hostinger-reach-app" class="hostinger-reach-app"></div>
101 <?php
102 }
103
104 public static function get_reach_admin_url(): string {
105 return admin_url( 'admin.php?page=hostinger-reach' );
106 }
107
108 private function get_title(): string {
109 return __( 'Reach', 'hostinger-reach' );
110 }
111
112 private function get_icon(): string {
113 return plugin_dir_url( dirname( __DIR__ ) ) . 'frontend/vue/assets/images/icons/reach-menu-logo.svg';
114 }
115 }
116