post_type ) {
return;
}
$options = BuilderFns::option_name_for_specific_product_set_default( $post_id );
if ( TemplateSettings::instance()->get_option( $options ) ) {
TemplateSettings::instance()->delete_option( $options );
}
$template_options = BuilderFns::option_name_by_template_id( $post_id );
if ( TemplateSettings::instance()->get_option( $template_options ) ) {
TemplateSettings::instance()->delete_option( $template_options );
}
$archive_options = BuilderFns::archive_option_name_by_template_id( $post_id );
if ( TemplateSettings::instance()->get_option( $archive_options ) ) {
TemplateSettings::instance()->delete_option( $archive_options );
}
$category_options = BuilderFns::option_name_for_specific_category_set_default( $post_id );
if ( TemplateSettings::instance()->get_option( $category_options ) ) {
TemplateSettings::instance()->delete_option( $category_options );
}
$selected_category_options = BuilderFns::archive_option_name_by_template_id( $post_id );
if ( TemplateSettings::instance()->get_option( $selected_category_options ) ) {
TemplateSettings::instance()->delete_option( $selected_category_options );
}
global $wpdb;
// Prepare and execute the SQL query.
$sql = $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", BuilderFns::$view_template_for_products_meta, $post_id );
$wpdb->query( $sql );
// Prepare and execute the SQL query.
$sql = $wpdb->prepare( "DELETE FROM $wpdb->termmeta WHERE meta_key = %s AND meta_value = %d", BuilderFns::$view_template_for_archive_meta, $post_id );
$wpdb->query( $sql );
}
/**
* Meta tags for social sharing.
*
* @return void
*/
public static function shopbuilder_share() {
$generalList = GeneralList::instance()->get_data();
if (
empty( $generalList['social_share']['share_platforms_to_product_page'] ) ||
'on' !== $generalList['social_share']['share_platforms_to_product_page'] ||
empty( $generalList['social_share']['share_platforms'] )
) {
return;
}
$share_platforms = [];
foreach ( $generalList['social_share']['share_platforms'] as $value ) {
$share_platforms[ $value ] = [
'share_items' => $value,
'share_text' => ucwords( $value ),
];
}
$settings['share_platforms'] = $share_platforms;
$settings['layout'] = ! empty( $generalList['social_share']['share_icon_layout'] ) ? $generalList['social_share']['share_icon_layout'] : 1;
$settings['show_share_icon'] = 1;
// TODO:: Implement Later ! empty( $generalList['social_share']['share_icon_show_to_product_page'] ) && 'on' === $generalList['social_share']['share_icon_show_to_product_page'];
Fns::print_html( WCRender::instance()->social_share_view( 'elementor/general/social-share', $settings ), true );
}
/**
* Meta tags for social sharing.
*
* @return void
*/
public static function og_metatags_for_sharing() {
global $post;
if ( ! isset( $post ) ) {
return;
}
if ( ! is_singular( 'product' ) ) {
return;
}
Fns::print_html( '', true );
Fns::print_html( '', true );
Fns::print_html( '', true );
Fns::print_html( '' );
$attachment = get_the_post_thumbnail_url();
if ( ! empty( $attachment ) ) {
Fns::print_html( '', true );
}
Fns::print_html( '', true );
Fns::print_html( '', true );
}
/**
* Render image.
*
* @param array $args Image args.
* @param array $settings Settings array.
*
* @return void
*/
public static function render_image( $args, $settings ) {
if ( $args['image_link'] ) {
$aria_label = esc_attr(
/* translators: Product Name */
sprintf( __( 'Image link for Product: %s', 'shopbuilder' ), $args['title'] )
);
?>
';
Fns::get_product_image( $args['img_html'], $args['hover_img_html'] );
echo '';
}
}
/**
* Modify WooCommerce query arguments for product retrieval.
*
* @param array $settings The settings array.
*
* @return void
*/
public static function modify_wc_query_args( $settings ) {
if ( ( isset( $settings['tax_relation'] ) && 'OR' === $settings['tax_relation'] ) ||
( isset( $settings['relation'] ) && 'OR' === $settings['relation'] ) ) {
add_filter( 'woocommerce_product_data_store_cpt_get_products_query', [ FilterHooks::class, 'extra_query_args' ], 10, 2 );
}
}
/**
* Reset WooCommerce query arguments for product retrieval.
*
* @param array $settings The settings array.
*
* @return void
*/
public static function reset_wc_query_args( $settings ) {
if ( ( isset( $settings['tax_relation'] ) && 'OR' === $settings['tax_relation'] ) ||
( isset( $settings['relation'] ) && 'OR' === $settings['relation'] ) ) {
remove_filter( 'woocommerce_product_data_store_cpt_get_products_query', [ FilterHooks::class, 'extra_query_args' ] );
}
}
}