PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.4.2
Admin Columns v2.4.2
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / settings.php
codepress-admin-columns / classes Last commit date
column 11 years ago storage_model 11 years ago addons.php 11 years ago column.php 11 years ago review_notice.php 11 years ago settings.php 11 years ago storage_model.php 11 years ago third_party.php 11 years ago upgrade.php 11 years ago utility.php 11 years ago
settings.php
964 lines
1 <?php
2
3 /**
4 * CPAC_Settings Class
5 *
6 * @since 2.0
7 */
8 class CPAC_Settings {
9
10 /**
11 * CPAC class
12 *
13 * @since 2.0
14 */
15 private $cpac;
16
17 /**
18 * Settings Page
19 *
20 * @since 2.0
21 */
22 private $settings_page;
23
24 /**
25 * @since 2.0
26 * @param object CPAC
27 */
28 function __construct( $cpac ) {
29
30 $this->cpac = $cpac;
31
32 // register settings
33 add_action( 'admin_menu', array( $this, 'settings_menu' ) );
34
35 // handle requests gets a low priority so it will trigger when all other plugins have loaded their columns
36 add_action( 'admin_init', array( $this, 'handle_column_request' ), 1000 );
37
38 add_action( 'wp_ajax_cpac_column_refresh', array( $this, 'ajax_column_refresh' ) );
39
40 add_action( 'cpac_messages', array( $this, 'maybe_display_addon_statuschange_message' ) );
41 }
42
43 /**
44 * @since 3.1.1
45 */
46 public function get_settings_page() {
47 return $this->settings_page;
48 }
49
50 /**
51 * Get available Admin Columns admin page URLs
52 *
53 * @since 2.2
54 * @return array Available settings URLs ([settings_page] => [url])
55 */
56 public function get_settings_urls() {
57
58 /**
59 * Filter the URLs for the different settings screens available in admin columns
60 *
61 * @since 2.2
62 *
63 * @param array $settings_urls Available settings URLs ([settings_page] => [url])
64 * @param CPAC_Settings $settings_instance Settings class instance
65 */
66 $settings_urls = apply_filters( 'cac/settings/settings_urls', array(
67 'admin' => admin_url( 'options-general.php?page=codepress-admin-columns' ),
68 'settings' => admin_url( 'options-general.php?page=codepress-admin-columns&tab=settings' ),
69 'info' => admin_url( 'options-general.php?page=codepress-admin-columns&info=' ),
70 'upgrade' => admin_url( 'options-general.php?page=cpac-upgrade' )
71 ), $this );
72
73 return $settings_urls;
74 }
75
76 /**
77 * Get the settings URL for a page
78 *
79 * @since 2.2
80 * @param string $page Optional. Admin page to get the URL from. Defaults to the basic Admin Columns page
81 * @return string Settings page URL
82 */
83 public function get_settings_url( $page = '' ) {
84
85 $settings_urls = $this->get_settings_urls();
86
87 if ( isset( $settings_urls[ $page ] ) ) {
88 return $settings_urls[ $page ];
89 }
90
91 if ( ! $page ) {
92 return $settings_urls['admin'];;
93 }
94
95 return add_query_arg( 'tab', $page, $this->get_settings_url() );
96 }
97
98 /**
99 * Display an activation/deactivation message on the addons page if applicable
100 *
101 * @since 2.2
102 */
103 public function maybe_display_addon_statuschange_message() {
104
105 if ( empty( $_REQUEST['tab'] ) || $_REQUEST['tab'] != 'addons' ) {
106 return;
107 }
108
109 $message = '';
110
111 if ( ! empty( $_REQUEST['activate'] ) ) {
112 $message = __( 'Add-on successfully activated.', 'cpac' );
113 }
114 else if ( ! empty( $_REQUEST['deactivate'] ) ) {
115 $message = __( 'Add-on successfully deactivated.', 'cpac' );
116 }
117
118 if ( ! $message ) {
119 return;
120 }
121 ?>
122 <div class="updated cac-notification below-h2">
123 <p><?php echo $message; ?></p>
124 </div>
125 <?php
126 }
127
128 /**
129 * @since 2.2
130 */
131 public function ajax_column_refresh() {
132 if ( ! empty( $_POST['formdata'] ) && ! empty( $_POST['column'] ) ) {
133 parse_str( $_POST['formdata'], $formdata );
134 $storagemodel_key = ! empty( $formdata['cpac_key'] ) ? $formdata['cpac_key'] : '';
135
136 if ( $storagemodel_key && ! empty( $formdata[ $storagemodel_key ][ $_POST['column'] ] ) ) {
137 $columndata = $formdata[ $formdata['cpac_key'] ][ $_POST['column'] ];
138 $storage_model = $this->cpac->get_storage_model( $formdata['cpac_key'] );
139 $registered_columns = $storage_model->get_registered_columns();
140
141 if ( in_array( $columndata['type'], array_keys( $registered_columns ) ) ) {
142 $column = clone $registered_columns[ $columndata['type'] ];
143 $column->set_clone( $columndata['clone'] );
144
145 foreach ( $columndata as $optionname => $optionvalue ) {
146 $column->set_options( $optionname, $optionvalue );
147 }
148
149 $column->sanitize_label();
150
151 $columns = array( $column->properties->name => $column );
152
153 do_action( 'cac/columns', $columns );
154 do_action( "cac/columns/storage_key={$storagemodel_key}", $columns );
155
156 $column->display();
157 }
158 }
159 }
160
161 exit;
162 }
163
164 /**
165 * @since 1.0
166 */
167 public function settings_menu() {
168
169 // add settings page
170 $this->settings_page = add_submenu_page( 'options-general.php', __( 'Admin Columns Settings', 'cpac' ), __( 'Admin Columns', 'cpac' ), 'manage_admin_columns', 'codepress-admin-columns', array( $this, 'display' ), false, 98 );
171
172 // add help tabs
173 add_action( "load-{$this->settings_page}", array( $this, 'help_tabs' ) );
174
175 // add scripts & styles
176 add_action( "admin_print_styles-{$this->settings_page}", array( $this, 'admin_styles' ) );
177 add_action( "admin_print_scripts-{$this->settings_page}", array( $this, 'admin_scripts' ) );
178
179 // register setting
180 register_setting( 'cpac-general-settings', 'cpac_general_options' );
181
182 // add cap to options.php
183 add_filter( 'option_page_capability_cpac-general-settings', array( $this, 'add_capability' ) );
184 }
185
186 /**
187 * Allows the capaiblity 'manage_admin_columns' to store data through /wp-admin/options.php
188 *
189 * @since 2.0
190 */
191 public function add_capability() {
192 return 'manage_admin_columns';
193 }
194
195 /**
196 * @since 1.0
197 */
198 public function admin_styles() {
199 $minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
200
201 wp_enqueue_style( 'wp-pointer' );
202 wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL . 'assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
203 wp_enqueue_style( 'cpac-admin', CPAC_URL . "assets/css/admin-column{$minified}.css", array(), CPAC_VERSION, 'all' );
204 }
205
206 /**
207 * @since 1.0
208 */
209 public function admin_scripts() {
210
211 wp_enqueue_script( 'wp-pointer' );
212 wp_enqueue_script( 'jquery-ui-slider' );
213
214 $minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
215
216 wp_enqueue_script( 'cpac-admin-settings', CPAC_URL . "assets/js/admin-settings{$minified}.js", array( 'jquery', 'dashboard', 'jquery-ui-slider', 'jquery-ui-sortable' ), CPAC_VERSION );
217
218 // javascript translations
219 wp_localize_script( 'cpac-admin-settings', 'cpac_i18n', array(
220 'clone' => __( '%s column is already present and can not be duplicated.', 'cpac' ),
221 ));
222 }
223
224 /**
225 * @since 1.0
226 */
227 public function handle_column_request() {
228
229 // only handle updates from the admin columns page
230 if ( ! ( isset($_GET['page'] ) && in_array( $_GET['page'], array( 'codepress-admin-columns' ) ) && isset( $_REQUEST['cpac_action'] ) ) ) {
231 return false;
232 }
233
234 // use $_REQUEST because the values are send both over $_GET and $_POST
235 $action = isset( $_REQUEST['cpac_action'] ) ? $_REQUEST['cpac_action'] : '';
236 $nonce = isset( $_REQUEST['_cpac_nonce'] ) ? $_REQUEST['_cpac_nonce'] : '';
237 $key = isset( $_REQUEST['cpac_key'] ) ? $_REQUEST['cpac_key'] : '';
238
239 switch ( $action ) :
240
241 case 'update_by_type' :
242 if ( wp_verify_nonce( $nonce, 'update-type' ) ) {
243 $storage_model = $this->cpac->get_storage_model( $key );
244 $storage_model->store();
245 }
246 break;
247
248 case 'restore_by_type' :
249 if ( wp_verify_nonce( $nonce, 'restore-type' ) ) {
250 $storage_model = $this->cpac->get_storage_model( $key );
251 $storage_model->restore();
252 }
253 break;
254
255 case 'restore_all' :
256 if ( wp_verify_nonce( $nonce, 'restore-all' ) ) {
257 $this->restore_all();
258 }
259 break;
260
261 endswitch;
262 }
263
264 /**
265 * Restore all column defaults
266 *
267 * @since 1.0
268 */
269 private function restore_all() {
270 global $wpdb;
271
272 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cpac_options_%'" );
273
274 cpac_admin_message( __( 'Default settings succesfully restored.', 'cpac' ), 'updated' );
275 }
276
277 /**
278 * Add help tabs to top menu
279 *
280 * @since 1.3.0
281 */
282 public function help_tabs() {
283
284 $screen = get_current_screen();
285
286 if ( ! method_exists( $screen,'add_help_tab' ) )
287 return;
288
289 $tabs = array(
290 array(
291 'title' => __( "Overview", 'cpac' ),
292 'content' =>
293 "<h5>Admin Columns</h5>
294 <p>". __( "This plugin is for adding and removing additional columns to the administration screens for post(types), pages, media library, comments, links and users. Change the column's label and reorder them.", 'cpac' ) . "</p>"
295 ),
296 array(
297 'title' => __( "Basics", 'cpac' ),
298 'content' => "
299 <h5>" . __( "Change order", 'cpac' ) . "</h5>
300 <p>" . __( "By dragging the columns you can change the order which they will appear in.", 'cpac' ) . "</p>
301 <h5>" . __( "Change label", 'cpac' ) . "</h5>
302 <p>" . __( "By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.", 'cpac' ) . "</p>
303 <h5>" . __( "Change column width", 'cpac' ) . "</h5>
304 <p>" . __( "By clicking on the triangle you will see the column options. By using the draggable slider you can set the width of the columns in percentages.", 'cpac' ) . "</p>
305 "
306 ),
307 array(
308 'title' => __( "Custom Field", 'cpac' ),
309 'content' =>
310 "<h5>". __( "'Custom Field' column", 'cpac' ) . "</h5>
311 <p>". __( "The custom field colum uses the custom fields from posts and users. There are 10 types which you can set.", 'cpac' ) . "</p>
312 <ul>
313 <li><strong>". __( "Default", 'cpac' ) . "</strong><br/>". __( "Value: Can be either a string or array. Arrays will be flattened and values are seperated by a ',' comma.", 'cpac' ) . "</li>
314 <li><strong>". __( "Image", 'cpac' ) . "</strong><br/>". __( "Value: should contain an image URL or Attachment IDs ( seperated by a ',' comma ).", 'cpac' ) . "</li>
315 <li><strong>". __( "Excerpt", 'cpac' ) . "</strong><br/>". __( "Value: This will show the first 20 words of the Post content.", 'cpac' ) . "</li>
316 <li><strong>". __( "Multiple Values", 'cpac' ) . "</strong><br/>". __( "Value: should be an array. This will flatten any ( multi dimensional ) array.", 'cpac' ) . "</li>
317 <li><strong>". __( "Numeric", 'cpac' ) . "</strong><br/>". __( "Value: Integers only.<br/>If you have the 'sorting addon' this will be used for sorting, so you can sort your posts on numeric (custom field) values.", 'cpac' ) . "</li>
318 <li><strong>". __( "Date", 'cpac' ) . "</strong><br/>". sprintf( __( "Value: Can be unix time stamp or a date format as described in the <a href='%s'>Codex</a>. You can change the outputted date format at the <a href='%s'>general settings</a> page.", 'cpac' ), 'http://codex.wordpress.org/Formatting_Date_and_Time', get_admin_url() . 'options-general.php' ) . "</li>
319 <li><strong>". __( "Post Titles", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more Post ID's (seperated by ',').", 'cpac' ) . "</li>
320 <li><strong>". __( "Usernames", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more User ID's (seperated by ',').", 'cpac' ) . "</li>
321 <li><strong>". __( "Checkmark", 'cpac' ) . "</strong><br/>". __( "Value: should be a 1 (one) or 0 (zero).", 'cpac' ) . "</li>
322 <li><strong>". __( "Color", 'cpac' ) . "</strong><br/>". __( "Value: hex value color, such as #808080.", 'cpac' ) . "</li>
323 <li><strong>". __( "Counter", 'cpac' ) . "</strong><br/>". __( "Value: Can be either a string or array. This will display a count of the number of times the meta key is used by the item.", 'cpac' ) . "</li>
324 </ul>
325 "
326 )
327 );
328
329 foreach ( $tabs as $k => $tab ) {
330 $screen->add_help_tab( array(
331 'id' => 'cpac-tab-'.$k,
332 'title' => $tab['title'],
333 'content' => $tab['content'],
334 ));
335 }
336 }
337
338 /**
339 * @since 1.0
340 * @param string $storage_model URL type.
341 * @return string Url.
342 */
343 function get_url( $type ) {
344
345 $site_url = 'http://www.admincolumns.com';
346
347 $urls = array(
348 'main' => $site_url,
349 'pricing' => $site_url . '/pricing-purchase/',
350 'codepress' => 'http://www.codepresshq.com',
351 'admincolumns' => $site_url,
352 'admincolumnspro' => $site_url,
353 'documentation' => $site_url . '/documentation/',
354 'feedback' => 'http://www.codepresshq.com/contact',
355 'plugins' => 'http://wordpress.org/extend/plugins/codepress-admin-columns/',
356 'support' => 'http://wordpress.org/tags/codepress-admin-columns/',
357 );
358
359 if ( ! isset( $urls[ $type ] ) )
360 return false;
361
362 return $urls[ $type ];
363 }
364
365 /**
366 * @since 2.0
367 */
368 public function uses_custom_fields() {
369
370 $old_columns = get_option('cpac_options');
371
372 if ( empty( $old_columns['columns'] ) ) return false;
373
374 foreach ( $old_columns['columns'] as $columns ) {
375 foreach ( $columns as $id => $values ) {
376 if ( strpos( $id, 'column-meta-' ) !== false )
377 return true;
378 }
379 }
380
381 return false;
382 }
383
384 /**
385 * Welcome screen
386 *
387 * @since 2.0
388 */
389 public function welcome_screen() {
390
391 // Should only be set after upgrade
392 $show_welcome = false !== get_transient('cpac_show_welcome');
393
394 // Should only be set manual
395 if ( isset( $_GET['info'] ) ) {
396 $show_welcome = true;
397 }
398
399 if ( ! $show_welcome ) {
400 return false;
401 }
402
403 // Set check that welcome should not be displayed.
404 delete_transient('cpac_show_welcome');
405
406 $tab = !empty( $_GET['info'] ) ? $_GET['info'] : 'whats-new';
407
408 ?>
409
410 <div id="cpac-welcome" class="wrap about-wrap">
411
412 <h1><?php _e( "Welcome to Admin Columns",'cpac'); ?> <?php echo CPAC_VERSION; ?></h1>
413
414 <div class="about-text">
415 <?php _e( "Thank you for updating to the latest version!", 'cpac' ); ?>
416 <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'cpac' ); ?>
417 </div>
418
419 <div class="cpac-content-body">
420 <h2 class="nav-tab-wrapper">
421 <a class="cpac-tab-toggle nav-tab <?php if( $tab == 'whats-new' ){ echo 'nav-tab-active'; } ?>" href="<?php echo $this->get_settings_url( 'info' ); ?>whats-new"><?php _e( "What’s New", 'cpac' ); ?></a>
422 <a class="cpac-tab-toggle nav-tab <?php if( $tab == 'changelog' ){ echo 'nav-tab-active'; } ?>" href="<?php echo $this->get_settings_url( 'info' ); ?>changelog"><?php _e( "Changelog", 'cpac' ); ?></a>
423 </h2>
424
425 <?php if ( 'whats-new' === $tab ) : ?>
426
427 <h3><?php _e( "Important", 'cpac' ); ?></h3>
428
429 <h4><?php _e( "Database Changes", 'cpac' ); ?></h4>
430 <p><?php _e("The database has been changed between versions 1 and 2. But we made sure you can still roll back to version 1x without any issues.",'cpac'); ?></p>
431
432 <?php if ( get_option( 'cpac_version', false ) < CPAC_UPGRADE_VERSION ) : ?>
433 <p><?php _e("Make sure you backup your database and then click",'cpac'); ?> <a href="<?php echo $this->get_settings_url( 'upgrade' ); ?>" class="button-primary"><?php _e( "Upgrade Database", 'cpac' );?></a></p>
434 <?php endif; ?>
435
436 <h4><?php _e( "Potential Issues", 'cpac' ); ?></h4>
437 <p><?php _e( "Do to the sizable refactoring the code, surounding Addons and action/filters, your website may not operate correctly. It is important that you read the full", 'cpac' ); ?> <a href="<?php echo $this->get_url('admincolumns'); ?>migrating-from-v1-to-v2" target="_blank"><?php _e( "Migrating from v1 to v2", 'cpac' ); ?></a> <?php _e( "guide to view the full list of changes.", 'cpac' ); ?> <?php printf( __( 'When you have found a bug please <a href="%s">report them to us</a> so we can fix it in the next release.', 'cpac'), 'mailto:info@codepress.nl' ); ?></p>
438
439 <div class="cpac-alert cpac-alert-error">
440 <p><strong><?php _e( "Important!", 'cpac' ); ?></strong> <?php _e( "If you updated the Admin Columns plugin without prior knowledge of such changes, Please roll back to the latest", 'cpac' ); ?> <a href="http://downloads.wordpress.org/plugin/codepress-admin-columns.1.4.9.zip"> <?php _e( "version 1", 'cpac' ); ?></a> <?php _e( "of this plugin.", 'cpac' ); ?></p>
441 </div>
442
443 <?php endif; ?>
444 <?php if ( 'changelog' === $tab ) : ?>
445
446 <h3><?php _e("Changelog for", 'cpac'); ?> <?php echo CPAC_VERSION; ?></h3>
447 <?php
448
449 $items = file_get_contents( CPAC_DIR . 'readme.txt' );
450 $items = explode('= ' . CPAC_VERSION . ' =', $items);
451 $items = end( $items );
452 $items = current( explode("\n\n", $items) );
453 $items = current( explode("= ", $items) );
454 $items = array_filter( array_map('trim', explode("*", $items)) );
455
456 ?>
457 <ul class="cpac-changelog">
458 <?php foreach( $items as $item ) :
459 $item = explode('http', $item);
460 ?>
461 <li><?php echo $item[0]; ?><?php if( isset($item[1]) ): ?><a href="http<?php echo $item[1]; ?>" target="_blank"><?php _e("Learn more", 'cpac'); ?></a><?php endif; ?></li>
462 <?php endforeach; ?>
463 </ul>
464
465 <?php endif; ?>
466 <hr/>
467
468 </div><!--.cpac-content-body-->
469
470 <div class="cpac-content-footer">
471 <a class="button-primary button-large" href="<?php echo $this->get_settings_url( 'general' ); ?>"><?php _e("Start using Admin Columns",'cpac'); ?></a>
472 </div><!--.cpac-content-footer-->
473
474 </div>
475 <?php
476
477 return true;
478 }
479
480 /**
481 * @since 1.0
482 */
483 public function display_settings() {
484 ?>
485 <table class="form-table cpac-form-table settings">
486 <tbody>
487
488 <tr class="general">
489 <th scope="row">
490 <h3><?php _e( 'General Settings', 'cpac' ); ?></h3>
491 <p><?php _e( 'Customize your Admin Columns settings.', 'cpac' ); ?></p>
492 </th>
493 <td class="padding-22">
494 <div class="cpac_general">
495 <form method="post" action="options.php">
496 <?php settings_fields( 'cpac-general-settings' ); ?>
497 <?php $options = get_option( 'cpac_general_options' ); ?>
498 <p>
499 <label for="show_edit_button">
500 <input name="cpac_general_options[show_edit_button]" type="hidden" value="0" >
501 <input name="cpac_general_options[show_edit_button]" id="show_edit_button" type="checkbox" value="1" <?php checked( ! isset( $options['show_edit_button'] ) || ( '1' == $options['show_edit_button'] ) ); ?>>
502 <?php _e( 'Show "Edit Columns" button on admin screens. Default is <code>on</code>.', 'cpac' ); ?>
503 </label>
504 </p>
505
506 <?php do_action( 'cac/settings/general', $options ); ?>
507
508 <p>
509 <input type="submit" class="button" value="<?php _e( 'Save' ); ?>" />
510 </p>
511 </form>
512 </div>
513 </td>
514 </tr><!--.general-->
515
516 <?php
517
518 /** Allow plugins to add their own custom settings to the settings page. */
519 if ( $groups = apply_filters( 'cac/settings/groups', array() ) ) {
520
521 foreach ( $groups as $id => $group ) {
522
523 $title = isset( $group['title'] ) ? $group['title'] : '';
524 $description = isset( $group['description'] ) ? $group['description'] : '';
525
526 ?>
527 <tr>
528 <th scope="row">
529 <h3><?php echo $title; ?></h3>
530 <p><?php echo $description; ?></p>
531 </th>
532 <td class="padding-22">
533 <?php
534
535 /** Use this Hook to add additonal fields to the group */
536 do_action( "cac/settings/groups/row={$id}" );
537
538 ?>
539 </td>
540 </tr>
541 <?php
542 }
543 }
544
545 ?>
546
547 <tr class="restore">
548 <th scope="row">
549 <h3><?php _e( 'Restore Settings', 'cpac' ); ?></h3>
550 <p><?php _e( 'This will delete all column settings and restore the default settings.', 'cpac' ); ?></p>
551 </th>
552 <td class="padding-22">
553 <form method="post" action="">
554 <?php wp_nonce_field( 'restore-all','_cpac_nonce'); ?>
555 <input type="hidden" name="cpac_action" value="restore_all" />
556 <input type="submit" class="button" name="cpac-restore-defaults" value="<?php _e( 'Restore default settings', 'cpac' ) ?>" onclick="return confirm('<?php _e("Warning! ALL saved admin columns data will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", 'cpac' ); ?>');" />
557 </form>
558 </td>
559 </tr><!--.restore-->
560
561 </tbody>
562 </table>
563
564 <?php
565 }
566
567 /**
568 * @since 2.4.1
569 */
570 private function get_menu_types() {
571 $menu_types = array(
572 'post' => __( 'Posttypes', 'cpac' ),
573 'other' => __( 'Others', 'cpac' ),
574 'taxonomy' => __( 'Taxonomies', 'cpac' ),
575 );
576 return apply_filters( 'cac/menu_types', $menu_types );
577 }
578
579 /**
580 * @since 1.0
581 */
582 public function display() {
583
584 if ( $this->welcome_screen() ) {
585 return;
586 }
587
588 $tabs = array(
589 'general' => __( 'Admin Columns', 'cpac' ),
590 'settings' => __( 'Settings', 'cpac' ),
591 'addons' => __( 'Add-ons', 'cpac' )
592 );
593
594 /**
595 * Filter the tabs on the settings screen
596 *
597 * @param array $tabs Available tabs
598 */
599 $tabs = apply_filters( 'cac/settings/tabs', $tabs );
600
601 $current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : sanitize_text_field( urldecode( $_GET['tab'] ) );
602 ?>
603 <div id="cpac" class="wrap">
604 <?php screen_icon( 'codepress-admin-columns' ); ?>
605 <h2 class="nav-tab-wrapper cpac-nav-tab-wrapper">
606 <?php foreach( $tabs as $name => $label ) : ?>
607 <a href="<?php echo $this->get_settings_url( 'admin' ) . "&amp;tab={$name}"; ?>" class="nav-tab<?php if( $current_tab == $name ) echo ' nav-tab-active'; ?>"><?php echo $label; ?></a>
608 <?php endforeach; ?>
609 </h2>
610
611 <?php do_action( 'cpac_messages' ); ?>
612
613 <?php
614 switch ( $current_tab ) :
615 case 'general':
616
617 $post_types = array_values( $this->cpac->get_post_types() );
618 $first = array_shift( $post_types );
619
620 $storage_models_by_type = array();
621 foreach ( $this->cpac->storage_models as $k => $storage_model ) {
622 $storage_models_by_type[ $storage_model->menu_type ][ $k ] = $storage_model;
623 }
624
625 ?>
626 <div class="cpac-menu">
627 <?php
628 foreach ( $this->get_menu_types() as $menu_type => $label ) {
629 if ( ! empty( $storage_models_by_type[ $menu_type ] ) ) {
630 $count = 0; ?>
631 <ul class="subsubsub">
632 <li class="first"><?php echo $label; ?>: </li>
633 <?php foreach ( $storage_models_by_type[ $menu_type ] as $storage_model ) : ?>
634 <li><?php echo $count++ != 0 ? ' | ' : ''; ?><a href="#cpac-box-<?php echo $storage_model->key; ?>" <?php echo $storage_model->is_menu_type_current( $first ) ? ' class="current"' : '';?> ><?php echo $storage_model->label; ?></a></li>
635 <?php endforeach; ?>
636 </ul>
637 <?php
638 }
639 }
640 ?>
641 </div>
642
643 <?php do_action( 'cac/settings/after_menu' ); ?>
644
645 <?php $count = 0; ?>
646 <?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
647 <div class="columns-container" data-type="<?php echo $storage_model->key ?>"<?php echo $storage_model->is_menu_type_current( $first ) ? '' : ' style="display:none"'; ?>>
648
649 <div class="columns-left">
650 <div id="titlediv">
651 <h2>
652 <?php echo $storage_model->label; ?>
653 <?php $storage_model->screen_link(); ?>
654 </h2>
655 </div>
656
657 <?php if ( $storage_model->is_using_php_export() ) : ?>
658 <div class="error below-h2">
659 <p><?php printf( __( 'The columns for %s are set up via PHP and can therefore not be edited in the admin panel.', 'cpac' ), '<strong>' . $storage_model->label . '</strong>' ); ?></p>
660 </div>
661 <?php endif; ?>
662 </div>
663
664 <div class="columns-right">
665 <div class="columns-right-inside">
666 <?php if ( ! $storage_model->is_using_php_export() ) : ?>
667 <div class="sidebox" id="form-actions">
668 <h3>
669 <?php _e( 'Store settings', 'cpac' ) ?>
670 </h3>
671 <?php $has_been_stored = $storage_model->get_stored_columns() ? true : false; ?>
672 <div class="form-update">
673 <a href="javascript:;" class="button-primary submit-update"><?php echo $has_been_stored ? __( 'Update' ) : __('Save'); ?> <?php echo $storage_model->label; ?></a>
674 </div>
675 <?php if ( $has_been_stored ) : ?>
676 <div class="form-reset">
677 <a href="<?php echo add_query_arg( array( '_cpac_nonce' => wp_create_nonce('restore-type'), 'cpac_key' => $storage_model->key, 'cpac_action' => 'restore_by_type' ), $this->get_settings_url( 'admin' ) ); ?>" class="reset-column-type" onclick="return confirm('<?php printf( __( "Warning! The %s columns data will be deleted. This cannot be undone. \'OK\' to delete, \'Cancel\' to stop", 'cpac' ), $storage_model->label ); ?>');">
678 <?php _e( 'Restore', 'cpac' ); ?> <?php echo $storage_model->label; ?> <?php _e( 'columns', 'cpac' ); ?>
679 </a>
680 </div>
681 <?php endif; ?>
682
683 <?php do_action( 'cac/settings/form_actions', $storage_model ); ?>
684
685 </div><!--form-actions-->
686 <?php endif; ?>
687
688 <?php if ( ! class_exists( 'CAC_Addon_Pro' ) ) : ?>
689 <?php $url_args = array(
690 'utm_source' => 'plugin-installation',
691 'utm_medium' => 'banner',
692 'utm_campaign' => 'plugin-installation'
693 ); ?>
694 <div class="sidebox" id="pro-version">
695 <div class="padding-box cta">
696 <h3>
697 <a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'title' ) ), $this->get_url( 'admincolumnspro' ) ); ?>"><?php _e( 'Get Admin Columns Pro', 'cpac' ) ?></a>
698 </h3>
699 <div class="inside">
700 <ul>
701 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-sorting' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Sorting', 'cpac' ); ?></a></li>
702 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-filtering' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Filtering', 'cpac' ); ?></a></li>
703 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-import-export' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Import/Export', 'cpac' ); ?></a></li>
704 <li><a href="<?php echo add_query_arg( array_merge( $url_args, array( 'utm_content' => 'usp-editing' ) ), $this->get_url( 'admincolumnspro' ) ) ?>"><?php _e( 'Add Direct Editing', 'cpac' ); ?></a></li>
705 </ul>
706 <p>
707 <?php printf( __( 'Check out <a href="%s">Admin Columns Pro</a> for more details!', 'cpac' ), add_query_arg( array_merge( $url_args, array( 'utm_content' => 'cta' ) ), $this->get_url( 'admincolumnspro' ) ) ); ?>
708 </p>
709 </div>
710 </div>
711 </div>
712
713 <?php
714 // @todo: add newsletter
715 /* ?>
716 <div class="padding-box newsletter">
717 <form action="http://codepress.us4.list-manage.com/subscribe/post?u=902ae7f162ce5bc38a0bc8a4f&amp;id=183e843a76" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank">
718 <?php $user = wp_get_current_user(); ?>
719 <p>
720 <?php _e ( "Subscribe to receive news &amp; updates below.", 'cpac' ); ?>
721 </p>
722 <div class="mc-field-group">
723 <label for="mce-FNAME"><?php _e( 'First Name', 'cpac' ); ?></label>
724 <input type="text" value="<?php echo trim( esc_attr( $user->first_name ) ); ?>" name="FNAME" class="" id="mce-FNAME">
725 </div>
726 <div class="mc-field-group">
727 <label for="mce-EMAIL"><?php _e( 'Your Email', 'cpac' ); ?></label>
728 <input type="email" value="<?php echo trim( esc_attr( $user->user_email ) ); ?>" name="EMAIL" class="required email" id="mce-EMAIL">
729 </div>
730 <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
731 </form>
732 </div>
733 <?php */ ?>
734
735
736 <div class="sidebox" id="direct-feedback">
737 <div id="feedback-choice">
738 <h3><?php _e( 'Are you happy with Admin Columns?', 'cpac' ); ?></h3>
739 <div class="inside">
740 <a href="#" class="yes">Yes</a>
741 <a href="#" class="no">No</a>
742 </div>
743 </div>
744 <div id="feedback-support">
745 <div class="inside">
746 <p><?php _e( "What's wrong? Need help? Let us know!", 'cpac' ); ?></p>
747 <p><?php _e( 'Check out our extensive documentation, or you can open a support topic on WordPress.org!', 'cpac' ); ?></p>
748 <ul class="share">
749 <li>
750 <a href="<?php echo add_query_arg( array(
751 'utm_source' => 'plugin-installation',
752 'utm_medium' => 'feedback-docs-button',
753 'utm_campaign' => 'plugin-installation'
754 ), $this->get_url( 'documentation' ) ); ?>" target="_blank">
755 <div class="dashicons dashicons-editor-help"></div> <?php _e( 'Docs', 'cpac' ); ?>
756 </a>
757 </li>
758 <li>
759 <a href="https://wordpress.org/support/plugin/codepress-admin-columns" target="_blank">
760 <div class="dashicons dashicons-wordpress"></div> <?php _e( 'Forums', 'cpac' ); ?>
761 </a>
762 </li>
763 </ul>
764 <div class="clear"></div>
765 </div>
766 </div>
767 <div id="feedback-rate">
768 <div class="inside">
769 <p><?php _e( "Woohoo! We're glad to hear that!", 'cpac' ); ?></p>
770 <p><?php _e( 'We would really love it if you could show your appreciation by giving us a rating on WordPress.org or tweet about Admin Columns!', 'cpac' ); ?></p>
771 <ul class="share">
772 <li>
773 <a href="http://wordpress.org/support/view/plugin-reviews/codepress-admin-columns#postform" target="_blank">
774 <div class="dashicons dashicons-star-empty"></div> <?php _e( 'Rate', 'cpac' ); ?>
775 </a>
776 </li>
777
778 <li>
779 <a href="<?php echo add_query_arg( array(
780 'hashtags' => 'wordpress',
781 'text' => urlencode( "I'm using Admin Columns for WordPress!" ),
782 'url' => urlencode( 'http://wordpress.org/plugins/codepress-admin-columns/' ),
783 'via' => 'wpcolumns'
784 ), 'https://twitter.com/intent/tweet' ); ?>" target="_blank">
785 <div class="dashicons dashicons-twitter"></div> <?php _e( 'Tweet', 'cpac' ); ?>
786 </a>
787 </li>
788
789 <li>
790 <a href="<?php echo add_query_arg( array(
791 'utm_source' => 'plugin-installation',
792 'utm_medium' => 'feedback-purchase-button',
793 'utm_campaign' => 'plugin-installation'
794 ), $this->get_url( 'admincolumnspro' ) ); ?>" target="_blank">
795 <div class="dashicons dashicons-cart"></div> <?php _e( 'Buy Pro', 'cpac' ); ?>
796 </a>
797 </li>
798 </ul>
799 <div class="clear"></div>
800 </div>
801 </div>
802 </div>
803
804 <?php endif; ?>
805
806 <div class="sidebox" id="plugin-support">
807 <h3><?php _e( 'Support', 'cpac' ); ?></h3>
808 <div class="inside">
809 <?php if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) : ?>
810 <p><?php _e( 'Check the <strong>Help</strong> section in the top-right screen.', 'cpac' ); ?></p>
811 <?php endif; ?>
812 <p>
813 <?php printf( __("For full documentation, bug reports, feature suggestions and other tips <a href='%s'>visit the Admin Columns website</a>", 'cpac' ), $this->get_url('documentation') ); ?>
814 </p>
815 </div>
816 </div><!--plugin-support-->
817
818 </div><!--.columns-right-inside-->
819 </div><!--.columns-right-->
820
821 <div class="columns-left">
822 <div class="cpac-boxes">
823 <?php if ( ! $storage_model->is_using_php_export() ) : ?>
824 <div class="cpac-columns">
825
826 <form method="post" action="">
827 <?php wp_nonce_field( 'update-type', '_cpac_nonce'); ?>
828
829 <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>" />
830 <input type="hidden" name="cpac_action" value="update_by_type" />
831
832 <?php
833 foreach ( $storage_model->columns as $column ) {
834 $column->display();
835 }
836 ?>
837 </form>
838
839 </div><!--.cpac-columns-->
840
841 <div class="column-footer">
842 <div class="order-message"><?php _e( 'Drag and drop to reorder', 'cpac' ); ?></div>
843
844 <div class="button-container">
845 <a href="javascript:;" class="add_column button button-primary">+ <?php _e( 'Add Column', 'cpac' );?></a><br/>
846 </div>
847
848 </div><!--.cpac-column-footer-->
849 <?php endif; ?>
850 </div><!--.cpac-boxes-->
851 </div><!--.columns-left-->
852 <div class="clear"></div>
853
854 <div class="for-cloning-only" style="display:none">
855 <?php
856 foreach ( $storage_model->get_registered_columns() as $column ) {
857 $column->display();
858 }
859 ?>
860 </div>
861 </div><!--.columns-container-->
862 <?php endforeach; // storage_models ?>
863
864 <div class="clear"></div>
865 <?php
866 break; // case: general
867 case 'settings' :
868 $this->display_settings();
869 break;
870 case 'addons' :
871 $this->tab_addons();
872 break;
873 case 'help' :
874 //$this->tab_addons();
875 break;
876 default:
877
878 /**
879 * Action to add tab contents
880 *
881 */
882 do_action( 'cac/settings/tab_contents/tab=' . $current_tab );
883
884 endswitch;
885 ?>
886 </div><!--.wrap-->
887 <?php
888 }
889
890 /**
891 * @since 2.2
892 */
893 public function tab_addons() {
894
895 $addon_groups = $this->cpac->addons()->get_addon_groups();
896 $grouped_addons = $this->cpac->addons()->get_available_addons( true );
897 ?>
898 <?php foreach ( $grouped_addons as $group_name => $addons ) : ?>
899 <h3><?php echo $addon_groups[ $group_name ]; ?></h3>
900
901 <ul class="cpac-addons">
902 <?php foreach ( $addons as $addon_name => $addon ) : ?>
903 <li>
904 <div class="cpac-addon-content">
905 <?php if ( ! empty( $addon['image'] ) ) : ?>
906 <img src="<?php echo $addon['image']; ?>" />
907 <?php else : ?>
908 <h3><?php echo $addon['title']; ?></h3>
909 <?php endif; ?>
910 </div>
911 <div class="cpac-addon-header">
912 <h3><?php echo $addon['title']; ?></h3>
913 <p><?php echo $addon['description']; ?></p>
914 </div>
915 <div class="cpac-addon-actions">
916 <?php
917
918 // Installed..
919 if ( ( $plugin_basename = $this->cpac->addons()->get_installed_addon_plugin_basename( $addon_name ) ) ) : ?>
920 <?php if ( is_plugin_active( $plugin_basename ) ) : ?>
921 <?php $deactivation_url = wp_nonce_url( add_query_arg( array(
922 'action' => 'deactivate',
923 'plugin' => urlencode( $plugin_basename ),
924 'cpac-redirect' => true
925 ), admin_url( 'plugins.php' ) ), 'deactivate-plugin_' . $plugin_basename ); ?>
926 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Active', 'cpac' ); ?></a>
927 <a href="<?php echo esc_attr( $deactivation_url ); ?>" class="button right"><?php _e( 'Deactivate', 'cpac' ); ?></a>
928 <?php else : ?>
929 <?php $activation_url = wp_nonce_url( add_query_arg( array(
930 'action' => 'activate',
931 'plugin' => urlencode( $plugin_basename ),
932 'cpac-redirect' => true
933 ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_basename ); ?>
934 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Installed', 'cpac' ); ?></a>
935 <a href="<?php echo esc_attr( $activation_url ); ?>" class="button right"><?php _e( 'Activate', 'cpac' ); ?></a>
936 <?php endif; ?>
937 <?php
938
939 // Not installed...
940 else :
941
942 // Got ACP?
943 if ( class_exists('CAC_Addon_Pro') ) :
944 $install_url = wp_nonce_url( add_query_arg( array(
945 'action' => 'install',
946 'plugin' => $addon_name,
947 ), $this->get_settings_url( 'addons' ) ), 'install-cac-addon' );
948 ?>
949 <a href="<?php echo esc_attr( $install_url ); ?>" class="button"><?php _e( 'Download & Install', 'cpac' ); ?></a>
950 <?php
951
952 // Get ACP?
953 else : ?>
954 <a target="_blank" href="<?php echo esc_attr( $this->get_url('pricing') ); ?>" class="button"><?php _e( 'Get this add-on', 'cpac' ); ?></a>
955 <?php endif; ?>
956 <?php endif; ?>
957 </div>
958 </li>
959 <?php endforeach; // addons ?>
960 </ul>
961 <?php endforeach; // grouped_addons ?>
962 <?php
963 }
964 }