Changeset 2741024
- Timestamp:
- 06/12/2022 03:39:33 AM (4 years ago)
- Location:
- pushnami-web-push-notifications
- Files:
-
- 14 added
- 4 edited
-
tags/1.0.7 (added)
-
tags/1.0.7/assets (added)
-
tags/1.0.7/assets/tmp (added)
-
tags/1.0.7/assets/tmp/advanced-script.js.tmp (added)
-
tags/1.0.7/assets/tmp/manifest.json.tmp (added)
-
tags/1.0.7/assets/tmp/service-worker.js.tmp (added)
-
tags/1.0.7/includes (added)
-
tags/1.0.7/includes/class-pushnami.php (added)
-
tags/1.0.7/pushnami.php (added)
-
tags/1.0.7/readme.txt (added)
-
tags/1.0.7/uninstall.php (added)
-
tags/1.0.7/views (added)
-
tags/1.0.7/views/admin (added)
-
tags/1.0.7/views/admin/pushnami-settings.php (added)
-
trunk/includes/class-pushnami.php (modified) (4 diffs)
-
trunk/pushnami.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/views/admin/pushnami-settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pushnami-web-push-notifications/trunk/includes/class-pushnami.php
r2739514 r2741024 37 37 add_action('wp_print_scripts', array($this, 'pushnami_print_scripts')); 38 38 add_action('wp_head', array($this, 'manifestFile'), 1, 1); 39 add_action('parse_request', array($this, 'my_plugin_parse_request')); 39 40 40 41 $pluginDirName = basename( plugin_dir_path( dirname( __FILE__ , 1 ) ) ); 41 42 $settingsPath = 'plugin_action_links_' . $pluginDirName . '/pushnami.php'; 42 43 add_filter($settingsPath, array($this, 'settingsLink')); 44 add_filter('query_vars', array($this, 'my_plugin_query_vars')); 43 45 } 44 46 … … 102 104 103 105 /** 104 * ServiceWorker file (service-worker.js) creation 106 * ServiceWorker file (service-worker.js) Render Template 107 * @return void 108 */ 109 public static function renderServiceWorker() 110 { 111 $api_url = get_option('pushnami_api_url'); 112 if (!$api_url) $api_url = PUSHNAMI_DEFAULT_API_URL; 113 114 $tmp_sw = file_get_contents(PUSHNAMI_PLUGIN_DIR . 'assets/tmp/service-worker.js.tmp'); 115 $tmp_sw = str_replace('KEY', get_option('pushnami_api_key'), $tmp_sw); 116 $tmp_sw = str_replace('API_PATH', $api_url, $tmp_sw); 117 118 return $tmp_sw; 119 } 120 121 /** 122 * ServiceWorker file (service-worker.js) Write File 105 123 * @return void 106 124 */ … … 111 129 if ($useCustomManifest) return; 112 130 113 $api_url = get_option('pushnami_api_url'); 114 if (!$api_url) $api_url = PUSHNAMI_DEFAULT_API_URL; 115 116 $tmp_sw = file_get_contents(PUSHNAMI_PLUGIN_DIR . 'assets/tmp/service-worker.js.tmp'); 117 $tmp_sw = str_replace('KEY', get_option('pushnami_api_key'), $tmp_sw); 118 $tmp_sw = str_replace('API_PATH', $api_url, $tmp_sw); 131 $tmp_sw = self::renderServiceWorker(); 119 132 $form_url = 'admin.php?page=pushnami-settings'; 120 133 … … 580 593 self::writeManifestJson(true); 581 594 } 595 596 public function my_plugin_parse_request($wp) { 597 $swPathsStr = get_option('pushnami_sw_paths'); 598 if ($swPathsStr) { 599 $swPathsArr = explode(",", $swPathsStr); 600 foreach ($swPathsArr as $swPath) { 601 $swPathKeyValue = explode("=", trim($swPath)); 602 $count = count($swPathKeyValue); 603 if ($count < 2) continue; // skip non query param paths 604 605 $key = preg_replace('/^\?{1}/', '', $swPathKeyValue[0]); 606 $val = $swPathKeyValue[1]; 607 if (array_key_exists($key, $wp->query_vars) 608 && $wp->query_vars[$key] == $val) { 609 610 $worker = self::renderServiceWorker(); 611 die($worker); 612 } 613 } 614 } 615 } 616 617 public function my_plugin_query_vars($vars) { 618 $swPathsStr = get_option('pushnami_sw_paths'); 619 if ($swPathsStr) { 620 $swPathsArr = explode(",", $swPathsStr); 621 622 foreach ($swPathsArr as $swPath) { 623 $swPathKeyValue = explode("=", trim($swPath)); 624 $count = count($swPathKeyValue); 625 if ($count < 2) continue; // skip non query param paths 626 627 $key = preg_replace('/^\?{1}/', '', $swPathKeyValue[0]); 628 $vars[] = $key; 629 } 630 } 631 632 return $vars; 633 } 582 634 } -
pushnami-web-push-notifications/trunk/pushnami.php
r2739514 r2741024 7 7 Plugin URI: https://wordpress.org/plugins/pushnami-web-push-notifications 8 8 Description: Capture & Monetize Your Audience. The leader for web push, mobile push notifications, and email. Trusted by more than 20K brands to send 10 billion messages per month. 9 Version: 1.0. 79 Version: 1.0.8 10 10 Author: Pushnami 11 11 Author URI: https://www.pushnami.com -
pushnami-web-push-notifications/trunk/readme.txt
r2739514 r2741024 59 59 == Changelog == 60 60 61 = 1.0.8 = 62 * Adds advanced option for setting extra service-worker query parameter paths. 63 61 64 = 1.0.7 = 62 65 * Bug fix to reset script collision flags when proper files are detected again. -
pushnami-web-push-notifications/trunk/views/admin/pushnami-settings.php
r2388400 r2741024 214 214 } 215 215 216 if(isset($_POST['pushnami_sw_paths']) ) { 217 if(!empty($_POST['pushnami_sw_paths'])) { 218 update_option('pushnami_sw_paths', sanitize_text_field($_POST['pushnami_sw_paths'])); 219 } else if(empty($_POST['pushnami_sw_paths'])) { 220 delete_option('pushnami_sw_paths'); 221 } 222 } 223 216 224 if(isset($_POST['pushnami_api_url']) ) { 217 225 if(!empty($_POST['pushnami_api_url'])) { … … 495 503 <td><input type="checkbox" name="pushnami_ab" value="true" <?php //checked(get_option('pushnami_ab')); ?> /></td> 496 504 </tr> --> 505 <tr valign="top" class="advanced_option"> 506 <th scope="row">Extra Worker Path</th> 507 <td><input type="text" size="64" name="pushnami_sw_paths" value="<?php echo esc_attr( get_option('pushnami_sw_paths') ); ?>" placeholder="service-worker.js"/></td> 508 </tr> 497 509 <tr valign="top" class="debug_option" style="<?php if (!get_option('pushnami_debug')) echo 'display:none;'; ?>"> 498 510 <th scope="row"><h3>Debug Options</h3></th>
Note: See TracChangeset
for help on using the changeset viewer.