File manager - Edit - /home/theblueo/tv/fb4e3b/flow.tar
Back
view/meta-flow-steps.php 0000666 00000022777 15214174504 0011304 0 ustar 00 <?php /** * View Flow steps * * @package CartFlows */ $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' ); $steps = array( 'landing' => __( 'Landing', 'cartflows' ), 'checkout' => __( 'Checkout (Woo)', 'cartflows' ), 'thankyou' => __( 'Thank You (Woo)', 'cartflows' ), 'upsell' => __( 'Upsell (Woo)', 'cartflows' ), 'downsell' => __( 'Downsell (Woo)', 'cartflows' ), 'optin' => __( 'Optin (Woo)', 'cartflows' ), ); ?> <div class="wcf-flow-steps-meta-box"> <div class="wcf-flow-settings"> <?php do_action( 'cartflows_above_flow_steps' ); ?> <div class="wcf-flow-steps-wrap"> <div class="wcf-flow-steps-container"> <?php if ( is_array( $options['steps'] ) ) { ?> <?php foreach ( $options['steps'] as $index => $data ) { ?> <?php $term_slug = ''; $term_name = ''; $step_wrap_class = ''; $has_product_assigned = true; $is_global_checkout = ''; $common = ''; $data_step_id = intval( $data['id'] ); if ( isset( $data['type'] ) ) { $term_slug = $data['type']; $term_name = $steps[ $data['type'] ]; } if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) { $step_wrap_class .= ' invalid-step'; } if ( isset( $_GET['highlight-step-id'] ) ) { //phpcs:ignore $highlight_step_id = intval( $_GET['highlight-step-id'] ); //phpcs:ignore if ( $highlight_step_id === $data_step_id ) { $step_wrap_class .= ' wcf-new-step-highlight'; } } if ( 'checkout' === $term_slug ) { $common = Cartflows_Helper::get_common_settings(); $is_global_checkout = (int) $common['global_checkout']; if ( $data['id'] === $is_global_checkout ) { $step_wrap_class .= ' wcf-global-checkout'; } } if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) { $has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] ); if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) { $step_wrap_class .= ' wcf-no-product-step'; } } ?> <div class="wcf-step-wrap <?php echo $step_wrap_class; ?>" data-id="<?php echo $data['id']; ?>" data-term-slug="<?php echo esc_attr( $term_slug ); ?>"> <div class="wcf-step"> <div class="wcf-step-left-content"> <span class="dashicons dashicons-menu"></span> <span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span> <span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span> <?php if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) { ?> <span class="wcf-no-product-badge"><?php esc_html_e( 'No Product Assigned', 'cartflows' ); ?></span> <?php } elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) { ?> <span class="wcf-global-checkout-badge wcf-error-badge"><?php esc_html_e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span> <?php } elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) { ?> <span class="wcf-global-checkout-badge"><?php esc_html_e( 'Global Checkout', 'cartflows' ); ?></span> <?php } ?> <input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>"> <?php do_action( 'cartflows_step_left_content', $data['id'], $term_slug ); ?> </div> <div class="wcf-steps-action-buttons"> <a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'View Step', 'cartflows' ); ?>" > <span class="dashicons dashicons-visibility"></span> <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'View', 'cartflows' ); ?></span> </a> <a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'Edit Step', 'cartflows' ); ?>" > <span class="dashicons dashicons-edit"></span> <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Edit', 'cartflows' ); ?></span> </a> <?php if ( _is_cartflows_pro() ) { ?> <a href="<?php echo wp_nonce_url( 'admin.php?action=cartflows_clone_step&post=' . $data['id'], 'step_clone', 'step_clone_nonce' ); ?>" class="wcf-step-clone wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>"> <span class="dashicons dashicons-admin-page"></span> <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Clone', 'cartflows' ); ?></span> </a> <?php } ?> <a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>"> <span class="dashicons dashicons-trash"></span> <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Delete', 'cartflows' ); ?></span> </a> </div> </div> </div><!-- .wcf-step-wrap --> <?php } ?> <?php } ?> </div><!-- .wcf-flow-steps-container --> </div> <!-- .wcf-flow-steps-wrap --> <div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap --> <?php do_action( 'cartflows_bellow_flow_steps' ); ?> <div class='wcf-add-new-step-btn-wrap'> <button class='wcf-trigger-popup button button-primary'> <?php echo esc_html__( 'Add New Step', 'cartflows' ); ?> </button> </div> </div><!-- .wcf-flow-buttons-wrap --> </div><!-- .wcf-flow-settings --> <div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay"> <div class="wcf-templates-popup-content"> <div class="spinner"></div> <div class="wcf-templates-wrap wcf-templates-wrap-flows"> <div id="wcf-remote-step-actions" class="wcf-template-header"> <div class="wcf-template-logo-wrap"> <span class="wcf-cartflows-logo-img"> <span class="cartflows-logo-icon"></span> </span> <span class="wcf-cartflows-title"><?php esc_html_e( 'Steps Library', 'cartflows' ); ?></span> </div> <div class="wcf-tab-wrapper"> <?php if ( 'other' !== $default_page_builder ) { ?> <div id="wcf-get-started-steps"> <ul class="filter-links "> <li> <a href="#" class="current" data-slug="ready-templates" data-title="<?php esc_html_e( 'Ready Templates', 'cartflows' ); ?>"><?php esc_html_e( 'Ready Templates', 'cartflows' ); ?></a> </li> <li> <a href="#" data-slug="canvas" data-title="<?php esc_html_e( 'Create Your Own', 'cartflows' ); ?>"><?php esc_html_e( 'Create Your Own', 'cartflows' ); ?></a> </li> </ul> </div> <?php } ?> </div> <div class="wcf-popup-close-wrap"> <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span> </div> </div> <!--<div class="wcf-search-form"> <label class="screen-reader-text" for="wp-filter-search-input"><?php esc_html_e( 'Search Sites', 'cartflows' ); ?> </label> <input placeholder="<?php esc_html_e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input"> </div>--> <div id="wcf-remote-content"> <?php if ( 'other' !== $default_page_builder ) { ?> <div id="wcf-ready-templates"> <div id="wcf-remote-filters"> <div id="wcf-page-builders"></div> <div id="wcf-categories"></div> </div> <div class="wcf-page-builder-notice"></div> <div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div> <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div> </div> <?php } ?> <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>"> <div class="inner"> <div id="wcf-scratch-steps-categories"> <select class="step-type-filter-links filter-links"> <option value="" class="current"> Select Step Type </option> <?php foreach ( $steps as $key => $value ) { ?> <option class="<?php echo $key; ?>" data-slug="<?php echo $key; ?>" data-title="<?php echo $key; ?>"><?php echo $value; ?></option> <?php } ?> </select> </div> <a href="#" class="button button-primary cartflows-step-import-blank"><?php esc_html_e( 'Create Step', 'cartflows' ); ?></a> <?php if ( ! _is_cartflows_pro() ) { ?> <div class="wcf-template-notice"><p><?php echo esc_html__( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div> <?php } ?> <p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php esc_html_e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p> </div> </div> </div> </div> </div> </div><!-- .wcf-templates-popup-overlay --> </div> <?php classes/class-cartflows-flow-post-type.php 0000666 00000024250 15214174504 0014742 0 ustar 00 <?php /** * Flow post type * * @package CartFlows */ /** * Initialization * * @since 1.0.0 */ class Cartflows_Flow_Post_Type { /** * Member Variable * * @var instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { add_action( 'init', array( $this, 'flow_post_type' ) ); add_action( 'admin_menu', array( $this, 'register_as_submenu' ), 100 ); add_action( 'do_meta_boxes', array( $this, 'wcf_change_metabox_position' ) ); add_filter( 'post_updated_messages', array( $this, 'custom_post_type_post_update_messages' ) ); add_filter( 'display_post_states', array( $this, 'add_cartflows_post_state' ), 15, 1 ); add_filter( 'hidden_meta_boxes', array( $this, 'display_flow_slug_meta_box' ), 10, 2 ); /* View Post URL */ add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 ); add_filter( 'preview_post_link', array( $this, 'preview_post_link' ), 10, 2 ); add_action( 'template_redirect', array( $this, 'redirect_to_step' ), 10 ); } /** * Add CartFlows post status. * * @param array $post_states post data. * @return array */ public function add_cartflows_post_state( $post_states ) { global $post; if ( isset( $post->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 ) { ?> <script> jQuery('.wrap h1.wp-heading-inline').after('<a type="button" class="wcf-custom-add-new-button button">Add New</a>'); </script> <?php } } /** * Upgrade to pro notice popup. * * @since 1.3.4 * * @return void */ public function upgrade_to_pro_notice_popup() { ?> <div id="cartflows-upgrade-notice-overlay" style="display:none;"></div> <div id="cartflows-upgrade-notice-popup" style="display:none;"> <div class="inner"> <div class="heading"> <span><?php esc_html_e( 'Upgrade to CartFlows Pro', 'cartflows' ); ?></span> <span class="cartflows-close-popup-button tb-close-icon"></span> </div> <div class="contents"> <div class="wcf-notice"> <p>Upgrade to CartFlows Pro for adding more flows and other features. <a href ="https://cartflows.com/" target="_blank"> Click here</a> to upgrade.</p> </div> </div> </div> </div> <?php } /** * Change metabox position. */ public function wcf_change_metabox_position() { remove_meta_box( 'slugdiv', CARTFLOWS_FLOW_POST_TYPE, 'normal' ); add_meta_box( 'slugdiv', __( 'Slug', 'cartflows' ), 'post_slug_meta_box', CARTFLOWS_FLOW_POST_TYPE, 'side', 'high' ); } /** * Add post raw actions * * @param array $actions actions. * @param array $post post data. * @return array */ public function post_row_actions( $actions, $post ) { $first_step = $this->get_first_step_url( $post ); if ( $first_step && isset( $actions['view'] ) ) { $actions['view'] = '<a href="' . $first_step . '">' . __( 'View', 'cartflows' ) . '</a>'; } 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(); classes/class-cartflows-flow-loader.php 0000666 00000002105 15214174504 0014237 0 ustar 00 <?php /** * Flow loader * * @package CartFlows */ /** * Initialization * * @since 1.0.0 */ class Cartflows_Flow_Loader { /** * Member Variable * * @var instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { $this->include_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(); classes/class-cartflows-step-post-meta.php 0000666 00000001062 15214174504 0014707 0 ustar 00 <?php /** * Step post meta. * * @package CartFlows */ /** * Initialization * * @since 1.0.0 */ class Cartflows_Step_Post_Meta { /** * Member Variable * * @var instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Step_Post_Meta::get_instance(); classes/class-cartflows-permalink.php 0000666 00000010270 15214174504 0014010 0 ustar 00 <?php /** * Step post type. * * @package CartFlows */ /** * Initialization * * @since 1.0.0 */ class Cartflows_Permalink { /** * Member Variable * * @var instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 ); add_action( 'init', array( $this, 'rewrite_step_rule' ) ); add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ), 20 ); } /** * Modify permalink * * @param string $post_link post link. * @param array $post post data. * @param string $leavename leave name. * @return string */ public function post_type_permalinks( $post_link, $post, $leavename ) { if ( isset( $post->post_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(); classes/class-cartflows-flow-shortcodes.php 0000666 00000006533 15214174504 0015157 0 ustar 00 <?php /** * Flow shortcodes * * @package CartFlows */ /** * Initialization * * @since 1.0.0 */ class Cartflows_Flow_Shortcodes { /** * Member Variable * * @var instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { add_shortcode( 'cartflows_next_step_link', array( $this, 'next_step_link' ) ); add_shortcode( 'cartflows_navigation', array( $this, 'navigation_shortcode' ) ); } /** * Returns next step link * * @param array $atts attributes. * @return string */ public function next_step_link( $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 ) ) { $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 = '<span class="wcf-nextstep-icon wcf-nextstep-icon-before"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>'; } else { $after = '<span class="wcf-nextstep-icon wcf-nextstep-icon-after"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>'; } } } $output = '<div><a target="_self" href="' . get_permalink( $navigation['id'] ) . '">' . $before . $label . $after . '</a></div>'; } } return $output; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Flow_Shortcodes::get_instance(); classes/class-cartflows-flow-meta.php 0000666 00000037014 15214174504 0013726 0 ustar 00 <?php /** * Flow meta * * @package CartFlows */ /** * Meta Boxes setup */ class Cartflows_Flow_Meta { /** * Instance * * @var $instance */ private static $instance; /** * Meta Option * * @var $meta_option */ private static $meta_option; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { add_action( 'admin_head', array( $this, 'menu_highlight' ) ); add_action( 'admin_init', array( $this, 'admin_init_actions' ) ); /* Init Metabox */ add_action( 'load-post.php', array( $this, 'init_metabox' ) ); add_action( 'load-post-new.php', array( $this, 'init_metabox' ) ); /* Add Scripts */ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 20 ); add_action( 'wp_ajax_cartflows_delete_flow_step', array( $this, 'cartflows_delete_flow_step' ) ); add_action( 'wp_ajax_cartflows_reorder_flow_steps', array( $this, 'cartflows_reorder_flow_steps' ) ); add_action( 'admin_notices', array( $this, 'admin_notices' ) ); add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) ); } /** * Display admin notices. * * @since 1.0.0 * * @return void */ public function admin_notices() { if ( CARTFLOWS_STEP_POST_TYPE !== get_post_type() ) { return; } $flow_id = get_post_meta( get_the_id(), 'wcf-flow-id', true ); if ( $flow_id ) { ?> <div class="wcf-notice-back-edit-flow"> <p> <a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button button-primary button-hero" style="text-decoration: none;"> <i class="dashicons dashicons-arrow-left-alt"></i> <?php esc_html_e( 'Back to edit Flow', 'cartflows' ); ?> </a> </p> </div> <?php } } /** * Initialize admin actions. * * @since 1.0.0 * * @return void */ public function admin_init_actions() { add_action( 'before_delete_post', array( $this, 'step_post_sync' ) ); add_action( 'wp_trash_post', array( $this, 'step_post_trash_sync' ) ); add_action( 'untrashed_post', array( $this, 'step_post_untrash_sync' ) ); } /** * Delete term data and steps data after deleting flow. * * @since 1.0.0 * @param int $pid post id. * * @return void */ public function step_post_sync( $pid ) { global $post_type; if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) { $steps = get_post_meta( $pid, 'wcf-steps', true ); if ( $steps && is_array( $steps ) ) { foreach ( $steps as $i => $step ) { wp_delete_post( $step['id'], true ); } } $term_data = term_exists( 'flow-' . $pid, CARTFLOWS_TAXONOMY_STEP_FLOW ); if ( is_array( $term_data ) ) { wp_delete_term( $term_data['term_id'], CARTFLOWS_TAXONOMY_STEP_FLOW ); } } } /** * Trash steps data after trashing flow. * * @since 1.0.0 * @param int $pid post id. * * @return void */ public function step_post_trash_sync( $pid ) { global $post_type; if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) { $steps = get_post_meta( $pid, 'wcf-steps', true ); if ( $steps && is_array( $steps ) ) { foreach ( $steps as $i => $step ) { wp_trash_post( $step['id'] ); } } } } /** * Untrash steps data after restoring flow. * * @since 1.0.0 * @param int $pid post id. * * @return void */ public function step_post_untrash_sync( $pid ) { global $post_type; if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) { $steps = get_post_meta( $pid, 'wcf-steps', true ); if ( $steps && is_array( $steps ) ) { foreach ( $steps as $i => $step ) { wp_untrash_post( $step['id'] ); } } } } /** * Create step for given flow. * * @param int $flow_id flow ID. * @param int $step_type step type. * @param int $step_title step title. * @since 1.0.0 * * @return int */ public function create_step( $flow_id, $step_type, $step_title ) { $new_step_id = wp_insert_post( array( 'post_type' => CARTFLOWS_STEP_POST_TYPE, 'post_title' => $step_title, 'post_status' => 'publish', ) ); if ( $new_step_id ) { $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( ! is_array( $flow_steps ) ) { $flow_steps = array(); } $flow_steps[] = array( 'id' => $new_step_id, 'title' => $step_title, 'type' => $step_type, ); // insert post meta. update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id ); update_post_meta( $new_step_id, 'wcf-step-type', $step_type ); wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE ); wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW ); } update_post_meta( $flow_id, 'wcf-steps', $flow_steps ); return $new_step_id; } /** * Delete step for flow * * @since 1.0.0 * * @return void */ public function cartflows_delete_flow_step() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'wcf-delete-flow-step', 'security' ); if ( isset( $_POST['post_id'] ) && isset( $_POST['step_id'] ) ) { $flow_id = intval( $_POST['post_id'] ); $step_id = intval( $_POST['step_id'] ); } $result = array( 'status' => false, /* translators: %s flow id */ 'text' => sprintf( __( 'Step not deleted for flow - %s', 'cartflows' ), $flow_id ), ); if ( ! $flow_id || ! $step_id ) { wp_send_json( $result ); } wp_delete_post( $step_id, true ); $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( ! is_array( $flow_steps ) ) { wp_send_json( $result ); } foreach ( $flow_steps as $index => $data ) { if ( intval( $data['id'] ) === $step_id ) { unset( $flow_steps[ $index ] ); break; } } /* Set index order properly */ $flow_steps = array_merge( $flow_steps ); update_post_meta( $flow_id, 'wcf-steps', $flow_steps ); $result = array( 'status' => true, /* translators: %s flow id */ 'text' => sprintf( __( 'Step deleted for flow - %s', 'cartflows' ), $flow_id ), ); wp_send_json( $result ); } /** * Reorder step flow * * @since 1.0.0 * * @return void */ public function cartflows_reorder_flow_steps() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'wcf-reorder-flow-steps', 'security' ); if ( isset( $_POST['post_id'] ) && isset( $_POST['step_ids'] ) ) { $flow_id = intval( $_POST['post_id'] ); $step_ids = array_map( 'intval', $_POST['step_ids'] ); } $result = array( 'status' => false, /* translators: %s flow id */ 'text' => sprintf( __( 'Steps not sorted for flow - %s', 'cartflows' ), $flow_id ), ); if ( ! $flow_id || ! is_array( $step_ids ) ) { wp_send_json( $result ); } $new_flow_steps = array(); foreach ( $step_ids as $index => $step_id ) { $new_flow_steps[] = array( 'id' => intval( $step_id ), 'title' => get_the_title( $step_id ), 'type' => get_post_meta( $step_id, 'wcf-step-type', true ), ); } update_post_meta( $flow_id, 'wcf-steps', $new_flow_steps ); $result = array( 'status' => true, /* translators: %s flow id */ 'text' => sprintf( __( 'Steps sorted for flow - %s', 'cartflows' ), $flow_id ), ); wp_send_json( $result ); } /** * Load admin scripts * * @since 1.0.0 * * @return void */ public function admin_scripts() { global $pagenow; global $post; $screen = get_current_screen(); if ( ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) && CARTFLOWS_FLOW_POST_TYPE == $screen->post_type ) { wp_enqueue_script( 'wcf-flow-meta', CARTFLOWS_URL . 'admin/assets/js/flow-admin-edit.js', array( 'jquery', 'jquery-ui-sortable' ), CARTFLOWS_VER, true ); wp_enqueue_style( 'wcf-flow-meta', CARTFLOWS_URL . 'admin/assets/css/flow-admin-edit.css', '', CARTFLOWS_VER ); wp_style_add_data( 'wcf-flow-meta', 'rtl', 'replace' ); $localize = array( 'ajax_url' => admin_url( 'admin-ajax.php' ), ); wp_localize_script( 'jquery', 'cartflows', apply_filters( 'wcf_js_localize', $localize ) ); } } /** * Initialize meta box * * @since 1.0.0 * * @return void */ public function init_metabox() { /** * Fires after the title field. * * @param WP_Post $post Post object. */ add_action( 'add_meta_boxes', array( $this, 'settings_meta_box' ) ); add_action( 'edit_form_after_title', array( $this, 'setup_meta_box' ) ); add_action( 'save_post', array( $this, 'save_meta_box' ) ); } /** * Is first time import? * * @param integer $post_id post ID. * @return bool */ public function is_flow_imported( $post_id = 0 ) { if ( 0 === $post_id ) { $post_id = get_the_ID(); } $steps = get_post_meta( $post_id, 'wcf-steps', true ); $choice = get_post_meta( $post_id, 'wcf-flow-choise', true ); if ( empty( $steps ) && 'import' === $choice ) { return true; } return false; } /** * Setup meta box. * * @return void */ public function setup_meta_box() { if ( ! Cartflows_Admin::is_flow_edit_admin() ) { return; } /** * Adding Add new step button to the top*/ echo $this->add_add_new_step_button(); $this->markup_meta_box(); $this->add_upgrade_to_pro_metabox(); } /** * Add metabox when cartflows pro is not enabled. */ public function add_upgrade_to_pro_metabox() { if ( ! _is_cartflows_pro() ) { add_meta_box( 'wcf-upgrade-pro', __( 'Analytics', 'cartflows' ), array( $this, 'upgrade_to_pro' ), CARTFLOWS_FLOW_POST_TYPE, 'side', 'high' ); } } /** * Show Upgrade To Pro markup. */ public function upgrade_to_pro() { echo '<div>'; /* translators: %s: link */ echo '<p><i>' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Analytics feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i></p>'; echo '<p><a target="_blank" href="https://cartflows.com/" class="button button-primary">' . esc_html__( 'Get Pro', 'cartflows' ) . '</a></p>'; echo '</div>'; } /** * Settings meta box. * * @return void */ public function settings_meta_box() { if ( CARTFLOWS_FLOW_POST_TYPE === get_post_type() ) { /* No need of sandbox will delete it later */ add_meta_box( 'wcf-sandbox-settings', // Id. __( 'Flow Settings', 'cartflows' ), // Title. array( $this, 'sandbox_meta_box' ), // Callback. CARTFLOWS_FLOW_POST_TYPE, // Post_type. 'side', // Context. 'high' // Priority. ); do_action( 'cartflows_add_flow_metabox' ); } } /** * Metabox Markup * * @return void */ public function markup_meta_box() { global $post; wp_nonce_field( 'save-nonce-flow-meta', 'nonce-flow-meta' ); // Get defaults. $meta = self::get_current_post_meta( $post->ID ); /** * Get options */ $updated_data = array( 'steps' => $meta['wcf-steps']['default'], ); do_action( 'wcf_flow_settings_markup_before', $meta ); $this->page_header_tab( $updated_data ); do_action( 'wcf_flow_settings_markup_after', $meta ); } /** * Metabox Markup * * @param object $post Post object. * @return void */ public function sandbox_meta_box( $post ) { // Get defaults. $meta = self::get_current_post_meta( $post->ID ); /** * Get options */ foreach ( $meta as $key => $value ) { $updated_data[ $key ] = $meta[ $key ]['default']; } do_action( 'wcf_flow_sandbox_markup_before', $meta ); $this->sandbox_markup( $updated_data ); do_action( 'wcf_flow_sandbox_markup_after', $meta ); } /** * Page Header Tabs * * @param array $options Post meta. * @return void */ public function page_header_tab( $options ) { include_once CARTFLOWS_FLOW_DIR . 'view/meta-flow-steps.php'; } /** * Sandbox Markup * * @param array $options Post meta. * @return void */ public function sandbox_markup( $options ) { ?> <div class="wcf-flow-sandbox-table wcf-general-metabox-wrap widefat"> <div class="wcf-flow-sandbox-table-container"> <?php echo wcf()->meta->get_checkbox_field( array( 'name' => 'wcf-testing', 'value' => $options['wcf-testing'], 'after' => esc_html__( 'Enable Test Mode', 'cartflows' ), ) ); echo wcf()->meta->get_description_field( array( 'name' => 'wcf-testing-note', 'content' => esc_html__( 'If you are using WooCommerce plugin then test mode will add random products in your flow, so you can preview it easily while testing.', 'cartflows' ), ) ); ?> </div> </div> <?php } /** * Keep the menu open when editing the flows. * Highlights the wanted admin (sub-) menu items for the CPT. * * @since 1.0.0 */ public function menu_highlight() { global $parent_file, $submenu_file, $post_type; if ( CARTFLOWS_FLOW_POST_TYPE == $post_type ) : $parent_file = CARTFLOWS_SLUG;//phpcs:ignore $submenu_file = 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE;//phpcs:ignore endif; } /** * Get metabox options * * @param int $post_id post id. * @return array */ public static function get_meta_option( $post_id ) { if ( null === self::$meta_option ) { /** * Set metabox options */ self::$meta_option = wcf()->options->get_flow_fields( $post_id ); } return self::$meta_option; } /** * Get metabox options * * @param int $post_id post ID. * @return array */ public static function get_current_post_meta( $post_id ) { $stored = get_post_meta( $post_id ); $default_meta = self::get_meta_option( $post_id ); // Set stored and override defaults. foreach ( $stored as $key => $value ) { if ( array_key_exists( $key, $default_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] : ''; } } return self::get_meta_option( $post_id ); } /** * 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-flow-meta'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce-flow-meta'] ) ), 'save-nonce-flow-meta' ) ) ? true : false; // Exits script depending on save status. if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { return; } wcf()->options->save_flow_fields( $post_id ); } /** * Localize variables in admin * * @param array $vars variables. */ public function localize_vars( $vars ) { $ajax_actions = array( 'wcf_setup_default_steps', 'wcf_add_flow_step', 'wcf_delete_flow_step', 'wcf_reorder_flow_steps', ); foreach ( $ajax_actions as $action ) { $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) ); } return $vars; } /** * Add New Step Button * * @return string */ public function add_add_new_step_button() { $add_new_btn_markup = '<style>.wrap{ position:relative;}</style>'; $add_new_btn_markup .= "<div class='wcf-button-wrap'>"; $add_new_btn_markup .= "<button class='wcf-trigger-popup page-title-action'>"; $add_new_btn_markup .= esc_html__( 'Add New Step', 'cartflows' ); $add_new_btn_markup .= '</button>'; $add_new_btn_markup .= '</div>'; return $add_new_btn_markup; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Flow_Meta::get_instance(); classes/class-cartflows-step-post-type.php 0000666 00000031031 15214174504 0014741 0 ustar 00 <?php /** * Step post type. * * @package CartFlows */ /** * Initialization * * @since 1.0.0 */ class Cartflows_Step_Post_Type { /** * Member Variable * * @var instance */ private static $instance; /** * Member Variable * * @var body_classes */ private $body_classes = array(); /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor */ public function __construct() { add_action( 'init', array( $this, 'step_post_type' ) ); add_action( 'init', array( $this, 'add_wp_templates_support' ) ); add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) ); add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 ); add_filter( 'template_include', array( $this, 'load_page_template' ), 90 ); add_filter( 'template_redirect', array( $this, 'query_fix' ), 3 ); } /** * Trys to load page.php for a header, footer or part theme layout. * * @since 1.0.0 * @param string $template The current template to be loaded. * @return string */ public function load_page_template( $template ) { global $post; if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) { /** * Remove Next/Prev Navigation * add_filter('next_post_link', '__return_empty_string'); * add_filter('previous_post_link', '__return_empty_string'); * * $page = locate_template( array( 'page.php' ) ); * * if ( ! empty( $page ) ) { * return $page; * } */ /* Remove Next / Previous Rel Link */ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); add_filter( 'next_post_rel_link', '__return_empty_string' ); add_filter( 'previous_post_rel_link', '__return_empty_string' ); $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true ); $page_template = apply_filters( 'cartflows_page_template', $page_template ); $file = ''; switch ( $page_template ) { case 'cartflows-default': $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php'; $this->body_classes[] = $page_template; break; case 'cartflows-canvas': $file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php'; $this->body_classes[] = $page_template; break; default: /** * Remove Next/Prev Navigation */ add_filter( 'next_post_link', '__return_empty_string' ); add_filter( 'previous_post_link', '__return_empty_string' ); $page = locate_template( array( 'page.php' ) ); if ( ! empty( $page ) ) { $file = $page; } break; /** * Default: * $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php'; * $this->body_classes[] = 'cartflows-default'; * break; */ } // Just to be safe, we check if the file exist first. if ( file_exists( $file ) ) { /* Add Body Class */ add_filter( 'body_class', array( $this, 'body_class' ) ); return $file; } else { echo $file; } } return $template; } /** * Body classes. * * @since 1.0.0 * @param array $classes Body classes. * @return array */ public function body_class( $classes = array() ) { $classes = array_merge( $classes, $this->body_classes ); return $classes; } /** * Create custom post type */ public function step_post_type() { $labels = array( 'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ), 'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ), 'search_items' => esc_html__( 'Search Steps', 'cartflows' ), 'all_items' => esc_html__( 'All Steps', 'cartflows' ), 'edit_item' => esc_html__( 'Edit Step', 'cartflows' ), 'view_item' => esc_html__( 'View Step', 'cartflows' ), 'add_new' => esc_html__( 'Add New', 'cartflows' ), 'update_item' => esc_html__( 'Update Step', 'cartflows' ), 'add_new_item' => esc_html__( 'Add New', 'cartflows' ), 'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ), ); $permalink_settings = Cartflows_Helper::get_permalink_settings(); $args = array( 'labels' => $labels, 'public' => true, 'query_var' => true, 'can_export' => true, 'exclude_from_search' => true, 'show_ui' => true, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'supports' => array( 'title', 'editor', 'elementor', 'revisions' ), 'capability_type' => 'post', 'capabilities' => array( 'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false. ), 'map_meta_cap' => true, ); if ( isset( $permalink_settings['permalink_structure'] ) && ! empty( $permalink_settings['permalink_structure'] ) ) { $args['rewrite'] = array( 'slug' => $permalink_settings['permalink_structure'], 'with_front' => false, ); } elseif ( isset( $permalink_settings['permalink'] ) && ! empty( $permalink_settings['permalink'] ) ) { $args['rewrite'] = array( 'slug' => $permalink_settings['permalink'], 'with_front' => false, ); } register_post_type( CARTFLOWS_STEP_POST_TYPE, $args ); // Step Type. $args = array( 'label' => __( 'Step Type', 'cartflows' ), 'public' => false, 'rewrite' => false, 'hierarchical' => false, ); register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args ); // Step Flow. $args = array( 'label' => __( 'Step Flow', 'cartflows' ), 'public' => false, 'rewrite' => false, 'hierarchical' => false, ); register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args ); if ( is_admin() ) { /** * Register 'Elementor' & 'Beaver Builder' site types. * * @see self::add_terms(); */ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE; $terms = array( array( 'name' => __( 'Landing', 'cartflows' ), 'slug' => 'landing', 'args' => array( 'slug' => 'landing', ), ), array( 'name' => __( 'Optin (Woo)', 'cartflows' ), 'slug' => 'optin', 'args' => array( 'slug' => 'optin', ), ), array( 'name' => __( 'Checkout (Woo)', 'cartflows' ), 'slug' => 'checkout', 'args' => array( 'slug' => 'checkout', ), ), array( 'name' => __( 'Thank You (Woo)', 'cartflows' ), 'slug' => 'thankyou', 'args' => array( 'slug' => 'thankyou', ), ), array( 'name' => __( 'Upsell (Woo)', 'cartflows' ), 'slug' => 'upsell', 'args' => array( 'slug' => 'upsell', ), ), array( 'name' => __( 'Downsell (Woo)', 'cartflows' ), 'slug' => 'downsell', 'args' => array( 'slug' => 'downsell', ), ), ); $this->add_terms( $taxonomy, $terms ); } } /** * Add WordPress templates. * * Adds Cartflows templates to steps * * @since 1.0.0 * @access public */ public function add_wp_templates_support() { add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 ); } /** * Add page templates. * * @since 1.0.0 * @access public * * @param array $page_templates Array of page templates. * * @param object $wp_theme wp theme. * @param object $post post. * * @return array Page templates. */ public function add_page_templates( $page_templates, $wp_theme, $post ) { $page_templates = array( 'cartflows-default' => _x( 'CartFlows — Boxed', 'cartflows' ), 'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ), ); return $page_templates; } /** * Query fixe throwing error on 404 page due our post type changes. * We are setting post_type as empty array to fix the issue. * Ther error was throwing due to redirect_canonical function * This fix is apply for 404 page only */ public function query_fix() { global $wp_query; if ( $wp_query->is_404() ) { $wp_query->set( 'post_type', array() ); } } /** * Prevent slug duplicated * * @param string $slug post slug. * @param int $post_ID post id. * @param string $post_status post status. * @param string $post_type post type. * @param int $post_parent post parent id. * @param string $original_slug original slug. * @return string */ public function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { $check_post_types = array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE, ); if ( ! in_array( $post_type, $check_post_types, true ) ) { return $slug; } if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) { // Saving a post, check for duplicates in POST or PAGE post types. $post_match = get_page_by_path( $slug, 'OBJECT', 'post' ); $page_match = get_page_by_path( $slug, 'OBJECT', 'page' ); if ( $post_match || $page_match ) { $slug .= '-2'; } } else { // Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type. $custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE ); if ( $custom_post_type_match ) { $slug .= '-2'; } } return $slug; } /** * Add Update messages for any custom post type * * @param array $messages Array of default messages. */ public function post_update_messages( $messages ) { $custom_post_type = get_post_type( get_the_ID() ); if ( CARTFLOWS_STEP_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; } /** * Add Terms for Taxonomy. * * => Example. * * $taxonomy = '{taxonomy}'; * $terms = array( * array( * 'name' => 'Landing', * 'slug' => 'landing', * ), * array( * 'name' => 'Checkout', * 'slug' => 'checkout', * ), * ); * * self::add_terms( $taxonomy, $terms ); * * @since 1.0.0 * @param string $taxonomy Taxonomy Name. * @param array $terms Terms list. * @return void */ public function add_terms( $taxonomy = '', $terms = array() ) { foreach ( $terms as $key => $term ) { $term_exist = term_exists( $term['slug'], $taxonomy ); if ( empty( $term_exist ) ) { /** * Add additional args if passed from request. * * @see https://codex.wordpress.org/Function_Reference/wp_insert_term */ if ( array_key_exists( 'args', $term ) ) { wp_insert_term( $term['name'], $taxonomy, $term['args'] ); } else { $term['args'] = array( $term['slug'] ); wp_insert_term( $term['name'], $taxonomy, $term['args'] ); } } } } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Step_Post_Type::get_instance(); class-cartflows-flow.php 0000666 00000001554 15214174504 0011345 0 ustar 00 <?php /** * Flow * * @package CartFlows */ define( 'CARTFLOWS_FLOW_DIR', CARTFLOWS_DIR . 'modules/flow/' ); define( 'CARTFLOWS_FLOW_URL', CARTFLOWS_URL . 'modules/flow/' ); /** * Initial Setup * * @since 1.0.0 */ class Cartflows_Flow { /** * Member Variable * * @var object instance */ private static $instance; /** * Initiator */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor function that initializes required actions and hooks */ public function __construct() { require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-loader.php'; require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-meta.php'; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Flow::get_instance(); templates/template-canvas.php 0000666 00000001554 15214174504 0012353 0 ustar 00 <?php /** * Template Name: No Header Footer * * @package CartFlows */ ?> <!DOCTYPE html> <html <?php language_attributes(); ?> class="no-js"> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="profile" href="http://gmpg.org/xfn/11"> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <?php wp_body_open(); do_action( 'cartflows_body_top' ); ?> <?php $atts_string = Cartflows_Helper::get_cartflows_container_atts(); ?> <div class="cartflows-container" <?php echo trim( $atts_string ); ?>> <?php do_action( 'cartflows_container_top' ); while ( have_posts() ) : the_post(); the_content(); endwhile; do_action( 'cartflows_container_bottom' ); ?> </div> <?php do_action( 'cartflows_wp_footer' ); ?> <?php wp_footer(); ?> </body> </html> <?php templates/template-default.php 0000666 00000001672 15214174504 0012525 0 ustar 00 <?php /** * Template Name: No Header Footer * * @package CartFlows */ ?> <!DOCTYPE html> <html <?php language_attributes(); ?> class="no-js"> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="profile" href="http://gmpg.org/xfn/11"> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <?php wp_body_open(); do_action( 'cartflows_body_top' ); ?> <?php $atts_string = Cartflows_Helper::get_cartflows_container_atts(); ?> <div class="cartflows-container" <?php echo trim( $atts_string ); ?>> <?php do_action( 'cartflows_container_top' ); ?> <div class="cartflows-primary"> <?php while ( have_posts() ) : the_post(); the_content(); endwhile; ?> </div> <?php do_action( 'cartflows_container_bottom' ); ?> </div> <?php do_action( 'cartflows_wp_footer' ); ?> <?php wp_footer(); ?> </body> </html> <?php templates/index.php 0000666 00000000131 15214174504 0010364 0 ustar 00 <?php /** * Index. * * @package CartFlows */ /* Silence is golden, and we agree. */
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings