PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.1.1
GenerateBlocks v1.1.1
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 6 years ago class-enqueue-css.php 6 years ago class-plugin-update.php 6 years ago class-settings.php 6 years ago dashboard.php 6 years ago defaults.php 6 years ago functions.php 6 years ago general.php 6 years ago generate-css.php 6 years ago
dashboard.php
231 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' );
13 /**
14 * Register our Dashboard page.
15 *
16 * @since 0.1
17 */
18 function generateblocks_register_dashboard() {
19 add_options_page(
20 __( 'GenerateBlocks', 'generateblocks' ),
21 __( 'GenerateBlocks', 'generateblocks' ),
22 'manage_options',
23 'generateblocks',
24 'generateblocks_do_dashboard'
25 );
26 }
27
28 add_action( 'admin_head', 'generateblocks_fix_dashboard_menu_item' );
29 /**
30 * Highlight the Settings menu item when on the Dashboard.
31 *
32 * @since 1.0
33 */
34 function generateblocks_fix_dashboard_menu_item() {
35 global $parent_file, $submenu_file;
36 $screen = get_current_screen();
37
38 if ( 'settings_page_generateblocks' === $screen->id ) {
39 $submenu_file = 'generateblocks-settings'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
40 }
41
42 remove_submenu_page( 'options-general.php', 'generateblocks' );
43 }
44
45 add_action( 'admin_enqueue_scripts', 'generateblocks_enqueue_dashboard_scripts' );
46 /**
47 * Add our scripts to the page.
48 *
49 * @since 0.1
50 */
51 function generateblocks_enqueue_dashboard_scripts() {
52 $screen = get_current_screen();
53
54 if ( 'settings_page_generateblocks' === $screen->id || 'settings_page_generateblocks-settings' === $screen->id ) {
55 wp_enqueue_style(
56 'generateblocks-dashboard',
57 GENERATEBLOCKS_DIR_URL . 'assets/css/dashboard.css',
58 array(),
59 filemtime( GENERATEBLOCKS_DIR . 'assets/css/dashboard.css' )
60 );
61 }
62 }
63
64 /**
65 * Build our Dashboard menu.
66 */
67 function generateblocks_dashboard_navigation() {
68 $screen = get_current_screen();
69
70 $tabs = apply_filters(
71 'generateblocks_dashboard_tabs',
72 array(
73 'dashboard' => array(
74 'name' => __( 'Dashboard', 'generateblocks' ),
75 'url' => admin_url( 'options-general.php?page=generateblocks' ),
76 'class' => 'settings_page_generateblocks' === $screen->id ? 'active' : '',
77 ),
78 'settings' => array(
79 'name' => __( 'Settings', 'generateblocks' ),
80 'url' => admin_url( 'options-general.php?page=generateblocks-settings' ),
81 'class' => 'settings_page_generateblocks-settings' === $screen->id ? 'active' : '',
82 ),
83 )
84 );
85
86 // Don't print any markup if we only have one tab.
87 if ( count( $tabs ) === 1 ) {
88 return;
89 }
90 ?>
91 <div class="gblocks-navigation">
92 <?php
93 foreach ( $tabs as $tab ) {
94 printf(
95 '<a href="%1$s" class="%2$s">%3$s</a>',
96 esc_url( $tab['url'] ),
97 esc_attr( $tab['class'] ),
98 esc_html( $tab['name'] )
99 );
100 }
101 ?>
102 </div>
103 <?php
104 }
105
106 /**
107 * Output our Dashboard HTML.
108 *
109 * @since 0.1
110 */
111 function generateblocks_do_dashboard() {
112 ?>
113 <div class="wrap gblocks-dashboard-wrap">
114 <div class="gblocks-dashboard-header">
115 <div class="gblocks-dashboard-header-content">
116 <h1 class="gblocks-logo">
117 <a href="https://generateblocks.com" target="_blank" rel="noopener noreferrer">
118 <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' ); ?>" />
119 </a>
120 <span class="gblocks-version"><?php echo esc_html( GENERATEBLOCKS_VERSION ); ?></span>
121 </h1>
122 </div>
123
124 <?php generateblocks_dashboard_navigation(); ?>
125 </div>
126
127 <div class="gblocks-dashboard-intro-content">
128 <?php esc_html_e( 'A small collection of lightweight WordPress blocks that can accomplish nearly anything.', 'generateblocks' ); ?>
129
130 <div class="gblocks-sub-navigation">
131 <a class="button" href="https://generateblocks.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn More', 'generateblocks' ); ?></a>
132 <a class="button" href="https://docs.generateblocks.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Documentation', 'generateblocks' ); ?></a>
133 </div>
134 </div>
135
136 <div class="gblocks-dashboard-content-container">
137 <div class="gblocks-dashboard-blocks">
138 <div class="gblocks-block">
139 <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">
140 <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"/>
141 </svg>
142
143 <h3><?php esc_html_e( 'Container', 'generateblocks' ); ?></h3>
144 <p><?php esc_html_e( 'Organize your content into rows and sections.', 'generateblocks' ); ?></p>
145 </div>
146
147 <div class="gblocks-block">
148 <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">
149 <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"/>
150 </svg>
151
152 <h3><?php esc_html_e( 'Grid', 'generateblocks' ); ?></h3>
153 <p><?php esc_html_e( 'Create advanced layouts with flexible grids.', 'generateblocks' ); ?></p>
154 </div>
155
156 <div class="gblocks-block">
157 <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%">
158 <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>
159 </svg>
160
161 <h3><?php esc_html_e( 'Headline', 'generateblocks' ); ?></h3>
162 <p><?php esc_html_e( 'Craft text-rich content with advanced typography.', 'generateblocks' ); ?></p>
163 </div>
164
165 <div class="gblocks-block">
166 <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">
167 <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"/>
168 </svg>
169
170 <h3><?php esc_html_e( 'Buttons', 'generateblocks' ); ?></h3>
171 <p><?php esc_html_e( 'Drive conversions with beautiful buttons.', 'generateblocks' ); ?></p>
172 </div>
173 </div>
174
175 <div class="gblocks-getting-started">
176 <p><?php esc_html_e( 'To get started, head over to the block editor and open the GenerateBlocks category.', 'generatepress' ); ?></p>
177 <img width="400" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/add-blocks.png'; ?>" alt="" />
178 </div>
179
180 <div class="gblocks-generatepress">
181 <div class="gblocks-inside-generatepress">
182 <div class="gblocks-generatepress-content">
183 <img width="300" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress.svg'; ?>" alt="" />
184 <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>
185 <div class="stats">
186 <div class="downloads">
187 <strong>2,000,000+</strong><br> <?php esc_html_e( 'Downloads', 'generateblocks' ); ?>
188 </div>
189
190 <div class="stars">
191 <strong>1000+</strong><br>
192 <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">
193 </div>
194
195 <div class="active-websites">
196 <strong>300,000+</strong><br> <?php esc_html_e( 'Active websites', 'generateblocks' ); ?>
197 </div>
198
199 <div class="active-websites">
200 <strong>60,000+</strong><br> <?php esc_html_e( 'Happy customers', 'generateblocks' ); ?>
201 </div>
202 </div>
203 <a class="gblocks-button" href="https://generatepress.com" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn more', 'generateblocks' ); ?></a>
204 </div>
205
206 <div class="gblocks-generatepress-image">
207 <img width="450" src="<?php echo esc_url( GENERATEBLOCKS_DIR_URL ) . 'assets/images/generatepress-sites.png'; ?>" alt="" />
208 </div>
209 </div>
210 </div>
211 </div>
212 </div>
213 <?php
214 }
215
216 add_action( 'admin_init', 'generateblocks_dashboard_redirect' );
217 /**
218 * Redirect to the Dashboard page on single plugin activation.
219 *
220 * @since 0.1
221 */
222 function generateblocks_dashboard_redirect() {
223 $do_redirect = apply_filters( 'generateblocks_do_activation_redirect', get_option( 'generateblocks_do_activation_redirect', false ) );
224
225 if ( $do_redirect ) {
226 delete_option( 'generateblocks_do_activation_redirect' );
227 wp_safe_redirect( esc_url( admin_url( 'options-general.php?page=generateblocks' ) ) );
228 exit;
229 }
230 }
231