BSF_Envato_Activate::envato_register( array $args )

Envato Register.


Description


Parameters

$args

(array) (Required) Arguments.


Source

File: admin/bsf-core/class-bsf-envato-activate.php

	public function envato_register( $args ) {

		// Check if alternate method is to be used.
		$method = ( isset( $_GET['activation_method'] ) && isset( $_GET['bsf_activation_nonce'] ) && wp_verify_nonce( $_GET['bsf_activation_nonce'], 'bsf_activation_nonce' ) ) ? esc_attr( $_GET['activation_method'] ) : 'oauth';

		$html         = '';
		$product_id   = isset( $args['product_id'] ) ? $args['product_id'] : '';
		$is_active    = $this->license_manager->bsf_is_active_license( $product_id );
		$product_name = $this->license_manager->bsf_get_product_info( $product_id, 'name' );
		$purchase_url = $this->license_manager->bsf_get_product_info( $product_id, 'purchase_url' );

		$bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );

		if ( ! empty( $bundled ) ) {
			$parent_id         = $bundled[0];
			$is_active         = $this->license_manager->bsf_is_active_license( $parent_id );
			$parent_name       = brainstrom_product_name( $parent_id );
			$registration_page = bsf_registration_page_url( '', $parent_id );

			$html .= '<div class="bundled-product-license-registration">';
			$html .= '<span>';

			if ( $is_active ) {

				$html .= '<h3>License Active!</h3>';

				$html .= '<p>' . sprintf(
					'Your license is activated, you will receive updates for <i>%s</i> when they are available.',
					$product_name
				) . '</p>';
			} else {

				$html .= '<h3>Updates Unavailable!</h3>';
				$html .= '<p>' . sprintf(
					'This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to activate license of <i>%2$s</i> <a href="%3$s">here</a>.',
					$parent_name,
					$parent_name,
					$registration_page
				) . '</p>';
			}

			$html .= '</span>';
			$html .= '</div>';

			return $html;
		}

		if ( 'license-key' === $method ) {
			$html .= bsf_license_activation_form( $args );

			return $html;
		}

		// Licence activation button.
		$form_action                  = ( isset( $args['form_action'] ) && ! is_null( $args['form_action'] ) ) ? $args['form_action'] : '';
		$form_class                   = ( isset( $args['form_class'] ) && ! is_null( $args['form_class'] ) ) ? $args['form_class'] : "bsf-license-form-{$product_id}";
		$submit_button_class          = ( isset( $args['submit_button_class'] ) && ! is_null( $args['submit_button_class'] ) ) ? $args['submit_button_class'] : '';
		$license_form_heading_class   = ( isset( $args['bsf_license_form_heading_class'] ) && ! is_null( $args['bsf_license_form_heading_class'] ) ) ? $args['bsf_license_form_heading_class'] : '';
		$license_active_class         = ( isset( $args['bsf_license_active_class'] ) && ! is_null( $args['bsf_license_active_class'] ) ) ? $args['bsf_license_active_class'] : '';
		$license_not_activate_message = ( isset( $args['bsf_license_not_activate_message'] ) && ! is_null( $args['bsf_license_not_activate_message'] ) ) ? $args['bsf_license_not_activate_message'] : '';

		$size                    = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
		$button_text_activate    = ( isset( $args['button_text_activate'] ) && ! is_null( $args['button_text_activate'] ) ) ? __( 'Sign Up & Activate', 'bsf' ) : __( 'Sign Up & Activate', 'bsf' );
		$button_text_deactivate  = ( isset( $args['button_text_deactivate'] ) && ! is_null( $args['button_text_deactivate'] ) ) ? $args['button_text_deactivate'] : __( 'Deactivate License', 'bsf' );
		$placeholder             = ( isset( $args['placeholder'] ) && ! is_null( $args['placeholder'] ) ) ? $args['placeholder'] : 'Enter your license key..';
		$popup_license_form      = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
		$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;

		if ( true === $bsf_license_allow_email ) {
			$form_class .= ' license-form-allow-email ';

			if ( ! $is_active ) {
				$submit_button_class .= ' button-primary button-hero bsf-envato-form-activation ';
			}
		}

		if ( true !== $is_active ) {
			$form_action = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
		} else {
			$form_action = bsf_registration_page_url( '', $product_id );
		}

		$html .= '<div class="envato-license-registration">';

		$html .= '<form method="post" class="' . $form_class . '" action="' . $form_action . '">';

		$html .= wp_nonce_field( 'bsf_license_activation_deactivation_nonce', 'bsf_graupi_nonce', true, false );

		if ( $this->get_message( 'message' ) !== '' ) {
			$html .= '<span class="bsf-license-message license-' . $this->get_message( 'status' ) . '">';
			$html .= $this->get_message( 'message' );
			$html .= '</span>';
		}

		if ( $is_active ) {

			$envato_active_oauth_title    = apply_filters( "envato_active_oauth_title_{$product_id}", 'Updates & Support Registration - <span class="active">Active!</span>' );
			$envato_active_oauth_subtitle = '<span class="active">' . sprintf(
				'Your license is active.',
				$product_name
			) . '</span>';

			$envato_active_oauth_subtitle = apply_filters( "envato_active_oauth_subtitle_{$product_id}", $envato_active_oauth_subtitle );

			if ( $popup_license_form ) {
				$html .= '<div class="bsf-wrap-title">';
				$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
				$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
				$html .= '</div>';

			} else {
				$html .= '<div class="bsf-wrap-title">';
				$html .= '<h3 class="envato-oauth-heading">' . $envato_active_oauth_title . '</h2>';
				$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
				$html .= '</div>';
			}

			$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="License Validated"/>';
			$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';

			$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';

		} else {

			$envato_not_active_oauth_title    = apply_filters( "envato_not_active_oauth_title_{$product_id}", __( 'Updates & Support Registration - <span class="not-active">Not Active!</span>', 'bsf' ) );
			$envato_not_active_oauth_subtitle = apply_filters( "envato_not_active_oauth_subtitle_{$product_id}", __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) );

			if ( $popup_license_form ) {
				$html .= '<div class="bsf-wrap-title">';
				$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
				$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
				$html .= '</div>';
			} else {
				$html .= '<div class="bsf-wrap-title">';
				$html .= '<h3 class="envato-oauth-heading">' . $envato_not_active_oauth_title . '</h2>';
				$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
				$html .= '</div>';
			}

			$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="url" value="' . get_site_url() . '"/>';
			$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="redirect" value="' . $this->get_redirect_url( $product_id ) . '"/>';
			$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="product_id" value="' . $product_id . '"/>';

			$html .= '<input id="bsf-license-privacy-consent" name="bsf_license_manager[privacy_consent]" type="hidden" value="true" />';
			$html .= '<input id="bsf-license-terms-conditions-consent" name="bsf_license_manager[terms_conditions_consent]" type="hidden" value="true" />';

			$html .= '<div class="submit-button-wrap">';
			$html .= '<input type="button" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
			$html .= "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
			$html .= '</div>';
		}

		$html .= '</form>';

		$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );

		$html .= '</div> <!-- envato-license-registration -->';

		if ( isset( $_GET['debug'] ) ) {
			$html .= get_bsf_systeminfo();
		}

		return $html;
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.