badge-share.php 2.86 KB
<?php
/*
 * Template Name: Badge share
 */
global $wpdb;


$badge =  str_replace("_",":",str_replace("-"," ", $_GET['badge'] ));
$result = $wpdb->get_row( "SELECT ID FROM wp_posts WHERE `post_title` =  '".$badge."' and `post_type` =  'badges' ");
$thumbnail_id = get_post_meta($result->ID, '_thumbnail_id', true);
?>
<html>
<head>
<title>badge share | The Commonwell</title>
		<link rel="canonical" href="https://thecommonwell.ca/?badge=<?php echo $_GET['badge'];?>&shared=true">
		<meta property="og:site_name" content="The Commonwell | The Commonwell Mutual Insurance Group">
		<meta property="og:type" content="article">
		<meta property="og:title" content="Commonwell College | The Commonwell">
		<meta property="og:description" content="I just earned my <?php echo $badge;?>  badge through the Commonwell College broker education program." />
		<meta property="og:url" content="https://thecommonwell.ca/badge-share/?badge=<?php echo $_GET['badge'];?>&shared=true">
		<meta property="og:image" content="<?php echo wp_get_attachment_url( $thumbnail_id);?> ">
		<meta property="article:published_time" content="2021-05-14T21:48:56Z">
		<meta property="article:modified_time" content="2021-05-14T21:49:01Z">
		<meta property="twitter:card" content="summary">
		<meta property="twitter:domain" content="https://thecommonwell.ca/badge-share/?badge=<?php echo $_GET['badge'];?>&shared=true">
		<meta property="twitter:title" content="Commonwell College | The Commonwell">
		<meta property="fb:app_id" content="1464709127223789"/>
		<!-- All in One SEO -->
        </head>
        <body>       
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const shared = urlParams.get('shared')
if(shared == 'true'){
	window.location.replace("https://thecommonwell.ca/all-badges/");
}else{
	var newUrlIS =  window.location.href + "&shared=true";
	history.pushState({}, null, newUrlIS);
}
</script>
<div id="brokercontent"  style="margin:auto;margin-top:20px;text-align: center;">
<h1 style="font-weight: 400;color: #54565A;font-family: Helvetica, Sans-Serif;">Share Your Badge</h1>
    <div id="page-content" style="margin:auto;margin-top:20px;text-align: center;">

   <?php echo wp_get_attachment_image($thumbnail_id, array('400', '300'), "", array( "class" => "img-responsive" ) ); ?>

	
    </div>
</div>

<script type="text/javascript" src="../wp-content/themes/commonwell-broker/scripts/sharerbox.js?ver=6" id="mc.sharerbox-js"></script>
<script>
window.onload = function(){
	sharerboxIcons('facebook twitter linkedin', 32);
	sharerSetup(behavior = 'popup', position = 'left', color = 'black', visibility = 'true', shareDescription = '')
	};
	
</script>
<style>
#page-content img{
    margin: auto;
}
#sharerbox-share-icon-fig{
	display: none !important;
}
<?php if(!is_user_logged_in()){ ?>
h1,
#sharerbox-section{
	display: none !important;
}

<?php } ?>
</style>
</body>
</html>