<?php
/**
 * Plugin Name: Checkout for Freemius
 * Plugin URI: https://dreamfoxmedia.com/plugins/checkout-for-freemius/
 * Version: 2.2.1
 * Author URI: https://dreamfoxmedia.com
 * Author: Dreamfox
 * Description: Add a Freemius Checkout buy button to sell WordPress plugins and themes with subscriptions, licenses, and one-click payments.
 * Requires at least: 5.8
 * Tested up to: 7.0.4
 * Requires PHP: 7.4
 * WC requires at least: 6.0.0
 * WC tested up to: 11.0.1
 * License: GPLv3 or later
 * License URI: http://www.opensource.org/licenses/gpl-license.php
 * Text Domain: checkout-for-freemius
 * Domain Path: /lang/
 *
 * @Developer : Marco van Loghum Slaterus / Hoang Xuan Hao ( Pamysoft )
 * @fs_premium_only /src/Premium/ /assets/premium
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Bail out early if another copy of this plugin is already loaded, to avoid
// fatal redeclaration errors. Functions below are wrapped in function_exists
// checks because PHP binds unconditional declarations at compile time.
if ( defined( 'CF_FREEMIUS_PLUGIN_VERSION' ) ) {
	return;
}

$cf_freemius_plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ) );
define( 'CF_FREEMIUS_PLUGIN_VERSION', $cf_freemius_plugin_data['Version'] );
define( 'CF_FREEMIUS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'CF_FREEMIUS_CHECKOUT_SCRIPT_HANDLE', 'freemius-checkout-script' );
define( 'CF_FREEMIUS_CHECKOUT_SCRIPT_URL', 'https://checkout.freemius.com/js/v1/' );

if ( ! function_exists( 'cf_freemius_plugin_declare_wc_compatibility' ) ) {
	/**
	 * Declare compatibility with WooCommerce features (HPOS and cart/checkout blocks).
	 *
	 * The plugin does not touch WooCommerce order data, so it is fully compatible.
	 */
	function cf_freemius_plugin_declare_wc_compatibility() {
		if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
			\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
			\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
		}
	}
}
add_action( 'before_woocommerce_init', 'cf_freemius_plugin_declare_wc_compatibility' );

if ( ! function_exists( 'cf_freemius_plugin_register_scripts' ) ) {
	/**
	 * Register the Freemius checkout script for later enqueueing.
	 *
	 * Hooked to init (not wp_enqueue_scripts) because block themes render
	 * template content before wp_head, and inline scripts attached to an
	 * unregistered handle are silently dropped.
	 */
	function cf_freemius_plugin_register_scripts() {
		wp_register_script(
			CF_FREEMIUS_CHECKOUT_SCRIPT_HANDLE,
			CF_FREEMIUS_CHECKOUT_SCRIPT_URL,
			array(),
			CF_FREEMIUS_PLUGIN_VERSION,
			true
		);
	}
}
add_action( 'init', 'cf_freemius_plugin_register_scripts' );

if ( ! function_exists( 'cf_freemius_plugin_build_inline_script' ) ) {
	/**
	 * Build per-button checkout initialization JavaScript.
	 *
	 * @param array  $config    Checkout configuration.
	 * @param string $button_id Button element ID.
	 * @return string
	 */
	function cf_freemius_plugin_build_inline_script( array $config, $button_id ) {
		$config_json    = wp_json_encode( $config );
		$button_id_json = wp_json_encode( $button_id );

		if ( false === $config_json || false === $button_id_json ) {
			return '';
		}

		return '(function(){'
			. 'var cfg=' . $config_json . ';'
			. 'var buttonId=' . $button_id_json . ';'
			. 'var button=document.getElementById(buttonId);'
			. 'if(!button||typeof FS==="undefined"||!FS.Checkout){return;}'
			. 'var checkout=new FS.Checkout({'
			. 'product_id:String(cfg.product_id||""),'
			. 'plan_id:cfg.plan_id||undefined,'
			. 'public_key:cfg.public_key||undefined,'
			. 'pricing_id:cfg.pricing_id||undefined,'
			. 'image:cfg.image||undefined'
			. '});'
			. 'button.addEventListener("click",function(event){'
			. 'event.preventDefault();'
			. 'checkout.open({'
			. 'name:cfg.name||undefined,'
			. 'success:function(response){'
			. 'if(response&&response.user&&response.user.email){alert(response.user.email);}'
			. '}'
			. '});'
			. '});'
			. '})();';
	}
}

