PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 3.1.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v3.1.0
5.12.0 5.13.0 5.13.1 5.11.0 5.10.0 5.9.0 5.8.0 5.8.1 5.7.0 5.6.2 5.6.3 5.6.1 5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 All 47 releases
double-opt-in / core / UIMenu.class.php

UIMenu.class.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 3.1.0, at core/UIMenu.class.php

113 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace forge12\contactform7\CF7DoubleOptIn {
4
5 use Forge12\Shared\Logger;
6 use Forge12\Shared\LoggerInterface;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 *
14 */
15 class UIMenu {
16 private LoggerInterface $logger;
17
18 /**
19 * UI constructor.
20 *
21 * @param $slug
22 */
23 public function __construct( LoggerInterface $logger ) {
24 $this->logger = $logger;
25 $this->get_logger()->info( 'UIMenu class instance created. Registering menu renderer.', [
26 'plugin' => 'double-opt-in',
27 ] );
28
29 add_action( 'f12_cf7_doubleoptin_admin_menu', array( $this, 'render' ), 10, 3 );
30 $this->get_logger()->debug( 'Added "render" method to "f12_cf7_doubleoptin_admin_menu" action.', [
31 'plugin' => 'double-opt-in',
32 ] );
33 }
34
35 public function get_logger() {
36 return $this->logger;
37 }
38
39 /**
40 *
41 * @param array<UIPage> $Pages
42 * @param string $active_slug
43 *
44 * @return void
45 */
46 public function render( $Pages, $active_slug, $plugin_slug ) {
47 $this->get_logger()->info( 'Rendering the admin menu navigation.', [
48 'plugin' => $plugin_slug,
49 'active_slug' => $active_slug,
50 ] );
51
52 if ( ! is_array( $Pages ) ) {
53 $this->get_logger()->warning( 'Provided pages variable is not an array. Converting to an array.', [
54 'plugin' => $plugin_slug,
55 ] );
56 $Pages = array( $Pages );
57 }
58
59 // Begin HTML output
60 ?>
61 <nav class="navbar">
62 <ul class="navbar-nav">
63 <?php
64 $this->get_logger()->info( 'Triggering "before-forge12-plugin-menu-' . $plugin_slug . '" action.', [
65 'plugin' => $plugin_slug,
66 ] );
67 do_action( 'before-forge12-plugin-menu-' . $plugin_slug );
68 ?>
69 <?php foreach ( $Pages as /** @var UIPage $Page */ $Page ): ?>
70 <li class="forge12-plugin-menu-item">
71 <?php
72 $this->get_logger()->debug( 'Processing menu item for page: ' . $Page->getSlug(), [
73 'plugin' => $plugin_slug,
74 ] );
75
76 $class = '';
77 $slug = $plugin_slug . '_' . $Page->getSlug();
78
79 if ( $Page->isDashboard() ) {
80 $slug = $plugin_slug;
81 }
82
83 if ( $Page->getSlug() == $active_slug || ( $Page->isDashboard() && empty( $active_slug ) ) ) {
84 $class = 'active';
85 $this->get_logger()->notice( 'Setting menu item "' . $Page->getSlug() . '" as active.', [
86 'plugin' => $plugin_slug,
87 ] );
88 }
89 ?>
90 <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $slug ); ?>"
91 title="<?php echo esc_attr( $Page->getTitle() ); ?>"
92 class="<?php echo esc_attr( $class ) . ' ' . esc_attr( $Page->getClass() ); ?>">
93 <?php echo esc_html( $Page->getTitle() ); ?>
94 </a>
95 </li>
96 <?php endforeach; ?>
97 <?php
98 $this->get_logger()->info( 'Triggering "after-forge12-plugin-menu-' . $plugin_slug . '" action.', [
99 'plugin' => $plugin_slug,
100 ] );
101 do_action( 'after-forge12-plugin-menu-' . $plugin_slug );
102 ?>
103 </ul>
104 </nav>
105 <?php
106 $this->get_logger()->notice( 'Menu navigation rendering complete.', [
107 'plugin' => $plugin_slug,
108 ] );
109 }
110 }
111
112 new UIMenu( Logger::getInstance() );
113 }