PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 2.25.0
Block Animations, Motion & Scroll Effects – Ghost Kit v2.25.0
3.7.2 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 2.25.0, at settings/index.php

221 lines 6.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 // work only if Gutenberg available.
21 if ( ! function_exists( 'register_block_type' ) ) {
22 return;
23 }
24
25 // Load admin style sheet and JavaScript.
26 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
27
28 // Sometimes redirect is not working on page opens. Admin Init is a solution.
29 add_action( 'admin_init', array( $this, 'go_pro_redirect' ) );
30
31 // Add the options page and menu item.
32 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
33 }
34
35 /**
36 * Register and enqueue admin-specific style sheet.
37 */
38 public function admin_enqueue_scripts() {
39 $screen = get_current_screen();
40
41 wp_enqueue_style(
42 'ghostkit-admin',
43 ghostkit()->plugin_url . 'assets/admin/css/admin.min.css',
44 array(),
45 filemtime( ghostkit()->plugin_path . 'assets/admin/css/admin.min.css' )
46 );
47 wp_style_add_data( 'ghostkit-admin', 'rtl', 'replace' );
48 wp_style_add_data( 'ghostkit-admin', 'suffix', '.min' );
49
50 wp_enqueue_style(
51 'ghostkit-settings',
52 ghostkit()->plugin_url . 'settings/style.min.css',
53 array(),
54 filemtime( ghostkit()->plugin_path . 'settings/style.min.css' )
55 );
56 wp_style_add_data( 'ghostkit-settings', 'rtl', 'replace' );
57 wp_style_add_data( 'ghostkit-settings', 'suffix', '.min' );
58
59 if ( 'toplevel_page_ghostkit' !== $screen->id ) {
60 return;
61 }
62
63 $block_categories = array();
64 if ( function_exists( 'get_block_categories' ) ) {
65 $block_categories = get_block_categories( get_post() );
66 } elseif ( function_exists( 'gutenberg_get_block_categories' ) ) {
67 $block_categories = gutenberg_get_block_categories( get_post() );
68 }
69
70 // enqueue blocks library.
71 wp_enqueue_script( 'wp-block-library' );
72
73 wp_add_inline_script(
74 'wp-blocks',
75 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( $block_categories ) ),
76 'after'
77 );
78
79 // Ghost Kit Settings.
80 wp_enqueue_script(
81 'ghostkit-settings',
82 ghostkit()->plugin_url . 'settings/index.min.js',
83 array( 'ghostkit-helper', 'wp-data', 'wp-element', 'wp-components', 'wp-api', 'wp-api-request', 'wp-i18n' ),
84 filemtime( ghostkit()->plugin_path . 'settings/index.min.js' ),
85 true
86 );
87
88 wp_localize_script(
89 'ghostkit-settings',
90 'ghostkitSettingsData',
91 array(
92 'api_nonce' => wp_create_nonce( 'wp_rest' ),
93 'api_url' => rest_url( 'ghostkit/v1/' ),
94 )
95 );
96
97 // phpcs:ignore
98 do_action( 'enqueue_block_editor_assets' );
99
100 wp_enqueue_style( 'wp-components' );
101
102 if ( function_exists( 'wp_enqueue_media' ) ) {
103 wp_enqueue_media();
104 }
105 }
106
107 /**
108 * Go Pro.
109 * Redirect to the Pro purchase page.
110 */
111 public function go_pro_redirect() {
112 // phpcs:ignore
113 if ( ! isset( $_GET['page'] ) || empty( $_GET['page'] ) ) {
114 return;
115 }
116
117 // phpcs:ignore
118 if ( 'ghostkit_go_pro' === $_GET['page'] ) {
119 $medium = 'admin_menu';
120
121 // phpcs:ignore
122 if ( isset( $_GET['utm_medium'] ) ) {
123 // phpcs:ignore
124 $medium = $_GET['utm_medium'];
125 }
126
127 // phpcs:ignore
128 wp_redirect( ghostkit()->go_pro_link() . '?utm_source=plugin&utm_medium=' . esc_attr( $medium ) . '&utm_campaign=go_pro&utm_content=2.25.0' );
129 exit();
130 }
131 }
132
133 /**
134 * Add admin menu.
135 */
136 public function admin_menu() {
137 add_menu_page(
138 esc_html__( 'Ghost Kit', 'ghostkit' ),
139 esc_html__( 'Ghost Kit', 'ghostkit' ),
140 'manage_options',
141 'ghostkit',
142 array( $this, 'display_admin_page' ),
143 // phpcs:ignore
144 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( ghostkit()->plugin_path . 'assets/images/admin-icon.svg' ) ),
145 56.9
146 );
147
148 add_submenu_page(
149 'ghostkit',
150 '',
151 esc_html__( 'Blocks', 'ghostkit' ),
152 'manage_options',
153 'ghostkit'
154 );
155 add_submenu_page(
156 'ghostkit',
157 '',
158 esc_html__( 'Icons', 'ghostkit' ),
159 'manage_options',
160 'admin.php?page=ghostkit&sub_page=icons'
161 );
162 add_submenu_page(
163 'ghostkit',
164 '',
165 esc_html__( 'Typography', 'ghostkit' ),
166 'manage_options',
167 'admin.php?page=ghostkit&sub_page=typography'
168 );
169 add_submenu_page(
170 'ghostkit',
171 '',
172 esc_html__( 'Fonts', 'ghostkit' ),
173 'manage_options',
174 'admin.php?page=ghostkit&sub_page=fonts'
175 );
176 add_submenu_page(
177 'ghostkit',
178 '',
179 esc_html__( 'Breakpoints', 'ghostkit' ),
180 'manage_options',
181 'admin.php?page=ghostkit&sub_page=breakpoints'
182 );
183 add_submenu_page(
184 'ghostkit',
185 '',
186 esc_html__( 'CSS & JavaScript', 'ghostkit' ),
187 'manage_options',
188 'admin.php?page=ghostkit&sub_page=css_js'
189 );
190 add_submenu_page(
191 'ghostkit',
192 '',
193 '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . esc_html__( 'Go Pro', 'ghostkit' ),
194 'manage_options',
195 'ghostkit_go_pro',
196 array( $this, 'go_pro_redirect' )
197 );
198
199 add_menu_page(
200 esc_html__( 'Reusable Blocks', 'ghostkit' ),
201 esc_html__( 'Reusable Blocks', 'ghostkit' ),
202 'read',
203 'edit.php?post_type=wp_block',
204 '',
205 'dashicons-editor-table',
206 57
207 );
208 }
209
210 /**
211 * Render the admin page.
212 */
213 public function display_admin_page() {
214 ?>
215 <div class="ghostkit-admin-page"></div>
216 <?php
217 }
218 }
219
220 new GhostKit_Settings();
221