|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Admin Menus |
|
4
|
|
|
* |
|
5
|
|
|
* @package SimpleCalendar\Admin |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace SimpleCalendar\Admin; |
|
8
|
|
|
|
|
9
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
10
|
|
|
exit; |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Admin Menus. |
|
15
|
|
|
* |
|
16
|
|
|
* Handles the plugin admin dashboard menus. |
|
17
|
|
|
* |
|
18
|
|
|
* @since 3.0.0 |
|
19
|
|
|
*/ |
|
20
|
|
|
class Menus { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The main menu screen hook. |
|
24
|
|
|
* |
|
25
|
|
|
* @access public |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
public static $main_menu = ''; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Plugin basename. |
|
32
|
|
|
* |
|
33
|
|
|
* @access private |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
private static $plugin = ''; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Set properties. |
|
40
|
|
|
* |
|
41
|
|
|
* @since 3.0.0 |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct() { |
|
44
|
|
|
|
|
45
|
|
|
self::$main_menu = 'edit.php?post_type=calendar'; |
|
46
|
|
|
|
|
47
|
|
|
add_action( 'admin_menu', array( __CLASS__, 'add_menu_items' ) ); |
|
48
|
|
|
|
|
49
|
|
|
self::$plugin = plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ); |
|
50
|
|
|
|
|
51
|
|
|
new Welcome(); |
|
52
|
|
|
|
|
53
|
|
|
// Links and meta content in plugins page. |
|
54
|
|
|
add_filter( 'plugin_action_links_' . self::$plugin, array( __CLASS__, 'plugin_action_links' ), 10, 5 ); |
|
55
|
|
|
add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); |
|
56
|
|
|
// Custom text in admin footer. |
|
57
|
|
|
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Add menu items. |
|
62
|
|
|
* |
|
63
|
|
|
* @since 3.0.0 |
|
64
|
|
|
*/ |
|
65
|
|
|
public static function add_menu_items() { |
|
66
|
|
|
|
|
67
|
|
|
add_submenu_page( |
|
68
|
|
|
self::$main_menu, |
|
69
|
|
|
__( 'Settings', 'google-calendar-events' ), |
|
70
|
|
|
__( 'Settings', 'google-calendar-events' ), |
|
71
|
|
|
'manage_options', |
|
72
|
|
|
'simple-calendar_settings', |
|
73
|
|
|
function () { |
|
74
|
|
|
$page = new Pages( 'settings' ); |
|
75
|
|
|
$page->html(); |
|
76
|
|
|
} |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
add_submenu_page( |
|
80
|
|
|
self::$main_menu, |
|
81
|
|
|
__( 'Add-ons', 'google-calendar-events' ), |
|
82
|
|
|
__( 'Add-ons', 'google-calendar-events' ), |
|
83
|
|
|
'manage_options', |
|
84
|
|
|
'simple-calendar_add_ons', |
|
85
|
|
|
function() { |
|
86
|
|
|
$page = new Pages( 'add-ons' ); |
|
87
|
|
|
$page->html(); |
|
88
|
|
|
} |
|
89
|
|
|
); |
|
90
|
|
|
|
|
91
|
|
|
add_submenu_page( |
|
92
|
|
|
self::$main_menu, |
|
93
|
|
|
__( 'Tools', 'google-calendar-events' ), |
|
94
|
|
|
__( 'Tools', 'google-calendar-events' ), |
|
95
|
|
|
'manage_options', |
|
96
|
|
|
'simple-calendar_tools', |
|
97
|
|
|
function () { |
|
98
|
|
|
$page = new Pages( 'tools' ); |
|
99
|
|
|
$page->html(); |
|
100
|
|
|
} |
|
101
|
|
|
); |
|
102
|
|
|
|
|
103
|
|
|
do_action( 'simcal_admin_add_menu_items' ); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Action links in plugins page. |
|
108
|
|
|
* |
|
109
|
|
|
* @since 3.0.0 |
|
110
|
|
|
* |
|
111
|
|
|
* @param array $action_links |
|
112
|
|
|
* @param string $file |
|
113
|
|
|
* |
|
114
|
|
|
* @return array |
|
115
|
|
|
*/ |
|
116
|
|
|
public static function plugin_action_links( $action_links, $file ) { |
|
117
|
|
|
|
|
118
|
|
|
if ( self::$plugin == $file ) { |
|
119
|
|
|
|
|
120
|
|
|
$links = array(); |
|
121
|
|
|
$links['settings'] = '<a href="' . admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings' ) . '">' . __( 'Settings', 'google-calendar-events' ) . '</a>'; |
|
122
|
|
|
$links['feeds'] = '<a href="' . admin_url( 'edit.php?post_type=calendar' ) . '">' . __( 'Calendars', 'google-calendar-events' ) . '</a>'; |
|
123
|
|
|
|
|
124
|
|
|
return apply_filters( 'simcal_plugin_action_links', array_merge( $links, $action_links ) ); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
return $action_links; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Links in plugin meta in plugins page. |
|
132
|
|
|
* |
|
133
|
|
|
* @since 3.0.0 |
|
134
|
|
|
* |
|
135
|
|
|
* @param array $meta_links |
|
136
|
|
|
* @param string $file |
|
137
|
|
|
* |
|
138
|
|
|
* @return array |
|
139
|
|
|
*/ |
|
140
|
|
|
public static function plugin_row_meta( $meta_links, $file ) { |
|
141
|
|
|
|
|
142
|
|
|
if ( self::$plugin == $file ) { |
|
143
|
|
|
|
|
144
|
|
|
$links = array(); |
|
145
|
|
|
$links['github'] = '<a href="' . simcal_get_url( 'github' ) . '" target="_blank" >GitHub</a>'; |
|
146
|
|
|
$links['documentation'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'docs' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
|
147
|
|
|
__( 'Documentation', 'google-calendar-events' ) . '</a>'; |
|
148
|
|
|
$links['support'] = '<a href="' . simcal_get_url( 'support' ) . '" target="_blank" >' . |
|
149
|
|
|
__( 'Support', 'google-calendar-events' ) . '</a>'; |
|
150
|
|
|
$links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'add-ons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
|
151
|
|
|
__( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
152
|
|
|
|
|
153
|
|
|
return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
return $meta_links; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Admin footer text filter callback. |
|
161
|
|
|
* |
|
162
|
|
|
* Change this plugin screens admin footer text. |
|
163
|
|
|
* |
|
164
|
|
|
* @since 3.0.0 |
|
165
|
|
|
* |
|
166
|
|
|
* @param $footer_text |
|
167
|
|
|
* |
|
168
|
|
|
* @return string|void |
|
169
|
|
|
*/ |
|
170
|
|
|
public function admin_footer_text( $footer_text ) { |
|
171
|
|
|
|
|
172
|
|
|
// Check to make sure we're on a SimpleCal admin page |
|
173
|
|
|
$screen = simcal_is_admin_screen(); |
|
174
|
|
|
if ( $screen !== false ) { |
|
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
if ( 'calendar' == $screen ) { |
|
177
|
|
|
|
|
178
|
|
|
// Add Drip promo signup form (@see Newsletter meta box). |
|
179
|
|
|
|
|
180
|
|
|
$drip_form_id = '9817628'; |
|
181
|
|
|
|
|
182
|
|
|
?> |
|
183
|
|
|
<form id="simcal-drip-form" |
|
184
|
|
|
method="post" |
|
185
|
|
|
target="_blank" |
|
186
|
|
|
action="https://www.getdrip.com/forms/<?php echo $drip_form_id; ?>/submissions/" |
|
|
|
|
|
|
187
|
|
|
data-drip-embedded-form="<?php echo $drip_form_id; ?>"> |
|
|
|
|
|
|
188
|
|
|
<input type="hidden" |
|
189
|
|
|
id="simcal-drip-real-field-first_name" |
|
190
|
|
|
name="fields[first_name]" |
|
191
|
|
|
value="" /> |
|
192
|
|
|
<input type="hidden" |
|
193
|
|
|
id="simcal-drip-real-field-email" |
|
194
|
|
|
name="fields[email]" |
|
195
|
|
|
value="" /> |
|
196
|
|
|
<input type="submit" |
|
197
|
|
|
class="hidden"/> |
|
198
|
|
|
</form> |
|
199
|
|
|
<?php |
|
200
|
|
|
|
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
// Change the footer text |
|
204
|
|
|
if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { |
|
205
|
|
|
|
|
206
|
|
|
$footer_text = sprintf( |
|
207
|
|
|
__( 'If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events' ), |
|
208
|
|
|
'<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'google-calendar-events' ) . '">', '</a>' |
|
209
|
|
|
); |
|
210
|
|
|
|
|
211
|
|
|
$footer_text .= '<script type="text/javascript">'; |
|
212
|
|
|
$footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { |
|
213
|
|
|
jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); |
|
214
|
|
|
jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
|
215
|
|
|
});"; |
|
216
|
|
|
$footer_text .= '</script>'; |
|
217
|
|
|
|
|
218
|
|
|
} else { |
|
219
|
|
|
|
|
220
|
|
|
$footer_text = __( 'Thank you for using Simple Calendar!', 'google-calendar-events' ); |
|
221
|
|
|
|
|
222
|
|
|
} |
|
|
|
|
|
|
223
|
|
|
|
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
return $footer_text; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
} |
|
230
|
|
|
|