Skip to content

Instantly share code, notes, and snippets.

@ptasker
Created January 3, 2012 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptasker/1555319 to your computer and use it in GitHub Desktop.
Save ptasker/1555319 to your computer and use it in GitHub Desktop.
Cheezcap settings created from a list of terms
/**
*
* Helper for the Cheezcap config array.
*
* Loops through the terms and categories on the site and creates Cheezcap options for them.
*
* Used to create Cheezcap options per category/taxonomy
*
* @param type $term
* @param type $slug
* @param type $desc
* @param type $textarea
* @param type $rich
* @return CheezCapTextOption
* @see config/bl-cheez-config.php
*/
function bl_term_cheezies( $term, $slug, $desc = '', $textarea = false, $rich = false ) {
$terms = get_terms( $term, array( 'hide_empty' => false ) );
$cheezies = array( );
$ta = $textarea ? true : false;
if(!$terms)
return $cheezies;
foreach ( $terms as $term ) {
if ( $rich ) {
$cheezies[ ] = new CheezCapRichTextOption(
'Term details for ' . $term->name,
$desc,
$slug.'_' . $term->slug,
'',
true
);
} else {
$cheezies[ ] = new CheezCapTextOption(
'Term details for ' . $term->name,
$desc,
$slug . '_' . $term->slug,
'',
$ta
);
}
}
return $cheezies;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment