PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.0.1
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.0.1
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / classes / Controllers / Admin / SettingsPage.php

SettingsPage.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 2.0.1, at classes/Controllers/Admin/SettingsPage.php

88 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 * Settings Page Controller Class.
4 *
5 * @package ContentControl
6 */
7
8 namespace ContentControl\Controllers\Admin;
9
10 use ContentControl\Base\Controller;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Settings Page Controller.
16 *
17 * @package ContentControl\Admin
18 */
19 class SettingsPage extends Controller {
20
21 /**
22 * Initialize the settings page.
23 */
24 public function init() {
25 add_action( 'admin_menu', [ $this, 'register_page' ], 999 );
26 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
27 // These are here to listen for incoming webhooks from the Upgrader service when user chooses to install Pro.
28 add_action( 'wp_ajax_content_control_connect_verify_connection', [ $this, 'process_verify_connection' ] );
29 add_action( 'wp_ajax_nopriv_content_control_connect_verify_connection', [ $this, 'process_verify_connection' ] );
30 add_action( 'wp_ajax_content_control_connect_webhook', [ $this, 'process_webhook' ] );
31 add_action( 'wp_ajax_nopriv_content_control_connect_webhook', [ $this, 'process_webhook' ] );
32 }
33
34 /**
35 * Register admin options pages.
36 */
37 public function register_page() {
38 add_options_page(
39 __( 'Content Control', 'content-control' ),
40 __( 'Content Control', 'content-control' ),
41 'manage_options',
42 'content-control-settings',
43 [ $this, 'render_page' ]
44 );
45 }
46
47 /**
48 * Render settings page title & container..
49 */
50 public function render_page() {
51 ?>
52 <div id="content-control-root-container"></div>
53 <script>jQuery(() => window.contentControl.settingsPage.init());</script>
54 <?php
55 }
56
57 /**
58 * Enqueue assets for the settings page.
59 *
60 * @param string $hook Page hook name.
61 */
62 public function enqueue_scripts( $hook ) {
63 if ( 'settings_page_content-control-settings' !== $hook ) {
64 return;
65 }
66
67 wp_enqueue_script( 'content-control-settings-page' );
68 }
69
70 /**
71 * Verify the connection.
72 *
73 * @return void
74 */
75 public function process_verify_connection() {
76 $this->container->get( 'connect' )->process_verify_connection();
77 }
78
79 /**
80 * Listen for incoming secure webhooks from the API server.
81 *
82 * @return void
83 */
84 public function process_webhook() {
85 $this->container->get( 'connect' )->process_webhook();
86 }
87 }
88