|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Auto Load Next Post Admin. |
|
4
|
|
|
* |
|
5
|
|
|
* @since 1.0.0 |
|
6
|
|
|
* @author Sébastien Dumont |
|
7
|
|
|
* @category Admin |
|
8
|
|
|
* @package Auto Load Next Post |
|
9
|
|
|
* @license GPL-2.0+ |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
if ( ! defined('ABSPATH')) { |
|
13
|
|
|
exit; |
|
14
|
|
|
} |
|
15
|
|
|
// Exit if accessed directly |
|
16
|
|
|
|
|
17
|
|
|
if ( ! class_exists('Auto_Load_Next_Post_Admin')) { |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class - Auto_Load_Next_Post_Admin |
|
21
|
|
|
* |
|
22
|
|
|
* @since 1.0.0 |
|
23
|
|
|
*/ |
|
24
|
|
|
class Auto_Load_Next_Post_Admin { |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Constructor |
|
28
|
|
|
* |
|
29
|
|
|
* @since 1.0.0 |
|
30
|
|
|
* @access public |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct() { |
|
33
|
|
|
// Actions |
|
34
|
|
|
add_action('init', array($this, 'includes'), 10); |
|
35
|
|
|
add_action('admin_init', array($this, 'admin_scripts'), 100); |
|
36
|
|
|
|
|
37
|
|
|
// Filters |
|
38
|
|
|
add_filter('plugin_action_links_'.plugin_basename(AUTO_LOAD_NEXT_POST_FILE), array($this, 'action_links')); |
|
39
|
|
|
add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2); |
|
40
|
|
|
add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
41
|
|
|
add_filter('update_footer', array($this, 'update_footer'), 15); |
|
42
|
|
|
} // END __construct() |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Plugin action links. |
|
46
|
|
|
* |
|
47
|
|
|
* @since 1.0.0 |
|
48
|
|
|
* @access public |
|
49
|
|
|
* @param mixed $links |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function action_links($links) { |
|
53
|
|
|
if (current_user_can('manage_options')) { |
|
54
|
|
|
$plugin_links = array( |
|
55
|
|
|
'<a href="https://autoloadnextpost.com/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page" target="_blank" style="color:green; font-weight:bold;">'.__('Upgrade to Premium', 'auto-load-next-post').'</a>', |
|
56
|
|
|
'<a href="'.admin_url('options-general.php?page=auto-load-next-post-settings').'">'.__('Settings', 'auto-load-next-post').'</a>', |
|
57
|
|
|
'<a href="'.admin_url('options-general.php?page=auto-load-next-post-settings&tab=support').'">'.__('Support', 'auto-load-next-post').'</a>', |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
return array_merge($plugin_links, $links); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return $links; |
|
64
|
|
|
} // END action_links() |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Plugin row meta links |
|
68
|
|
|
* |
|
69
|
|
|
* @since 1.0.0 |
|
70
|
|
|
* @access public |
|
71
|
|
|
* @param array $input already defined meta links |
|
72
|
|
|
* @param string $file plugin file path and name being processed |
|
73
|
|
|
* @return array $input |
|
74
|
|
|
*/ |
|
75
|
|
|
public function plugin_row_meta($input, $file) { |
|
76
|
|
|
if (plugin_basename(AUTO_LOAD_NEXT_POST_FILE) !== $file) { |
|
77
|
|
|
return $input; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$links = array( |
|
81
|
|
|
'<a href="'.esc_url('https://github.com/seb86/Auto-Load-Next-Post/wiki/').'" target="_blank">'.__('Documentation', 'auto-load-next-post').'</a>', |
|
82
|
|
|
'<a href="'.esc_url('https://wordpress.org/support/plugin/auto-load-next-post').'" target="_blank">'.__('Community Support', 'auto-load-next-post').'</a>' |
|
83
|
|
|
); |
|
84
|
|
|
|
|
85
|
|
|
$input = array_merge($input, $links); |
|
86
|
|
|
|
|
87
|
|
|
return $input; |
|
88
|
|
|
} // END plugin_row_meta() |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Include any classes we need within admin. |
|
92
|
|
|
* |
|
93
|
|
|
* @since 1.0.0 |
|
94
|
|
|
* @access public |
|
95
|
|
|
*/ |
|
96
|
|
|
public function includes() { |
|
97
|
|
|
// Classes we only need if the ajax is not-ajax |
|
98
|
|
|
if ( ! auto_load_next_post_is_ajax()) { |
|
99
|
|
|
include('class-auto-load-next-post-install.php'); // Install Plugin |
|
100
|
|
|
include('class-auto-load-next-post-admin-menus.php'); // Plugin Menu |
|
101
|
|
|
include('class-auto-load-next-post-admin-notices.php'); // Plugin Notices |
|
102
|
|
|
include('class-auto-load-next-post-admin-help.php'); // Plugin Help Tab |
|
103
|
|
|
} |
|
104
|
|
|
} // END includes() |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Registers and enqueues stylesheets and javascripts |
|
108
|
|
|
* for the administration panel. |
|
109
|
|
|
* |
|
110
|
|
|
* @since 1.0.0 |
|
111
|
|
|
* @access public |
|
112
|
|
|
*/ |
|
113
|
|
|
public function admin_scripts() { |
|
114
|
|
|
// Auto Load Next Post Main Javascript |
|
115
|
|
|
Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_admin_script', '/assets/js/admin/auto-load-next-post'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION); |
|
116
|
|
|
// Chosen |
|
117
|
|
|
Auto_Load_Next_Post::load_file('chosen', '/assets/js/libs/chosen/chosen.jquery'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION); |
|
118
|
|
|
// TipTip |
|
119
|
|
|
Auto_Load_Next_Post::load_file('jquery-tiptip', '/assets/js/libs/jquery-tiptip/jquery.tipTip'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION); |
|
120
|
|
|
// Variables for Admin JavaScripts |
|
121
|
|
|
wp_localize_script(AUTO_LOAD_NEXT_POST_SLUG.'_admin_script', 'auto_load_next_post_admin_params', array( |
|
122
|
|
|
'i18n_nav_warning' => __('The changes you made will be lost if you navigate away from this page.', 'auto-load-next-post'), |
|
123
|
|
|
)); |
|
124
|
|
|
|
|
125
|
|
|
// Stylesheets |
|
126
|
|
|
Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_admin_style', '/assets/css/admin/auto-load-next-post'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.css'); |
|
127
|
|
|
Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_chosen_style', '/assets/css/libs/chosen'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.css'); |
|
128
|
|
|
} // END admin_scripts() |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Filters the admin footer text by placing links |
|
132
|
|
|
* for the plugin including a simply thank you to |
|
133
|
|
|
* review the plugin on WordPress.org. |
|
134
|
|
|
* |
|
135
|
|
|
* @since 1.0.0 |
|
136
|
|
|
* @access public |
|
137
|
|
|
* @param $text |
|
138
|
|
|
* @return string |
|
139
|
|
|
*/ |
|
140
|
|
|
public function admin_footer_text($text) { |
|
141
|
|
|
$screen = get_current_screen(); |
|
142
|
|
|
|
|
143
|
|
|
if ($screen->id == 'settings_page_auto-load-next-post-settings') { |
|
144
|
|
|
|
|
145
|
|
|
$links = array( |
|
146
|
|
|
'https://autoloadnextpost.com/?utm_source=wpadmin&utm_campaign=plugin-settings-footer' => __('Website', 'auto-load-next-post'), |
|
147
|
|
|
'https://github.com/seb86/Auto-Load-Next-Post/wiki/?utm_source=wpadmin&utm_campaign=plugin-settings-footer' => __('Documentation', 'auto-load-next-post'), |
|
148
|
|
|
); |
|
149
|
|
|
|
|
150
|
|
|
$text = ''; |
|
151
|
|
|
$counter = 0; |
|
152
|
|
|
|
|
153
|
|
|
foreach ($links as $key => $value) { |
|
154
|
|
|
$text .= '<a target="_blank" href="'.$key.'">'.$value.'</a>'; |
|
155
|
|
|
|
|
156
|
|
|
if (count($links) > 1 && count($links) != $counter) { |
|
157
|
|
|
$text .= ' | '; |
|
158
|
|
|
$counter++; |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
// Rating and Review |
|
163
|
|
|
$text .= sprintf(__('If you like <strong>%1$s</strong> please leave a <a href="%2$s" target="_blank">★★★★★</a> rating on <a href="%2$s" target="_blank">WordPress.org</a>. A huge thank you in advance!', 'auto-load-next-post'), 'Auto Load Next Post', 'https://wordpress.org/support/view/plugin-reviews/auto-load-next-post?filter=5#postform'); |
|
164
|
|
|
|
|
165
|
|
|
return $text; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
return $text; |
|
169
|
|
|
} // END admin_footer_text() |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* Filters the update footer by placing details |
|
173
|
|
|
* of the plugin and links to contribute or |
|
174
|
|
|
* report issues with the plugin when viewing any |
|
175
|
|
|
* of the plugin pages. |
|
176
|
|
|
* |
|
177
|
|
|
* @since 1.0.0 |
|
178
|
|
|
* @access public |
|
179
|
|
|
* @param $text |
|
180
|
|
|
* @return string $text |
|
181
|
|
|
*/ |
|
182
|
|
|
public function update_footer($text) { |
|
183
|
|
|
$screen = get_current_screen(); |
|
184
|
|
|
|
|
185
|
|
|
if ($screen->id == 'settings_page_auto-load-next-post-settings') { |
|
186
|
|
|
|
|
187
|
|
|
$text = '<span class="wrap">'; |
|
188
|
|
|
|
|
189
|
|
|
$links = array( |
|
190
|
|
|
'https://github.com/seb86/Auto-Load-Next-Post/blob/master/CONTRIBUTING.md' => __('Contribute', 'auto-load-next-post'), |
|
191
|
|
|
'https://github.com/seb86/Auto-Load-Next-Post/issues/new' => __('Report an Issue', 'auto-load-next-post'), |
|
192
|
|
|
); |
|
193
|
|
|
|
|
194
|
|
|
foreach ($links as $key => $value) { |
|
195
|
|
|
$text .= '<a target="_blank" class="add-new-h2" href="'.$key.'">'.$value.'</a>'; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
$text .= '</span>'.'</p>'. |
|
199
|
|
|
'<p class="alignright">'. |
|
200
|
|
|
sprintf(__('%s Version', 'auto-load-next-post'), 'Auto Load Next Post'). |
|
201
|
|
|
' : '.esc_attr(AUTO_LOAD_NEXT_POST_VERSION).'</p>'; |
|
202
|
|
|
|
|
203
|
|
|
return $text; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
return $text; |
|
207
|
|
|
} // END update_footer() |
|
208
|
|
|
|
|
209
|
|
|
} // END class |
|
210
|
|
|
|
|
211
|
|
|
} // END if class exists |
|
212
|
|
|
|
|
213
|
|
|
return new Auto_Load_Next_Post_Admin(); |
|
214
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.