WP_Theme_JSON::get_custom_css()
Returns the global styles custom CSS.
Method of the class: WP_Theme_JSON{}
No Hooks.
Return
String
. The global styles custom CSS.
Usage
$WP_Theme_JSON = new WP_Theme_JSON(); $WP_Theme_JSON->get_custom_css();
Changelog
Since 6.2.0 | Introduced. |
WP_Theme_JSON::get_custom_css() WP Theme JSON::get custom css code WP 6.6.2
public function get_custom_css() { // Add the global styles root CSS. $stylesheet = isset( $this->theme_json['styles']['css'] ) ? $this->theme_json['styles']['css'] : ''; // Add the global styles block CSS. if ( isset( $this->theme_json['styles']['blocks'] ) ) { foreach ( $this->theme_json['styles']['blocks'] as $name => $node ) { $custom_block_css = isset( $this->theme_json['styles']['blocks'][ $name ]['css'] ) ? $this->theme_json['styles']['blocks'][ $name ]['css'] : null; if ( $custom_block_css ) { $selector = static::$blocks_metadata[ $name ]['selector']; $stylesheet .= $this->process_blocks_custom_css( $custom_block_css, $selector ); } } } return $stylesheet; }