| 1 |
<?php |
| 2 |
/** |
| 3 |
* JavaScript file |
| 4 |
* |
| 5 |
* Main javascript file for plugin |
| 6 |
* |
| 7 |
* @category Components |
| 8 |
* @package WordPress |
| 9 |
* @subpackage Parse.ly |
| 10 |
*/ |
| 11 |
|
| 12 |
?> |
| 13 |
|
| 14 |
<?php |
| 15 |
if ( ! isset( $parsely_options['apikey'] ) || empty( $parsely_options['apikey'] ) ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
?> |
| 19 |
|
| 20 |
<!-- START Parse.ly Include: Standard --> |
| 21 |
<?php if ( ! empty( $parsely_options['api_secret'] ) ) : ?> |
| 22 |
<script data-cfasync="false"> |
| 23 |
|
| 24 |
function uuidProfileCall() { |
| 25 |
var rootUrl = 'https://api.parsely.com/v2/profile?apikey=<?php echo esc_html( $parsely_options['apikey'] ); ?>'; |
| 26 |
var uuid = '&uuid=' + PARSELY.config.parsely_site_uuid; |
| 27 |
var requestUrl = rootUrl + uuid + '&url=' + window.location.href; |
| 28 |
jQuery.ajax({ |
| 29 |
url: requestUrl, |
| 30 |
dataType: "jsonp" |
| 31 |
}); |
| 32 |
} |
| 33 |
|
| 34 |
if (typeof PARSELY == 'object') { |
| 35 |
var oldonload = PARSELY.onload; |
| 36 |
if (typeof PARSELY.onload != 'function') { |
| 37 |
PARSELY.onload = uuidProfileCall |
| 38 |
} |
| 39 |
else { |
| 40 |
PARSELY.onload = function () { |
| 41 |
if (oldonload) { |
| 42 |
oldonload(); |
| 43 |
} |
| 44 |
uuidProfileCall(); |
| 45 |
}; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
else { |
| 50 |
PARSELY = { |
| 51 |
onload: uuidProfileCall |
| 52 |
} |
| 53 |
} |
| 54 |
</script> |
| 55 |
<?php endif; ?> |
| 56 |
|
| 57 |
<div id="parsely-root" style="display: none"> |
| 58 |
<div id="parsely-cfg" data-parsely-site="<?php echo esc_html( $parsely_options['apikey'] ); ?>"></div> |
| 59 |
</div> |
| 60 |
<script data-cfasync="false"> |
| 61 |
(function (s, p, d) { |
| 62 |
var h = d.location.protocol, i = p + "-" + s, |
| 63 |
e = d.getElementById(i), r = d.getElementById(p + "-root"), |
| 64 |
u = h === "https:" ? "d1z2jf7jlzjs58.cloudfront.net" |
| 65 |
: "static." + p + ".com"; |
| 66 |
if (e) return; |
| 67 |
e = d.createElement(s); |
| 68 |
e.id = i; |
| 69 |
e.async = true; |
| 70 |
e.setAttribute('data-cfasync', 'false'); |
| 71 |
e.src = h + "//" + u + "/p.js"; |
| 72 |
r.appendChild(e); |
| 73 |
})("script", "parsely", document); |
| 74 |
</script> |
| 75 |
|
| 76 |
<!-- END Parse.ly Include: Standard --> |
| 77 |
|