Admin Columns - Version 3.0.7

Version Description

Release Date: December 22nd, 2017

  • [Added] New setting for content fields: String limit (Limit on words or characters)
  • [Improved] Merged the roles column into the author column
  • [Improved] Added Before/After fields for the following columns: Content, Excerpt, User Description
  • [Improved] Removed deprecated Welcome page
  • [Improved] Removed deprecated Upgrade page
Download this release

Release Info

Developer tschutter
Plugin Icon 128x128 Admin Columns
Version 3.0.7
Comparing to
See all releases

Code changes from version 3.0.5 to 3.0.7

Files changed (42) hide show
  1. api.php +4 -4
  2. classes/Addon.php +7 -319
  3. classes/Admin.php +1 -4
  4. classes/Admin/Addon.php +349 -0
  5. classes/{Addon → Admin/Addon}/ACF.php +1 -1
  6. classes/{Addon → Admin/Addon}/BuddyPress.php +1 -1
  7. classes/{Addon → Admin/Addon}/EventsCalendar.php +1 -1
  8. classes/{Addon → Admin/Addon}/NinjaForms.php +1 -1
  9. classes/{Addon → Admin/Addon}/Pods.php +1 -1
  10. classes/{Addon → Admin/Addon}/Types.php +1 -1
  11. classes/{Addon → Admin/Addon}/WooCommerce.php +1 -1
  12. classes/{Addons.php → Admin/Addons.php} +10 -10
  13. classes/Admin/Page/Addons.php +2 -2
  14. classes/Admin/Page/Help.php +14 -4
  15. classes/Admin/Page/Upgrade.php +0 -372
  16. classes/Admin/Page/Welcome.php +0 -97
  17. classes/Column.php +23 -20
  18. classes/Column/Comment/ID.php +4 -0
  19. classes/Column/Media/AlternateText.php +7 -1
  20. classes/Column/Media/Caption.php +7 -1
  21. classes/Column/Placeholder.php +3 -3
  22. classes/Column/Post/Content.php +2 -1
  23. classes/Column/Post/EstimatedReadingTime.php +1 -1
  24. classes/Column/Post/Excerpt.php +1 -0
  25. classes/Column/Post/Permalink.php +6 -2
  26. classes/Column/Post/Roles.php +0 -42
  27. classes/Column/Post/Shortcodes.php +7 -3
  28. classes/Column/Taxonomy.php +11 -6
  29. classes/Column/User/Description.php +1 -0
  30. classes/Container.php +0 -55
  31. classes/Helper/Html.php +16 -3
  32. classes/Helper/String.php +9 -5
  33. classes/Plugin.php +14 -75
  34. classes/Plugin/Update.php +3 -1
  35. classes/Plugin/Update/{V305.php → V3005.php} +1 -8
  36. classes/Plugin/Update/V3007.php +63 -0
  37. classes/Plugin/Updater.php +15 -3
  38. classes/Settings/Column/StringLimit.php +5 -4
  39. classes/Settings/Column/Type.php +7 -3
  40. classes/Settings/Column/WordLimit.php +0 -1
  41. codepress-admin-columns.php +10 -5
  42. readme.txt +18 -2
api.php CHANGED
@@ -49,14 +49,14 @@ function ac_get_site_utm_url( $path, $utm_medium, $utm_content = null, $utm_camp
49
  // Specific promotions or sales
50
  'utm_campaign' => $utm_campaign,
51
 
52
- // Marketing medium: banner, support documentation, email
53
  'utm_medium' => $utm_medium,
54
 
55
  // Used for differentiation of medium
56
  'utm_content' => $utm_content,
57
  );
58
 
59
- $args = array_map( 'sanitize_key', $args );
60
 
61
  return add_query_arg( $args, $url );
62
  }
