1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Auto Load Next Post - Admin. |
4
|
|
|
* |
5
|
|
|
* @since 1.0.0 |
6
|
|
|
* @version 1.4.8 |
7
|
|
|
* @author Sébastien Dumont |
8
|
|
|
* @category Admin |
9
|
|
|
* @package Auto Load Next Post |
10
|
|
|
* @license GPL-2.0+ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
if ( ! defined('ABSPATH')) { |
14
|
|
|
exit; // Exit if accessed directly. |
15
|
|
|
} |
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
|
|
|
* @version 1.4.8 |
49
|
|
|
* @access public |
50
|
|
|
* @param mixed $links |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
|
|
public function action_links($links) { |
54
|
|
|
if (current_user_can('manage_options')) { |
55
|
|
|
$plugin_links = array( |
56
|
|
|
'<a href="'.esc_url('https://autoloadnextpost.com/premium/?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>', |
57
|
|
|
'<a href="'.admin_url('options-general.php?page=auto-load-next-post-settings').'">'.__('Settings', '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
|
|
|
* @version 1.4.8 |
71
|
|
|
* @access public |
72
|
|
|
* @param array $input already defined meta links |
73
|
|
|
* @param string $file plugin file path and name being processed |
74
|
|
|
* @return array $input |
75
|
|
|
*/ |
76
|
|
|
public function plugin_row_meta($input, $file) { |
77
|
|
|
if (plugin_basename(AUTO_LOAD_NEXT_POST_FILE) !== $file) { |
78
|
|
|
return $input; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$links = array( |
82
|
|
|
'<a href="'.esc_url('https://github.com/seb86/Auto-Load-Next-Post/wiki/').'" target="_blank">'.__('Documentation', 'auto-load-next-post').'</a>', |
83
|
|
|
'<a href="'.esc_url('https://wordpress.org/support/plugin/auto-load-next-post').'" target="_blank">'.__('Community Support', 'auto-load-next-post').'</a>', |
84
|
|
|
'<a href="'.esc_url('https://autoloadnextpost.com/product/setup-support/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page').'" target="_blank">'.__('Setup Support', 'auto-load-next-post').'</a>', |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
$input = array_merge($input, $links); |
88
|
|
|
|
89
|
|
|
return $input; |
90
|
|
|
} // END plugin_row_meta() |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Include any classes we need within admin. |
94
|
|
|
* |
95
|
|
|
* @since 1.0.0 |
96
|
|
|
* @access public |
97
|
|
|
*/ |
98
|
|
|
public function includes() { |
99
|
|
|
// Classes we only need if the ajax is not-ajax |
100
|
|
|
if ( ! auto_load_next_post_is_ajax()) { |
101
|
|
|
include('class-auto-load-next-post-install.php'); // Install Plugin |
102
|
|
|
include('class-auto-load-next-post-admin-menus.php'); // Plugin Menu |
103
|
|
|
include('class-auto-load-next-post-admin-notices.php'); // Plugin Notices |
104
|
|
|
include('class-auto-load-next-post-admin-help.php'); // Plugin Help Tab |
105
|
|
|
} |
106
|
|
|
} // END includes() |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Registers and enqueues stylesheets and javascripts |
110
|
|
|
* for the administration panel. |
111
|
|
|
* |
112
|
|
|
* @since 1.0.0 |
113
|
|
|
* @access public |
114
|
|
|
*/ |
115
|
|
|
public function admin_scripts() { |
116
|
|
|
// Auto Load Next Post Main Javascript |
117
|
|
|
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); |
118
|
|
|
// Chosen |
119
|
|
|
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); |
120
|
|
|
// TipTip |
121
|
|
|
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); |
122
|
|
|
// Variables for Admin JavaScripts |
123
|
|
|
wp_localize_script(AUTO_LOAD_NEXT_POST_SLUG.'_admin_script', 'auto_load_next_post_admin_params', array( |
124
|
|
|
'i18n_nav_warning' => __('The changes you made will be lost if you navigate away from this page.', 'auto-load-next-post'), |
125
|
|
|
)); |
126
|
|
|
|
127
|
|
|
// Stylesheets |
128
|
|
|
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'); |
129
|
|
|
Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_chosen_style', '/assets/css/libs/chosen'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.css'); |
130
|
|
|
} // END admin_scripts() |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Filters the admin footer text by placing simply thank you to those who |
134
|
|
|
* like and review the plugin on WordPress.org. |
135
|
|
|
* |
136
|
|
|
* @since 1.0.0 |
137
|
|
|
* @version 1.4.8 |
138
|
|
|
* @access public |
139
|
|
|
* @param $text |
140
|
|
|
* @return string |
141
|
|
|
*/ |
142
|
|
|
public function admin_footer_text($text) { |
143
|
|
|
$screen = get_current_screen(); |
144
|
|
|
|
145
|
|
|
if ($screen->id == 'settings_page_auto-load-next-post-settings') { |
146
|
|
|
|
147
|
|
|
// Rating and Review |
148
|
|
|
$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'); |
149
|
|
|
|
150
|
|
|
return $text; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
return $text; |
154
|
|
|
} // END admin_footer_text() |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Filters the update footer by placing the version of the plugin |
158
|
|
|
* when viewing any of the plugins pages. |
159
|
|
|
* |
160
|
|
|
* @since 1.0.0 |
161
|
|
|
* @version 1.4.8 |
162
|
|
|
* @access public |
163
|
|
|
* @param $text |
164
|
|
|
* @return string $text |
165
|
|
|
*/ |
166
|
|
|
public function update_footer($text) { |
167
|
|
|
$screen = get_current_screen(); |
168
|
|
|
|
169
|
|
|
if ($screen->id == 'settings_page_auto-load-next-post-settings') { |
170
|
|
|
|
171
|
|
|
$text = '<p class="alignright">'.sprintf(__('%s Version', 'auto-load-next-post'), 'Auto Load Next Post').' '.esc_attr(AUTO_LOAD_NEXT_POST_VERSION).'</p>'; |
172
|
|
|
|
173
|
|
|
return $text; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
return $text; |
177
|
|
|
} // END update_footer() |
178
|
|
|
|
179
|
|
|
} // END class |
180
|
|
|
|
181
|
|
|
} // END if class exists |
182
|
|
|
|
183
|
|
|
return new Auto_Load_Next_Post_Admin(); |
184
|
|
|
|
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.