Created
September 17, 2014 14:44
-
-
Save annalinneajohansson/be49f6e08640e61003f0 to your computer and use it in GitHub Desktop.
Adds a rules column to ACF field groups overview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'manage_edit-acf-field-group_columns', 'hip_acf_columns', 9999 ); | |
| add_filter( 'manage_acf-field-group_posts_custom_column', 'hip_acf_columns_html', 9999 ); | |
| function hip_acf_columns( $columns ) { | |
| $columns['rules'] = __( 'Rules', THEME_TEXTDOMAIN ); | |
| return $columns; | |
| } | |
| function hip_acf_columns_html( $column, $post_id ) { | |
| $field_group = get_post( $post_id ); | |
| $rules = unserialize( $field_group->post_content ); | |
| $location = isset( $rules['location'] ) ? $rules['location'] : false; | |
| if( $column == 'rules' && $location ) { | |
| $groups = count( $location ); | |
| $i = 0; | |
| foreach ( $location as $group ) : | |
| if( $groups > 1 && $i > 0 ) echo "<strong>OR</strong>"; | |
| echo "<ul style='border:1px solid #EEE;padding:5px'>"; | |
| foreach ( $group as $item ) : | |
| echo "<li>" . $item['param'] . " " . $item['operator'] . " " . $item['value'] . "</li>"; | |
| endforeach; | |
| echo "</ul>"; | |
| ++$i; | |
| endforeach; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment