Created
November 23, 2023 15:47
-
-
Save andreiglingeanu/9f25d6eee16660c7ddeff3db999caebc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Blocksy\CustomPostType\Integrations; | |
class GreenShift extends \Blocksy\CustomPostTypeRenderer { | |
public function get_content($args = []) { | |
return \Blocksy\CustomPostTypeRenderer::NOT_IMPLEMENTED; | |
/* | |
$content_post = get_post($this->id); | |
if (! is_object($content_post)) { | |
return \Blocksy\CustomPostTypeRenderer::NOT_IMPLEMENTED; | |
} | |
return parent::get_content(array_merge($args, [ | |
'use_integrations' => false | |
])); | |
*/ | |
} | |
public function pre_output() { | |
wp_enqueue_style('wp-block-library'); | |
add_action( | |
'wp_enqueue_scripts', | |
function () { | |
$gspb_css_content = get_post_meta( | |
$this->id, | |
'_gspb_post_css', | |
true | |
); | |
if (! $gspb_css_content) { | |
$content_post = get_post($this->id); | |
$blocks = parse_blocks($contentpost); | |
$maybe_style = gspb_get_inline_styles_blocks($blocks); | |
if (! empty($maybe_style)) { | |
$gspb_css_content = $maybe_style; | |
} | |
} | |
if (empty($gspb_saved_css_content)) { | |
return; | |
} | |
$gspb_saved_css_content = gspb_get_final_css($gspb_css_content); | |
$final_css = $gspb_saved_css_content; | |
$css_id = 'greenshift-post-css-' . $this->id; | |
wp_register_style($css_id, false); | |
wp_enqueue_style($css_id); | |
wp_add_inline_style($css_id, $final_css); | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment