PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.1.1
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.1.1
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.1.1, at admin/index.php

166 lines 6.8 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__( 'Design Library', '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__( 'Demos', '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', 'blockspare' ) . '</a>',
43 'video' => '<a href="https://afthemes.com/all-themes-plan/" aria-label="' . esc_attr( esc_html__( 'Access All Themes and Plugins', 'blockspare' ) ) . '" target="_blank">' . esc_html__( 'All Themes & Plugins', 'blockspare' ) . '</a>',
44 'support' => '<a href="https://afthemes.com/supports/" aria-label="' . esc_attr( esc_html__( 'Need help for Blockspare?', 'blockspare' ) ) . '" target="_blank">' . esc_html__( 'Need Help?', 'blockspare' ) . '</a>',
45 ];
46
47 $plugin_meta = array_merge( $plugin_meta, $row_meta );
48 }
49
50 return $plugin_meta;
51 }
52
53 public function add_dashboard_page()
54 {
55
56 // @see images/blockspare-icon.svg
57 $svg = <<< SVG
58 <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"
59 viewBox="0 0 40 40" style="enable-background:new 0 0 40 40;" xml:space="preserve">
60 <g>
61 <g>
62 <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"/>
63 <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 "/>
64 </g>
65 <g>
66 <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
67 29.2,19.7 26,18.4 26,3.1 "/>
68 <polygon id="XMLID_1_" class="st1" points="17,38.4 19.9,40 38.4,30.7 35.3,29 "/>
69 </g>
70 </g>
71 </svg>
72 SVG;
73
74 add_menu_page(
75 __('Blockspare', 'blockspare'), // Page Title.
76 __('Blockspare', 'blockspare'), // Menu Title.
77 'edit_posts', // Capability.
78 'blockspare', // Menu slug.
79 array($this, 'blockspare_admin_dashboard'), // Action.
80 'data:image/svg+xml;base64,' . base64_encode($svg) // Blockspare icon.
81 );
82
83
84 // Our getting started page.
85 add_submenu_page(
86 'blockspare', // Parent slug.
87 __('Design Library', 'blockspare'), // Page title.
88 __('Design Library', 'blockspare'), // Menu title.
89 'manage_options', // Capability.
90 'blockspare', // Menu slug.
91 array($this, 'blockspare_admin_dashboard'), // Callback function.
92 1 // Position
93 );
94
95 add_submenu_page(
96 'blockspare', // Parent slug.
97 __('My Templates', 'blockspare'), // Page title.
98 __('My Templates', 'blockspare'), // Menu title.
99 'manage_options', // Capability.
100 'edit.php?post_type=bs_templates', // Menu slug.
101
102 );
103 }
104
105
106 public function enqueue_dashboard_script($hook)
107 {
108 wp_enqueue_style('blockspare-admin', BLOCKSPARE_PLUGIN_URL .'admin/assets/css/style.css','','');
109 wp_enqueue_script( 'blockspare_dashboard_js', BLOCKSPARE_PLUGIN_URL. 'dist/block_admin_dashboard.js', array('react', 'react-dom', 'wp-components', 'wp-element', 'wp-api-fetch', 'wp-polyfill'), '1.0' );
110 wp_enqueue_style('blockspare-admin-css',BLOCKSPARE_PLUGIN_URL.'dist/style-block_admin_dashboard.css');
111 $blockspare_dashboard_logo = BLOCKSPARE_PLUGIN_URL . 'admin/assets/images/blockspare-logo.png';
112 wp_localize_script(
113 'blockspare_dashboard_js',
114 'blockspare_dashboard',
115 array(
116
117 'logo'=>$blockspare_dashboard_logo,
118 "imagePath"=> "https://templatespare.com/wp-content/uploads/blockspare-demo-data/blocks/",
119 "static_img"=>BLOCKSPARE_PLUGIN_URL,
120 'newPageUrl'=>admin_url('post-new.php?post_type=page&blockspare_create_block'),
121 'adminPath'=>admin_url('post-new.php?post_type=page&blockspare_show_intro=true'),
122 'pluginVesion'=>BLOCKSPARE_VERSION
123
124
125 )
126 );
127 }
128
129 public function blockspare_admin_dashboard()
130 {
131 ?>
132 <div id="bs-dashboard"></div>
133
134 <?php
135 }
136
137 /**
138 * Adds a marker to remember to redirect after activation.
139 * Redirecting right away will not work.
140 */
141 public static function start_redirect_to_blockspare_page()
142 {
143 update_option('blockspare_redirect_to_welcome', '1');
144 }
145
146 /**
147 * Redirect to the welcome screen if our marker exists.
148 */
149 public function redirect_to_blockspare_page()
150 {
151 if (get_option('blockspare_redirect_to_welcome')) {
152 delete_option('blockspare_redirect_to_welcome');
153 wp_redirect(esc_url(admin_url('admin.php?page=blockspare')));
154 die();
155 }
156 }
157
158
159
160 }
161
162 new Blockspare_Admin_Dashboard();
163 }
164
165 // Redirect to the welcome screen.
166 register_activation_hook(BLOCKSPARE_BASE_FILE, array('Blockspare_Admin_Dashboard', 'start_redirect_to_blockspare_page'));