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