-
Notifications
You must be signed in to change notification settings - Fork 16
/
contact-widgets.php
168 lines (127 loc) · 3.52 KB
/
contact-widgets.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/**
* Plugin Name: Contact Widgets
* Description: Beautifully display social media and contact information on your website with these simple widgets.
* Version: 1.6.2
* Author: GoDaddy
* Author URI: https://godaddy.com
* Text Domain: contact-widgets
* Domain Path: /languages
* License: GPL-2.0
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright © 2016 GoDaddy Operating Company, LLC. All Rights Reserved.
*
* @package ContactWidgets.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Contact_Widgets' ) ) {
/**
* Contact Widgets plugin class.
*/
final class Contact_Widgets {
/**
* Minimum PHP version
*
* @var string
*/
private $php_min_version = '5.4';
/**
* Plugin assets URL
*
* @var string
*/
public static $assets_url;
/**
* Font Awesome 5
*
* @var boolean
*/
public static $fontawesome_5;
/**
* Font Awesome CSS locations
*
* @var string
*/
public static $fa_url;
/**
* Class constructor
*
* @param string $cur_php_version The current php version represented by String.
*/
public function __construct( $cur_php_version = PHP_VERSION ) {
static::$assets_url = plugin_dir_url( __FILE__ ) . 'assets/';
/**
* Should Font Awesome 5 be loaded.
*
* @var boolean
*/
static::$fontawesome_5 = (bool) apply_filters( 'wpcw_social_icons_fontawesome_5', false );
static::$fa_url = $this->font_awesome_url();
$composer_autoloader = __DIR__ . '/vendor/autoload.php';
if ( defined( 'WP_CLI' ) && WP_CLI && file_exists( $composer_autoloader ) ) {
// This is for enabling codeception.
require_once $composer_autoloader;
}
add_action( 'plugins_loaded', array( $this, 'i18n' ) );
if ( version_compare( $cur_php_version, $this->php_min_version, '<' ) ) {
add_action( 'shutdown', array( $this, 'notice' ) );
return;
}
require_once __DIR__ . '/includes/autoload.php';
}
/**
* Setup the Front Awesome assets URL
*
* @return string Returns URL where Font Awesome should load from.
*
* @since 1.5.0
*/
public function font_awesome_url() {
$suffix = SCRIPT_DEBUG ? '' : '.min';
/**
* Font Awesome CDN URL.
*
* @var string
*/
$fontawesome_cdn_url = (string) esc_url( apply_filters( 'wpcw_social_icons_cdn_url', ( self::$fontawesome_5 ? 'https://use.fontawesome.com/releases/v5.0.13/css/all.css' : "//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome{$suffix}.css" ) ) );
if ( self::$fontawesome_5 ) {
// Font Awesome 5 CDN URL.
return $fontawesome_cdn_url;
}
/**
* Should Font Awesome be loaded from the CDN.
*
* @var boolean
*/
$use_cdn = (bool) apply_filters( 'wpcw_social_icons_use_cdn', false );
return ! $use_cdn ? static::$assets_url . "css/font-awesome{$suffix}.css" : $fontawesome_cdn_url;
}
/**
* Load languages
*
* @action plugins_loaded
*/
public function i18n() {
load_plugin_textdomain( 'contact-widgets', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
/**
* Display min PHP version notice
*
* @action shutdown
*/
public function notice() {
printf(
'<div class="error"><p>%s</p></div>',
sprintf(
/* translators: Minumum PHP version supported. */
esc_html__( 'Contact widgets requires PHP version %s or higher. Please deactivate the plugin and contact your system administrator.', 'contact-widgets' ),
esc_html( $this->php_min_version )
)
);
}
}
new Contact_Widgets();
}