PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.1.1
Admin Columns v2.1.1
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 12 years ago storage_model 12 years ago column.php 12 years ago deprecated.php 12 years ago settings.php 12 years ago storage_model.php 12 years ago third_party.php 12 years ago upgrade.php 12 years ago utility.php 12 years ago
settings.php
807 lines
1 <?php
2
3 /**
4 * CPAC_Settings Class
5 *
6 * @since 2.0.0
7 */
8 class CPAC_Settings {
9
10 /**
11 * CPAC class
12 *
13 * @since 2.0.0
14 */
15 private $cpac;
16
17 /**
18 * Settings uri
19 *
20 * @since 2.0.0
21 * @param array URL for general, settings and info screens
22 */
23 private $settings_urls = array();
24
25 /**
26 * Constructor
27 *
28 * @since 2.0.0
29 * @param object CPAC
30 */
31 function __construct( $cpac ) {
32
33 $this->cpac = $cpac;
34
35 // register settings
36 add_action( 'admin_menu', array( $this, 'settings_menu' ) );
37
38 // handle requests gets a low priority so it will trigger when all other plugins have loaded their columns
39 add_action( 'admin_init', array( $this, 'handle_column_request' ), 1000 );
40
41 // handle addon downloads
42 add_action( 'admin_init', array( $this, 'handle_download_request' ) );
43
44 // Settings Url's
45 $this->settings_urls = (object) array(
46 'admin' => admin_url( 'options-general.php?page=codepress-admin-columns' ),
47 'general' => admin_url( 'options-general.php?page=codepress-admin-columns&tab=general' ),
48 'settings' => admin_url( 'options-general.php?page=codepress-admin-columns&tab=settings' ),
49 'info' => admin_url( 'options-general.php?page=codepress-admin-columns&info=' ),
50 'upgrade' => admin_url( 'options-general.php?page=cpac-upgrade' )
51 );
52 }
53
54 /**
55 * Admin Menu.
56 *
57 * Create the admin menu link for the settings page.
58 *
59 * @since 1.0.0
60 */
61 public function settings_menu() {
62
63 // add settings page
64 $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 );
65
66 // add help tabs
67 add_action( "load-{$settings_page}", array( $this, 'help_tabs' ) );
68
69 // add scripts & styles
70 add_action( "admin_print_styles-{$settings_page}", array( $this, 'admin_styles' ) );
71 add_action( "admin_print_scripts-{$settings_page}", array( $this, 'admin_scripts' ) );
72
73 // register setting
74 register_setting( 'cpac-general-settings', 'cpac_general_options' );
75
76 // @ todo_minor REMOVE
77 // add capabilty to administrator to manage admin columns
78 // note to devs: you can use this to grant other roles this privilidge as well.
79 //if ( $role = get_role( 'administrator' ) )
80 //$role->add_cap( 'manage_admin_columns' );
81
82 // add cap to options.php
83 add_filter( 'option_page_capability_cpac-general-settings', array( $this, 'add_capability' ) );
84 }
85
86 /**
87 * Add capability
88 *
89 * Allows the capaiblity 'manage_admin_columns' to store data through /wp-admin/options.php
90 *
91 * @since 2.0.0
92 */
93 public function add_capability() {
94
95 return 'manage_admin_columns';
96 }
97
98 /**
99 * Register admin css
100 *
101 * @since 1.0.0
102 */
103 public function admin_styles() {
104 wp_enqueue_style( 'wp-pointer' );
105 wp_enqueue_style( 'jquery-ui-lightness', CPAC_URL . 'assets/ui-theme/jquery-ui-1.8.18.custom.css', array(), CPAC_VERSION, 'all' );
106 wp_enqueue_style( 'cpac-admin', CPAC_URL . 'assets/css/admin-column.css', array(), CPAC_VERSION, 'all' );
107 wp_enqueue_style( 'cpac-custom-fields-css', CPAC_URL . 'assets/css/custom-fields.css', array(), CPAC_VERSION, 'all' );
108 }
109
110 /**
111 * Register admin scripts
112 *
113 * @since 1.0.0
114 */
115 public function admin_scripts() {
116
117 wp_enqueue_script( 'wp-pointer' );
118 wp_enqueue_script( 'jquery-ui-slider' );
119
120 // columns
121 wp_enqueue_script( 'cpac-admin-columns', CPAC_URL . 'assets/js/admin-columns.js', array( 'jquery', 'dashboard', 'jquery-ui-slider', 'jquery-ui-sortable' ), CPAC_VERSION );
122 wp_enqueue_script( 'cpac-custom-fields-js', CPAC_URL . 'assets/js/custom-fields.js', array( 'jquery' ), CPAC_VERSION );
123
124 // javascript translations
125 wp_localize_script( 'cpac-admin-columns', 'cpac_i18n', array(
126 'clone' => __( '%s column is already present and can not be duplicated.', 'cpac' ),
127 ));
128 }
129
130 /**
131 * Handle column requests.
132 *
133 * @since 1.0.0
134 */
135 public function handle_column_request() {
136
137 // only handle updates from the admin columns page
138 if ( ! ( isset($_GET['page'] ) && in_array( $_GET['page'], array( 'codepress-admin-columns', 'cpac-settings' ) ) && isset( $_REQUEST['cpac_action'] ) ) )
139 return false;
140
141 // use $_REQUEST because the values are send both over $_GET and $_POST
142 $action = isset( $_REQUEST['cpac_action'] ) ? $_REQUEST['cpac_action'] : '';
143 $nonce = isset( $_REQUEST['_cpac_nonce'] ) ? $_REQUEST['_cpac_nonce'] : '';
144 $key = isset( $_REQUEST['cpac_key'] ) ? $_REQUEST['cpac_key'] : '';
145
146 switch ( $action ) :
147
148 case 'update_by_type' :
149
150 if ( wp_verify_nonce( $nonce, 'update-type' ) ) {
151 $storage_model = $this->cpac->get_storage_model( $key );
152 $storage_model->store();
153 }
154 break;
155
156 case 'restore_by_type' :
157 if ( wp_verify_nonce( $nonce, 'restore-type' ) ) {
158 $storage_model = $this->cpac->get_storage_model( $key );
159 $storage_model->restore();
160 }
161 break;
162
163 case 'restore_all' :
164 if ( wp_verify_nonce( $nonce, 'restore-all' ) ) {
165 $this->restore_all();
166 }
167 break;
168
169 endswitch;
170 }
171
172 /**
173 * Restore defaults
174 *
175 * @since 1.0.0
176 */
177 private function restore_all() {
178 global $wpdb;
179
180 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cpac_options_%'" );
181
182 cpac_admin_message( __( 'Default settings succesfully restored.', 'cpac' ), 'updated' );
183 }
184
185 /**
186 * Add help tabs
187 *
188 * @since 1.3.0
189 */
190 public function help_tabs() {
191
192 $screen = get_current_screen();
193
194 if ( ! method_exists( $screen,'add_help_tab' ) )
195 return;
196
197 // add help content
198 $tabs = array(
199 array(
200 'title' => __( "Overview", 'cpac' ),
201 'content' =>
202 "<h5>Codepress Admin Columns</h5>
203 <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>"
204 ),
205 array(
206 'title' => __( "Basics", 'cpac' ),
207 'content' => "
208 <h5>" . __( "Change order", 'cpac' ) . "</h5>
209 <p>" . __( "By dragging the columns you can change the order which they will appear in.", 'cpac' ) . "</p>
210 <h5>" . __( "Change label", 'cpac' ) . "</h5>
211 <p>" . __( "By clicking on the triangle you will see the column options. Here you can change each label of the columns heading.", 'cpac' ) . "</p>
212 <h5>" . __( "Change column width", 'cpac' ) . "</h5>
213 <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>
214 "
215 ),
216 array(
217 'title' => __( "Custom Field", 'cpac' ),
218 'content' =>
219 "<h5>". __( "'Custom Field' column", 'cpac' ) . "</h5>
220 <p>". __( "The custom field colum uses the custom fields from posts and users. There are 10 types which you can set.", 'cpac' ) . "</p>
221 <ul>
222 <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>
223 <li><strong>". __( "Image", 'cpac' ) . "</strong><br/>". __( "Value: should contain an image URL or Attachment IDs ( seperated by a ',' comma ).", 'cpac' ) . "</li>
224 <li><strong>". __( "Excerpt", 'cpac' ) . "</strong><br/>". __( "Value: This will show the first 20 words of the Post content.", 'cpac' ) . "</li>
225 <li><strong>". __( "Multiple Values", 'cpac' ) . "</strong><br/>". __( "Value: should be an array. This will flatten any ( multi dimensional ) array.", 'cpac' ) . "</li>
226 <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>
227 <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>
228 <li><strong>". __( "Post Titles", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more Post ID's (seperated by ',').", 'cpac' ) . "</li>
229 <li><strong>". __( "Usernames", 'cpac' ) . "</strong><br/>". __( "Value: can be one or more User ID's (seperated by ',').", 'cpac' ) . "</li>
230 <li><strong>". __( "Checkmark", 'cpac' ) . "</strong><br/>". __( "Value: should be a 1 (one) or 0 (zero).", 'cpac' ) . "</li>
231 <li><strong>". __( "Color", 'cpac' ) . "</strong><br/>". __( "Value: hex value color, such as #808080.", 'cpac' ) . "</li>
232 <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>
233 </ul>
234 "
235 )
236 );
237
238 foreach ( $tabs as $k => $tab ) {
239 $screen->add_help_tab( array(
240 'id' => 'cpac-tab-'.$k,
241 'title' => $tab['title'],
242 'content' => $tab['content'],
243 ));
244 }
245 }
246
247 /**
248 * External Urls
249 *
250 * @since 1.0.0
251 *
252 * @param string $storage_model URL type.
253 * @return string Url.
254 */
255 function get_url( $type ) {
256
257 $site_url = 'http://www.codepresshq.com';
258
259 $urls = array(
260 'codepress' => $site_url,
261 'admincolumns' => $site_url . '/wordpress-plugins/admin-columns/',
262 'pro_addon' => $site_url . '/wordpress-plugins/admin-columns/pro-add-on/',
263 'documentation' => $site_url . '/wordpress-plugins/admin-columns/',
264 'feedback' => $site_url . '/contact',
265 'plugins' => 'http://wordpress.org/extend/plugins/codepress-admin-columns/',
266 'support' => 'http://wordpress.org/tags/codepress-admin-columns/',
267 );
268
269 if ( ! isset( $urls[ $type ] ) )
270 return false;
271
272 return $urls[ $type ];
273 }
274
275 /**
276 * Has Custom Field
277 *
278 * @since 2.0.0
279 */
280 public function uses_custom_fields() {
281
282 $old_columns = get_option('cpac_options');
283
284 if ( empty( $old_columns['columns'] ) ) return false;
285
286 foreach ( $old_columns['columns'] as $columns ) {
287 foreach ( $columns as $id => $values ) {
288 if ( strpos( $id, 'column-meta-' ) !== false )
289 return true;
290 }
291 }
292
293 return false;
294 }
295
296 /**
297 * Handle Addon Download
298 *
299 * @since 2.0.0
300 */
301 function handle_download_request() {
302
303 // API domain
304 $store_url = 'http://codepresshq.com';
305
306 if ( ! isset( $_REQUEST['cpac_product_id'] ) ) return false;
307
308 $args = array(
309 'codepress-wc-api' => 'plugin_updater',
310 'secret_key' => '',
311 'product_id' => $_REQUEST['cpac_product_id'],
312 'licence_key' => isset( $_REQUEST['cpac_license_key'] ) ? $_REQUEST['cpac_license_key'] : '',
313 'slug' => '',
314 'instance' => 'fresh_install'
315 );
316
317 $result = wp_remote_get( add_query_arg( $args, $store_url ), array( 'timeout' => 15, 'sslverify' => false ) );
318
319 // Call the custom API.
320 $response = json_decode( wp_remote_retrieve_body( $result ) );
321
322 if ( ! $response ) {
323 cpac_admin_message( 'Could not connect to API.', 'error' );
324 return;
325 }
326 if( isset( $response->error ) ) {
327 cpac_admin_message( $response->error, 'error' );
328 return;
329 }
330 if( empty( $response->package ) ) {
331 cpac_admin_message( 'No File found.', 'error' );
332 return;
333 }
334
335 // no @ signs allowed/
336 // source: http://wordpress.stackexchange.com/questions/64818/wp-sanitize-redirect-strips-out-signs-even-from-parameters-why
337 $redirect_url = str_replace( '@', urlencode('@'), $response->package );
338
339 wp_redirect( $redirect_url );
340 exit;
341 }
342
343 /**
344 * Welcome screen
345 *
346 * @since 2.0.0
347 */
348 public function welcome_screen() {
349
350 // Should only be set after upgrade
351 $show_welcome = false !== get_transient('cpac_show_welcome');
352
353 // Should only be set manual
354 if ( isset( $_GET['info'] ) )
355 $show_welcome = true;
356
357 if ( ! $show_welcome )
358 return false;
359
360 // Set check that welcome should not be displayed.
361 delete_transient('cpac_show_welcome');
362
363 // Get tab
364 $tab = !empty( $_GET['info'] ) ? $_GET['info'] : 'whats-new';
365
366 // check if old site used custom field columns
367 $uses_customfields = $this->uses_custom_fields();
368 $uses_sortorder = get_option( "cpac_sortable_ac" ) && ! class_exists( 'CAC_Addon_Pro' ) ? true : false;
369
370 $installed_customfields = false;
371 $installed_sortorder = false;
372
373 ?>
374
375 <div id="cpac-welcome" class="wrap about-wrap">
376
377 <h1><?php _e( "Welcome to Admin Columns",'cpac'); ?> <?php echo CPAC_VERSION; ?></h1>
378
379 <div class="about-text">
380 <?php _e( "Thank you for updating to the latest version!", 'cpac' ); ?>
381 <?php _e( "Admin Columns is more polished and enjoyable than ever before. We hope you like it.", 'cpac' ); ?>
382 </div>
383
384 <div class="cpac-content-body">
385 <h2 class="nav-tab-wrapper">
386 <a class="cpac-tab-toggle nav-tab <?php if( $tab == 'whats-new' ){ echo 'nav-tab-active'; } ?>" href="<?php echo $this->settings_urls->info; ?>whats-new"><?php _e( "What’s New", 'cpac' ); ?></a>
387 <a class="cpac-tab-toggle nav-tab <?php if( $tab == 'changelog' ){ echo 'nav-tab-active'; } ?>" href="<?php echo $this->settings_urls->info; ?>changelog"><?php _e( "Changelog", 'cpac' ); ?></a>
388 <?php if( $tab == 'download-add-ons' ): ?>
389 <a class="cpac-tab-toggle nav-tab nav-tab-active" href="<?php echo $this->settings_urls->info; ?>download-add-ons"><?php _e( "Download Addons", 'cpac' ); ?></a>
390 <?php endif; ?>
391 </h2>
392
393 <?php if ( 'whats-new' === $tab ) : ?>
394
395 <h3><?php _e( "Addons", 'cpac' ); ?></h3>
396 <p>
397 <?php _e( "Addons are now activated by downloading and installing individual plugins. Although these plugins will not be hosted on the wordpress.org repository, each Add-on will continue to receive updates in the usual way.",'cpac'); ?>
398 </p>
399 <?php if ( $uses_sortorder ) : ?>
400 <h4><?php _e( "This website uses the Sortorder Addon. This addon needs to be downloaded." ,'cpac' ); ?></h4>
401 <div class="cpac-alert cpac-alert-success">
402 <p>
403 <?php _e( "Addons are seperate plugins which need to be downloaded.", 'cpac' ); ?> <a href="<?php echo $this->settings_urls->info; ?>download-add-ons" class="button-primary" style="display: inline-block;"><?php _e( "Download your Addons", 'cpac'); ?></a>
404 </p>
405 </div>
406 <?php else : ?>
407 <div class="cpac-alert cpac-alert-success">
408 <p>
409 <strong><?php _e( 'This website does not use add-ons', 'cpac' ); ?></strong>. <a target="_blank" href="<?php echo $this->get_url('pro_addon'); ?>"><?php _e( 'See our website for the Pro-addon.', 'cpac' ); ?></a>
410 </p>
411 </div>
412 <?php endif; ?>
413
414 <hr />
415
416 <h3><?php _e( "Important", 'cpac' ); ?></h3>
417
418 <h4><?php _e( "Database Changes", 'cpac' ); ?></h4>
419 <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>
420
421 <?php if ( get_option( 'cpac_version', false ) < CPAC_UPGRADE_VERSION ) : ?>
422 <p><?php _e("Make sure you backup your database and then click",'cpac'); ?> <a href="<?php echo $this->settings_urls->upgrade; ?>" class="button-primary"><?php _e( "Upgrade Database", 'cpac' );?></a></p>
423 <?php endif; ?>
424
425 <h4><?php _e( "Potential Issues", 'cpac' ); ?></h4>
426 <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>
427
428 <div class="cpac-alert cpac-alert-error">
429 <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>
430 </div>
431
432 <?php endif; ?>
433 <?php if ( 'changelog' === $tab ) : ?>
434
435 <h3><?php _e("Changelog for", 'cpac'); ?> <?php echo CPAC_VERSION; ?></h3>
436 <?php
437
438 $items = file_get_contents( CPAC_DIR . 'readme.txt' );
439
440 $items = end( explode('= ' . CPAC_VERSION . ' =', $items) );
441 $items = current( explode("\n\n", $items) );
442 $items = current( explode("= ", $items) );
443 $items = array_filter( array_map('trim', explode("*", $items)) );
444
445 ?>
446 <ul class="cpac-changelog">
447 <?php foreach( $items as $item ) :
448 $item = explode('http', $item);
449 ?>
450 <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>
451 <?php endforeach; ?>
452 </ul>
453
454 <?php endif; ?>
455 <?php if ( 'download-add-ons' === $tab ) : ?>
456
457 <h3><?php _e("Overview",'cpac'); ?></h3>
458
459 <p><?php _e( "New to v2, all Addons act as separate plugins which need to be individually downloaded, installed and updated.", 'cpac' ); ?></p>
460 <p><?php _e( "This page will assist you in downloading and installing each available Addon.", 'cpac' ); ?></p>
461 <h3><?php _e( "Available Addons", 'cpac' ); ?></h3>
462
463 <table class="widefat" id="cpac-download-add-ons-table">
464 <thead>
465 <tr>
466 <th><?php _e("Name",'cpac'); ?></th>
467 <th><?php _e("Download",'cpac'); ?></th>
468 </tr>
469 </thead>
470 <tbody>
471 <?php if ( $uses_sortorder ): ?>
472 <tr>
473 <th class="td-name"><?php _e("Pro Add-on (includes Sortorder add-on)",'cpac'); ?></th>
474 <td class="td-download">
475 <a class="button" href="<?php echo $this->settings_urls->info; ?>download-add-ons&amp;cpac_product_id=cac-pro&amp;cpac_license_key=<?php echo get_option( "cpac_sortable_ac" ); ?>"><?php _e("Download",'cpac'); ?></a>
476 </td>
477 </tr>
478 <?php endif; ?>
479
480 </tbody>
481 </table>
482
483 <h3><?php _e("Installation",'cpac'); ?></h3>
484
485 <p><?php _e("For each Add-on available, please perform the following:",'cpac'); ?></p>
486 <ol>
487 <li><?php _e("Download the Addon plugin (.zip file) to your desktop",'cpac'); ?></li>
488 <li><?php _e("Navigate to",'cpac'); ?> <a target="_blank" href="<?php echo admin_url('plugin-install.php?tab=upload'); ?>"><?php _e("Plugins > Add New > Upload",'cpac'); ?></a></li>
489 <li><?php _e("Use the uploader to browse, select and install your Add-on (.zip file)",'cpac'); ?></li>
490 <li><?php _e("Once the plugin has been uploaded and installed, click the 'Activate Plugin' link",'cpac'); ?></li>
491 <li><?php _e("The Add-on is now installed and activated!",'cpac'); ?></li>
492 <li><?php printf( __("For automatic updates make sure to <a href='%s'>enter your licence key</a>.",'cpac'), $this->settings_urls->settings ); ?></li>
493 </ol>
494
495 <?php endif; ?>
496
497 <hr/>
498
499 </div><!--.cpac-content-body-->
500
501 <div class="cpac-content-footer">
502 <a class="button-primary button-large" href="<?php echo $this->settings_urls->general; ?>"><?php _e("Start using Admin Columns",'cpac'); ?></a>
503 </div><!--.cpac-content-footer-->
504
505 </div>
506 <?php
507
508 return true;
509 }
510
511 /**
512 * Column Settings.
513 *
514 * @since 1.0.0
515 */
516 public function display() {
517
518 // Load Welcome screen
519 if ( $this->welcome_screen() ) return;
520
521 $current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : sanitize_text_field( urldecode( $_GET['tab'] ) );
522
523 // get first element from post-types
524 $post_types = array_values( $this->cpac->get_post_types() );
525 $first = array_shift( $post_types );
526 ?>
527
528 <div id="cpac" class="wrap">
529
530 <?php screen_icon( 'codepress-admin-columns' ); ?>
531
532 <h2 class="nav-tab-wrapper cpac-nav-tab-wrapper">
533 <?php
534 $tabs = array(
535 'general' => __( 'Admin Columns', 'cpac' ),
536 'settings' => __( 'Settings', 'cpac' )
537 );
538 foreach( $tabs as $name => $label ) : ?>
539 <a href="<?php echo $this->settings_urls->admin . "&amp;tab={$name}"; ?>" class="nav-tab<?php if( $current_tab == $name ) echo ' nav-tab-active'; ?>"><?php echo $label; ?></a>
540 <?php endforeach; ?>
541 </h2>
542
543 <?php do_action( 'cpac_messages' ); ?>
544
545 <?php
546 switch ($current_tab) :
547
548 case "general" :
549 ?>
550
551 <div class="cpac-menu">
552 <ul class="subsubsub">
553 <?php $count = 0; ?>
554 <?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
555 <li><?php echo $count++ != 0 ? ' | ' : ''; ?><a href="#cpac-box-<?php echo $storage_model->key; ?>" <?php echo $storage_model->is_menu_type_current( $first ) ? ' class="current"' : '';?> ><?php echo $storage_model->label; ?></a></li>
556 <?php endforeach; ?>
557 </ul>
558 </div>
559
560 <?php foreach ( $this->cpac->storage_models as $storage_model ) : ?>
561
562 <div class="columns-container" data-type="<?php echo $storage_model->key ?>"<?php echo $storage_model->is_menu_type_current( $first ) ? '' : ' style="display:none"'; ?>>
563
564 <div class="columns-left">
565 <div id="titlediv">
566 <h2>
567 <?php echo $storage_model->label; ?>
568 <?php $storage_model->screen_link(); ?>
569 </h2>
570 </div>
571 </div>
572
573 <div class="columns-right">
574 <div class="columns-right-inside">
575 <div class="sidebox" id="form-actions">
576 <h3>
577 <?php _e( 'Store settings', 'cpac' ) ?>
578 </h3>
579 <?php $has_been_stored = $storage_model->get_stored_columns() ? true : false; ?>
580 <div class="form-update">
581 <a href="javascript:;" class="button-primary submit-update"><?php echo $has_been_stored ? __( 'Update' ) : __('Publish'); ?> <?php echo $storage_model->label; ?></a>
582 </div>
583 <?php if ( $has_been_stored ) : ?>
584 <div class="form-reset">
585 <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->settings_urls->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 ); ?>');">
586 <?php _e( 'Restore', 'cpac' ); ?> <?php echo $storage_model->label; ?> <?php _e( 'columns', 'cpac' ); ?>
587 </a>
588 </div>
589 <?php endif; ?>
590
591 <?php do_action( 'cac/settings/form_actions', $storage_model ); ?>
592
593 </div><!--form-actions-->
594
595 <?php if ( ! class_exists( 'CAC_Addon_Pro' ) ) : ?>
596 <div class="sidebox" id="pro-version">
597 <div class="padding-box cta">
598 <h3>
599 <a href="<?php echo $this->get_url('pro_addon'); ?>"><?php _e( 'Get the Pro Add-on', 'cpac' ) ?></a>
600 </h3>
601 <div class="inside">
602 <ul>
603 <li><a href="<?php echo $this->get_url('pro_addon'); ?>"><?php _e( 'Add Sorting', 'cpac' ); ?></a></li>
604 <li><a href="<?php echo $this->get_url('pro_addon'); ?>"><?php _e( 'Add Filtering', 'cpac' ); ?></a></li>
605 <li><a href="<?php echo $this->get_url('pro_addon'); ?>"><?php _e( 'Add Import/Export', 'cpac' ); ?></a></li>
606 </ul>
607 <p>
608 <?php printf( __( 'Check the <a href="%s">Pro Add-on</a> for more details!', 'cpac' ), $this->get_url('pro_addon') ); ?>
609 </p>
610 </div>
611 </div>
612
613 <?php
614 // @todo: add newsletter
615 if ( false ) : ?>
616 <div class="padding-box newsletter">
617 <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">
618 <?php $user = wp_get_current_user(); ?>
619 <p>
620 <?php _e ( "Subscribe to receive news &amp; updates below.", 'cpac' ); ?>
621 </p>
622 <div class="mc-field-group">
623 <label for="mce-FNAME"><?php _e( 'First Name', 'cpac' ); ?></label>
624 <input type="text" value="<?php echo trim( esc_attr( $user->first_name ) ); ?>" name="FNAME" class="" id="mce-FNAME">
625 </div>
626 <div class="mc-field-group">
627 <label for="mce-EMAIL"><?php _e( 'Your Email', 'cpac' ); ?></label>
628 <input type="email" value="<?php echo trim( esc_attr( $user->user_email ) ); ?>" name="EMAIL" class="required email" id="mce-EMAIL">
629 </div>
630 <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
631 </form>
632 </div>
633 <?php endif; ?>
634 </div>
635 <?php endif; ?>
636
637 <div class="sidebox" id="plugin-support">
638 <h3><?php _e( 'Support', 'cpac' ); ?></h3>
639 <div class="inside">
640 <?php if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) : ?>
641 <p><?php _e( 'Check the <strong>Help</strong> section in the top-right screen.', 'cpac' ); ?></p>
642 <?php endif; ?>
643 <p>
644 <?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') ); ?>
645 </p>
646 </div>
647 </div><!--.form-actions-->
648
649 </div><!--.columns-right-inside-->
650 </div><!--.columns-right-->
651
652 <div class="columns-left">
653 <div class="cpac-boxes">
654 <div class="cpac-columns">
655
656 <form method="post" action="">
657 <?php wp_nonce_field( 'update-type', '_cpac_nonce'); ?>
658
659 <input type="hidden" name="cpac_key" value="<?php echo $storage_model->key; ?>" />
660 <input type="hidden" name="cpac_action" value="update_by_type" />
661
662 <?php
663 foreach ( $storage_model->columns as $column ) {
664 $column->display();
665 }
666 ?>
667 </form>
668
669 </div><!--.cpac-columns-->
670
671 <div class="column-footer">
672 <div class="order-message"><?php _e( 'Drag and drop to reorder', 'cpac' ); ?></div>
673
674 <div class="button-container">
675 <a href="javascript:;" class="add_column button button-primary">+ <?php _e( 'Add Column', 'cpac' );?></a><br/>
676 </div>
677
678 </div><!--.cpac-column-footer-->
679 </div><!--.cpac-boxes-->
680 </div><!--.columns-left-->
681 <div class="clear"></div>
682
683 <div class="for-cloning-only" style="display:none">
684 <?php
685 foreach ( $storage_model->get_registered_columns() as $column ) {
686 $column->display();
687 }
688 ?>
689 </div>
690
691 </div><!--.columns-container-->
692
693 <?php endforeach; // storage_models ?>
694
695 <div class="clear"></div>
696
697 <?php
698 break; // case: general
699
700 case 'settings' :
701 $this->display_settings();
702 break;
703
704 endswitch;
705 ?>
706
707 </div><!--.wrap-->
708 <?php
709 }
710
711 /**
712 * General Settings.
713 *
714 * @since 1.0.0
715 */
716 public function display_settings() {
717 ?>
718 <table class="form-table cpac-form-table">
719 <tbody>
720
721 <tr class="general">
722 <th scope="row">
723 <h3><?php _e( 'General Settings', 'cpac' ); ?></h3>
724 <p><?php _e( 'Customize your Admin Columns settings.', 'cpac' ); ?></p>
725 </th>
726 <td class="padding-22">
727 <div class="cpac_general">
728 <form method="post" action="options.php">
729 <?php settings_fields( 'cpac-general-settings' ); ?>
730 <?php $options = get_option( 'cpac_general_options' ); ?>
731 <p>
732 <br/>
733 </p>
734 <p>
735 <label for="show_hidden">
736 <input name="cpac_general_options[show_hidden]" id="show_hidden" type="checkbox" value="1" <?php checked( isset( $options['show_hidden'] ) ? $options['show_hidden'] : '', '1' ); ?>>
737 <?php _e( 'Show hidden custom fields. Default is <code>off</code>.', 'cpac' ); ?>
738 </label>
739 </p>
740 <p>
741 <label for="show_edit_button">
742 <input name="cpac_general_options[show_edit_button]" id="show_edit_button" type="checkbox" value="1" <?php checked( isset( $options['show_edit_button'] ) ? $options['show_edit_button'] : '', '1' ); ?>>
743 <?php _e( 'Show "Edit Columns" button on admin screens. Default is <code>off</code>.', 'cpac' ); ?>
744 </label>
745 </p>
746
747 <?php do_action( 'cac/settings/general', $options ); ?>
748
749 <p>
750 <input type="submit" class="button" value="<?php _e( 'Save' ); ?>" />
751 </p>
752 </form>
753 </div>
754 </td>
755 </tr><!--.general-->
756
757 <?php
758
759 /** Allow plugins to add their own custom settings to the settings page. */
760 if ( $groups = apply_filters( 'cac/settings/groups', array() ) ) {
761
762 foreach ( $groups as $id => $group ) {
763
764 $title = isset( $group['title'] ) ? $group['title'] : '';
765 $description = isset( $group['description'] ) ? $group['description'] : '';
766
767 ?>
768 <tr>
769 <th scope="row">
770 <h3><?php echo $title; ?></h3>
771 <p><?php echo $description; ?></p>
772 </th>
773 <td class="padding-22">
774 <?php
775
776 /** Use this Hook to add additonal fields to the group */
777 do_action( "cac/settings/groups/row={$id}" );
778
779 ?>
780 </td>
781 </tr>
782 <?php
783 }
784 }
785
786 ?>
787
788 <tr class="restore">
789 <th scope="row">
790 <h3><?php _e( 'Restore Settings', 'cpac' ); ?></h3>
791 <p><?php _e( 'This will delete all column settings and restore the default settings.', 'cpac' ); ?></p>
792 </th>
793 <td class="padding-22">
794 <form method="post" action="">
795 <?php wp_nonce_field( 'restore-all','_cpac_nonce'); ?>
796 <input type="hidden" name="cpac_action" value="restore_all" />
797 <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' ); ?>');" />
798 </form>
799 </td>
800 </tr><!--.restore-->
801
802 </tbody>
803 </table>
804
805 <?php
806 }
807 }