PluginProbe
Pushly / 2.4.0
Pushly v2.4.0
2.4.0 2.3.0 trunk 1.0 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 2.0.0 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1
pushly / includes / public / views / sdk.php

sdk.php in Pushly 2.4.0, at includes/public/views/sdk.php

28 lines 871 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 /**
7 * Emits the Pushly SDK initialization snippet.
8 *
9 * Outputs the inline <script> directly with all dynamic values JSON-encoded
10 * for safe embedding in JS contexts.
11 *
12 * @param string $sdk_key The Pushly SDK / domain key.
13 * @param string $sw_root Base plugin URL used to build the service-worker path and scope.
14 */
15 function pushly_render_sdk_snippet( $sdk_key, $sw_root ) {
16 ?>
17 <script>
18 var PushlySDK = window.PushlySDK || [];
19 function pushly() { PushlySDK.push(arguments) }
20 pushly('load', {
21 domainKey: decodeURIComponent("<?php echo rawurlencode( (string) $sdk_key ); ?>"),
22 sw: <?php echo wp_json_encode( esc_url( $sw_root . 'assets/js/pushly-sdk-worker.js.php' ), JSON_UNESCAPED_SLASHES ); ?>,
23 swScope: <?php echo wp_json_encode( esc_url( $sw_root ), JSON_UNESCAPED_SLASHES ); ?>
24 });
25 </script>
26 <?php
27 }
28