Skip to content

Commit

Permalink
initial functions for page_builder_class and get_page_builder_class. …
Browse files Browse the repository at this point in the history
…TODO need to figure out a way to identify the current template part being used

#11
  • Loading branch information
jazzsequence committed Jul 20, 2015
1 parent c7184f2 commit b92234b
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,55 @@ function wds_page_builder_load_part( $part = '' ) {

$page_builder = new WDS_Page_Builder;
$page_builder->load_template_part( array( 'template_group' => $part ) );
}

/**
* Display the classes for the template part wrapper
* @since 1.5
* @param string|array $class One or more classes to add to the class list
* @return null
*/
function page_builder_class( $class = '' ) {
// Separates classes with a single space, collates classes for template part wrapper DIV
echo 'class="' . join( ' ', get_page_builder_class( $class ) ) . '"';
}

/**
* Retrieve the class names for the template part as an array
*
* Based on post_class, but we're not getting as much information as post_class.
* We just want to return a generic class, the current template part slug, and any
* custom class names that were passed to the function.
*
* @param string|array $class One or more classes to add to the class list
* @param string $part_slug Optional. The template part slug.
* @return array Array of classes.
*/
function get_page_builder_class( $class = '', $part_slug = '' ) {

if ( $class ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_map( 'esc_attr', $class );
}

$classes[] = 'pagebuilder-part';

// if ( ! $part_slug ) {
// $part_slug = get_page_builder_part_slug();
// }
// $classes[] = $part_slug;

/**
* Filter the list of CSS classes for the current part
* @since 1.5
* @param array $classes An array of pagebuilder part classes
* @param string $class A comma-separated list of additional classes added to the post
* @param string $part_slug The template part slug to add the filtered classes to
*/
$classes = apply_filters( 'page_builder_class', $classes, $class, $part_slug );

return array_unique( $classes );

}

0 comments on commit b92234b

Please sign in to comment.