PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.0.0
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.0.0
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / admin / index.php

index.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 3.0.0, at admin/index.php

347 lines 16.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Welcome screen.
4 */
5
6 // Exit if accessed directly.
7 if (!defined('ABSPATH')) {
8 exit;
9 }
10
11 if (!class_exists('Blockspare_Admin_Dashboard')) {
12 class Blockspare_Admin_Dashboard
13 {
14 function __construct()
15 {
16 add_action('admin_menu', array($this, 'add_dashboard_page'));
17
18 add_action('admin_enqueue_scripts', array($this, 'enqueue_dashboard_script'));
19
20 add_action('admin_init', array($this, 'redirect_to_blockspare_page'));
21
22 add_action( 'init', array($this,'blockspare_load_api_files'));
23
24 add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
25
26 add_filter( 'plugin_action_links_' . BLOCKSPARE_PLUGIN_BASE, [ $this, 'plugin_action_links' ] );
27 }
28
29 public function plugin_action_links( $links ) {
30 $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=blockspare' ), esc_html__( 'Get Started', 'blockspare' ) );
31
32 array_unshift( $links, $settings_link );
33
34 $links['bspro'] = sprintf( '<a href="%1$s" target="_blank" class="blockspare-pro-link">%2$s</a>', 'https://www.blockspare.com/pricing/', esc_html__( 'Get Blockspare Pro', 'blockspare' ) );
35
36 return $links;
37 }
38 public function plugin_row_meta( $plugin_meta, $plugin_file ) {
39 if ( BLOCKSPARE_PLUGIN_BASE === $plugin_file ) {
40 $row_meta = [
41 'starter' => '<a href="https://www.blockspare.com/starter-templates/" aria-label="' . esc_attr( esc_html__( 'View Blockspare Starter Templates', 'blockspare' ) ) . '" target="_blank">' . esc_html__( 'Starter Templates', 'blockspare' ) . '</a>',
42 'docs' => '<a href="https://www.blockspare.com/docs/" aria-label="' . esc_attr( esc_html__( 'View Blockspare Documentation', 'blockspare' ) ) . '" target="_blank">' . esc_html__( 'Docs & FAQs', 'blockspare' ) . '</a>',
43 'ideo' => '<a href="https://www.youtube.com/@blockspare" aria-label="' . esc_attr( esc_html__( 'View Blockspare Video Tutorials', 'blockspare' ) ) . '" target="_blank">' . esc_html__( 'Video Tutorials', 'blockspare' ) . '</a>',
44 ];
45
46 $plugin_meta = array_merge( $plugin_meta, $row_meta );
47 }
48
49 return $plugin_meta;
50 }
51
52 public function add_dashboard_page()
53 {
54
55 // @see images/blockspare-icon.svg
56 $svg = <<< SVG
57 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
58 viewBox="0 0 40 40" style="enable-background:new 0 0 40 40;" xml:space="preserve">
59 <g>
60 <g>
61 <path class="st0" d="M1.6,9.2v21.4l18.3-9.2L20.2,0L1.6,9.2z M16.9,19.8L4.9,26V10.9l12-6.1V19.8z"/>
62 <polygon id="XMLID_3_" class="st1" points="19.9,21.4 16.9,23 26,27.7 13.8,33.8 4.9,29 1.6,30.7 13.9,36.9 32.4,27.7 "/>
63 </g>
64 <g>
65 <polygon id="XMLID_2_" class="st0" points="23,1.5 23,19.8 32.4,24.6 32.4,9.4 35.3,10.9 35.3,29 38.4,30.7 38.4,9.2 29.4,4.8
66 29.2,19.7 26,18.4 26,3.1 "/>
67 <polygon id="XMLID_1_" class="st1" points="17,38.4 19.9,40 38.4,30.7 35.3,29 "/>
68 </g>
69 </g>
70 </svg>
71 SVG;
72
73 add_menu_page(
74 __('Blockspare', 'blockspare'), // Page Title.
75 __('Blockspare', 'blockspare'), // Menu Title.
76 'edit_posts', // Capability.
77 'blockspare', // Menu slug.
78 array($this, 'blockspare_admin_dashboard'), // Action.
79 'data:image/svg+xml;base64,' . base64_encode($svg) // Blockspare icon.
80 );
81
82 // Our getting started page.
83 add_submenu_page(
84 'blockspare', // Parent slug.
85 __( 'Getting Started', 'blockspare' ), // Page title.
86 __( 'Getting Started', 'blockspare' ), // Menu title.
87 'manage_options', // Capability.
88 'blockspare', // Menu slug.
89 array( $this, 'blockspare_admin_dashboard' ), // Callback function.
90 1 // Position
91 );
92 }
93
94
95 public function enqueue_dashboard_script($hook)
96 {
97 wp_enqueue_style('blockspare-admin', BLOCKSPARE_PLUGIN_URL .'admin/assets/css/style.css','','');
98 wp_enqueue_script( 'blockspare_dashboard_js', BLOCKSPARE_PLUGIN_URL. 'dist/block_admin_dashboard.js', array('react', 'react-dom', 'wp-element', 'wp-api-fetch', 'wp-polyfill'), '1.0' );
99 wp_enqueue_style('blockspare-admin-css',BLOCKSPARE_PLUGIN_URL.'dist/style-block_admin_dashboard.css');
100 $blockspare_dashboard_logo = BLOCKSPARE_PLUGIN_URL . 'admin/assets/images/blockspare-logo.png';
101 wp_localize_script(
102 'blockspare_dashboard_js',
103 'blockspare_dashboard',
104 array(
105
106 'logo'=>$blockspare_dashboard_logo,
107 "imagePath"=> "https://templatespare.com/wp-content/uploads/blockspare/blocks/",
108 "static_img"=>BLOCKSPARE_PLUGIN_URL,
109 'adminPath'=>admin_url('post-new.php?post_type=page&blockspare_show_intro=true')
110
111 )
112 );
113 }
114
115 public function blockspare_admin_dashboard()
116 {
117 ?>
118 <div id="bs-dashboard"></div>
119 <?php /*
120 <div class="wrap blockspare-wrap">
121
122 <header class="blockspare-header">
123 <img src="<?php echo esc_url(plugins_url('assets/blockspare-logo.png', __FILE__)) ?>"
124 alt="<?php esc_attr_e('Blockspare', 'blockspare') ?>" />
125
126 <h1><?php _e('Blockspare', 'blockspare') ?></h1>
127 <h2><?php _e('Beautiful Page Building Blocks for WordPress', 'blockspare') ?></h2>
128
129 <div class="blockspare-separator">
130 <svg class="blockspare-separator-double-wave" preserveAspectRatio="none" aria-hidden="true"
131 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1946 175">
132 <path class="st0"
133 d="M-.5 27.7v146.8h1946V10.7s-170.6 20.4-265 57.2c0 0-374.1 116.7-794.2 24.7 0 0-414.1-100.9-673.1-92-.1 0-102.9 5.2-213.7 27.1z">
134 </path>
135 <path class="st1"
136 d="M1945.5 69.9s-425.5-100-888 20.5c0 0-342.6 63.3-611.4 43.8 0 0-224.9-40.3-446.6-84.4V174h1946V69.9z">
137 </path>
138 <path d="M-.5 88s425.5-100 888 20.5c0 0 342.6 63.3 611.4 43.8 0 0 224.9-20.2 446.6-64.3v87H-.5V88z">
139 </path>
140 </svg>
141 </div>
142 </header>
143 <section class="blockspare-main-container">
144 <article class="blockspare-intro blockspare-section">
145
146 <div class="blockspare-intro-col blockspare-intro-desc">
147 <div class="blockspare-common-header-wrapper">
148 <span class="blockspare-subtitle"><?php _e('Amazing Blocks', 'blockspare') ?></span>
149 <h2><?php _e('Envision Amazing Layouts with Blockspare', 'blockspare') ?></h2>
150 </div>
151
152 <p><?php _e('Now you have Blockspare for your WordPress editor', 'blockspare') ?></p>
153 <ol>
154 <li>
155 <?php _e('Create a new page', 'blockspare') ?>
156 </li>
157 <li>
158 <?php _e('Click on the <span class="plus-btn-svg"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="#222"><path d="M10 1c-5 0-9 4-9 9s4 9 9 9 9-4 9-9-4-9-9-9zm0 16c-3.9 0-7-3.1-7-7s3.1-7 7-7 7 3.1 7 7-3.1 7-7 7zm1-11H9v3H6v2h3v3h2v-3h3V9h-3V6z"></path></svg></span> button to add a block', 'blockspare') ?>
159 </li>
160 <li>
161 <?php _e('Expand Blockspare panel!', 'blockspare') ?>
162 </li>
163 <li>
164 <?php _e('Select to add and customize a block!', 'blockspare') ?>
165 </li>
166 </ol>
167
168 <a href="<?php echo esc_url(admin_url('post-new.php?post_type=page&blockspare_show_intro=true')) ?>"
169 class="blockspare-button"
170 title="<?php esc_attr_e('Try it on New Page', 'blockspare') ?>"><?php _e('Try it on New Page', 'blockspare') ?></a>
171 </p>
172 </div>
173 <div class="blockspare-intro-col blockspare-intro-img">
174 <p><img src="<?php echo esc_url(plugins_url('assets/blockspare-adding-blocks.gif', __FILE__)) ?>"
175 alt="<?php esc_attr_e('Adding Blockspare', 'blockspare') ?>" class="blockspare-gif" /></p>
176 <p>
177 </div>
178 </article>
179 </section>
180 <section class="blockspare-body-container">
181 <div class="blockspare-body">
182
183 <article class="blockspare-section blockspare-block-intro">
184
185 <div class="blockspare-common-header-wrapper">
186 <span class="blockspare-subtitle"><?php _e('Enhanced set of Blocks', 'blockspare') ?></span>
187 <h3><?php _e('Start Creating Page using Enhanced set of Blocks in Minutes!', 'blockspare') ?></h3>
188 </div>
189
190 <p><?php _e('We design an elegant series of WordPress blocks to help you create the website you always wanted with ease.', 'blockspare') ?>
191 </p>
192 <!-- We put all the block controls here. -->
193 <div class="blockspare-available-blocks-wrapper">
194 <?php
195 $blockspare_blocks = blockspare_admin_blocks_list();
196 if (isset($blockspare_blocks) && !empty($blockspare_blocks)):
197 foreach ($blockspare_blocks as $block):
198 $blocks_name = $block['name'];
199 $icon_url = plugins_url("assets/" .$block['slug'] . "-image.png", __FILE__);
200 $demo_url = 'https://blockspare.com/block/'.$block['slug'];
201
202 ?>
203 <a class="blockspare-explore-btn" href="<?php echo esc_url($demo_url) ?>" target="_blank">
204 <div class="blockspare-available-blocks">
205
206 <img src="<?php echo esc_attr($icon_url); ?>" alt="<?php echo esc_attr($blocks_name) ?>">
207 <h4>
208 <?php echo esc_attr($blocks_name) ?>
209 </h4>
210
211
212
213 </div>
214 </a>
215 <?php
216 endforeach;
217 endif;
218
219 ?>
220 </div>
221 <div class="blocksparea-all-blocks-button"><a href="https://blockspare.com/" class="blockspare-button"
222 target="_blank"
223 title="<?php esc_attr_e('Explore All Blocks', 'blockspare') ?>"><?php _e('Explore All Blocks', 'blockspare') ?></a>
224 </div>
225 </article>
226 <aside class="blockspare-backward-compatibility-control-wrapper"></aside>
227 <?php if (BLOCKSPARE_SHOW_PRO_NOTICES): ?>
228 <aside class="blockspare-pro-control-wrapper"></aside>
229 <?php endif; ?>
230 </div>
231 <div class="blockspare-side">
232
233 <div class="blockspare-side-sticky">
234 <?php
235 $blockspare_pro = true;
236 if ($blockspare_pro == false ) : ?>
237 <aside class="blockspare-section blockspare-premium-section">
238 <h3><?php _e('Blockspare Pro', 'blockspare') ?></h3>
239 <p><?php _e('Want to use Blockspare to build an awesome site with more options and controls? Upgrade to Pro and get:', 'blockspare') ?>
240 </p>
241 <ul class="blockspare-premium-features">
242 <li><?php _e('30+ Custom WordPress Blocks', 'blockspare') ?></li>
243 <li><?php _e('110+ Pre-designed Blocks Layouts', 'blockspare') ?></li>
244 <li><?php _e('Gradient Colors Effects', 'blockspare') ?></li>
245 <li><?php _e('Additional Block Options', 'blockspare') ?></li>
246 <li><?php _e('Rearrangeable Inner Blocks', 'blockspare') ?></li>
247 <li><?php _e('Image Masking Colors Effects and Filters ', 'blockspare') ?></li>
248 <li><?php _e('All Premium Effects', 'blockspare') ?></li>
249 <li><?php _e('Customer Email Support', 'blockspare') ?></li>
250 <li><?php _e('Regular Updates & Premium Support', 'blockspare') ?></li>
251 </ul>
252 </p>
253 <p>
254 <a href="https://blockspare.com/" class="blockspare-button"
255 title="<?php esc_attr_e('Get Blockspare Pro', 'blockspare') ?>"><?php esc_attr_e('Get Blockspare Pro', 'blockspare') ?></a>
256 </p>
257
258 </aside>
259 <?php endif; ?>
260
261 <aside class="blockspare-section">
262 <h3><?php _e('Knowledge Base', 'blockspare') ?></h3>
263 <ul class="blockspare-list blockspare-knowledge-base">
264 <li>
265 <h4 class="blockspare-sub-headings">
266 <a href="https://blockspare.com/docs/"><?php esc_html_e('Documentations', 'blockspare') ?>
267 →</a>
268 </h4>
269 <p><?php esc_html_e('Do you have any difficulties regarding plugin setup and uses? Please visit Documentations page.', 'blockspare') ?>
270 </p>
271 </li>
272 <li>
273 <h4 class="blockspare-sub-headings">
274 <a href="https://blockspare.com/block/"><?php esc_html_e('Demos', 'blockspare') ?> →</a>
275 </h4>
276 <p><?php esc_html_e('We have also designed and displayed multiple type of layouts with Blockspare. For more details please visit our site.', 'blockspare') ?>
277 </p>
278 </li>
279 <li>
280 <h4 class="blockspare-sub-headings">
281 <a href="https://afthemes.com/supports/"><?php esc_html_e('Support', 'blockspare') ?>
282 →</a>
283 </h4>
284 <p><?php esc_html_e('You directly come upon to our support guys with your valuable queries.', 'blockspare') ?>
285 </p>
286 </li>
287 <li>
288 <h4 class="blockspare-sub-headings">
289 <a href="https://wordpress.org/plugins/blockspare/"><?php esc_html_e('WordPress Support Forum', 'blockspare') ?>
290 →</a>
291 </h4>
292 <p><?php esc_html_e('You can also go to our .org forum for any kind of support enquiries.', 'blockspare') ?>
293 </p>
294 </li>
295 <li>
296 <h4 class="blockspare-sub-headings">
297 <a href="https://blockspare.com/blog/"><?php esc_html_e('Latest Blog', 'blockspare') ?>
298 →</a>
299 </h4>
300 <p><?php esc_html_e('Get latest articles about WordPress.', 'blockspare') ?></p>
301 </li>
302 </ul>
303
304 </p>
305 </aside>
306 </div>
307
308 </div>
309 </section>
310 </div>
311 <?php */?>
312 <?php
313 }
314
315 /**
316 * Adds a marker to remember to redirect after activation.
317 * Redirecting right away will not work.
318 */
319 public static function start_redirect_to_blockspare_page()
320 {
321 update_option('blockspare_redirect_to_welcome', '1');
322 }
323
324 /**
325 * Redirect to the welcome screen if our marker exists.
326 */
327 public function redirect_to_blockspare_page()
328 {
329 if (get_option('blockspare_redirect_to_welcome')) {
330 delete_option('blockspare_redirect_to_welcome');
331 wp_redirect(esc_url(admin_url('admin.php?page=blockspare')));
332 die();
333 }
334 }
335 public function blockspare_load_api_files(){
336 require_once BLOCKSPARE_PLUGIN_DIR. '/admin/rest-request.php';
337 }
338
339
340
341 }
342
343 new Blockspare_Admin_Dashboard();
344 }
345
346 // Redirect to the welcome screen.
347 register_activation_hook(BLOCKSPARE_BASE_FILE, array('Blockspare_Admin_Dashboard', 'start_redirect_to_blockspare_page'));