MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/www/wp-content/plugins/pwa-for-wp/3rd-party/webpushr.php
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;

Class Pwaforwp_webpushr{
	/**
	 * get the unique instance of the class
	 * @var Pwaforwp_webpushr
	 */
	private static $instance;

	private $settings = array();
	/**
	 * Constructor
	 */
	function __construct(){
		if(!$this->settings){
			$this->settings = pwaforwp_defaultSettings();
		}
		add_action('plugins_loaded', array($this, 'web_init'));
	}
	/**
	 * Check and entry function for compatibility with webpushr plugin
	 * @return null
	 */
	public function web_init(){
		if(isset($this->settings['webpusher_support_setting']) && $this->settings['webpusher_support_setting']==1){
			// add_filter( 'pwaforwp_sw_name_modify', array($this, 'change_sw_name') );
			add_filter("pwaforwp_sw_js_template", array($this, 'add_webpushr'));
			
		}
	}
	/**
     * Gets an instance of our Pwaforwp_webpushr class.
     *
     * @return Pwaforwp_webpushr
     */
	public static function get_instance(){
		if (null === self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
	}
	/**
	 * add content in service worker for webpushr call
	 * @param string $content javascript content
	 * @return string $content javascript content
	 */
	public function add_webpushr($content){
		$content = "importScripts('https://cdn.webpushr.com/sw-server.min.js');\n".$content;
		return $content;
	}

}

function pwaforwp_webpushr(){
	return Pwaforwp_webpushr::get_instance();
}
pwaforwp_webpushr();