@@ -100,7 +100,7 @@ function ac_is_version_gte( $version ) {
100
  * @since 2.2
101
  *
102
  * @param string|array $list_screen_key List screen key or keys
103
- * @param array $column_data
104
  */
105
  function ac_register_columns( $list_screen_keys, $column_data ) {
106
  AC()->api()->load_columndata( $list_screen_keys, $column_data );
@@ -150,7 +150,7 @@ function cac_is_setting_screen( $slug = '' ) {
150
  /**
151
  * Returns true if the installed version of WooCommerce is version X or greater
152
  *
153
- * @since 2.3.4
154
  * @deprecated 3.0
155
  * @return boolean true if the installed version of WooCommerce is version X or greater
156
  */
49
  // Specific promotions or sales
50
  'utm_campaign' => $utm_campaign,
51
 
52
+ // Marketing medium: banner, documentation or email
53
  'utm_medium' => $utm_medium,
54
 
55
  // Used for differentiation of medium
56
  'utm_content' => $utm_content,
57
  );
58
 
59
+ $args = array_map( 'sanitize_key', array_filter( $args ) );
60
 
61
  return add_query_arg( $args, $url );
62
  }
100
  * @since 2.2
101
  *
102
  * @param string|array $list_screen_key List screen key or keys
103
+ * @param array $column_data
104
  */
105
  function ac_register_columns( $list_screen_keys, $column_data ) {
106
  AC()->api()->load_columndata( $list_screen_keys, $column_data );
150
  /**
151
  * Returns true if the installed version of WooCommerce is version X or greater
152
  *
153
+ * @since 2.3.4
154
  * @deprecated 3.0
155
  * @return boolean true if the installed version of WooCommerce is version X or greater
156
  */
classes/Addon.php CHANGED
@@ -4,346 +4,34 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon {
8
 
9
  /**
10
- * @var string
11
- */
12
- private $title;
13
-
14
- /**
15
- * @var string
16
- */
17
- private $description;
18
-
19
- /**
20
- * @var string
21
- */
22
- private $logo;
23
-
24
- /**
25
- * Icon is a small version of the logo. Mainly used on the promo banner.
26
- *
27
- * @var string
28
- */
29
- private $icon;
30
-
31
- /**
32
- * Plugin folder name
33
- *
34
- * @var AC_PluginInformation
35
- */
36
- private $addon;
37
-
38
- /**
39
- * Plugin basename. Example: plugin/plugin.php
40
  *
41
- * @var AC_PluginInformation[]
42
- */
43
- private $plugins;
44
-
45
- /**
46
- * External website link
47
- *
48
- * @var string
49
- */
50
- private $link;
51
-
52
- /**
53
- * Plugin URL. Place where the plugin can be downloaded from. Default is install plugin screen.
54
- *
55
- * @var string Url
56
- */
57
- private $plugin_url;
58
-
59
- public function __construct( $addon_dirname ) {
60
- $this->addon = new AC_PluginInformation( $addon_dirname );
61
- }
62
-
63
- /**
64
- * @return string
65
- */
66
- public function get_title() {
67
- return $this->title;
68
- }
69
-
70
- /**
71
- * @param string $title
72
- */
73
- protected function set_title( $title ) {
74
- $this->title = $title;
75
-
76
- return $this;
77
- }
78
-
79
- /**
80
- * Plugin folder name
81
- *
82
- * @return AC_PluginInformation[]
83
- */
84
- public function get_plugins() {
85
- return $this->plugins;
86
- }
87
-
88
- /**
89
- * @param string $slug Plugin folder name. Example: 'plugin/init.php' then directory name is 'plugin'.
90
- */
91
- protected function add_plugin( $plugin ) {
92
- $this->plugins[] = new AC_PluginInformation( $plugin );
93
-
94
- return $this;
95
- }
96
-
97
- /**
98
- * @return AC_PluginInformation
99
- */
100
- public function get_plugin() {
101
- return $this->plugins[0];
102
- }
103
-
104
- /**
105
- * @return string
106
- */
107
- public function get_link() {
108
- if ( null === $this->link ) {
109
- $this->set_link( ac_get_site_utm_url( 'pricing-purchase', 'addon' ) );
110
- }
111
-
112
- return $this->link;
113
- }
114
-
115
- /**
116
- * @param string $link
117
- */
118
- protected function set_link( $url ) {
119
- if ( ac_helper()->string->is_valid_url( $url ) ) {
120
- $this->link = $url;
121
- }
122
-
123
- return $this;
124
- }
125
-
126
- /**
127
  * @return string
128
  */
129
- public function get_description() {
130
- return $this->description;
131
- }
132
-
133
- /**
134
- * @param string $description
135
- */
136
- protected function set_description( $description ) {
137
- $this->description = $description;
138
-
139
- return $this;
140
- }
141
-
142
- /**
143
- * @return string
144
- */
145
- public function get_logo() {
146
- return $this->logo;
147
- }
148
-
149
- /**
150
- * @param string $logo
151
- */
152
- protected function set_logo( $logo ) {
153
- $this->logo = $logo;
154
-
155
- return $this;
156
- }
157
-
158
- /**
159
- * @return string
160
- */
161
- public function get_icon() {
162
- return $this->icon;
163
- }
164
-
165
- /**
166
- * @param string $icon
167
- */
168
- protected function set_icon( $icon ) {
169
- $this->icon = $icon;
170
-
171
- return $this;
172
- }
173
 
174
  /**
175
- * Plugin folder name
176
- *
177
  * @return string
178
  */
179
- public function get_slug() {
180
- return $this->addon->get_dirname();
181
- }
182
-
183
- /**
184
- * @return bool
185
- */
186
- public function is_installed() {
187
- return $this->addon->is_installed();
188
- }
189
-
190
- /**
191
- * @return bool
192
- */
193
- public function is_active() {
194
- return $this->addon->is_active();
195
- }
196
-
197
- /**
198
- * @return string|false Returns the plugin version if the plugin is installed, false otherwise
199
- */
200
- public function get_version() {
201
- return $this->addon->get_version();
202
- }
203
-
204
- /**
205
- * @return string Basename
206
- */
207
  public function get_basename() {
208
- return $this->addon->get_basename();
209
- }
210
-
211
- /**
212
- * @return bool
213
- */
214
- public function is_plugin_installed() {
215
- return $this->get_plugin()->is_installed();
216
- }
217
-
218
- /**
219
- * @return bool
220
- */
221
- public function is_plugin_active() {
222
- return $this->get_plugin()->is_active();
223
- }
224
-
225
- /**
226
- * @return string Basename
227
- */
228
- public function get_plugin_basename() {
229
- return $this->get_plugin()->get_basename();
230
- }
231
-
232
- /**
233
- * @return string
234
- */
235
- public function get_plugin_activation_url() {
236
- return $this->get_activation_url( $this->get_plugin_basename() );
237
- }
238
-
239
- /**
240
- * Icon
241
- */
242
- public function display_icon() {
243
- if ( $this->get_icon() ) : ?>
244
- <img class="icon <?php echo esc_attr( $this->get_slug() ); ?>" src="<?php echo esc_attr( $this->get_icon() ); ?>" alt="<?php echo esc_attr( $this->get_title() ); ?>">
245
- <?php endif;
246
- }
247
-
248
- public function display_promo() {
249
- if ( $this->get_icon() ) {
250
- $this->display_icon();
251
-
252
- return;
253
- }
254
-
255
- echo $this->get_title();
256
- }
257
-
258
- /**
259
- * @return AC_Column_Placeholder
260
- */
261
- public function get_placeholder_column() {
262
- $column = new AC_Column_Placeholder();
263
- $column->set_addon( $this );
264
-
265
- return $column;
266
- }
267
-
268
- /**
269
- * @param string $title
270
- *
271
- * @return string
272
- */
273
- protected function get_fields_description( $title ) {
274
- return sprintf( __( 'Display and edit %s fields in the posts overview in seconds!', 'codepress-admin-columns' ), $title );
275
  }
276
 
277
  /**
278
- * Activate plugin
279
- *
280
  * @return string
281
  */
282
- public function get_activation_url( $basename ) {
283
- return $this->get_plugin_action_url( 'activate', $basename );
284
  }
285
 
286
  /**
287
- * Deactivate plugin
288
- *
289
- * @return string
290
- */
291
- public function get_deactivation_url( $basename ) {
292
- return $this->get_plugin_action_url( 'deactivate', $basename );
293
- }
294
-
295
- /**
296
- * Activate or Deactivate plugin
297
- *
298
- * @param string $action
299
- *
300
- * @return string
301
- */
302
- private function get_plugin_action_url( $action = 'activate', $basename ) {
303
- $plugin_url = add_query_arg( array(
304
- 'action' => $action,
305
- 'plugin' => $basename,
306
- 'ac-redirect' => true,
307
- ), admin_url( 'plugins.php' ) );
308
-
309
- return wp_nonce_url( $plugin_url, $action . '-plugin_' . $basename );
310
- }
311
-
312
- /**
313
- * @param string $plugin_url
314
- *
315
- * @return $this
316
- */
317
- public function set_plugin_url( $plugin_url ) {
318
- $this->plugin_url = $plugin_url;
319
-
320
- return $this;
321
- }
322
-
323
- /**
324
- * @param string $search_term
325
- *
326
  * @return string
327
  */
328
  public function get_plugin_url() {
329
- if ( null === $this->plugin_url ) {
330
- $this->set_plugin_url( add_query_arg( array(
331
- 'tab' => 'search',
332
- 'type' => 'term',
333
- 's' => $this->get_title(),
334
- ), admin_url( 'plugin-install.php' ) ) );
335
- }
336
-
337
- return $this->plugin_url;
338
- }
339
-
340
- /**
341
- * Show notice on admin page only
342
- *
343
- * @return bool
344
- */
345
- public function show_missing_notice_on_current_page() {
346
- return AC()->admin()->is_admin_screen() || AC()->table_screen()->get_current_list_screen();
347
  }
348
 
349
  }
4
  exit;
5
  }
6
 
7
+ abstract class AC_Addon {
8
 
9
  /**
10
+ * Return the file from this plugin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  * @return string
13
  */
14
+ abstract protected function get_file();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  /**
 
 
17
  * @return string
18
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  public function get_basename() {
20
+ return plugin_basename( $this->get_file() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
  /**
 
 
24
  * @return string
25
  */
26
+ public function get_plugin_dir() {
27
+ return plugin_dir_path( $this->get_file() );
28
  }
29
 
30
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  * @return string
32
  */
33
  public function get_plugin_url() {
34
+ return plugin_dir_url( $this->get_file() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
 
37
  }
classes/Admin.php CHANGED
@@ -42,10 +42,7 @@ class AC_Admin {
42
  ->register_page( new AC_Admin_Page_Columns() )
43
  ->register_page( new AC_Admin_Page_Settings() )
44
  ->register_page( new AC_Admin_Page_Addons() )
45
- ->register_page( new AC_Admin_Page_Help() )
46
- // Hidden
47
- ->register_page( new AC_Admin_Page_Welcome() )
48
- ->register_page( new AC_Admin_Page_Upgrade() );
49
 
50
  do_action( 'ac/admin_pages', $this->pages );
51
  }
42
  ->register_page( new AC_Admin_Page_Columns() )
43
  ->register_page( new AC_Admin_Page_Settings() )
44
  ->register_page( new AC_Admin_Page_Addons() )
45
+ ->register_page( new AC_Admin_Page_Help() );
 
 
 
46
 
47
  do_action( 'ac/admin_pages', $this->pages );
48
  }
classes/Admin/Addon.php ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Admin_Addon {
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ private $title;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ private $description;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ private $logo;
23
+
24
+ /**
25
+ * Icon is a small version of the logo. Mainly used on the promo banner.
26
+ *
27
+ * @var string
28
+ */
29
+ private $icon;
30
+
31
+ /**
32
+ * Plugin folder name
33
+ *
34
+ * @var AC_PluginInformation
35
+ */
36
+ private $addon;
37
+
38
+ /**
39
+ * Plugin basename. Example: plugin/plugin.php
40
+ *
41
+ * @var AC_PluginInformation[]
42
+ */
43
+ private $plugins;
44
+
45
+ /**
46
+ * External website link
47
+ *
48
+ * @var string
49
+ */
50
+ private $link;
51
+
52
+ /**
53
+ * Plugin URL. Place where the plugin can be downloaded from. Default is install plugin screen.
54
+ *
55
+ * @var string Url
56
+ */
57
+ private $plugin_url;
58
+
59
+ public function __construct( $addon_dirname ) {
60
+ $this->addon = new AC_PluginInformation( $addon_dirname );
61
+ }
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function get_title() {
67
+ return $this->title;
68
+ }
69
+
70
+ /**
71
+ * @param string $title
72
+ */
73
+ protected function set_title( $title ) {
74
+ $this->title = $title;
75
+
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Plugin folder name
81
+ *
82
+ * @return AC_PluginInformation[]
83
+ */
84
+ public function get_plugins() {
85
+ return $this->plugins;
86
+ }
87
+
88
+ /**
89
+ * @param string $slug Plugin folder name. Example: 'plugin/init.php' then directory name is 'plugin'.
90
+ */
91
+ protected function add_plugin( $plugin ) {
92
+ $this->plugins[] = new AC_PluginInformation( $plugin );
93
+
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * @return AC_PluginInformation
99
+ */
100
+ public function get_plugin() {
101
+ return $this->plugins[0];
102
+ }
103
+
104
+ /**
105
+ * @return string
106
+ */
107
+ public function get_link() {
108
+ if ( null === $this->link ) {
109
+ $this->set_link( ac_get_site_utm_url( 'pricing-purchase', 'addon' ) );
110
+ }
111
+
112
+ return $this->link;
113
+ }
114
+
115
+ /**
116
+ * @param string $link
117
+ */
118
+ protected function set_link( $url ) {
119
+ if ( ac_helper()->string->is_valid_url( $url ) ) {
120
+ $this->link = $url;
121
+ }
122
+
123
+ return $this;
124
+ }
125
+
126
+ /**
127
+ * @return string
128
+ */
129
+ public function get_description() {
130
+ return $this->description;
131
+ }
132
+
133
+ /**
134
+ * @param string $description
135
+ */
136
+ protected function set_description( $description ) {
137
+ $this->description = $description;
138
+
139
+ return $this;
140
+ }
141
+
142
+ /**
143
+ * @return string
144
+ */
145
+ public function get_logo() {
146
+ return $this->logo;
147
+ }
148
+
149
+ /**
150
+ * @param string $logo
151
+ */
152
+ protected function set_logo( $logo ) {
153
+ $this->logo = $logo;
154
+
155
+ return $this;
156
+ }
157
+
158
+ /**
159
+ * @return string
160
+ */
161
+ public function get_icon() {
162
+ return $this->icon;
163
+ }
164
+
165
+ /**
166
+ * @param string $icon
167
+ */
168
+ protected function set_icon( $icon ) {
169
+ $this->icon = $icon;
170
+
171
+ return $this;
172
+ }
173
+
174
+ /**
175
+ * Plugin folder name
176
+ *
177
+ * @return string
178
+ */
179
+ public function get_slug() {
180
+ return $this->addon->get_dirname();
181
+ }
182
+
183
+ /**
184
+ * @return bool
185
+ */
186
+ public function is_installed() {
187
+ return $this->addon->is_installed();
188
+ }
189
+
190
+ /**
191
+ * @return bool
192
+ */
193
+ public function is_active() {
194
+ return $this->addon->is_active();
195
+ }
196
+
197
+ /**
198
+ * @return string|false Returns the plugin version if the plugin is installed, false otherwise
199
+ */
200
+ public function get_version() {
201
+ return $this->addon->get_version();
202
+ }
203
+
204
+ /**
205
+ * @return string Basename
206
+ */
207
+ public function get_basename() {
208
+ return $this->addon->get_basename();
209
+ }
210
+
211
+ /**
212
+ * @return bool
213
+ */
214
+ public function is_plugin_installed() {
215
+ return $this->get_plugin()->is_installed();
216
+ }
217
+
218
+ /**
219
+ * @return bool
220
+ */
221
+ public function is_plugin_active() {
222
+ return $this->get_plugin()->is_active();
223
+ }
224
+
225
+ /**
226
+ * @return string Basename
227
+ */
228
+ public function get_plugin_basename() {
229
+ return $this->get_plugin()->get_basename();
230
+ }
231
+
232
+ /**
233
+ * @return string
234
+ */
235
+ public function get_plugin_activation_url() {
236
+ return $this->get_activation_url( $this->get_plugin_basename() );
237
+ }
238
+
239
+ /**
240
+ * Icon
241
+ */
242
+ public function display_icon() {
243
+ if ( $this->get_icon() ) : ?>
244
+ <img class="icon <?php echo esc_attr( $this->get_slug() ); ?>" src="<?php echo esc_attr( $this->get_icon() ); ?>" alt="<?php echo esc_attr( $this->get_title() ); ?>">
245
+ <?php endif;
246
+ }
247
+
248
+ public function display_promo() {
249
+ if ( $this->get_icon() ) {
250
+ $this->display_icon();
251
+
252
+ return;
253
+ }
254
+
255
+ echo $this->get_title();
256
+ }
257
+
258
+ /**
259
+ * @return AC_Column_Placeholder
260
+ */
261
+ public function get_placeholder_column() {
262
+ $column = new AC_Column_Placeholder();
263
+ $column->set_addon( $this );
264
+
265
+ return $column;
266
+ }
267
+
268
+ /**
269
+ * @param string $title
270
+ *
271
+ * @return string
272
+ */
273
+ protected function get_fields_description( $title ) {
274
+ return sprintf( __( 'Display and edit %s fields in the posts overview in seconds!', 'codepress-admin-columns' ), $title );
275
+ }
276
+
277
+ /**
278
+ * Activate plugin
279
+ *
280
+ * @return string
281
+ */
282
+ public function get_activation_url( $basename ) {
283
+ return $this->get_plugin_action_url( 'activate', $basename );
284
+ }
285
+
286
+ /**
287
+ * Deactivate plugin
288
+ *
289
+ * @return string
290
+ */
291
+ public function get_deactivation_url( $basename ) {
292
+ return $this->get_plugin_action_url( 'deactivate', $basename );
293
+ }
294
+
295
+ /**
296
+ * Activate or Deactivate plugin
297
+ *
298
+ * @param string $action
299
+ *
300
+ * @return string
301
+ */
302
+ private function get_plugin_action_url( $action = 'activate', $basename ) {
303
+ $plugin_url = add_query_arg( array(
304
+ 'action' => $action,
305
+ 'plugin' => $basename,
306
+ 'ac-redirect' => true,
307
+ ), admin_url( 'plugins.php' ) );
308
+
309
+ return wp_nonce_url( $plugin_url, $action . '-plugin_' . $basename );
310
+ }
311
+
312
+ /**
313
+ * @param string $plugin_url
314
+ *
315
+ * @return $this
316
+ */
317
+ public function set_plugin_url( $plugin_url ) {
318
+ $this->plugin_url = $plugin_url;
319
+
320
+ return $this;
321
+ }
322
+
323
+ /**
324
+ * @param string $search_term
325
+ *
326
+ * @return string
327
+ */
328
+ public function get_plugin_url() {
329
+ if ( null === $this->plugin_url ) {
330
+ $this->set_plugin_url( add_query_arg( array(
331
+ 'tab' => 'search',
332
+ 'type' => 'term',
333
+ 's' => $this->get_title(),
334
+ ), admin_url( 'plugin-install.php' ) ) );
335
+ }
336
+
337
+ return $this->plugin_url;
338
+ }
339
+
340
+ /**
341
+ * Show notice on admin page only
342
+ *
343
+ * @return bool
344
+ */
345
+ public function show_missing_notice_on_current_page() {
346
+ return AC()->admin()->is_admin_screen() || AC()->table_screen()->get_current_list_screen();
347
+ }
348
+
349
+ }
classes/{Addon → Admin/Addon}/ACF.php RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon_ACF extends AC_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'cac-addon-acf' );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addon_ACF extends AC_Admin_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'cac-addon-acf' );
classes/{Addon → Admin/Addon}/BuddyPress.php RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon_BuddyPress extends AC_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-buddypress' );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addon_BuddyPress extends AC_Admin_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-buddypress' );
classes/{Addon → Admin/Addon}/EventsCalendar.php RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon_EventsCalendar extends AC_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-events-calendar' );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addon_EventsCalendar extends AC_Admin_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-events-calendar' );
classes/{Addon → Admin/Addon}/NinjaForms.php RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon_NinjaForms extends AC_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-ninjaforms' );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addon_NinjaForms extends AC_Admin_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-ninjaforms' );
classes/{Addon → Admin/Addon}/Pods.php RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon_Pods extends AC_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-pods' );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addon_Pods extends AC_Admin_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-pods' );
classes/{Addon → Admin/Addon}/Types.php RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon_Types extends AC_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-types' );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addon_Types extends AC_Admin_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'ac-addon-types' );
classes/{Addon → Admin/Addon}/WooCommerce.php RENAMED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addon_WooCommerce extends AC_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'cac-addon-woocommerce' );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addon_WooCommerce extends AC_Admin_Addon {
8
 
9
  public function __construct() {
10
  parent::__construct( 'cac-addon-woocommerce' );
classes/{Addons.php → Admin/Addons.php} RENAMED
@@ -4,15 +4,15 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Addons {
8
 
9
  /**
10
- * @var AC_Addon[]
11
  */
12
  private $addons;
13
 
14
  /**
15
- * @return AC_Addon[]
16
  */
17
  public function get_addons() {
18
  if ( null === $this->addons ) {
@@ -23,7 +23,7 @@ class AC_Addons {
23
  }
24
 
25
  /**
26
- * @return AC_Addon[]
27
  */
28
  public function get_active_promo() {
29
  $addons = $this->get_addons();
@@ -40,7 +40,7 @@ class AC_Addons {
40
  /**
41
  * All addons where 3d party is installed but integration is not installed
42
  *
43
- * @return AC_Addon[]
44
  */
45
  public function get_missing_addons() {
46
  $missing = array();
@@ -55,7 +55,7 @@ class AC_Addons {
55
  }
56
 
57
  /**
58
- * @return AC_addon[]
59
  */
60
  public function get_active_addons() {
61
  $addons = array();
@@ -76,7 +76,7 @@ class AC_Addons {
76
  *
77
  * @param string $slug Addon slug
78
  *
79
- * @return AC_Addon|false Returns addon details if the add-on exists, false otherwise
80
  */
81
  public function get_addon( $slug ) {
82
  foreach ( $this->get_addons() as $addon ) {
@@ -89,9 +89,9 @@ class AC_Addons {
89
  }
90
 
91
  /**
92
- * @param AC_Addon $addon
93
  */
94
- public function register_addon( AC_Addon $addon ) {
95
  $this->addons[] = $addon;
96
  }
97
 
@@ -99,7 +99,7 @@ class AC_Addons {
99
  * Register addon
100
  */
101
  private function set_addons() {
102
- $classes = AC()->autoloader()->get_class_names_from_dir( AC()->get_plugin_dir() . 'classes/Addon', 'AC_' );
103
 
104
  foreach ( $classes as $class ) {
105
  $this->register_addon( new $class );
4
  exit;
5
  }
6
 
7
+ class AC_Admin_Addons {
8
 
9
  /**
10
+ * @var AC_Admin_Addon[]
11
  */
12
  private $addons;
13
 
14
  /**
15
+ * @return AC_Admin_Addon[]
16
  */
17
  public function get_addons() {
18
  if ( null === $this->addons ) {
23
  }
24
 
25
  /**
26
+ * @return AC_Admin_Addon[]
27
  */
28
  public function get_active_promo() {
29
  $addons = $this->get_addons();
40
  /**
41
  * All addons where 3d party is installed but integration is not installed
42
  *
43
+ * @return AC_Admin_Addon[]
44
  */
45
  public function get_missing_addons() {
46
  $missing = array();
55
  }
56
 
57
  /**
58
+ * @return AC_Admin_Addon[]
59
  */
60
  public function get_active_addons() {
61
  $addons = array();
76
  *
77
  * @param string $slug Addon slug
78
  *
79
+ * @return AC_Admin_Addon|false Returns addon details if the add-on exists, false otherwise
80
  */
81
  public function get_addon( $slug ) {
82
  foreach ( $this->get_addons() as $addon ) {
89
  }
90
 
91
  /**
92
+ * @param AC_Admin_Addon $addon
93
  */
94
+ public function register_addon( AC_Admin_Addon $addon ) {
95
  $this->addons[] = $addon;
96
  }
97
 
99
  * Register addon
100
  */
101
  private function set_addons() {
102
+ $classes = AC()->autoloader()->get_class_names_from_dir( AC()->get_plugin_dir() . 'classes/Admin/Addon', 'AC_' );
103
 
104
  foreach ( $classes as $class ) {
105
  $this->register_addon( new $class );
classes/Admin/Page/Addons.php CHANGED
@@ -337,7 +337,7 @@ class AC_Admin_Page_Addons extends AC_Admin_Page {
337
  }
338
  }
339
 
340
- /* @var AC_Addon[] $sorted */
341
  $sorted = array_merge( $active, $inactive );
342
 
343
  $grouped = array();
@@ -379,7 +379,7 @@ class AC_Admin_Page_Addons extends AC_Admin_Page {
379
  <ul>
380
  <?php
381
  foreach ( $group['addons'] as $addon ) :
382
- /* @var AC_Addon $addon */ ?>
383
  <li class="<?php echo esc_attr( $addon->get_slug() ); ?>">
384
  <div class="addon-header">
385
  <div class="inner">
337
  }
338
  }
339
 
340
+ /* @var AC_Admin_Addon[] $sorted */
341
  $sorted = array_merge( $active, $inactive );
342
 
343
  $grouped = array();
379
  <ul>
380
  <?php
381
  foreach ( $group['addons'] as $addon ) :
382
+ /* @var AC_Admin_Addon $addon */ ?>
383
  <li class="<?php echo esc_attr( $addon->get_slug() ); ?>">
384
  <div class="addon-header">
385
  <div class="inner">
classes/Admin/Page/Help.php CHANGED
@@ -151,7 +151,7 @@ class AC_Admin_Page_Help extends AC_Admin_Page {
151
 
152
  // Actions
153
  $this->deprecated_action( 'cac/admin_head', '3.0', 'cac-admin_head' );
154
- $this->deprecated_action( 'cac/loaded', '3.0', 'cac-cacloaded' );
155
  $this->deprecated_action( 'cac/inline-edit/after_ajax_column_save', '3.0', 'cacinline-editafter_ajax_column_save' );
156
  $this->deprecated_action( 'cac/settings/after_title', '3.0' );
157
  $this->deprecated_action( 'cac/settings/form_actions', '3.0' );
@@ -184,7 +184,12 @@ class AC_Admin_Page_Help extends AC_Admin_Page {
184
  if ( has_filter( $hook ) ) {
185
  $message = sprintf( __( 'The filter %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook . '</code>', '<strong>' . $version . '</strong>' );
186
 
187
- $this->add_deprecated_message( 'filter', $message, $hook, 'filter-reference/' . $page_slug );
 
 
 
 
 
188
  }
189
  }
190
 
@@ -197,7 +202,12 @@ class AC_Admin_Page_Help extends AC_Admin_Page {
197
  if ( has_action( $hook ) ) {
198
  $message = sprintf( __( 'The action %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook . '</code>', '<strong>' . $version . '</strong>' );
199
 
200
- $this->add_deprecated_message( 'action', $message, $hook, 'action-reference/' . $page_slug );
 
 
 
 
 
201
  }
202
  }
203
 
@@ -245,7 +255,7 @@ class AC_Admin_Page_Help extends AC_Admin_Page {
245
  * @return false|string
246
  */
247
  private function get_documention_link( $page ) {
248
- return ac_helper()->html->link( ac_get_site_url( 'documentation/' . $page ), __( 'View documentation', 'codepress-admin-columns' ) . ' &raquo;', array( 'target' => '_blank' ) );
249
  }
250
 
251
  /**
151
 
152
  // Actions
153
  $this->deprecated_action( 'cac/admin_head', '3.0', 'cac-admin_head' );
154
+ $this->deprecated_action( 'cac/loaded', '3.0', 'cac-loaded' );
155
  $this->deprecated_action( 'cac/inline-edit/after_ajax_column_save', '3.0', 'cacinline-editafter_ajax_column_save' );
156
  $this->deprecated_action( 'cac/settings/after_title', '3.0' );
157
  $this->deprecated_action( 'cac/settings/form_actions', '3.0' );
184
  if ( has_filter( $hook ) ) {
185
  $message = sprintf( __( 'The filter %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook . '</code>', '<strong>' . $version . '</strong>' );
186
 
187
+ $page = '#filter-reference';
188
+ if ( $page_slug ) {
189
+ $page = 'filter-reference/' . $page_slug;
190
+ }
191
+
192
+ $this->add_deprecated_message( 'filter', $message, $hook, $page );
193
  }
194
  }
195
 
202
  if ( has_action( $hook ) ) {
203
  $message = sprintf( __( 'The action %s used on this website is deprecated since %s.', 'codepress-admin-columns' ), '<code>' . $hook . '</code>', '<strong>' . $version . '</strong>' );
204
 
205
+ $page = '#action-reference';
206
+ if ( $page_slug ) {
207
+ $page = 'action-reference/' . $page_slug;
208
+ }
209
+
210
+ $this->add_deprecated_message( 'action', $message, $hook, $page );
211
  }
212
  }
213
 
255
  * @return false|string
256
  */
257
  private function get_documention_link( $page ) {
258
+ return ac_helper()->html->link( ac_get_site_url( 'documentation' ) . $page, __( 'View documentation', 'codepress-admin-columns' ) . ' &raquo;', array( 'target' => '_blank' ) );
259
  }
260
 
261
  /**
classes/Admin/Page/Upgrade.php DELETED
@@ -1,372 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- /**
8
- * Upgrade
9
- *
10
- * Class largely based on code from ACF ( props to Elliot )
11
- *
12
- * @since 2.0
13
- */
14
- class AC_Admin_Page_Upgrade extends AC_Admin_Page {
15
-
16
- const VERSION_KEY = 'cpac_version';
17
-
18
- public $update_prevented = false;
19
-
20
- /**
21
- * @since 2.0
22
- */
23
- function __construct() {
24
- $this
25
- ->set_slug( 'upgrade' )
26
- ->set_label( __( 'Upgrade', 'codepress-admin-columns' ) )
27
- ->set_show_in_menu( false );
28
-
29
- add_action( 'wp_ajax_cpac_upgrade', array( $this, 'ajax_upgrade' ) );
30
-
31
- if ( ! $this->allow_upgrade() ) {
32
- add_action( 'ac/settings/after_menu', array( $this, 'proaddon_notice' ) );
33
- }
34
-
35
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
36
- }
37
-
38
- /**
39
- * Display a notice about the deprecated pro add-on
40
- *
41
- * @since 2.2
42
- */
43
- public function proaddon_notice() { ?>
44
- <div class="message error">
45
- <p>
46
- <?php _e( 'The pro add-on is no longer supported. Please login to your account and download Admin Columns Pro', 'codepress-admin-columns' ); ?>
47
- <a href="<?php echo ac_get_site_utm_url( 'pro-addon-information', 'pro-notice' ); ?>" target="_blank"><?php _e( 'Learn more', 'codepress-admin-columns' ); ?></a>
48
- </p>
49
- </div>
50
- <?php
51
- }
52
-
53
- /**
54
- * Whether upgrading is allowed
55
- *
56
- * @since 2.1.5
57
- *
58
- * @return bool Whether plugin upgrading is allowed
59
- */
60
- public function allow_upgrade() {
61
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
62
-
63
- return ! is_plugin_active( 'cac-addon-pro/cac-addon-pro.php' );
64
- }
65
-
66
- /**
67
- * Init Upgrade Process
68
- *
69
- * @since 2.0
70
- */
71
- public function ajax_upgrade() {
72
-
73
- // vars
74
- $return = array(
75
- 'status' => false,
76
- 'message' => "",
77
- 'next' => false,
78
- );
79
-
80
- $version = $_POST['version'];
81
-
82
- // versions
83
- switch ( $version ) {
84
-
85
- case '2.0.0' :
86
-
87
- $old_settings = get_option( 'cpac_options' );
88
-
89
- // old settings
90
- if ( ! empty( $old_settings['columns'] ) ) {
91
-
92
- foreach ( $old_settings['columns'] as $storage_key => $old_columns ) {
93
-
94
- $columns = array();
95
-
96
- if ( $old_columns ) {
97
-
98
- // used to determine clone ID
99
- $tax_count = null;
100
- $post_count = null;
101
- $meta_count = null;
102
-
103
- foreach ( $old_columns as $old_column_name => $old_column_settings ) {
104
-
105
- // only active columns
106
- if ( isset( $old_column_settings['state'] ) && 'on' !== $old_column_settings['state'] ) {
107
- continue;
108
- }
109
-
110
- // convert old settings to new
111
- $settings = array_merge( $old_column_settings, array(
112
- 'type' => $old_column_name,
113
- 'clone' => '',
114
- ) );
115
-
116
- // set name
117
- $name = $old_column_name;
118
-
119
- // convert: Users
120
- if ( 'wp-users' == $storage_key ) {
121
-
122
- // is user post count?
123
- if ( strpos( $old_column_name, 'column-user_postcount-' ) !== false ) {
124
- $settings['type'] = 'column-user_postcount';
125
- $settings['clone'] = $post_count;
126
- $settings['post_type'] = str_replace( 'column-user_postcount-', '', $old_column_name );
127
-
128
- $name = $post_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
129
- $post_count++;
130
- }
131
- }
132
-
133
- // convert: Media
134
- elseif ( 'wp-media' == $storage_key ) {
135
-
136
- if ( 'column-filesize' == $old_column_name ) {
137
- $name = 'column-file_size';
138
- $settings['type'] = $name;
139
- }
140
- // is EXIF data?
141
- elseif ( strpos( $old_column_name, 'column-image-' ) !== false ) {
142
- $name = 'column-exif_data';
143
- $settings['type'] = $name;
144
- $settings['exif_datatype'] = str_replace( 'column-image-', '', $old_column_name );
145
- }
146
- elseif ( 'column-file_paths' == $old_column_name ) {
147
- $name = 'column-available_sizes';
148
- $settings['type'] = $name;
149
- }
150
- }
151
-
152
- // convert: Comments
153
- elseif ( 'wp-comments' == $storage_key ) {
154
-
155
- if ( 'column-author_author' == $old_column_name ) {
156
- $name = 'column-author';
157
- $settings['type'] = $name;
158
- }
159
- }
160
-
161
- // convert: Posts
162
- else {
163
-
164
- if ( 'column-attachment-count' == $old_column_name ) {
165
- $name = 'column-attachment_count';
166
- $settings['type'] = $name;
167
- }
168
- elseif ( 'column-author-name' == $old_column_name ) {
169
- $name = 'column-author_name';
170
- $settings['type'] = $name;
171
- $settings['display_author_as'] = $old_column_settings['display_as'];
172
- }
173
- elseif ( 'column-before-moretag' == $old_column_name ) {
174
- $name = 'column-before_moretag';
175
- $settings['type'] = $name;
176
- }
177
- elseif ( 'column-comment-count' == $old_column_name ) {
178
- $name = 'column-comment_count';
179
- $settings['type'] = $name;
180
- $settings['comment_status'] = 'total_comments';
181
- }
182
- elseif ( 'column-comment-status' == $old_column_name ) {
183
- $name = 'column-comment_status';
184
- $settings['type'] = $name;
185
- }
186
- elseif ( 'column-ping-status' == $old_column_name ) {
187
- $name = 'column-ping_status';
188
- $settings['type'] = $name;
189
- }
190
- elseif ( 'column-page-slug' == $old_column_name ) {
191
- $name = 'column-slug';
192
- $settings['type'] = $name;
193
- }
194
- elseif ( 'column-page-template' == $old_column_name ) {
195
- $name = 'column-page_template';
196
- $settings['type'] = $name;
197
- }
198
- }
199
-
200
- // convert: Applies to all storage types
201
-
202
- // is taxonomy?
203
- if ( strpos( $old_column_name, 'column-taxonomy-' ) !== false ) {
204
- $settings['type'] = 'column-taxonomy';
205
- $settings['clone'] = $tax_count;
206
- $settings['taxonomy'] = str_replace( 'column-taxonomy-', '', $old_column_name );
207
-
208
- $name = $tax_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
209
- $tax_count++;
210
- }
211
- // is custom field?
212
- elseif ( strpos( $old_column_name, 'column-meta-' ) !== false ) {
213
-
214
- $settings['type'] = 'column-meta';
215
- //$settings['clone'] = str_replace( 'column-meta-', '', $old_column_name );
216
- $settings['clone'] = $meta_count;
217
-
218
- $name = $meta_count ? $settings['type'] . '-' . $settings['clone'] : $settings['type'];
219
- $meta_count++;
220
- }
221
- elseif ( 'column-word-count' == $old_column_name ) {
222
- $name = 'column-word_count';
223
- $settings['type'] = $name;
224
- }
225
-
226
- // add to column set
227
- $columns[ $name ] = $settings;
228
-
229
- // reorder so that active column are at the top of the pile.
230
- $active = $inactive = array();
231
- foreach ( $columns as $name => $_settings ) {
232
- if ( 'on' === $_settings['state'] ) {
233
- $active[ $name ] = $_settings;
234
- }
235
- else {
236
- $inactive[ $name ] = $_settings;
237
- }
238
- }
239
- $columns = array_merge( $active, $inactive );
240
- }
241
-
242
- // store column settings
243
- if ( ! get_option( "cpac_options_{$storage_key}" ) ) {
244
- update_option( "cpac_options_{$storage_key}", $columns );
245
- }
246
- }
247
- }
248
- }
249
-
250
- // update version
251
- update_option( self::VERSION_KEY, $version );
252
-
253
- $return = array(
254
- 'status' => true,
255
- 'message' => __( "Migrating Column Settings", 'codepress-admin-columns' ) . '...',
256
- 'next' => false,
257
- );
258
-
259
- break;
260
- }
261
-
262
- // return json
263
- echo json_encode( $return );
264
- die;
265
- }
266
-
267
- /*
268
- * Starting points of the upgrade process
269
- *
270
- * @since 2.0
271
- */
272
- public function start_upgrade() {
273
-
274
- $version = get_option( self::VERSION_KEY, '1.0.0' );
275
- $next = false;
276
-
277
- // list of starting points
278
- if ( $version < '2.0.0' ) {
279
- $next = '2.0.0';
280
- }
281
-
282
- // Run upgrade?
283
- if ( $next ) : ?>
284
- <script type="text/javascript">
285
- run_upgrade( "<?php echo $next; ?>" );
286
- </script>
287
- <?php
288
-
289
- // No update required
290
- else : ?>
291
- <p><?php _e( 'No Upgrade Required', 'codepress-admin-columns' ); ?></p>
292
- <?php echo ac_helper()->html->link( AC()->admin()->get_link( 'welcome' ), __( 'Return to welcome screen.', 'codepress-admin-columns' ) );
293
- endif;
294
- }
295
-
296
- /**
297
- * Scripts
298
- *
299
- * @since 2.0
300
- */
301
- public function admin_scripts() {
302
- if ( ! $this->is_current_screen() ) {
303
- return;
304
- }
305
-
306
- wp_enqueue_script( 'ac-upgrade', AC()->get_plugin_url() . 'assets/js/upgrade.js', array( 'jquery' ), AC()->get_version() );
307
- wp_localize_script( 'ac-upgrade', 'cpac_upgrade_i18n', array(
308
- 'complete' => __( 'Upgrade Complete!', 'codepress-admin-columns' ) . '</p><p><a href="' . esc_url( AC()->admin()->get_link( 'welcome' ) ) . '">' . __( 'Return to settings.', 'codepress-admin-columns' ) . "</a>",
309
- 'error' => __( 'Error', 'codepress-admin-columns' ),
310
- 'major_error' => __( 'Sorry. Something went wrong during the upgrade process. Please report this on the support forum.', 'codepress-admin-columns' ),
311
- ) );
312
- }
313
-
314
- /**
315
- * @since 2.0
316
- */
317
- public function display() {
318
- ?>
319
- <h1><?php _e( 'Upgrade', 'codepress-admin-columns' ); ?></h1>
320
- <?php
321
-
322
- $version = get_option( self::VERSION_KEY, false );
323
-
324
- // Maybe version pre 2.0.0 was used
325
- if ( ! $version && get_option( 'cpac_options' ) ) {
326
- $version = '1.0.0';
327
- }
328
-
329
- // Maybe upgrade?
330
- if ( $version ) {
331
-
332
- // run every upgrade
333
- if ( $version < AC()->get_version() ) {
334
- // nothing yet
335
- }
336
-
337
- // run only when updating from v1 to v2
338
- if ( $version < '2.0.0' ) {
339
-
340
- // show welcome screen
341
- wp_safe_redirect( AC()->admin()->get_link( 'welcome' ) );
342
- exit;
343
- }
344
-
345
- // run only when database upgrade is needed
346
- if ( $version < AC()->get_upgrade_version() ) {
347
-
348
- // display upgrade message on every page except upgrade page itself
349
- if ( ! ( isset( $_REQUEST['page'] ) && 'upgrade' === $_REQUEST['page'] ) ) {
350
-
351
- $message = sprintf( "Admin Columns %s requires a database upgrade.", AC()->get_version() );
352
- $message .= sprintf( "Please %s, then click %s.", ac_helper()->html->link( 'http://codex.wordpress.org/Backing_Up_Your_Database', 'backup your database' ), ac_helper()->html->link( $this->get_link(), 'Upgrade Database' ) );
353
-
354
- AC()->notice( $message, 'updated' );
355
- }
356
- }
357
-
358
- // run when NO upgrade is needed
359
- elseif ( $version < AC()->get_version() ) {
360
-
361
- update_option( self::VERSION_KEY, AC()->get_version() );
362
- }
363
- }
364
-
365
- // Fresh install
366
- else {
367
-
368
- update_option( self::VERSION_KEY, AC()->get_version() );
369
- }
370
- }
371
-
372
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/Admin/Page/Welcome.php DELETED
@@ -1,97 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- class AC_Admin_Page_Welcome extends AC_Admin_Page {
8
-
9
- public function __construct() {
10
- $this
11
- ->set_slug( 'welcome' )
12
- ->set_label( __( 'Welcome', 'codepress-admin-columns' ) )
13
- ->set_show_in_menu( false );
14
- }
15
-
16
- private function get_sub_tabs() {
17
- return array(
18
- '' => 'Welcome',
19
- 'changelog' => 'Changelog',
20
- );
21
- }
22
-
23
- private function get_current_tab() {
24
- return filter_input( INPUT_GET, 'sub_tab' );
25
- }
26
-
27
- private function display_changelog() {
28
- ?>
29
- <h3><?php echo __( "Changelog for", 'codepress-admin-columns' ) . ' ' . AC()->get_version(); ?></h3>
30
- <?php
31
-
32
- $items = file_get_contents( AC()->get_plugin_dir() . 'readme.txt' );
33
- $items = explode( '= ' . AC()->get_version() . ' =', $items );
34
- $items = end( $items );
35
- $items = explode( "\n\n", $items );
36
-
37
- $changelog = false;
38
- foreach ( $items as $item ) {
39
- if ( 0 === strpos( $item, '*' ) ) {
40
- $changelog = $item;
41
- break;
42
- }
43
- }
44
-
45
- $items = array_filter( array_map( 'trim', explode( "*", $changelog ) ) );
46
- ?>
47
- <ul class="cpac-changelog">
48
- <?php echo implode( '<br/>', $items ); ?>
49
- </ul>
50
- <?php
51
- }
52
-
53
- public function display() {
54
- ?>
55
-
56
- <div id="cpac-welcome" class="wrap about-wrap">
57
-
58
- <h1><?php echo __( "Welcome to Admin Columns", 'codepress-admin-columns' ) . ' ' . AC()->get_version(); ?></h1>
59
-
60
- <div class="about-text">
61
- <?php _e( "Thank you for updating to the latest version!", 'codepress-admin-columns' ); ?>
62
- <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'codepress-admin-columns' ); ?>
63
- </div>
64
-
65
- <div class="cpac-content-body">
66
- <h2 class="nav-tab-wrapper">
67
- <?php foreach ( $this->get_sub_tabs() as $slug => $label ) {
68
- echo ac_helper()->html->link( add_query_arg( array( 'sub_tab' => $slug ), $this->get_link() ), $label, array( 'class' => 'cpac-tab-toggle nav-tab' . ( $this->get_current_tab() == $slug ? ' nav-tab-active' : '' ) ) );
69
- } ?>
70
-
71
- </h2>
72
-
73
- <?php switch ( $this->get_current_tab() ) {
74
-
75
- case 'changelog' :
76
- $this->display_changelog();
77
- break;
78
-
79
- default :
80
- ?>
81
- <h3>Changes</h3>
82
- <p>*</p>
83
- <?php
84
- }
85
- ?>
86
-
87
- </div>
88
-
89
- <div class="cpac-content-footer">
90
- <a class="button-primary button-large" href="<?php echo esc_url( AC()->admin_columns_screen()->get_link() ); ?>"><?php _e( "Start using Admin Columns", 'codepress-admin-columns' ); ?></a>
91
- </div>
92
-
93
- </div>
94
- <?php
95
- }
96
-
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/Column.php CHANGED
@@ -49,11 +49,6 @@ class AC_Column {
49
  */
50
  protected $list_screen;
51
 
52
- /**
53
- * @var AC_Container
54
- */
55
- private $services;
56
-
57
  /**
58
  * The options managed by the settings
59
  *
@@ -121,20 +116,6 @@ class AC_Column {
121
  return $this;
122
  }
123
 
124
- /**
125
- * Container to inject and get services for this column
126
- *
127
- * @since 3.0.5
128
- * @return AC_Container
129
- */
130
- public function services() {
131
- if ( null === $this->services ) {
132
- $this->services = new AC_Container();
133
- }
134
-
135
- return $this->services;
136
- }
137
-
138
  /**
139
  * Get the type of the column.
140
  *
@@ -397,6 +378,28 @@ class AC_Column {
397
  return $value;
398
  }
399
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  /**
401
  * Get the raw, underlying value for the column
402
  * Not suitable for direct display, use get_value() for that
@@ -416,7 +419,7 @@ class AC_Column {
416
  *
417
  * @param int $id
418
  *
419
- * @return int|string
420
  */
421
  public function get_value( $id ) {
422
  $value = $this->get_formatted_value( $this->get_raw_value( $id ), $id );
49
  */
50
  protected $list_screen;
51
 
 
 
 
 
 
52
  /**
53
  * The options managed by the settings
54
  *
116
  return $this;
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  /**
120
  * Get the type of the column.
121
  *
378
  return $value;
379
  }
380
 
381
+ /**
382
+ * True when the column is sortable by default
383
+ *
384
+ * return bool
385
+ */
386
+ public function is_native_sortable() {
387
+ if ( ! $this->is_original() ) {
388
+ return false;
389
+ }
390
+
391
+ $table = $this->get_list_screen()->get_list_table();
392
+
393
+ if ( ! $table instanceof WP_List_Table ) {
394
+ return false;
395
+ }
396
+
397
+ $column_info = $table->get_column_info();
398
+ $sortables = $column_info[2];
399
+
400
+ return isset( $sortables[ $this->get_type() ] );
401
+ }
402
+
403
  /**
404
  * Get the raw, underlying value for the column
405
  * Not suitable for direct display, use get_value() for that
419
  *
420
  * @param int $id
421
  *
422
+ * @return string
423
  */
424
  public function get_value( $id ) {
425
  $value = $this->get_formatted_value( $this->get_raw_value( $id ), $id );
classes/Column/Comment/ID.php CHANGED
@@ -18,4 +18,8 @@ class AC_Column_Comment_ID extends AC_Column {
18
  return $id;
19
  }
20
 
 
 
 
 
21
  }
18
  return $id;
19
  }
20
 
21
+ public function get_raw_value( $id ) {
22
+ return $id;
23
+ }
24
+
25
  }
classes/Column/Media/AlternateText.php CHANGED
@@ -19,7 +19,13 @@ class AC_Column_Media_AlternateText extends AC_Column_Meta {
19
  }
20
 
21
  public function get_value( $id ) {
22
- return ac_helper()->string->strip_trim( $this->get_raw_value( $id ) );
 
 
 
 
 
 
23
  }
24
 
25
  public function get_raw_value( $id ) {
19
  }
20
 
21
  public function get_value( $id ) {
22
+ $value = ac_helper()->string->strip_trim( $this->get_raw_value( $id ) );
23
+
24
+ if ( ! $value ) {
25
+ return $this->get_empty_char();
26
+ }
27
+
28
+ return $value;
29
  }
30
 
31
  public function get_raw_value( $id ) {
classes/Column/Media/Caption.php CHANGED
@@ -15,7 +15,13 @@ class AC_Column_Media_Caption extends AC_Column {
15
  }
16
 
17
  public function get_value( $id ) {
18
- return esc_html( $this->get_raw_value( $id ) );
 
 
 
 
 
 
19
  }
20
 
21
  public function get_raw_value( $id ) {
15
  }
16
 
17
  public function get_value( $id ) {
18
+ $value = esc_html( $this->get_raw_value( $id ) );
19
+
20
+ if ( ! $value ) {
21
+ return $this->get_empty_char();
22
+ }
23
+
24
+ return $value;
25
  }
26
 
27
  public function get_raw_value( $id ) {
classes/Column/Placeholder.php CHANGED
@@ -12,14 +12,14 @@ if ( ! defined( 'ABSPATH' ) ) {
12
  class AC_Column_Placeholder extends AC_Column {
13
 
14
  /**
15
- * @var AC_Addon
16
  */
17
  private $addon;
18
 
19
  /**
20
- * @param AC_Addon $addon
21
  */
22
- public function set_addon( AC_Addon $addon ) {
23
  $this->addon = $addon;
24
 
25
  $this->set_type( 'placeholder-' . $addon->get_slug() );
12
  class AC_Column_Placeholder extends AC_Column {
13
 
14
  /**
15
+ * @var AC_Admin_Addon
16
  */
17
  private $addon;
18
 
19
  /**
20
+ * @param AC_Admin_Addon $addon
21
  */
22
+ public function set_addon( AC_Admin_Addon $addon ) {
23
  $this->addon = $addon;
24
 
25
  $this->set_type( 'placeholder-' . $addon->get_slug() );
classes/Column/Post/Content.php CHANGED
@@ -19,7 +19,8 @@ class AC_Column_Post_Content extends AC_Column {
19
  }
20
 
21
  public function register_settings() {
22
- $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
 
23
  }
24
 
25
  }
19
  }
20
 
21
  public function register_settings() {
22
+ $this->add_setting( new AC_Settings_Column_StringLimit( $this ) );
23
+ $this->add_setting( new AC_Settings_Column_BeforeAfter( $this ) );
24
  }
25
 
26
  }
classes/Column/Post/EstimatedReadingTime.php CHANGED
@@ -18,7 +18,7 @@ class AC_Column_Post_EstimatedReadingTime extends AC_Column {
18
  * Estimate read time in seconds
19
  * @since 2.3.3
20
  *
21
- * @return int Seconds
22
  */
23
  public function get_raw_value( $post_id ) {
24
  return ac_helper()->post->get_raw_field( 'post_content', $post_id );
18
  * Estimate read time in seconds
19
  * @since 2.3.3
20
  *
21
+ * @return string Raw Post Content
22
  */
23
  public function get_raw_value( $post_id ) {
24
  return ac_helper()->post->get_raw_field( 'post_content', $post_id );
classes/Column/Post/Excerpt.php CHANGED
@@ -30,6 +30,7 @@ class AC_Column_Post_Excerpt extends AC_Column {
30
 
31
  public function register_settings() {
32
  $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
 
33
  }
34
 
35
  }
30
 
31
  public function register_settings() {
32
  $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
33
+ $this->add_setting( new AC_Settings_Column_BeforeAfter( $this ) );
34
  }
35
 
36
  }
classes/Column/Post/Permalink.php CHANGED
@@ -16,10 +16,14 @@ class AC_Column_Post_Permalink extends AC_Column {
16
  $this->set_label( __( 'Permalink', 'codepress-admin-columns' ) );
17
  }
18
 
19
- public function get_raw_value( $id ) {
20
- $link = get_permalink( $id );
21
 
22
  return ac_helper()->html->link( $link, $link, array( 'target' => '_blank' ) );
23
  }
24
 
 
 
 
 
25
  }
16
  $this->set_label( __( 'Permalink', 'codepress-admin-columns' ) );
17
  }
18
 
19
+ public function get_value( $id ) {
20
+ $link = $this->get_raw_value( $id );
21
 
22
  return ac_helper()->html->link( $link, $link, array( 'target' => '_blank' ) );
23
  }
24
 
25
+ public function get_raw_value( $id ) {
26
+ return get_permalink( $id );
27
+ }
28
+
29
  }
classes/Column/Post/Roles.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- /**
8
- * @since 2.0
9
- */
10
- class AC_Column_Post_Roles extends AC_Column {
11
-
12
- public function __construct() {
13
- $this->set_type( 'column-roles' );
14
- $this->set_label( __( 'Roles', 'codepress-admin-columns' ) );
15
- }
16
-
17
- /**
18
- * @param int $post_id
19
- *
20
- * @return string
21
- */
22
- public function get_value( $post_id ) {
23
- $names = ac_helper()->user->get_role_names( $this->get_raw_value( $post_id ) );
24
-
25
- if ( ! $names ) {
26
- return $this->get_empty_char();
27
- }
28
-
29
- return implode( __( ', ' ), $names );
30
- }
31
-
32
- public function get_raw_value( $post_id ) {
33
- $userdata = get_userdata( get_post_field( 'post_author', $post_id ) );
34
-
35
- if ( empty( $userdata->roles[0] ) ) {
36
- return array();
37
- }
38
-
39
- return $userdata->roles;
40
- }
41
-
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/Column/Post/Shortcodes.php CHANGED
@@ -49,9 +49,13 @@ class AC_Column_Post_Shortcodes extends AC_Column {
49
  $_shortcodes = array_keys( $shortcode_tags );
50
  asort( $_shortcodes );
51
 
52
- foreach ( $_shortcodes as $sc ) {
53
- if ( $count = substr_count( $content, '[' . $sc ) ) {
54
- $shortcodes[ $sc ] = $count;
 
 
 
 
55
  }
56
  }
57
 
49
  $_shortcodes = array_keys( $shortcode_tags );
50
  asort( $_shortcodes );
51
 
52
+ foreach ( $_shortcodes as $shortcode ) {
53
+
54
+ $count = substr_count( $content, '[' . $shortcode . ']' );
55
+ $count += substr_count( $content, '[' . $shortcode . ' ' );
56
+
57
+ if ( $count ) {
58
+ $shortcodes[ $shortcode ] = $count;
59
  }
60
  }
61
 
classes/Column/Taxonomy.php CHANGED
@@ -21,16 +21,23 @@ class AC_Column_Taxonomy extends AC_Column {
21
  return $this->get_option( 'taxonomy' );
22
  }
23
 
24
- // Display
25
-
26
  public function get_value( $post_id ) {
27
- $terms = ac_helper()->taxonomy->get_term_links( get_the_terms( $post_id, $this->get_taxonomy() ), get_post_type( $post_id ) );
 
 
 
 
28
 
29
  return ac_helper()->string->enumeration_list( $terms, 'and' );
30
  }
31
 
 
 
 
 
 
32
  public function get_raw_value( $post_id ) {
33
- $terms = wp_get_post_terms( $post_id, $this->get_taxonomy(), array( 'fields' => 'ids' ) );
34
 
35
  if ( ! $terms || is_wp_error( $terms ) ) {
36
  return false;
@@ -39,8 +46,6 @@ class AC_Column_Taxonomy extends AC_Column {
39
  return $terms;
40
  }
41
 
42
- // Settings
43
-
44
  public function register_settings() {
45
  $this->add_setting( new AC_Settings_Column_Taxonomy( $this ) );
46
  }
21
  return $this->get_option( 'taxonomy' );
22
  }
23
 
 
 
24
  public function get_value( $post_id ) {
25
+ $terms = ac_helper()->taxonomy->get_term_links( $this->get_raw_value( $post_id ), get_post_type( $post_id ) );
26
+
27
+ if ( empty( $terms ) ) {
28
+ return $this->get_empty_char();
29
+ }
30
 
31
  return ac_helper()->string->enumeration_list( $terms, 'and' );
32
  }
33
 
34
+ /**
35
+ * @param int $post_id
36
+ *
37
+ * @return array|false
38
+ */
39
  public function get_raw_value( $post_id ) {
40
+ $terms = get_the_terms( $post_id, $this->get_taxonomy() );
41
 
42
  if ( ! $terms || is_wp_error( $terms ) ) {
43
  return false;
46
  return $terms;
47
  }
48
 
 
 
49
  public function register_settings() {
50
  $this->add_setting( new AC_Settings_Column_Taxonomy( $this ) );
51
  }
classes/Column/User/Description.php CHANGED
@@ -20,6 +20,7 @@ class AC_Column_User_Description extends AC_Column {
20
 
21
  public function register_settings() {
22
  $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
 
23
  }
24
 
25
  }
20
 
21
  public function register_settings() {
22
  $this->add_setting( new AC_Settings_Column_WordLimit( $this ) );
23
+ $this->add_setting( new AC_Settings_Column_BeforeAfter( $this ) );
24
  }
25
 
26
  }
classes/Container.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- class AC_Container {
8
-
9
- /**
10
- * @var object[]
11
- */
12
- protected $services = array();
13
-
14
- /**
15
- * @param string $id
16
- *
17
- * @return false|object
18
- */
19
- public function get( $id ) {
20
- return $this->has( $id ) ? $this->services[ $id ] : false;
21
- }
22
-
23
- /**
24
- * @param string $id
25
- * @param object $service
26
- *
27
- * @return $this
28
- */
29
- public function set( $id, $service ) {
30
- if ( ! is_object( $service ) ) {
31
- throw new InvalidArgumentException( sprintf( 'The %s service is not an object.', $id ) );
32
- }
33
-
34
- $this->services[ $id ] = $service;
35
-
36
- return $this;
37
- }
38
-
39
- /**
40
- * @param string $id
41
- *
42
- * @return bool
43
- */
44
- public function has( $id ) {
45
- return array_key_exists( $id, $this->services );
46
- }
47
-
48
- /**
49
- * @return string[]
50
- */
51
- public function get_ids() {
52
- return array_keys( $this->services );
53
- }
54
-
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/Helper/Html.php CHANGED
@@ -178,11 +178,12 @@ class AC_Helper_Html {
178
  /**
179
  * Returns an array with internal / external links
180
  *
181
- * @param $string
 
182
  *
183
  * @return false|array [ internal | external ]
184
  */
185
- public function get_internal_external_links( $string ) {
186
  if ( ! class_exists( 'DOMDocument' ) ) {
187
  return false;
188
  }
@@ -192,6 +193,10 @@ class AC_Helper_Html {
192
  return false;
193
  }
194
 
 
 
 
 
195
  $internal_links = array();
196
  $external_links = array();
197
 
@@ -204,7 +209,15 @@ class AC_Helper_Html {
204
  /** @var DOMElement $link */
205
  $href = $link->getAttribute( 'href' );
206
 
207
- if ( false !== strpos( $href, home_url() ) ) {
 
 
 
 
 
 
 
 
208
  $internal_links[] = $href;
209
  } else {
210
  $external_links[] = $href;
178
  /**
179
  * Returns an array with internal / external links
180
  *
181
+ * @param string $string
182
+ * @param array $internal_domains Domains which determine internal links. Default is home_url().
183
  *
184
  * @return false|array [ internal | external ]
185
  */
186
+ public function get_internal_external_links( $string, $internal_domains = array() ) {
187
  if ( ! class_exists( 'DOMDocument' ) ) {
188
  return false;
189
  }
193
  return false;
194
  }
195
 
196
+ if ( ! $internal_domains ) {
197
+ $internal_domains = array( home_url() );
198
+ }
199
+
200
  $internal_links = array();
201
  $external_links = array();
202
 
209
  /** @var DOMElement $link */
210
  $href = $link->getAttribute( 'href' );
211
 
212
+ $internal = false;
213
+
214
+ foreach ( (array) $internal_domains as $domain ) {
215
+ if ( false !== strpos( $href, $domain ) ) {
216
+ $internal = true;
217
+ }
218
+ }
219
+
220
+ if ( $internal ) {
221
  $internal_links[] = $href;
222
  } else {
223
  $external_links[] = $href;
classes/Helper/String.php CHANGED
@@ -74,6 +74,10 @@ class AC_Helper_String {
74
  return false;
75
  }
76
 
 
 
 
 
77
  return wp_trim_words( $string, $num_words, $more );
78
  }
79
 
@@ -201,15 +205,15 @@ class AC_Helper_String {
201
  * @return array
202
  */
203
  public function string_to_array_integers( $string ) {
204
- $values = $this->comma_separated_to_array( $string );
205
 
206
- foreach ( $values as $k => $value ) {
207
- if ( ! is_numeric( trim( $value ) ) ) {
208
- unset( $values[ $k ] );
209
  }
210
  }
211
 
212
- return $values;
213
  }
214
 
215
  /**
74
  return false;
75
  }
76
 
77
+ if ( ! $num_words ) {
78
+ return $string;
79
+ }
80
+
81
  return wp_trim_words( $string, $num_words, $more );
82
  }
83
 
205
  * @return array
206
  */
207
  public function string_to_array_integers( $string ) {
208
+ $integers = array();
209
 
210
+ foreach ( $this->comma_separated_to_array( $string ) as $k => $value ) {
211
+ if ( is_numeric( trim( $value ) ) ) {
212
+ $integers[] = $value;
213
  }
214
  }
215
 
216
+ return $integers;
217
  }
218
 
219
  /**
classes/Plugin.php CHANGED
@@ -4,34 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- abstract class AC_Plugin {
8
-
9
- /**
10
- * @var string
11
- */
12
- private $plugin_dir;
13
-
14
- /**
15
- * @var string
16
- */
17
- private $plugin_url;
18
-
19
- /**
20
- * @var string
21
- */
22
- private $basename;
23
-
24
- /**
25
- * @var bool
26
- */
27
- private $fresh_install;
28
-
29
- /**
30
- * Return the file from this plugin
31
- *
32
- * @return string
33
- */
34
- abstract protected function get_file();
35
 
36
  /**
37
  * Check if plugin is network activated
@@ -55,55 +28,29 @@ abstract class AC_Plugin {
55
  }
56
 
57
  /**
58
- * @return string
 
 
 
 
59
  */
60
- public function get_basename() {
61
- if ( null === $this->basename ) {
62
- $this->set_basename();
63
- }
64
 
65
- return $this->basename;
66
- }
67
-
68
- protected function set_basename() {
69
- $this->basename = plugin_basename( $this->get_file() );
70
- }
71
-
72
- /**
73
- * @return string
74
- */
75
- public function get_plugin_dir() {
76
- if ( null === $this->plugin_dir ) {
77
- $this->set_plugin_dir();
78
  }
79
 
80
- return $this->plugin_dir;
81
- }
82
-
83
- protected function set_plugin_dir() {
84
- $this->plugin_dir = plugin_dir_path( $this->get_file() );
85
  }
86
 
87
  /**
88
  * @return string
89
  */
90
- public function get_plugin_url() {
91
- if ( null === $this->plugin_url ) {
92
- $this->set_plugin_url();
93
- }
94
-
95
- return $this->plugin_url;
96
  }
97
 
98
- protected function set_plugin_url() {
99
- $this->plugin_url = plugin_dir_url( $this->get_file() );
100
- }
101
-
102
- /**
103
- * @return string
104
- */
105
- public abstract function get_version();
106
-
107
  /**
108
  * @return string
109
  */
@@ -127,14 +74,6 @@ abstract class AC_Plugin {
127
  * Check if the plugin was updated or is a fresh install
128
  */
129
  public function is_fresh_install() {
130
- if ( null === $this->fresh_install ) {
131
- $this->set_fresh_install();
132
- }
133
-
134
- return $this->fresh_install;
135
- }
136
-
137
- protected function set_fresh_install() {
138
  global $wpdb;
139
 
140
  $sql = "
@@ -146,7 +85,7 @@ abstract class AC_Plugin {
146
 
147
  $results = $wpdb->get_results( $sql );
148
 
149
- $this->fresh_install = empty( $results );
150
  }
151
 
152
  }
4
  exit;
5
  }
6
 
7
+ abstract class AC_Plugin extends AC_Addon {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  /**
10
  * Check if plugin is network activated
28
  }
29
 
30
  /**
31
+ * Return a plugin header from the plugin data
32
+ *
33
+ * @param $key
34
+ *
35
+ * @return false|string
36
  */
37
+ protected function get_plugin_header( $key ) {
38
+ $data = $this->get_plugin_data();
 
 
39
 
40
+ if ( ! isset( $data[ $key ] ) ) {
41
+ return false;
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
+ return $data[ $key ];
 
 
 
 
45
  }
46
 
47
  /**
48
  * @return string
49
  */
50
+ public function get_version() {
51
+ return $this->get_plugin_header( 'Version' );
 
 
 
 
52
  }
53
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * @return string
56
  */
74
  * Check if the plugin was updated or is a fresh install
75
  */
76
  public function is_fresh_install() {
 
 
 
 
 
 
 
 
77
  global $wpdb;
78
 
79
  $sql = "
85
 
86
  $results = $wpdb->get_results( $sql );
87
 
88
+ return empty( $results );
89
  }
90
 
91
  }
classes/Plugin/Update.php CHANGED
@@ -31,7 +31,9 @@ abstract class AC_Plugin_Update {
31
  *
32
  * @return bool
33
  */
34
- public abstract function needs_update();
 
 
35
 
36
  /**
37
  * @return bool
31
  *
32
  * @return bool
33
  */
34
+ public function needs_update() {
35
+ return $this->is_less_or_equal_stored_version();
36
+ }
37
 
38
  /**
39
  * @return bool
classes/Plugin/Update/{V305.php → V3005.php} RENAMED
@@ -4,14 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
7
- class AC_Plugin_Update_V305 extends AC_Plugin_Update {
8
-
9
- /**
10
- * @return bool
11
- */
12
- public function needs_update() {
13
- return $this->is_less_or_equal_stored_version();
14
- }
15
 
16
  public function apply_update() {
17
  $this->migrate_user_specific_settings();
4
  exit;
5
  }
6
 
7
+ class AC_Plugin_Update_V3005 extends AC_Plugin_Update {
 
 
 
 
 
 
 
8
 
9
  public function apply_update() {
10
  $this->migrate_user_specific_settings();
classes/Plugin/Update/V3007.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class AC_Plugin_Update_V3007 extends AC_Plugin_Update {
8
+
9
+ public function apply_update() {
10
+ $this->update_roles_column();
11
+ }
12
+
13
+ protected function set_version() {
14
+ $this->version = '3.0.7';
15
+ }
16
+
17
+ /**
18
+ * Change the roles columns to the author column
19
+ */
20
+ private function update_roles_column() {
21
+ global $wpdb;
22
+
23
+ $sql = "
24
+ SELECT *
25
+ FROM {$wpdb->options}
26
+ WHERE option_name LIKE 'cpac_options_%'
27
+ ";
28
+
29
+ $results = $wpdb->get_results( $sql );
30
+
31
+ if ( ! is_array( $results ) ) {
32
+ return;
33
+ }
34
+
35
+ foreach ( $results as $row ) {
36
+ $options = maybe_unserialize( $row->option_value );
37
+ $update = false;
38
+
39
+ if ( ! is_array( $options ) ) {
40
+ continue;
41
+ }
42
+
43
+ foreach ( $options as $k => $v ) {
44
+ if ( ! is_array( $v ) || empty( $v['type'] ) || $v['type'] !== 'column-roles' ) {
45
+ continue;
46
+ }
47
+
48
+ $v['type'] = 'column-author_name';
49
+ $v['display_author_as'] = 'roles';
50
+ $v['edit'] = 'off';
51
+
52
+ $options[ $k ] = $v;
53
+
54
+ $update = true;
55
+ }
56
+
57
+ if ( $update ) {
58
+ update_option( $row->option_name, $options );
59
+ }
60
+ }
61
+ }
62
+
63
+ }
classes/Plugin/Updater.php CHANGED
@@ -36,7 +36,9 @@ class AC_Plugin_Updater {
36
  */
37
  public function __construct( AC_Plugin $plugin ) {
38
  $this->plugin = $plugin;
39
- $this->apply_updates = 'true' === filter_input( INPUT_GET, 'ac_do_update' );
 
 
40
  }
41
 
42
  public function add_update( AC_Plugin_Update $update ) {
@@ -44,7 +46,6 @@ class AC_Plugin_Updater {
44
  }
45
 
46
  public function parse_updates() {
47
-
48
  // Network wide updating is not allowed
49
  if ( is_network_admin() ) {
50
  return;
@@ -76,10 +77,21 @@ class AC_Plugin_Updater {
76
 
77
  if ( $this->apply_updates ) {
78
  $plugin->update_stored_version( $plugin->get_version() );
 
 
79
  }
80
  }
81
 
82
- public function show_update_notice() {
 
 
 
 
 
 
 
 
 
83
  $url = add_query_arg( array( 'ac_do_update' => 'true' ), AC()->admin()->get_settings_url() );
84
 
85
  $message = sprintf( '<strong>%s</strong> &ndash; %s <a href="%s" class="button ac-update-now">%s</a>',
36
  */
37
  public function __construct( AC_Plugin $plugin ) {
38
  $this->plugin = $plugin;
39
+ // TODO: https://github.com/codepress/admin-columns-issues/issues/982
40
+ //$this->apply_updates = 'true' === filter_input( INPUT_GET, 'ac_do_update' );
41
+ $this->apply_updates = true;
42
  }
43
 
44
  public function add_update( AC_Plugin_Update $update ) {
46
  }
47
 
48
  public function parse_updates() {
 
49
  // Network wide updating is not allowed
50
  if ( is_network_admin() ) {
51
  return;
77
 
78
  if ( $this->apply_updates ) {
79
  $plugin->update_stored_version( $plugin->get_version() );
80
+ // TODO: https://github.com/codepress/admin-columns-issues/issues/982
81
+ //$this->show_completed_notice();
82
  }
83
  }
84
 
85
+ protected function show_completed_notice() {
86
+ $message = sprintf( '<strong>%s</strong> &ndash; %s',
87
+ esc_html__( 'Admin Columns', 'codepress-admin-columns' ),
88
+ esc_html__( 'Your database is up to date. You are awesome.', 'codepress-admin-columns' )
89
+ );
90
+
91
+ AC()->notice( $message );
92
+ }
93
+
94
+ protected function show_update_notice() {
95
  $url = add_query_arg( array( 'ac_do_update' => 'true' ), AC()->admin()->get_settings_url() );
96
 
97
  $message = sprintf( '<strong>%s</strong> &ndash; %s <a href="%s" class="button ac-update-now">%s</a>',
classes/Settings/Column/StringLimit.php CHANGED
@@ -21,7 +21,8 @@ class AC_Settings_Column_StringLimit extends AC_Settings_Column {
21
  ->set_options( $this->get_limit_options() );
22
 
23
  $view = new AC_View( array(
24
- 'label' => __( 'Maximum Length', 'codepress-admin-columns' ),
 
25
  'setting' => $setting,
26
  ) );
27
 
@@ -30,9 +31,9 @@ class AC_Settings_Column_StringLimit extends AC_Settings_Column {
30
 
31
  private function get_limit_options() {
32
  $options = array(
33
- '' => __( 'No Maximum Length', 'codepress-admin-columns' ),
34
- 'character_limit' => __( 'Limit on Characters', 'codepress-admin-columns' ),
35
- 'word_limit' => __( 'Limit on Words', 'codepress-admin-columns' ),
36
  );
37
 
38
  return $options;
21
  ->set_options( $this->get_limit_options() );
22
 
23
  $view = new AC_View( array(
24
+ 'label' => __( 'Text Limit', 'codepress-admin-columns' ),
25
+ 'tooltip' => __( 'Limit text to a certain number of characters or words', 'codepress-admin-columns' ),
26
  'setting' => $setting,
27
  ) );
28
 
31
 
32
  private function get_limit_options() {
33
  $options = array(
34
+ '' => __( 'No limit', 'codepress-admin-columns' ),
35
+ 'character_limit' => __( 'Character Limit', 'codepress-admin-columns' ),
36
+ 'word_limit' => __( 'Word Limit', 'codepress-admin-columns' ),
37
  );
38
 
39
  return $options;
classes/Settings/Column/Type.php CHANGED
@@ -23,10 +23,14 @@ class AC_Settings_Column_Type extends AC_Settings_Column {
23
  ->set_options( $this->get_grouped_columns() );
24
 
25
  // Tooltip
26
- $tooltip = __( 'Choose a column type.', 'codepress-admin-columns' ) . '<em>' . __( 'Type', 'codepress-admin-columns' ) . ': ' . $this->column->get_type() . '</em>';
27
 
28
- if ( $this->column->get_name() ) {
29
- $tooltip .= '<em>' . __( 'Name', 'codepress-admin-columns' ) . ': ' . $this->column->get_name() . '</em>';
 
 
 
 
30
  }
31
 
32
  $view = new AC_View( array(
23
  ->set_options( $this->get_grouped_columns() );
24
 
25
  // Tooltip
26
+ $tooltip = __( 'Choose a column type.', 'codepress-admin-columns' );
27
 
28
+ if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
29
+ $tooltip .= '<em>' . __( 'Type', 'codepress-admin-columns' ) . ': ' . $this->column->get_type() . '</em>';
30
+
31
+ if ( $this->column->get_name() ) {
32
+ $tooltip .= '<em>' . __( 'Name', 'codepress-admin-columns' ) . ': ' . $this->column->get_name() . '</em>';
33
+ }
34
  }
35
 
36
  $view = new AC_View( array(
classes/Settings/Column/WordLimit.php CHANGED
@@ -27,7 +27,6 @@ class AC_Settings_Column_WordLimit extends AC_Settings_Column
27
  ->set_attributes( array(
28
  'min' => 0,
29
  'step' => 1,
30
- 'placeholder' => $this->get_default(),
31
  ) );
32
 
33
  $view = new AC_View( array(
27
  ->set_attributes( array(
28
  'min' => 0,
29
  'step' => 1,
 
30
  ) );
31
 
32
  $view = new AC_View( array(
codepress-admin-columns.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Admin Columns
4
- Version: 3.0.5
5
  Description: Customize columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
6
  Author: AdminColumns.com
7
  Author URI: https://www.admincolumns.com
@@ -35,6 +35,7 @@ if ( ! is_admin() ) {
35
  }
36
 
37
  require_once 'classes/Autoloader.php';
 
38
  require_once 'classes/Plugin.php';
39
  require_once 'api.php';
40
 
@@ -92,7 +93,7 @@ class CPAC extends AC_Plugin {
92
  private $api;
93
 
94
  /**
95
- * @var AC_Addons
96
  */
97
  private $addons;
98
 
@@ -130,7 +131,7 @@ class CPAC extends AC_Plugin {
130
  new AC_ThirdParty_WPML();
131
 
132
  // Init
133
- $this->addons = new AC_Addons();
134
  $this->admin = new AC_Admin();
135
  $this->table_screen = new AC_TableScreen();
136
  $this->helper = new AC_Helper();
@@ -173,7 +174,7 @@ class CPAC extends AC_Plugin {
173
  * @return string
174
  */
175
  public function get_version() {
176
- return '3.0.5';
177
  }
178
 
179
  public function ready() {
@@ -215,6 +216,10 @@ class CPAC extends AC_Plugin {
215
  * Handle installation and updates
216
  */
217
  public function install() {
 
 
 
 
218
  $classes = AC()->autoloader()->get_class_names_from_dir( $this->get_plugin_dir() . 'classes/Plugin/Update', 'AC_' );
219
  $updater = new AC_Plugin_Updater( $this );
220
 
@@ -308,7 +313,7 @@ class CPAC extends AC_Plugin {
308
 
309
  /**
310
  * @since 2.2
311
- * @return AC_Addons Add-ons class instance
312
  */
313
  public function addons() {
314
  return $this->addons;
1
  <?php
2
  /*
3
  Plugin Name: Admin Columns
4
+ Version: 3.0.7
5
  Description: Customize columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
6
  Author: AdminColumns.com
7
  Author URI: https://www.admincolumns.com
35
  }
36
 
37
  require_once 'classes/Autoloader.php';
38
+ require_once 'classes/Addon.php';
39
  require_once 'classes/Plugin.php';
40
  require_once 'api.php';
41
 
93
  private $api;
94
 
95
  /**
96
+ * @var AC_Admin_Addons
97
  */
98
  private $addons;
99
 
131
  new AC_ThirdParty_WPML();
132
 
133
  // Init
134
+ $this->addons = new AC_Admin_Addons();
135
  $this->admin = new AC_Admin();
136
  $this->table_screen = new AC_TableScreen();
137
  $this->helper = new AC_Helper();
174
  * @return string
175
  */
176
  public function get_version() {
177
+ return '3.0.7';
178
  }
179
 
180
  public function ready() {
216
  * Handle installation and updates
217
  */
218
  public function install() {
219
+ if ( 0 === version_compare( $this->get_version(), $this->get_stored_version() ) ) {
220
+ return;
221
+ }
222
+
223
  $classes = AC()->autoloader()->get_class_names_from_dir( $this->get_plugin_dir() . 'classes/Plugin/Update', 'AC_' );
224
  $updater = new AC_Plugin_Updater( $this );
225
 
313
 
314
  /**
315
  * @since 2.2
316
+ * @return AC_Admin_Addons Add-ons class instance
317
  */
318
  public function addons() {
319
  return $this->addons;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: codepress, tschutter, davidmosterd, engelen, dungengronovius
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J
4
  Tags: plugins, wordpress, admin, column, columns, custom columns, custom fields, image, dashboard, sortable, filters, posts, media, users, pages, posttypes, manage columns, wp-admin
5
  Requires at least: 4.5
6
- Tested up to: 4.8.1
7
- Stable tag: 3.0.5
8
 
9
  Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
10
 
@@ -218,6 +218,22 @@ You can find a list of the available actions and filters (and examples on how to
218
 
219
  == Changelog ==
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  = 3.0.5 =
222
 
223
  Release Date: November 9th, 2017
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J
4
  Tags: plugins, wordpress, admin, column, columns, custom columns, custom fields, image, dashboard, sortable, filters, posts, media, users, pages, posttypes, manage columns, wp-admin
5
  Requires at least: 4.5
6
+ Tested up to: 4.9.1
7
+ Stable tag: 3.0.7
8
 
9
  Customise columns on the administration screens for post(types), pages, media, comments, links and users with an easy to use drag-and-drop interface.
10
 
218
 
219
  == Changelog ==
220
 
221
+ = 3.0.7 =
222
+
223
+ Release Date: December 22nd, 2017
224
+
225
+ * [Added] New setting for content fields: String limit (Limit on words or characters)
226
+ * [Improved] Merged the roles column into the author column
227
+ * [Improved] Added Before/After fields for the following columns: Content, Excerpt, User Description
228
+ * [Improved] Removed deprecated Welcome page
229
+ * [Improved] Removed deprecated Upgrade page
230
+
231
+ = 3.0.6 =
232
+
233
+ Release Date: November 22nd, 2017
234
+
235
+ * [Fixed] Removed unused classes and methods
236
+
237
  = 3.0.5 =
238
 
239
  Release Date: November 9th, 2017