if ( ! function_exists( 'cf_freemius_plugin_enqueue_checkout_assets' ) ) {
	/**
	 * Enqueue checkout assets and attach button-specific initialization.
	 *
	 * @param array  $config    Checkout configuration.
	 * @param string $button_id Button element ID.
	 */
	function cf_freemius_plugin_enqueue_checkout_assets( array $config, $button_id ) {
		if ( ! wp_script_is( CF_FREEMIUS_CHECKOUT_SCRIPT_HANDLE, 'registered' ) ) {
			cf_freemius_plugin_register_scripts();
		}

		wp_enqueue_script( CF_FREEMIUS_CHECKOUT_SCRIPT_HANDLE );

		$inline_script = cf_freemius_plugin_build_inline_script( $config, $button_id );
		if ( '' !== $inline_script ) {
			wp_add_inline_script( CF_FREEMIUS_CHECKOUT_SCRIPT_HANDLE, $inline_script );
		}
	}
}

if ( ! function_exists( 'cf_freemius_plugin_shortcode' ) ) {
	/**
	 * Freemius Checkout Shortcode.
	 *
	 * @param array $atts Shortcode attributes.
	 * @return string
	 */
	function cf_freemius_plugin_shortcode( $atts ) {
		static $instance = 0;

		$atts = shortcode_atts(
			array(
				'plugin_id'    => '',
				'plan_id'      => '',
				'pricing_id'   => '',
				'public_key'   => '',
				'image'        => '',
				'name'         => '',
				'button'       => esc_html__( 'Buy Now', 'checkout-for-freemius' ),
				'button_id'    => 'purchase',
				'button_class' => '',
			),
			$atts,
			'checkout-for-freemius'
		);

		if ( '' === $atts['plugin_id'] || '' === $atts['public_key'] ) {
			return '';
		}

		++$instance;

		if ( 1 === $instance ) {
			$button_id = sanitize_html_class( $atts['button_id'] );
		} elseif ( 'purchase' === $atts['button_id'] ) {
			$button_id = 'cf-freemius-purchase-' . $instance;
		} else {
			$button_id = sanitize_html_class( $atts['button_id'] );
		}

		$config = array(
			'product_id' => sanitize_text_field( $atts['plugin_id'] ),
			'plan_id'    => '' !== $atts['plan_id'] ? absint( $atts['plan_id'] ) : null,
			'pricing_id' => '' !== $atts['pricing_id'] ? absint( $atts['pricing_id'] ) : null,
			'public_key' => sanitize_text_field( $atts['public_key'] ),
			'image'      => esc_url_raw( $atts['image'] ),
			'name'       => sanitize_text_field( $atts['name'] ),
		);

		cf_freemius_plugin_enqueue_checkout_assets( $config, $button_id );

		ob_start();
		?>
		<button
			type="button"
			id="<?php echo esc_attr( $button_id ); ?>"
			class="<?php echo esc_attr( $atts['button_class'] ); ?>"
		>
			<?php echo esc_html( $atts['button'] ); ?>
		</button>
		<?php
		return ob_get_clean();
	}
}

add_shortcode( 'checkout-for-freemius', 'cf_freemius_plugin_shortcode' );
add_shortcode( 'freemius_checkout', 'cf_freemius_plugin_shortcode' );
add_shortcode( 'cf_freemius_plugin_checkout_for_freemius', 'cf_freemius_plugin_shortcode' );

if ( ! function_exists( 'cf_freemius_plugin_add_admin_menu' ) ) {
	/**
	 * Add admin menu and submenu items.
	 */
	function cf_freemius_plugin_add_admin_menu() {
		add_menu_page(
			esc_html__( 'DFM Plugins', 'checkout-for-freemius' ),
			esc_html__( 'DFM Plugins', 'checkout-for-freemius' ),
			'manage_options',
			'dfm-plugins',
			'cf_freemius_plugin_plugins_page',
			'dashicons-admin-generic',
			6
		);

		add_submenu_page(
			'dfm-plugins',
			esc_html__( 'Freemius Checkout', 'checkout-for-freemius' ),
			esc_html__( 'Freemius Checkout', 'checkout-for-freemius' ),
			'manage_options',
			'freemius-checkout',
			'cf_freemius_plugin_checkout_page'
		);
	}
}
add_action( 'admin_menu', 'cf_freemius_plugin_add_admin_menu' );

