0, // 0 as default if id in $atts is empty default ], $atts, 'apbox_product_box' ); // Assign shortcode id to product_id $product_id = absint( $atts['id'] ); // Get post for product id if ( ! $product_id || get_post_type( $product_id ) !== 'apbox_product' ) { return '
Invalid product ID.
'; } $title = get_the_title( $product_id ); $description_raw = (string) get_post_field( 'post_content', $product_id ); $description_lines = preg_split( "/\r\n|\r|\n/", $description_raw ); $description_items = []; if ( ! empty( $description_lines ) ) { foreach ( $description_lines as $description_line ) { $description_line = trim( $description_line ); if ( '' === $description_line ) { continue; } $description_items[] = do_shortcode( $description_line ); } } $price = get_post_meta( $product_id, '_apbox_price', true ); $affiliate_url = get_post_meta( $product_id, '_apbox_affiliate_link', true ); $rating = (int) get_post_meta( $product_id, '_apbox_rating', true ); $font_size = get_option( 'apbox_font_size', '16px' ); $button_color = get_option( 'apbox_button_color', '#ff6600' ); $button_text = get_option( 'apbox_button_text', 'Buy Now' ); $heading_level = get_option( 'apbox_heading_level', 'h2' ); $heading_level = APBOX_Settings::sanitize_heading_level( $heading_level ); // Fallback for empty value if ( '' === trim( $button_text ) ) { $button_text = __( 'Buy Now', 'affiliate-product-boxes' ); } // Get currency from settings $currency = get_option( 'apbox_currency', 'USD' ); $currencies = apbox_Settings::get_currencies(); // Try to extract symbol from the label $symbol = $currency; if ( isset( $currencies[ $currency ] ) ) { // The label looks like "Euro (€)" → extract the part in parentheses if ( preg_match( '/\((.*?)\)/', $currencies[ $currency ], $matches ) ) { $symbol = $matches[1]; } } $image_url = get_the_post_thumbnail_url( $product_id, 'medium' ); if ( ! $image_url ) { $image_url = plugin_dir_url( APBOX_PLUGIN_FILE ) . 'assets/images/default-product.jpg'; // Optional fallback } ob_start(); ?>
%2$s', esc_attr( $heading_level ), esc_html( $title ) ); ?>

(/5)

<?php echo esc_attr( $title ); ?>