| 1 |
<?php |
| 2 |
/** |
| 3 |
* CartFlows flow Meta Helper. |
| 4 |
* |
| 5 |
* @package CartFlows |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace CartflowsAdmin\AdminCore\Inc; |
| 9 |
|
| 10 |
// Exit if accessed directly. |
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Class flowMeta. |
| 17 |
*/ |
| 18 |
class FlowMeta { |
| 19 |
|
| 20 |
|
| 21 |
/** |
| 22 |
* Get flow meta options. |
| 23 |
* |
| 24 |
* @param int $flow_id flow id. |
| 25 |
*/ |
| 26 |
public static function get_meta_settings( $flow_id ) { |
| 27 |
|
| 28 |
$settings = self::get_settings_fields( $flow_id ); |
| 29 |
$settings_data = array( |
| 30 |
'settings' => $settings, |
| 31 |
); |
| 32 |
return $settings_data; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* Page Header Tabs. |
| 38 |
* |
| 39 |
* @param int $flow_id id. |
| 40 |
*/ |
| 41 |
public static function get_settings_fields( $flow_id ) { |
| 42 |
|
| 43 |
// Check is the current theme is FSE theme or not. |
| 44 |
$is_fse_theme = wcf_is_current_theme_is_fse_theme(); |
| 45 |
|
| 46 |
// Add the hidden class if the current theme is not FSE theme. |
| 47 |
$section_hide_class = ! $is_fse_theme ? 'wcf-hide hidden' : ''; |
| 48 |
|
| 49 |
// Check is the current flow is Store Checkout Flow. |
| 50 |
$is_store_checkout_flow = intval( \Cartflows_Helper::get_global_setting( '_cartflows_store_checkout' ) ) === intval( $flow_id ); |
| 51 |
|
| 52 |
// Determine whether to show CodeMirror editors or the legacy textarea. |
| 53 |
$show_code_editor = AdminHelper::should_show_code_editor(); |
| 54 |
|
| 55 |
$general_fields = array( |
| 56 |
'flow_slug' => array( |
| 57 |
'type' => 'text', |
| 58 |
'name' => 'post_name', |
| 59 |
'label' => __( 'Funnel Slug', 'cartflows' ), |
| 60 |
'value' => get_post_field( 'post_name', $flow_id ), |
| 61 |
'display_align' => 'vertical', |
| 62 |
), |
| 63 |
'flow_indexing' => array( |
| 64 |
'type' => 'select', |
| 65 |
'name' => 'wcf-flow-indexing', |
| 66 |
'label' => __( 'Disallow Indexing', 'cartflows' ), |
| 67 |
'tooltip' => __( 'Changing this will replace the default global setting. To go back to the global setting, just select Default.', 'cartflows' ), |
| 68 |
'display_align' => 'vertical', |
| 69 |
'options' => array( |
| 70 |
array( |
| 71 |
'value' => '', |
| 72 |
'label' => __( 'Default', 'cartflows' ), |
| 73 |
), |
| 74 |
array( |
| 75 |
'value' => 'disallow', |
| 76 |
'label' => __( 'Yes', 'cartflows' ), |
| 77 |
), |
| 78 |
array( |
| 79 |
'value' => 'allow', |
| 80 |
'label' => __( 'No', 'cartflows' ), |
| 81 |
), |
| 82 |
), |
| 83 |
'value' => get_post_meta( $flow_id, 'wcf-flow-indexing', true ), |
| 84 |
), |
| 85 |
); |
| 86 |
|
| 87 |
if ( $show_code_editor ) { |
| 88 |
// Migration completed: show separate JS and CSS CodeMirror editors. |
| 89 |
$general_fields['flow_script_option'] = array( |
| 90 |
'type' => 'code', |
| 91 |
'label' => __( 'Funnel Custom JavaScript', 'cartflows' ), |
| 92 |
'name' => 'wcf-flow-custom-js', |
| 93 |
'value' => get_post_meta( $flow_id, 'wcf-flow-custom-js', true ), |
| 94 |
'language' => 'javascript', |
| 95 |
'tooltip' => __( 'Any JavaScript added here will run across all pages in this funnel. Do not include script tags.', 'cartflows' ), |
| 96 |
'display_align' => 'vertical', |
| 97 |
); |
| 98 |
$general_fields['flow_style_option'] = array( |
| 99 |
'type' => 'code', |
| 100 |
'label' => __( 'Funnel Custom CSS', 'cartflows' ), |
| 101 |
'name' => 'wcf-flow-custom-css', |
| 102 |
'value' => get_post_meta( $flow_id, 'wcf-flow-custom-css', true ), |
| 103 |
'language' => 'css', |
| 104 |
'tooltip' => __( 'Any CSS added here will run across all pages in this funnel. Do not include style tags.', 'cartflows' ), |
| 105 |
'display_align' => 'vertical', |
| 106 |
); |
| 107 |
} else { |
| 108 |
// Migration not completed: show the legacy combined textarea. |
| 109 |
$general_fields['script_option'] = array( |
| 110 |
'type' => 'textarea', |
| 111 |
'label' => __( 'Funnel Custom Script', 'cartflows' ), |
| 112 |
'name' => 'wcf-flow-custom-script', |
| 113 |
'value' => get_post_meta( $flow_id, 'wcf-flow-custom-script', true ), |
| 114 |
'tooltip' => __( 'Any code you add here will work across all the pages in this funnel.', 'cartflows' ), |
| 115 |
'display_align' => 'vertical', |
| 116 |
); |
| 117 |
} |
| 118 |
|
| 119 |
$settings = array( |
| 120 |
'instant-layout' => array( |
| 121 |
'title' => __( 'Instant Layout ', 'cartflows' ), |
| 122 |
'slug' => 'instant_layout', |
| 123 |
'fields' => array( |
| 124 |
'instant-layout-style' => array( |
| 125 |
'type' => 'toggle', |
| 126 |
'label' => __( 'Enable Instant Layout', 'cartflows' ), |
| 127 |
'name' => 'instant-layout-style', |
| 128 |
'value' => get_post_meta( $flow_id, 'instant-layout-style', true ), |
| 129 |
'desc' => sprintf( |
| 130 |
/* translators: %1$s: link html Start, %2$s: Link html end. */ |
| 131 |
__( 'This layout will replace the default page template for the Checkout, Upsell/Downsell and Thank You steps. You can customize the design in the Checkout, Upsell/Downsell and Thank You step\'s settings, under the design tab. %1$sRead More.%2$s', 'cartflows' ), |
| 132 |
'<a href="' . esc_url( \Cartflows_Helper::get_kb_doc_link( 'https://cartflows.com/docs/cartflows-instant-checkout-layout/' ) ) . '" target="_blank">', |
| 133 |
'</a>' |
| 134 |
), |
| 135 |
'is_fullwidth' => true, |
| 136 |
), |
| 137 |
'wcf-instant-checkout-header-logo-heading' => array( |
| 138 |
'type' => 'heading', |
| 139 |
'label' => __( 'Logo', 'cartflows' ), |
| 140 |
'conditions' => array( |
| 141 |
'relation' => 'and', |
| 142 |
'fields' => array( |
| 143 |
array( |
| 144 |
'name' => 'instant-layout-style', |
| 145 |
'operator' => '===', |
| 146 |
'value' => 'yes', |
| 147 |
), |
| 148 |
), |
| 149 |
), |
| 150 |
), |
| 151 |
'wcf-instant-checkout-header-logo' => array( |
| 152 |
'type' => 'image-selector', |
| 153 |
'label' => __( 'Custom Logo', 'cartflows' ), |
| 154 |
'name' => 'wcf-instant-checkout-header-logo', |
| 155 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-instant-checkout-header-logo' ), |
| 156 |
'isNameArray' => true, |
| 157 |
'objName' => 'wcf_instant_checkout_header_logo', |
| 158 |
'tooltip' => __( 'If you\'ve added a custom logo, it will show up here. If not, a default logo from the theme will be used instead.', 'cartflows' ), |
| 159 |
'conditions' => array( |
| 160 |
'relation' => 'and', |
| 161 |
'fields' => array( |
| 162 |
array( |
| 163 |
'name' => 'instant-layout-style', |
| 164 |
'operator' => '===', |
| 165 |
'value' => 'yes', |
| 166 |
), |
| 167 |
), |
| 168 |
), |
| 169 |
'desc' => __( 'Minimum image size should be 130 x 40 in pixes for ideal display.', 'cartflows' ), |
| 170 |
'display_align' => 'vertical', |
| 171 |
), |
| 172 |
'wcf-instant-checkout-header-logo-width' => array( |
| 173 |
'type' => 'number', |
| 174 |
'label' => __( 'Width (In px)', 'cartflows' ), |
| 175 |
'name' => 'wcf-instant-checkout-header-logo-width', |
| 176 |
'placeholder' => '130px', |
| 177 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-instant-checkout-header-logo-width' ), |
| 178 |
'display_align' => 'horizontal', |
| 179 |
'conditions' => array( |
| 180 |
'fields' => array( |
| 181 |
array( |
| 182 |
'name' => 'instant-layout-style', |
| 183 |
'operator' => '===', |
| 184 |
'value' => 'yes', |
| 185 |
), |
| 186 |
), |
| 187 |
), |
| 188 |
), |
| 189 |
'wcf-instant-checkout-header-logo-height' => array( |
| 190 |
'type' => 'number', |
| 191 |
'label' => __( 'Height (In px)', 'cartflows' ), |
| 192 |
'name' => 'wcf-instant-checkout-header-logo-height', |
| 193 |
'placeholder' => '40px', |
| 194 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-instant-checkout-header-logo-height' ), |
| 195 |
'display_align' => 'horizontal', |
| 196 |
'conditions' => array( |
| 197 |
'fields' => array( |
| 198 |
array( |
| 199 |
'name' => 'instant-layout-style', |
| 200 |
'operator' => '===', |
| 201 |
'value' => 'yes', |
| 202 |
), |
| 203 |
), |
| 204 |
), |
| 205 |
), |
| 206 |
'wcf-instant-checkout-header--color' => array( |
| 207 |
'type' => 'color-picker', |
| 208 |
'name' => 'wcf-instant-checkout-header-color', |
| 209 |
'label' => __( 'Header Color', 'cartflows' ), |
| 210 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-instant-checkout-header-color' ), |
| 211 |
'conditions' => array( |
| 212 |
'fields' => array( |
| 213 |
array( |
| 214 |
'name' => 'instant-layout-style', |
| 215 |
'operator' => '===', |
| 216 |
'value' => 'yes', |
| 217 |
), |
| 218 |
), |
| 219 |
), |
| 220 |
), |
| 221 |
), |
| 222 |
'priority' => 10, |
| 223 |
), |
| 224 |
'funnel-advanced-options' => array( |
| 225 |
'title' => __( 'Global Styling', 'cartflows' ), |
| 226 |
'slug' => 'funnel_advanced_options', |
| 227 |
'fields' => array( |
| 228 |
'gcp-enable-option' => array( |
| 229 |
'type' => 'toggle', |
| 230 |
'label' => __( 'Enable Global Styling', 'cartflows' ), |
| 231 |
'name' => 'wcf-enable-gcp-styling', |
| 232 |
'value' => get_post_meta( $flow_id, 'wcf-enable-gcp-styling', true ), |
| 233 |
'is_fullwidth' => true, |
| 234 |
), |
| 235 |
'gcp-primary-color' => array( |
| 236 |
'type' => 'color-picker', |
| 237 |
'name' => 'wcf-gcp-primary-color', |
| 238 |
'label' => __( 'Primary Color', 'cartflows' ), |
| 239 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-gcp-primary-color' ), |
| 240 |
'conditions' => array( |
| 241 |
'fields' => array( |
| 242 |
array( |
| 243 |
'name' => 'wcf-enable-gcp-styling', |
| 244 |
'operator' => '===', |
| 245 |
'value' => 'yes', |
| 246 |
), |
| 247 |
), |
| 248 |
), |
| 249 |
), |
| 250 |
'gcp-secondary-color' => array( |
| 251 |
'type' => 'color-picker', |
| 252 |
'name' => 'wcf-gcp-secondary-color', |
| 253 |
'label' => __( 'Secondary Color', 'cartflows' ), |
| 254 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-gcp-secondary-color' ), |
| 255 |
'conditions' => array( |
| 256 |
'fields' => array( |
| 257 |
array( |
| 258 |
'name' => 'wcf-enable-gcp-styling', |
| 259 |
'operator' => '===', |
| 260 |
'value' => 'yes', |
| 261 |
), |
| 262 |
), |
| 263 |
), |
| 264 |
), |
| 265 |
'gcp-primary-text-color' => array( |
| 266 |
'type' => 'color-picker', |
| 267 |
'name' => 'wcf-gcp-text-color', |
| 268 |
'label' => __( 'Text Color', 'cartflows' ), |
| 269 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-gcp-text-color' ), |
| 270 |
'conditions' => array( |
| 271 |
'fields' => array( |
| 272 |
array( |
| 273 |
'name' => 'wcf-enable-gcp-styling', |
| 274 |
'operator' => '===', |
| 275 |
'value' => 'yes', |
| 276 |
), |
| 277 |
), |
| 278 |
), |
| 279 |
), |
| 280 |
'gcp-accent-color' => array( |
| 281 |
'type' => 'color-picker', |
| 282 |
'name' => 'wcf-gcp-accent-color', |
| 283 |
'label' => __( 'Heading/Accent Color', 'cartflows' ), |
| 284 |
'value' => wcf()->options->get_flow_meta_value( $flow_id, 'wcf-gcp-accent-color' ), |
| 285 |
'conditions' => array( |
| 286 |
'fields' => array( |
| 287 |
array( |
| 288 |
'name' => 'wcf-enable-gcp-styling', |
| 289 |
'operator' => '===', |
| 290 |
'value' => 'yes', |
| 291 |
), |
| 292 |
), |
| 293 |
), |
| 294 |
), |
| 295 |
), |
| 296 |
'priority' => 20, |
| 297 |
), |
| 298 |
'general' => array( |
| 299 |
'title' => __( 'General ', 'cartflows' ), |
| 300 |
'slug' => 'general', |
| 301 |
'fields' => $general_fields, |
| 302 |
'priority' => 30, |
| 303 |
), |
| 304 |
); |
| 305 |
return apply_filters( 'cartflows_admin_flow_settings', $settings, $flow_id ); |
| 306 |
} |
| 307 |
} |
| 308 |
|