PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / addons / cookie-consent / admin.php

admin.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.13.1, at addons/cookie-consent/admin.php

79 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocksCookieConsent;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * The addon's place in the aBlocks admin.
10 *
11 * One submenu entry, appearing only while the addon is on, plus the data the
12 * React screen needs at boot so it does not have to make a request before it
13 * can render anything.
14 */
15 class Admin {
16
17 public static function init() {
18 $self = new self();
19 add_filter( 'ablocks/admin_menu_list', [ $self, 'admin_menu' ] );
20 add_filter( 'ablocks/assets/dashboard_scripts_data', [ $self, 'dashboard_data' ] );
21 }
22
23 /**
24 * Insert the screen directly after Theme Builder, so the two addon screens
25 * sit together rather than one of them landing under Settings.
26 *
27 * @param array $menu Menu registry.
28 * @return array
29 */
30 public function admin_menu( $menu ) {
31 $entry = [
32 ABLOCKS_PLUGIN_SLUG . '-cookie-consent' => [
33 'parent_slug' => ABLOCKS_PLUGIN_SLUG,
34 'title' => __( 'Cookie Consent', 'ablocks' ),
35 'capability' => 'manage_options',
36 ],
37 ];
38
39 $anchor = ABLOCKS_PLUGIN_SLUG . '-theme-builder';
40 if ( ! isset( $menu[ $anchor ] ) ) {
41 $anchor = ABLOCKS_PLUGIN_SLUG . '-addons';
42 }
43 if ( ! isset( $menu[ $anchor ] ) ) {
44 return array_merge( $menu, $entry );
45 }
46
47 $position = array_search( $anchor, array_keys( $menu ), true ) + 1;
48
49 return array_merge(
50 array_slice( $menu, 0, $position, true ),
51 $entry,
52 array_slice( $menu, $position, null, true )
53 );
54 }
55
56 /**
57 * @param array $data Localised dashboard data.
58 * @return array
59 */
60 public function dashboard_data( $data ) {
61 $data['cookie_consent'] = [
62 'defaults' => Helper::defaults(),
63 'settings' => Helper::get_settings(),
64 'consent_signals' => ConsentMode::signal_map(),
65 'pro' => Helper::pro_features(),
66 'record_count' => Record::count(),
67 'table_ready' => Database::table_exists(),
68 // Still needed by the notice that asks a site to move a tag it
69 // entered before aBlocks stopped placing them.
70 'tag_providers' => Tags::detected_providers(),
71 'embed_defaults' => [
72 'embed' => Embeds::default_rules(),
73 'pixel' => Embeds::default_pixel_rules(),
74 ],
75 ];
76 return $data;
77 }
78 }
79