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

<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName

use Automattic\Jetpack\Status;

/**
 * Components Library
 *
 * Load and display a pre-rendered component
 */
class Jetpack_Components {
	/**
	 * Load and display a pre-rendered component
	 *
	 * @since 7.7.0
	 *
	 * @param string $name  Component name.
	 * @param array  $props Component properties.
	 *
	 * @return string The component markup
	 */
	public static function render_component( $name, $props ) {

		$rtl = is_rtl() ? '.rtl' : '';
		wp_enqueue_style( 'jetpack-components', plugins_url( "_inc/blocks/components{$rtl}.css", JETPACK__PLUGIN_FILE ), array( 'wp-components' ), JETPACK__VERSION );

		ob_start();
		// `include` fails gracefully and throws a warning, but doesn't halt execution.
		include JETPACK__PLUGIN_DIR . "_inc/blocks/$name.html";
		$markup = ob_get_clean();

		foreach ( $props as $key => $value ) {
			$markup = str_replace(
				"#$key#",
				$value,
				$markup
			);

			// Workaround, required to replace strings in `sprintf`-expressions.
			// See extensions/i18n-to-php.js for more information.
			$markup = str_replace(
				"%($key)s",
				$value,
				$markup
			);
		}

		return $markup;
	}

	/**
	 * Renders the frontend-nudge with the provided props.
	 *
	 * @param array $props Component properties.
	 *
	 * @return string The component markup.
	 */
	public static function render_frontend_nudge( $props ) {
		return self::render_component(
			'frontend-nudge',
			$props
		);
	}

	/**
	 * Load and display a pre-rendered component
	 *
	 * @since 7.7.0
	 *
	 * @param array $props Component properties.
	 *
	 * @return string The component markup
	 */
	public static function render_upgrade_nudge( $props ) {
		$plan_slug = $props['plan'];
		require_once JETPACK__PLUGIN_DIR . '_inc/lib/plans.php';
		$plan = Jetpack_Plans::get_plan( $plan_slug );

		if ( ! $plan ) {
			return self::render_component(
				'upgrade-nudge',
				array(
					'checkoutUrl' => '',
				)
			);
		}

		// WP.com plan objects have a dedicated `path_slug` field, Jetpack plan objects don't.
		$plan_path_slug = wp_startswith( $plan_slug, 'jetpack_' )
			? $plan_slug
			: $plan->path_slug;

		$post_id = get_the_ID();

		$site_slug = ( new Status() )->get_site_suffix();

		// Post-checkout: redirect back to the editor.
		$redirect_to = add_query_arg(
			array(
				'plan_upgraded' => 1,
			),
			get_edit_post_link( $post_id )
		);

		$upgrade_url =
			$plan_path_slug
			? add_query_arg(
				'redirect_to',
				$redirect_to,
				"https://wordpress.com/checkout/{$site_slug}/{$plan_path_slug}"
			) : '';

		return self::render_component(
			'upgrade-nudge',
			array(
				'checkoutUrl' => $upgrade_url,
			)
		);
	}
}

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).