PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.4.6
Block Animations, Motion & Scroll Effects – Ghost Kit v3.4.6
3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / settings / index.php

index.php in Block Animations, Motion & Scroll Effects – Ghost Kit 3.4.6, at settings/index.php

232 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Additional PHP for blocks.
4 *
5 * @package ghostkit
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * GhostKit_Settings
14 */
15 class GhostKit_Settings {
16 /**
17 * GhostKit_Settings constructor.
18 */
19 public function __construct() {
20 // Load admin style sheet and JavaScript.
21 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
22
23 // Sometimes redirect is not working on page opens. Admin Init is a solution.
24 add_action( 'admin_init', array( $this, 'go_pro_redirect' ) );
25
26 // Add the options page and menu item.
27 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
28 }
29
30 /**
31 * Register and enqueue admin-specific style sheet.
32 */
33 public function admin_enqueue_scripts() {
34 $screen = get_current_screen();
35
36 GhostKit_Assets::enqueue_style(
37 'ghostkit-admin',
38 'build/assets/admin/css/admin',
39 array(),
40 filemtime( ghostkit()->plugin_path . 'build/assets/admin/css/admin.css' )
41 );
42 wp_style_add_data( 'ghostkit-admin', 'rtl', 'replace' );
43 wp_style_add_data( 'ghostkit-admin', 'suffix', '.min' );
44
45 GhostKit_Assets::enqueue_style(
46 'ghostkit-settings',
47 'build/settings/style',
48 array(),
49 filemtime( ghostkit()->plugin_path . 'build/settings/style.css' )
50 );
51 wp_style_add_data( 'ghostkit-settings', 'rtl', 'replace' );
52 wp_style_add_data( 'ghostkit-settings', 'suffix', '.min' );
53
54 if ( 'toplevel_page_ghostkit' !== $screen->id ) {
55 return;
56 }
57
58 $block_editor_context = new WP_Block_Editor_Context();
59
60 // Preload server-registered block schemas.
61 wp_add_inline_script(
62 'wp-blocks',
63 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
64 );
65
66 wp_add_inline_script(
67 'wp-blocks',
68 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $block_editor_context ) ) ),
69 'after'
70 );
71
72 // phpcs:ignore
73 do_action( 'enqueue_block_editor_assets' );
74
75 // phpcs:ignore
76 do_action( 'enqueue_block_assets' );
77
78 // Ghost Kit Settings.
79 GhostKit_Assets::enqueue_script(
80 'ghostkit-settings',
81 'build/settings/index',
82 array( 'ghostkit-helper' )
83 );
84
85 wp_localize_script(
86 'ghostkit-settings',
87 'ghostkitSettingsData',
88 array(
89 'api_nonce' => wp_create_nonce( 'wp_rest' ),
90 'api_url' => rest_url( 'ghostkit/v1/' ),
91 )
92 );
93
94 wp_enqueue_style( 'wp-components' );
95
96 if ( function_exists( 'wp_enqueue_media' ) ) {
97 wp_enqueue_media();
98 }
99 }
100
101 /**
102 * Go Pro.
103 * Redirect to the Pro purchase page.
104 */
105 public function go_pro_redirect() {
106 // phpcs:ignore
107 if ( ! isset( $_GET['page'] ) || empty( $_GET['page'] ) ) {
108 return;
109 }
110
111 // phpcs:ignore
112 if ( 'ghostkit_go_pro' === $_GET['page'] ) {
113 $medium = 'admin_menu';
114
115 // phpcs:ignore
116 if ( isset( $_GET['utm_medium'] ) ) {
117 // phpcs:ignore
118 $medium = $_GET['utm_medium'];
119 }
120
121 // phpcs:ignore
122 wp_redirect( ghostkit()->go_pro_link() . '?utm_source=plugin&utm_medium=' . esc_attr( $medium ) . '&utm_campaign=go_pro&utm_content=' . GHOSTKIT_VERSION );
123 exit();
124 }
125 }
126
127 /**
128 * Add admin menu.
129 */
130 public function admin_menu() {
131 add_menu_page(
132 esc_html__( 'Ghost Kit', 'ghostkit' ),
133 esc_html__( 'Ghost Kit', 'ghostkit' ),
134 'manage_options',
135 'ghostkit',
136 array( $this, 'display_admin_page' ),
137 // phpcs:ignore
138 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( ghostkit()->plugin_path . 'assets/images/admin-icon.svg' ) ),
139 56.9
140 );
141
142 add_submenu_page(
143 'ghostkit',
144 '',
145 esc_html__( 'Blocks', 'ghostkit' ),
146 'manage_options',
147 'ghostkit'
148 );
149 add_submenu_page(
150 'ghostkit',
151 '',
152 esc_html__( 'Icons', 'ghostkit' ),
153 'manage_options',
154 'admin.php?page=ghostkit&sub_page=icons'
155 );
156 add_submenu_page(
157 'ghostkit',
158 '',
159 esc_html__( 'Typography', 'ghostkit' ),
160 'manage_options',
161 'admin.php?page=ghostkit&sub_page=typography'
162 );
163 add_submenu_page(
164 'ghostkit',
165 '',
166 esc_html__( 'Fonts', 'ghostkit' ),
167 'manage_options',
168 'admin.php?page=ghostkit&sub_page=fonts'
169 );
170 add_submenu_page(
171 'ghostkit',
172 '',
173 esc_html__( 'Breakpoints', 'ghostkit' ),
174 'manage_options',
175 'admin.php?page=ghostkit&sub_page=breakpoints'
176 );
177 add_submenu_page(
178 'ghostkit',
179 '',
180 esc_html__( 'CSS & JavaScript', 'ghostkit' ),
181 'manage_options',
182 'admin.php?page=ghostkit&sub_page=css_js'
183 );
184
185 if ( GhostKit_Templates::is_allowed() ) {
186 add_submenu_page(
187 'ghostkit',
188 '',
189 esc_html__( 'Templates', 'ghostkit' ),
190 'manage_options',
191 'edit.php?post_type=ghostkit_template'
192 );
193 }
194
195 add_submenu_page(
196 'ghostkit',
197 '',
198 '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . esc_html__( 'Go Pro', 'ghostkit' ),
199 'manage_options',
200 'ghostkit_go_pro',
201 array( $this, 'go_pro_redirect' )
202 );
203
204 global $wp_version;
205
206 // Since WP 6.3 user have an ability to open the reusable blocks page
207 // From the Appearance -> Editor -> Patterns.
208 if ( ! version_compare( $wp_version, '6.3', '>=' ) ) {
209 add_menu_page(
210 esc_html__( 'Reusable Blocks', 'ghostkit' ),
211 esc_html__( 'Reusable Blocks', 'ghostkit' ),
212 'read',
213 'edit.php?post_type=wp_block',
214 '',
215 'dashicons-editor-table',
216 57
217 );
218 }
219 }
220
221 /**
222 * Render the admin page.
223 */
224 public function display_admin_page() {
225 ?>
226 <div class="ghostkit-admin-page"></div>
227 <?php
228 }
229 }
230
231 new GhostKit_Settings();
232