| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPFunnels Shortcode |
| 4 |
* |
| 5 |
* @package WPFunnels\Shortcodes |
| 6 |
*/ |
| 7 |
namespace WPFunnels\Shortcodes; |
| 8 |
|
| 9 |
|
| 10 |
use WPFunnels\Data_Store\Wpfnl_Steps_Store_Data; |
| 11 |
use WPFunnels\Traits\SingletonTrait; |
| 12 |
use WPFunnels\Wpfnl_functions; |
| 13 |
use WPFunnels\Shortcodes\Wpfnl_Shortcode_Order_details; |
| 14 |
use WPFunnels\Shortcodes\Wpfnl_Shortcode_NextStepButton; |
| 15 |
use WPFunnels\Shortcodes\Wpfnl_Shortcode_Checkout; |
| 16 |
use WPFunnels\Shortcodes\WC_Shortcode_Optin; |
| 17 |
|
| 18 |
|
| 19 |
/** |
| 20 |
* Class Wpfnl_Shortcodes |
| 21 |
* |
| 22 |
* @package WPFunnels\Shortcodes |
| 23 |
*/ |
| 24 |
class Wpfnl_Shortcodes { |
| 25 |
|
| 26 |
use SingletonTrait; |
| 27 |
|
| 28 |
|
| 29 |
public static function init() { |
| 30 |
$shortcodes = array( |
| 31 |
'wpfunnels_order_details' => __CLASS__ . '::render_order_details', |
| 32 |
'wpf_next_step_button' => __CLASS__ . '::render_next_step_button', |
| 33 |
'wpf_checkout' => __CLASS__ . '::render_checkout', |
| 34 |
'wpf_optin_form' => __CLASS__ . '::render_optin_form', |
| 35 |
); |
| 36 |
|
| 37 |
foreach ( $shortcodes as $shortcode => $function ) { |
| 38 |
add_shortcode( $shortcode, $function ); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
public function __construct() { |
| 43 |
add_action( 'wp_enqueue_scripts', array( $this, 'thankyou_scripts' ), 21 ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Render order details markup |
| 48 |
* |
| 49 |
* @return string |
| 50 |
* |
| 51 |
* @since 2.0.3 |
| 52 |
*/ |
| 53 |
public static function render_order_details( $atts ) { |
| 54 |
$shortcode = new Wpfnl_Shortcode_Order_details( (array) $atts ); |
| 55 |
return $shortcode->get_content(); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Render next step button |
| 60 |
* |
| 61 |
* @return string |
| 62 |
*/ |
| 63 |
public static function render_next_step_button( $atts ){ |
| 64 |
$shortcode = new Wpfnl_Shortcode_NextStepButton( (array) $atts ); |
| 65 |
return $shortcode->get_content(); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Render checkout |
| 70 |
* |
| 71 |
* @return string |
| 72 |
*/ |
| 73 |
public static function render_checkout( $atts ){ |
| 74 |
$shortcode = new Wpfnl_Shortcode_Checkout( (array) $atts ); |
| 75 |
return $shortcode->get_content(); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Render optin form |
| 80 |
* |
| 81 |
* @return string |
| 82 |
*/ |
| 83 |
public static function render_optin_form( $atts ){ |
| 84 |
$shortcode = new WC_Shortcode_Optin( (array) $atts ); |
| 85 |
return $shortcode->get_content(); |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
public function thankyou_scripts() { |
| 92 |
global $post; |
| 93 |
if ( Wpfnl_functions::check_if_this_is_step_type('thankyou') ) { |
| 94 |
$style = $this->generate_style(); |
| 95 |
wp_add_inline_style('wpfnl-public', $style); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
public function generate_style() |
| 103 |
{ |
| 104 |
global $post; |
| 105 |
$output = ''; |
| 106 |
$thankyou = new Wpfnl_Steps_Store_Data(); |
| 107 |
$thankyou->read($post->ID); |
| 108 |
$order_overview = $thankyou->get_internal_metas_by_key('_wpfnl_thankyou_order_overview'); |
| 109 |
$order_details = $thankyou->get_internal_metas_by_key('_wpfnl_thankyou_order_details'); |
| 110 |
$billing_details = $thankyou->get_internal_metas_by_key('_wpfnl_thankyou_billing_details'); |
| 111 |
$shipping_details = $thankyou->get_internal_metas_by_key('_wpfnl_thankyou_shipping_details'); |
| 112 |
$style_file = WPFNL_DIR.'public/modules/thankyou/css/dynamic-css.php'; |
| 113 |
include $style_file; |
| 114 |
return $output; |
| 115 |
} |
| 116 |
} |
| 117 |
|