Created
November 19, 2021 09:25
-
-
Save tomrobak/dc9e4cfc9af6d67dd1d44a18db5fd61b to your computer and use it in GitHub Desktop.
Blocksy - Loading stylesheet from Qubely
This file contains hidden or 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 | |
| add_action('blocksy:pro:content-blocks:pre-output', function ($id) { | |
| if (! class_exists('Qubely')) { | |
| return; | |
| } | |
| if (! class_exists('Blocksy_Qubely')) { | |
| eval("class Blocksy_Qubely extends Qubely { | |
| public function __construct() {} | |
| }"); | |
| } | |
| add_action('wp_enqueue_scripts', function () use ($id) { | |
| global $post; | |
| $old_post = $post; | |
| $hook = get_post($id); | |
| $post = $hook; | |
| setup_postdata($hook); | |
| $qubely_driver = new \Blocksy_Qubely(); | |
| $qubely_driver->qubely_enqueue_style(); | |
| $qubely_driver->qubely_enqueue_scripts(); | |
| wp_reset_postdata(); | |
| $post = $old_post; | |
| }); | |
| $option_data = get_option( 'qubely_options' ); | |
| $css_save_as = isset( | |
| $option_data['css_save_as'] | |
| ) ? $option_data['css_save_as'] : 'wp_head'; | |
| if ($css_save_as == 'filesystem') { | |
| add_action( | |
| 'wp_enqueue_scripts', | |
| function () use ($id) { | |
| global $post; | |
| $old_post = $post; | |
| $hook = get_post($id); | |
| $post = $hook; | |
| setup_postdata($hook); | |
| $qubely_driver = new \Blocksy_Qubely(); | |
| $qubely_driver->enqueue_block_css_file(); | |
| wp_reset_postdata(); | |
| $post = $old_post; | |
| } | |
| ); | |
| } else { | |
| add_action( | |
| 'wp_head', | |
| function () use ($id) { | |
| global $post; | |
| $old_post = $post; | |
| $hook = get_post($id); | |
| $post = $hook; | |
| setup_postdata($hook); | |
| $qubely_driver = new \Blocksy_Qubely(); | |
| $qubely_driver->add_block_inline_css(); | |
| wp_reset_postdata(); | |
| $post = $old_post; | |
| }, | |
| 100 | |
| ); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment