| 1 |
<?php |
| 2 |
/** |
| 3 |
* Load assets for our blocks. |
| 4 |
* |
| 5 |
* @package Gutenify |
| 6 |
*/ |
| 7 |
|
| 8 |
// Exit if accessed directly. |
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Load general assets for our blocks. |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
*/ |
| 18 |
class Gutenify_Block_Assets { |
| 19 |
/** |
| 20 |
* This plugin's instance. |
| 21 |
* |
| 22 |
* @var Gutenify_Block_Assets |
| 23 |
*/ |
| 24 |
private static $instance; |
| 25 |
|
| 26 |
/** |
| 27 |
* Registers the plugin. |
| 28 |
* |
| 29 |
* @return Gutenify_Block_Assets |
| 30 |
*/ |
| 31 |
public static function register() { |
| 32 |
if ( null === self::$instance ) { |
| 33 |
self::$instance = new Gutenify_Block_Assets(); |
| 34 |
} |
| 35 |
|
| 36 |
return self::$instance; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* The Constructor. |
| 41 |
*/ |
| 42 |
public function __construct() { |
| 43 |
add_action( 'enqueue_block_assets', array( $this, 'block_assets' ) ); |
| 44 |
add_action( 'init', array( $this, 'editor_assets' ) ); |
| 45 |
add_action( 'wp_enqueue_scripts', array( $this, 'add_block_inline_css' ), 200 ); |
| 46 |
add_action( 'admin_footer', array( $this, 'add_admin_global_inline_css' ), 200 ); |
| 47 |
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ), 9 ); |
| 48 |
add_action( 'enqueue_block_editor_assets', array( $this, 'editor_scripts' ) ); |
| 49 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Loads the asset file for the given script or style. |
| 54 |
* Returns a default if the asset file is not found. |
| 55 |
* |
| 56 |
* @param string $filepath The name of the file without the extension. |
| 57 |
* |
| 58 |
* @return array The asset file contents. |
| 59 |
*/ |
| 60 |
public function get_asset_file( $filepath ) { |
| 61 |
$asset_path = GUTENIFY_PLUGIN_DIR . $filepath . '.asset.php'; |
| 62 |
|
| 63 |
return file_exists( $asset_path ) |
| 64 |
? include $asset_path |
| 65 |
: array( |
| 66 |
'dependencies' => array(), |
| 67 |
'version' => GUTENIFY_VERSION, |
| 68 |
); |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Enqueue block assets for use within Gutenberg. |
| 73 |
* |
| 74 |
* @access public |
| 75 |
*/ |
| 76 |
public function block_assets() { |
| 77 |
if ( is_admin() ) { |
| 78 |
return false; |
| 79 |
} |
| 80 |
global $post; |
| 81 |
|
| 82 |
// Only load the front end CSS if a Gutenify is in use. |
| 83 |
$has_gutenify = ! is_singular(); |
| 84 |
|
| 85 |
if ( ! is_admin() && is_singular() ) { |
| 86 |
$wp_post = get_post( $post ); |
| 87 |
|
| 88 |
// This is similar to has_block() in core, but will match anything |
| 89 |
// in the gutenify/* namespace. |
| 90 |
if ( $wp_post instanceof WP_Post ) { |
| 91 |
$has_gutenify = ! empty( |
| 92 |
array_filter( |
| 93 |
array( |
| 94 |
false !== strpos( $wp_post->post_content, '<!-- wp:gutenify/' ), |
| 95 |
has_block( 'core/block', $wp_post ), |
| 96 |
has_block( 'core/button', $wp_post ), |
| 97 |
has_block( 'core/cover', $wp_post ), |
| 98 |
has_block( 'core/heading', $wp_post ), |
| 99 |
has_block( 'core/image', $wp_post ), |
| 100 |
has_block( 'core/gallery', $wp_post ), |
| 101 |
has_block( 'core/list', $wp_post ), |
| 102 |
has_block( 'core/paragraph', $wp_post ), |
| 103 |
has_block( 'core/pullquote', $wp_post ), |
| 104 |
has_block( 'core/quote', $wp_post ), |
| 105 |
) |
| 106 |
) |
| 107 |
); |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
// if ( ! $has_gutenify && ! $this->is_page_gutenberg() ) { |
| 112 |
// return; |
| 113 |
// } |
| 114 |
|
| 115 |
$fonts_url = gutenify_fonts_url(); |
| 116 |
wp_enqueue_style( 'gutenify-fonts', $fonts_url, array(), null ); |
| 117 |
|
| 118 |
// Styles. |
| 119 |
$name = 'style-gutenify'; |
| 120 |
$filepath = 'dist/' . $name; |
| 121 |
$asset_file = $this->get_asset_file( $filepath ); |
| 122 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 123 |
|
| 124 |
$deps = array( 'gutenify-fontawesome-style' ); |
| 125 |
|
| 126 |
if ( $fonts_url ) { |
| 127 |
$deps[] = 'gutenify-fonts'; |
| 128 |
} |
| 129 |
|
| 130 |
global $wp_styles; |
| 131 |
if ( in_array( 'global-styles', $wp_styles->queue ) ) { |
| 132 |
$deps[] = 'global-styles'; |
| 133 |
} |
| 134 |
if ( in_array( 'woocommerce-layout', $wp_styles->queue ) ) { |
| 135 |
$deps[] = 'woocommerce-layout'; |
| 136 |
} |
| 137 |
|
| 138 |
wp_enqueue_style( 'gutenify-frontend', GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', $deps, $asset_file['version'] ); |
| 139 |
|
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* Enqueue block assets for use within Gutenberg. |
| 144 |
* |
| 145 |
* @access public |
| 146 |
*/ |
| 147 |
public function editor_assets() { |
| 148 |
|
| 149 |
// Styles. |
| 150 |
$name = 'gutenify'; |
| 151 |
$filepath = 'dist/' . $name; |
| 152 |
$asset_file = $this->get_asset_file( $filepath ); |
| 153 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 154 |
|
| 155 |
wp_register_style( 'gutenify-fontawesome-style', GUTENIFY_PLUGIN_URL . '/assets/fontawesome/css/all.css', array(), 'v4' ); |
| 156 |
|
| 157 |
$fonts_url = gutenify_fonts_url(); |
| 158 |
wp_enqueue_style( 'gutenify-fonts', $fonts_url, array(), null ); |
| 159 |
|
| 160 |
$deps = array( 'gutenify-fontawesome-style' ); |
| 161 |
|
| 162 |
if ( $fonts_url ) { |
| 163 |
$deps[] = 'gutenify-fonts'; |
| 164 |
} |
| 165 |
|
| 166 |
if ( class_exists( 'woocommerce' ) ) { |
| 167 |
$deps[] = 'wc-blocks-editor-style'; |
| 168 |
} |
| 169 |
|
| 170 |
wp_register_style( |
| 171 |
'gutenify-editor', |
| 172 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 173 |
$deps, |
| 174 |
$asset_file['version'] |
| 175 |
); |
| 176 |
|
| 177 |
// Scripts. |
| 178 |
$name = 'gutenify'; // gutenify.js. |
| 179 |
$filepath = 'dist/' . $name; |
| 180 |
$asset_file = $this->get_asset_file( $filepath ); |
| 181 |
|
| 182 |
wp_register_script( |
| 183 |
'gutenify-editor', |
| 184 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 185 |
array_merge( $asset_file['dependencies'], array( 'wp-api', 'gutenify-global' ) ), |
| 186 |
$asset_file['version'], |
| 187 |
true |
| 188 |
); |
| 189 |
|
| 190 |
$post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT ); |
| 191 |
|
| 192 |
wp_localize_script( |
| 193 |
'gutenify-editor', |
| 194 |
'gutenify_block_data', |
| 195 |
array( |
| 196 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 197 |
'site_url' => esc_url( site_url() ), |
| 198 |
'settings_url' => esc_url( admin_url( 'edit.php?post_type=gutenify_template&page=gutenify-settings' ) ), |
| 199 |
'add_template_url' => esc_url( admin_url( 'post-new.php?post_type=gutenify_template' ) ), |
| 200 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 201 |
) |
| 202 |
); |
| 203 |
|
| 204 |
$localized_values = array( |
| 205 |
'font_families' => gutenify_font_families(), |
| 206 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 207 |
'site_url' => esc_url( site_url() ), |
| 208 |
); |
| 209 |
wp_localize_script( |
| 210 |
'gutenify-editor', |
| 211 |
'_gutenify', |
| 212 |
apply_filters( 'gutenify-admin-localized-values', $localized_values ), |
| 213 |
); |
| 214 |
|
| 215 |
wp_localize_script( |
| 216 |
'gutenify-editor', |
| 217 |
'_gutenify_vars', |
| 218 |
array( |
| 219 |
'site_url' => esc_url( site_url() ), |
| 220 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 221 |
'gutenify_version' => GUTENIFY_VERSION, |
| 222 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 223 |
'is_pro_activated' => apply_filters( 'gutenify_pro_activation_status', false ), |
| 224 |
) |
| 225 |
); |
| 226 |
} |
| 227 |
|
| 228 |
/** |
| 229 |
* Enqueue front-end assets for blocks. |
| 230 |
* |
| 231 |
* @access public |
| 232 |
* @since 1.9.5 |
| 233 |
*/ |
| 234 |
public function frontend_scripts() { |
| 235 |
|
| 236 |
// magnific. |
| 237 |
$name = 'jquery.magnific-popup'; // swiper.js. |
| 238 |
$filepath = 'assets/js/lib/' . $name; |
| 239 |
|
| 240 |
wp_register_script( |
| 241 |
'jquery-magnific-popup', |
| 242 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 243 |
array( 'jquery' ), |
| 244 |
'1.1.0', |
| 245 |
false |
| 246 |
); |
| 247 |
|
| 248 |
// magnific style. |
| 249 |
$name = 'magnific-popup'; // swiper.js. |
| 250 |
$filepath = 'assets/css/lib/' . $name; |
| 251 |
|
| 252 |
wp_register_style( |
| 253 |
'jquery-magnific-popup', |
| 254 |
GUTENIFY_PLUGIN_URL . $filepath . '.css', |
| 255 |
array(), |
| 256 |
'1.1.0', |
| 257 |
false |
| 258 |
); |
| 259 |
|
| 260 |
// Scripts. |
| 261 |
$name = 'swiper-bundle'; // swiper.js. |
| 262 |
$filepath = 'assets/js/lib/' . $name; |
| 263 |
|
| 264 |
wp_register_script( |
| 265 |
'gutenify-swiper', |
| 266 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 267 |
array( 'jquery' ), |
| 268 |
'6.8.2', |
| 269 |
false |
| 270 |
); |
| 271 |
|
| 272 |
// Scripts. |
| 273 |
$name = 'gutenify-frontend'; // gutenify.js. |
| 274 |
$filepath = 'dist/js/' . $name; |
| 275 |
$asset_file = $this->get_asset_file( $filepath ); |
| 276 |
|
| 277 |
$deps = array( 'jquery', 'gutenify-swiper' ); |
| 278 |
|
| 279 |
// Enqueue for gutenify animations. |
| 280 |
wp_enqueue_script( |
| 281 |
'gutenify-frontend', |
| 282 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 283 |
$deps, |
| 284 |
GUTENIFY_VERSION, |
| 285 |
false |
| 286 |
); |
| 287 |
|
| 288 |
|
| 289 |
/** |
| 290 |
* Add: Isotope JS |
| 291 |
*/ |
| 292 |
|
| 293 |
// Scripts. |
| 294 |
$name = 'gutenify-isotope'; // swiper.js. |
| 295 |
$filepath = 'assets/js/lib/isotope.pkgd'; |
| 296 |
wp_register_script( $name, GUTENIFY_PLUGIN_URL . $filepath . '.js', array( 'jquery' ), '3.0.6', false ); |
| 297 |
|
| 298 |
/** |
| 299 |
* END: Isotope JS |
| 300 |
*/ |
| 301 |
|
| 302 |
|
| 303 |
/** |
| 304 |
* Add: marquee JS |
| 305 |
*/ |
| 306 |
|
| 307 |
// Scripts. |
| 308 |
$name = 'jquery-marquee'; |
| 309 |
$filepath = 'assets/js/lib/jquery.marquee'; |
| 310 |
wp_register_script( $name, GUTENIFY_PLUGIN_URL . $filepath . '.js', array( 'jquery' ), '1.6.0', false ); |
| 311 |
|
| 312 |
/** |
| 313 |
* END: marquee JS |
| 314 |
*/ |
| 315 |
|
| 316 |
// Styles. |
| 317 |
$name = 'swiper-bundle.min'; // swiper.js. |
| 318 |
$filepath = 'assets/css/lib/' . $name; |
| 319 |
$asset_file = $this->get_asset_file( $filepath ); |
| 320 |
wp_enqueue_style( |
| 321 |
'gutenify-swiper-style', |
| 322 |
GUTENIFY_PLUGIN_URL . $filepath . '.css', |
| 323 |
array(), |
| 324 |
'6.8.2' |
| 325 |
); |
| 326 |
|
| 327 |
} |
| 328 |
|
| 329 |
/** |
| 330 |
* Enqueue editor scripts for blocks. |
| 331 |
* |
| 332 |
* @access public |
| 333 |
* @since 1.9.5 |
| 334 |
*/ |
| 335 |
public function editor_scripts() { |
| 336 |
} |
| 337 |
|
| 338 |
/** |
| 339 |
* Return whether a post type should display the Block Editor. |
| 340 |
* |
| 341 |
* @param string $post_type The post_type slug to check. |
| 342 |
*/ |
| 343 |
protected function is_post_type_gutenberg( $post_type ) { |
| 344 |
return use_block_editor_for_post_type( $post_type ); |
| 345 |
} |
| 346 |
|
| 347 |
/** |
| 348 |
* Return whether the page we are on is loading the Block Editor. |
| 349 |
*/ |
| 350 |
protected function is_page_gutenberg() { |
| 351 |
if ( ! is_admin() ) { |
| 352 |
return false; |
| 353 |
} |
| 354 |
|
| 355 |
$admin_page = wp_basename( esc_url( $_SERVER['REQUEST_URI'] ) ); |
| 356 |
|
| 357 |
if ( false !== strpos( $admin_page, 'post-new.php' ) && empty( $_GET['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 358 |
return true; |
| 359 |
} |
| 360 |
|
| 361 |
if ( false !== strpos( $admin_page, 'post-new.php' ) && isset( $_GET['post_type'] ) && $this->is_post_type_gutenberg( $_GET['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 362 |
return true; |
| 363 |
} |
| 364 |
|
| 365 |
if ( false !== strpos( $admin_page, 'post.php' ) ) { |
| 366 |
$wp_post = get_post( $_GET['post'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 367 |
if ( isset( $wp_post ) && isset( $wp_post->post_type ) && $this->is_post_type_gutenberg( $wp_post->post_type ) ) { |
| 368 |
return true; |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
if ( false !== strpos( $admin_page, 'revision.php' ) ) { |
| 373 |
$wp_post = get_post( $_GET['revision'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 374 |
$post_parent = get_post( $wp_post->post_parent ); |
| 375 |
if ( isset( $post_parent ) && isset( $post_parent->post_type ) && $this->is_post_type_gutenberg( $post_parent->post_type ) ) { |
| 376 |
return true; |
| 377 |
} |
| 378 |
} |
| 379 |
return false; |
| 380 |
} |
| 381 |
|
| 382 |
/** |
| 383 |
* Add inline css |
| 384 |
* |
| 385 |
* @return void |
| 386 |
*/ |
| 387 |
public static function add_block_inline_css() { |
| 388 |
if ( is_singular() ) { |
| 389 |
global $post; |
| 390 |
// $style_file = trailingslashit( wp_upload_dir()['basedir'] ) . 'gutenify/styles/style-' . 'post-' . $post->ID . '.css'; |
| 391 |
|
| 392 |
// if ( file_exists( $style_file ) ) { |
| 393 |
// $style_file_url = trailingslashit( wp_upload_dir()['baseurl'] ) . 'gutenify/styles/style-' . 'post-' . $post->ID . '.css'; |
| 394 |
|
| 395 |
// wp_enqueue_style( 'gutenify-frontend-post', $style_file_url, array( 'gutenify-frontend' ), GUTENIFY_VERSION ); |
| 396 |
// } else { |
| 397 |
// } |
| 398 |
$post_meta = get_post_meta( $post->ID ); |
| 399 |
$gutenify_custom_css = ! empty( $post_meta['gutenify_custom_css'][0] ) ? $post_meta['gutenify_custom_css'][0] : ''; |
| 400 |
wp_add_inline_style( 'gutenify-frontend', $gutenify_custom_css ); |
| 401 |
} |
| 402 |
$gutenify_global_style = get_option( 'gutenify_global_style' ); |
| 403 |
|
| 404 |
$deps = array(); |
| 405 |
wp_register_style( 'gutenify-global-inline-handle', false, $deps ); |
| 406 |
wp_enqueue_style( 'gutenify-global-inline-handle' ); |
| 407 |
|
| 408 |
if ( $gutenify_global_style ) { |
| 409 |
$handle = 'gutenify-global-inline-handle'; |
| 410 |
wp_add_inline_style( $handle, $gutenify_global_style ); |
| 411 |
} |
| 412 |
} |
| 413 |
|
| 414 |
/** |
| 415 |
* Add Global inline css |
| 416 |
* |
| 417 |
* @return void |
| 418 |
*/ |
| 419 |
public static function add_admin_global_inline_css() { |
| 420 |
|
| 421 |
$gutenify_admin_global_style = get_option( 'gutenify_admin_global_style' ); |
| 422 |
$deps = array(); |
| 423 |
wp_register_style( 'gutenify-global-inline-handle', false, $deps ); |
| 424 |
wp_enqueue_style( 'gutenify-global-inline-handle' ); |
| 425 |
|
| 426 |
if ( $gutenify_admin_global_style ) { |
| 427 |
wp_add_inline_style( 'gutenify-global-inline-handle', $gutenify_admin_global_style ); |
| 428 |
} |
| 429 |
} |
| 430 |
|
| 431 |
/** |
| 432 |
* Admin scripts. |
| 433 |
* |
| 434 |
* @return mixed |
| 435 |
*/ |
| 436 |
public function admin_scripts() { |
| 437 |
// Scripts. |
| 438 |
$name = 'gutenify-global'; // gutenify.js. |
| 439 |
$filepath = 'dist/' . $name; |
| 440 |
$asset_file = $this->get_asset_file( $filepath ); |
| 441 |
|
| 442 |
// Enqueue for gutenify animations. |
| 443 |
wp_register_script( |
| 444 |
$name, |
| 445 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 446 |
$asset_file['dependencies'], |
| 447 |
$asset_file['version'], |
| 448 |
true |
| 449 |
); |
| 450 |
|
| 451 |
// Getting Started. |
| 452 |
if ( ( ! empty( $_GET['page'] ) && 'gutenify' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 453 |
// Scripts. |
| 454 |
$name = 'gutenify-getting-started-admin'; // gutenify.js. |
| 455 |
$filepath = 'dist/' . $name; |
| 456 |
$asset_file = $this->get_asset_file( $filepath ); |
| 457 |
|
| 458 |
// Enqueue for gutenify animations. |
| 459 |
wp_enqueue_script( |
| 460 |
'gutenify-getting-started-admin', |
| 461 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 462 |
$asset_file['dependencies'], |
| 463 |
$asset_file['version'], |
| 464 |
true |
| 465 |
); |
| 466 |
|
| 467 |
// Styles. |
| 468 |
$name = 'gutenify-getting-started-admin-style'; |
| 469 |
$filepath = 'dist/' . $name; |
| 470 |
$asset_file = $this->get_asset_file( $filepath ); |
| 471 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 472 |
|
| 473 |
wp_enqueue_style( |
| 474 |
$name, |
| 475 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 476 |
array( 'gutenify-fontawesome-style', 'wp-components' ), |
| 477 |
$asset_file['version'] |
| 478 |
); |
| 479 |
|
| 480 |
wp_localize_script( |
| 481 |
'gutenify-getting-started-admin', |
| 482 |
'_gutenify_vars', |
| 483 |
array( |
| 484 |
'site_url' => esc_url( site_url() ), |
| 485 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 486 |
'gutenify_version' => GUTENIFY_VERSION, |
| 487 |
// 'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 488 |
// 'is_block_theme' => function_exists( 'wp_get_theme' ) && ! empty( wp_get_theme()->is_block_theme() ), |
| 489 |
// 'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 490 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 491 |
'is_pro_activated' => apply_filters( 'gutenify_pro_activation_status', false ), |
| 492 |
) |
| 493 |
); |
| 494 |
} |
| 495 |
|
| 496 |
// Site options |
| 497 |
if ( ( ! empty( $_GET['page'] ) && 'gutenify-site-options' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 498 |
// Scripts. |
| 499 |
$name = 'gutenify-site-options-admin'; // gutenify.js. |
| 500 |
$filepath = 'dist/' . $name; |
| 501 |
$asset_file = $this->get_asset_file( $filepath ); |
| 502 |
|
| 503 |
// Enqueue for gutenify animations. |
| 504 |
wp_enqueue_script( |
| 505 |
'gutenify-site-options-admin', |
| 506 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 507 |
$asset_file['dependencies'], |
| 508 |
$asset_file['version'], |
| 509 |
true |
| 510 |
); |
| 511 |
|
| 512 |
// Styles. |
| 513 |
$name = 'gutenify-site-options-admin-style'; |
| 514 |
$filepath = 'dist/' . $name; |
| 515 |
$asset_file = $this->get_asset_file( $filepath ); |
| 516 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 517 |
|
| 518 |
wp_enqueue_style( |
| 519 |
$name, |
| 520 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 521 |
array( 'gutenify-fontawesome-style', 'wp-components' ), |
| 522 |
$asset_file['version'] |
| 523 |
); |
| 524 |
|
| 525 |
wp_localize_script( |
| 526 |
'gutenify-site-options-admin', |
| 527 |
'_gutenify_site_options', |
| 528 |
array( |
| 529 |
'site_url' => esc_url( site_url() ), |
| 530 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 531 |
'is_block_theme' => function_exists( 'wp_get_theme' ) && ! empty( wp_get_theme()->is_block_theme() ), |
| 532 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 533 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 534 |
) |
| 535 |
); |
| 536 |
} |
| 537 |
|
| 538 |
// if ( ! empty( $_GET['post_type'] ) && 'gutenify_kit' === $_GET['post_type'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 539 |
if ( ( ! empty( $_GET['page'] ) && 'gutenify-template-kits' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 540 |
// Scripts. |
| 541 |
$name = 'gutenify-kit-admin'; // gutenify.js. |
| 542 |
$filepath = 'dist/' . $name; |
| 543 |
$asset_file = $this->get_asset_file( $filepath ); |
| 544 |
|
| 545 |
// Enqueue for gutenify animations. |
| 546 |
wp_enqueue_script( |
| 547 |
'gutenify-kit-admin', |
| 548 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 549 |
$asset_file['dependencies'], |
| 550 |
$asset_file['version'], |
| 551 |
true |
| 552 |
); |
| 553 |
|
| 554 |
// Styles. |
| 555 |
$name = 'gutenify-kit-admin-style'; |
| 556 |
$filepath = 'dist/' . $name; |
| 557 |
$asset_file = $this->get_asset_file( $filepath ); |
| 558 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 559 |
|
| 560 |
wp_enqueue_style( |
| 561 |
$name, |
| 562 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 563 |
array( 'gutenify-fontawesome-style', 'wp-components' ), |
| 564 |
$asset_file['version'] |
| 565 |
); |
| 566 |
|
| 567 |
wp_localize_script( |
| 568 |
'gutenify-kit-admin', |
| 569 |
'_gutenify_kit', |
| 570 |
array( |
| 571 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 572 |
'site_url' => esc_url( site_url() ), |
| 573 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 574 |
'is_block_theme' => wp_is_block_theme(), // function_exists( 'wp_get_theme' ) && ! empty( wp_get_theme()->is_block_theme() ), |
| 575 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 576 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 577 |
) |
| 578 |
); |
| 579 |
|
| 580 |
wp_localize_script( |
| 581 |
'gutenify-kit-admin', |
| 582 |
'_gutenify_vars', |
| 583 |
array( |
| 584 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 585 |
'site_url' => esc_url( site_url() ), |
| 586 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 587 |
'is_block_theme' => wp_is_block_theme(), // function_exists( 'wp_get_theme' ) && ! empty( wp_get_theme()->is_block_theme() ), |
| 588 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 589 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 590 |
'font_families' => gutenify_font_families(), |
| 591 |
'is_pro_activated' => apply_filters( 'gutenify_pro_activation_status', false ), |
| 592 |
) |
| 593 |
); |
| 594 |
} |
| 595 |
|
| 596 |
if ( ( ! empty( $_GET['page'] ) && 'gutenify-settings' !== $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 597 |
return false; |
| 598 |
} |
| 599 |
// Scripts. |
| 600 |
$name = 'gutenify-admin-settings'; // gutenify.js. |
| 601 |
$filepath = 'dist/' . $name; |
| 602 |
$asset_file = $this->get_asset_file( $filepath ); |
| 603 |
|
| 604 |
$asset_file['dependencies'][] = 'gutenify-global'; |
| 605 |
|
| 606 |
// Enqueue for gutenify animations. |
| 607 |
wp_enqueue_script( |
| 608 |
'gutenify-admin-settings', |
| 609 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 610 |
$asset_file['dependencies'], |
| 611 |
$asset_file['version'], |
| 612 |
true |
| 613 |
); |
| 614 |
|
| 615 |
wp_localize_script( |
| 616 |
'gutenify-admin-settings', |
| 617 |
'_gutenify', |
| 618 |
array( |
| 619 |
'site_url' => esc_url( site_url() ), |
| 620 |
'pro_account_url' => esc_url( admin_url( 'admin.php?page=gutenify-pro-license' ) ), |
| 621 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 622 |
'gutenify_hub_server_url' => defined( 'GUTENIFY_HUB_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://hub.gutenify.com/' ), |
| 623 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 624 |
'font_families' => gutenify_font_families(), |
| 625 |
'global_settings' => wp_get_global_settings(), |
| 626 |
) |
| 627 |
); |
| 628 |
|
| 629 |
wp_localize_script( |
| 630 |
'gutenify-admin-settings', |
| 631 |
'_gutenify_vars', |
| 632 |
array( |
| 633 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 634 |
'site_url' => esc_url( site_url() ), |
| 635 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 636 |
'is_block_theme' => wp_is_block_theme(), // function_exists( 'wp_get_theme' ) && ! empty( wp_get_theme()->is_block_theme() ), |
| 637 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 638 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 639 |
'font_families' => gutenify_font_families(), |
| 640 |
'is_pro_activated' => apply_filters( 'gutenify_pro_activation_status', false ), |
| 641 |
) |
| 642 |
); |
| 643 |
|
| 644 |
// Styles. |
| 645 |
$name = 'gutenify-admin-settings'; |
| 646 |
$filepath = 'dist/' . $name; |
| 647 |
$asset_file = $this->get_asset_file( $filepath ); |
| 648 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 649 |
|
| 650 |
wp_enqueue_style( |
| 651 |
'gutenify-admin-settings-style', |
| 652 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 653 |
array( 'gutenify-fontawesome-style', 'wp-components' ), |
| 654 |
$asset_file['version'] |
| 655 |
); |
| 656 |
} |
| 657 |
} |
| 658 |
|
| 659 |
Gutenify_Block_Assets::register(); |
| 660 |
|