WC_Admin_Addons::output()public staticWC 1.0

Handles output of the addons page in admin.

Метод класса: WC_Admin_Addons{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$result = WC_Admin_Addons::output();

Код WC_Admin_Addons::output() WC 8.7.0

public static function output() {
	$section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '_featured';
	$search  = isset( $_GET['search'] ) ? sanitize_text_field( wp_unslash( $_GET['search'] ) ) : '';

	if ( isset( $_GET['section'] ) && 'helper' === $_GET['section'] ) {
		do_action( 'woocommerce_helper_output' );
		return;
	}

	if ( isset( $_GET['install-addon'] ) ) {
		switch ( $_GET['install-addon'] ) {
			case 'woocommerce-services':
				self::install_woocommerce_services_addon();
				break;
			case 'woocommerce-payments':
				self::install_woocommerce_payments_addon( $section );
				break;
			default:
				// Do nothing.
				break;
		}
	}

	$sections        = self::get_sections();
	$theme           = wp_get_theme();
	$current_section = isset( $_GET['section'] ) ? $section : '_featured';
	$promotions      = array();
	$addons          = array();

	if ( '_featured' !== $current_section ) {
		$category       = $section ? $section : null;
		$term           = $search ? $search : null;
		$country        = WC()->countries->get_base_country();
		$extension_data = self::get_extension_data( $category, $term, $country );
		$addons         = is_wp_error( $extension_data ) ? $extension_data : $extension_data->products;
		$promotions     = ! empty( $extension_data->promotions ) ? $extension_data->promotions : array();
	}

	// We need Automattic\WooCommerce\Admin\RemoteInboxNotifications for the next part, if not remove all promotions.
	if ( ! WC()->is_wc_admin_active() ) {
		$promotions = array();
	}
	// Check for existence of promotions and evaluate out if we should show them.
	if ( ! empty( $promotions ) ) {
		foreach ( $promotions as $promo_id => $promotion ) {
			$evaluator = new PromotionRuleEngine\RuleEvaluator();
			$passed    = $evaluator->evaluate( $promotion->rules );
			if ( ! $passed ) {
				unset( $promotions[ $promo_id ] );
			}
		}
		// Transform promotions to the correct format ready for output.
		$promotions = self::format_promotions( $promotions );
	}

	/**
	 * Addon page view.
	 *
	 * @uses $addons
	 * @uses $search
	 * @uses $sections
	 * @uses $theme
	 * @uses $current_section
	 */
	include_once dirname( __FILE__ ) . '/views/html-admin-page-addons.php';
}