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

167 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 25
82 );
83
84
85 // Our getting started page.
86 add_submenu_page(
87 'blockspare', // Parent slug.
88 __('Design Library', 'blockspare'), // Page title.
89 __('Design Library', 'blockspare'), // Menu title.
90 'manage_options', // Capability.
91 'blockspare', // Menu slug.
92 array($this, 'blockspare_admin_dashboard'), // Callback function.
93 1 // Position
94 );
95
96 add_submenu_page(
97 'blockspare', // Parent slug.
98 __('My Templates', 'blockspare'), // Page title.
99 __('My Templates', 'blockspare'), // Menu title.
100 'manage_options', // Capability.
101 'edit.php?post_type=bs_templates', // Menu slug.
102
103 );
104 }
105
106
107 public function enqueue_dashboard_script($hook)
108 {
109 wp_enqueue_style('blockspare-admin', BLOCKSPARE_PLUGIN_URL .'admin/assets/css/style.css','','');
110 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' );
111 wp_enqueue_style('blockspare-admin-css',BLOCKSPARE_PLUGIN_URL.'dist/style-block_admin_dashboard.css');
112 $blockspare_dashboard_logo = BLOCKSPARE_PLUGIN_URL . 'admin/assets/images/blockspare-logo.png';
113 wp_localize_script(
114 'blockspare_dashboard_js',
115 'blockspare_dashboard',
116 array(
117
118 'logo'=>$blockspare_dashboard_logo,
119 "imagePath"=> "https://templatespare.com/wp-content/uploads/blockspare-demo-data/blocks/",
120 "static_img"=>BLOCKSPARE_PLUGIN_URL,
121 'newPageUrl'=>admin_url('post-new.php?post_type=page&blockspare_create_block'),
122 'adminPath'=>admin_url('post-new.php?post_type=page&blockspare_show_intro=true'),
123 'pluginVesion'=>BLOCKSPARE_VERSION
124
125
126 )
127 );
128 }
129
130 public function blockspare_admin_dashboard()
131 {
132 ?>
133 <div id="bs-dashboard"></div>
134
135 <?php
136 }
137
138 /**
139 * Adds a marker to remember to redirect after activation.
140 * Redirecting right away will not work.
141 */
142 public static function start_redirect_to_blockspare_page()
143 {
144 update_option('blockspare_redirect_to_welcome', '1');
145 }
146
147 /**
148 * Redirect to the welcome screen if our marker exists.
149 */
150 public function redirect_to_blockspare_page()
151 {
152 if (get_option('blockspare_redirect_to_welcome')) {
153 delete_option('blockspare_redirect_to_welcome');
154 wp_redirect(esc_url(admin_url('admin.php?page=blockspare')));
155 die();
156 }
157 }
158
159
160
161 }
162
163 new Blockspare_Admin_Dashboard();
164 }
165
166 // Redirect to the welcome screen.
167 register_activation_hook(BLOCKSPARE_BASE_FILE, array('Blockspare_Admin_Dashboard', 'start_redirect_to_blockspare_page'));