_alignments.scss000066600000000675152133527650007766 0ustar00.alignleft { /*rtl:ignore*/ float: left; /*rtl:ignore*/ margin-right: $size__spacing-unit; @include media(tablet) { /*rtl:ignore*/ margin-right: calc(2 * #{$size__spacing-unit}); } } .alignright { /*rtl:ignore*/ float: right; /*rtl:ignore*/ margin-left: $size__spacing-unit; @include media(tablet) { /*rtl:ignore*/ margin-left: calc(2 * #{$size__spacing-unit}); } } .aligncenter { clear: both; @include center-block; } _clearings.scss000066600000000646152133527650007572 0ustar00.clear:before, .clear:after, .entry-content:before, .entry-content:after, .comment-content:before, .comment-content:after, .site-header:before, .site-header:after, .site-content:before, .site-content:after, .site-footer:before, .site-footer:after { @include clearfix; } .clear:after, .entry-content:after, .comment-content:after, .site-header:after, .site-content:after, .site-footer:after { @include clearfix-after; } _accessibility.scss000066600000001626152133527650010451 0ustar00/* Text meant only for screen readers. */ .screen-reader-text { border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute !important; width: 1px; word-wrap: normal !important; /* Many screen reader and browser combinations announce broken words as they would appear visually. */ &:focus { background-color: $color__background-screen; border-radius: 3px; box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6); clip: auto !important; clip-path: none; color: $color__text-screen; display: block; font-size: 0.875rem; font-weight: bold; height: auto; left: 5px; line-height: normal; padding: 15px 23px 14px; text-decoration: none; top: 5px; width: auto; z-index: 100000; /* Above WP toolbar. */ } } /* Do not show the outline on the skip link target. */ #content[tabindex="-1"]:focus { outline: 0; } thankyou/class-cartflows-thankyou.php000066600000001630152140300170014063 0ustar00utils->get_step_post_type(), // Post_type. 'normal', // Context. 'high' // Priority. ); } } /** * Metabox Markup * * @param object $post Post object. * @return void */ public function markup_meta_box( $post ) { wp_nonce_field( 'save-nonce-thankyou-step-meta', 'nonce-thankyou-step-meta' ); $stored = get_post_meta( $post->ID ); $checkout_meta = self::get_meta_option( $post->ID ); // Set stored and override defaults. foreach ( $stored as $key => $value ) { if ( array_key_exists( $key, $checkout_meta ) ) { self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : ''; } else { self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : ''; } } // Get defaults. $meta = self::get_meta_option( $post->ID ); /** * Get options */ $thankyou_data = array(); foreach ( $meta as $key => $value ) { $thankyou_data[ $key ] = $meta[ $key ]['default']; } do_action( 'wcf_thankyou_settings_markup_before', $meta ); $this->page_header_tab( $thankyou_data, $post->ID ); do_action( 'wcf_thankyou_settings_markup_after', $meta ); } /** * Page Header Tabs * * @param array $options Post meta. * @param int $post_id Post ID. */ public function page_header_tab( $options, $post_id ) { $active_tab = get_post_meta( $post_id, 'wcf-active-tab', true ); if ( empty( $active_tab ) ) { $active_tab = 'wcf-thankyou-shortcodes'; } $tabs = array( array( 'title' => __( 'Shortcodes', 'cartflows' ), 'id' => 'wcf-thankyou-shortcodes', 'class' => 'wcf-thankyou-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-editor-code', ), array( 'title' => __( 'Design', 'cartflows' ), 'id' => 'wcf-thankyou-design', 'class' => 'wcf-thankyou-design' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-admin-customizer', ), array( 'title' => __( 'Edit Fields', 'cartflows' ), 'id' => 'wcf-thankyou-fields', 'class' => 'wcf-thankyou-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-welcome-widgets-menus', ), array( 'title' => __( 'Settings', 'cartflows' ), 'id' => 'wcf-thankyou-redirect', 'class' => 'wcf-thankyou-redirect' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-randomize', ), array( 'title' => __( 'Custom Script', 'cartflows' ), 'id' => 'wcf-thankyou-custom-script-header', 'class' => 'wcf-thankyou-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-format-aside', ), ); ?>
$tab ) { ?>
meta->get_shortcode_field( array( 'label' => __( 'Order Details', 'cartflows' ), 'name' => 'wcf-order-details', 'content' => esc_html( '[cartflows_order_details]' ), ) ); ?>
meta->get_section( array( 'label' => __( 'Text', 'cartflows' ), ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Color', 'cartflows' ), 'name' => 'wcf-tq-text-color', 'value' => $options['wcf-tq-text-color'], ) ); echo wcf()->meta->get_font_family_field( array( 'for' => 'wcf-tq-font-family', 'label' => esc_html__( 'Font Family', 'cartflows' ), 'name' => 'wcf-tq-font-family', 'value' => $options['wcf-tq-font-family'], ) ); echo wcf()->meta->get_number_field( array( 'label' => __( 'Font Size', 'cartflows' ), 'name' => 'wcf-tq-font-size', 'value' => $options['wcf-tq-font-size'], ) ); echo wcf()->meta->get_section( array( 'label' => __( 'Heading', 'cartflows' ), ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Color', 'cartflows' ), 'name' => 'wcf-tq-heading-color', 'value' => $options['wcf-tq-heading-color'], ) ); echo wcf()->meta->get_font_family_field( array( 'for' => 'wcf-tq-heading-font-family', 'label' => esc_html__( 'Font Family', 'cartflows' ), 'name' => 'wcf-tq-heading-font-family', 'value' => $options['wcf-tq-heading-font-family'], ) ); echo wcf()->meta->get_font_weight_field( array( 'for' => 'wcf-tq-heading-font-family', 'label' => esc_html__( 'Font Weight', 'cartflows' ), 'name' => 'wcf-tq-heading-font-wt', 'value' => $options['wcf-tq-heading-font-wt'], ) ); echo wcf()->meta->get_checkbox_field( array( 'label' => __( 'Advanced Options', 'cartflows' ), 'name' => 'wcf-tq-advance-options-fields', 'value' => $options['wcf-tq-advance-options-fields'], 'after' => 'Enable', ) ); echo wcf()->meta->get_number_field( array( 'for' => 'wcf-heading', 'label' => esc_html__( 'Container Width (In px)', 'cartflows' ), 'name' => 'wcf-tq-container-width', 'value' => $options['wcf-tq-container-width'], ) ); echo wcf()->meta->get_color_picker_field( array( 'label' => __( 'Section Background Color', 'cartflows' ), 'name' => 'wcf-tq-section-bg-color', 'value' => $options['wcf-tq-section-bg-color'], ) ); ?>
meta->get_checkbox_field( array( 'name' => 'wcf-show-overview-section', 'value' => $options['wcf-show-overview-section'], 'after' => esc_html__( 'Enable Order Overview ', 'cartflows' ), ) ); echo wcf()->meta->get_checkbox_field( array( 'name' => 'wcf-show-details-section', 'value' => $options['wcf-show-details-section'], 'after' => esc_html__( 'Enable Order Details ', 'cartflows' ), ) ); echo wcf()->meta->get_checkbox_field( array( 'name' => 'wcf-show-billing-section', 'value' => $options['wcf-show-billing-section'], 'after' => esc_html__( 'Enable Billing Details ', 'cartflows' ), ) ); echo wcf()->meta->get_checkbox_field( array( 'name' => 'wcf-show-shipping-section', 'value' => $options['wcf-show-shipping-section'], 'after' => esc_html__( 'Enable Shipping Details ', 'cartflows' ), ) ); echo wcf()->meta->get_hidden_field( array( 'name' => 'wcf-field-google-font-url', 'value' => $options['wcf-field-google-font-url'], ) ); ?>
meta->get_text_field( array( 'label' => __( 'Thank You Page Text', 'cartflows' ), 'name' => 'wcf-tq-text', 'value' => $options['wcf-tq-text'], 'attr' => array( 'placeholder' => __( 'Thank you. Your order has been received.', 'cartflows' ), ), 'help' => __( 'It will change the default text on thank you page.', 'cartflows' ), ) ); echo wcf()->meta->get_hr_line_field( array() ); echo wcf()->meta->get_checkbox_field( array( 'label' => __( 'Redirect After Purchase', 'cartflows' ), 'name' => 'wcf-show-tq-redirect-section', 'value' => $options['wcf-show-tq-redirect-section'], 'after' => 'Enable', ) ); echo wcf()->meta->get_text_field( array( 'label' => __( 'Redirect Link', 'cartflows' ), 'name' => 'wcf-tq-redirect-link', 'value' => $options['wcf-tq-redirect-link'], 'attr' => array( 'placeholder' => __( 'https://', 'cartflows' ), ), ) ); ?>
tab_custom_script( $options, $post_id ); ?> right_column_footer( $options, $post_id ); ?>
options->get_thankyou_fields( $post_id ); } return self::$meta_option; } /** * Metabox Save * * @param number $post_id Post ID. * @return void */ public function save_meta_box( $post_id ) { // Checks save status. $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id ); $is_valid_nonce = ( isset( $_POST['nonce-thankyou-step-meta'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce-thankyou-step-meta'] ) ), 'save-nonce-thankyou-step-meta' ) ) ? true : false; // Exits script depending on save status. if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { return; } wcf()->options->save_thankyou_fields( $post_id ); } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Thankyou_Meta::get_instance(); thankyou/classes/class-cartflows-thankyou-markup.php000066600000023422152140300170017020 0ustar00ID; $enable_redirection = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-tq-redirect-section' ); $redirect_link = wp_http_validate_url( wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-redirect-link' ) ); if ( 'yes' === $enable_redirection && ! empty( $redirect_link ) ) { exit( wp_redirect( $redirect_link ) ); //phpcs:ignore } } } /** * Order shortcode markup * * @param array $atts attributes. * @since 1.0.0 */ public function cartflows_order_details_shortcode_markup( $atts ) { $output = ''; if ( _is_wcf_thankyou_type() ) { /* Remove order item link */ add_filter( 'woocommerce_order_item_permalink', '__return_false' ); /* Change order text */ add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'custom_tq_text' ), 10, 2 ); if ( ! function_exists( 'wc_print_notices' ) ) { $notice_out = '

' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '

'; $notice_out .= ''; return $notice_out; } $order = false; $id_param = 'wcf-order'; $key_param = 'wcf-key'; if ( isset( $_GET['wcf-opt-order'] ) ) { //phpcs:ignore $id_param = 'wcf-opt-order'; $key_param = 'wcf-opt-key'; } if ( ! isset( $_GET[ $id_param ] ) && wcf()->flow->is_flow_testmode() ) { //phpcs:ignore $args = array( 'limit' => 1, 'order' => 'DESC', 'post_type' => 'shop_order', 'status' => array( 'completed', 'processing' ), ); $latest_order = wc_get_orders( $args ); $order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0; if ( $order_id > 0 ) { $order = wc_get_order( $order_id ); if ( ! $order ) { $order = false; } } } else { if ( ! isset( $_GET[ $id_param ] ) ) { //phpcs:ignore return '

Order not found. You cannot access this page directly.

'; } // Get the order. $order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET[ $id_param ] ) ? 0 : intval( $_GET[ $id_param ] ) ); //phpcs:ignore $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET[ $key_param ] ) ? '' : wc_clean( wp_unslash( $_GET[ $key_param ] ) ) ); //phpcs:ignore if ( $order_id > 0 ) { $order = wc_get_order( $order_id ); if ( ! $order || $order->get_order_key() !== $order_key ) { $order = false; } } } // Empty awaiting payment session. unset( WC()->session->order_awaiting_payment ); if ( null !== WC()->session ) { if ( ! isset( WC()->cart ) || '' === WC()->cart ) { WC()->cart = new WC_Cart(); } if ( ! WC()->cart->is_empty() ) { // wc_empty_cart(); // Empty current cart. WC()->cart->empty_cart( true ); wc_clear_notices(); } wc_print_notices(); } ob_start(); echo "
"; wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) ); echo '
'; $output = ob_get_clean(); } return $output; } /** * Load Thank You scripts. * * @return void */ public function thank_you_scripts() { if ( _is_wcf_thankyou_type() ) { do_action( 'cartflows_thank_you_scripts' ); $style = $this->generate_thank_you_style(); wp_add_inline_style( 'wcf-frontend-global', $style ); } } /** * Load DIVI compatibility Thank You style. * * @return void */ public function add_divi_compatibility_css() { global $post; $thank_you_id = $post->ID; if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() || Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $thank_you_id ) ) { wp_enqueue_style( 'wcf-frontend-global-divi', wcf()->utils->get_css_url( 'frontend-divi' ), array(), CARTFLOWS_VER ); } } /** * Set thank you as a order received page. * * @param boolean $is_order_page order page. * @return boolean */ public function set_order_received_page( $is_order_page ) { if ( _is_wcf_thankyou_type() ) { $is_order_page = true; } return $is_order_page; } /** * Generate Thank You Styles. * * @return string */ public function generate_thank_you_style() { global $post; if ( _is_wcf_thankyou_type() ) { $thank_you_id = $post->ID; } else { $thank_you_id = _get_wcf_thankyou_id( $post->post_content ); } CartFlows_Font_Families::render_fonts( $thank_you_id ); $text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' ); $text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' ); $text_font_size = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-size' ); $heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' ); $heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' ); $heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' ); $container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' ); $section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' ); $show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' ); $show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' ); $show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' ); $show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' ); $output = " .wcf-thankyou-wrap{ color: {$text_color}; font-family: {$text_font_family}; max-width:{$container_width}px; font-size: {$text_font_size}px; } .woocommerce-order h2.woocommerce-column__title, .woocommerce-order h2.woocommerce-order-details__title, .woocommerce-order .woocommerce-thankyou-order-received, .woocommerce-order-details h2, .woocommerce-order h2.wc-bacs-bank-details-heading, .woocommerce-order h2.woocommerce-order-downloads__title { color: {$heading_text_color}; font-family: {$heading_font_family}; font-weight: {$heading_font_weight}; } .woocommerce-order ul.order_details, .woocommerce-order .woocommerce-order-details, .woocommerce-order .woocommerce-customer-details, .woocommerce-order .woocommerce-bacs-bank-details, .woocommerce-order .woocommerce-order-downloads{ background-color: {$section_bg_color} } img.emoji, img.wp-smiley {} "; if ( 'no' == $show_order_review ) { $output .= ' .woocommerce-order ul.order_details{ display: none; } '; } if ( 'no' == $show_order_details ) { $output .= ' .woocommerce-order .woocommerce-order-details{ display: none; } '; } if ( 'no' == $show_billing_details ) { $output .= ' .woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{ display: none; } '; } if ( 'no' == $show_shipping_details ) { $output .= ' .woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{ display: none; } '; } if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) { $output .= ' .woocommerce-order .woocommerce-customer-details{ display: none; } '; } return $output; } /** * Set as a checkout page if it is thank you page. * Thank you page need to be set as a checkout page. * Becauye ayment gateways will not load if it is not checkout. * * @param bool $is_checkout is checkout. * * @return bool */ public function woo_checkout_flag( $is_checkout ) { if ( ! is_admin() ) { if ( _is_wcf_thankyou_type() ) { $is_checkout = true; } } return $is_checkout; } /** * Add custom text on thank you page. * * @param string $woo_text Default text. * @param int $order order. */ public function custom_tq_text( $woo_text, $order ) { global $post; $thank_you_id = $post->ID; $new_text = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text' ); if ( ! empty( $new_text ) ) { $woo_text = do_shortcode( $new_text ); } return $woo_text; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Thankyou_Markup::get_instance(); flow/view/meta-flow-steps.php000066600000022777152140300170012241 0ustar00 __( 'Landing', 'cartflows' ), 'checkout' => __( 'Checkout (Woo)', 'cartflows' ), 'thankyou' => __( 'Thank You (Woo)', 'cartflows' ), 'upsell' => __( 'Upsell (Woo)', 'cartflows' ), 'downsell' => __( 'Downsell (Woo)', 'cartflows' ), 'optin' => __( 'Optin (Woo)', 'cartflows' ), ); ?>
$data ) { ?>

post_type ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) { $flow_id = get_post_meta( $post->ID, 'wcf-flow-id', true ); $flow_title = get_the_title( $flow_id ); $post_states['cartflows_step'] = '( ' . __( 'Flow: ', 'cartflows' ) . $flow_id . ' | ' . __( 'Name: ', 'cartflows' ) . $flow_title . ')'; } return $post_states; } /** * Display slugdiv. * * @param array $hidden metaboxes. * @param obj $screen screen. * @return array */ public function display_flow_slug_meta_box( $hidden, $screen ) { $post_type = $screen->id; if ( ! empty( $post_type ) && CARTFLOWS_FLOW_POST_TYPE === $post_type ) { $pos = array_search( 'slugdiv', $hidden, true ); unset( $hidden[ $pos ] ); } return $hidden; } /** * Create custom post type */ public function flow_post_type() { $labels = array( 'name' => esc_html_x( 'Flows', 'flow general name', 'cartflows' ), 'singular_name' => esc_html_x( 'Flow', 'flow singular name', 'cartflows' ), 'search_items' => esc_html__( 'Search Flows', 'cartflows' ), 'all_items' => esc_html__( 'All Flows', 'cartflows' ), 'edit_item' => esc_html__( 'Edit Flow', 'cartflows' ), 'view_item' => esc_html__( 'View Flow', 'cartflows' ), 'add_new' => esc_html__( 'Add New', 'cartflows' ), 'update_item' => esc_html__( 'Update Flow', 'cartflows' ), 'add_new_item' => esc_html__( 'Add New', 'cartflows' ), 'new_item_name' => esc_html__( 'New Flow Name', 'cartflows' ), ); $args = array( 'labels' => $labels, 'show_in_menu' => false, 'public' => false, // it's not public, not own permalink. 'publicly_queryable' => true, // you should be able to query it. 'show_ui' => true, 'query_var' => true, 'can_export' => true, 'show_in_admin_bar' => true, 'exclude_from_search' => true, 'has_archive' => false, // it shouldn't have archive page. 'rewrite' => false, // it shouldn't have rewrite rules. 'supports' => array( 'title', 'thumbnail', 'slug' ), 'capability_type' => 'post', ); if ( ! _is_cartflows_pro() ) { $flow_posts = get_posts( array( 'posts_per_page' => 4, 'post_type' => CARTFLOWS_FLOW_POST_TYPE, 'post_status' => array( 'publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash' ), ) ); if ( is_array( $flow_posts ) ) { $flow_count = count( $flow_posts ); if ( $flow_count > 3 || 3 === $flow_count ) { $args['capabilities'] = array( 'create_posts' => 'do_not_allow', ); $args['map_meta_cap'] = true; // Add new notice button. add_action( 'admin_print_footer_scripts', array( $this, 'add_new_notice_button' ) ); // Add the notice popup HTML to admin footer. add_action( 'admin_footer', array( $this, 'upgrade_to_pro_notice_popup' ) ); } } } register_post_type( CARTFLOWS_FLOW_POST_TYPE, $args ); } /** * Show custom add new button. */ public function add_new_notice_button() { $screen = get_current_screen(); if ( is_object( $screen ) && CARTFLOWS_FLOW_POST_TYPE === $screen->post_type && 'edit-cartflows_flow' === $screen->id ) { ?> get_first_step_url( $post ); if ( $first_step && isset( $actions['view'] ) ) { $actions['view'] = '' . __( 'View', 'cartflows' ) . ''; } return $actions; } /** * Returns previous post link * * @param string $prev_link previous link. * @param array $post post data. * @return string */ public function preview_post_link( $prev_link, $post ) { if ( $this->is_flow_post_type( $post ) ) { $first_step = $this->get_first_step_url( $post ); if ( $first_step ) { return $first_step; } return ''; } return $prev_link; } /** * Check if post type is flow * * @param array $post post data. * @return bool */ public function is_flow_post_type( $post ) { if ( isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) { return true; } return false; } /** * Redirect to first step * * @return void */ public function redirect_to_step() { global $post; $first_step = $this->get_first_step_url( $post ); if ( $first_step ) { wp_safe_redirect( $first_step ); die; } } /** * Return first step URL * * @param array $post post data. * @return bool */ public function get_first_step_url( $post ) { if ( $this->is_flow_post_type( $post ) ) { $flow_id = $post->ID; $title = $post->post_title; $steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( is_array( $steps ) && ! empty( $steps ) && isset( $steps[0]['id'] ) ) { return get_permalink( $steps[0]['id'] ); } } return false; } /** * Register the admin menu for Custom Layouts * * @since 1.0.0 * Moved the menu under Appearance -> Custom Layouts public function register_admin_menu() { add_submenu_page( CARTFLOWS_SLUG, __( 'Flows', 'wcf' ), __( 'Flows', 'wcf' ), 'edit_pages', 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE ); } */ public function register_as_submenu() { global $submenu; $submenu[ CARTFLOWS_SLUG ][0] = array( //phpcs:ignore __( 'Flows', 'cartflows' ), 'edit_pages', 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, ); } /** * Add Update messages for any custom post type * * @param array $messages Array of default messages. */ public function custom_post_type_post_update_messages( $messages ) { $custom_post_type = get_post_type( get_the_ID() ); if ( CARTFLOWS_FLOW_POST_TYPE == $custom_post_type ) { $obj = get_post_type_object( $custom_post_type ); $singular_name = $obj->labels->singular_name; $messages[ $custom_post_type ] = array( 0 => '', // Unused. Messages start at index 1. /* translators: %s: singular custom post type name */ 1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ), /* translators: %s: singular custom post type name */ 2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ), /* translators: %s: singular custom post type name */ 3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ), /* translators: %s: singular custom post type name */ 4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ), /* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */ 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, //phpcs:ignore /* translators: %s: singular custom post type name */ 6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ), /* translators: %s: singular custom post type name */ 7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ), /* translators: %s: singular custom post type name */ 8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ), /* translators: %s: singular custom post type name */ 9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ), /* translators: %s: singular custom post type name */ 10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ), ); } return $messages; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Flow_Post_Type::get_instance(); flow/classes/class-cartflows-flow-loader.php000066600000002105152140300170015174 0ustar00include_files(); } /** * Load classes. * * @since 1.0.0 * * @return void */ public function include_files() { require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-post-type.php'; require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-step-post-type.php'; require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-step-post-meta.php'; require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-shortcodes.php'; require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-permalink.php'; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Flow_Loader::get_instance(); flow/classes/class-cartflows-step-post-meta.php000066600000001062152140300170015644 0ustar00post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) { $flow_id = get_post_meta( $post->ID, 'wcf-flow-id', true ); $flow_name = get_post_field( 'post_name', $flow_id ); $cf_permalink = Cartflows_Helper::get_permalink_settings(); if ( isset( $cf_permalink['permalink_structure'] ) && ! empty( $cf_permalink['permalink_structure'] ) ) { $search = array( 'cartflows_flow', '%flowname%', 'cartflows_step' ); $replace = array( $cf_permalink['permalink_flow_base'], $flow_name, $cf_permalink['permalink'] ); $post_link = str_replace( $search, $replace, $post_link ); } else { // If elementor page preview, return post link as it is. if ( isset( $_REQUEST['elementor-preview'] ) ) { //phpcs:ignore return $post_link; } $structure = get_option( 'permalink_structure' ); if ( '/%postname%/' === $structure ) { $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); } } } return $post_link; } /** * Reqrite rules for acrtflows step. */ public function rewrite_step_rule() { $cf_permalink = Cartflows_Helper::get_permalink_settings(); if ( isset( $cf_permalink['permalink_structure'] ) ) { switch ( $cf_permalink['permalink_structure'] ) { case '/cartflows_flow/%flowname%/cartflows_step': add_rewrite_rule( '^' . $cf_permalink['permalink_flow_base'] . '/([^/]*)/' . $cf_permalink['permalink'] . '/([^\/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' ); break; case '/cartflows_flow/%flowname%': add_rewrite_rule( '^' . $cf_permalink['permalink_flow_base'] . '/([^/]*)/([^/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' ); break; case '/%flowname%/cartflows_step': add_rewrite_rule( '([^/]*)/' . $cf_permalink['permalink'] . '/([^\/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' ); break; default: break; } } } /** * Have WordPress match postname to any of our public post types. * All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts. * By default, WordPress only accounts for posts and pages where the slug is /post-name/. * * @param string $query query statement. */ public function add_cpt_post_names_to_main_query( $query ) { // Bail if this is not the main query. if ( ! $query->is_main_query() ) { return; } // Bail if this query doesn't match our very specific rewrite rule. if ( ! isset( $query->query['thrive-variations'] ) && ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) { return; } // Bail if we're not querying based on the post name. if ( empty( $query->query['name'] ) ) { return; } // Add cartflows step post type to existing post type array. if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) { $post_types = $query->query_vars['post_type']; $post_types[] = CARTFLOWS_STEP_POST_TYPE; $query->set( 'post_type', $post_types ); } else { // Add CPT to the list of post types WP will include when it queries based on the post name. $query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) ); } } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Permalink::get_instance(); flow/classes/class-cartflows-flow-shortcodes.php000066600000006533152140300170016114 0ustar00post_type ) { $navigation = false; $step_id = intval( $post->ID ); $flow_id = get_post_meta( $step_id, 'wcf-flow-id', true ); if ( ! $flow_id ) { return $output; } $steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) { return $output; } foreach ( $steps as $i => $step ) { if ( intval( $step['id'] ) === $step_id ) { $next_i = $i + 1; if ( isset( $steps[ $next_i ] ) ) { $navigation = $steps[ $next_i ]; } break; } } if ( $navigation && is_array( $navigation ) ) { $output = get_permalink( $navigation['id'] ); } } return $output; } /** * Navigation shortcode callback * * @param array $atts attributes for shortcode. * @return string */ public function navigation_shortcode( $atts ) { $atts = shortcode_atts( array( 'label' => '', 'icon' => '', 'icon_position' => '', ), $atts ); global $post; $output = ''; if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) { $navigation = false; $step_id = intval( $post->ID ); $flow_id = get_post_meta( $step_id, 'wcf-flow-id', true ); if ( ! $flow_id ) { return $output; } $steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) { return $output; } foreach ( $steps as $i => $step ) { if ( intval( $step['id'] ) === $step_id ) { $next_i = $i + 1; if ( isset( $steps[ $next_i ] ) ) { $navigation = $steps[ $next_i ]; } break; } } if ( $navigation && is_array( $navigation ) ) { $label = ( '' != $atts['label'] ) ? $atts['label'] : __( 'Next Step', 'cartflows' ); $before = ''; $after = ''; if ( '' != $atts['icon'] ) { if ( '' != $atts['icon_position'] ) { if ( 'before' == $atts['icon_position'] ) { $before = ''; } else { $after = ''; } } } $output = '
' . $before . $label . $after . '
'; } } return $output; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Flow_Shortcodes::get_instance(); flow/classes/class-cartflows-flow-meta.php000066600000037014152140300170014663 0ustar00