wpfunnels
/
includes
/
core
/
widgets
/
oxygen
/
elements
/
next-step-button
/
class-next-step-button.php
class-next-step-button.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.2, at includes/core/widgets/oxygen/elements/next-step-button/class-next-step-button.php
| 1 | <?php |
| 2 | /** |
| 3 | * Next step button |
| 4 | * |
| 5 | * @package |
| 6 | */ |
| 7 | namespace WPFunnels\Widgets\Oxygen; |
| 8 | |
| 9 | use WPFunnels\Wpfnl_functions; |
| 10 | |
| 11 | /** |
| 12 | * Class NextStepButton |
| 13 | * |
| 14 | * @package WPFunnels\Widgets\Oxygen |
| 15 | */ |
| 16 | class NextStepButton extends Elements { |
| 17 | |
| 18 | function init() { |
| 19 | // Do some initial things here. |
| 20 | } |
| 21 | |
| 22 | function afterInit() { |
| 23 | // Do things after init, like remove apply params button and remove the add button. |
| 24 | $this->removeApplyParamsButton(); |
| 25 | // $this->removeAddButton(); |
| 26 | } |
| 27 | |
| 28 | function name() { |
| 29 | return 'Next Step Button'; |
| 30 | } |
| 31 | |
| 32 | function slug() { |
| 33 | return "next-step-button"; |
| 34 | } |
| 35 | |
| 36 | function icon() { |
| 37 | return plugin_dir_url(__FILE__) . 'icon/next_steps.svg'; |
| 38 | } |
| 39 | |
| 40 | // function button_place() { |
| 41 | // // return "interactive"; |
| 42 | // } |
| 43 | |
| 44 | function button_priority() { |
| 45 | // return 9; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | function render($options, $defaults, $content) { |
| 50 | if (Wpfnl_functions::check_if_this_is_step_type('checkout') || Wpfnl_functions::check_if_this_is_step_type('upsell') || Wpfnl_functions::check_if_this_is_step_type('downsell') || Wpfnl_functions::check_if_this_is_step_type('thankyou')){ |
| 51 | echo __('Sorry, Please place the element in WPFunnels Landing page','wpfnl'); |
| 52 | }else{ |
| 53 | if( $this->is_builder_mode() ) { |
| 54 | $id = ''; |
| 55 | } else { |
| 56 | $id = 'wpfunnels_next_step_controller'; |
| 57 | } |
| 58 | |
| 59 | if( 'url-path' === $options['button_type_selector'] ){ |
| 60 | $url = isset($options['url_path_field']) ? $options['url_path_field'] : ''; |
| 61 | |
| 62 | }elseif( 'another-funnel' === $options['button_type_selector'] ){ |
| 63 | $url = $options['another_funnel_field']; |
| 64 | |
| 65 | }else{ |
| 66 | $url = ''; |
| 67 | } |
| 68 | |
| 69 | ?> |
| 70 | |
| 71 | <div class=""> |
| 72 | <a href="" data-button-type="<?php echo $options['button_type_selector']; ?>" data-url="<?php echo $url; ?>" class="btn-default wpfnl-oxy-next-step-btn" id="<?php echo $id; ?>"> <?= $options['title_text'] ?> |
| 73 | <span class="wpfnl-loader"></span> |
| 74 | </a> |
| 75 | </div> |
| 76 | <?php |
| 77 | } |
| 78 | |
| 79 | } |
| 80 | function controls() { |
| 81 | $button_type = $this->addControlSection("button_type", __("Button",'wpfnl'), "assets/icon.png", $this); |
| 82 | $button_type->addOptionControl( |
| 83 | array( |
| 84 | "type" => 'dropdown', |
| 85 | "name" => __("Select Button Type","wpfnl"), |
| 86 | "slug" => 'button_type_selector', |
| 87 | "default" => "checkout" |
| 88 | ) |
| 89 | )->setValue(array( |
| 90 | 'checkout' => __('Next Step',"wpfnl" ), |
| 91 | 'url-path' => __('Go To URL Path',"wpfnl" ), |
| 92 | 'another-funnel' => __('Another Funnel',"wpfnl" ), |
| 93 | ))->rebuildElementOnChange(); |
| 94 | |
| 95 | $button_type->addOptionControl( |
| 96 | array( |
| 97 | "type" => "textfield", |
| 98 | "name" => __("URL Path",'wpfnl'), |
| 99 | "slug" => "url_path_field", |
| 100 | "default" => "", |
| 101 | "condition" => 'button_type_selector=url-path', |
| 102 | ) |
| 103 | )->rebuildElementOnChange(); |
| 104 | |
| 105 | $button_type->addOptionControl( |
| 106 | array( |
| 107 | "type" => 'dropdown', |
| 108 | "name" => __("Choose funnel","wpfnl"), |
| 109 | "slug" => 'another_funnel_field', |
| 110 | "default" => "Select Funnel", |
| 111 | "condition" => 'button_type_selector=another-funnel', |
| 112 | ) |
| 113 | )->setValue( |
| 114 | Wpfnl_functions::get_funnel_list() |
| 115 | )->rebuildElementOnChange(); |
| 116 | |
| 117 | $button_type->addOptionControl( |
| 118 | array( |
| 119 | "type" => "textfield", |
| 120 | "name" => __("Button Text",'wpfnl'), |
| 121 | "slug" => "title_text", |
| 122 | "default" => "Buy Now" |
| 123 | ) |
| 124 | )->rebuildElementOnChange(); |
| 125 | |
| 126 | $button = $this->addControlSection("button_style", __("Button Style",'wpfnl'), "assets/icon.png", $this); |
| 127 | |
| 128 | $icon_selector = '.wpfnl-oxy-next-step-btn'; |
| 129 | |
| 130 | $button->addPreset( |
| 131 | "padding", |
| 132 | "menu_item_padding", |
| 133 | __("Button Padding","wpfnl"), |
| 134 | $icon_selector |
| 135 | )->whiteList(); |
| 136 | |
| 137 | $button->addPreset( |
| 138 | "margin", |
| 139 | "menu_item_margin", |
| 140 | __("Button Margin","wpfnl"), |
| 141 | $icon_selector |
| 142 | )->whiteList(); |
| 143 | |
| 144 | $button->addStyleControls( |
| 145 | array( |
| 146 | array( |
| 147 | "name" => __('Background Color','wpfnl'), |
| 148 | "selector" => $icon_selector."", |
| 149 | "property" => 'background-color', |
| 150 | ), |
| 151 | array( |
| 152 | "name" => __('Background Hover Color','wpfnl'), |
| 153 | "selector" => $icon_selector.":hover", |
| 154 | "property" => 'background-color', |
| 155 | ), |
| 156 | array( |
| 157 | "name" => __('Hover Text Color','wpfnl'), |
| 158 | "selector" => $icon_selector.":hover", |
| 159 | "property" => 'color', |
| 160 | ), |
| 161 | |
| 162 | ) |
| 163 | ); |
| 164 | |
| 165 | $button->borderSection( |
| 166 | __("Button Border",'wpfnl'), |
| 167 | $icon_selector."", |
| 168 | $this |
| 169 | ); |
| 170 | $button->typographySection( |
| 171 | __("Typography",'wpfnl'), |
| 172 | ".wpfnl-oxy-next-step-btn", |
| 173 | $this |
| 174 | ); |
| 175 | |
| 176 | |
| 177 | } |
| 178 | |
| 179 | function defaultCSS() { |
| 180 | |
| 181 | } |
| 182 | |
| 183 | } |
| 184 |