if ( ! function_exists( 'cf_freemius_plugin_admin_enqueue_scripts' ) ) {
	/**
	 * Enqueue admin styles on plugin settings pages.
	 *
	 * @param string $hook_suffix Current admin page hook suffix.
	 */
	function cf_freemius_plugin_admin_enqueue_scripts( $hook_suffix ) {
		$plugin_pages = array(
			'toplevel_page_dfm-plugins',
			'dfm-plugins_page_freemius-checkout',
		);

		if ( ! in_array( $hook_suffix, $plugin_pages, true ) ) {
			return;
		}

		wp_enqueue_style(
			'cf-freemius-admin',
			CF_FREEMIUS_PLUGIN_URL . 'assets/css/admin.css',
			array(),
			CF_FREEMIUS_PLUGIN_VERSION
		);
	}
}
add_action( 'admin_enqueue_scripts', 'cf_freemius_plugin_admin_enqueue_scripts' );

if ( ! function_exists( 'cf_freemius_plugin_render_settings_banner' ) ) {
	/**
	 * Render the settings page banner image.
	 */
	function cf_freemius_plugin_render_settings_banner() {
		$banner_url = CF_FREEMIUS_PLUGIN_URL . 'assets/images/settings-banner.png';

		echo '<div class="cf-freemius-settings-banner">';
		echo '<img src="' . esc_url( $banner_url ) . '" alt="' . esc_attr__( 'Freemius Checkout - Sell WordPress plugins and themes anywhere', 'checkout-for-freemius' ) . '" />';
		echo '</div>';
	}
}

if ( ! function_exists( 'cf_freemius_plugin_get_dfm_plugins' ) ) {
	/**
	 * List of Dreamfox Media plugins shown on the DFM Plugins page.
	 *
	 * @return array[]
	 */
	function cf_freemius_plugin_get_dfm_plugins() {
		return array(
			array(
				'name'        => __( 'Checkout for Freemius', 'checkout-for-freemius' ),
				'description' => __( 'Sell WordPress plugins and themes anywhere with a Freemius Checkout buy button (this plugin).', 'checkout-for-freemius' ),
				'url'         => 'https://wordpress.org/plugins/checkout-for-freemius/',
			),
			array(
				'name'        => __( 'Delivery Date & Timeslot for WooCommerce', 'checkout-for-freemius' ),
				'description' => __( 'Let customers pick a delivery date and time slot during WooCommerce checkout.', 'checkout-for-freemius' ),
				'url'         => 'https://wordpress.org/plugins/woocommerce-delivery-date/',
			),
			array(
				'name'        => __( 'Payment Gateway Per Product for WooCommerce', 'checkout-for-freemius' ),
				'description' => __( 'Enable or disable specific payment gateways per product or product category.', 'checkout-for-freemius' ),
				'url'         => 'https://wordpress.org/plugins/woocommerce-product-payments/',
			),
			array(
				'name'        => __( 'Shipping Gateway Per Product for WooCommerce', 'checkout-for-freemius' ),
				'description' => __( 'Control which shipping methods are available per product.', 'checkout-for-freemius' ),
				'url'         => 'https://wordpress.org/plugins/woocommerce-shipping-gateway-per-product/',
			),
			array(
				'name'        => __( 'Event Master Plugin', 'checkout-for-freemius' ),
				'description' => __( 'Create and manage events on your WordPress site.', 'checkout-for-freemius' ),
				'url'         => 'https://wordpress.org/plugins/event-master/',
			),
			array(
				'name'        => __( 'Dreamfoxmedia Helpspot Live Lookup', 'checkout-for-freemius' ),
				'description' => __( 'Connect HelpSpot live lookup with your WordPress and WooCommerce customer data.', 'checkout-for-freemius' ),
				'url'         => 'https://wordpress.org/plugins/dreamfox-helpspot-live-lookup/',
			),
		);
	}
}

