forked from sendgrid/wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpsendgrid.php
89 lines (75 loc) · 3.26 KB
/
wpsendgrid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/*
Plugin Name: SendGrid
Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
Version: 1.11.11
Author: SendGrid
Author URI: http://sendgrid.com
Text Domain: sendgrid-email-delivery-simplified
License: GPLv2
*/
// SendGrid configurations
define( 'SENDGRID_CATEGORY', 'wp_sendgrid_plugin' );
define( 'SENDGRID_PLUGIN_SETTINGS', 'settings_page_sendgrid-settings' );
define( 'SENDGRID_PLUGIN_STATISTICS', 'dashboard_page_sendgrid-statistics' );
if ( version_compare( phpversion(), '5.4.0', '<' ) ) {
add_action( 'admin_notices', 'php_version_error' );
/**
* Display the notice if PHP version is lower than plugin need
*
* return void
*/
function php_version_error()
{
echo '<div class="error"><p>' . __('SendGrid: Plugin requires PHP >= 5.4.0.') . '</p></div>';
}
return;
}
if ( function_exists('wp_mail') )
{
/**
* wp_mail has been declared by another process or plugin, so you won't be able to use SENDGRID until the problem is solved.
*/
add_action( 'admin_notices', 'wp_mail_already_declared_notice' );
/**
* Display the notice that wp_mail function was declared by another plugin
*
* return void
*/
function wp_mail_already_declared_notice()
{
echo '<div class="error"><p>' . __( 'SendGrid: wp_mail has been declared by another process or plugin, so you won\'t be able to use SendGrid until the conflict is solved.' ) . '</p></div>';
}
return;
}
// Load plugin files
require_once plugin_dir_path( __FILE__ ) . 'lib/class-sendgrid-tools.php';
require_once plugin_dir_path( __FILE__ ) . 'lib/class-sendgrid-settings.php';
require_once plugin_dir_path( __FILE__ ) . 'lib/class-sendgrid-mc-optin.php';
require_once plugin_dir_path( __FILE__ ) . 'lib/class-sendgrid-statistics.php';
require_once plugin_dir_path( __FILE__ ) . 'lib/sendgrid/sendgrid-wp-mail.php';
require_once plugin_dir_path( __FILE__ ) . 'lib/class-sendgrid-nlvx-widget.php';
require_once plugin_dir_path( __FILE__ ) . 'lib/class-sendgrid-virtual-pages.php';
require_once plugin_dir_path( __FILE__ ) . 'lib/class-sendgrid-filters.php';
// Widget Registration
if ( 'true' == Sendgrid_Tools::get_mc_auth_valid() ) {
add_action( 'widgets_init', 'register_sendgrid_widgets' );
} else {
add_action( 'widgets_init', 'unregister_sendgrid_widgets' );
}
// Widget notice dismissed
if ( isset( $_POST['sg_dismiss_widget_notice'] ) ) {
Sendgrid_Tools::set_mc_widget_notice_dismissed( 'true' );
}
// Display widget notice
if ( 'true' != Sendgrid_Tools::get_mc_widget_notice_dismissed() and
( !is_multisite() or ( is_multisite() and ( get_option( 'sendgrid_can_manage_subsite' ) or is_main_site() ) ) ) ) {
add_action( 'admin_notices', 'sg_subscription_widget_admin_notice' );
}
// Initialize SendGrid Settings
new Sendgrid_Settings( plugin_basename( __FILE__ ) );
// Initialize SendGrid Statistics
new Sendgrid_Statistics();
// Initialize SendGrid Filters
new Sendgrid_Filters();