setup_titles(); $page_title = get_post_meta( $page_id, 'page_title', true ); if ( ! $page_title ) { $page_title = $alpus_layout['title']; } $page_subtitle = get_post_meta( $page_id, 'page_subtitle', true ); if ( ! $page_subtitle ) { $page_subtitle = $alpus_layout['subtitle']; } ?> '; } /** * Fires before rendering main content. * * @since 1.0 */ do_action( 'alpus_before_main_content' ); echo '
'; if ( $has_left_sidebar ) { alpus_get_template_part( 'sidebar', null, array( 'position' => 'left' ) ); } if ( $has_right_sidebar ) { alpus_get_template_part( 'sidebar', null, array( 'position' => 'right' ) ); } /** * Fires after print sidebar. * * @since 1.0 */ do_action( 'alpus_sidebar' ); /** * Filters the main content class. * * @since 1.0 */ echo '
'; /** * Fires before print inner content. * * @since 1.0 */ do_action( 'alpus_before_inner_content' ); } } /** * Print layout after. * * @since 1.0 */ if ( ! function_exists( 'alpus_print_layout_after' ) ) { function alpus_print_layout_after() { $ls = false; // state of left sidebar $rs = false; // state of right sidebar $ls_canvas = false; // on_canvas/off_canvas $rs_canvas = false; // on_canvas/off_canvas global $alpus_layout; /** * Fires after print inner content. * * @since 1.0 */ do_action( 'alpus_after_inner_content', $alpus_layout ); echo '
'; // End of main content wrap /** * Fires after rendering main content. * * @since 1.0 */ do_action( 'alpus_after_main_content' ); echo '
'; if ( is_page() && ! alpus_is_shop() && comments_open() ) { comments_template(); } if ( isset( $alpus_layout['wrap'] ) && 'full' != $alpus_layout['wrap'] ) { // end of container or container-fluid echo ''; } } } /** * The comment form before fields. * * @since 1.0 */ if ( ! function_exists( 'alpus_comment_form_before_fields' ) ) { function alpus_comment_form_before_fields() { echo '
'; } } /** * The comment form after fields. * * @since 1.0 */ if ( ! function_exists( 'alpus_comment_form_after_fields' ) ) { function alpus_comment_form_after_fields() { echo '
'; } } /** * Set avatar size. * * @since 1.0 */ if ( ! function_exists( 'alpus_set_avatar_size' ) ) { function alpus_set_avatar_size( $args ) { $args['size'] = 90; $args['width'] = 90; $args['height'] = 90; return $args; } } /** * The author date pattern. * * @since 1.0 */ if ( ! function_exists( 'alpus_author_date_pattern' ) ) { function alpus_author_date_pattern( $date ) { return date( 'F j, Y \a\t g:s a', strtotime( $date ) ); } } /** * Set cookies. * * @since 1.0 */ if ( ! function_exists( 'alpus_set_cookies' ) ) { function alpus_set_cookies() { // phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification if ( ! empty( $_GET['top_filter'] ) ) { setcookie( 'top_filter', sanitize_title( $_GET['top_filter'] ), time() + ( 86400 ), '/' ); $_COOKIE['alpus_top_filter'] = esc_html( $_GET['top_filter'] ); } // phpcs:enable } } /** * Ajax actions: loadmore * * * @since 1.0 */ if ( ! function_exists( 'alpus_loadmore' ) ) { function alpus_loadmore() { // phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification if ( isset( $_POST['args'] ) && isset( $_POST['props'] ) ) { $args = $_POST['args']; $props = $_POST['props']; $cpt = empty( $args['cpt'] ) ? 'post' : $args['cpt']; $shortcode = empty( $props['shortcode'] ) ? '' : $props['shortcode']; if ( 'alpus-posts-grid' == $shortcode ) { $atts = $props; if ( ! empty( $args['paged'] ) ) { if ( is_front_page() ) { set_query_var( 'page', (int) $args['paged'] ); } else { set_query_var( 'paged', (int) $args['paged'] ); } } if ( ! empty( $args['category'] ) && '*' != $args['category'] ) { $atts['cats'] = sanitize_text_field( $args['category'] ); } require alpus_core_framework_path( ALPUS_CORE_FRAMEWORK_PATH . '/widgets/posts-grid/render-posts-grid.php' ); } elseif ( 'product' == $cpt ) { /** * Load more products */ if ( isset( $args['paged'] ) && $args['paged'] ) { $args['page'] = $args['paged']; unset( $args['paged'] ); } if ( isset( $args['total'] ) && $args['total'] ) { unset( $args['total'] ); } if ( isset( $props['row_cnt'] ) ) { $GLOBALS['alpus_current_product_id'] = 0; } wc_set_loop_prop( 'alpus_ajax_load', true ); foreach ( $props as $key => $prop ) { wc_set_loop_prop( $key, $prop ); } $args_str = ''; foreach ( $args as $key => $value ) { if ( 'posts_per_page' == $key ) { $key = 'limit'; } $args_str .= ' ' . $key . '=' . json_encode( $value ); } $html = do_shortcode( '[products' . $args_str . ']' ); echo alpus_escaped( $html ); } else { /** * Load more posts */ $posts = new WP_Query( $args ); if ( $posts ) { ob_start(); /** * Fires before archive posts widget render. * * @since 1.0 */ do_action( 'alpus_before_posts_loop', $props ); alpus_get_template_part( 'posts/post', 'loop-start' ); while ( $posts->have_posts() ) : $posts->the_post(); alpus_get_template_part( 'posts/post' ); endwhile; alpus_get_template_part( 'posts/post', 'loop-end' ); /** * Fires after archive posts widget render. * * @since 1.0 */ do_action( 'alpus_after_posts_loop' ); $html = ob_get_clean(); if ( $_POST['pagination'] ) { echo json_encode( array( 'html' => $html, 'pagination' => alpus_get_pagination( $posts, 'pagination-load' ), ) ); } else { echo alpus_escaped( $html ); } wp_reset_postdata(); } } } exit; // phpcs:enable } } /** * Ajax sign in/ sign up * * @since 1.0 */ if ( ! function_exists( 'alpus_retrieve_account_html' ) ) { function alpus_retrieve_account_html() { ?>
trim( $_POST['username'] ), 'user_password' => $_POST['password'], 'remember' => isset( $_POST['rememberme'] ), ); $validation_error = new WP_Error(); $validation_error = apply_filters( $filter_prefix . '_process_login_errors', $validation_error, $_POST['username'], $_POST['password'] ); if ( $validation_error->get_error_code() ) { echo json_encode( array( 'loggedin' => false, 'message' => '' . esc_html__( 'Error:', 'alpus' ) . ' ' . $validation_error->get_error_message(), ) ); die(); } if ( empty( $creds['user_login'] ) ) { echo json_encode( array( 'loggedin' => false, 'message' => '' . esc_html__( 'Error:', 'alpus' ) . ' ' . esc_html__( 'Username is required.', 'alpus' ), ) ); die(); } // On multisite, ensure user exists on current site, if not add them before allowing login. if ( is_multisite() ) { $user_data = get_user_by( is_email( $creds['user_login'] ) ? 'email' : 'login', $creds['user_login'] ); if ( $user_data && ! is_user_member_of_blog( $user_data->ID, get_current_blog_id() ) ) { add_user_to_blog( get_current_blog_id(), $user_data->ID, 'customer' ); } } // Perform the login $user = wp_signon( apply_filters( $filter_prefix . '_login_credentials', $creds ), is_ssl() ); if ( ! is_wp_error( $user ) ) { $result = true; } } catch ( Exception $e ) { $result = false; } } if ( $result ) { echo json_encode( array( 'loggedin' => true, 'message' => esc_html__( 'Login successful, redirecting...', 'alpus' ), ) ); } else { echo json_encode( array( 'loggedin' => false, 'message' => esc_html__( 'Wrong username or password.', 'alpus' ), ) ); } die(); } } /** * Account signup validate * * @since 1.0 */ if ( ! function_exists( 'alpus_account_signup_validate' ) ) { function alpus_account_signup_validate() { if ( class_exists( 'WooCommerce' ) ) { $filter_prefix = 'woocommerce'; } else { $filter_prefix = 'alpus'; } $nonce_value = isset( $_POST['_wpnonce'] ) ? $_POST['_wpnonce'] : ''; $nonce_value = isset( $_POST[ $filter_prefix . '-register-nonce' ] ) ? $_POST[ $filter_prefix . '-register-nonce' ] : $nonce_value; $result = false; if ( wp_verify_nonce( $nonce_value, $filter_prefix . '-register' ) ) { if ( class_exists( 'WooCommerce' ) ) { $username = 'no' == get_option( 'woocommerce_registration_generate_username' ) ? $_POST['username'] : ''; $password = 'no' == get_option( 'woocommerce_registration_generate_password' ) ? $_POST['password'] : ''; $email = $_POST['email']; } else { $username = isset( $_POST['username'] ) ? $_POST['username'] : ''; $password = isset( $_POST['password'] ) ? $_POST['password'] : ''; $email = $_POST['email']; } try { $validation_error = new WP_Error(); $validation_error = apply_filters( $filter_prefix . '_process_registration_errors', $validation_error, $username, $password, $email ); if ( $validation_error->get_error_code() ) { echo json_encode( array( 'loggedin' => false, 'message' => $validation_error->get_error_message(), ) ); die(); } if ( class_exists( 'WooCommerce' ) ) { $new_customer = wc_create_new_customer( sanitize_email( $email ), wc_clean( $username ), $password ); if ( is_wp_error( $new_customer ) ) { echo json_encode( array( 'loggedin' => false, 'message' => $new_customer->get_error_message(), ) ); die(); } if ( apply_filters( 'woocommerce_registration_auth_new_customer', true, $new_customer ) ) { wc_set_customer_auth_cookie( $new_customer ); $result = true; } } else { if ( empty( $username ) || empty( $email ) ) { echo json_encode( array( 'loggedin' => false, 'message' => '' . esc_html__( 'Error:', 'alpus' ) . ' ' . esc_html__( 'Username and Email both are required.', 'alpus' ), ) ); die(); } $new_customer_data = apply_filters( 'alpus_new_customer_data', array( 'user_login' => $username, 'user_pass' => wp_generate_password(), 'user_email' => $email, 'role' => 'customer', ) ); $customer_id = wp_insert_user( $new_customer_data ); if ( $customer_id ) { wp_set_current_user( $customer_id ); wp_set_auth_cookie( $customer_id, true ); $result = true; } } } catch ( Exception $e ) { $result = false; } } if ( $result ) { echo json_encode( array( 'loggedin' => true, 'message' => esc_html__( 'Register successful, redirecting...', 'alpus' ), ) ); } else { echo json_encode( array( 'loggedin' => false, 'message' => esc_html__( 'Register failed.', 'alpus' ), ) ); } die(); } } /** * Load Mobile Menu * * @since 1.0 */ if ( ! function_exists( 'alpus_load_mobile_menu' ) ) { function alpus_load_mobile_menu() { // phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification ?>