if ( ! function_exists( 'cf_freemius_plugin_render_sidebar' ) ) {
	/**
	 * Render the shared "Dreamfox Media" (+ optionally sibling-plugins)
	 * sidebar used on the admin pages.
	 *
	 * @param bool $include_plugin_list Whether to also list sibling plugins.
	 *                                  Skipped on the DFM Plugins page, which
	 *                                  already lists them in its main table.
	 */
	function cf_freemius_plugin_render_sidebar( $include_plugin_list = true ) {
		echo '<aside class="cf-freemius-info-sidebar">';

		echo '<div class="cf-freemius-info-card">';
		echo '<h3>' . esc_html__( 'Dreamfox Media', 'checkout-for-freemius' ) . '</h3>';
		echo '<p>' . esc_html__( 'Reliable WordPress and WooCommerce plugins trusted by store owners since 2014.', 'checkout-for-freemius' ) . '</p>';
		echo '<ul class="cf-freemius-info-links">';
		echo '<li><a href="https://dreamfoxmedia.com/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Website', 'checkout-for-freemius' ) . '</a></li>';
		echo '<li><a href="https://dreamfoxmedia.com/plugins" target="_blank" rel="noopener noreferrer">' . esc_html__( 'All plugins', 'checkout-for-freemius' ) . '</a></li>';
		echo '<li><a href="https://help.dreamfoxmedia.com" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Knowledge base', 'checkout-for-freemius' ) . '</a></li>';
		echo '<li><a href="https://dreamfoxmedia.com/support/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Get help / support', 'checkout-for-freemius' ) . '</a></li>';
		echo '<li><a href="https://dreamfoxmedia.com/contact/" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Contact us', 'checkout-for-freemius' ) . '</a></li>';
		echo '</ul>';
		echo '</div>';

		if ( $include_plugin_list ) {
			echo '<div class="cf-freemius-info-card cf-freemius-info-card--muted">';
			echo '<h3>' . esc_html__( 'More plugins by Dreamfox Media', 'checkout-for-freemius' ) . '</h3>';
			echo '<ul class="cf-freemius-info-plugin-list">';
			foreach ( cf_freemius_plugin_get_dfm_plugins() as $dfm_plugin ) {
				echo '<li>';
				echo '<a href="' . esc_url( $dfm_plugin['url'] ) . '" target="_blank" rel="noopener noreferrer">' . esc_html( $dfm_plugin['name'] ) . '</a>';
				echo '<span>' . esc_html( $dfm_plugin['description'] ) . '</span>';
				echo '</li>';
			}
			echo '</ul>';
			echo '</div>';
		}

		echo '</aside>';
	}
}

