badge-share.php
2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?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-corp/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>