PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.4
Admin Columns v2.4
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 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
957 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 wp_enqueue_style( 'wp-pointer' );
200 wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL . 'assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
201 wp_enqueue_style( 'cpac-admin', CPAC_URL . 'assets/css/admin-column.css', array(), CPAC_VERSION, 'all' );
202 }
203
204 /**
205 * @since 1.0
206 */
207 public function admin_scripts() {
208
209 wp_enqueue_script( 'wp-pointer' );
210 wp_enqueue_script( 'jquery-ui-slider' );
211
212 $minified = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
213
214 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 );
215
216 // javascript translations
217 wp_localize_script( 'cpac-admin-settings', 'cpac_i18n', array(
218 'clone' => __( '%s column is already present and can not be duplicated.', 'cpac' ),
219 ));
220 }
221
222 /**
223 * @since 1.0
224 */
225 public function handle_column_request() {
226
227 // only handle updates from the admin columns page
228 if ( ! ( isset($_GET['page'] ) && in_array( $_GET['page'], array( 'codepress-admin-columns' ) ) && isset( $_REQUEST['cpac_action'] ) ) ) {
229 return false;
230 }
231
232 // use $_REQUEST because the values are send both over $_GET and $_POST
233 $action = isset( $_REQUEST['cpac_action'] ) ? $_REQUEST['cpac_action'] : '';
234 $nonce = isset( $_REQUEST['_cpac_nonce'] ) ? $_REQUEST['_cpac_nonce'] : '';
235 $key = isset( $_REQUEST['cpac_key'] ) ? $_REQUEST['cpac_key'] : '';
236
237 switch ( $action ) :
238
239 case 'update_by_type' :
240 if ( wp_verify_nonce( $nonce, 'update-type' ) ) {
241 $storage_model = $this->cpac->get_storage_model( $key );
242 $storage_model->store();
243 }
244 break;
245
246 case 'restore_by_type' :
247 if ( wp_verify_nonce( $nonce, 'restore-type' ) ) {
248 $storage_model = $this->cpac->get_storage_model( $key );
249 $storage_model->restore();
250 }
251 break;
252
253 case 'restore_all' :
254 if ( wp_verify_nonce( $nonce, 'restore-all' ) ) {
255 $this->restore_all();
256 }
257 break;
258
259 endswitch;
260 }
261
262 /**
263 * Restore all column defaults
264 *
265 * @since 1.0
266 */
267 private function restore_all() {
268 global $wpdb;
269
270 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cpac_options_%'" );
271
272 cpac_admin_message( __( 'Default settings succesfully restored.', 'cpac' ), 'updated' );
273 }
274
275 /**
276 * Add help tabs to top menu
277 *
278 * @since 1.3.0
279 */
280 public function help_tabs() {
281
282 $screen = get_current_screen();
283
284 if ( ! method_exists( $screen,'add_help_tab' ) )
285 return;
286
287 $tabs = array(
288 array(
289 'title' => __( "Overview", 'cpac' ),
290 'content' =>
291 "<h5>Admin Columns</h5>
292 <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>"
293 ),
294 array(
295 'title' => __( "Basics", 'cpac' ),
296 'content' => "
297 <h5>" . __( "Change order", 'cpac' ) . "</h5>
298 <p>" . __( "By dragging the columns you can change the order which they will appear in.", 'cpac' ) . "</p>
299 <h5>" . __( "Change label", 'cpac' ) . "</h5>
300 <p>" . __( "By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.", 'cpac' ) . "</p>
301 <h5>" . __( "Change column width", 'cpac' ) . "</h5>
302 <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>
303 "
304 ),
305 array(
306 'title' => __( "Custom Field", 'cpac' ),
307 'content' =>
308 "<h5>". __( "'Custom Field' column", 'cpac' ) . "</h5>
309 <p>". __( "The custom field colum uses the custom fields from posts and users. There are 10 types which you can set.", 'cpac' ) . "</p>
310 <ul>
311 <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>
312 <li><strong>". __( "Image", 'cpac' ) . "</strong><br/>". __( "Value: should contain an image URL or Attachment IDs ( seperated by a ',' comma ).", 'cpac' ) . "</li>
313 <li><strong>". __( "Excerpt", 'cpac' ) . "</strong><br/>". __( "Value: This will show the first 20 words of the Post content.", 'cpac' ) . "</li>
314 <li><strong>". __( "Multiple Values", 'cpac' ) . "</strong><br/>". __( "Value: should be an array. This will flatten any ( multi dimensional ) array.", 'cpac' ) . "</li>
315 <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>
316 <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>
317 <li><strong>". __( "Post Titles", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more Post ID's (seperated by ',').", 'cpac' ) . "</li>
318 <li><strong>". __( "Usernames", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more User ID's (seperated by ',').", 'cpac' ) . "</li>
319 <li><strong>". __( "Checkmark", 'cpac' ) . "</strong><br/>". __( "Value: should be a 1 (one) or 0 (zero).", 'cpac' ) . "</li>
320 <li><strong>". __( "Color", 'cpac' ) . "</strong><br/>". __( "Value: hex value color, such as #808080.", 'cpac' ) . "</li>
321 <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>
322 </ul>
323 "
324 )
325 );
326
327 foreach ( $tabs as $k => $tab ) {
328 $screen->add_help_tab( array(
329 'id' => 'cpac-tab-'.$k,
330 'title' => $tab['title'],
331 'content' => $tab['content'],
332 ));
333 }
334 }
335
336 /**
337 * @since 1.0
338 * @param string $storage_model URL type.
339 * @return string Url.
340 */
341 function get_url( $type ) {
342
343 $site_url = 'http://www.admincolumns.com';
344
345 $urls = array(
346 'main' => $site_url,
347 'pricing' => $site_url . '/pricing-purchase/',
348 'codepress' => 'http://www.codepresshq.com',
349 'admincolumns' => $site_url,
350 'admincolumnspro' => $site_url,
351 'documentation' => $site_url . '/documentation/',
352 'feedback' => 'http://www.codepresshq.com/contact',
353 'plugins' => 'http://wordpress.org/extend/plugins/codepress-admin-columns/',
354 'support' => 'http://wordpress.org/tags/codepress-admin-columns/',
355 );
356
357 if ( ! isset( $urls[ $type ] ) )
358 return false;
359
360 return $urls[ $type ];
361 }
362
363 /**
364 * @since 2.0
365 */
366 public function uses_custom_fields() {
367
368 $old_columns = get_option('cpac_options');
369
370 if ( empty( $old_columns['columns'] ) ) return false;
371
372 foreach ( $old_columns['columns'] as $columns ) {
373 foreach ( $columns as $id => $values ) {
374 if ( strpos( $id, 'column-meta-' ) !== false )
375 return true;
376 }
377 }
378
379 return false;
380 }
381
382 /**
383 * Welcome screen
384 *
385 * @since 2.0
386 */
387 public function welcome_screen() {
388
389 // Should only be set after upgrade
390 $show_welcome = false !== get_transient('cpac_show_welcome');
391
392 // Should only be set manual
393 if ( isset( $_GET['info'] ) ) {
394 $show_welcome = true;
395 }
396
397 if ( ! $show_welcome ) {
398 return false;
399 }
400
401 // Set check that welcome should not be displayed.
402 delete_transient('cpac_show_welcome');
403
404 $tab = !empty( $_GET['info'] ) ? $_GET['info'] : 'whats-new';
405
406 ?>
407
408 <div id="cpac-welcome" class="wrap about-wrap">
409
410 <h1><?php _e( "Welcome to Admin Columns",'cpac'); ?> <?php echo CPAC_VERSION; ?></h1>
411
412 <div class="about-text">
413 <?php _e( "Thank you for updating to the latest version!", 'cpac' ); ?>
414 <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'cpac' ); ?>
415 </div>
416
417 <div class="cpac-content-body">
418 <h2 class="nav-tab-wrapper">
419 <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>
420 <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>
421 </h2>
422
423 <?php if ( 'whats-new' === $tab ) : ?>
424
425 <h3><?php _e( "Important", 'cpac' ); ?></h3>
426
427 <h4><?php _e( "Database Changes", 'cpac' ); ?></h4>
428 <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>
429
430 <?php if ( get_option( 'cpac_version', false ) < CPAC_UPGRADE_VERSION ) : ?>
431 <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>
432 <?php endif; ?>
433
434 <h4><?php _e( "Potential Issues", 'cpac' ); ?></h4>
435 <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>
436
437 <div class="cpac-alert cpac-alert-error">
438 <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>
439 </div>
440
441 <?php endif; ?>
442 <?php if ( 'changelog' === $tab ) : ?>
443
444 <h3><?php _e("Changelog for", 'cpac'); ?> <?php echo CPAC_VERSION; ?></h3>
445 <?php
446
447 $items = file_get_contents( CPAC_DIR . 'readme.txt' );
448 $items = explode('= ' . CPAC_VERSION . ' =', $items);
449 $items = end( $items );
450 $items = current( explode("\n\n", $items) );
451 $items = current( explode("= ", $items) );
452 $items = array_filter( array_map('trim', explode("*", $items)) );
453
454 ?>
455 <ul class="cpac-changelog">
456 <?php foreach( $items as $item ) :
457 $item = explode('http', $item);
458 ?>
459 <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>
460 <?php endforeach; ?>
461 </ul>
462
463 <?php endif; ?>
464 <hr/>
465
466 </div><!--.cpac-content-body-->
467
468 <div class="cpac-content-footer">
469 <a class="button-primary button-large" href="<?php echo $this->get_settings_url( 'general' ); ?>"><?php _e("Start using Admin Columns",'cpac'); ?></a>
470 </div><!--.cpac-content-footer-->
471
472 </div>
473 <?php
474
475 return true;
476 }
477
478 /**
479 * @since 2.2
480 */
481 public function display_menu_by_type( $menu_type = '', $label = '', $active_item = '' ) {
482
483 $storage_models_by_type = array();
484
485 foreach( $this->cpac->storage_models as $k => $storage_model ) {
486 if ( $menu_type == $storage_model->menu_type ) {
487 $storage_models_by_type[ $menu_type ][ $k ] = $storage_model;
488 }
489 }
490
491 if ( ! empty( $storage_models_by_type[ $menu_type ] ) ) { $count = 0; ?>
492 <ul class="subsubsub">
493 <li class="first"><?php echo $label; ?>: </li>
494 <?php foreach ( $storage_models_by_type[ $menu_type ] as $storage_model ) : ?>
495 <li><?php echo $count++ != 0 ? ' | ' : ''; ?><a href="#cpac-box-<?php echo $storage_model->key; ?>" <?php echo $storage_model->is_menu_type_current( $active_item ) ? ' class="current"' : '';?> ><?php echo $storage_model->label; ?></a></li>
496 <?php endforeach; ?>
497 </ul>
498 <?php
499 }
500 }
501
502 /**
503 * @since 1.0
504 */
505 public function display_settings() {
506 ?>
507 <table class="form-table cpac-form-table settings">
508 <tbody>
509
510 <tr class="general">
511 <th scope="row">
512 <h3><?php _e( 'General Settings', 'cpac' ); ?></h3>
513 <p><?php _e( 'Customize your Admin Columns settings.', 'cpac' ); ?></p>
514 </th>
515 <td class="padding-22">
516 <div class="cpac_general">
517 <form method="post" action="options.php">
518 <?php settings_fields( 'cpac-general-settings' ); ?>
519 <?php $options = get_option( 'cpac_general_options' ); ?>
520 <p>
521 <label for="show_edit_button">
522 <input name="cpac_general_options[show_edit_button]" type="hidden" value="0" >
523 <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'] ) ); ?>>
524 <?php _e( 'Show "Edit Columns" button on admin screens. Default is <code>on</code>.', 'cpac' ); ?>
525 </label>
526 </p>
527
528 <?php do_action( 'cac/settings/general', $options ); ?>
529
530 <p>
531 <input type="submit" class="button" value="<?php _e( 'Save' ); ?>" />
532 </p>
533 </form>
534 </div>
535 </td>
536 </tr><!--.general-->
537
538 <?php
539
540 /** Allow plugins to add their own custom settings to the settings page. */
541 if ( $groups = apply_filters( 'cac/settings/groups', array() ) ) {
542
543 foreach ( $groups as $id => $group ) {
544
545 $title = isset( $group['title'] ) ? $group['title'] : '';
546 $description = isset( $group['description'] ) ? $group['description'] : '';
547
548 ?>
549 <tr>
550 <th scope="row">
551 <h3><?php echo $title; ?></h3>
552 <p><?php echo $description; ?></p>
553 </th>
554 <td class="padding-22">
555 <?php
556
557 /** Use this Hook to add additonal fields to the group */
558 do_action( "cac/settings/groups/row={$id}" );
559
560 ?>
561 </td>
562 </tr>
563 <?php
564 }
565 }
566
567 ?>
568
569 <tr class="restore">
570 <th scope="row">
571 <h3><?php _e( 'Restore Settings', 'cpac' ); ?></h3>
572 <p><?php _e( 'This will delete all column settings and restore the default settings.', 'cpac' ); ?></p>
573 </th>
574 <td class="padding-22">
575 <form method="post" action="">
576 <?php wp_nonce_field( 'restore-all','_cpac_nonce'); ?>
577 <input type="hidden" name="cpac_action" value="restore_all" />
578 <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' ); ?>');" />
579 </form>
580 </td>
581 </tr><!--.restore-->
582
583 </tbody>
584 </table>
585
586 <?php
587 }
588
589 /**
590 * @since 1.0
591 */
592 public function display() {
593
594 if ( $this->welcome_screen() ) {
595 return;
596 }
597
598 $tabs = array(
599 'general' => __( 'Admin Columns', 'cpac' ),
600 'settings' => __( 'Settings', 'cpac' ),
601 'addons' => __( 'Add-ons', 'cpac' )
602 );
603
604 /**
605 * Filter the tabs on the settings screen
606 *
607 * @param array $tabs Available tabs
608 */
609 $tabs = apply_filters( 'cac/settings/tabs', $tabs );
610
611 $current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : sanitize_text_field( urldecode( $_GET['tab'] ) );
612
613 $post_types = array_values( $this->cpac->get_post_types() );
614 $first = array_shift( $post_types );
615 ?>
616 <div id="cpac" class="wrap">
617 <?php screen_icon( 'codepress-admin-columns' ); ?>
618 <h2 class="nav-tab-wrapper cpac-nav-tab-wrapper">
619 <?php foreach( $tabs as $name => $label ) : ?>
620 <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>
621 <?php endforeach; ?>
622 </h2>
623
624 <?php do_action( 'cpac_messages' ); ?>
625
626 <?php
627 switch ( $current_tab ) :
628 case 'general':
629 ?>
630 <div class="cpac-menu">
631 <?php $this->display_menu_by_type( 'post', __( 'Posttypes', 'cpac' ), $first ); ?>
632 <?php $this->display_menu_by_type( 'other', __( 'Others', 'cpac' ) ); ?>
633 <?php $this->display_menu_by_type( 'taxonomy', __( 'Taxonomies', 'cpac' ) ); ?>
634 </div>
635
636 <?php do_action( 'cac/settings/after_menu' ); ?>
637
638 <?php $count = 0; ?>
639 <?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
640 <div class="columns-container" data-type="<?php echo $storage_model->key ?>"<?php echo $storage_model->is_menu_type_current( $first ) ? '' : ' style="display:none"'; ?>>
641
642 <div class="columns-left">
643 <div id="titlediv">
644 <h2>
645 <?php echo $storage_model->label; ?>
646 <?php $storage_model->screen_link(); ?>
647 </h2>
648 </div>
649
650 <?php if ( $storage_model->is_using_php_export() ) : ?>
651 <div class="error below-h2">
652 <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>
653 </div>
654 <?php endif; ?>
655 </div>
656
657 <div class="columns-right">
658 <div class="columns-right-inside">
659 <?php if ( ! $storage_model->is_using_php_export() ) : ?>
660 <div class="sidebox" id="form-actions">
661 <h3>
662 <?php _e( 'Store settings', 'cpac' ) ?>
663 </h3>
664 <?php $has_been_stored = $storage_model->get_stored_columns() ? true : false; ?>
665 <div class="form-update">
666 <a href="javascript:;" class="button-primary submit-update"><?php echo $has_been_stored ? __( 'Update' ) : __('Save'); ?> <?php echo $storage_model->label; ?></a>
667 </div>
668 <?php if ( $has_been_stored ) : ?>
669 <div class="form-reset">
670 <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 ); ?>');">
671 <?php _e( 'Restore', 'cpac' ); ?> <?php echo $storage_model->label; ?> <?php _e( 'columns', 'cpac' ); ?>
672 </a>
673 </div>
674 <?php endif; ?>
675
676 <?php do_action( 'cac/settings/form_actions', $storage_model ); ?>
677
678 </div><!--form-actions-->
679 <?php endif; ?>
680
681 <?php if ( ! class_exists( 'CAC_Addon_Pro' ) ) : ?>
682 <?php $url_args = array(
683 'utm_source' => 'plugin-installation',
684 'utm_medium' => 'banner',
685 'utm_campaign' => 'plugin-installation'
686 ); ?>
687 <div class="sidebox" id="pro-version">
688 <div class="padding-box cta">
689 <h3>
690 <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>
691 </h3>
692 <div class="inside">
693 <ul>
694 <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>
695 <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>
696 <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>
697 <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>
698 </ul>
699 <p>
700 <?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' ) ) ); ?>
701 </p>
702 </div>
703 </div>
704 </div>
705
706 <?php
707 // @todo: add newsletter
708 /* ?>
709 <div class="padding-box newsletter">
710 <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">
711 <?php $user = wp_get_current_user(); ?>
712 <p>
713 <?php _e ( "Subscribe to receive news &amp; updates below.", 'cpac' ); ?>
714 </p>
715 <div class="mc-field-group">
716 <label for="mce-FNAME"><?php _e( 'First Name', 'cpac' ); ?></label>
717 <input type="text" value="<?php echo trim( esc_attr( $user->first_name ) ); ?>" name="FNAME" class="" id="mce-FNAME">
718 </div>
719 <div class="mc-field-group">
720 <label for="mce-EMAIL"><?php _e( 'Your Email', 'cpac' ); ?></label>
721 <input type="email" value="<?php echo trim( esc_attr( $user->user_email ) ); ?>" name="EMAIL" class="required email" id="mce-EMAIL">
722 </div>
723 <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
724 </form>
725 </div>
726 <?php */ ?>
727
728
729 <div class="sidebox" id="direct-feedback">
730 <div id="feedback-choice">
731 <h3><?php _e( 'Are you happy with Admin Columns?', 'cpac' ); ?></h3>
732 <div class="inside">
733 <a href="#" class="yes">Yes</a>
734 <a href="#" class="no">No</a>
735 </div>
736 </div>
737 <div id="feedback-support">
738 <div class="inside">
739 <p><?php _e( "What's wrong? Need help? Let us know!", 'cpac' ); ?></p>
740 <p><?php _e( 'Check out our extensive documentation, or you can open a support topic on WordPress.org!', 'cpac' ); ?></p>
741 <ul class="share">
742 <li>
743 <a href="<?php echo add_query_arg( array(
744 'utm_source' => 'plugin-installation',
745 'utm_medium' => 'feedback-docs-button',
746 'utm_campaign' => 'plugin-installation'
747 ), $this->get_url( 'documentation' ) ); ?>" target="_blank">
748 <div class="dashicons dashicons-editor-help"></div> <?php _e( 'Docs', 'cpac' ); ?>
749 </a>
750 </li>
751 <li>
752 <a href="https://wordpress.org/support/plugin/codepress-admin-columns" target="_blank">
753 <div class="dashicons dashicons-wordpress"></div> <?php _e( 'Forums', 'cpac' ); ?>
754 </a>
755 </li>
756 </ul>
757 <div class="clear"></div>
758 </div>
759 </div>
760 <div id="feedback-rate">
761 <div class="inside">
762 <p><?php _e( "Woohoo! We're glad to hear that!", 'cpac' ); ?></p>
763 <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>
764 <ul class="share">
765 <li>
766 <a href="http://wordpress.org/support/view/plugin-reviews/codepress-admin-columns#postform" target="_blank">
767 <div class="dashicons dashicons-star-empty"></div> <?php _e( 'Rate', 'cpac' ); ?>
768 </a>
769 </li>
770
771 <li>
772 <a href="<?php echo add_query_arg( array(
773 'hashtags' => 'wordpress',
774 'text' => urlencode( "I'm using Admin Columns for WordPress!" ),
775 'url' => urlencode( 'http://wordpress.org/plugins/codepress-admin-columns/' ),
776 'via' => 'wpcolumns'
777 ), 'https://twitter.com/intent/tweet' ); ?>" target="_blank">
778 <div class="dashicons dashicons-twitter"></div> <?php _e( 'Tweet', 'cpac' ); ?>
779 </a>
780 </li>
781
782 <li>
783 <a href="<?php echo add_query_arg( array(
784 'utm_source' => 'plugin-installation',
785 'utm_medium' => 'feedback-purchase-button',
786 'utm_campaign' => 'plugin-installation'
787 ), $this->get_url( 'admincolumnspro' ) ); ?>" target="_blank">
788 <div class="dashicons dashicons-cart"></div> <?php _e( 'Buy Pro', 'cpac' ); ?>
789 </a>
790 </li>
791 </ul>
792 <div class="clear"></div>
793 </div>
794 </div>
795 </div>
796
797 <?php endif; ?>
798
799 <div class="sidebox" id="plugin-support">
800 <h3><?php _e( 'Support', 'cpac' ); ?></h3>
801 <div class="inside">
802 <?php if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) : ?>
803 <p><?php _e( 'Check the <strong>Help</strong> section in the top-right screen.', 'cpac' ); ?></p>
804 <?php endif; ?>
805 <p>
806 <?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') ); ?>
807 </p>
808 </div>
809 </div><!--plugin-support-->
810
811 </div><!--.columns-right-inside-->
812 </div><!--.columns-right-->
813
814 <div class="columns-left">
815 <div class="cpac-boxes">
816 <?php if ( ! $storage_model->is_using_php_export() ) : ?>
817 <div class="cpac-columns">
818
819 <form method="post" action="">
820 <?php wp_nonce_field( 'update-type', '_cpac_nonce'); ?>
821
822 <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>" />
823 <input type="hidden" name="cpac_action" value="update_by_type" />
824
825 <?php
826 foreach ( $storage_model->columns as $column ) {
827 $column->display();
828 }
829 ?>
830 </form>
831
832 </div><!--.cpac-columns-->
833
834 <div class="column-footer">
835 <div class="order-message"><?php _e( 'Drag and drop to reorder', 'cpac' ); ?></div>
836
837 <div class="button-container">
838 <a href="javascript:;" class="add_column button button-primary">+ <?php _e( 'Add Column', 'cpac' );?></a><br/>
839 </div>
840
841 </div><!--.cpac-column-footer-->
842 <?php endif; ?>
843 </div><!--.cpac-boxes-->
844 </div><!--.columns-left-->
845 <div class="clear"></div>
846
847 <div class="for-cloning-only" style="display:none">
848 <?php
849 foreach ( $storage_model->get_registered_columns() as $column ) {
850 $column->display();
851 }
852 ?>
853 </div>
854 </div><!--.columns-container-->
855 <?php endforeach; // storage_models ?>
856
857 <div class="clear"></div>
858 <?php
859 break; // case: general
860 case 'settings' :
861 $this->display_settings();
862 break;
863 case 'addons' :
864 $this->tab_addons();
865 break;
866 case 'help' :
867 //$this->tab_addons();
868 break;
869 default:
870
871 /**
872 * Action to add tab contents
873 *
874 */
875 do_action( 'cac/settings/tab_contents/tab=' . $current_tab );
876
877 endswitch;
878 ?>
879 </div><!--.wrap-->
880 <?php
881 }
882
883 /**
884 * @since 2.2
885 */
886 public function tab_addons() {
887
888 $addon_groups = $this->cpac->addons()->get_addon_groups();
889 $grouped_addons = $this->cpac->addons()->get_available_addons( true );
890 ?>
891 <?php foreach ( $grouped_addons as $group_name => $addons ) : ?>
892 <h3><?php echo $addon_groups[ $group_name ]; ?></h3>
893
894 <ul class="cpac-addons">
895 <?php foreach ( $addons as $addon_name => $addon ) : ?>
896 <li>
897 <div class="cpac-addon-content">
898 <?php if ( ! empty( $addon['image'] ) ) : ?>
899 <img src="<?php echo $addon['image']; ?>" />
900 <?php else : ?>
901 <h3><?php echo $addon['title']; ?></h3>
902 <?php endif; ?>
903 </div>
904 <div class="cpac-addon-header">
905 <h3><?php echo $addon['title']; ?></h3>
906 <p><?php echo $addon['description']; ?></p>
907 </div>
908 <div class="cpac-addon-actions">
909 <?php
910
911 // Installed..
912 if ( ( $plugin_basename = $this->cpac->addons()->get_installed_addon_plugin_basename( $addon_name ) ) ) : ?>
913 <?php if ( is_plugin_active( $plugin_basename ) ) : ?>
914 <?php $deactivation_url = wp_nonce_url( add_query_arg( array(
915 'action' => 'deactivate',
916 'plugin' => urlencode( $plugin_basename ),
917 'cpac-redirect' => true
918 ), admin_url( 'plugins.php' ) ), 'deactivate-plugin_' . $plugin_basename ); ?>
919 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Active', 'cpac' ); ?></a>
920 <a href="<?php echo esc_attr( $deactivation_url ); ?>" class="button right"><?php _e( 'Deactivate', 'cpac' ); ?></a>
921 <?php else : ?>
922 <?php $activation_url = wp_nonce_url( add_query_arg( array(
923 'action' => 'activate',
924 'plugin' => urlencode( $plugin_basename ),
925 'cpac-redirect' => true
926 ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_basename ); ?>
927 <a href="#" class="button button-disabled cpac-installed"><?php _e( 'Installed', 'cpac' ); ?></a>
928 <a href="<?php echo esc_attr( $activation_url ); ?>" class="button right"><?php _e( 'Activate', 'cpac' ); ?></a>
929 <?php endif; ?>
930 <?php
931
932 // Not installed...
933 else :
934
935 // Got ACP?
936 if ( class_exists('CAC_Addon_Pro') ) :
937 $install_url = wp_nonce_url( add_query_arg( array(
938 'action' => 'install',
939 'plugin' => $addon_name,
940 ), $this->get_settings_url( 'addons' ) ), 'install-cac-addon' );
941 ?>
942 <a href="<?php echo esc_attr( $install_url ); ?>" class="button"><?php _e( 'Download & Install', 'cpac' ); ?></a>
943 <?php
944
945 // Get ACP?
946 else : ?>
947 <a target="_blank" href="<?php echo esc_attr( $this->get_url('pricing') ); ?>" class="button"><?php _e( 'Get this add-on', 'cpac' ); ?></a>
948 <?php endif; ?>
949 <?php endif; ?>
950 </div>
951 </li>
952 <?php endforeach; // addons ?>
953 </ul>
954 <?php endforeach; // grouped_addons ?>
955 <?php
956 }
957 }