Description
Added in version 1.4
The gravityflowfolders_folders filter allows customization of the list of folders can be added/removed from. If customizing this filter you may want to look at gravityflowfolders_folder_match_remove_step and gravityflowfolders_gravityflowfolders_folder_match_add_stepfolder_match_add_step
Parameters
Parameter | Type | Definition |
---|---|---|
$folder_configs | Array | The configuration for each defined folder. |
Examples
Define folders based on a WordPress taxonomy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | add_filter( 'gravityflowfolders_folders' , 'folders_execgroups' , 10, 1 ); function folders_execgroups( $folder_configs ) { // Retrieve the set of objects you want to base additional folders on. $execgroups = get_terms( array ( 'taxonomy' => 'execgroup' , 'hide_empty' => false, ) ); if ( ! empty ( $execgroups ) ) { //Loop through the array - in this example case it is a custom taxonomy foreach ( $execgroups as $execgroup ) { // JS generates a random id for direct folder creation. // Use the term data as seed to generate an approximate random id of same length/ $folder_configs [] = array ( 'id' => substr ( md5( $execgroup ->term_id), 0, 9), 'name' => $execgroup ->name, 'permissions' => 'all' , 'assignees' => array (), ); } } return $folder_configs ; } |
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?