Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Last active October 20, 2017 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/96ed597523f8285513cad95df0e94bef to your computer and use it in GitHub Desktop.
Save steveosoule/96ed597523f8285513cad95df0e94bef to your computer and use it in GitHub Desktop.
Miva WordPress Integrations Optimized
<?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;
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment