class-cartflows-landing.php000066600000001615152142407040012004 0ustar00 CARTFLOWS_STEP_POST_TYPE, 'numberposts' => 100, 'meta_query' => array( //phpcs:ignore 'relation' => 'OR', array( 'key' => 'wcf-step-type', 'value' => 'landing', ), array( 'key' => 'wcf-step-type', 'value' => 'checkout', ), array( 'key' => 'wcf-step-type', 'value' => 'optin', ), ), ); $landing_pages = get_posts( $args ); if ( is_array( $landing_pages ) && ! empty( $landing_pages ) ) { $cartflows_custom_option = ''; $front_page_id = get_option( 'page_on_front' ); foreach ( $landing_pages as $key => $landing_page ) { $selected = selected( $front_page_id, $landing_page->ID, false ); $cartflows_custom_option .= ""; } $cartflows_custom_option .= ''; $output = str_replace( '', $cartflows_custom_option, $output ); } } return $output; } /** * Set post query. * * @param string $query post query. */ public function wcf_pre_get_posts( $query ) { if ( $query->is_main_query() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { $post_type = $query->get( 'post_type' ); $page_id = $query->get( 'page_id' ); if ( empty( $post_type ) && ! empty( $page_id ) ) { $query->set( 'post_type', get_post_type( $page_id ) ); } } } /** * Redirect to homepage if landing page set as home page. */ public function template_redirect() { $compatibiliy = Cartflows_Compatibility::get_instance(); // Do not redirect for page builder preview. if ( $compatibiliy->is_page_builder_preview() ) { return; } global $post; if ( is_singular() && ! is_front_page() && get_option( 'page_on_front' ) == $post->ID ) { wp_safe_redirect( site_url(), 301 ); } } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Landing_Markup::get_instance(); classes/class-cartflows-landing-meta.php000066600000013251152142407040014364 0ustar00utils->get_step_post_type(), // Post_type. 'normal', // Context. 'high' // Priority. ); } } /** * Landing Metabox Markup * * @param object $post Post object. * @return void */ public function landing_meta_box( $post ) { wp_nonce_field( 'save-nonce-landing-step-meta', 'nonce-landing-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 */ $landing_data = array(); foreach ( $meta as $key => $value ) { $landing_data[ $key ] = $meta[ $key ]['default']; } do_action( 'wcf_landing_settings_markup_before', $meta ); $this->page_header_tab( $landing_data, $post->ID ); do_action( 'wcf_landing_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-landing-shortcodes'; } $tabs = array( array( 'title' => __( 'Shortcodes', 'cartflows' ), 'id' => 'wcf-landing-shortcodes', 'class' => 'wcf-landing-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-info', ), array( 'title' => __( 'Custom Script', 'cartflows' ), 'id' => 'wcf-landing-custom-script-header', 'class' => 'wcf-landing-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab', 'icon' => 'dashicons-format-aside', ), ); ?>
$tab ) { ?>
utils->get_linking_url( array( 'class' => 'wcf-next-step' ) ); echo wcf()->meta->get_shortcode_field( array( 'label' => __( 'Next Step Link', 'cartflows' ), 'name' => 'wcf-next-step-link', 'content' => $next_step_link, ) ); ?>
tab_custom_script( $options, $post_id ); ?> right_column_footer( $options, $post_id ); ?>
options->get_landing_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-landing-step-meta'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce-landing-step-meta'] ) ), 'save-nonce-landing-step-meta' ) ) ? true : false; // Exits script depending on save status. if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { return; } wcf()->options->save_landing_fields( $post_id ); } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Landing_Meta::get_instance();