PHP 8.2.31
Preview: plans.php Size: 1.89 KB
/home/nshryvcy/himaltourism.com/wp-content/plugins/jetpack/_inc/lib/plans.php

<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
 * Plans Library
 *
 * Fetch plans data from WordPress.com.
 *
 * Not to be confused with the `Jetpack_Plan` (singular)
 * class, which stores and syncs data about the site's _current_ plan.
 *
 * @package automattic/jetpack
 */
class Jetpack_Plans {
	/**
	 * Get a list of all available plans from WordPress.com
	 *
	 * @since 7.7.0
	 *
	 * @return array The plans list
	 */
	public static function get_plans() {
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
			if ( ! class_exists( 'Store_Product_List' ) ) {
				require WP_CONTENT_DIR . '/admin-plugins/wpcom-billing/store-product-list.php';
			}

			return Store_Product_List::api_only_get_active_plans_v1_4();
		}

		// We're on Jetpack, so it's safe to use this namespace.
		$request = Automattic\Jetpack\Connection\Client::wpcom_json_api_request_as_user(
			'/plans?_locale=' . get_user_locale(),
			// We're using version 1.5 of the endpoint rather than the default version 2
			// since the latter only returns Jetpack Plans, but we're also interested in
			// WordPress.com plans, for consumers of this method that run on WP.com.
			'1.5',
			array(
				'method'  => 'GET',
				'headers' => array(
					'X-Forwarded-For' => ( new Automattic\Jetpack\Status\Visitor() )->get_ip( true ),
				),
			),
			null,
			'rest'
		);

		$body = wp_remote_retrieve_body( $request );
		if ( 200 === wp_remote_retrieve_response_code( $request ) ) {
			return json_decode( $body );
		} else {
			return $body;
		}
	}

	/**
	 * Get plan information for a plan given its slug
	 *
	 * @since 7.7.0
	 *
	 * @param string $plan_slug Plan slug.
	 *
	 * @return object The plan object
	 */
	public static function get_plan( $plan_slug ) {
		$plans = self::get_plans();
		if ( ! is_array( $plans ) ) {
			return;
		}

		foreach ( $plans as $plan ) {
			if ( $plan_slug === $plan->product_slug ) {
				return $plan;
			}
		}
	}
}

Directory Contents

Dirs: 4 × Files: 31

Name Size Perms Modified Actions
- drwxr-xr-x 2023-04-04 05:35:21
Edit Download
core-api DIR
- drwxr-xr-x 2023-04-04 05:35:21
Edit Download
debugger DIR
- drwxr-xr-x 2023-04-04 05:35:21
Edit Download
markdown DIR
- drwxr-xr-x 2023-04-04 05:35:21
Edit Download
7.59 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
4.52 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
3.58 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
2.91 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
3.16 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
3.58 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
19.89 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
16.85 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
58.82 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
214 B lrw-r--r-- 2023-04-04 05:35:21
Edit Download
20.88 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
134.21 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
229 B lrw-r--r-- 2023-04-04 05:35:21
Edit Download
3.10 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
9.03 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
32.44 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
4.51 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
6.10 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
3.62 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
20.44 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
14.98 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
15.75 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
2.64 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
1.12 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
18.90 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
32.74 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
344 B lrw-r--r-- 2023-04-04 05:35:21
Edit Download
1.89 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
209 B lrw-r--r-- 2023-04-04 05:35:21
Edit Download
6.23 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download
26.28 KB lrw-r--r-- 2023-04-04 05:35:21
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).