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