| 1 |
<?php |
| 2 |
/** |
| 3 |
* Render deprecated block custom styles. |
| 4 |
* |
| 5 |
* @since v3.1.0 |
| 6 |
* |
| 7 |
* @package ghostkit |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* Class GhostKit_Deprecated_Extension_Styles |
| 16 |
*/ |
| 17 |
class GhostKit_Deprecated_Extension_Styles { |
| 18 |
/** |
| 19 |
* GhostKit_Deprecated_Extension_Styles constructor. |
| 20 |
*/ |
| 21 |
public function __construct() { |
| 22 |
add_filter( 'gkt_block_custom_styles', array( $this, 'block_custom_styles' ), 10, 2 ); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Get styles from block attribute. |
| 27 |
* |
| 28 |
* @param string $blocks_css - block css. |
| 29 |
* @param array $block - block data. |
| 30 |
* |
| 31 |
* @return string - ready to use styles string. |
| 32 |
*/ |
| 33 |
public static function block_custom_styles( $blocks_css, $block ) { |
| 34 |
$attributes = $block['attrs'] ?? array(); |
| 35 |
|
| 36 |
$id = $attributes['ghostkit']['id'] ?? $attributes['ghostkitId'] ?? ''; |
| 37 |
|
| 38 |
if ( $id && ! empty( $attributes['ghostkitStyles'] ) ) { |
| 39 |
if ( ! empty( $blocks_css ) ) { |
| 40 |
$blocks_css .= ' '; |
| 41 |
} |
| 42 |
|
| 43 |
$blocks_css .= GhostKit_Extension_Styles::parse( ghostkit_decode( $attributes['ghostkitStyles'] ) ); |
| 44 |
} |
| 45 |
|
| 46 |
return $blocks_css; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
new GhostKit_Deprecated_Extension_Styles(); |
| 51 |
|