steveosoule
3/17/2017 - 11:37 PM

Miva WordPress Integrations Optimized

Miva WordPress Integrations Optimized

<?php
	$hostname = $_SERVER['SERVER_NAME'];



	/**
	 * ------------------------
	 * Basic Example
	 * ------------------------
	 * No transients, no password-protection curl methods
	 */
	echo file_get_contents("http://" . $hostname . "/mm5/merchant.mvc?Screen=WP-FOOTER");



	/**
	 * ------------------------
	 * Transient Example
	 * ------------------------
	 */
	 /*
		// Use WP Transients to cache the Miva WP-FOOTER page
		if ( false === ( $miva_wp_footer = get_transient( 'miva_wp_footer' ) ) ) {
			$miva_wp_footer = file_get_contents("http://" . $hostname . "/mm5/merchant.mvc?Screen=WP-FOOTER");
			set_transient( 'miva_wp_footer', $miva_wp_footer, 6 * HOUR_IN_SECONDS );
		}
		echo $miva_wp_footer;
	 */


	/**
	 * ------------------------
	 * Password Protection CURL & Transient Example
	 * ------------------------
	 */
	/*
		// Load In Miva's WP-FOOTER Page
		$wp_footer = get_transient( 'wp_footer' );
		$hostname = $_SERVER['SERVER_NAME'];
		if( $wp_footer === FALSE || isset($_REQUEST['update_miva_hdft']) )
		{
			echo '<!-- !@! Updating WP-FOOTER -->';
			$wp_footer_url = 'https://'.$hostname.'/mm5/merchant.mvc?Screen=WP-FOOTER';

			// create a new cURL resource
			$ch = curl_init();
			// set URL and other appropriate options
			curl_setopt_array($ch, array(
				CURLOPT_URL => $wp_footer_url,
				CURLOPT_USERPWD => 'super:secret',
				CURLOPT_RETURNTRANSFER => TRUE,
				CURLOPT_SSL_VERIFYHOST => 0,
				CURLOPT_SSL_VERIFYPEER => 0
			));

			// grab URL and return the content from the URL
			$wp_footer = curl_exec($ch);

			// close cURL resource, and free up system resources
			curl_close($ch);

			// Save the URL's response in a WordPress Transient to speed-up future page-views
			set_transient( 'wp_footer', $wp_footer, 12*HOUR_IN_SECONDS );
		}
		else {
			echo '<!-- !@! Transiented WP-FOOTER -->';
		}

		// Output the Transiented or Newly cURL'd URL
		echo $wp_footer;
	 */
?>
<?php
	/**
	 * ------------------------
	 * Basic Example
	 * ------------------------
	 * No transients, no password-protection curl methods
	 */
	echo file_get_contents("http://" . $hostname . "/mm5/merchant.mvc?Screen=WP-HEADER");


	/**
	 * ------------------------
	 * Transient Example
	 * ------------------------
	 */
	/*
	 	// Use WP Transients to cache the Miva WP-HEADER page
	 	if ( false === ( $miva_wp_header = get_transient( 'miva_wp_header' ) ) ) {
			$miva_wp_header = file_get_contents("http://" . $hostname . "/mm5/merchant.mvc?Screen=WP-HEADER");
			set_transient( 'miva_wp_header', $miva_wp_header, 6 * HOUR_IN_SECONDS );
		}
		echo $miva_wp_header;
	 */


	/**
	 * ------------------------
	 * Password Protection CURL & Transient Example
	 * ------------------------
	 */
	/*
		// Load In Miva's WP-HEADER Page
		$wp_header = get_transient( 'wp_header' );
		$hostname = $_SERVER['SERVER_NAME'];
		if( $wp_header === FALSE || isset($_REQUEST['update_miva_hdft']) )
		{
			echo '<!-- !@! Updating WP-HEADER -->';
			$wp_header_url = 'https://'.$hostname.'/mm5/merchant.mvc?Screen=WP-HEADER';

			// create a new cURL resource
			$ch = curl_init();

			// set URL and other appropriate options
			curl_setopt_array($ch, array(
				CURLOPT_URL => $wp_header_url,
				CURLOPT_USERPWD => 'super:secret',
				CURLOPT_RETURNTRANSFER => TRUE,
				CURLOPT_SSL_VERIFYHOST => 0,
				CURLOPT_SSL_VERIFYPEER => 0
			));

			// grab URL and return the content from the URL
			$wp_header = curl_exec($ch);

			// close cURL resource, and free up system resources
			curl_close($ch);

			// Save the URL's response in a WordPress Transient to speed-up future page-views
			set_transient( 'wp_header', $wp_header, 12*HOUR_IN_SECONDS );
		} else {
			echo '<!-- !@! Transiented WP-HEADER -->';
		}

		// Output the Transiented or Newly cURL'd URL
		echo $wp_header;
	 */
?>