PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.3.4
GenerateBlocks v1.3.4
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / includes / dashboard.php
generateblocks / includes Last commit date
class-do-css.php 5 years ago class-enqueue-css.php 4 years ago class-plugin-update.php 5 years ago class-render-blocks.php 5 years ago class-rest.php 5 years ago class-settings.php 5 years ago dashboard.php 5 years ago defaults.php 5 years ago functions.php 4 years ago general.php 4 years ago generate-css.php 5 years ago
dashboard.php
312 lines
1 <?php
2 /**
3 * Our admin Dashboard.
4 *
5 * @package GenerateBlocks
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 add_action( 'admin_menu', 'generateblocks_register_dashboard', 9 );
13 /**
14 * Register our Dashboard page.
15 *
16 * @since 0.1
17 */
18 function generateblocks_register_dashboard() {
19 $dashboard = add_menu_page(
20 __( 'GenerateBlocks', 'generateblocks' ),
21 __( 'GenerateBlocks', 'generateblocks' ),
22 'manage_options',
23 'generateblocks',
24 'generateblocks_do_dashboard'
25 );
26
27 add_submenu_page(
28 'generateblocks',
29 __( 'Dashboard', 'generateblocks' ),
30 __( 'Dashboard', 'generateblocks' ),
31 'manage_options',
32 'generateblocks'
33 );
34
35 add_action( "admin_print_styles-$dashboard", 'generateblocks_enqueue_dashboard_scripts' );
36 }
37
38 /**
39 * Add our Dashboard-specific scripts.
40 *
41 * @since 1.0.0
42 */
43 function generateblocks_enqueue_dashboard_scripts() {
44 wp_enqueue_style(
45 'generateblocks-dashboard',
46 GENERATEBLOCKS_DIR_URL . 'assets/css/dashboard.css',
47 array(),
48 GENERATEBLOCKS_VERSION
49 );
50 }
51
52 /**
53 * Get a list of our Dashboard pages.
54 *
55 * @since 1.2.0
56 */
57 function generateblocks_get_dashboard_pages() {
58 return apply_filters(
59 'generateblocks_dashboard_screens',
60 array(
61 'toplevel_page_generateblocks',
62 'generateblocks_page_generateblocks-settings',
63 )
64 );
65 }
66
67 add_filter( 'admin_body_class', 'generateblocks_set_admin_body_classes' );
68 /**
69 * Add admin body classes when needed.
70 *
71 * @since 1.2.0
72 * @param string $classes The existing classes.
73 */
74 function generateblocks_set_admin_body_classes( $classes ) {
75 $dashboard_pages = generateblocks_get_dashboard_pages();
76 $current_screen = get_current_screen();
77
78 if ( in_array( $current_screen->id, $dashboard_pages ) ) {
79 $classes .= ' generateblocks-dashboard-page';
80 }
81
82 return $classes;
83 }
84
85 add_action( 'in_admin_header', 'generateblocks_do_dashboard_headers' );
86 /**
87 * Add our Dashboard headers.
88 *
89 * @since 1.3.0
90 */
91 function generateblocks_do_dashboard_headers() {
92 $dashboard_pages = generateblocks_get_dashboard_pages();
93 $current_screen = get_current_screen();
94
95 if ( in_array( $current_screen->id, $dashboard_pages ) ) {
96 generateblocks_do_dashboard_header();
97 }
98 }
99
100 add_action( 'admin_enqueue_scripts', 'generateblocks_enqueue_global_dashboard_scripts' );
101 /**
102 * Add our scripts to the page.
103 *
104 * @since 0.1
105 */
106 function generateblocks_enqueue_global_dashboard_scripts() {
107 wp_enqueue_style(
108 'generateblocks-dashboard-global',
109 GENERATEBLOCKS_DIR_URL . 'assets/css/dashboard-global.css',
110 array(),
111 GENERATEBLOCKS_VERSION
112 );
113
114 $dashboard_pages = generateblocks_get_dashboard_pages();
115 $current_screen = get_current_screen();
116
117 if ( in_array( $current_screen->id, $dashboard_pages ) ) {
118 wp_enqueue_style(
119 'generateblocks-settings-build',
120 GENERATEBLOCKS_DIR_URL . 'dist/dashboard.css',
121 array( 'wp-components' ),
122 GENERATEBLOCKS_VERSION
123 );
124 }
125 }
126
127 /**
128 * Build our Dashboard menu.
129 */
130 function generateblocks_dashboard_navigation() {
131 $screen = get_current_screen();
132
133 $tabs = apply_filters(
134 'generateblocks_dashboard_tabs',
135 array(
136 'dashboard' => array(
137 'name' => __( 'Dashboard', 'generateblocks' ),
138 'url' => admin_url( 'admin.php?page=generateblocks' ),
139 'class' => 'toplevel_page_generateblocks' === $screen->id ? 'active' : '',
140 ),
141 'settings' => array(
142 'name' => __( 'Settings', 'generateblocks' ),
143 'url' => admin_url( 'admin.php?page=generateblocks-settings' ),
144 'class' => 'generateblocks_page_generateblocks-settings' === $screen->id ? 'active' : '',
145 ),
146 )
147 );
148
149 // Don't print any markup if we only have one tab.
150 if ( count( $tabs ) === 1 ) {
151 return;
152 }
153 ?>
154 <div class="gblocks-navigation">
155 <?php
156 foreach ( $tabs as $tab ) {
157 printf(
158 '<a href="%1$s" class="%2$s">%3$s</a>',
159 esc_url( $tab['url'] ),
160 esc_attr( $tab['class'] ),
161 esc_html( $tab['name'] )
162 );
163 }
164 ?>
165 </div>
166 <?php
167 }
168
169 /**
170 * Build our Dashboard header.
171 *
172 * @since 1.2.0
173 */
174 function generateblocks_do_dashboard_header() {
175 ?>
176 <div class="gblocks-dashboard-header">
177 <div class="gblocks-dashboard-header-title">
178 <h1>
179 <svg aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 50 60.12" xml:space="preserve"><path class="st0" d="M6.686 31.622V18.918a.077.077 0 01.05-.072l6.5-2.313 6.5-2.313 9.682-3.445L39.1 7.33a.067.067 0 00.036-.028.074.074 0 00.014-.044V.076a.077.077 0 00-.032-.062.076.076 0 00-.069-.009l-13 4.625-13 4.625-6.5 2.313-6.5 2.313a.067.067 0 00-.036.028.097.097 0 00-.013.046V52.067c0 .026.013.048.032.062s.044.018.069.009l3.267-1.163 3.267-1.163c.015-.005.028-.015.036-.028s.014-.028.014-.044V37.999l.001-6.377c-.001 0 0 0 0 0z"/><path class="st0" d="M23.949 29.976l13-4.625 13-4.625c.015-.005.028-.015.036-.028s.015-.028.015-.044V8.056a.077.077 0 00-.032-.062.076.076 0 00-.069-.009l-13 4.625-13 4.625-6.5 2.313-6.5 2.313a.067.067 0 00-.036.028.074.074 0 00-.014.044V60.045c0 .026.013.048.032.062a.076.076 0 00.069.009l6.475-2.304 6.475-2.304 6.525-2.322 6.525-2.322 6.5-2.313 6.5-2.313c.015-.005.028-.015.036-.028s.014-.025.014-.041V27.193a.077.077 0 00-.032-.062.076.076 0 00-.069-.009l-6.45 2.295L37 31.711a.067.067 0 00-.036.028.074.074 0 00-.014.044v6.272a.077.077 0 01-.05.072l-6.45 2.295L24 42.715a.075.075 0 01-.101-.071V30.046c0-.016.005-.031.014-.044a.08.08 0 01.036-.026z"/></svg>
180 <?php echo esc_html( get_admin_page_title() ); ?>
181 </h1>
182 </div>
183
184 <?php generateblocks_dashboard_navigation(); ?>
185 </div>
186 <?php
187 }
188
189 /**
190 * Output our Dashboard HTML.
191 *
192 * @since 0.1
193 */
194 function generateblocks_do_dashboard() {
195 ?>
196 <div class="wrap gblocks-dashboard-wrap">
197 <div class="gblocks-dashboard-intro-content">
198 <?php esc_html_e( 'A small collection of lightweight WordPress blocks that can accomplish nearly anything.', 'generateblocks' ); ?>
199
200 <div class="gblocks-sub-navigation">
201 <a class="button" href="https://generateblocks.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn More', 'generateblocks' ); ?></a>
202 <a class="button" href="https://docs.generateblocks.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Documentation', 'generateblocks' ); ?></a>
203 </div>
204 </div>
205
206 <div class="gblocks-dashboard-content-container">
207 <div class="gblocks-dashboard-blocks">
208 <div class="gblocks-block">
209 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 20 20" xml:space="preserve">
210 <path style="fill:currentColor;" class="st0" d="M2.8 3.4c0-.4.3-.7.7-.7h1.2V0H3.4C1.5 0 0 1.5 0 3.4v1.2h2.8V3.4zM0 7.4h2.8v5.3H0zm17.2 0H20v5.3h-2.8zm0 9.2c0 .4-.3.7-.7.7h-1.2V20h1.2c1.9 0 3.4-1.5 3.4-3.4v-1.2h-2.8v1.2h.1zM7.4 0h5.3v2.8H7.4zm-4 17.2c-.4 0-.7-.3-.7-.7v-1.2H0v1.2c0 2 1.5 3.5 3.4 3.5h1.2v-2.8H3.4zm4 0h5.3V20H7.4zm9.2-14.4c.4 0 .7.3.7.7v1.2H20V3.4C20 1.5 18.5 0 16.6 0h-1.2v2.8h1.2z"/>
211 </svg>
212
213 <h3><?php esc_html_e( 'Container', 'generateblocks' ); ?></h3>
214 <p><?php esc_html_e( 'Organize your content into rows and sections.', 'generateblocks' ); ?></p>
215
216 <div class="gblocks-block-learn-more">
217 <a class="button" href="https://docs.generateblocks.com/collection/container/" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Container Documentation', 'generateblocks' ); ?></a>
218 </div>
219 </div>
220
221 <div class="gblocks-block">
222 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 20 20" xml:space="preserve">
223 <path style="fill:currentColor;" class="st0" d="M20 .6c0-.3-.2-.6-.5-.6H.5C.2 0 0 .3 0 .6v4.6c0 .3.2.6.5.6h19c.3 0 .5-.3.5-.6V.6zM6.7 7.7c0-.3-.2-.6-.5-.6H.5c-.3 0-.5.3-.5.6v4.6c0 .3.2.6.5.6h5.6c.3 0 .5-.3.5-.6l.1-4.6zm13.2 0c0-.3-.2-.6-.6-.6H8.6c-.4 0-.6.3-.6.6v4.5c0 .3.2.6.6.6h10.8c.3 0 .6-.3.6-.6l-.1-4.5zM20 14.8c0-.3-.2-.6-.5-.6h-5.6c-.3 0-.5.2-.5.6v4.6c0 .3.2.6.5.6h5.6c.3 0 .5-.2.5-.6v-4.6zm-8 0c0-.3-.2-.5-.5-.5H.5c-.3 0-.5.2-.5.5v4.6c0 .4.2.6.5.6h11c.3 0 .5-.2.5-.5v-4.7z"/>
224 </svg>
225
226 <h3><?php esc_html_e( 'Grid', 'generateblocks' ); ?></h3>
227 <p><?php esc_html_e( 'Create advanced layouts with flexible grids.', 'generateblocks' ); ?></p>
228
229 <div class="gblocks-block-learn-more">
230 <a class="button" href="https://docs.generateblocks.com/collection/grid/" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Grid Documentation', 'generateblocks' ); ?></a>
231 </div>
232 </div>
233
234 <div class="gblocks-block">
235 <svg style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;" xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 38 38" height="100%" width="100%">
236 <path style="fill:currentColor;fill-rule:nonzero;" d="M34.82,37.5l-10.183,0l0,-14.037l-11.774,0l0,14.037l-10.183,0l0,-37.5l10.183,0l0,12.652l11.774,0l0,-12.652l10.183,0l0,37.5Z"></path>
237 </svg>
238
239 <h3><?php esc_html_e( 'Headline', 'generateblocks' ); ?></h3>
240 <p><?php esc_html_e( 'Craft text-rich content with advanced typography.', 'generateblocks' ); ?></p>
241
242 <div class="gblocks-block-learn-more">
243 <a class="button" href="https://docs.generateblocks.com/collection/headline/" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Headline Documentation', 'generateblocks' ); ?></a>
244 </div>
245 </div>
246
247 <div class="gblocks-block">
248 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 20 20" xml:space="preserve">
249 <path style="fill:currentColor;" class="st0" d="M19.2 0H.8C.4 0 0 .4 0 .8v6.4c0 .4.4.8.8.8h18.4c.4 0 .8-.4.8-.8V.8c0-.4-.4-.8-.8-.8zm-.8 12H1.6c-.9 0-1.6.7-1.6 1.6v4.8c0 .9.7 1.6 1.6 1.6h16.8c.9 0 1.6-.7 1.6-1.6v-4.8c0-.9-.7-1.6-1.6-1.6zm.4 6.4c0 .2-.2.4-.4.4H1.6c-.2 0-.4-.2-.4-.4v-4.8c0-.2.2-.4.4-.4h16.8c.2 0 .4.2.4.4v4.8z"/>
250 </svg>
251
252 <h3><?php esc_html_e( 'Buttons', 'generateblocks' ); ?></h3>
253 <p><?php esc_html_e( 'Drive conversions with beautiful buttons.', 'generateblocks' ); ?></p>
254
255 <div class="gblocks-block-learn-more">
256 <a class="button" href="https://docs.generateblocks.com/collection/buttons/" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Buttons Documentation', 'generateblocks' ); ?></a>
257 </div>
258 </div>
259 </div>
260
261 <div class="gblocks-generatepress">
262 <div class="gblocks-inside-generatepress">
263 <div class="gblocks-generatepress-content">
264 <img width="300" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress.svg'; ?>" alt="" />
265 <p><?php esc_html_e( 'Looking for a WordPress theme? GenerateBlocks and GeneratePress are built with the same principles in mind and complement each other perfectly.', 'generateblocks' ); ?></p>
266 <div class="stats">
267 <div class="downloads">
268 <strong>3,000,000+</strong><br> <?php esc_html_e( 'Downloads', 'generateblocks' ); ?>
269 </div>
270
271 <div class="stars">
272 <strong>1000+</strong><br>
273 <img src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/stars.svg'; ?>" alt="" width="98" height="17" class="alignnone size-full wp-image-44">
274 </div>
275
276 <div class="active-websites">
277 <strong>300,000+</strong><br> <?php esc_html_e( 'Active websites', 'generateblocks' ); ?>
278 </div>
279
280 <div class="active-websites">
281 <strong>70,000+</strong><br> <?php esc_html_e( 'Happy customers', 'generateblocks' ); ?>
282 </div>
283 </div>
284 <a class="gblocks-button" href="https://generatepress.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn more', 'generateblocks' ); ?></a>
285 </div>
286
287 <div class="gblocks-generatepress-image">
288 <img width="450" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress-sites.png'; ?>" alt="" />
289 </div>
290 </div>
291 </div>
292 </div>
293 </div>
294 <?php
295 }
296
297 add_action( 'admin_init', 'generateblocks_dashboard_redirect' );
298 /**
299 * Redirect to the Dashboard page on single plugin activation.
300 *
301 * @since 0.1
302 */
303 function generateblocks_dashboard_redirect() {
304 $do_redirect = apply_filters( 'generateblocks_do_activation_redirect', get_option( 'generateblocks_do_activation_redirect', false ) );
305
306 if ( $do_redirect ) {
307 delete_option( 'generateblocks_do_activation_redirect' );
308 wp_safe_redirect( esc_url( admin_url( 'admin.php?page=generateblocks' ) ) );
309 exit;
310 }
311 }
312