Skip to content

Commit 5083192

Browse files
committed
show blocksy theme styles in the design library
1 parent 1e56ba3 commit 5083192

File tree

5 files changed

+53
-6
lines changed

5 files changed

+53
-6
lines changed

src/compatibility/blocksy/index.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,42 @@ function stackable_blocksy_global_color_schemes_compatibility( $styles, $scheme,
8787
}
8888

8989
add_filter( 'stackable.global-settings.global-color-schemes.add-theme-compatibility', 'stackable_blocksy_global_color_schemes_compatibility', 10, 6 );
90-
}
90+
}
91+
92+
if ( ! function_exists( 'stackable_blocksy_theme_global_styles' ) ) {
93+
function stackable_blocksy_theme_global_styles( $styles ) {
94+
95+
if ( function_exists( 'blocksy_manager' ) ) {
96+
$blocksy_css = blocksy_manager()->dynamic_css->load_backend_dynamic_css([
97+
'echo' => false
98+
] );
99+
100+
$styles .= $blocksy_css;
101+
}
102+
103+
if ( class_exists( 'Blocksy_Static_Css_Files' ) ) {
104+
$blocksy_static_files = ( new Blocksy_Static_Css_Files() )->all_static_files();
105+
106+
$blocksy_static_files = array_filter(
107+
$blocksy_static_files,
108+
function( $file ) {
109+
return isset( $file['id'] ) && in_array( $file['id'], array( 'ct-main-styles', 'ct-stackable-styles' ), true );
110+
}
111+
);
112+
113+
foreach ( $blocksy_static_files as $file ) {
114+
if ( isset( $file['url'] ) ) {
115+
$file_url = get_template_directory_uri() . $file['url'];
116+
$response = wp_remote_get( $file_url );
117+
if ( ! is_wp_error( $response ) ) {
118+
$styles .= wp_remote_retrieve_body( $response );
119+
}
120+
}
121+
}
122+
}
123+
124+
return $styles;
125+
}
126+
127+
add_filter( 'stackable.design-library.global-theme-styles', 'stackable_blocksy_theme_global_styles' );
128+
}

src/compatibility/blocksy/style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
:where(.stk--is-blocksy-theme.stk--has-default-container-scheme) {
44
--stk-default-link-color: var(--theme-link-initial-color);
55
--stk-default-heading-color: var(--theme-heading-color, var(--theme-headings-color));
6+
--stk-default-button-background-color: var(--theme-button-background-initial-color);
67

78
:where(.stk-block-heading) {
89
@for $i from 1 through 6 {

src/compatibility/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
require_once( plugin_dir_path( __FILE__ ) . './neve/index.php' );
99
require_once( plugin_dir_path( __FILE__ ) . './ewww.php' );
1010
require_once( plugin_dir_path( __FILE__ ) . './woocommerce.php' );
11+
require_once( plugin_dir_path( __FILE__ ) . './blocksy/index.php' );

src/design-library/init.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public function __construct() {
3030
add_action( 'rest_api_init', array( $this, 'register_route' ) );
3131

3232
add_action( 'stackable_delete_design_library_cache', array( $this, 'delete_cache_v3' ) );
33+
34+
add_filter( 'stackable_localize_script', array( $this, 'add_wp_theme_global_styles' ) );
3335
}
3436

3537
public static function validate_string( $value, $request, $param ) {
@@ -299,6 +301,16 @@ public function get_design_library( $request ) {
299301
public static function get_cdn_url() {
300302
return trailingslashit( STACKABLE_DESIGN_LIBRARY_URL );
301303
}
304+
305+
public function add_wp_theme_global_styles( $args ) {
306+
$wp_global_styles = apply_filters( 'stackable.design-library.global-theme-styles', '' );
307+
308+
$wp_global_styles .= wp_get_global_stylesheet();
309+
310+
$args['wpGlobalStylesInlineCss'] = $wp_global_styles;
311+
312+
return $args;
313+
}
302314
}
303315

304316
new Stackable_Design_Library();

src/init.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@ public function register_block_editor_assets() {
334334

335335
$version_parts = explode( '-', STACKABLE_VERSION );
336336

337-
$wp_global_styles = wp_get_global_stylesheet();
338-
339337
global $content_width;
340338
global $wp_version;
341339
$args = apply_filters( 'stackable_localize_script', array(
@@ -373,9 +371,6 @@ public function register_block_editor_assets() {
373371
'settings' => apply_filters( 'stackable_js_settings', array() ),
374372
'isContentOnlyMode' => apply_filters( 'stackable_editor_role_is_content_only', false ),
375373
'blockCategoryIndex' => apply_filters( 'stackable_block_category_index', 0 ),
376-
377-
// Global Styles for Design Library
378-
'wpGlobalStylesInlineCss' => $wp_global_styles,
379374
) );
380375
wp_localize_script( 'wp-blocks', 'stackable', $args );
381376
}

0 commit comments

Comments
 (0)