get_block_css_and_js( $block );
$desktop_css = isset( $assets['css']['desktop'] ) ? $assets['css']['desktop'] : '';
if ( ! empty( $assets['css']['tablet'] ) ) {
$tab_styling_css .= '@media only screen and (max-width: ' . UAGB_TABLET_BREAKPOINT . 'px) {';
$tab_styling_css .= $assets['css']['tablet'];
$tab_styling_css .= '}';
}
if ( ! empty( $assets['css']['mobile'] ) ) {
$mob_styling_css .= '@media only screen and (max-width: ' . UAGB_MOBILE_BREAKPOINT . 'px) {';
$mob_styling_css .= $assets['css']['mobile'];
$mob_styling_css .= '}';
}
$block_css_style = $desktop_css . $tab_styling_css . $mob_styling_css;
if ( empty( $block_css_style ) || empty( $block['attrs'] ) || ! is_array( $block['attrs'] ) ) {
return $block;
}
// This line of code creates a new array named $font_family_attrs by searching through the keys of an existing array.
$font_family_attrs = preg_grep( '/fontfamily/i', array_keys( $block['attrs'] ) );
$link_tag_list = '';
if ( ! empty( $font_family_attrs ) && is_array( $font_family_attrs ) ) {
foreach ( $font_family_attrs as $attr ) {
if ( ! empty( $block['attrs'][ $attr ] ) ) {
// Get the font family value and construct the Google Fonts URL.
$gfont_url = 'https://fonts.googleapis.com/css?family=' . urlencode( $block['attrs'][ $attr ] );
// Create a link tag for the stylesheet with the constructed URL.
$link_tag_list .= '';
}
}
}
$style = '';
$style = $style . $link_tag_list;
array_push( $block['innerContent'], $style );
return $block;
}
/**
* This function updates the __uagb_asset_version when Widgets Editor is Updated.
*
* @since 2.0.0
*/
public function after_widget_save_action() {
/* Update the asset version */
update_option( '__uagb_asset_version', time() );
}
/**
* This function deletes the Page assets from the Page Meta Key.
*
* @param int $post_id Post Id.
* @since 1.23.0
*/
public function delete_page_assets( $post_id ) {
$current_post_type = get_post_type( $post_id );
if ( 'wp_template_part' === $current_post_type || 'wp_template' === $current_post_type ) {
// Delete all the TOC Post Meta on update of the template.
delete_post_meta_by_key( '_uagb_toc_options' );
$wp_upload_dir = UAGB_Helper::get_uag_upload_dir_path();
if ( file_exists( $wp_upload_dir . 'custom-style-blocks.css' ) ) {
wp_delete_file( $wp_upload_dir . 'custom-style-blocks.css' );
}
$file_generation = UAGB_Helper::allow_file_generation();
if ( 'enabled' === $file_generation ) {
UAGB_Helper::delete_uag_asset_dir();
}
UAGB_Admin_Helper::create_specific_stylesheet();
/* Update the asset version */
UAGB_Admin_Helper::update_admin_settings_option( '__uagb_asset_version', time() );
return;
}
if ( 'enabled' === UAGB_Helper::$file_generation ) {
$css_asset_info = UAGB_Scripts_Utils::get_asset_info( 'css', $post_id );
$js_asset_info = UAGB_Scripts_Utils::get_asset_info( 'js', $post_id );
$css_file_path = $css_asset_info['css'];
$js_file_path = $js_asset_info['js'];
if ( file_exists( $css_file_path ) ) {
wp_delete_file( $css_file_path );
}
if ( file_exists( $js_file_path ) ) {
wp_delete_file( $js_file_path );
}
}
delete_post_meta( $post_id, '_uag_page_assets' );
delete_post_meta( $post_id, '_uag_css_file_name' );
delete_post_meta( $post_id, '_uag_js_file_name' );
$does_post_contain_reusable_blocks = $this->does_post_contain_reusable_blocks( $post_id );
if ( true === $does_post_contain_reusable_blocks ) {
/* Update the asset version */
update_option( '__uagb_asset_version', time() );
}
}
/**
* Does Post contains reusable blocks.
*
* @param int $post_id Post ID.
*
* @since 1.23.5
*
* @return boolean Wether the Post contains any Reusable blocks or not.
*/
public function does_post_contain_reusable_blocks( $post_id ) {
$post_content = get_post_field( 'post_content', $post_id, 'raw' );
$tag = '