if ( ! function_exists( 'cf_freemius_plugin_plugins_page' ) ) {
	/**
	 * Render the main DFM Plugins admin page.
	 */
	function cf_freemius_plugin_plugins_page() {
		if ( ! current_user_can( 'manage_options' ) ) {
			return;
		}

		echo '<div class="wrap cf-freemius-settings">';
		echo '<h1>' . esc_html__( 'DFM Plugins', 'checkout-for-freemius' ) . '</h1>';

		echo '<div class="cf-freemius-info-grid">';
		echo '<div class="cf-freemius-info-main">';

		echo '<h2>' . esc_html__( 'About Dreamfox Media', 'checkout-for-freemius' ) . '</h2>';
		echo '<p>' . esc_html__( 'Dreamfox Media builds custom WordPress and WooCommerce plugins, trusted by over 10,000 users. We offer solutions for payments, shipping, delivery dates, and selling digital products.', 'checkout-for-freemius' ) . '</p>';
		echo '<p>';
		echo '<a href="https://dreamfoxmedia.com" target="_blank" rel="noopener noreferrer" class="button button-primary">' . esc_html__( 'Visit dreamfoxmedia.com', 'checkout-for-freemius' ) . '</a> ';
		echo '<a href="https://dreamfoxmedia.com/plugins/" target="_blank" rel="noopener noreferrer" class="button">' . esc_html__( 'Premium plugins portfolio', 'checkout-for-freemius' ) . '</a> ';
		echo '<a href="https://dreamfoxmedia.com/contact/" target="_blank" rel="noopener noreferrer" class="button">' . esc_html__( 'Contact us', 'checkout-for-freemius' ) . '</a>';
		echo '</p>';

		echo '<h2>' . esc_html__( 'Our plugins', 'checkout-for-freemius' ) . '</h2>';
		echo '<table class="widefat striped cf-freemius-plugins-table">';
		echo '<thead><tr>';
		echo '<th>' . esc_html__( 'Plugin', 'checkout-for-freemius' ) . '</th>';
		echo '<th>' . esc_html__( 'Description', 'checkout-for-freemius' ) . '</th>';
		echo '<th>' . esc_html__( 'Link', 'checkout-for-freemius' ) . '</th>';
		echo '</tr></thead><tbody>';

		foreach ( cf_freemius_plugin_get_dfm_plugins() as $dfm_plugin ) {
			echo '<tr>';
			echo '<td><strong>' . esc_html( $dfm_plugin['name'] ) . '</strong></td>';
			echo '<td>' . esc_html( $dfm_plugin['description'] ) . '</td>';
			echo '<td><a href="' . esc_url( $dfm_plugin['url'] ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Learn more', 'checkout-for-freemius' ) . '</a></td>';
			echo '</tr>';
		}

		echo '</tbody></table>';
		echo '</div>';

		cf_freemius_plugin_render_sidebar( false );

		echo '</div>';
		echo '</div>';
	}
}

if ( ! function_exists( 'cf_freemius_plugin_checkout_page' ) ) {
	/**
	 * Render the Freemius Checkout admin page.
	 */
	function cf_freemius_plugin_checkout_page() {
		if ( ! current_user_can( 'manage_options' ) ) {
			return;
		}

		echo '<div class="wrap cf-freemius-settings">';
		echo '<h1>' . esc_html__( 'Freemius Checkout', 'checkout-for-freemius' ) . '</h1>';

		echo '<div class="cf-freemius-info-grid">';
		echo '<div class="cf-freemius-info-main">';

		cf_freemius_plugin_render_settings_banner();

		echo '<p>' . esc_html__( 'Turn any page into a sales page. Drop in a shortcode and start selling plugin, theme, or SaaS licenses through the official Freemius Checkout overlay — no custom payment integration required.', 'checkout-for-freemius' ) . '</p>';

		echo '<h2>' . esc_html__( 'How to use the shortcode', 'checkout-for-freemius' ) . '</h2>';
		echo '<p>' . esc_html__( 'Add the [checkout-for-freemius] or [freemius_checkout] shortcode to any page or post to show a Freemius buy button. You will find your product ID, plan ID, pricing ID, and public key in the Freemius Developer Dashboard.', 'checkout-for-freemius' ) . '</p>';

		echo '<h3>' . esc_html__( 'Shortcode parameters', 'checkout-for-freemius' ) . '</h3>';
		echo '<table class="widefat striped cf-freemius-params-table">';
		echo '<thead><tr>';
		echo '<th>' . esc_html__( 'Parameter', 'checkout-for-freemius' ) . '</th>';
		echo '<th>' . esc_html__( 'Required', 'checkout-for-freemius' ) . '</th>';
		echo '<th>' . esc_html__( 'Description', 'checkout-for-freemius' ) . '</th>';
		echo '</tr></thead><tbody>';

		$cf_params = array(
			array( 'plugin_id', __( 'Yes', 'checkout-for-freemius' ), __( 'Your Freemius product ID (plugin, theme, or bundle).', 'checkout-for-freemius' ) ),
			array( 'public_key', __( 'Yes', 'checkout-for-freemius' ), __( 'Your Freemius public key (starts with pk_).', 'checkout-for-freemius' ) ),
			array( 'name', __( 'No', 'checkout-for-freemius' ), __( 'Product name shown in the checkout popup.', 'checkout-for-freemius' ) ),
			array( 'plan_id', __( 'No', 'checkout-for-freemius' ), __( 'The plan to preselect. Defaults to the cheapest visible plan.', 'checkout-for-freemius' ) ),
			array( 'pricing_id', __( 'No', 'checkout-for-freemius' ), __( 'A specific pricing tier (e.g. a multi-site license).', 'checkout-for-freemius' ) ),
			array( 'image', __( 'No', 'checkout-for-freemius' ), __( 'HTTPS URL of your product logo, shown in the popup.', 'checkout-for-freemius' ) ),
			array( 'button', __( 'No', 'checkout-for-freemius' ), __( 'Button label. Default: Buy Now.', 'checkout-for-freemius' ) ),
			array( 'button_id', __( 'No', 'checkout-for-freemius' ), __( 'HTML id of the button. Default: purchase. Use a unique id per button when placing multiple buttons on one page.', 'checkout-for-freemius' ) ),
			array( 'button_class', __( 'No', 'checkout-for-freemius' ), __( 'Extra CSS classes for styling the button.', 'checkout-for-freemius' ) ),
		);

		foreach ( $cf_params as $cf_param ) {
			echo '<tr>';
			echo '<td><code>' . esc_html( $cf_param[0] ) . '</code></td>';
			echo '<td>' . esc_html( $cf_param[1] ) . '</td>';
			echo '<td>' . esc_html( $cf_param[2] ) . '</td>';
			echo '</tr>';
		}

		echo '</tbody></table>';

		echo '<h3>' . esc_html__( 'Examples', 'checkout-for-freemius' ) . '</h3>';

		echo '<p><strong>' . esc_html__( '1. Minimal buy button', 'checkout-for-freemius' ) . '</strong><br />';
		echo esc_html__( 'Only the required fields. The checkout opens with your default plan and pricing.', 'checkout-for-freemius' ) . '</p>';
		echo '<p><code>[checkout-for-freemius plugin_id="1234" public_key="pk_xxxxxxxxxxxxxxxxxxxxxxxxx"]</code></p>';

		echo '<p><strong>' . esc_html__( '2. Specific plan with product name and custom label', 'checkout-for-freemius' ) . '</strong><br />';
		echo esc_html__( 'Preselects a plan and shows your product name in the popup.', 'checkout-for-freemius' ) . '</p>';
		echo '<p><code>[checkout-for-freemius name="My Awesome Plugin" plugin_id="1234" plan_id="5678" public_key="pk_xxxxxxxxxxxxxxxxxxxxxxxxx" button="Get Pro"]</code></p>';

		echo '<p><strong>' . esc_html__( '3. Full example with pricing tier, logo, and styling', 'checkout-for-freemius' ) . '</strong><br />';
		echo esc_html__( 'Preselects a multi-site pricing tier, shows your logo, and styles the button with your own CSS class.', 'checkout-for-freemius' ) . '</p>';
		echo '<p><code>[checkout-for-freemius name="My Awesome Plugin" plugin_id="1234" plan_id="5678" pricing_id="91011" public_key="pk_xxxxxxxxxxxxxxxxxxxxxxxxx" image="https://example.com/logo-100x100.png" button="Buy 5-Site License" button_class="my-buy-button"]</code></p>';

		echo '<p><strong>' . esc_html__( '4. Two buttons on one page', 'checkout-for-freemius' ) . '</strong><br />';
		echo esc_html__( 'Give each button a unique button_id.', 'checkout-for-freemius' ) . '</p>';
		echo '<p><code>[checkout-for-freemius name="Plugin A" plugin_id="1234" public_key="pk_xxx" button_id="buy-plugin-a"]</code><br />';
		echo '<code>[checkout-for-freemius name="Plugin B" plugin_id="5678" public_key="pk_yyy" button_id="buy-plugin-b"]</code></p>';

		echo '<h3>' . esc_html__( 'Screenshots', 'checkout-for-freemius' ) . '</h3>';
		$cf_screenshots = array(
			array(
				'src' => CF_FREEMIUS_PLUGIN_URL . 'assets/images/screenshot-1.jpg',
				'alt' => __( 'DFM Plugins admin page', 'checkout-for-freemius' ),
			),
			array(
				'src' => CF_FREEMIUS_PLUGIN_URL . 'assets/images/screenshot-2.jpg',
				'alt' => __( 'Freemius Checkout shortcode documentation', 'checkout-for-freemius' ),
			),
		);
		echo '<div class="cf-freemius-screenshots">';
		foreach ( $cf_screenshots as $cf_i => $cf_shot ) {
			echo '<a href="#cf-freemius-lightbox-' . absint( $cf_i ) . '" class="cf-freemius-screenshot-thumb">';
			echo '<img src="' . esc_url( $cf_shot['src'] ) . '" alt="' . esc_attr( $cf_shot['alt'] ) . '" />';
			echo '</a>';
		}
		echo '</div>';
		foreach ( $cf_screenshots as $cf_i => $cf_shot ) {
			echo '<a href="#_" id="cf-freemius-lightbox-' . absint( $cf_i ) . '" class="cf-freemius-lightbox">';
			echo '<img src="' . esc_url( $cf_shot['src'] ) . '" alt="' . esc_attr( $cf_shot['alt'] ) . '" />';
			echo '</a>';
		}

		echo '</div>';

		cf_freemius_plugin_render_sidebar( true );

		echo '</div>';
		echo '</div>';
	}
}
