示例#1
0
 public static function render_tab_pricing_style()
 {
     ProSites_View_Pricing_Styling::render_tab_pricing_style();
 }
示例#2
0
	function checkout_page_load( $query ) {

		$x = '';
		//don't check on other blogs
		if ( ! is_main_site() ) {
			return;
		}

		//prevent weird redo when theme has multiple query loops
		if ( $this->checkout_processed ) {
			return;
		}

		// using get_queried_object_id() causes child forums in bbpress to give 404 results.
		$queried_object_id = intval( isset( $query->queried_object_id ) ? $query->queried_object_id : 0 );

		//check if on checkout page or exit
		if ( ! $this->get_setting( 'checkout_page' ) || $queried_object_id != $this->get_setting( 'checkout_page' ) ) {

			return;
		}

		//force ssl on the checkout page if required by gateway force if admin is forced (because user will be logged in)
		if ( ( apply_filters( 'psts_force_ssl', false ) && ! is_ssl() ) || ( force_ssl_admin() && ! is_ssl() ) ) {
			wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
			exit();
		}

		//passed all checks, flip one time flag
		$this->checkout_processed = true;

		//remove all filters except shortcodes and checkout form
		remove_all_filters( 'the_content' );
		add_filter( 'the_content', 'do_shortcode' );

		/**
		 * Responsible for checkout page
		 */
		add_filter( 'the_content', array( &$this, 'checkout_output' ), 15 );
		/**
		 * @todo: come back to this one
		 */
		do_action( 'psts_checkout_page_load'); //for gateway plugins to hook into

		wp_enqueue_script( 'psts-checkout', $this->plugin_url . 'js/checkout.js', array( 'jquery' ), $this->version );
		wp_enqueue_script( 'jquery-ui-tabs' );

		wp_localize_script( 'psts-checkout', 'prosites_checkout', array(
			'ajax_url' => ProSites_Helper_ProSite::admin_ajax_url(),
			'confirm_cancel' => __( "Please note that if you cancel your subscription you will not be immune to future price increases. The price of un-canceled subscriptions will never go up!\n\nAre you sure you really want to cancel your subscription?\nThis action cannot be undone!", 'psts'),
			'button_signup' => __( "Sign Up", 'psts' ),
			'button_choose' => __( "Choose Plan", 'psts' ),
			'button_chosen' => __( "Chosen Plan", 'psts' ),
			'logged_in' => is_user_logged_in(),
		) );

		if ( ! current_theme_supports( 'psts_style' ) ) {
			wp_enqueue_style( 'psts-checkout', $this->plugin_url . 'css/checkout.css', false, $this->version );
			wp_enqueue_style( 'dashicons' ); // in case it hasn't been loaded yet

			/* Checkout layout */
			$layout_option = $this->get_setting( 'pricing_table_layout', 'option1' );
			$checkout_layout = apply_filters( 'prosites_checkout_css', $this->plugin_url . 'css/pricing-tables/' . $layout_option . '.css' );
			wp_enqueue_style( 'psts-checkout-layout', $checkout_layout, false, $this->version );

			/* Apply styles from options */
			$checkout_style = ProSites_View_Pricing_Styling::get_styles_from_options();
			if( ! empty( $checkout_style ) ) {
				wp_add_inline_style( 'psts-checkout-layout', $checkout_style );
			};

		}
		if ( $this->get_setting( 'plans_table_enabled' ) || $this->get_setting( 'comparison_table_enabled' ) ) {
			wp_enqueue_style( 'psts-plans-pricing', $this->plugin_url . 'css/plans-pricing.css', false, $this->version );
		}

		//setup error var
		$this->errors = new WP_Error();

		//set blog_id
		$blog_id = false;
		$domain  = false;

		if ( isset( $_POST['bid'] ) ) {
			$blog_id = intval( $_POST['bid'] );
		} else if ( isset( $_GET['bid'] ) ) {
			$blog_id = intval( $_GET['bid'] );
		}

		// Set domain if in session
		$domain = ProSites_Helper_Session::session( 'domain' );

		if ( $blog_id || $domain ) {

			add_filter( 'the_title', array( &$this, 'page_title_output' ), 99, 2 );
			add_filter( 'bp_page_title', array( &$this, 'page_title_output' ), 99, 2 );

			$use_pricing_table = $this->get_setting( 'comparison_table_enabled' ) ? $this->get_setting( 'comparison_table_enabled' ) : $this->get_setting( 'co_pricing' );
			if ( $use_pricing_table === "enabled" ) {
				add_filter( 'psts_checkout_screen_before_grid', array( &$this, 'checkout_trial_msg' ), 10, 2 );
			}

			//clear coupon if link clicked
			if ( isset( $_GET['remove_coupon'] ) ) {
				ProSites_Helper_Session::unset_session( 'COUPON_CODE' );
			}

			//check for coupon session variable
			if ( $session_coupon = ProSites_Helper_Session::session( 'COUPON_CODE' ) ) {
				if ( $this->check_coupon( $session_coupon, $blog_id, intval( @$_POST['level'] ), $_POST['period'], '' ) ) {
					$coupon = true;
				} else {
					if ( isset( $_POST['level'] ) && is_numeric( $_POST['level'] ) ) {
						$this->errors->add( 'coupon', __( 'Sorry, the coupon code you entered is not valid for your chosen level.', 'psts' ) );
					} else {
						$this->errors->add( 'coupon', __( 'Whoops! The coupon code you entered is not valid.', 'psts' ) );
						ProSites_Helper_Session::unset_session( 'COUPON_CODE' );
					}
				}
			}

			if ( isset( $_POST['coupon-submit'] ) ) {
				$code   = preg_replace( '/[^A-Z0-9_-]/', '', strtoupper( $_POST['coupon_code'] ) );
				$coupon = $this->check_coupon( $code, $blog_id );
				if ( $coupon ) {
					ProSites_Helper_Session::session( 'COUPON_CODE', $code );
					$this->log_action( $blog_id, __( "User added a valid coupon to their order on the checkout page:", 'psts' ) . ' ' . $code, $domain );
				} else {
					$this->errors->add( 'coupon', __( 'Whoops! The coupon code you entered is not valid.', 'psts' ) );
					$this->log_action( $blog_id, __( "User attempted to add an invalid coupon to their order on the checkout page:", 'psts' ) . ' ' . $code, $domain );
				}
			}
		} else {
			//code for unique coupon links
			if ( isset( $_GET['coupon'] ) ) {
				$code = preg_replace( '/[^A-Z0-9_-]/', '', strtoupper( $_GET['coupon'] ) );
				if ( $this->check_coupon( $code ) ) {
					ProSites_Helper_Session::session( 'COUPON_CODE', $code );
				}
			}
		}
	}