| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: SendPulse Free Web Push |
| 4 |
* Plugin URI: https://sendpulse.com/integrations/cms/wordpress |
| 5 |
* Description: SendPulse Free Web Push plugin adds your web push integration code into the <head> section of your website. The plugin will enable web push subscription requests to your website visitors and optionally pass emails and names of logged in users for segmentation and personalization. To get started: 1)Click the "Activate" link to the left of this description, 2) Sign up for a free <a href="https://sendpulse.com/webpush/register?utm_source=wordpress&utm_medium=referral&utm_campaign=wordpresspush">Sendpulse account</a>, and 3) Add your website to SendPulse, copy and paste the integation code into the plugin settings section |
| 6 |
* Version: 1.4.2 |
| 7 |
* Author: SendPulse |
| 8 |
* Author URI: https://sendpulse.com/webpush?utm_source=wordpress |
| 9 |
* License: GPLv2 |
| 10 |
* Text Domain: sendpulse-web-push |
| 11 |
* Domain Path: /languages |
| 12 |
*/ |
| 13 |
|
| 14 |
namespace SendpulseWebPush; |
| 15 |
|
| 16 |
// Exit if accessed directly. |
| 17 |
if (!defined('ABSPATH')) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
define('SENDPULSE_WEBPUSH_ABS_PATH', get_public_dir(basename(dirname(__FILE__)))); |
| 22 |
define('SENDPULSE_WEBPUSH_PUBLIC_PATH', untrailingslashit(plugin_dir_url(__FILE__))); |
| 23 |
|
| 24 |
load_plugin_textdomain('sendpulse-web-push', false, basename(dirname(__FILE__)) . '/languages'); |
| 25 |
|
| 26 |
// Check for forwardslash/backslash in folder path to structure paths |
| 27 |
function get_public_dir($url = '') { |
| 28 |
$url = strval($url); |
| 29 |
if (!empty($url) && !preg_match('#(\\\\|/)$#', $url)) { |
| 30 |
return $url . '/'; |
| 31 |
} else if (empty($url)) { |
| 32 |
return '/'; |
| 33 |
} else { |
| 34 |
return $url; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
class SendpulseWebPush { |
| 39 |
/** launch the hooks */ |
| 40 |
public function __construct() { |
| 41 |
require_once (plugin_dir_path(__FILE__) . 'faq.php'); |
| 42 |
require_once (plugin_dir_path(__FILE__) . 'settings.php'); |
| 43 |
require_once (plugin_dir_path(__FILE__) . 'sendpulse-webpush.php'); |
| 44 |
|
| 45 |
// add actions init |
| 46 |
add_action('admin_menu', array($this, 'sp_webpush_settings'), 30); |
| 47 |
add_action('admin_assets', array($this, 'sp_webpush_assets'), 30); |
| 48 |
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'sendpulse_webpush_settings_link'); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
public function sp_push_settings_link($links) { |
| 53 |
$url = esc_url( |
| 54 |
add_query_arg( |
| 55 |
'page', |
| 56 |
'sendpulse-web-push/settings.php', |
| 57 |
get_admin_url() . 'admin.php' |
| 58 |
) |
| 59 |
); |
| 60 |
|
| 61 |
$plugin_links = array( |
| 62 |
'<a href="' . $url . '">' . __('Settings', 'sendpulse-web-push') . '</a>', |
| 63 |
); |
| 64 |
|
| 65 |
return array_merge($plugin_links, $links); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
/** settings page */ |
| 70 |
public function sp_webpush_settings() { |
| 71 |
$allowed_group = 'administrator'; |
| 72 |
add_menu_page( |
| 73 |
__('Sendpulse WebPush', 'sendpulse-web-push'), |
| 74 |
__('WebPush', 'sendpulse-web-push'), |
| 75 |
$allowed_group, |
| 76 |
'sendpulse-web-push/settings.php', |
| 77 |
'sendpulse_config', |
| 78 |
plugins_url('sendpulse-web-push/img/menu_icon.png'), |
| 79 |
'30' |
| 80 |
); |
| 81 |
|
| 82 |
add_submenu_page( |
| 83 |
'sendpulse-web-push/settings.php', |
| 84 |
__('Settings', 'sendpulse-web-push'), |
| 85 |
__('Settings', 'sendpulse-web-push'), |
| 86 |
$allowed_group, |
| 87 |
'sendpulse-web-push/settings.php', |
| 88 |
'sendpulse_config' |
| 89 |
); |
| 90 |
|
| 91 |
add_submenu_page( |
| 92 |
'sendpulse-web-push/settings.php', |
| 93 |
__('FAQ', 'sendpulse-web-push'), |
| 94 |
__('FAQ', 'sendpulse-web-push'), |
| 95 |
$allowed_group, |
| 96 |
'sendpulse-web-push/faq.php', |
| 97 |
'sendpulse_faq' |
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
register_activation_hook(__FILE__, 'SendPulseInstallStep1'); |
| 104 |
register_deactivation_hook(__FILE__, 'SendPulseDeactivationStep1'); |
| 105 |
register_uninstall_hook(__FILE__, 'SendPulseDeinstallStep1'); |
| 106 |
|
| 107 |
$sendpulse_webpush = new SendpulseWebPush(); |
| 108 |
|