/** * Add services macros data to process it in carousel shortcode * * @since 1.0.0 * * @param array $postdata default data * @param array $post_id processed post ID * @param array $atts shortcode attributes */ public function add_carousel_data($postdata, $post_id, $atts) { require_once CHERRY_SERVICES_DIR . 'public/includes/class-cherry-services-template-callbacks.php'; $callbacks = new Cherry_Services_Template_Callbacks($atts); $postdata['icon'] = $callbacks->get_icon(); $postdata['features'] = $callbacks->get_features(); $postdata['price'] = $callbacks->get_price(); $postdata['order'] = $callbacks->get_order_button(); return $postdata; }
/** * Get order button * @since 1.0.0 */ public function get_order_button($class = 'cherry-btn cherry-btn-primary') { global $post; $format = '<a href="%2$s" class="%3$s">%1$s</a>'; $text = !empty($this->atts['order_button_text']) ? $this->atts['order_button_text'] : __('Order', 'cherry-services'); $class = esc_attr($class); $meta = Cherry_Services_Template_Callbacks::setup_meta(); $url = !empty($meta['order-url']) ? esc_url($meta['order-url']) : get_permalink($post->ID); return sprintf($format, $text, $url, $class); }