-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview.php
More file actions
163 lines (144 loc) · 5.75 KB
/
preview.php
File metadata and controls
163 lines (144 loc) · 5.75 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
require_once 'preview/config.php';
require_once 'preview/functions.php';
/**
* Redirect ASAP, need to be done using JS
*/
if( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
if( FALSE !== strstr( $_SERVER['HTTP_REFERER'], 'themeforest.net' ) ) {
?>
<!DOCTYPE html>
<html>
<head>
<script>window.top.location.href = "<?php echo BASE_URL; ?>?theme=<?php echo htmlspecialchars($_GET['theme']); ?>";</script>
</head>
<body></body>
</html>
<?php
exit;
}
}
/**
* Check for current item
*/
if( key_exists( @$_GET['theme'], $items ) ) {
$item = $items[$_GET['theme']];
} else {
$item = array(
'title' => FALLBACK_ITEM_TITLE_PREFIX.ENVATO_USERNAME,
'title_short' => FALLBACK_ITEM_TITLE_SHORT,
'url' => FALLBACK_ITEM_URL,
'demo_url' => FALLBACK_ITEM_URL,
'price' => '',
);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?php echo $item['title']; ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Demo theme preview">
<meta name="author" content="<?php echo AUTHOR; ?>">
<!-- = CSS stylesheets = -->
<link rel="stylesheet" href="<?php echo BASE_URL; ?>preview/stylesheets/style.css" type="text/css" media="all" />
<!-- Fav icon -->
<link rel="shortcut icon" href="<?php echo BASE_DOMAIN; ?>/favicon.ico">
<script src="<?php echo BASE_URL; ?>preview/js/main.js?ver=<?php echo ASSETS_VERSION; ?>" async></script>
<!-- fb tracking pixel -->
<?php if ( defined( 'FB_TRACKING_PX' ) && ! empty( FB_TRACKING_PX ) ): ?>
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) {
var fbds = document.createElement('script');
fbds.async = true;
fbds.src = '//connect.facebook.net/en_US/fbds.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(fbds, s);
_fbq.loaded = true;
}
_fbq.push(['addPixelId', '<?php echo FB_TRACKING_PX; ?>']);
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', 'PixelInitialized', {}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?id=<?php echo FB_TRACKING_PX; ?>&ev=PixelInitialized" /></noscript>
<?php endif; ?>
</head>
<body>
<?php if ( defined( 'GA_ID' ) && ! empty( GA_ID ) ): ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('require', 'linker');
// property for the preview bar
ga('create', '<?php echo GA_ID; ?>', 'auto');
ga('send', 'pageview');
<?php if ( has_analytics( $item ) ) : ?>
// property for the item being shown
ga('create', '<?php echo $item['analytics']['tracking_id']; ?>', 'auto', {'allowLinker': true, 'name': 'itemShown'});
ga('linker:autoLink', ['<?php echo implode( "', '", $item['analytics']['allowed_domains'] ); ?>'] );
ga('itemShown.send', 'pageview');
<?php endif; ?>
</script>
<?php endif; ?>
<div class="preview" id="custom-preview-bar">
<!-- Envato Logo -->
<div class="preview-bar__logo">
<a href="<?php echo LOGO_LINK; ?>">Envato Market</a>
</div>
<!-- Select Theme -->
<div class="preview-bar__select-theme">
<?php echo $item['title_short']; ?>
<ul class="preview-bar__select-theme__all-themes">
<?php foreach($items as $slug => $single_item) : ?>
<li><a href="<?php echo site_url('?theme=' . $slug); ?>"><?php echo $single_item['title_short']; ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<!-- Made by -->
<span class="preview-bar__proteusthemes">made by <a href="<?php echo MADE_BY_LINK; ?>" target="_blank"><?php echo MADE_BY_TEXT; ?></a></span>
<!-- Close Frame -->
<a class="preview-bar__remove-frame js-link-to-demo" href="<?php echo $item['demo_url']; ?>" title="Close This Frame">
<!--<img class="preview-bar__remove-frame__x" src="preview-bar/images/"> <span class="preview-bar__remove-frame__text">Remove Frame</span> -->
</a>
<!-- Buy Now Button -->
<a class="preview-bar__purchase-button" href="<?php echo $item['url']; ?>&ref=<?php echo ENVATO_USERNAME; ?>">Buy now</a>
<!-- Mobile/Tablet/Desktop switcher -->
<div class="preview-bar__switcher js-switcher">
<a href="#" class="switcher-btn switcher-btn--active switcher--desktop" data-switchto="desktop"><span></span></a>
<a href="#" class="switcher-btn switcher--tablet" data-switchto="tablet"><span></span></a>
<a href="#" class="switcher-btn switcher--mobile" data-switchto="mobile"><span></span></a>
</div>
</div>
<div id="iframe-holder" class="desktop">
<?php if ( has_analytics( $item ) ): ?>
<script>
/**
* Dynamically create the iframe with the proper linker for analytics
*/
var linker;
function addiFrame( divId, url, opt_hash ) {
return function( tracker ) {
window.linker = window.linker || new window.gaplugins.Linker( tracker );
var iFrame = document.createElement( 'iFrame' );
iFrame.src = window.linker.decorate( url, opt_hash );
iFrame.id = 'main-preview-frame';
iFrame.setAttribute( 'frameborder', '0' );
document.getElementById( divId ).appendChild( iFrame );
calcHeight();
};
}
// Dynamically add the iFrame to the page with proper linker parameters.
ga( addiFrame( 'iframe-holder', '<?php echo $item['demo_url']; ?>' ) );
</script>
<?php else : ?>
<iframe src="<?php echo $item['demo_url']; ?>" frameborder="0" id="main-preview-frame"></iframe>
<?php endif; ?>
<div class="qr-code"><div class="qr-label">Mobile demo preview:</div></div>
</div>
</body>
</html>