use Automattic\WooCommerce\Blocks\Package; use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields; if ( ! function_exists( 'woocommerce_register_additional_checkout_field' ) ) { /** * Register a checkout field. * * @param array $options Field arguments. See CheckoutFields::register_checkout_field() for details. * @throws \Exception If field registration fails. */ function woocommerce_register_additional_checkout_field( $options ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore // Check if `woocommerce_blocks_loaded` ran. If not then the CheckoutFields class will not be available yet. // In that case, re-hook `woocommerce_blocks_loaded` and try running this again. $woocommerce_blocks_loaded_ran = did_action( 'woocommerce_blocks_loaded' ); if ( ! $woocommerce_blocks_loaded_ran ) { add_action( 'woocommerce_blocks_loaded', function () use ( $options ) { woocommerce_register_additional_checkout_field( $options ); } ); return; } $checkout_fields = Package::container()->get( CheckoutFields::class ); $result = $checkout_fields->register_checkout_field( $options ); if ( is_wp_error( $result ) ) { throw new \Exception( esc_attr( $result->get_error_message() ) ); } } } if ( ! function_exists( '__experimental_woocommerce_blocks_register_checkout_field' ) ) { /** * Register a checkout field. * * @param array $options Field arguments. See CheckoutFields::register_checkout_field() for details. * @throws \Exception If field registration fails. * @deprecated 5.6.0 Use woocommerce_register_additional_checkout_field() instead. */ function __experimental_woocommerce_blocks_register_checkout_field( $options ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore wc_deprecated_function( __FUNCTION__, '8.9.0', 'woocommerce_register_additional_checkout_field' ); woocommerce_register_additional_checkout_field( $options ); } } if ( ! function_exists( '__internal_woocommerce_blocks_deregister_checkout_field' ) ) { /** * Deregister a checkout field. * * @param string $field_id Field ID. * @throws \Exception If field deregistration fails. * @internal */ function __internal_woocommerce_blocks_deregister_checkout_field( $field_id ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore $checkout_fields = Package::container()->get( CheckoutFields::class ); $result = $checkout_fields->deregister_checkout_field( $field_id ); if ( is_wp_error( $result ) ) { throw new \Exception( esc_attr( $result->get_error_message() ) ); } } } /** * Deprecated functions * * Where functions come to die. * * @author Automattic * @category Core * @package WooCommerce\Functions * @version 3.3.0 */ use Automattic\Jetpack\Constants; use Automattic\WooCommerce\Internal\Admin\Logging\Settings; use Automattic\WooCommerce\Utilities\LoggingUtil; if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Runs a deprecated action with notice only if used. * * @since 3.0.0 * @param string $tag The name of the action hook. * @param array $args Array of additional function arguments to be passed to do_action(). * @param string $version The version of WooCommerce that deprecated the hook. * @param string $replacement The hook that should have been used. * @param string $message A message regarding the change. */ function wc_do_deprecated_action( $tag, $args, $version, $replacement = null, $message = null ) { if ( ! has_action( $tag ) ) { return; } wc_deprecated_hook( $tag, $version, $replacement, $message ); do_action_ref_array( $tag, $args ); } /** * Wrapper for deprecated functions so we can apply some extra logic. * * @since 3.0.0 * @param string $function Function used. * @param string $version Version the message was added in. * @param string $replacement Replacement for the called function. */ function wc_deprecated_function( $function, $version, $replacement = null ) { // @codingStandardsIgnoreStart if ( wp_doing_ajax() || WC()->is_rest_api_request() ) { do_action( 'deprecated_function_run', $function, $replacement, $version ); $log_string = "The {$function} function is deprecated since version {$version}."; $log_string .= $replacement ? " Replace with {$replacement}." : ''; error_log( $log_string ); } else { _deprecated_function( $function, $version, $replacement ); } // @codingStandardsIgnoreEnd } /** * Wrapper for deprecated hook so we can apply some extra logic. * * @since 3.3.0 * @param string $hook The hook that was used. * @param string $version The version of WordPress that deprecated the hook. * @param string $replacement The hook that should have been used. * @param string $message A message regarding the change. */ function wc_deprecated_hook( $hook, $version, $replacement = null, $message = null ) { // @codingStandardsIgnoreStart if ( wp_doing_ajax() || WC()->is_rest_api_request() ) { do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message ); $message = empty( $message ) ? '' : ' ' . $message; $log_string = "{$hook} is deprecated since version {$version}"; $log_string .= $replacement ? "! Use {$replacement} instead." : ' with no alternative available.'; error_log( $log_string . $message ); } else { _deprecated_hook( $hook, $version, $replacement, $message ); } // @codingStandardsIgnoreEnd } /** * When catching an exception, this allows us to log it if unexpected. * * @since 3.3.0 * @param Exception $exception_object The exception object. * @param string $function The function which threw exception. * @param array $args The args passed to the function. */ function wc_caught_exception( $exception_object, $function = '', $args = array() ) { // @codingStandardsIgnoreStart $message = $exception_object->getMessage(); $message .= '. Args: ' . print_r( $args, true ) . '.'; do_action( 'woocommerce_caught_exception', $exception_object, $function, $args ); error_log( "Exception caught in {$function}. {$message}." ); // @codingStandardsIgnoreEnd } /** * Wrapper for _doing_it_wrong(). * * @since 3.0.0 * @param string $function Function used. * @param string $message Message to log. * @param string $version Version the message was added in. */ function wc_doing_it_wrong( $function, $message, $version ) { // @codingStandardsIgnoreStart $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); if ( wp_doing_ajax() || WC()->is_rest_api_request() ) { do_action( 'doing_it_wrong_run', $function, $message, $version ); error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); } else { _doing_it_wrong( $function, $message, $version ); } // @codingStandardsIgnoreEnd } /** * Wrapper for deprecated arguments so we can apply some extra logic. * * @since 3.0.0 * @param string $argument * @param string $version * @param string $replacement */ function wc_deprecated_argument( $argument, $version, $message = null ) { if ( wp_doing_ajax() || WC()->is_rest_api_request() ) { do_action( 'deprecated_argument_run', $argument, $message, $version ); error_log( "The {$argument} argument is deprecated since version {$version}. {$message}" ); } else { _deprecated_argument( $argument, $version, $message ); } } /** * @deprecated 2.1 */ function woocommerce_show_messages() { wc_deprecated_function( 'woocommerce_show_messages', '2.1', 'wc_print_notices' ); wc_print_notices(); } /** * @deprecated 2.1 */ function woocommerce_weekend_area_js() { wc_deprecated_function( 'woocommerce_weekend_area_js', '2.1' ); } /** * @deprecated 2.1 */ function woocommerce_tooltip_js() { wc_deprecated_function( 'woocommerce_tooltip_js', '2.1' ); } /** * @deprecated 2.1 */ function woocommerce_datepicker_js() { wc_deprecated_function( 'woocommerce_datepicker_js', '2.1' ); } /** * @deprecated 2.1 */ function woocommerce_admin_scripts() { wc_deprecated_function( 'woocommerce_admin_scripts', '2.1' ); } /** * @deprecated 2.1 */ function woocommerce_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { wc_deprecated_function( 'woocommerce_create_page', '2.1', 'wc_create_page' ); return wc_create_page( $slug, $option, $page_title, $page_content, $post_parent ); } /** * @deprecated 2.1 */ function woocommerce_readfile_chunked( $file, $retbytes = true ) { wc_deprecated_function( 'woocommerce_readfile_chunked', '2.1', 'WC_Download_Handler::readfile_chunked()' ); return WC_Download_Handler::readfile_chunked( $file ); } /** * Formal total costs - format to the number of decimal places for the base currency. * * @access public * @param mixed $number * @deprecated 2.1 * @return string */ function woocommerce_format_total( $number ) { wc_deprecated_function( __FUNCTION__, '2.1', 'wc_format_decimal()' ); return wc_format_decimal( $number, wc_get_price_decimals(), false ); } /** * Get product name with extra details such as SKU price and attributes. Used within admin. * * @access public * @param WC_Product $product * @deprecated 2.1 * @return string */ function woocommerce_get_formatted_product_name( $product ) { wc_deprecated_function( __FUNCTION__, '2.1', 'WC_Product::get_formatted_name()' ); return $product->get_formatted_name(); } /** * Handle IPN requests for the legacy paypal gateway by calling gateways manually if needed. * * @access public */ function woocommerce_legacy_paypal_ipn() { if ( ! empty( $_GET['paypalListener'] ) && 'paypal_standard_IPN' === $_GET['paypalListener'] ) { WC()->payment_gateways(); do_action( 'woocommerce_api_wc_gateway_paypal' ); } } add_action( 'init', 'woocommerce_legacy_paypal_ipn' ); /** * @deprecated 3.0 */ function get_product( $the_product = false, $args = array() ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product' ); return wc_get_product( $the_product, $args ); } /** * @deprecated 3.0 */ function woocommerce_protected_product_add_to_cart( $passed, $product_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_protected_product_add_to_cart' ); return wc_protected_product_add_to_cart( $passed, $product_id ); } /** * @deprecated 3.0 */ function woocommerce_empty_cart() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_empty_cart' ); wc_empty_cart(); } /** * @deprecated 3.0 */ function woocommerce_load_persistent_cart( $user_login, $user = 0 ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_load_persistent_cart' ); return wc_load_persistent_cart( $user_login, $user ); } /** * @deprecated 3.0 */ function woocommerce_add_to_cart_message( $product_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_to_cart_message' ); wc_add_to_cart_message( $product_id ); } /** * @deprecated 3.0 */ function woocommerce_clear_cart_after_payment() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_clear_cart_after_payment' ); wc_clear_cart_after_payment(); } /** * @deprecated 3.0 */ function woocommerce_cart_totals_subtotal_html() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_subtotal_html' ); wc_cart_totals_subtotal_html(); } /** * @deprecated 3.0 */ function woocommerce_cart_totals_shipping_html() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_shipping_html' ); wc_cart_totals_shipping_html(); } /** * @deprecated 3.0 */ function woocommerce_cart_totals_coupon_html( $coupon ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_coupon_html' ); wc_cart_totals_coupon_html( $coupon ); } /** * @deprecated 3.0 */ function woocommerce_cart_totals_order_total_html() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_order_total_html' ); wc_cart_totals_order_total_html(); } /** * @deprecated 3.0 */ function woocommerce_cart_totals_fee_html( $fee ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_fee_html' ); wc_cart_totals_fee_html( $fee ); } /** * @deprecated 3.0 */ function woocommerce_cart_totals_shipping_method_label( $method ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cart_totals_shipping_method_label' ); return wc_cart_totals_shipping_method_label( $method ); } /** * @deprecated 3.0 */ function woocommerce_get_template_part( $slug, $name = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_template_part' ); wc_get_template_part( $slug, $name ); } /** * @deprecated 3.0 */ function woocommerce_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_template' ); wc_get_template( $template_name, $args, $template_path, $default_path ); } /** * @deprecated 3.0 */ function woocommerce_locate_template( $template_name, $template_path = '', $default_path = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_locate_template' ); return wc_locate_template( $template_name, $template_path, $default_path ); } /** * @deprecated 3.0 */ function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r\n", $attachments = "" ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_mail' ); wc_mail( $to, $subject, $message, $headers, $attachments ); } /** * @deprecated 3.0 */ function woocommerce_disable_admin_bar( $show_admin_bar ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_disable_admin_bar' ); return wc_disable_admin_bar( $show_admin_bar ); } /** * @deprecated 3.0 */ function woocommerce_create_new_customer( $email, $username = '', $password = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_create_new_customer' ); return wc_create_new_customer( $email, $username, $password ); } /** * @deprecated 3.0 */ function woocommerce_set_customer_auth_cookie( $customer_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_set_customer_auth_cookie' ); wc_set_customer_auth_cookie( $customer_id ); } /** * @deprecated 3.0 */ function woocommerce_update_new_customer_past_orders( $customer_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_update_new_customer_past_orders' ); return wc_update_new_customer_past_orders( $customer_id ); } /** * @deprecated 3.0 */ function woocommerce_paying_customer( $order_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_paying_customer' ); wc_paying_customer( $order_id ); } /** * @deprecated 3.0 */ function woocommerce_customer_bought_product( $customer_email, $user_id, $product_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_bought_product' ); return wc_customer_bought_product( $customer_email, $user_id, $product_id ); } /** * @deprecated 3.0 */ function woocommerce_customer_has_capability( $allcaps, $caps, $args ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_has_capability' ); return wc_customer_has_capability( $allcaps, $caps, $args ); } /** * @deprecated 3.0 */ function woocommerce_sanitize_taxonomy_name( $taxonomy ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_sanitize_taxonomy_name' ); return wc_sanitize_taxonomy_name( $taxonomy ); } /** * @deprecated 3.0 */ function woocommerce_get_filename_from_url( $file_url ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_filename_from_url' ); return wc_get_filename_from_url( $file_url ); } /** * @deprecated 3.0 */ function woocommerce_get_dimension( $dim, $to_unit ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_dimension' ); return wc_get_dimension( $dim, $to_unit ); } /** * @deprecated 3.0 */ function woocommerce_get_weight( $weight, $to_unit ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_weight' ); return wc_get_weight( $weight, $to_unit ); } /** * @deprecated 3.0 */ function woocommerce_trim_zeros( $price ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_trim_zeros' ); return wc_trim_zeros( $price ); } /** * @deprecated 3.0 */ function woocommerce_round_tax_total( $tax ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_round_tax_total' ); return wc_round_tax_total( $tax ); } /** * @deprecated 3.0 */ function woocommerce_format_decimal( $number, $dp = false, $trim_zeros = false ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_format_decimal' ); return wc_format_decimal( $number, $dp, $trim_zeros ); } /** * @deprecated 3.0 */ function woocommerce_clean( $var ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_clean' ); return wc_clean( $var ); } /** * @deprecated 3.0 */ function woocommerce_array_overlay( $a1, $a2 ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_array_overlay' ); return wc_array_overlay( $a1, $a2 ); } /** * @deprecated 3.0 */ function woocommerce_price( $price, $args = array() ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_price' ); return wc_price( $price, $args ); } /** * @deprecated 3.0 */ function woocommerce_let_to_num( $size ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_let_to_num' ); return wc_let_to_num( $size ); } /** * @deprecated 3.0 */ function woocommerce_date_format() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_date_format' ); return wc_date_format(); } /** * @deprecated 3.0 */ function woocommerce_time_format() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_time_format' ); return wc_time_format(); } /** * @deprecated 3.0 */ function woocommerce_timezone_string() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_timezone_string' ); return wc_timezone_string(); } if ( ! function_exists( 'woocommerce_rgb_from_hex' ) ) { /** * @deprecated 3.0 */ function woocommerce_rgb_from_hex( $color ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_rgb_from_hex' ); return wc_rgb_from_hex( $color ); } } if ( ! function_exists( 'woocommerce_hex_darker' ) ) { /** * @deprecated 3.0 */ function woocommerce_hex_darker( $color, $factor = 30 ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_hex_darker' ); return wc_hex_darker( $color, $factor ); } } if ( ! function_exists( 'woocommerce_hex_lighter' ) ) { /** * @deprecated 3.0 */ function woocommerce_hex_lighter( $color, $factor = 30 ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_hex_lighter' ); return wc_hex_lighter( $color, $factor ); } } if ( ! function_exists( 'woocommerce_light_or_dark' ) ) { /** * @deprecated 3.0 */ function woocommerce_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_light_or_dark' ); return wc_light_or_dark( $color, $dark, $light ); } } if ( ! function_exists( 'woocommerce_format_hex' ) ) { /** * @deprecated 3.0 */ function woocommerce_format_hex( $hex ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_format_hex' ); return wc_format_hex( $hex ); } } /** * @deprecated 3.0 */ function woocommerce_get_order_id_by_order_key( $order_key ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_order_id_by_order_key' ); return wc_get_order_id_by_order_key( $order_key ); } /** * @deprecated 3.0 */ function woocommerce_downloadable_file_permission( $download_id, $product_id, $order ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_downloadable_file_permission' ); return wc_downloadable_file_permission( $download_id, $product_id, $order ); } /** * @deprecated 3.0 */ function woocommerce_downloadable_product_permissions( $order_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_downloadable_product_permissions' ); wc_downloadable_product_permissions( $order_id ); } /** * @deprecated 3.0 */ function woocommerce_add_order_item( $order_id, $item ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_order_item' ); return wc_add_order_item( $order_id, $item ); } /** * @deprecated 3.0 */ function woocommerce_delete_order_item( $item_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_delete_order_item' ); return wc_delete_order_item( $item_id ); } /** * @deprecated 3.0 */ function woocommerce_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_update_order_item_meta' ); return wc_update_order_item_meta( $item_id, $meta_key, $meta_value, $prev_value ); } /** * @deprecated 3.0 */ function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_add_order_item_meta' ); return wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique ); } /** * @deprecated 3.0 */ function woocommerce_delete_order_item_meta( $item_id, $meta_key, $meta_value = '', $delete_all = false ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_delete_order_item_meta' ); return wc_delete_order_item_meta( $item_id, $meta_key, $meta_value, $delete_all ); } /** * @deprecated 3.0 */ function woocommerce_get_order_item_meta( $item_id, $key, $single = true ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_order_item_meta' ); return wc_get_order_item_meta( $item_id, $key, $single ); } /** * @deprecated 3.0 */ function woocommerce_cancel_unpaid_orders() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_cancel_unpaid_orders' ); wc_cancel_unpaid_orders(); } /** * @deprecated 3.0 */ function woocommerce_processing_order_count() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_processing_order_count' ); return wc_processing_order_count(); } /** * @deprecated 3.0 */ function woocommerce_get_page_id( $page ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_page_id' ); return wc_get_page_id( $page ); } /** * @deprecated 3.0 */ function woocommerce_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_endpoint_url' ); return wc_get_endpoint_url( $endpoint, $value, $permalink ); } /** * @deprecated 3.0 */ function woocommerce_lostpassword_url( $url ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_lostpassword_url' ); return wc_lostpassword_url( $url ); } /** * @deprecated 3.0 */ function woocommerce_customer_edit_account_url() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_customer_edit_account_url' ); return wc_customer_edit_account_url(); } /** * @deprecated 3.0 */ function woocommerce_nav_menu_items( $items, $args ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_nav_menu_items' ); return wc_nav_menu_items( $items ); } /** * @deprecated 3.0 */ function woocommerce_nav_menu_item_classes( $menu_items, $args ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_nav_menu_item_classes' ); return wc_nav_menu_item_classes( $menu_items ); } /** * @deprecated 3.0 */ function woocommerce_list_pages( $pages ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_list_pages' ); return wc_list_pages( $pages ); } /** * @deprecated 3.0 */ function woocommerce_product_dropdown_categories( $args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_product_dropdown_categories' ); return wc_product_dropdown_categories( $args, $deprecated_hierarchical, $deprecated_show_uncategorized, $deprecated_orderby ); } /** * @deprecated 3.0 */ function woocommerce_walk_category_dropdown_tree( $a1 = '', $a2 = '', $a3 = '' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_walk_category_dropdown_tree' ); return wc_walk_category_dropdown_tree( $a1, $a2, $a3 ); } /** * @deprecated 3.0 */ function woocommerce_taxonomy_metadata_wpdbfix() { wc_deprecated_function( __FUNCTION__, '3.0' ); } /** * @deprecated 3.0 */ function wc_taxonomy_metadata_wpdbfix() { wc_deprecated_function( __FUNCTION__, '3.0' ); } /** * @deprecated 3.0 */ function woocommerce_order_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_reorder_terms' ); return wc_reorder_terms( $the_term, $next_id, $taxonomy, $index, $terms ); } /** * @deprecated 3.0 */ function woocommerce_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_set_term_order' ); return wc_set_term_order( $term_id, $index, $taxonomy, $recursive ); } /** * @deprecated 3.0 */ function woocommerce_terms_clauses( $clauses, $taxonomies, $args ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_terms_clauses' ); return wc_terms_clauses( $clauses, $taxonomies, $args ); } /** * @deprecated 3.0 */ function _woocommerce_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ) { wc_deprecated_function( __FUNCTION__, '3.0', '_wc_term_recount' ); return _wc_term_recount( $terms, $taxonomy, $callback, $terms_are_term_taxonomy_ids ); } /** * @deprecated 3.0 */ function woocommerce_recount_after_stock_change( $product_id ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_recount_after_stock_change' ); return wc_recount_after_stock_change( $product_id ); } /** * @deprecated 3.0 */ function woocommerce_change_term_counts( $terms, $taxonomies, $args ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_change_term_counts' ); return wc_change_term_counts( $terms, $taxonomies ); } /** * @deprecated 3.0 */ function woocommerce_get_product_ids_on_sale() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product_ids_on_sale' ); return wc_get_product_ids_on_sale(); } /** * @deprecated 3.0 */ function woocommerce_get_featured_product_ids() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_featured_product_ids' ); return wc_get_featured_product_ids(); } /** * @deprecated 3.0 */ function woocommerce_get_product_terms( $object_id, $taxonomy, $fields = 'all' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_product_terms' ); return wc_get_product_terms( $object_id, $taxonomy, array( 'fields' => $fields ) ); } /** * @deprecated 3.0 */ function woocommerce_product_post_type_link( $permalink, $post ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_product_post_type_link' ); return wc_product_post_type_link( $permalink, $post ); } /** * @deprecated 3.0 */ function woocommerce_placeholder_img_src() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_placeholder_img_src' ); return wc_placeholder_img_src(); } /** * @deprecated 3.0 */ function woocommerce_placeholder_img( $size = 'woocommerce_thumbnail' ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_placeholder_img' ); return wc_placeholder_img( $size ); } /** * @deprecated 3.0 */ function woocommerce_get_formatted_variation( $variation = '', $flat = false ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_formatted_variation' ); return wc_get_formatted_variation( $variation, $flat ); } /** * @deprecated 3.0 */ function woocommerce_scheduled_sales() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_scheduled_sales' ); return wc_scheduled_sales(); } /** * @deprecated 3.0 */ function woocommerce_get_attachment_image_attributes( $attr ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_get_attachment_image_attributes' ); return wc_get_attachment_image_attributes( $attr ); } /** * @deprecated 3.0 */ function woocommerce_prepare_attachment_for_js( $response ) { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_prepare_attachment_for_js' ); return wc_prepare_attachment_for_js( $response ); } /** * @deprecated 3.0 */ function woocommerce_track_product_view() { wc_deprecated_function( __FUNCTION__, '3.0', 'wc_track_product_view' ); return wc_track_product_view(); } /** * @deprecated 2.3 has no replacement */ function woocommerce_compile_less_styles() { wc_deprecated_function( 'woocommerce_compile_less_styles', '2.3' ); } /** * woocommerce_calc_shipping was an option used to determine if shipping was enabled prior to version 2.6.0. This has since been replaced with wc_shipping_enabled() function and * the woocommerce_ship_to_countries setting. * @deprecated 2.6.0 * @return string */ function woocommerce_calc_shipping_backwards_compatibility( $value ) { if ( Constants::is_defined( 'WC_UPDATING' ) ) { return $value; } return 'disabled' === get_option( 'woocommerce_ship_to_countries' ) ? 'no' : 'yes'; } add_filter( 'pre_option_woocommerce_calc_shipping', 'woocommerce_calc_shipping_backwards_compatibility' ); /** * @deprecated 3.0.0 * @see WC_Structured_Data class * * @return string */ function woocommerce_get_product_schema() { wc_deprecated_function( 'woocommerce_get_product_schema', '3.0' ); global $product; $schema = "Product"; // Downloadable product schema handling if ( $product->is_downloadable() ) { switch ( $product->download_type ) { case 'application' : $schema = "SoftwareApplication"; break; case 'music' : $schema = "MusicAlbum"; break; default : $schema = "Product"; break; } } return 'http://schema.org/' . $schema; } /** * Save product price. * * This is a private function (internal use ONLY) used until a data manipulation api is built. * * @deprecated 3.0.0 * @param int $product_id * @param float $regular_price * @param float $sale_price * @param string $date_from * @param string $date_to */ function _wc_save_product_price( $product_id, $regular_price, $sale_price = '', $date_from = '', $date_to = '' ) { wc_doing_it_wrong( '_wc_save_product_price()', 'This function is not for developer use and is deprecated.', '3.0' ); $product_id = absint( $product_id ); $regular_price = wc_format_decimal( $regular_price ); $sale_price = '' === $sale_price ? '' : wc_format_decimal( $sale_price ); $date_from = wc_clean( $date_from ); $date_to = wc_clean( $date_to ); update_post_meta( $product_id, '_regular_price', $regular_price ); update_post_meta( $product_id, '_sale_price', $sale_price ); // Save Dates update_post_meta( $product_id, '_sale_price_dates_from', $date_from ? strtotime( $date_from ) : '' ); update_post_meta( $product_id, '_sale_price_dates_to', $date_to ? strtotime( $date_to ) : '' ); if ( $date_to && ! $date_from ) { $date_from = strtotime( 'NOW', current_time( 'timestamp' ) ); update_post_meta( $product_id, '_sale_price_dates_from', $date_from ); } // Update price if on sale if ( '' !== $sale_price && '' === $date_to && '' === $date_from ) { update_post_meta( $product_id, '_price', $sale_price ); } else { update_post_meta( $product_id, '_price', $regular_price ); } if ( '' !== $sale_price && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) { update_post_meta( $product_id, '_price', $sale_price ); } if ( $date_to && strtotime( $date_to ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) { update_post_meta( $product_id, '_price', $regular_price ); update_post_meta( $product_id, '_sale_price_dates_from', '' ); update_post_meta( $product_id, '_sale_price_dates_to', '' ); } } /** * Return customer avatar URL. * * @deprecated 3.1.0 * @since 2.6.0 * @param string $email the customer's email. * @return string the URL to the customer's avatar. */ function wc_get_customer_avatar_url( $email ) { // Deprecated in favor of WordPress get_avatar_url() function. wc_deprecated_function( 'wc_get_customer_avatar_url()', '3.1', 'get_avatar_url()' ); return get_avatar_url( $email ); } /** * WooCommerce Core Supported Themes. * * @deprecated 3.3.0 * @since 2.2 * @return string[] */ function wc_get_core_supported_themes() { wc_deprecated_function( 'wc_get_core_supported_themes()', '3.3' ); return array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ); } /** * Get min/max price meta query args. * * @deprecated 3.6.0 * @since 3.0.0 * @param array $args Min price and max price arguments. * @return array */ function wc_get_min_max_price_meta_query( $args ) { wc_deprecated_function( 'wc_get_min_max_price_meta_query()', '3.6' ); $current_min_price = isset( $args['min_price'] ) ? floatval( $args['min_price'] ) : 0; $current_max_price = isset( $args['max_price'] ) ? floatval( $args['max_price'] ) : PHP_INT_MAX; return apply_filters( 'woocommerce_get_min_max_price_meta_query', array( 'key' => '_price', 'value' => array( $current_min_price, $current_max_price ), 'compare' => 'BETWEEN', 'type' => 'DECIMAL(10,' . wc_get_price_decimals() . ')', ), $args ); } /** * When a term is split, ensure meta data maintained. * * @deprecated 3.6.0 * @param int $old_term_id Old term ID. * @param int $new_term_id New term ID. * @param string $term_taxonomy_id Term taxonomy ID. * @param string $taxonomy Taxonomy. */ function wc_taxonomy_metadata_update_content_for_split_terms( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { wc_deprecated_function( 'wc_taxonomy_metadata_update_content_for_split_terms', '3.6' ); } /** * WooCommerce Term Meta API. * * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. * This function serves as a wrapper, using the new table if present, or falling back to the WC table. * * @deprecated 3.6.0 * @param int $term_id Term ID. * @param string $meta_key Meta key. * @param mixed $meta_value Meta value. * @param string $prev_value Previous value. (default: ''). * @return bool */ function update_woocommerce_term_meta( $term_id, $meta_key, $meta_value, $prev_value = '' ) { wc_deprecated_function( 'update_woocommerce_term_meta', '3.6', 'update_term_meta' ); return function_exists( 'update_term_meta' ) ? update_term_meta( $term_id, $meta_key, $meta_value, $prev_value ) : update_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value, $prev_value ); } /** * WooCommerce Term Meta API. * * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. * This function serves as a wrapper, using the new table if present, or falling back to the WC table. * * @deprecated 3.6.0 * @param int $term_id Term ID. * @param string $meta_key Meta key. * @param mixed $meta_value Meta value. * @param bool $unique Make meta key unique. (default: false). * @return bool */ function add_woocommerce_term_meta( $term_id, $meta_key, $meta_value, $unique = false ) { wc_deprecated_function( 'add_woocommerce_term_meta', '3.6', 'add_term_meta' ); return function_exists( 'add_term_meta' ) ? add_term_meta( $term_id, $meta_key, $meta_value, $unique ) : add_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value, $unique ); } /** * WooCommerce Term Meta API * * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. * This function serves as a wrapper, using the new table if present, or falling back to the WC table. * * @deprecated 3.6.0 * @param int $term_id Term ID. * @param string $meta_key Meta key. * @param mixed $meta_value Meta value (default: ''). * @param bool $deprecated Deprecated param (default: false). * @return bool */ function delete_woocommerce_term_meta( $term_id, $meta_key, $meta_value = '', $deprecated = false ) { wc_deprecated_function( 'delete_woocommerce_term_meta', '3.6', 'delete_term_meta' ); return function_exists( 'delete_term_meta' ) ? delete_term_meta( $term_id, $meta_key, $meta_value ) : delete_metadata( 'woocommerce_term', $term_id, $meta_key, $meta_value ); } /** * WooCommerce Term Meta API * * WC tables for storing term meta are deprecated from WordPress 4.4 since 4.4 has its own table. * This function serves as a wrapper, using the new table if present, or falling back to the WC table. * * @deprecated 3.6.0 * @param int $term_id Term ID. * @param string $key Meta key. * @param bool $single Whether to return a single value. (default: true). * @return mixed */ function get_woocommerce_term_meta( $term_id, $key, $single = true ) { wc_deprecated_function( 'get_woocommerce_term_meta', '3.6', 'get_term_meta' ); return function_exists( 'get_term_meta' ) ? get_term_meta( $term_id, $key, $single ) : get_metadata( 'woocommerce_term', $term_id, $key, $single ); } /** * Registers the default log handler. * * @deprecated 8.6.0 * @since 3.0 * @param array $handlers Handlers. * @return array */ function wc_register_default_log_handler( $handlers = array() ) { wc_deprecated_function( 'wc_register_default_log_handler', '8.6.0' ); $default_handler = wc_get_container()->get( Settings::class )->get_default_handler(); array_push( $handlers, new $default_handler() ); return $handlers; } /** * Get a log file path. * * @deprecated 8.6.0 * @since 2.2 * * @param string $handle name. * @return string the log file path. */ function wc_get_log_file_path( $handle ) { wc_deprecated_function( 'wc_get_log_file_path', '8.6.0' ); $directory = LoggingUtil::get_log_directory(); $file_id = LoggingUtil::generate_log_file_id( $handle, null, time() ); $hash = LoggingUtil::generate_log_file_hash( $file_id ); return "{$directory}{$file_id}-{$hash}.log"; } /** * Get a log file name. * * @since 3.3 * * @param string $handle Name. * @return string The log file name. */ function wc_get_log_file_name( $handle ) { wc_deprecated_function( 'wc_get_log_file_name', '8.6.0' ); $file_id = LoggingUtil::generate_log_file_id( $handle, null, time() ); $hash = LoggingUtil::generate_log_file_hash( $file_id ); return "{$file_id}-{$hash}"; } .uagb-social-share__outer-wrap,.uagb-social-share__wrap{display:flex;align-items:center;justify-content:center}.uagb-social-share__layout-vertical.uagb-social-share__outer-wrap,.uagb-social-share__layout-vertical .uagb-social-share__wrap{flex-direction:column}.uagb-social-share__layout-vertical .wp-block-uagb-social-share-child.uagb-ss-repeater.uagb-ss__wrapper:first-child{margin-top:0 !important}.uagb-social-share__layout-vertical .wp-block-uagb-social-share-child.uagb-ss-repeater.uagb-ss__wrapper:last-child{margin-bottom:0 !important}.uagb-social-share__outer-wrap a.uagb-button__link:focus{box-shadow:none}.uagb-social-share__outer-wrap .uagb-ss__wrapper{padding:0;margin-left:5px;margin-right:5px;transition:all 0.2s;display:inline-flex;text-align:center}.uagb-social-share__outer-wrap .uagb-ss__source-wrap{display:inline-block}.uagb-social-share__outer-wrap .uagb-ss__link{color:#3a3a3a;display:inline-table;line-height:0;cursor:pointer}.uagb-social-share__outer-wrap .uagb-ss__source-icon{font-size:40px;width:40px;height:40px}.uagb-social-share__outer-wrap .uagb-ss__source-image{width:40px}@media (max-width: 976px){.uagb-social-share__layout-horizontal .uagb-ss__wrapper{margin-left:0;margin-right:0}}.uagb-social-share__layout-horizontal .wp-block-uagb-social-share-child.uagb-ss-repeater.uagb-ss__wrapper:first-child{margin-left:0 !important}.uagb-social-share__layout-horizontal .wp-block-uagb-social-share-child.uagb-ss-repeater.uagb-ss__wrapper:last-child{margin-right:0 !important} { "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "berry", "patterns": [ { "include": "#controls" }, { "include": "#strings" }, { "include": "#comment-block" }, { "include": "#comments" }, { "include": "#keywords" }, { "include": "#function" }, { "include": "#member" }, { "include": "#identifier" }, { "include": "#number" }, { "include": "#operator" } ], "repository": { "controls": { "patterns": [ { "name": "keyword.control.berry", "match": "\\b(if|elif|else|for|while|do|end|break|continue|return|try|except|raise)\\b" } ] }, "strings": { "patterns": [ { "name": "string.quoted.double.berry", "match": "\"(\\\\.|[^\"])*\"" }, { "name": "string.quoted.single.berry", "match": "'(\\\\.|[^'])*'" } ] }, "comment-block": { "name": "comment.berry", "begin": "\\#\\-", "end": "\\-#", "patterns": [{}] }, "comments": { "name": "comment.line.berry", "begin": "\\#", "end": "\\n", "patterns": [{}] }, "keywords": { "patterns": [ { "name": "keyword.berry", "match": "\\b(var|static|def|class|true|false|nil|self|super|import|as)\\b" } ] }, "identifier": { "patterns": [ { "name": "identifier.berry", "match": "\\b[_A-Za-z]\\w+\\b" } ] }, "number": { "patterns": [ { "name": "constant.numeric.berry", "match": "0x[a-fA-F0-9]+|\\d+|(\\d+\\.?|\\.\\d)\\d*([eE][+-]?\\d+)?" } ] }, "operator": { "patterns": [ { "name": "keyword.operator.berry", "match": "\\(|\\)|\\[|\\]|\\.|-|\\!|~|\\*|/|%|\\+|&|\\^|\\||<|>|=|:" } ] }, "member": { "patterns": [ { "match": "\\.([a-zA-Z_][a-zA-Z0-9_]*)", "captures": { "0": { "name": "entity.other.attribute-name.berry" } } } ] }, "function": { "patterns": [ { "name": "entity.name.function.berry", "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*(?=\\s*\\())" } ] } }, "scopeName": "source.berry" } /** * WooCommerce Message Functions * * Functions for error/message handling and display. * * @package WooCommerce\Functions * @version 2.1.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Get the count of notices added, either for all notices (default) or for one. * particular notice type specified by $notice_type. * * @since 2.1 * @param string $notice_type Optional. The name of the notice type - either error, success or notice. * @return int */ function wc_notice_count( $notice_type = '' ) { if ( ! did_action( 'woocommerce_init' ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' ); return; } $notice_count = 0; $all_notices = WC()->session->get( 'wc_notices', array() ); if ( isset( $all_notices[ $notice_type ] ) && is_array( $all_notices[ $notice_type ] ) ) { $notice_count = count( $all_notices[ $notice_type ] ); } elseif ( empty( $notice_type ) ) { foreach ( $all_notices as $notices ) { if ( is_countable( $notices ) ) { $notice_count += count( $notices ); } } } return $notice_count; } /** * Check if a notice has already been added. * * @since 2.1 * @param string $message The text to display in the notice. * @param string $notice_type Optional. The name of the notice type - either error, success or notice. * @return bool */ function wc_has_notice( $message, $notice_type = 'success' ) { if ( ! did_action( 'woocommerce_init' ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' ); return false; } $notices = WC()->session->get( 'wc_notices', array() ); $notices = isset( $notices[ $notice_type ] ) ? $notices[ $notice_type ] : array(); return array_search( $message, wp_list_pluck( $notices, 'notice' ), true ) !== false; } /** * Add and store a notice. * * @since 2.1 * @version 3.9.0 * @param string $message The text to display in the notice. * @param string $notice_type Optional. The name of the notice type - either error, success or notice. * @param array $data Optional notice data. */ function wc_add_notice( $message, $notice_type = 'success', $data = array() ) { if ( ! did_action( 'woocommerce_init' ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' ); return; } $notices = WC()->session->get( 'wc_notices', array() ); // Backward compatibility. if ( 'success' === $notice_type ) { $message = apply_filters( 'woocommerce_add_message', $message ); } $message = apply_filters( 'woocommerce_add_' . $notice_type, $message ); if ( ! empty( $message ) ) { $notices[ $notice_type ][] = array( 'notice' => $message, 'data' => $data, ); } WC()->session->set( 'wc_notices', $notices ); } /** * Set all notices at once. * * @since 2.6.0 * @param array[] $notices Array of notices. */ function wc_set_notices( $notices ) { if ( ! did_action( 'woocommerce_init' ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.6' ); return; } WC()->session->set( 'wc_notices', $notices ); } /** * Unset all notices. * * @since 2.1 */ function wc_clear_notices() { if ( ! did_action( 'woocommerce_init' ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' ); return; } WC()->session->set( 'wc_notices', null ); } /** * Prints messages and errors which are stored in the session, then clears them. * * @since 2.1 * @param bool $return true to return rather than echo. @since 3.5.0. * @return string|void */ function wc_print_notices( $return = false ) { if ( ! did_action( 'woocommerce_init' ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' ); return; } $session = WC()->session; // If the session handler has not initialized, there will be no notices for us to read. if ( null === $session ) { return; } $all_notices = $session->get( 'wc_notices', array() ); $notice_types = apply_filters( 'woocommerce_notice_types', array( 'error', 'success', 'notice' ) ); // Buffer output. ob_start(); foreach ( $notice_types as $notice_type ) { if ( wc_notice_count( $notice_type ) > 0 ) { $messages = array(); foreach ( $all_notices[ $notice_type ] as $notice ) { $messages[] = isset( $notice['notice'] ) ? $notice['notice'] : $notice; } wc_get_template( "notices/{$notice_type}.php", array( 'messages' => array_filter( $messages ), // @deprecated 3.9.0 'notices' => array_filter( $all_notices[ $notice_type ] ), ) ); } } wc_clear_notices(); $notices = wc_kses_notice( ob_get_clean() ); if ( $return ) { return $notices; } echo $notices; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Print a single notice immediately. * * @since 2.1 * @version 3.9.0 * @param string $message The text to display in the notice. * @param string $notice_type Optional. The singular name of the notice type - either error, success or notice. * @param array $data Optional notice data. @since 3.9.0. * @param bool $return true to return rather than echo. @since 7.7.0. */ function wc_print_notice( $message, $notice_type = 'success', $data = array(), $return = false ) { if ( 'success' === $notice_type ) { $message = apply_filters( 'woocommerce_add_message', $message ); } $message = apply_filters( 'woocommerce_add_' . $notice_type, $message ); // Buffer output. ob_start(); wc_get_template( "notices/{$notice_type}.php", array( 'messages' => array( $message ), // @deprecated 3.9.0 'notices' => array( array( 'notice' => $message, 'data' => $data, ), ), ) ); $notice = wc_kses_notice( ob_get_clean() ); if ( $return ) { return $notice; } echo $notice; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Returns all queued notices, optionally filtered by a notice type. * * @since 2.1 * @version 3.9.0 * @param string $notice_type Optional. The singular name of the notice type - either error, success or notice. * @return array[] */ function wc_get_notices( $notice_type = '' ) { if ( ! did_action( 'woocommerce_init' ) ) { wc_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before woocommerce_init.', 'woocommerce' ), '2.3' ); return; } $all_notices = WC()->session->get( 'wc_notices', array() ); if ( empty( $notice_type ) ) { $notices = $all_notices; } elseif ( isset( $all_notices[ $notice_type ] ) ) { $notices = $all_notices[ $notice_type ]; } else { $notices = array(); } return $notices; } /** * Add notices for WP Errors. * * @param WP_Error $errors Errors. */ function wc_add_wp_error_notices( $errors ) { if ( is_wp_error( $errors ) && $errors->get_error_messages() ) { foreach ( $errors->get_error_messages() as $error ) { wc_add_notice( $error, 'error' ); } } } /** * Filters out the same tags as wp_kses_post, but allows tabindex for element. * * @since 3.5.0 * @param string $message Content to filter through kses. * @return string */ function wc_kses_notice( $message ) { $allowed_tags = array_replace_recursive( wp_kses_allowed_html( 'post' ), array( 'a' => array( 'tabindex' => true, ), ) ); /** * Kses notice allowed tags. * * @since 3.9.0 * @param array[]|string $allowed_tags An array of allowed HTML elements and attributes, or a context name such as 'post'. */ return wp_kses( $message, apply_filters( 'woocommerce_kses_notice_allowed_tags', $allowed_tags ) ); } /** * Get notice data attribute. * * @since 3.9.0 * @param array $notice Notice data. * @return string */ function wc_get_notice_data_attr( $notice ) { if ( empty( $notice['data'] ) ) { return; } $attr = ''; foreach ( $notice['data'] as $key => $value ) { $attr .= sprintf( ' data-%1$s="%2$s"', sanitize_title( $key ), esc_attr( $value ) ); } return $attr; } /* * This file is part of the Symfony package. * * (c) Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\String; if (!\function_exists(u::class)) { function u(?string $string = ''): UnicodeString { return new UnicodeString($string ?? ''); } } if (!\function_exists(b::class)) { function b(?string $string = ''): ByteString { return new ByteString($string ?? ''); } } if (!\function_exists(s::class)) { /** * @return UnicodeString|ByteString */ function s(?string $string = ''): AbstractString { $string = $string ?? ''; return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string); } } /** * Functions * * @since 2.0.0 * @package Astra Sites */ if ( ! function_exists( 'astra_sites_error_log' ) ) : /** * Error Log * * A wrapper function for the error_log() function. * * @since 2.0.0 * * @param mixed $message Error message. * @return void */ function astra_sites_error_log( $message = '' ) { if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { if ( is_array( $message ) ) { $message = wp_json_encode( $message ); } if ( apply_filters( 'astra_sites_debug_logs', false ) ) { error_log( $message ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- This is for the debug logs while importing. This is conditional and will not be logged in the debug.log file for normal users. } } } endif; if ( ! function_exists( 'astra_sites_get_suggestion_link' ) ) : /** * * Get suggestion link. * * @since 2.6.1 * * @return suggestion link. */ function astra_sites_get_suggestion_link() { $white_label_link = Astra_Sites_White_Label::get_option( 'astra-agency', 'licence' ); if ( empty( $white_label_link ) ) { $white_label_link = 'https://wpastra.com/sites-suggestions/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=suggestions'; } return apply_filters( 'astra_sites_suggestion_link', $white_label_link ); } endif; if ( ! function_exists( 'astra_sites_is_valid_image' ) ) : /** * Check for the valid image * * @param string $link The Image link. * * @since 2.6.2 * @return boolean */ function astra_sites_is_valid_image( $link = '' ) { return preg_match( '/^((https?:\/\/)|(www\.))([a-z0-9-].?)+(:[0-9]+)?\/[\w\-\@]+\.(jpg|png|gif|jpeg|svg)\/?$/i', $link ); } endif; if ( ! function_exists( 'astra_get_site_data' ) ) : /** * Returns the value of the index for the Site Data * * @param string $index The index value of the data. * * @since 2.6.14 * @return mixed */ function astra_get_site_data( $index = '' ) { $demo_data = Astra_Sites_File_System::get_instance()->get_demo_content(); if ( ! empty( $demo_data ) && isset( $demo_data[ $index ] ) ) { return $demo_data[ $index ]; } return ''; } endif; if ( ! function_exists( 'astra_sites_get_reset_form_data' ) ) : /** * Get all the forms to be reset. * * @since 3.0.3 * @return array */ function astra_sites_get_reset_form_data() { global $wpdb; $form_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_astra_sites_imported_wp_forms'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need this to get all the WP forms. Traditional WP_Query would have been expensive here. return $form_ids; } endif; if ( ! function_exists( 'astra_sites_get_reset_term_data' ) ) : /** * Get all the terms to be reset. * * @since 3.0.3 * @return array */ function astra_sites_get_reset_term_data() { global $wpdb; $term_ids = $wpdb->get_col( "SELECT term_id FROM {$wpdb->termmeta} WHERE meta_key='_astra_sites_imported_term'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need this to get all the terms and taxonomy. Traditional WP_Query would have been expensive here. return $term_ids; } endif; if ( ! function_exists( 'astra_sites_empty_post_excerpt' ) ) : /** * Remove the post excerpt * * @param int $post_id The post ID. * @since 3.1.0 */ function astra_sites_empty_post_excerpt( $post_id = 0 ) { if ( ! $post_id ) { return; } wp_update_post( array( 'ID' => $post_id, 'post_excerpt' => '', ) ); } endif; What do all those files mean? ============================= * `php5.y`: PHP 5 grammar written in a pseudo language * `php7.y`: PHP 7 grammar written in a pseudo language * `tokens.y`: Tokens definition shared between PHP 5 and PHP 7 grammars * `parser.template`: A `kmyacc` parser prototype file for PHP * `tokens.template`: A `kmyacc` prototype file for the `Tokens` class * `rebuildParsers.php`: Preprocesses the grammar and builds the parser using `kmyacc` .phpy pseudo language ===================== The `.y` file is a normal grammar in `kmyacc` (`yacc`) style, with some transformations applied to it: * Nodes are created using the syntax `Name[..., ...]`. This is transformed into `new Name(..., ..., attributes())` * Some function-like constructs are resolved (see `rebuildParsers.php` for a list) Building the parser =================== Run `php grammar/rebuildParsers.php` to rebuild the parsers. Additional options: * The `KMYACC` environment variable can be used to specify an alternative `kmyacc` binary. By default the `phpyacc` dev dependency will be used. To use the original `kmyacc`, you need to compile [moriyoshi's fork](https://github.com/moriyoshi/kmyacc-forked). * The `--debug` option enables emission of debug symbols and creates the `y.output` file. * The `--keep-tmp-grammar` option preserves the preprocessed grammar file. /** * Sureforms Block Helper. * * @package Sureforms */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } if ( ! class_exists( 'Spec_Block_Helper' ) ) { /** * Class Spec_Block_Helper. */ class Spec_Block_Helper { /** * Get Icon Block CSS * * @since 0.0.1 * @param array $attr The block attributes. * @param string $id The selector ID. * @return array The Widget List. */ public static function get_icon_css( $attr, $id ) { $defaults = Spec_Gb_Helper::$block_list['srfm/icon']['attributes']; $attr = array_merge( $defaults, $attr ); $icon_width = Spec_Gb_Helper::get_css_value( $attr['iconSize'], $attr['iconSizeUnit'] ); $transformation = Spec_Gb_Helper::get_css_value( $attr['rotation'], $attr['rotationUnit'] ); $background = 'classic' === $attr['iconBackgroundColorType'] ? $attr['iconBackgroundColor'] : $attr['iconBackgroundGradientColor']; $hover_background = 'classic' === $attr['iconHoverBackgroundColorType'] ? $attr['iconHoverBackgroundColor'] : $attr['iconHoverBackgroundGradientColor']; $drop_shadow_properties = [ 'horizontal' => $attr['iconShadowHOffset'], 'vertical' => $attr['iconShadowVOffset'], 'blur' => $attr['iconShadowBlur'], 'color' => $attr['iconShadowColor'], ]; $drop_shadow = Spec_Gb_Helper::generate_shadow_css( $drop_shadow_properties ); $box_shadow_properties = [ 'horizontal' => $attr['iconBoxShadowHOffset'], 'vertical' => $attr['iconBoxShadowVOffset'], 'blur' => $attr['iconBoxShadowBlur'], 'spread' => $attr['iconBoxShadowSpread'], 'color' => $attr['iconBoxShadowColor'], 'position' => $attr['iconBoxShadowPosition'], ]; $box_shadow_hover_properties = [ 'horizontal' => $attr['iconBoxShadowHOffsetHover'], 'vertical' => $attr['iconBoxShadowVOffsetHover'], 'blur' => $attr['iconBoxShadowBlurHover'], 'spread' => $attr['iconBoxShadowSpreadHover'], 'color' => $attr['iconBoxShadowColorHover'], 'position' => $attr['iconBoxShadowPositionHover'], 'alt_color' => $attr['iconBoxShadowColor'], ]; $box_shadow = Spec_Gb_Helper::generate_shadow_css( $box_shadow_properties ); $box_shadow_hover_css = Spec_Gb_Helper::generate_shadow_css( $box_shadow_hover_properties ); $t_selectors = []; $m_selectors = []; $selectors['.uagb-icon-wrapper'] = [ 'text-align' => $attr['align'], ]; $selectors['.uagb-icon-wrapper .uagb-svg-wrapper a'] = [ 'display' => 'contents', ]; $selectors['.uagb-icon-wrapper svg'] = [ 'width' => $icon_width, 'height' => $icon_width, 'transform' => "rotate($transformation)", 'box-sizing' => 'content-box', 'fill' => $attr['iconColor'], 'filter' => $drop_shadow ? "drop-shadow( $drop_shadow )" : '', ]; $selectors['.uagb-icon-wrapper .uagb-svg-wrapper:hover svg'] = [ 'fill' => $attr['iconHoverColor'], ]; $selectors['.uagb-icon-wrapper .uagb-svg-wrapper'] = array_merge( [ 'display' => 'inline-flex', 'background' => $background, // padding. 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopPadding'], $attr['iconPaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightPadding'], $attr['iconPaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomPadding'], $attr['iconPaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftPadding'], $attr['iconPaddingUnit'] ), // margin. 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopMargin'], $attr['iconMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightMargin'], $attr['iconMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomMargin'], $attr['iconMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftMargin'], $attr['iconMarginUnit'] ), // border. 'border-style' => $attr['iconBorderStyle'], 'border-color' => $attr['iconBorderColor'], 'box-shadow' => $box_shadow, ], self::generate_border_css( $attr, 'icon' ) ); $selectors['.uagb-icon-wrapper .uagb-svg-wrapper:hover'] = [ 'border-color' => $attr['iconBorderHColor'], 'background' => $hover_background, ]; // If using separate box shadow hover settings, then generate CSS for it. if ( $attr['useSeparateBoxShadows'] ) { $selectors['.uagb-icon-wrapper .uagb-svg-wrapper:hover'] = [ 'box-shadow' => $box_shadow_hover_css, 'border-color' => $attr['iconBorderHColor'], 'background' => $hover_background, ]; }; // Generates css for tablet devices. $t_icon_width = Spec_Gb_Helper::get_css_value( $attr['iconSizeTablet'], $attr['iconSizeUnit'] ); $t_selectors['.uagb-icon-wrapper'] = [ 'text-align' => $attr['alignTablet'], ]; $t_selectors['.uagb-icon-wrapper svg'] = [ 'width' => $t_icon_width, 'height' => $t_icon_width, ]; $t_selectors['.uagb-icon-wrapper .uagb-svg-wrapper'] = array_merge( [ 'display' => 'inline-flex', 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopTabletPadding'], $attr['iconTabletPaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightTabletPadding'], $attr['iconTabletPaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomTabletPadding'], $attr['iconTabletPaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftTabletPadding'], $attr['iconTabletPaddingUnit'] ), 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopTabletMargin'], $attr['iconTabletMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightTabletMargin'], $attr['iconTabletMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomTabletMargin'], $attr['iconTabletMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftTabletMargin'], $attr['iconTabletMarginUnit'] ), ], self::generate_border_css( $attr, 'icon', 'tablet' ) ); // Generates css for mobile devices. $m_icon_width = Spec_Gb_Helper::get_css_value( $attr['iconSizeMobile'], $attr['iconSizeUnit'] ); $m_selectors['.uagb-icon-wrapper'] = [ 'text-align' => $attr['alignMobile'], ]; $m_selectors['.uagb-icon-wrapper svg'] = [ 'width' => $m_icon_width, 'height' => $m_icon_width, ]; $m_selectors['.uagb-icon-wrapper .uagb-svg-wrapper'] = array_merge( [ 'display' => 'inline-flex', 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopMobilePadding'], $attr['iconMobilePaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightMobilePadding'], $attr['iconMobilePaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomMobilePadding'], $attr['iconMobilePaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftMobilePadding'], $attr['iconMobilePaddingUnit'] ), 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['iconTopMobileMargin'], $attr['iconMobileMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['iconRightMobileMargin'], $attr['iconMobileMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['iconBottomMobileMargin'], $attr['iconMobileMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['iconLeftMobileMargin'], $attr['iconMobileMarginUnit'] ), ], self::generate_border_css( $attr, 'icon', 'mobile' ) ); $combined_selectors = [ 'desktop' => $selectors, 'tablet' => $t_selectors, 'mobile' => $m_selectors, ]; return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id ); } /** * Get Image Block CSS * * @since 0.0.1 * @param array $attr The block attributes. * @param string $id The selector ID. * @return array The Widget List. */ public static function get_image_css( $attr, $id ) { $defaults = Spec_Gb_Helper::$block_list['srfm/image']['attributes']; $attr = array_merge( $defaults, $attr ); $m_selectors = []; $t_selectors = []; $image_border_css = self::generate_border_css( $attr, 'image' ); $image_border_css_tablet = self::generate_border_css( $attr, 'image', 'tablet' ); $image_border_css_mobile = self::generate_border_css( $attr, 'image', 'mobile' ); $overlay_border_css = self::generate_border_css( $attr, 'overlay' ); $overlay_border_css_tablet = self::generate_border_css( $attr, 'overlay', 'tablet' ); $overlay_border_css_mobile = self::generate_border_css( $attr, 'overlay', 'mobile' ); $width_tablet = '' !== $attr['widthTablet'] ? $attr['widthTablet'] . 'px' : $attr['width'] . 'px'; $width_mobile = '' !== $attr['widthMobile'] ? $attr['widthMobile'] . 'px' : $width_tablet; $height_tablet = '' !== $attr['heightTablet'] ? $attr['heightTablet'] . 'px' : $attr['height'] . 'px'; $height_mobile = '' !== $attr['heightMobile'] ? $attr['heightMobile'] . 'px' : $height_tablet; $align = ''; $align_tablet = ''; $align_mobile = ''; switch ( $attr['align'] ) { case 'left': $align = 'flex-start'; break; case 'right': $align = 'flex-end'; break; case 'center': $align = 'center'; break; } switch ( $attr['alignTablet'] ) { case 'left': $align_tablet = 'flex-start'; break; case 'right': $align_tablet = 'flex-end'; break; case 'center': $align_tablet = 'center'; break; } switch ( $attr['alignMobile'] ) { case 'left': $align_mobile = 'flex-start'; break; case 'right': $align_mobile = 'flex-end'; break; case 'center': $align_mobile = 'center'; break; } $box_shadow_properties = [ 'horizontal' => $attr['imageBoxShadowHOffset'], 'vertical' => $attr['imageBoxShadowVOffset'], 'blur' => $attr['imageBoxShadowBlur'], 'spread' => $attr['imageBoxShadowSpread'], 'color' => $attr['imageBoxShadowColor'], 'position' => $attr['imageBoxShadowPosition'], ]; $box_shadow_hover_properties = [ 'horizontal' => $attr['imageBoxShadowHOffsetHover'], 'vertical' => $attr['imageBoxShadowVOffsetHover'], 'blur' => $attr['imageBoxShadowBlurHover'], 'spread' => $attr['imageBoxShadowSpreadHover'], 'color' => $attr['imageBoxShadowColorHover'], 'position' => $attr['imageBoxShadowPositionHover'], 'alt_color' => $attr['imageBoxShadowColor'], ]; $box_shadow_css = Spec_Gb_Helper::generate_shadow_css( $box_shadow_properties ); $box_shadow_hover_css = Spec_Gb_Helper::generate_shadow_css( $box_shadow_hover_properties ); $selectors = [ '.wp-block-uagb-image' => [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['imageTopMargin'], $attr['imageMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['imageRightMargin'], $attr['imageMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['imageBottomMargin'], $attr['imageMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['imageLeftMargin'], $attr['imageMarginUnit'] ), 'text-align' => $attr['align'], 'justify-content' => $align, 'align-self' => $align, ], ' .wp-block-uagb-image__figure' => [ 'align-items' => $align, ], '.wp-block-uagb-image--layout-default figure img' => array_merge( [ 'box-shadow' => $box_shadow_css, ], $image_border_css ), '.wp-block-uagb-image .wp-block-uagb-image__figure img:hover' => [ 'border-color' => $attr['imageBorderHColor'], ], '.wp-block-uagb-image .wp-block-uagb-image__figure figcaption' => [ 'color' => $attr['captionColor'], 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['captionTopMargin'], $attr['captionMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['captionRightMargin'], $attr['captionMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['captionBottomMargin'], $attr['captionMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['captionLeftMargin'], $attr['captionMarginUnit'] ), 'text-align' => $attr['captionAlign'], ], '.wp-block-uagb-image .wp-block-uagb-image__figure figcaption a' => [ 'color' => $attr['captionColor'], ], // overlay. '.wp-block-uagb-image--layout-overlay figure img' => array_merge( [ 'box-shadow' => $box_shadow_css, ], $image_border_css ), '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__color-wrapper' => array_merge( [ 'background' => $attr['overlayBackground'], 'opacity' => $attr['overlayOpacity'], ], $image_border_css ), '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__color-wrapper:hover' => [ 'border-color' => $attr['imageBorderHColor'], ], '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner' => array_merge( $overlay_border_css, [ 'left' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ), 'right' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ), 'top' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ), 'bottom' => Spec_Gb_Helper::get_css_value( $attr['overlayPositionFromEdge'], $attr['overlayPositionFromEdgeUnit'] ), ] ), '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading' => [ 'color' => $attr['headingColor'], 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['headingTopMargin'], $attr['headingMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['headingRightMargin'], $attr['headingMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headingBottomMargin'], $attr['headingMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['headingLeftMargin'], $attr['headingMarginUnit'] ), 'opacity' => 'always' === $attr['headingShowOn'] ? 1 : 0, ], '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading a' => [ 'color' => $attr['headingColor'], ], '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-caption' => [ 'opacity' => 'always' === $attr['captionShowOn'] ? 1 : 0, ], '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner' => [ 'border-color' => $attr['overlayBorderHColor'], ], '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__color-wrapper' => [ 'opacity' => $attr['overlayHoverOpacity'], ], // separator. '.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator' => [ 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidth'], $attr['separatorWidthType'] ), 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorThickness'], $attr['separatorThicknessUnit'] ), 'border-top-color' => $attr['separatorColor'], 'border-top-style' => $attr['separatorStyle'], 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorBottomMargin'], $attr['separatorMarginUnit'] ), 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['separatorTopMargin'], $attr['separatorMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['separatorLeftMargin'], $attr['separatorMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['separatorRightMargin'], $attr['separatorMarginUnit'] ), 'opacity' => 'always' === $attr['separatorShowOn'] ? 1 : 0, ], ]; $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [ 'object-fit' => $attr['objectFit'], 'width' => $attr['width'] . 'px', 'height' => 'auto', ]; if ( $attr['customHeightSetDesktop'] ) { $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img']['height'] = $attr['height'] . 'px'; } if ( 'hover' === $attr['headingShowOn'] ) { $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading'] = [ 'opacity' => 1, ]; } if ( 'hover' === $attr['captionShowOn'] ) { $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner .uagb-image-caption'] = [ 'opacity' => 1, ]; } if ( 'hover' === $attr['separatorShowOn'] ) { $selectors['.wp-block-uagb-image .wp-block-uagb-image__figure:hover .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator'] = [ 'opacity' => 1, ]; } // If using separate box shadow hover settings, then generate CSS for it. if ( $attr['useSeparateBoxShadows'] ) { $selectors['.wp-block-uagb-image--layout-default figure img:hover'] = [ 'box-shadow' => $box_shadow_hover_css, ]; $selectors['.wp-block-uagb-image--layout-overlay figure img:hover'] = [ 'box-shadow' => $box_shadow_hover_css, ]; }; if ( 'none' !== $attr['maskShape'] ) { $image_path = SRFM_URL . 'assets/images/masks/' . $attr['maskShape'] . '.svg'; if ( 'custom' === $attr['maskShape'] ) { $image_path = $attr['maskCustomShape']['url']; } if ( ! empty( $image_path ) ) { $selectors[ '.wp-block-uagb-image .wp-block-uagb-image__figure img, .uagb-block-' . $id . ' .wp-block-uagb-image--layout-overlay__color-wrapper' ] = [ 'mask-image' => 'url(' . $image_path . ')', '-webkit-mask-image' => 'url(' . $image_path . ')', 'mask-size' => $attr['maskSize'], '-webkit-mask-size' => $attr['maskSize'], 'mask-repeat' => $attr['maskRepeat'], '-webkit-mask-repeat' => $attr['maskRepeat'], 'mask-position' => $attr['maskPosition'], '-webkit-mask-position' => $attr['maskPosition'], ]; } } // tablet. $t_selectors['.wp-block-uagb-image--layout-default figure img'] = $image_border_css_tablet; $t_selectors['.wp-block-uagb-image--layout-overlay figure img'] = $image_border_css_tablet; $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [ 'width' => Spec_Gb_Helper::get_css_value( $attr['widthTablet'], 'px' ), ]; $t_selectors['.wp-block-uagb-image'] = [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['imageTopMarginTablet'], $attr['imageMarginUnitTablet'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['imageRightMarginTablet'], $attr['imageMarginUnitTablet'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['imageBottomMarginTablet'], $attr['imageMarginUnitTablet'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['imageLeftMarginTablet'], $attr['imageMarginUnitTablet'] ), 'text-align' => $attr['alignTablet'], 'justify-content' => $align_tablet, 'align-self' => $align_tablet, ]; $t_selectors[' .wp-block-uagb-image__figure'] = [ 'align-items' => $align_tablet, ]; $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure figcaption'] = [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['captionTopMarginTablet'], $attr['captionMarginUnitTablet'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['captionRightMarginTablet'], $attr['captionMarginUnitTablet'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['captionBottomMarginTablet'], $attr['captionMarginUnitTablet'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['captionLeftMarginTablet'], $attr['captionMarginUnitTablet'] ), ]; $t_selectors['.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner'] = $overlay_border_css_tablet; $t_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading'] = [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['headingTopMarginTablet'], $attr['headingMarginUnitTablet'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['headingRightMarginTablet'], $attr['headingMarginUnitTablet'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headingBottomMarginTablet'], $attr['headingMarginUnitTablet'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['headingLeftMarginTablet'], $attr['headingMarginUnitTablet'] ), ]; $t_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator'] = [ 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorBottomMarginTablet'], $attr['separatorMarginUnitTablet'] ), 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['separatorTopMarginTablet'], $attr['separatorMarginUnitTablet'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['separatorLeftMarginTablet'], $attr['separatorMarginUnitTablet'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['separatorRightMarginTablet'], $attr['separatorMarginUnitTablet'] ), ]; $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [ 'object-fit' => $attr['objectFitTablet'], 'width' => $width_tablet, 'height' => 'auto', ]; if ( $attr['customHeightSetTablet'] ) { $t_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img']['height'] = $height_tablet; } // mobile. $m_selectors['.wp-block-uagb-image--layout-default figure img'] = $image_border_css_mobile; $m_selectors['.wp-block-uagb-image--layout-overlay figure img'] = $image_border_css_mobile; $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [ 'width' => Spec_Gb_Helper::get_css_value( $attr['widthMobile'], 'px' ), ]; $m_selectors['.wp-block-uagb-image'] = [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['imageTopMarginMobile'], $attr['imageMarginUnitMobile'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['imageRightMarginMobile'], $attr['imageMarginUnitMobile'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['imageBottomMarginMobile'], $attr['imageMarginUnitMobile'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['imageLeftMarginMobile'], $attr['imageMarginUnitMobile'] ), 'text-align' => $attr['alignMobile'], 'justify-content' => $align_mobile, 'align-self' => $align_mobile, ]; $m_selectors[' .wp-block-uagb-image__figure'] = [ 'align-items' => $align_mobile, ]; $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure figcaption'] = [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['captionTopMarginMobile'], $attr['captionMarginUnitMobile'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['captionRightMarginMobile'], $attr['captionMarginUnitMobile'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['captionBottomMarginMobile'], $attr['captionMarginUnitMobile'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['captionLeftMarginMobile'], $attr['captionMarginUnitMobile'] ), ]; $m_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading'] = [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['headingTopMarginMobile'], $attr['headingMarginUnitMobile'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['headingRightMarginMobile'], $attr['headingMarginUnitMobile'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headingBottomMarginMobile'], $attr['headingMarginUnitMobile'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['headingLeftMarginMobile'], $attr['headingMarginUnitMobile'] ), ]; $m_selectors['.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner'] = $overlay_border_css_mobile; $m_selectors['.wp-block-uagb-image .wp-block-uagb-image--layout-overlay__inner .uagb-image-separator'] = [ 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorBottomMarginMobile'], $attr['separatorMarginUnitMobile'] ), 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['separatorTopMarginMobile'], $attr['separatorMarginUnitMobile'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['separatorLeftMarginMobile'], $attr['separatorMarginUnitMobile'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['separatorRightMarginMobile'], $attr['separatorMarginUnitMobile'] ), ]; $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img'] = [ 'object-fit' => $attr['objectFitMobile'], 'width' => $width_mobile, 'height' => 'auto', ]; if ( $attr['customHeightSetMobile'] ) { $m_selectors['.wp-block-uagb-image .wp-block-uagb-image__figure img']['height'] = $height_mobile; } $combined_selectors = [ 'desktop' => $selectors, 'tablet' => $t_selectors, 'mobile' => $m_selectors, ]; $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'heading', '.wp-block-uagb-image--layout-overlay .wp-block-uagb-image--layout-overlay__inner .uagb-image-heading', $combined_selectors ); $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'caption', '.wp-block-uagb-image .wp-block-uagb-image__figure figcaption', $combined_selectors ); return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id ); } /** * Get Heading Block CSS * * @since 0.0.1 * @param array $attr The block attributes. * @param string $id The selector ID. * @return array The Widget List. */ public static function get_advanced_heading_css( $attr, $id ) { $defaults = Spec_Gb_Helper::$block_list['srfm/advanced-heading']['attributes']; $attr = array_merge( $defaults, $attr ); $t_selectors = []; $m_selectors = []; $selectors = []; $high_light_border_css = self::generate_border_css( $attr, 'highLight' ); $high_light_border_css_tablet = self::generate_border_css( $attr, 'highLight', 'tablet' ); $high_light_border_css_mobile = self::generate_border_css( $attr, 'highLight', 'mobile' ); $selectors = [ '.wp-block-uagb-advanced-heading .uagb-heading-text' => [ 'color' => $attr['headingColor'], ], '.wp-block-uagb-advanced-heading ' => [ 'background' => 'classic' === $attr['blockBackgroundType'] ? $attr['blockBackground'] : $attr['blockGradientBackground'], 'text-align' => $attr['headingAlign'], 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMargin'], $attr['blockMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMargin'], $attr['blockMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMargin'], $attr['blockMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMargin'], $attr['blockMarginUnit'] ), 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPadding'], $attr['blockPaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPadding'], $attr['blockPaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPadding'], $attr['blockPaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPadding'], $attr['blockPaddingUnit'] ), ], '.wp-block-uagb-advanced-heading a' => [ 'color' => $attr['linkColor'], ], '.wp-block-uagb-advanced-heading a:hover' => [ 'color' => $attr['linkHColor'], ], '.wp-block-uagb-advanced-heading .uagb-desc-text' => [ 'color' => $attr['subHeadingColor'], 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['subHeadSpace'], 'px' ), ], '.wp-block-uagb-advanced-heading .srfm-highlight' => array_merge( [ 'background' => $attr['highLightBackground'], 'color' => $attr['highLightColor'], '-webkit-text-fill-color' => $attr['highLightColor'], 'font-family' => $attr['highLightFontFamily'], 'font-style' => $attr['highLightFontStyle'], 'text-decoration' => $attr['highLightDecoration'], 'text-transform' => $attr['highLightTransform'], 'font-weight' => $attr['highLightFontWeight'], 'font-size' => Spec_Gb_Helper::get_css_value( $attr['highLightFontSize'], $attr['highLightFontSizeType'] ), 'line-height' => Spec_Gb_Helper::get_css_value( $attr['highLightLineHeight'], $attr['highLightLineHeightType'] ), 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['highLightTopPadding'], $attr['highLightPaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['highLightRightPadding'], $attr['highLightPaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['highLightBottomPadding'], $attr['highLightPaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['highLightLeftPadding'], $attr['highLightPaddingUnit'] ), ], $high_light_border_css ), '.wp-block-uagb-advanced-heading .srfm-highlight:hover' => [ 'border-color' => $attr['highLightBorderHColor'], ], ]; $heading_text_shadow_color = ( ! empty( $attr['headShadowColor'] ) ? Spec_Gb_Helper::get_css_value( $attr['headShadowHOffset'], 'px' ) . ' ' . Spec_Gb_Helper::get_css_value( $attr['headShadowVOffset'], 'px' ) . ' ' . Spec_Gb_Helper::get_css_value( $attr['headShadowBlur'], 'px' ) . ' ' . $attr['headShadowColor'] : '' ); if ( 'gradient' === $attr['headingColorType'] ) { $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'] = array_merge( $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'], [ 'background' => $attr['headingGradientColor'], '-webkit-background-clip' => 'text', '-webkit-text-fill-color' => 'transparent', 'filter' => 'drop-shadow( ' . $heading_text_shadow_color . ' )', ] ); $selectors['.wp-block-uagb-advanced-heading a'] = array_merge( $selectors['.wp-block-uagb-advanced-heading a'], [ '-webkit-text-fill-color' => $attr['linkColor'], ] ); $selectors['.wp-block-uagb-advanced-heading a:hover'] = array_merge( $selectors['.wp-block-uagb-advanced-heading a:hover'], [ '-webkit-text-fill-color' => $attr['linkHColor'], ] ); } else { $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'] = array_merge( $selectors['.wp-block-uagb-advanced-heading .uagb-heading-text'], [ 'text-shadow' => $heading_text_shadow_color, ] ); } // Text Selection & highlight. $highlight_selection_text = [ 'color' => $attr['highLightColor'], 'background' => $attr['highLightBackground'], '-webkit-text-fill-color' => $attr['highLightColor'], ]; $selectors['.wp-block-uagb-advanced-heading .srfm-highlight::-moz-selection'] = $highlight_selection_text; $selectors['.wp-block-uagb-advanced-heading .srfm-highlight::selection'] = $highlight_selection_text; $separator_style = isset( $attr['separatorStyle'] ) ? $attr['separatorStyle'] : ''; if ( 'none' !== $separator_style ) { $selectors['.wp-block-uagb-advanced-heading .uagb-separator'] = [ 'border-top-style' => $attr['separatorStyle'], 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorHeight'], $attr['separatorHeightType'] ), 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidth'], $attr['separatorWidthType'] ), 'border-color' => $attr['separatorColor'], 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorSpace'], $attr['separatorSpaceType'] ), ]; $t_selectors['.wp-block-uagb-advanced-heading .uagb-separator'] = [ 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthTablet'], $attr['separatorWidthType'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorSpaceTablet'], $attr['separatorSpaceType'] ), ]; $m_selectors['.wp-block-uagb-advanced-heading .uagb-separator'] = [ 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthMobile'], $attr['separatorWidthType'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['separatorSpaceMobile'], $attr['separatorSpaceType'] ), ]; } $t_selectors['.wp-block-uagb-advanced-heading '] = [ 'text-align' => $attr['headingAlignTablet'], 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingTablet'], $attr['blockPaddingUnitTablet'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingTablet'], $attr['blockPaddingUnitTablet'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingTablet'], $attr['blockPaddingUnitTablet'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingTablet'], $attr['blockPaddingUnitTablet'] ), 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginTablet'], $attr['blockMarginUnitTablet'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginTablet'], $attr['blockMarginUnitTablet'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginTablet'], $attr['blockMarginUnitTablet'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginTablet'], $attr['blockMarginUnitTablet'] ), ]; $t_selectors['.wp-block-uagb-advanced-heading .srfm-highlight'] = array_merge( [ 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['highLightTopPaddingTablet'], $attr['highLightPaddingUnitTablet'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['highLightRightPaddingTablet'], $attr['highLightPaddingUnitTablet'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['highLightBottomPaddingTablet'], $attr['highLightPaddingUnitTablet'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['highLightLeftPaddingTablet'], $attr['highLightPaddingUnitTablet'] ), ], $high_light_border_css_tablet ); $m_selectors['.wp-block-uagb-advanced-heading '] = [ 'text-align' => $attr['headingAlignMobile'], 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingMobile'], $attr['blockPaddingUnitMobile'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingMobile'], $attr['blockPaddingUnitMobile'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingMobile'], $attr['blockPaddingUnitMobile'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingMobile'], $attr['blockPaddingUnitMobile'] ), 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginMobile'], $attr['blockMarginUnitMobile'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginMobile'], $attr['blockMarginUnitMobile'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginMobile'], $attr['blockMarginUnitMobile'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginMobile'], $attr['blockMarginUnitMobile'] ), ]; $m_selectors['.wp-block-uagb-advanced-heading .srfm-highlight'] = array_merge( [ 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['highLightTopPaddingMobile'], $attr['highLightPaddingUnitMobile'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['highLightRightPaddingMobile'], $attr['highLightPaddingUnitMobile'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['highLightBottomPaddingMobile'], $attr['highLightPaddingUnitMobile'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['highLightLeftPaddingMobile'], $attr['highLightPaddingUnitMobile'] ), ], $high_light_border_css_mobile ); $t_selectors['.wp-block-uagb-advanced-heading .uagb-desc-text'] = [ 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['subHeadSpaceTablet'], $attr['subHeadSpaceType'] ), ]; $m_selectors['.wp-block-uagb-advanced-heading .uagb-desc-text'] = [ 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['subHeadSpaceMobile'], $attr['subHeadSpaceType'] ), ]; if ( $attr['headingDescToggle'] || 'none' !== $attr['separatorStyle'] ) { $selectors[' .uagb-heading-text'] = [ 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headSpace'], 'px' ), ]; $t_selectors[' .uagb-heading-text'] = [ 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headSpaceTablet'], $attr['headSpaceType'] ), ]; $m_selectors[' .uagb-heading-text'] = [ 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['headSpaceMobile'], $attr['headSpaceType'] ), ]; } $combined_selectors = Spec_Gb_Helper::get_combined_selectors( 'advanced-heading', [ 'desktop' => $selectors, 'tablet' => $t_selectors, 'mobile' => $m_selectors, ], $attr ); $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'head', ' .uagb-heading-text', $combined_selectors ); $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'subHead', ' .uagb-desc-text', $combined_selectors ); $combined_selectors = Spec_Gb_Helper::get_typography_css( $attr, 'highLight', '.wp-block-uagb-advanced-heading .srfm-highlight', $combined_selectors ); return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id ); } /** * Get Separator Block CSS * * @since 0.0.1 * @param array $attr The block attributes. * @param string $id The selector ID. * @return array The Widget List. */ public static function get_separator_css( $attr, $id ) { $defaults = Spec_Gb_Helper::$block_list['srfm/separator']['attributes']; $attr = array_merge( $defaults, $attr ); $t_selectors = []; $m_selectors = []; $selectors = []; $border_size = '100%'; $border_css = [ '-webkit-mask-size' => ( Spec_Gb_Helper::get_css_value( $attr['separatorSize'], $attr['separatorSizeType'] ) . ' ' . $border_size ), 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorBorderHeight'], $attr['separatorBorderHeightUnit'] ), 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidth'], $attr['separatorWidthType'] ), 'border-top-color' => $attr['separatorColor'], 'border-top-style' => $attr['separatorStyle'], ]; $border_style = []; $icon_spacing_style = []; if ( 'none' === $attr['elementType'] ) { $border_style['.wp-block-uagb-separator:not(.wp-block-uagb-separator--text):not(.wp-block-uagb-separator--icon) .wp-block-uagb-separator__inner'] = $border_css; } else { $align_css = Spec_Gb_Helper::alignment_css( $attr['separatorAlign'] ); $border_style = [ '.wp-block-uagb-separator .wp-block-uagb-separator__inner' => array_merge( [ 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidth'], $attr['separatorWidthType'] ), ], $align_css ), ]; $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = $border_css; $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = $border_css; $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = $border_css; $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = $border_css; if ( 'left' === $attr['elementPosition'] ) { $icon_spacing_style['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ), ]; $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = [ 'display' => 'none', ]; $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = [ 'display' => 'none', ]; } if ( 'right' === $attr['elementPosition'] ) { $icon_spacing_style['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ), ]; $border_style['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = [ 'display' => 'none', ]; $border_style['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = [ 'display' => 'none', ]; } if ( 'center' === $attr['elementPosition'] ) { $icon_spacing_style['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacing'], $attr['elementSpacingUnit'] ), ]; } } $selectors = [ '.wp-block-uagb-separator.uagb-block .wp-block-uagb-separator-wrapper' => [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMargin'], $attr['blockMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMargin'], $attr['blockMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMargin'], $attr['blockMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMargin'], $attr['blockMarginUnit'] ), 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPadding'], $attr['blockPaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPadding'], $attr['blockPaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPadding'], $attr['blockPaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPadding'], $attr['blockPaddingUnit'] ), 'text-align' => $attr['separatorAlign'], ], '.wp-block-uagb-separator--text .wp-block-uagb-separator-element .uagb-html-tag' => [ 'font-family' => $attr['elementTextFontFamily'], 'font-style' => $attr['elementTextFontStyle'], 'text-decoration' => $attr['elementTextDecoration'], 'text-transform' => $attr['elementTextTransform'], 'font-weight' => $attr['elementTextFontWeight'], 'color' => $attr['elementColor'], 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementTextFontSize'], $attr['elementTextFontSizeType'] ), 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementTextLineHeight'], $attr['elementTextLineHeightType'] ), 'letter-spacing' => Spec_Gb_Helper::get_css_value( $attr['elementTextLetterSpacing'], $attr['elementTextLetterSpacingType'] ), ], '.wp-block-uagb-separator--icon .wp-block-uagb-separator-element svg' => [ 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ), 'width' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ), 'height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ), 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidth'], $attr['elementIconWidthType'] ), 'color' => $attr['elementColor'], 'fill' => $attr['elementColor'], ], ]; $selectors = array_merge( $selectors, $border_style, $icon_spacing_style ); // Tablet. $border_css_tablet = [ '-webkit-mask-size' => ( Spec_Gb_Helper::get_css_value( $attr['separatorSizeTablet'], $attr['separatorSizeType'] ) . ' ' . $border_size ), 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorBorderHeightTablet'], $attr['separatorBorderHeightUnit'] ), 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthTablet'], $attr['separatorWidthType'] ), 'border-top-color' => $attr['separatorColor'], 'border-top-style' => $attr['separatorStyle'], ]; $border_style_tablet = []; $icon_spacing_style_tablet = []; if ( 'none' === $attr['elementType'] ) { $border_style_tablet['.wp-block-uagb-separator:not(.wp-block-uagb-separator--text):not(.wp-block-uagb-separator--icon) .wp-block-uagb-separator__inner'] = $border_css_tablet; } else { $align_css = Spec_Gb_Helper::alignment_css( $attr['separatorAlignTablet'] ); $border_style_tablet = [ '.wp-block-uagb-separator .wp-block-uagb-separator__inner' => array_merge( [ 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthTablet'], $attr['separatorWidthType'] ), ], $align_css ), ]; $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = $border_css_tablet; $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = $border_css_tablet; $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = $border_css_tablet; $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = $border_css_tablet; if ( 'left' === $attr['elementPosition'] ) { $icon_spacing_style_tablet['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ), ]; $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = [ 'display' => 'none', ]; $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = [ 'display' => 'none', ]; } if ( 'center' === $attr['elementPosition'] ) { $icon_spacing_style_tablet['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ), ]; } if ( 'right' === $attr['elementPosition'] ) { $icon_spacing_style_tablet['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingTablet'], $attr['elementSpacingUnit'] ), ]; $border_style_tablet['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = [ 'display' => 'none', ]; $border_style_tablet['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = [ 'display' => 'none', ]; } } $t_selectors = [ '.wp-block-uagb-separator.uagb-block .wp-block-uagb-separator-wrapper' => [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginTablet'], $attr['blockMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginTablet'], $attr['blockMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginTablet'], $attr['blockMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginTablet'], $attr['blockMarginUnit'] ), 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingTablet'], $attr['blockPaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingTablet'], $attr['blockPaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingTablet'], $attr['blockPaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingTablet'], $attr['blockPaddingUnit'] ), 'text-align' => $attr['separatorAlignTablet'], ], '.wp-block-uagb-separator--text .wp-block-uagb-separator-element .uagb-html-tag' => [ 'font-family' => $attr['elementTextFontFamily'], 'font-style' => $attr['elementTextFontStyle'], 'text-decoration' => $attr['elementTextDecoration'], 'text-transform' => $attr['elementTextTransform'], 'font-weight' => $attr['elementTextFontWeight'], 'color' => $attr['elementColor'], 'margin-bottom' => 'initial', 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementTextFontSizeTablet'], $attr['elementTextFontSizeType'] ), 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementTextLineHeightTablet'], $attr['elementTextLineHeightType'] ), 'letter-spacing' => Spec_Gb_Helper::get_css_value( $attr['elementTextLetterSpacingTablet'], $attr['elementTextLetterSpacingType'] ), ], '.wp-block-uagb-separator--icon .wp-block-uagb-separator-element svg' => [ 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr['elementIconWidthType'] ), 'width' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr['elementIconWidthType'] ), 'height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr['elementIconWidthType'] ), 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthTablet'], $attr ['elementIconWidthType'] ), 'color' => $attr['elementColor'], 'fill' => $attr['elementColor'], ], ]; $t_selectors = array_merge( $t_selectors, $border_style_tablet, $icon_spacing_style_tablet ); // Mobile. $border_css_mobile = [ '-webkit-mask-size' => ( Spec_Gb_Helper::get_css_value( $attr['separatorSizeMobile'], $attr['separatorSizeType'] ) . ' ' . $border_size ), 'border-top-width' => Spec_Gb_Helper::get_css_value( $attr['separatorBorderHeightMobile'], $attr['separatorBorderHeightUnit'] ), 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthMobile'], $attr['separatorWidthType'] ), 'border-top-color' => $attr['separatorColor'], 'border-top-style' => $attr['separatorStyle'], ]; $border_style_mobile = []; $icon_spacing_style_mobile = []; if ( 'none' === $attr['elementType'] ) { $border_style_mobile['.wp-block-uagb-separator:not(.wp-block-uagb-separator--text):not(.wp-block-uagb-separator--icon) .wp-block-uagb-separator__inner'] = $border_css_mobile; } else { $align_css = Spec_Gb_Helper::alignment_css( $attr['separatorAlignMobile'] ); $border_style_mobile = [ '.wp-block-uagb-separator .wp-block-uagb-separator__inner' => array_merge( [ 'width' => Spec_Gb_Helper::get_css_value( $attr['separatorWidthMobile'], $attr['separatorWidthType'] ), ], $align_css ), ]; $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = $border_css_mobile; $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = $border_css_mobile; $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = $border_css_mobile; $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = $border_css_mobile; if ( 'left' === $attr['elementPosition'] ) { $icon_spacing_style_mobile['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ), ]; $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::before'] = [ 'display' => 'none', ]; $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::before'] = [ 'display' => 'none', ]; } if ( 'center' === $attr['elementPosition'] ) { $icon_spacing_style_mobile['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ), ]; } if ( 'right' === $attr['elementPosition'] ) { $icon_spacing_style_mobile['.wp-block-uagb-separator .wp-block-uagb-separator__inner .wp-block-uagb-separator-element'] = [ 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['elementSpacingMobile'], $attr['elementSpacingUnit'] ), ]; $border_style_mobile['.wp-block-uagb-separator--text .wp-block-uagb-separator__inner::after'] = [ 'display' => 'none', ]; $border_style_mobile['.wp-block-uagb-separator--icon .wp-block-uagb-separator__inner::after'] = [ 'display' => 'none', ]; } } $m_selectors = [ '.wp-block-uagb-separator.uagb-block .wp-block-uagb-separator-wrapper' => [ 'margin-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopMarginMobile'], $attr['blockMarginUnit'] ), 'margin-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightMarginMobile'], $attr['blockMarginUnit'] ), 'margin-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomMarginMobile'], $attr['blockMarginUnit'] ), 'margin-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftMarginMobile'], $attr['blockMarginUnit'] ), 'padding-top' => Spec_Gb_Helper::get_css_value( $attr['blockTopPaddingMobile'], $attr['blockPaddingUnit'] ), 'padding-right' => Spec_Gb_Helper::get_css_value( $attr['blockRightPaddingMobile'], $attr['blockPaddingUnit'] ), 'padding-bottom' => Spec_Gb_Helper::get_css_value( $attr['blockBottomPaddingMobile'], $attr['blockPaddingUnit'] ), 'padding-left' => Spec_Gb_Helper::get_css_value( $attr['blockLeftPaddingMobile'], $attr['blockPaddingUnit'] ), 'text-align' => $attr['separatorAlignMobile'], ], '.wp-block-uagb-separator--text .wp-block-uagb-separator-element .uagb-html-tag' => [ 'font-family' => $attr['elementTextFontFamily'], 'font-style' => $attr['elementTextFontStyle'], 'text-decoration' => $attr['elementTextDecoration'], 'text-transform' => $attr['elementTextTransform'], 'font-weight' => $attr['elementTextFontWeight'], 'color' => $attr['elementColor'], 'margin-bottom' => 'initial', 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementTextFontSizeMobile'], $attr['elementTextFontSizeType'] ), 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementTextLineHeightMobile'], $attr['elementTextLineHeightType'] ), 'letter-spacing' => Spec_Gb_Helper::get_css_value( $attr['elementTextLetterSpacingMobile'], $attr['elementTextLetterSpacingType'] ), ], '.wp-block-uagb-separator--icon .wp-block-uagb-separator-element svg' => [ 'font-size' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr['elementIconWidthType'] ), 'width' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr['elementIconWidthType'] ), 'height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr['elementIconWidthType'] ), 'line-height' => Spec_Gb_Helper::get_css_value( $attr['elementIconWidthMobile'], $attr ['elementIconWidthType'] ), 'color' => $attr['elementColor'], 'fill' => $attr['elementColor'], ], ]; $m_selectors = array_merge( $m_selectors, $border_style_mobile, $icon_spacing_style_mobile ); $combined_selectors = [ 'desktop' => $selectors, 'tablet' => $t_selectors, 'mobile' => $m_selectors, ]; return Spec_Gb_Helper::generate_all_css( $combined_selectors, ' .uagb-block-' . $id ); } /** * Border CSS generation Function. * * @since 0.0.1 * @param array $attr Attribute List. * @param string $prefix Attribuate prefix . * @param string $device Responsive. * @return array border css array. */ public static function generate_border_css( $attr, $prefix, $device = 'desktop' ) { $gen_border_css = []; if ( 'tablet' === $device ) { if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] ) { $gen_border_css['border-top-width'] = self::get_css_value( $attr[ $prefix . 'BorderTopWidthTablet' ], 'px' ); $gen_border_css['border-left-width'] = self::get_css_value( $attr[ $prefix . 'BorderLeftWidthTablet' ], 'px' ); $gen_border_css['border-right-width'] = self::get_css_value( $attr[ $prefix . 'BorderRightWidthTablet' ], 'px' ); $gen_border_css['border-bottom-width'] = self::get_css_value( $attr[ $prefix . 'BorderBottomWidthTablet' ], 'px' ); } $gen_border_unit_tablet = isset( $attr[ $prefix . 'BorderRadiusUnitTablet' ] ) ? $attr[ $prefix . 'BorderRadiusUnitTablet' ] : 'px'; $gen_border_css['border-top-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopLeftRadiusTablet' ], $gen_border_unit_tablet ); $gen_border_css['border-top-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopRightRadiusTablet' ], $gen_border_unit_tablet ); $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadiusTablet' ], $gen_border_unit_tablet ); $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomRightRadiusTablet' ], $gen_border_unit_tablet ); } elseif ( 'mobile' === $device ) { if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] ) { $gen_border_css['border-top-width'] = self::get_css_value( $attr[ $prefix . 'BorderTopWidthMobile' ], 'px' ); $gen_border_css['border-left-width'] = self::get_css_value( $attr[ $prefix . 'BorderLeftWidthMobile' ], 'px' ); $gen_border_css['border-right-width'] = self::get_css_value( $attr[ $prefix . 'BorderRightWidthMobile' ], 'px' ); $gen_border_css['border-bottom-width'] = self::get_css_value( $attr[ $prefix . 'BorderBottomWidthMobile' ], 'px' ); } $gen_border_unit_mobile = isset( $attr[ $prefix . 'BorderTopLeftRadiusMobile' ] ) ? $attr[ $prefix . 'BorderTopLeftRadiusMobile' ] : 'px'; $gen_border_css['border-top-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopLeftRadiusMobile' ], $gen_border_unit_mobile ); $gen_border_css['border-top-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopRightRadiusMobile' ], $gen_border_unit_mobile ); $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadiusMobile' ], $gen_border_unit_mobile ); $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomRightRadiusMobile' ], $gen_border_unit_mobile ); } else { if ( 'none' !== $attr[ $prefix . 'BorderStyle' ] ) { $gen_border_css['border-top-width'] = self::get_css_value( $attr[ $prefix . 'BorderTopWidth' ], 'px' ); $gen_border_css['border-left-width'] = self::get_css_value( $attr[ $prefix . 'BorderLeftWidth' ], 'px' ); $gen_border_css['border-right-width'] = self::get_css_value( $attr[ $prefix . 'BorderRightWidth' ], 'px' ); $gen_border_css['border-bottom-width'] = self::get_css_value( $attr[ $prefix . 'BorderBottomWidth' ], 'px' ); } $gen_border_unit = isset( $attr[ $prefix . 'BorderRadiusUnit' ] ) ? $attr[ $prefix . 'BorderRadiusUnit' ] : 'px'; $gen_border_css['border-top-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopLeftRadius' ], $gen_border_unit ); $gen_border_css['border-top-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderTopRightRadius' ], $gen_border_unit ); $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomLeftRadius' ], $gen_border_unit ); $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $attr[ $prefix . 'BorderBottomRightRadius' ], $gen_border_unit ); } $border_style = $attr[ $prefix . 'BorderStyle' ]; $border_color = $attr[ $prefix . 'BorderColor' ]; $gen_border_css['border-style'] = $border_style; $gen_border_css['border-color'] = $border_color; return $gen_border_css; } /** * Get CSS value * * Syntax: * * get_css_value( VALUE, UNIT ); * * E.g. * * get_css_value( VALUE, 'em' ); * * @param string $value CSS value. * @param string $unit CSS unit. * @since 0.0.1 */ public static function get_css_value( $value = '', $unit = '' ) { if ( '' === $value ) { return $value; } $css_val = ''; if ( isset( $value ) ) { $css_val = esc_attr( $value ) . $unit; } return $css_val; } /** * Deprecated Border CSS generation Function. * * @since 0.0.1 * @param array $current_css Current style list. * @param string $border_width Border Width. * @param string $border_radius Border Radius. * @param string $border_color Border Color. * @param string $border_style Border Style. */ public static function generate_deprecated_border_css( $current_css, $border_width, $border_radius, $border_color = '', $border_style = '' ) { $gen_border_css = []; if ( is_numeric( $border_width ) ) { $gen_border_css['border-top-width'] = self::get_css_value( $border_width, 'px' ); $gen_border_css['border-left-width'] = self::get_css_value( $border_width, 'px' ); $gen_border_css['border-right-width'] = self::get_css_value( $border_width, 'px' ); $gen_border_css['border-bottom-width'] = self::get_css_value( $border_width, 'px' ); } if ( is_numeric( $border_radius ) ) { $gen_border_css['border-top-left-radius'] = self::get_css_value( $border_radius, 'px' ); $gen_border_css['border-top-right-radius'] = self::get_css_value( $border_radius, 'px' ); $gen_border_css['border-bottom-left-radius'] = self::get_css_value( $border_radius, 'px' ); $gen_border_css['border-bottom-right-radius'] = self::get_css_value( $border_radius, 'px' ); } if ( $border_color ) { $gen_border_css['border-color'] = $border_color; } if ( $border_style ) { $gen_border_css['border-style'] = $border_style; } return wp_parse_args( $gen_border_css, $current_css ); } } } /** * Astra Updates * * Functions for updating data, used by the background updater. * * @package Astra * @version 2.1.3 */ defined( 'ABSPATH' ) || exit; /** * Clear Astra + Astra Pro assets cache. * * @since 3.6.1 * @return void. */ function astra_clear_all_assets_cache() { if ( ! class_exists( 'Astra_Cache_Base' ) ) { return; } // Clear Astra theme asset cache. $astra_cache_base_instance = new Astra_Cache_Base( 'astra' ); $astra_cache_base_instance->refresh_assets( 'astra' ); // Clear Astra Addon's static and dynamic CSS asset cache. $astra_addon_cache_base_instance = new Astra_Cache_Base( 'astra-addon' ); $astra_addon_cache_base_instance->refresh_assets( 'astra-addon' ); } /** * 4.0.0 backward handling part. * * 1. Migrate existing setting & do required onboarding for new admin dashboard v4.0.0 app. * 2. Migrating Post Structure & Meta options in title area meta parts. * * @since 4.0.0 * @return void */ function astra_theme_background_updater_4_0_0() { // Dynamic customizer migration starts here. $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['dynamic-blog-layouts'] ) && ! isset( $theme_options['theme-dynamic-customizer-support'] ) ) { $theme_options['dynamic-blog-layouts'] = false; $theme_options['theme-dynamic-customizer-support'] = true; $post_types = Astra_Posts_Structure_Loader::get_supported_post_types(); // Archive summary box compatibility. $archive_title_font_size = array( 'desktop' => isset( $theme_options['font-size-archive-summary-title']['desktop'] ) ? $theme_options['font-size-archive-summary-title']['desktop'] : 40, 'tablet' => isset( $theme_options['font-size-archive-summary-title']['tablet'] ) ? $theme_options['font-size-archive-summary-title']['tablet'] : '', 'mobile' => isset( $theme_options['font-size-archive-summary-title']['mobile'] ) ? $theme_options['font-size-archive-summary-title']['mobile'] : '', 'desktop-unit' => isset( $theme_options['font-size-archive-summary-title']['desktop-unit'] ) ? $theme_options['font-size-archive-summary-title']['desktop-unit'] : 'px', 'tablet-unit' => isset( $theme_options['font-size-archive-summary-title']['tablet-unit'] ) ? $theme_options['font-size-archive-summary-title']['tablet-unit'] : 'px', 'mobile-unit' => isset( $theme_options['font-size-archive-summary-title']['mobile-unit'] ) ? $theme_options['font-size-archive-summary-title']['mobile-unit'] : 'px', ); $single_title_font_size = array( 'desktop' => isset( $theme_options['font-size-entry-title']['desktop'] ) ? $theme_options['font-size-entry-title']['desktop'] : '', 'tablet' => isset( $theme_options['font-size-entry-title']['tablet'] ) ? $theme_options['font-size-entry-title']['tablet'] : '', 'mobile' => isset( $theme_options['font-size-entry-title']['mobile'] ) ? $theme_options['font-size-entry-title']['mobile'] : '', 'desktop-unit' => isset( $theme_options['font-size-entry-title']['desktop-unit'] ) ? $theme_options['font-size-entry-title']['desktop-unit'] : 'px', 'tablet-unit' => isset( $theme_options['font-size-entry-title']['tablet-unit'] ) ? $theme_options['font-size-entry-title']['tablet-unit'] : 'px', 'mobile-unit' => isset( $theme_options['font-size-entry-title']['mobile-unit'] ) ? $theme_options['font-size-entry-title']['mobile-unit'] : 'px', ); $archive_summary_box_bg = array( 'desktop' => array( 'background-color' => ! empty( $theme_options['archive-summary-box-bg-color'] ) ? $theme_options['archive-summary-box-bg-color'] : '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', 'background-type' => '', 'background-media' => '', ), 'tablet' => array( 'background-color' => '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', 'background-type' => '', 'background-media' => '', ), 'mobile' => array( 'background-color' => '', 'background-image' => '', 'background-repeat' => 'repeat', 'background-position' => 'center center', 'background-size' => 'auto', 'background-attachment' => 'scroll', 'background-type' => '', 'background-media' => '', ), ); // Single post structure. foreach ( $post_types as $post_type ) { /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $single_post_structure = isset( $theme_options['blog-single-post-structure'] ) ? $theme_options['blog-single-post-structure'] : array( 'single-image', 'single-title-meta' ); /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $migrated_post_structure = array(); if ( ! empty( $single_post_structure ) ) { /** @psalm-suppress PossiblyInvalidIterator */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort foreach ( $single_post_structure as $key ) { /** @psalm-suppress PossiblyInvalidIterator */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( 'single-title-meta' === $key ) { $migrated_post_structure[] = 'ast-dynamic-single-' . esc_attr( $post_type ) . '-title'; if ( 'post' === $post_type ) { $migrated_post_structure[] = 'ast-dynamic-single-' . esc_attr( $post_type ) . '-meta'; } } if ( 'single-image' === $key ) { $migrated_post_structure[] = 'ast-dynamic-single-' . esc_attr( $post_type ) . '-image'; } } $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-structure' ] = $migrated_post_structure; } // Single post meta. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $single_post_meta = isset( $theme_options['blog-single-meta'] ) ? $theme_options['blog-single-meta'] : array( 'comments', 'category', 'author' ); /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $migrated_post_metadata = array(); if ( ! empty( $single_post_meta ) ) { $tax_counter = 0; $tax_slug = 'ast-dynamic-single-' . esc_attr( $post_type ) . '-taxonomy'; /** @psalm-suppress PossiblyInvalidIterator */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort foreach ( $single_post_meta as $key ) { /** @psalm-suppress PossiblyInvalidIterator */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort switch ( $key ) { case 'author': $migrated_post_metadata[] = 'author'; break; case 'date': $migrated_post_metadata[] = 'date'; break; case 'comments': $migrated_post_metadata[] = 'comments'; break; case 'category': if ( 'post' === $post_type ) { $migrated_post_metadata[] = $tax_slug; $theme_options[ $tax_slug ] = 'category'; $tax_counter = ++$tax_counter; $tax_slug = 'ast-dynamic-single-' . esc_attr( $post_type ) . '-taxonomy-' . $tax_counter; } break; case 'tag': if ( 'post' === $post_type ) { $migrated_post_metadata[] = $tax_slug; $theme_options[ $tax_slug ] = 'post_tag'; $tax_counter = ++$tax_counter; $tax_slug = 'ast-dynamic-single-' . esc_attr( $post_type ) . '-taxonomy-' . $tax_counter; } break; default: break; } } $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-metadata' ] = $migrated_post_metadata; } // Archive layout compatibilities. $archive_banner_layout = class_exists( 'WooCommerce' ) && 'product' === $post_type ? false : true; // Setting WooCommerce archive option disabled as WC already added their header content on archive. $theme_options[ 'ast-archive-' . esc_attr( $post_type ) . '-title' ] = $archive_banner_layout; // Single layout compatibilities. $single_banner_layout = class_exists( 'WooCommerce' ) && 'product' === $post_type ? false : true; // Setting WC single option disabled as there is no any header set from default WooCommerce. $theme_options[ 'ast-single-' . esc_attr( $post_type ) . '-title' ] = $single_banner_layout; // BG color support. $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-banner-image-type' ] = ! empty( $theme_options['archive-summary-box-bg-color'] ) ? 'custom' : 'none'; $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-banner-custom-bg' ] = $archive_summary_box_bg; // Archive title font support. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-title-font-family' ] = ! empty( $theme_options['font-family-archive-summary-title'] ) ? $theme_options['font-family-archive-summary-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-title-font-size' ] = $archive_title_font_size; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-title-font-weight' ] = ! empty( $theme_options['font-weight-archive-summary-title'] ) ? $theme_options['font-weight-archive-summary-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $archive_dynamic_line_height = ! empty( $theme_options['line-height-archive-summary-title'] ) ? $theme_options['line-height-archive-summary-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $archive_dynamic_text_transform = ! empty( $theme_options['text-transform-archive-summary-title'] ) ? $theme_options['text-transform-archive-summary-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-title-font-extras' ] = array( 'line-height' => $archive_dynamic_line_height, 'line-height-unit' => 'em', 'letter-spacing' => '', 'letter-spacing-unit' => 'px', 'text-transform' => $archive_dynamic_text_transform, 'text-decoration' => '', ); // Archive title colors support. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-banner-title-color' ] = ! empty( $theme_options['archive-summary-box-title-color'] ) ? $theme_options['archive-summary-box-title-color'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-banner-text-color' ] = ! empty( $theme_options['archive-summary-box-text-color'] ) ? $theme_options['archive-summary-box-text-color'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort // Single title colors support. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-banner-title-color' ] = ! empty( $theme_options['entry-title-color'] ) ? $theme_options['entry-title-color'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort // Single title font support. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-title-font-family' ] = ! empty( $theme_options['font-family-entry-title'] ) ? $theme_options['font-family-entry-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-title-font-size' ] = $single_title_font_size; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-title-font-weight' ] = ! empty( $theme_options['font-weight-entry-title'] ) ? $theme_options['font-weight-entry-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $single_dynamic_line_height = ! empty( $theme_options['line-height-entry-title'] ) ? $theme_options['line-height-entry-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $single_dynamic_text_transform = ! empty( $theme_options['text-transform-entry-title'] ) ? $theme_options['text-transform-entry-title'] : ''; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-title-font-extras' ] = array( 'line-height' => $single_dynamic_line_height, 'line-height-unit' => 'em', 'letter-spacing' => '', 'letter-spacing-unit' => 'px', 'text-transform' => $single_dynamic_text_transform, 'text-decoration' => '', ); } // Set page specific structure, as page only has featured image at top & title beneath to it, hardcoded writing it here. $theme_options['ast-dynamic-single-page-structure'] = array( 'ast-dynamic-single-page-image', 'ast-dynamic-single-page-title' ); // EDD content layout & sidebar layout migration in new dynamic option. $theme_options['archive-download-content-layout'] = isset( $theme_options['edd-archive-product-layout'] ) ? $theme_options['edd-archive-product-layout'] : 'default'; $theme_options['archive-download-sidebar-layout'] = isset( $theme_options['edd-sidebar-layout'] ) ? $theme_options['edd-sidebar-layout'] : 'no-sidebar'; $theme_options['single-download-content-layout'] = isset( $theme_options['edd-single-product-layout'] ) ? $theme_options['edd-single-product-layout'] : 'default'; $theme_options['single-download-sidebar-layout'] = isset( $theme_options['edd-single-product-sidebar-layout'] ) ? $theme_options['edd-single-product-sidebar-layout'] : 'default'; update_option( 'astra-settings', $theme_options ); } // Admin backward handling starts here. $admin_dashboard_settings = get_option( 'astra_admin_settings', array() ); if ( ! isset( $admin_dashboard_settings['theme-setup-admin-migrated'] ) ) { if ( ! isset( $admin_dashboard_settings['self_hosted_gfonts'] ) ) { $admin_dashboard_settings['self_hosted_gfonts'] = isset( $theme_options['load-google-fonts-locally'] ) ? $theme_options['load-google-fonts-locally'] : false; } if ( ! isset( $admin_dashboard_settings['preload_local_fonts'] ) ) { $admin_dashboard_settings['preload_local_fonts'] = isset( $theme_options['preload-local-fonts'] ) ? $theme_options['preload-local-fonts'] : false; } // Consider admin part from theme side migrated. $admin_dashboard_settings['theme-setup-admin-migrated'] = true; update_option( 'astra_admin_settings', $admin_dashboard_settings ); } // Check if existing user and disable smooth scroll-to-id. if ( ! isset( $theme_options['enable-scroll-to-id'] ) ) { $theme_options['enable-scroll-to-id'] = false; update_option( 'astra-settings', $theme_options ); } // Check if existing user and disable scroll to top if disabled from pro addons list. $scroll_to_top_visibility = false; /** @psalm-suppress UndefinedClass */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( defined( 'ASTRA_EXT_VER' ) && Astra_Ext_Extension::is_active( 'scroll-to-top' ) ) { /** @psalm-suppress UndefinedClass */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $scroll_to_top_visibility = true; } if ( ! isset( $theme_options['scroll-to-top-enable'] ) ) { $theme_options['scroll-to-top-enable'] = $scroll_to_top_visibility; update_option( 'astra-settings', $theme_options ); } // Default colors & typography flag. if ( ! isset( $theme_options['update-default-color-typo'] ) ) { $theme_options['update-default-color-typo'] = false; update_option( 'astra-settings', $theme_options ); } // Block editor experience improvements compatibility flag. if ( ! isset( $theme_options['v4-block-editor-compat'] ) ) { $theme_options['v4-block-editor-compat'] = false; update_option( 'astra-settings', $theme_options ); } } /** * 4.0.2 backward handling part. * * 1. Read Time option backwards handling for old users. * * @since 4.0.2 * @return void */ function astra_theme_background_updater_4_0_2() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-0-2-update-migration'] ) && isset( $theme_options['blog-single-meta'] ) && in_array( 'read-time', $theme_options['blog-single-meta'] ) ) { if ( isset( $theme_options['ast-dynamic-single-post-metadata'] ) && ! in_array( 'read-time', $theme_options['ast-dynamic-single-post-metadata'] ) ) { $theme_options['ast-dynamic-single-post-metadata'][] = 'read-time'; $theme_options['v4-0-2-update-migration'] = true; update_option( 'astra-settings', $theme_options ); } } } /** * Handle backward compatibility on version 4.1.0 * * @since 4.1.0 * @return void */ function astra_theme_background_updater_4_1_0() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-1-0-update-migration'] ) ) { $theme_options['v4-1-0-update-migration'] = true; $current_payment_list = array(); $old_payment_list = isset( $theme_options['single-product-payment-list']['items'] ) ? $theme_options['single-product-payment-list']['items'] : array(); $visa_payment = isset( $theme_options['single-product-payment-visa'] ) ? $theme_options['single-product-payment-visa'] : ''; $mastercard_payment = isset( $theme_options['single-product-payment-mastercard'] ) ? $theme_options['single-product-payment-mastercard'] : ''; $discover_payment = isset( $theme_options['single-product-payment-discover'] ) ? $theme_options['single-product-payment-discover'] : ''; $paypal_payment = isset( $theme_options['single-product-payment-paypal'] ) ? $theme_options['single-product-payment-paypal'] : ''; $apple_pay_payment = isset( $theme_options['single-product-payment-apple-pay'] ) ? $theme_options['single-product-payment-apple-pay'] : ''; false !== $visa_payment ? array_push( $current_payment_list, array( 'id' => 'item-100', 'enabled' => true, 'source' => 'icon', 'icon' => 'cc-visa', 'image' => '', 'label' => __( 'Visa', 'astra' ), ) ) : ''; false !== $mastercard_payment ? array_push( $current_payment_list, array( 'id' => 'item-101', 'enabled' => true, 'source' => 'icon', 'icon' => 'cc-mastercard', 'image' => '', 'label' => __( 'Mastercard', 'astra' ), ) ) : ''; false !== $mastercard_payment ? array_push( $current_payment_list, array( 'id' => 'item-102', 'enabled' => true, 'source' => 'icon', 'icon' => 'cc-amex', 'image' => '', 'label' => __( 'Amex', 'astra' ), ) ) : ''; false !== $discover_payment ? array_push( $current_payment_list, array( 'id' => 'item-103', 'enabled' => true, 'source' => 'icon', 'icon' => 'cc-discover', 'image' => '', 'label' => __( 'Discover', 'astra' ), ) ) : ''; $paypal_payment ? array_push( $current_payment_list, array( 'id' => 'item-104', 'enabled' => true, 'source' => 'icon', 'icon' => 'cc-paypal', 'image' => '', 'label' => __( 'Paypal', 'astra' ), ) ) : ''; $apple_pay_payment ? array_push( $current_payment_list, array( 'id' => 'item-105', 'enabled' => true, 'source' => 'icon', 'icon' => 'cc-apple-pay', 'image' => '', 'label' => __( 'Apple Pay', 'astra' ), ) ) : ''; if ( $current_payment_list ) { $theme_options['single-product-payment-list'] = array( 'items' => array_merge( $current_payment_list, $old_payment_list ), ); update_option( 'astra-settings', $theme_options ); } if ( ! isset( $theme_options['woo_support_global_settings'] ) ) { $theme_options['woo_support_global_settings'] = true; update_option( 'astra-settings', $theme_options ); } if ( isset( $theme_options['theme-dynamic-customizer-support'] ) ) { $post_types = Astra_Posts_Structure_Loader::get_supported_post_types(); foreach ( $post_types as $post_type ) { $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-title-font-extras' ]['text-transform'] = ''; } update_option( 'astra-settings', $theme_options ); } } } /** * 4.1.4 backward handling cases. * * 1. Migrating users to combined color overlay option to new dedicated overlay options. * * @since 4.1.4 * @return void */ function astra_theme_background_updater_4_1_4() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-1-4-update-migration'] ) ) { $ast_bg_control_options = array( 'off-canvas-background', 'footer-adv-bg-obj', 'footer-bg-obj', ); foreach ( $ast_bg_control_options as $bg_option ) { if ( isset( $theme_options[ $bg_option ] ) && ! isset( $theme_options[ $bg_option ]['overlay-type'] ) ) { $bg_type = isset( $theme_options[ $bg_option ]['background-type'] ) ? $theme_options[ $bg_option ]['background-type'] : ''; $theme_options[ $bg_option ]['overlay-type'] = 'none'; $theme_options[ $bg_option ]['overlay-color'] = ''; $theme_options[ $bg_option ]['overlay-opacity'] = ''; $theme_options[ $bg_option ]['overlay-gradient'] = ''; if ( 'image' === $bg_type ) { $bg_img = isset( $theme_options[ $bg_option ]['background-image'] ) ? $theme_options[ $bg_option ]['background-image'] : ''; $bg_color = isset( $theme_options[ $bg_option ]['background-color'] ) ? $theme_options[ $bg_option ]['background-color'] : ''; if ( '' !== $bg_img && '' !== $bg_color && ( ! is_numeric( strpos( $bg_color, 'linear-gradient' ) ) && ! is_numeric( strpos( $bg_color, 'radial-gradient' ) ) ) ) { $theme_options[ $bg_option ]['overlay-type'] = 'classic'; $theme_options[ $bg_option ]['overlay-color'] = $bg_color; $theme_options[ $bg_option ]['overlay-opacity'] = ''; $theme_options[ $bg_option ]['overlay-gradient'] = ''; } } } } $ast_resp_bg_control_options = array( 'hba-footer-bg-obj-responsive', 'hbb-footer-bg-obj-responsive', 'footer-bg-obj-responsive', 'footer-menu-bg-obj-responsive', 'hb-footer-bg-obj-responsive', 'hba-header-bg-obj-responsive', 'hbb-header-bg-obj-responsive', 'hb-header-bg-obj-responsive', 'header-mobile-menu-bg-obj-responsive', 'site-layout-outside-bg-obj-responsive', 'content-bg-obj-responsive', ); $post_types = Astra_Posts_Structure_Loader::get_supported_post_types(); foreach ( $post_types as $index => $post_type ) { $ast_resp_bg_control_options[] = 'ast-dynamic-archive-' . esc_attr( $post_type ) . '-banner-custom-bg'; $ast_resp_bg_control_options[] = 'ast-dynamic-single-' . esc_attr( $post_type ) . '-banner-background'; } $component_limit = defined( 'ASTRA_EXT_VER' ) ? Astra_Builder_Helper::$component_limit : Astra_Builder_Helper::$num_of_header_menu; for ( $index = 1; $index <= $component_limit; $index++ ) { $_prefix = 'menu' . $index; $ast_resp_bg_control_options[] = 'header-' . $_prefix . '-bg-obj-responsive'; } foreach ( $ast_resp_bg_control_options as $resp_bg_option ) { // Desktop version. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( isset( $theme_options[ $resp_bg_option ]['desktop'] ) && is_array( $theme_options[ $resp_bg_option ]['desktop'] ) && ! isset( $theme_options[ $resp_bg_option ]['desktop']['overlay-type'] ) ) { // @codingStandardsIgnoreStart $desk_bg_type = isset( $theme_options[ $resp_bg_option ]['desktop']['background-type'] ) ? $theme_options[ $resp_bg_option ]['desktop']['background-type'] : ''; // @codingStandardsIgnoreEnd $theme_options[ $resp_bg_option ]['desktop']['overlay-type'] = ''; $theme_options[ $resp_bg_option ]['desktop']['overlay-color'] = ''; $theme_options[ $resp_bg_option ]['desktop']['overlay-opacity'] = ''; $theme_options[ $resp_bg_option ]['desktop']['overlay-gradient'] = ''; if ( 'image' === $desk_bg_type ) { $bg_img = isset( $theme_options[ $resp_bg_option ]['desktop']['background-image'] ) ? $theme_options[ $resp_bg_option ]['desktop']['background-image'] : ''; $bg_color = isset( $theme_options[ $resp_bg_option ]['desktop']['background-color'] ) ? $theme_options[ $resp_bg_option ]['desktop']['background-color'] : ''; if ( '' !== $bg_img && '' !== $bg_color && ( ! is_numeric( strpos( $bg_color, 'linear-gradient' ) ) && ! is_numeric( strpos( $bg_color, 'radial-gradient' ) ) ) ) { $theme_options[ $resp_bg_option ]['desktop']['overlay-type'] = 'classic'; $theme_options[ $resp_bg_option ]['desktop']['overlay-color'] = $bg_color; $theme_options[ $resp_bg_option ]['desktop']['overlay-opacity'] = ''; $theme_options[ $resp_bg_option ]['desktop']['overlay-gradient'] = ''; } } } // Tablet version. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( isset( $theme_options[ $resp_bg_option ]['tablet'] ) && is_array( $theme_options[ $resp_bg_option ]['tablet'] ) && ! isset( $theme_options[ $resp_bg_option ]['tablet']['overlay-type'] ) ) { // @codingStandardsIgnoreStart $tablet_bg_type = isset( $theme_options[ $resp_bg_option ]['tablet']['background-type'] ) ? $theme_options[ $resp_bg_option ]['tablet']['background-type'] : ''; // @codingStandardsIgnoreEnd $theme_options[ $resp_bg_option ]['tablet']['overlay-type'] = ''; $theme_options[ $resp_bg_option ]['tablet']['overlay-color'] = ''; $theme_options[ $resp_bg_option ]['tablet']['overlay-opacity'] = ''; $theme_options[ $resp_bg_option ]['tablet']['overlay-gradient'] = ''; if ( 'image' === $tablet_bg_type ) { $bg_img = isset( $theme_options[ $resp_bg_option ]['tablet']['background-image'] ) ? $theme_options[ $resp_bg_option ]['tablet']['background-image'] : ''; $bg_color = isset( $theme_options[ $resp_bg_option ]['tablet']['background-color'] ) ? $theme_options[ $resp_bg_option ]['tablet']['background-color'] : ''; if ( '' !== $bg_img && '' !== $bg_color && ( ! is_numeric( strpos( $bg_color, 'linear-gradient' ) ) && ! is_numeric( strpos( $bg_color, 'radial-gradient' ) ) ) ) { $theme_options[ $resp_bg_option ]['tablet']['overlay-type'] = 'classic'; $theme_options[ $resp_bg_option ]['tablet']['overlay-color'] = $bg_color; $theme_options[ $resp_bg_option ]['tablet']['overlay-opacity'] = ''; $theme_options[ $resp_bg_option ]['tablet']['overlay-gradient'] = ''; } } } // Mobile version. /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( isset( $theme_options[ $resp_bg_option ]['mobile'] ) && is_array( $theme_options[ $resp_bg_option ]['mobile'] ) && ! isset( $theme_options[ $resp_bg_option ]['mobile']['overlay-type'] ) ) { // @codingStandardsIgnoreStart $mobile_bg_type = isset( $theme_options[ $resp_bg_option ]['mobile']['background-type'] ) ? $theme_options[ $resp_bg_option ]['mobile']['background-type'] : ''; // @codingStandardsIgnoreEnd $theme_options[ $resp_bg_option ]['mobile']['overlay-type'] = ''; $theme_options[ $resp_bg_option ]['mobile']['overlay-color'] = ''; $theme_options[ $resp_bg_option ]['mobile']['overlay-opacity'] = ''; $theme_options[ $resp_bg_option ]['mobile']['overlay-gradient'] = ''; if ( 'image' === $mobile_bg_type ) { $bg_img = isset( $theme_options[ $resp_bg_option ]['mobile']['background-image'] ) ? $theme_options[ $resp_bg_option ]['mobile']['background-image'] : ''; $bg_color = isset( $theme_options[ $resp_bg_option ]['mobile']['background-color'] ) ? $theme_options[ $resp_bg_option ]['mobile']['background-color'] : ''; if ( '' !== $bg_img && '' !== $bg_color && ( ! is_numeric( strpos( $bg_color, 'linear-gradient' ) ) && ! is_numeric( strpos( $bg_color, 'radial-gradient' ) ) ) ) { $theme_options[ $resp_bg_option ]['mobile']['overlay-type'] = 'classic'; $theme_options[ $resp_bg_option ]['mobile']['overlay-color'] = $bg_color; $theme_options[ $resp_bg_option ]['mobile']['overlay-opacity'] = ''; $theme_options[ $resp_bg_option ]['mobile']['overlay-gradient'] = ''; } } } } $theme_options['v4-1-4-update-migration'] = true; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility on version 4.1.6 * * @since 4.1.6 * @return void */ function astra_theme_background_updater_4_1_6() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['list-block-vertical-spacing'] ) ) { $theme_options['list-block-vertical-spacing'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Set flag to avoid direct reflections on live site & to maintain backward compatibility for existing users. * * @since 4.1.7 * @return void */ function astra_theme_background_updater_4_1_7() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['add-hr-styling-css'] ) ) { $theme_options['add-hr-styling-css'] = false; update_option( 'astra-settings', $theme_options ); } if ( ! isset( $theme_options['astra-site-svg-logo-equal-height'] ) ) { $theme_options['astra-site-svg-logo-equal-height'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Migrating users to new container layout options * * @since 4.2.0 * @return void */ function astra_theme_background_updater_4_2_0() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-2-0-update-migration'] ) ) { $post_types = Astra_Posts_Structure_Loader::get_supported_post_types(); $theme_options = get_option( 'astra-settings' ); $blog_types = array( 'single', 'archive' ); $third_party_layouts = array( 'woocommerce', 'edd', 'lifterlms', 'lifterlms-course-lesson', 'learndash' ); // Global. if ( isset( $theme_options['site-content-layout'] ) ) { $theme_options = astra_apply_layout_migration( 'site-content-layout', 'ast-site-content-layout', 'site-content-style', 'site-sidebar-style', $theme_options ); } // Single, archive. foreach ( $blog_types as $blog_type ) { foreach ( $post_types as $post_type ) { $old_layout = $blog_type . '-' . esc_attr( $post_type ) . '-content-layout'; $new_layout = $blog_type . '-' . esc_attr( $post_type ) . '-ast-content-layout'; $content_style = $blog_type . '-' . esc_attr( $post_type ) . '-content-style'; $sidebar_style = $blog_type . '-' . esc_attr( $post_type ) . '-sidebar-style'; if ( isset( $theme_options[ $old_layout ] ) ) { $theme_options = astra_apply_layout_migration( $old_layout, $new_layout, $content_style, $sidebar_style, $theme_options ); } } } // Third party existing layout migrations to new layout options. foreach ( $third_party_layouts as $layout ) { $old_layout = $layout . '-content-layout'; $new_layout = $layout . '-ast-content-layout'; $content_style = $layout . '-content-style'; $sidebar_style = $layout . '-sidebar-style'; if ( isset( $theme_options[ $old_layout ] ) ) { if ( 'lifterlms' === $layout ) { // Lifterlms course/lesson sidebar style migration case. $theme_options = astra_apply_layout_migration( $old_layout, $new_layout, $content_style, 'lifterlms-course-lesson-sidebar-style', $theme_options ); } $theme_options = astra_apply_layout_migration( $old_layout, $new_layout, $content_style, $sidebar_style, $theme_options ); } } if ( ! isset( $theme_options['fullwidth_sidebar_support'] ) ) { $theme_options['fullwidth_sidebar_support'] = false; } $theme_options['v4-2-0-update-migration'] = true; update_option( 'astra-settings', $theme_options ); } } /** * Handle migration from old to new layouts. * * Migration cases for old users, old layouts -> new layouts. * * @since 4.2.0 * @param mixed $old_layout old_layout. * @param mixed $new_layout new_layout. * @param mixed $content_style content_style. * @param mixed $sidebar_style sidebar_style. * @param array $theme_options theme_options. * @return array $theme_options The updated theme options. */ function astra_apply_layout_migration( $old_layout, $new_layout, $content_style, $sidebar_style, $theme_options ) { switch ( astra_get_option( $old_layout ) ) { case 'boxed-container': $theme_options[ $new_layout ] = 'normal-width-container'; $theme_options[ $content_style ] = 'boxed'; $theme_options[ $sidebar_style ] = 'boxed'; break; case 'content-boxed-container': $theme_options[ $new_layout ] = 'normal-width-container'; $theme_options[ $content_style ] = 'boxed'; $theme_options[ $sidebar_style ] = 'unboxed'; break; case 'plain-container': $theme_options[ $new_layout ] = 'normal-width-container'; $theme_options[ $content_style ] = 'unboxed'; $theme_options[ $sidebar_style ] = 'unboxed'; break; case 'page-builder': $theme_options[ $new_layout ] = 'full-width-container'; $theme_options[ $content_style ] = 'unboxed'; $theme_options[ $sidebar_style ] = 'unboxed'; break; case 'narrow-container': $theme_options[ $new_layout ] = 'narrow-width-container'; $theme_options[ $content_style ] = 'unboxed'; $theme_options[ $sidebar_style ] = 'unboxed'; break; default: $theme_options[ $new_layout ] = 'default'; $theme_options[ $content_style ] = 'default'; $theme_options[ $sidebar_style ] = 'default'; break; } return $theme_options; } /** * Handle backward compatibility on version 4.2.2 * * @since 4.2.2 * @return void */ function astra_theme_background_updater_4_2_2() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-2-2-core-form-btns-styling'] ) ) { $theme_options['v4-2-2-core-form-btns-styling'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility on version 4.6.0 * * @since 4.4.0 * @return void */ function astra_theme_background_updater_4_4_0() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-4-0-backward-option'] ) ) { $theme_options['v4-4-0-backward-option'] = false; // Migrate primary button outline styles to secondary buttons. if ( isset( $theme_options['font-family-button'] ) ) { $theme_options['secondary-font-family-button'] = $theme_options['font-family-button']; } if ( isset( $theme_options['font-size-button'] ) ) { $theme_options['secondary-font-size-button'] = $theme_options['font-size-button']; } if ( isset( $theme_options['font-weight-button'] ) ) { $theme_options['secondary-font-weight-button'] = $theme_options['font-weight-button']; } if ( isset( $theme_options['font-extras-button'] ) ) { $theme_options['secondary-font-extras-button'] = $theme_options['font-extras-button']; } if ( isset( $theme_options['button-bg-color'] ) ) { $theme_options['secondary-button-bg-color'] = $theme_options['button-bg-color']; } if ( isset( $theme_options['button-bg-h-color'] ) ) { $theme_options['secondary-button-bg-h-color'] = $theme_options['button-bg-h-color']; } if ( isset( $theme_options['theme-button-border-group-border-color'] ) ) { $theme_options['secondary-theme-button-border-group-border-color'] = $theme_options['theme-button-border-group-border-color']; } if ( isset( $theme_options['theme-button-border-group-border-h-color'] ) ) { $theme_options['secondary-theme-button-border-group-border-h-color'] = $theme_options['theme-button-border-group-border-h-color']; } if ( isset( $theme_options['button-radius-fields'] ) ) { $theme_options['secondary-button-radius-fields'] = $theme_options['button-radius-fields']; } // Single - Article Featured Image visibility migration. $post_types = Astra_Posts_Structure_Loader::get_supported_post_types(); foreach ( $post_types as $post_type ) { $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-article-featured-image-position-layout-1' ] = 'none'; $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-article-featured-image-position-layout-2' ] = 'none'; $theme_options[ 'ast-dynamic-single-' . esc_attr( $post_type ) . '-article-featured-image-ratio-type' ] = 'default'; } update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility on version 4.5.0. * * @since 4.5.0 * @return void */ function astra_theme_background_updater_4_5_0() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-5-0-backward-option'] ) ) { $theme_options['v4-5-0-backward-option'] = false; $palette_options = get_option( 'astra-color-palettes', Astra_Global_Palette::get_default_color_palette() ); if ( ! isset( $palette_options['presets'] ) ) { $palette_options['presets'] = astra_get_palette_presets(); update_option( 'astra-color-palettes', $palette_options ); } update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility on version 4.5.2. * * @since 4.5.2 * @return void */ function astra_theme_background_updater_4_5_2() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['scndry-btn-default-padding'] ) ) { $theme_options['scndry-btn-default-padding'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility on version 4.6.0 * * @since 4.6.0 * @return void */ function astra_theme_background_updater_4_6_0() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-6-0-backward-option'] ) ) { $theme_options['v4-6-0-backward-option'] = false; /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $blog_post_structure = isset( $theme_options['blog-post-structure'] ) ? $theme_options['blog-post-structure'] : array( 'image', 'title-meta' ); /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $migrated_post_structure = array(); if ( ! empty( $blog_post_structure ) ) { /** @psalm-suppress PossiblyInvalidIterator */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort foreach ( $blog_post_structure as $key ) { /** @psalm-suppress PossiblyInvalidIterator */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( 'title-meta' === $key ) { $migrated_post_structure[] = 'title'; $migrated_post_structure[] = 'title-meta'; } if ( 'image' === $key ) { $migrated_post_structure[] = 'image'; } } $migrated_post_structure[] = 'excerpt'; $migrated_post_structure[] = 'read-more'; $theme_options['blog-post-structure'] = $migrated_post_structure; } if ( defined( 'ASTRA_EXT_VER' ) ) { $theme_options['ast-sub-section-author-box-border-width'] = isset( $theme_options['author-box-border-width'] ) ? $theme_options['author-box-border-width'] : array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ); $theme_options['ast-sub-section-author-box-border-radius'] = isset( $theme_options['author-box-border-radius'] ) ? $theme_options['author-box-border-radius'] : array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ); $theme_options['ast-sub-section-author-box-border-color'] = isset( $theme_options['author-box-border-color'] ) ? $theme_options['author-box-border-color'] : ''; if ( isset( $theme_options['single-post-inside-spacing'] ) ) { $theme_options['ast-sub-section-author-box-padding'] = $theme_options['single-post-inside-spacing']; } if ( isset( $theme_options['font-family-post-meta'] ) ) { $theme_options['font-family-post-read-more'] = $theme_options['font-family-post-meta']; } if ( isset( $theme_options['font-extras-post-meta'] ) ) { $theme_options['font-extras-post-read-more'] = $theme_options['font-extras-post-meta']; } } if ( isset( $theme_options['single-post-inside-spacing'] ) ) { $theme_options['ast-sub-section-related-posts-padding'] = $theme_options['single-post-inside-spacing']; } $theme_options['single-content-images-shadow'] = false; $theme_options['ast-font-style-update'] = false; update_option( 'astra-settings', $theme_options ); } $docs_legacy_data = get_option( 'astra_docs_data', array() ); if ( ! empty( $docs_legacy_data ) ) { delete_option( 'astra_docs_data' ); } } /** * Handle backward compatibility on version 4.6.2. * * @since 4.6.2 * @return void */ function astra_theme_background_updater_4_6_2() { $theme_options = get_option( 'astra-settings', array() ); // Unset "featured image" for pages structure. if ( ! isset( $theme_options['v4-6-2-backward-option'] ) ) { $theme_options['v4-6-2-backward-option'] = false; $page_banner_layout = isset( $theme_options['ast-dynamic-single-page-layout'] ) ? $theme_options['ast-dynamic-single-page-layout'] : 'layout-1'; $page_structure = isset( $theme_options['ast-dynamic-single-page-structure'] ) ? $theme_options['ast-dynamic-single-page-structure'] : array( 'ast-dynamic-single-page-image', 'ast-dynamic-single-page-title' ); $layout_1_image_position = isset( $theme_options['ast-dynamic-single-page-article-featured-image-position-layout-1'] ) ? $theme_options['ast-dynamic-single-page-article-featured-image-position-layout-1'] : 'behind'; $migrated_page_structure = array(); if ( 'layout-1' === $page_banner_layout && 'none' === $layout_1_image_position && ! empty( $page_structure ) ) { foreach ( $page_structure as $key ) { if ( 'ast-dynamic-single-page-image' !== $key ) { $migrated_page_structure[] = $key; } } $theme_options['ast-dynamic-single-page-structure'] = $migrated_page_structure; } update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility on version 4.6.4. * * @since 4.6.4 * @return void */ function astra_theme_background_updater_4_6_4() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['btn-stylings-upgrade'] ) ) { $theme_options['btn-stylings-upgrade'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for Elementor Pro heading's margin. * * @since 4.6.5 * @return void */ function astra_theme_background_updater_4_6_5() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['elementor-headings-style'] ) ) { $theme_options['elementor-headings-style'] = defined( 'ELEMENTOR_PRO_VERSION' ) ? true : false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for Elementor Loop block post div container padding. * * @since 4.6.6 * @return void */ function astra_theme_background_updater_4_6_6() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['elementor-container-padding-style'] ) ) { $theme_options['elementor-container-padding-style'] = defined( 'ELEMENTOR_PRO_VERSION' ) ? true : false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for Starter template library preview line height cases. * * @since 4.6.11 * @return void */ function astra_theme_background_updater_4_6_11() { $theme_options = get_option( 'astra-settings', array() ); if ( isset( $theme_options['global-headings-line-height-update'] ) ) { return; } $headers_fonts = array( 'h1' => '1.4', 'h2' => '1.3', 'h3' => '1.3', 'h4' => '1.2', 'h5' => '1.2', 'h6' => '1.25', ); foreach ( $headers_fonts as $header_tag => $header_font_value ) { if ( empty( $theme_options[ 'font-extras-' . $header_tag ]['line-height'] ) ) { $theme_options[ 'font-extras-' . $header_tag ]['line-height'] = $header_font_value; if ( empty( $theme_options[ 'font-extras-' . $header_tag ]['line-height-unit'] ) ) { $theme_options[ 'font-extras-' . $header_tag ]['line-height-unit'] = 'em'; } } } $theme_options['global-headings-line-height-update'] = true; update_option( 'astra-settings', $theme_options ); } /** * Handle backward compatibility for heading `clear:both` css in single posts and pages. * * @since 4.6.12 * @return void */ function astra_theme_background_updater_4_6_12() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['single_posts_pages_heading_clear_none'] ) ) { $theme_options['single_posts_pages_heading_clear_none'] = false; update_option( 'astra-settings', $theme_options ); } if ( ! isset( $theme_options['elementor-btn-styling'] ) ) { $theme_options['elementor-btn-styling'] = defined( 'ELEMENTOR_VERSION' ) ? true : false; update_option( 'astra-settings', $theme_options ); } if ( ! isset( $theme_options['remove_single_posts_navigation_mobile_device_padding'] ) ) { $theme_options['remove_single_posts_navigation_mobile_device_padding'] = true; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for following pointers. * * 1. unit less line-height support. * 2. H5 font size case. * * @since 4.6.14 * @return void */ function astra_theme_background_updater_4_6_14() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['enable-4-6-14-compatibility'] ) ) { $theme_options['enable-4-6-14-compatibility'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for following cases. * * 1. Making edd default option enable by default. * 2. Handle backward compatibility for Heading font size fix. * * @since 4.7.0 * @return void */ function astra_theme_background_updater_4_7_0() { $theme_options = get_option( 'astra-settings', array() ); if ( class_exists( 'Easy_Digital_Downloads' ) && ! isset( $theme_options['can-update-edd-featured-image-default'] ) ) { $theme_options['can-update-edd-featured-image-default'] = false; update_option( 'astra-settings', $theme_options ); } if ( ! isset( $theme_options['heading-widget-font-size'] ) ) { $theme_options['heading-widget-font-size'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for version 4.7.1 * * @since 4.7.1 * @return void */ function astra_theme_background_updater_4_7_1() { $theme_options = get_option( 'astra-settings', array() ); // Setting same background color for above and below transparent headers as on transparent primary header. if ( isset( $theme_options['transparent-header-bg-color-responsive'] ) ) { if ( ! isset( $theme_options['hba-transparent-header-bg-color-responsive'] ) ) { $theme_options['hba-transparent-header-bg-color-responsive'] = $theme_options['transparent-header-bg-color-responsive']; } if ( ! isset( $theme_options['hbb-transparent-header-bg-color-responsive'] ) ) { $theme_options['hbb-transparent-header-bg-color-responsive'] = $theme_options['transparent-header-bg-color-responsive']; } update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility Spectra Heading max-width with Astra when fullwidth layout is selected. * * @since 4.8.0 * @return void */ function astra_theme_background_updater_4_8_0() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['enable-4-8-0-compatibility'] ) ) { $theme_options['enable-4-8-0-compatibility'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility Single post outside spacing issue. * * @since 4.8.2 * @return void */ function astra_theme_background_updater_4_8_2() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-8-2-backward-option'] ) ) { $theme_options['v4-8-2-backward-option'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for Spectra container margin left and right. * Handle backward compatibility for Heading font size px to em conversion cases. * * @since 4.8.4 * @return void */ function astra_theme_background_updater_4_8_4() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['enable-4-8-4-compatibility'] ) ) { $theme_options['enable-4-8-4-compatibility'] = false; update_option( 'astra-settings', $theme_options ); } if ( ! isset( $theme_options['astra-heading-font-size-compatibility'] ) ) { $theme_options['astra-heading-font-size-compatibility'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Set key to show NPS survey popup immediately for old user. * * @since 4.8.7 * @return void */ function astra_theme_background_updater_4_8_7() { // Bail early if the starter template is being imported. if ( get_option( 'astra_sites_import_started' ) === 'yes' ) { return; } update_option( 'astra_nps_show', true ); } /** * Handle backward compatibility on version 4.8.9. * 1. Reorganizing color palettes. * * @since 4.8.9 * @return void */ function astra_theme_background_updater_4_8_9() { // Bail early if the starter template is being imported. if ( get_option( 'astra_sites_import_started' ) === 'yes' || astra_get_option( 'new-color-labels' ) ) { astra_update_option( 'new-color-labels', true ); } $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['enable-4-8-9-compatibility'] ) ) { $theme_options['enable-4-8-9-compatibility'] = false; update_option( 'astra-settings', $theme_options ); } // Enable off canvas move body option for existing users. if ( ! isset( $theme_options['off-canvas-move-body'] ) ) { $theme_options['off-canvas-move-body'] = true; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility on version 4.8.10. * * @since 4.8.10 * @return void */ function astra_theme_background_updater_4_8_10() { $theme_options = get_option( 'astra-settings', array() ); /** * Enable star rating compatibility for existing users, excluding template import scenarios. */ if ( get_option( 'astra_sites_import_started' ) !== 'yes' ) { $theme_options['star-rating-comp'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Handle backward compatibility for dark palette. * Dark palette backward compatibility for some cases default option . * * @since 4.9.0 * @return void */ function astra_theme_background_updater_4_9_0() { $theme_options = get_option( 'astra-settings', array() ); if ( ! isset( $theme_options['v4-9-0-backward-option'] ) ) { $theme_options['v4-9-0-backward-option'] = false; update_option( 'astra-settings', $theme_options ); } } /** * Background updater function for theme v4.10.0 * * @since 4.10.0 * @return void */ function astra_theme_background_updater_4_10_0() { // Retrieve the installed time and optin status of BSF Analytics and update it as per product specific key. $analytics_options = array( 'bsf_analytics_installed_time' => 'astra_analytics_installed_time', 'bsf_analytics_optin' => 'astra_analytics_optin', ); foreach ( $analytics_options as $source => $target ) { $status = get_site_option( $source ); if ( ! get_site_option( $target ) && $status ) { update_option( $target, $status ); } } } Please visit the plugin settings page and add your purchase code to activate the plugin