Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/admin/dashboard/core.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Admin Dashboard
4 + *
5 + * @copyright 2019-present Creative Themes
6 + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
7 + * @package Blocksy
8 + */
9 +
10 + defined( 'ABSPATH' ) || die( "Don't run this file directly!" );
11 +
12 + function blocksy_is_dashboard_page() {
13 + global $pagenow;
14 +
15 + $is_ct_settings =
16 + // 'themes.php' === $pagenow &&
17 + isset( $_GET['page'] ) && 'ct-dashboard' === $_GET['page'];
18 +
19 + return $is_ct_settings;
20 + }
21 +
22 + class Blocksy_Dashboard_Page {
23 + private $templates;
24 +
25 + private $page_slug = 'ct-dashboard';
26 +
27 + public function is_dashboard_page() {
28 + return blocksy_is_dashboard_page();
29 + }
30 +
31 + public function __construct() {
32 + add_action(
33 + 'admin_menu',
34 + [$this, 'setup_framework_page'],
35 + 5
36 + );
37 +
38 + if (is_admin() && defined('DOING_AJAX') && DOING_AJAX) {
39 + $plugins_api = new Blocksy_Admin_Dashboard_API_Premium_Plugins();
40 + $plugins_api->attach_ajax_actions();
41 +
42 + $api = new Blocksy_Admin_Dashboard_API();
43 + $api->attach_ajax_actions();
44 + }
45 +
46 + if ($this->is_dashboard_page()) {
47 + add_action(
48 + 'admin_enqueue_scripts',
49 + [$this, 'enqueue_static']
50 + );
51 + }
52 +
53 + if ($this->is_dashboard_page()) {
54 + add_action(
55 + 'admin_print_scripts',
56 + function () {
57 + global $wp_filter;
58 +
59 + if (is_user_admin()) {
60 + if (isset($wp_filter['user_admin_notices'])) {
61 + unset($wp_filter['user_admin_notices']);
62 + }
63 + } elseif (isset($wp_filter['admin_notices'])) {
64 + unset($wp_filter['admin_notices']);
65 + }
66 +
67 + if (isset($wp_filter['all_admin_notices'])) {
68 + unset($wp_filter['all_admin_notices']);
69 + }
70 + }
71 + );
72 + }
73 + }
74 +
75 + public function enqueue_static() {
76 + $theme = blocksy_get_wp_parent_theme();
77 +
78 + $dependencies = [
79 + 'underscore',
80 + 'wp-util',
81 + 'ct-events',
82 + 'ct-options-scripts'
83 + ];
84 +
85 + wp_enqueue_script(
86 + 'ct-dashboard-scripts',
87 + get_template_directory_uri() . '/admin/dashboard/static/bundle/main.js',
88 + $dependencies,
89 + $theme->get('Version'),
90 + false
91 + );
92 +
93 + if (defined('WP_DEBUG')) {
94 + wp_localize_script(
95 + 'ct-dashboard-scripts',
96 + 'WP_DEBUG',
97 + [ 'debug' => true ]
98 + );
99 + }
100 +
101 + $manager = new Blocksy_Plugin_Manager();
102 + $plugins_config = $manager->get_config();
103 +
104 + wp_localize_script(
105 + 'ct-dashboard-scripts',
106 + 'ctDashboardLocalizations',
107 + [
108 + 'ajax_url' => admin_url('admin-ajax.php'),
109 + 'dashboard_actions_nonce' => wp_create_nonce('ct-dashboard'),
110 + 'customizer_url' => admin_url('/customize.php?autofocus'),
111 + 'theme_version' => $theme->get('Version'),
112 + 'theme_name' => $theme->get('Name'),
113 + 'theme_custom_description' => $theme->get('CustomDescription'),
114 + 'is_child_theme' => is_child_theme(),
115 + 'child_theme_exists' => isset(wp_get_themes()['blocksy-child']),
116 + 'home_url' => home_url(),
117 + 'clean_install_plugins' => $plugins_config,
118 + 'is_companion_active' => $manager->get_companion_status()['status'],
119 + 'companion_download_link' => 'https://creativethemes.com/blocksy/companion/',
120 + 'child_download_link' => 'https://creativethemes.com/downloads/blocksy-child.zip',
121 + 'plugin_data' => apply_filters('blocksy_dashboard_localizations', []),
122 + 'support_url' => apply_filters(
123 + 'blocksy_dashboard_support_url',
124 + 'https://creativethemes.com/blocksy/support/'
125 + ),
126 + 'dashboard_has_heading' => apply_filters(
127 + 'blocksy_dashboard_has_heading',
128 + 'yes'
129 + )
130 + ]
131 + );
132 +
133 + wp_enqueue_style(
134 + 'ct-dashboard-styles',
135 + get_template_directory_uri() . '/admin/dashboard/static/bundle/main.min.css',
136 + [],
137 + $theme->get('Version')
138 + );
139 +
140 + if (is_rtl()) {
141 + wp_enqueue_style(
142 + 'ct-dashboard-rtl-styles',
143 + get_template_directory_uri() . '/admin/dashboard/static/bundle/main-rtl.min.css',
144 + ['ct-dashboard-styles'],
145 + $theme->get('Version')
146 + );
147 + }
148 + }
149 +
150 + public function setup_framework_page() {
151 + $theme = blocksy_get_wp_parent_theme();
152 +
153 + if (! current_user_can('manage_options')) {
154 + return;
155 + }
156 +
157 + $welcome_page_options = [
158 + 'title' => $theme->get('Name'),
159 + 'menu-title' => $theme->get('Name'),
160 + 'permision' => 'manage_options',
161 + 'top-level-handle' => $this->page_slug,
162 + 'callback' => [ $this, 'welcome_page_template' ],
163 + 'icon-url' => apply_filters(
164 + 'blocksy:dashboard:icon-url',
165 + 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMzUgMzUiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM1IDM1OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxwYXRoIGQ9Ik0yMS42LDIxLjNjMCwwLjYtMC41LDEuMS0xLjEsMS4xaC0zLjVsLTAuOS0yLjJoNC40QzIxLjEsMjAuMiwyMS42LDIwLjcsMjEuNiwyMS4zeiBNMjAuNiwxMy41aC00LjRsMC45LDIuMmgzLjUKCWMwLjYsMCwxLjEtMC41LDEuMS0xLjFDMjEuNiwxNCwyMS4xLDEzLjUsMjAuNiwxMy41eiBNMzUsMTcuNUMzNSwyNy4yLDI3LjIsMzUsMTcuNSwzNUM3LjgsMzUsMCwyNy4yLDAsMTcuNUMwLDcuOCw3LjgsMCwxNy41LDAKCUMyNy4yLDAsMzUsNy44LDM1LDE3LjV6IE0yNSwxNy45YzAuNy0wLjksMS4xLTIuMSwxLjEtMy40YzAtMS4yLTAuNC0yLjQtMS4xLTMuM2MtMS0xLjQtMi42LTIuMy00LjQtMi4zYzAsMC0wLjEsMC0wLjEsMHYwSDkuOQoJYy0wLjMsMC0wLjUsMC4zLTAuNCwwLjVsMi42LDYuMkg5LjljLTAuMywwLTAuNSwwLjMtMC40LDAuNUwxNCwyNi45aDYuNWMzLjEsMCw1LjYtMi41LDUuNi01LjZDMjYuMiwyMCwyNS44LDE4LjksMjUsMTcuOQoJQzI1LjEsMTcuOSwyNS4xLDE3LjksMjUsMTcuOXoiLz4KPC9zdmc+Cg=='
166 + ),
167 + 'position' => 2,
168 + ];
169 +
170 + $result = apply_filters(
171 + 'blocksy_add_menu_page',
172 + false,
173 + $welcome_page_options
174 + );
175 +
176 + if (! $result) {
177 + add_theme_page(
178 + $welcome_page_options['title'],
179 + $welcome_page_options['menu-title'],
180 + $welcome_page_options['permision'],
181 + $welcome_page_options['top-level-handle'],
182 + $welcome_page_options['callback']
183 + );
184 + }
185 + }
186 +
187 + public function welcome_page_template() {
188 + if ( ! current_user_can( 'manage_options' ) ) {
189 + wp_die( esc_html( __( 'You do not have sufficient permissions to access this page.', 'blocksy' ) ) );
190 + }
191 +
192 + echo '<div id="ct-dashboard"></div>';
193 + }
194 + }
195 +
196 + new Blocksy_Dashboard_Page();
197 +