has_pro() ) { add_action( 'woocommerce_product_query', [ __CLASS__, 'query_modifier' ], 15 ); } add_action( 'switch_theme', [ __CLASS__, 'clear_cache' ] ); } /** * Clear scheduled cron events when a module is deactivated. * * Checks the given block ID against predefined schedules and clears * related cron hooks if the corresponding module is turned off. * * @param string $section_id Section identifier (not used in this function). * @param string $block_id Module/block identifier to check scheduled hooks. * @param array $rawOptions Module options array containing 'active' status. * * @return void */ public static function clear_cron_schedule( $section_id, $block_id, $rawOptions ) { $schedule = [ 'abandoned_cart_recovery' => [ 'rtsb_abandoned_cart_recovery_action', 'rtsb_send_abandoned_cart_emails', ], 'currency_switcher' => [ 'update_exchange_rates_hourly', ], ]; if ( ! isset( $schedule[ $block_id ] ) ) { return; } if ( ! isset( $rawOptions['active'] ) ) { return; } if ( 'on' === $rawOptions['active'] ) { return; } // CLear All Custom Schedule If module disabled. foreach ( $schedule[ $block_id ] as $hook ) { wp_clear_scheduled_hook( $hook ); } } /** * @param boolen $has_orders Order exist or not. * * @return void */ public static function after_account_orders( $has_orders ) { if ( ! $has_orders ) { echo ''; } } /** * @param boolen $has_orders Order exist or not. * * @return void */ public static function before_account_orders( $has_orders ) { if ( ! $has_orders ) { echo '
'; } } /** * @return void */ public static function woocommerce_checkout_coupon_form() { echo '
'; woocommerce_checkout_coupon_form(); echo '
'; } /** * @return void */ public static function woocommerce_checkout_login_form() { echo '
'; woocommerce_checkout_login_form(); echo '
'; } /** * @return void */ public static function cart_is_empty() { echo '
'; wc_empty_cart_message(); echo '
'; } /** * @param int $post_id Post Ids. * @param object $post Post Object. * * @return void */ public static function deleted_post( $post_id, $post ) { if ( BuilderFns::$post_type_tb !== $post->post_type ) { return; } $options = BuilderFns::option_name_for_specific_product_set_default( $post_id ); TemplateSettings::instance()->delete_option( $options ); $template_options = BuilderFns::option_name_by_template_id( $post_id ); TemplateSettings::instance()->delete_option( $template_options ); $archive_options = BuilderFns::archive_option_name_by_template_id( $post_id ); TemplateSettings::instance()->delete_option( $archive_options ); $category_options = BuilderFns::option_name_for_specific_category_set_default( $post_id ); TemplateSettings::instance()->delete_option( $category_options ); $selected_category_options = BuilderFns::archive_option_name_by_template_id( $post_id ); TemplateSettings::instance()->delete_option( $selected_category_options ); // Delete Data From Options. $options_product_selected_cat = BuilderFns::option_name_product_page_selected_cat( $post_id ); $cat_list = TemplateSettings::instance()->get_option( $options_product_selected_cat ); if ( ! empty( $cat_list ) ) { foreach ( $cat_list as $old_slug ) { $OldcatList = get_term_by( 'slug', $old_slug, 'product_cat' ); if ( ! empty( $OldcatList ) && ! is_wp_error( $OldcatList ) ) { delete_term_meta( $OldcatList->term_id, BuilderFns::$categories_product_page_template, $post_id ); } } } TemplateSettings::instance()->delete_option( $options_product_selected_cat ); $set_default_option = BuilderFns::option_name_product_page_specific_cat_set_default( $post_id ); TemplateSettings::instance()->delete_option( $set_default_option ); // Tags Remove. $options_product_selected_tag = BuilderFns::option_name_product_page_selected_tag( $post_id ); $tag_list = TemplateSettings::instance()->get_option( $options_product_selected_tag ); if ( ! empty( $tag_list ) ) { foreach ( $tag_list as $old_slug ) { $OldTagList = get_term_by( 'slug', $old_slug, 'product_tag' ); if ( ! empty( $OldTagList ) && ! is_wp_error( $OldTagList ) ) { delete_term_meta( $OldTagList->term_id, BuilderFns::$tags_product_page_template, $post_id ); } } } TemplateSettings::instance()->delete_option( $options_product_selected_tag ); // Tag Set Default Option. $tag_set_default_option = BuilderFns::option_name_product_page_specific_tag_set_default( $post_id ); TemplateSettings::instance()->delete_option( $tag_set_default_option ); 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 ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching // 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 ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching } /** * 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; /** * 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( Render::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. * * @return void */ public static function render_image( $args ) { 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_or' ], 10, 2 ); } if ( ( isset( $settings['tax_relation'] ) && 'AND' === $settings['tax_relation'] ) || ( isset( $settings['relation'] ) && 'AND' === $settings['relation'] ) ) { add_filter( 'woocommerce_product_data_store_cpt_get_products_query', [ FilterHooks::class, 'extra_query_args_and' ], 10, 2 ); } if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) { add_filter( 'woocommerce_product_data_store_cpt_get_products_query', [ FilterHooks::class, 'extra_query_args_outofstock' ] ); } } /** * 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_or' ] ); } if ( ( isset( $settings['tax_relation'] ) && 'AND' === $settings['tax_relation'] ) || ( isset( $settings['relation'] ) && 'AND' === $settings['relation'] ) ) { remove_filter( 'woocommerce_product_data_store_cpt_get_products_query', [ FilterHooks::class, 'extra_query_args_and' ] ); } if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) { remove_filter( 'woocommerce_product_data_store_cpt_get_products_query', [ FilterHooks::class, 'extra_query_args_outofstock' ] ); } } /** * Display a filter header. * * @param array $settings The settings. * * @return void */ public static function default_filter_header( $settings ) { if ( empty( $settings['show_filter_header'] ) && empty( $settings['filter_header_text'] ) ) { return; } $wrapper_class = 'rtsb-default-filter-header '; ?>

! empty( $settings['search_title'] ) ? $settings['search_title'] : '', 'show_icon' => ! empty( $settings['show_search_title_icon'] ), 'icon' => ! empty( $settings['filter_search_title_icon'] ) ? $settings['filter_search_title_icon'] : [], ]; $placeholder = ! empty( $settings['search_placeholder'] ) ? $settings['search_placeholder'] : ''; $btn_icon = ! empty( $settings['search_title_icon'] ) ? $settings['search_title_icon'] : []; $wrapper_class = 'rtsb-default-filter-search rtsb-default-product-search'; $unique_id = substr( uniqid(), -6 ); $search_term = isset( $_REQUEST['s'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>
set( 'post__in', ! empty( $on_sale_products ) ? $on_sale_products : [ 0 ] ); } elseif ( 'regular' === $onsale_filter ) { $query->set( 'post__not_in', $on_sale_products ); } return $query; } /** * Delete cache when switching to another theme. * * @return void */ public static function clear_cache() { Cache::clear_all_cache(); } }