| 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 = 'gutenify-style'; |
| 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 |
// Styles. |
| 141 |
$name = 'gutenify-theme-style'; |
| 142 |
$filepath = 'dist/' . $name; |
| 143 |
$asset_file = $this->get_asset_file( $filepath ); |
| 144 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 145 |
|
| 146 |
$deps = array( 'gutenify-frontend' ); |
| 147 |
|
| 148 |
// wp_enqueue_style( $name, GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', $deps, $asset_file['version'] ); |
| 149 |
} |
| 150 |
|
| 151 |
/** |
| 152 |
* Enqueue block assets for use within Gutenberg. |
| 153 |
* |
| 154 |
* @access public |
| 155 |
*/ |
| 156 |
public function editor_assets() { |
| 157 |
|
| 158 |
// Styles. |
| 159 |
$name = 'gutenify-editor'; |
| 160 |
$filepath = 'dist/' . $name; |
| 161 |
$asset_file = $this->get_asset_file( $filepath ); |
| 162 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 163 |
|
| 164 |
wp_register_style( 'gutenify-fontawesome-style', GUTENIFY_PLUGIN_URL . '/assets/fontawesome/css/all.css', array(), 'v4' ); |
| 165 |
|
| 166 |
$fonts_url = gutenify_fonts_url(); |
| 167 |
wp_enqueue_style( 'gutenify-fonts', $fonts_url, array(), null ); |
| 168 |
|
| 169 |
$deps = array( 'gutenify-fontawesome-style' ); |
| 170 |
|
| 171 |
if ( $fonts_url ) { |
| 172 |
$deps[] = 'gutenify-fonts'; |
| 173 |
} |
| 174 |
|
| 175 |
if ( class_exists( 'woocommerce' ) ) { |
| 176 |
$deps[] = 'wc-blocks-editor-style'; |
| 177 |
} |
| 178 |
|
| 179 |
wp_register_style( |
| 180 |
'gutenify-editor', |
| 181 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 182 |
$deps, |
| 183 |
$asset_file['version'] |
| 184 |
); |
| 185 |
|
| 186 |
// Scripts. |
| 187 |
$name = 'gutenify'; // gutenify.js. |
| 188 |
$filepath = 'dist/' . $name; |
| 189 |
$asset_file = $this->get_asset_file( $filepath ); |
| 190 |
|
| 191 |
wp_register_script( |
| 192 |
'gutenify-editor', |
| 193 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 194 |
array_merge( $asset_file['dependencies'], array( 'wp-api', 'gutenify-global' ) ), |
| 195 |
$asset_file['version'], |
| 196 |
true |
| 197 |
); |
| 198 |
|
| 199 |
$post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT ); |
| 200 |
|
| 201 |
wp_localize_script( |
| 202 |
'gutenify-editor', |
| 203 |
'gutenify_block_data', |
| 204 |
array( |
| 205 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 206 |
'site_url' => esc_url( site_url() ), |
| 207 |
'settings_url' => esc_url( admin_url( 'edit.php?post_type=gutenify_template&page=gutenify-settings' ) ), |
| 208 |
'add_template_url' => esc_url( admin_url( 'post-new.php?post_type=gutenify_template' ) ), |
| 209 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 210 |
) |
| 211 |
); |
| 212 |
|
| 213 |
wp_localize_script( |
| 214 |
'gutenify-editor', |
| 215 |
'_gutenify', |
| 216 |
array( |
| 217 |
'font_families' => gutenify_font_families(), |
| 218 |
) |
| 219 |
); |
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
/** |
| 224 |
* Enqueue front-end assets for blocks. |
| 225 |
* |
| 226 |
* @access public |
| 227 |
* @since 1.9.5 |
| 228 |
*/ |
| 229 |
public function frontend_scripts() { |
| 230 |
|
| 231 |
// Scripts. |
| 232 |
$name = 'swiper-bundle'; // swiper.js. |
| 233 |
$filepath = 'assets/js/lib/' . $name; |
| 234 |
|
| 235 |
wp_register_script( |
| 236 |
'gutenify-swiper', |
| 237 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 238 |
array( 'jquery' ), |
| 239 |
'6.8.2', |
| 240 |
false |
| 241 |
); |
| 242 |
|
| 243 |
// Scripts. |
| 244 |
$name = 'gutenify-frontend'; // gutenify.js. |
| 245 |
$filepath = 'dist/js/' . $name; |
| 246 |
$asset_file = $this->get_asset_file( $filepath ); |
| 247 |
|
| 248 |
$deps = array( 'jquery', 'gutenify-swiper' ); |
| 249 |
|
| 250 |
// Enqueue for gutenify animations. |
| 251 |
wp_enqueue_script( |
| 252 |
'gutenify-frontend', |
| 253 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 254 |
$deps, |
| 255 |
GUTENIFY_VERSION, |
| 256 |
false |
| 257 |
); |
| 258 |
|
| 259 |
// Styles. |
| 260 |
$name = 'swiper-bundle.min'; // swiper.js. |
| 261 |
$filepath = 'assets/css/lib/' . $name; |
| 262 |
$asset_file = $this->get_asset_file( $filepath ); |
| 263 |
wp_enqueue_style( |
| 264 |
'gutenify-swiper-style', |
| 265 |
GUTENIFY_PLUGIN_URL . $filepath . '.css', |
| 266 |
array(), |
| 267 |
'6.8.2' |
| 268 |
); |
| 269 |
|
| 270 |
} |
| 271 |
|
| 272 |
/** |
| 273 |
* Enqueue editor scripts for blocks. |
| 274 |
* |
| 275 |
* @access public |
| 276 |
* @since 1.9.5 |
| 277 |
*/ |
| 278 |
public function editor_scripts() { |
| 279 |
} |
| 280 |
|
| 281 |
/** |
| 282 |
* Return whether a post type should display the Block Editor. |
| 283 |
* |
| 284 |
* @param string $post_type The post_type slug to check. |
| 285 |
*/ |
| 286 |
protected function is_post_type_gutenberg( $post_type ) { |
| 287 |
return use_block_editor_for_post_type( $post_type ); |
| 288 |
} |
| 289 |
|
| 290 |
/** |
| 291 |
* Return whether the page we are on is loading the Block Editor. |
| 292 |
*/ |
| 293 |
protected function is_page_gutenberg() { |
| 294 |
if ( ! is_admin() ) { |
| 295 |
return false; |
| 296 |
} |
| 297 |
|
| 298 |
$admin_page = wp_basename( esc_url( $_SERVER['REQUEST_URI'] ) ); |
| 299 |
|
| 300 |
if ( false !== strpos( $admin_page, 'post-new.php' ) && empty( $_GET['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 301 |
return true; |
| 302 |
} |
| 303 |
|
| 304 |
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 |
| 305 |
return true; |
| 306 |
} |
| 307 |
|
| 308 |
if ( false !== strpos( $admin_page, 'post.php' ) ) { |
| 309 |
$wp_post = get_post( $_GET['post'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 310 |
if ( isset( $wp_post ) && isset( $wp_post->post_type ) && $this->is_post_type_gutenberg( $wp_post->post_type ) ) { |
| 311 |
return true; |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
if ( false !== strpos( $admin_page, 'revision.php' ) ) { |
| 316 |
$wp_post = get_post( $_GET['revision'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 317 |
$post_parent = get_post( $wp_post->post_parent ); |
| 318 |
if ( isset( $post_parent ) && isset( $post_parent->post_type ) && $this->is_post_type_gutenberg( $post_parent->post_type ) ) { |
| 319 |
return true; |
| 320 |
} |
| 321 |
} |
| 322 |
return false; |
| 323 |
} |
| 324 |
|
| 325 |
/** |
| 326 |
* Add inline css |
| 327 |
* |
| 328 |
* @return void |
| 329 |
*/ |
| 330 |
public static function add_block_inline_css() { |
| 331 |
if ( is_singular() ) { |
| 332 |
global $post; |
| 333 |
// $style_file = trailingslashit( wp_upload_dir()['basedir'] ) . 'gutenify/styles/style-' . 'post-' . $post->ID . '.css'; |
| 334 |
|
| 335 |
// if ( file_exists( $style_file ) ) { |
| 336 |
// $style_file_url = trailingslashit( wp_upload_dir()['baseurl'] ) . 'gutenify/styles/style-' . 'post-' . $post->ID . '.css'; |
| 337 |
|
| 338 |
// wp_enqueue_style( 'gutenify-frontend-post', $style_file_url, array( 'gutenify-frontend' ), GUTENIFY_VERSION ); |
| 339 |
// } else { |
| 340 |
// } |
| 341 |
$post_meta = get_post_meta( $post->ID ); |
| 342 |
$gutenify_custom_css = ! empty( $post_meta['gutenify_custom_css'][0] ) ? $post_meta['gutenify_custom_css'][0] : ''; |
| 343 |
wp_add_inline_style( 'gutenify-frontend', $gutenify_custom_css ); |
| 344 |
} |
| 345 |
$gutenify_global_style = get_option( 'gutenify_global_style' ); |
| 346 |
|
| 347 |
$deps = array(); |
| 348 |
wp_register_style( 'gutenify-global-inline-handle', false, $deps ); |
| 349 |
wp_enqueue_style( 'gutenify-global-inline-handle' ); |
| 350 |
|
| 351 |
if ( $gutenify_global_style ) { |
| 352 |
$handle = 'gutenify-global-inline-handle'; |
| 353 |
wp_add_inline_style( $handle, $gutenify_global_style ); |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
/** |
| 358 |
* Add Global inline css |
| 359 |
* |
| 360 |
* @return void |
| 361 |
*/ |
| 362 |
public static function add_admin_global_inline_css() { |
| 363 |
|
| 364 |
$gutenify_admin_global_style = get_option( 'gutenify_admin_global_style' ); |
| 365 |
$deps = array(); |
| 366 |
wp_register_style( 'gutenify-global-inline-handle', false, $deps ); |
| 367 |
wp_enqueue_style( 'gutenify-global-inline-handle' ); |
| 368 |
|
| 369 |
if ( $gutenify_admin_global_style ) { |
| 370 |
wp_add_inline_style( 'gutenify-global-inline-handle', $gutenify_admin_global_style ); |
| 371 |
} |
| 372 |
} |
| 373 |
|
| 374 |
/** |
| 375 |
* Admin scripts. |
| 376 |
* |
| 377 |
* @return mixed |
| 378 |
*/ |
| 379 |
public function admin_scripts() { |
| 380 |
// Scripts. |
| 381 |
$name = 'gutenify-global'; // gutenify.js. |
| 382 |
$filepath = 'dist/' . $name; |
| 383 |
$asset_file = $this->get_asset_file( $filepath ); |
| 384 |
|
| 385 |
// Enqueue for gutenify animations. |
| 386 |
wp_register_script( |
| 387 |
$name, |
| 388 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 389 |
$asset_file['dependencies'], |
| 390 |
$asset_file['version'], |
| 391 |
true |
| 392 |
); |
| 393 |
|
| 394 |
// Site options |
| 395 |
if ( ( ! empty( $_GET['page'] ) && 'gutenify-site-options' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 396 |
// Scripts. |
| 397 |
$name = 'gutenify-site-options-admin'; // gutenify.js. |
| 398 |
$filepath = 'dist/' . $name; |
| 399 |
$asset_file = $this->get_asset_file( $filepath ); |
| 400 |
|
| 401 |
// Enqueue for gutenify animations. |
| 402 |
wp_enqueue_script( |
| 403 |
'gutenify-site-options-admin', |
| 404 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 405 |
$asset_file['dependencies'], |
| 406 |
$asset_file['version'], |
| 407 |
true |
| 408 |
); |
| 409 |
|
| 410 |
// Styles. |
| 411 |
$name = 'gutenify-site-options-admin-style'; |
| 412 |
$filepath = 'dist/' . $name; |
| 413 |
$asset_file = $this->get_asset_file( $filepath ); |
| 414 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 415 |
|
| 416 |
wp_enqueue_style( |
| 417 |
$name, |
| 418 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 419 |
array( 'gutenify-fontawesome-style', 'wp-components' ), |
| 420 |
$asset_file['version'] |
| 421 |
); |
| 422 |
|
| 423 |
wp_localize_script( |
| 424 |
'gutenify-site-options-admin', |
| 425 |
'_gutenify_site_options', |
| 426 |
array( |
| 427 |
'site_url' => esc_url( site_url() ), |
| 428 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 429 |
'is_block_theme' => function_exists( 'wp_get_theme' ) && ! empty( wp_get_theme()->is_block_theme() ), |
| 430 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 431 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 432 |
) |
| 433 |
); |
| 434 |
} |
| 435 |
|
| 436 |
// if ( ! empty( $_GET['post_type'] ) && 'gutenify_kit' === $_GET['post_type'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 437 |
if ( ! empty( $_GET['post_type'] ) && 'gutenify_template' === $_GET['post_type'] && ( ! empty( $_GET['page'] ) && 'gutenify-template-kits' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 438 |
// Scripts. |
| 439 |
$name = 'gutenify-kit-admin'; // gutenify.js. |
| 440 |
$filepath = 'dist/' . $name; |
| 441 |
$asset_file = $this->get_asset_file( $filepath ); |
| 442 |
|
| 443 |
// Enqueue for gutenify animations. |
| 444 |
wp_enqueue_script( |
| 445 |
'gutenify-kit-admin', |
| 446 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 447 |
$asset_file['dependencies'], |
| 448 |
$asset_file['version'], |
| 449 |
true |
| 450 |
); |
| 451 |
|
| 452 |
// Styles. |
| 453 |
$name = 'gutenify-kit-admin-style'; |
| 454 |
$filepath = 'dist/' . $name; |
| 455 |
$asset_file = $this->get_asset_file( $filepath ); |
| 456 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 457 |
|
| 458 |
wp_enqueue_style( |
| 459 |
$name, |
| 460 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 461 |
array( 'gutenify-fontawesome-style', 'wp-components' ), |
| 462 |
$asset_file['version'] |
| 463 |
); |
| 464 |
|
| 465 |
wp_localize_script( |
| 466 |
'gutenify-kit-admin', |
| 467 |
'_gutenify_kit', |
| 468 |
array( |
| 469 |
'plugin_directory_url' => esc_url( GUTENIFY_PLUGIN_URL ), |
| 470 |
'site_url' => esc_url( site_url() ), |
| 471 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 472 |
'is_block_theme' => wp_is_block_theme(), // function_exists( 'wp_get_theme' ) && ! empty( wp_get_theme()->is_block_theme() ), |
| 473 |
'is_woocommerce_activated' => class_exists( 'woocommerce' ), |
| 474 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 475 |
) |
| 476 |
); |
| 477 |
} |
| 478 |
|
| 479 |
if ( empty( $_GET['post_type'] ) || empty( 'page' ) || 'gutenify_template' !== $_GET['post_type'] || ( ! empty( $_GET['page'] ) && 'gutenify-settings' !== $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 480 |
return false; |
| 481 |
} |
| 482 |
// Scripts. |
| 483 |
$name = 'gutenify-admin-settings'; // gutenify.js. |
| 484 |
$filepath = 'dist/' . $name; |
| 485 |
$asset_file = $this->get_asset_file( $filepath ); |
| 486 |
|
| 487 |
$asset_file['dependencies'][] = 'gutenify-global'; |
| 488 |
|
| 489 |
// Enqueue for gutenify animations. |
| 490 |
wp_enqueue_script( |
| 491 |
'gutenify-admin-settings', |
| 492 |
GUTENIFY_PLUGIN_URL . $filepath . '.js', |
| 493 |
$asset_file['dependencies'], |
| 494 |
$asset_file['version'], |
| 495 |
true |
| 496 |
); |
| 497 |
|
| 498 |
wp_localize_script( |
| 499 |
'gutenify-admin-settings', |
| 500 |
'_gutenify', |
| 501 |
array( |
| 502 |
'site_url' => esc_url( site_url() ), |
| 503 |
'pro_account_url' => esc_url( admin_url( 'edit.php?post_type=gutenify_template&page=gutenify-pro-license' ) ), |
| 504 |
'gutenify_com_server_url' => defined( 'GUTENIFY_COM_SERVER_URL' ) ? trailingslashit( GUTENIFY_COM_SERVER_URL ) : trailingslashit( 'https://api.gutenify.com/' ), |
| 505 |
'pro_license_status' => apply_filters( 'gutenify_pro_license_status', false ), |
| 506 |
'font_families' => gutenify_font_families(), |
| 507 |
'global_settings' => wp_get_global_settings(), |
| 508 |
) |
| 509 |
); |
| 510 |
|
| 511 |
// Styles. |
| 512 |
$name = 'gutenify-admin-settings-style'; |
| 513 |
$filepath = 'dist/' . $name; |
| 514 |
$asset_file = $this->get_asset_file( $filepath ); |
| 515 |
$rtl = ! is_rtl() ? '' : '-rtl'; |
| 516 |
|
| 517 |
wp_enqueue_style( |
| 518 |
$name, |
| 519 |
GUTENIFY_PLUGIN_URL . $filepath . $rtl . '.css', |
| 520 |
array( 'gutenify-fontawesome-style', 'wp-components' ), |
| 521 |
$asset_file['version'] |
| 522 |
); |
| 523 |
} |
| 524 |
} |
| 525 |
|
| 526 |
Gutenify_Block_Assets::register(); |
| 527 |
|