PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.2.0
GenerateBlocks v1.2.0
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 5 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 5 years ago general.php 5 years ago generate-css.php 5 years ago
dashboard.php
301 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( 'admin_enqueue_scripts', 'generateblocks_enqueue_global_dashboard_scripts' );
86 /**
87 * Add our scripts to the page.
88 *
89 * @since 0.1
90 */
91 function generateblocks_enqueue_global_dashboard_scripts() {
92 wp_enqueue_style(
93 'generateblocks-dashboard-global',
94 GENERATEBLOCKS_DIR_URL . 'assets/css/dashboard-global.css',
95 array(),
96 GENERATEBLOCKS_VERSION
97 );
98
99 $dashboard_pages = generateblocks_get_dashboard_pages();
100 $current_screen = get_current_screen();
101
102 if ( in_array( $current_screen->id, $dashboard_pages ) ) {
103 wp_enqueue_style(
104 'generateblocks-settings-build',
105 GENERATEBLOCKS_DIR_URL . 'dist/dashboard.css',
106 array( 'wp-components' ),
107 GENERATEBLOCKS_VERSION
108 );
109 }
110 }
111
112 /**
113 * Build our Dashboard menu.
114 */
115 function generateblocks_dashboard_navigation() {
116 $screen = get_current_screen();
117
118 $tabs = apply_filters(
119 'generateblocks_dashboard_tabs',
120 array(
121 'dashboard' => array(
122 'name' => __( 'Dashboard', 'generateblocks' ),
123 'url' => admin_url( 'admin.php?page=generateblocks' ),
124 'class' => 'toplevel_page_generateblocks' === $screen->id ? 'active' : '',
125 ),
126 'settings' => array(
127 'name' => __( 'Settings', 'generateblocks' ),
128 'url' => admin_url( 'admin.php?page=generateblocks-settings' ),
129 'class' => 'generateblocks_page_generateblocks-settings' === $screen->id ? 'active' : '',
130 ),
131 )
132 );
133
134 // Don't print any markup if we only have one tab.
135 if ( count( $tabs ) === 1 ) {
136 return;
137 }
138 ?>
139 <div class="gblocks-navigation">
140 <?php
141 foreach ( $tabs as $tab ) {
142 printf(
143 '<a href="%1$s" class="%2$s">%3$s</a>',
144 esc_url( $tab['url'] ),
145 esc_attr( $tab['class'] ),
146 esc_html( $tab['name'] )
147 );
148 }
149 ?>
150 </div>
151 <?php
152 }
153
154 /**
155 * Build our Dashboard header.
156 *
157 * @since 1.2.0
158 * @param string $title The title of the page.
159 */
160 function generateblocks_do_dashboard_header( $title ) {
161 ?>
162 <div class="gblocks-dashboard-header">
163 <div class="gblocks-dashboard-header-content">
164 <?php
165 if ( 'dashboard' === $title ) :
166 ?>
167 <h1 class="gblocks-logo">
168 <a href="https://generateblocks.com" target="_blank" rel="noopener noreferrer">
169 <img width="200" height="55" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/gb-logo-black.svg'; ?>" alt="<?php esc_attr_e( 'GenerateBlocks', 'generateblocks' ); ?>" />
170 </a>
171 <span class="gblocks-version"><?php echo esc_html( GENERATEBLOCKS_VERSION ); ?></span>
172 </h1>
173 <?php
174 else :
175 ?>
176 <h1><?php echo esc_html( $title ); ?></h1>
177 <?php
178 endif;
179 ?>
180 </div>
181
182 <?php generateblocks_dashboard_navigation(); ?>
183 </div>
184 <?php
185 }
186
187 /**
188 * Output our Dashboard HTML.
189 *
190 * @since 0.1
191 */
192 function generateblocks_do_dashboard() {
193 ?>
194 <div class="wrap gblocks-dashboard-wrap">
195 <?php generateblocks_do_dashboard_header( 'dashboard' ); ?>
196
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 </div>
216
217 <div class="gblocks-block">
218 <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">
219 <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"/>
220 </svg>
221
222 <h3><?php esc_html_e( 'Grid', 'generateblocks' ); ?></h3>
223 <p><?php esc_html_e( 'Create advanced layouts with flexible grids.', 'generateblocks' ); ?></p>
224 </div>
225
226 <div class="gblocks-block">
227 <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%">
228 <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>
229 </svg>
230
231 <h3><?php esc_html_e( 'Headline', 'generateblocks' ); ?></h3>
232 <p><?php esc_html_e( 'Craft text-rich content with advanced typography.', 'generateblocks' ); ?></p>
233 </div>
234
235 <div class="gblocks-block">
236 <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">
237 <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"/>
238 </svg>
239
240 <h3><?php esc_html_e( 'Buttons', 'generateblocks' ); ?></h3>
241 <p><?php esc_html_e( 'Drive conversions with beautiful buttons.', 'generateblocks' ); ?></p>
242 </div>
243 </div>
244
245 <div class="gblocks-getting-started">
246 <p><?php esc_html_e( 'To get started, head over to the block editor and open the GenerateBlocks category.', 'generatepress' ); ?></p>
247 <img width="400" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/add-blocks.png'; ?>" alt="" />
248 </div>
249
250 <div class="gblocks-generatepress">
251 <div class="gblocks-inside-generatepress">
252 <div class="gblocks-generatepress-content">
253 <img width="300" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress.svg'; ?>" alt="" />
254 <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>
255 <div class="stats">
256 <div class="downloads">
257 <strong>3,000,000+</strong><br> <?php esc_html_e( 'Downloads', 'generateblocks' ); ?>
258 </div>
259
260 <div class="stars">
261 <strong>1000+</strong><br>
262 <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">
263 </div>
264
265 <div class="active-websites">
266 <strong>300,000+</strong><br> <?php esc_html_e( 'Active websites', 'generateblocks' ); ?>
267 </div>
268
269 <div class="active-websites">
270 <strong>70,000+</strong><br> <?php esc_html_e( 'Happy customers', 'generateblocks' ); ?>
271 </div>
272 </div>
273 <a class="gblocks-button" href="https://generatepress.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn more', 'generateblocks' ); ?></a>
274 </div>
275
276 <div class="gblocks-generatepress-image">
277 <img width="450" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress-sites.png'; ?>" alt="" />
278 </div>
279 </div>
280 </div>
281 </div>
282 </div>
283 <?php
284 }
285
286 add_action( 'admin_init', 'generateblocks_dashboard_redirect' );
287 /**
288 * Redirect to the Dashboard page on single plugin activation.
289 *
290 * @since 0.1
291 */
292 function generateblocks_dashboard_redirect() {
293 $do_redirect = apply_filters( 'generateblocks_do_activation_redirect', get_option( 'generateblocks_do_activation_redirect', false ) );
294
295 if ( $do_redirect ) {
296 delete_option( 'generateblocks_do_activation_redirect' );
297 wp_safe_redirect( esc_url( admin_url( 'admin.php?page=generateblocks' ) ) );
298 exit;
299 }
300 }
301