pmpro_body_classes

Adds custom classes to the array of body classes.

Description

(array) pmpro_body_classes( (array) $classes ); 

Same as the above, but acts on the queried object instead of the post global.

pmpro-body-level-required = this post requires at least one level pmpro-body-level-1 = this post requires level 1 pmpro-body-has-access = this post is usually locked, but the current user has access to this post

Returns (array)

Parameters (1)

0. $classes (array)
Classes for the body element.

Usage

  1. if ( !function_exists( 'pmpro_body_classes' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/content.php'; 
  3.  
  4. // Classes for the body element. 
  5. $classes = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_body_classes($classes); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/content.php  
  1. function pmpro_body_classes( $classes ) {  
  2.  
  3. $post = get_queried_object(); 
  4.  
  5. if(empty($post) || !is_singular()) 
  6. return $classes; 
  7.  
  8. $post_levels = array(); 
  9. $post_levels = pmpro_has_membership_access($post->ID, NULL, true); 
  10.  
  11. if(!empty($post_levels)) 
  12. if(!empty($post_levels[1])) 
  13. $classes[] = 'pmpro-body-level-required'; 
  14. foreach($post_levels[1] as $post_level) 
  15. $classes[] = 'pmpro-body-level-' . $post_level[0]; 
  16. if(!empty($post_levels[0]) && $post_levels[0] == true) 
  17. $classes[] = 'pmpro-body-has-access'; 
  18. return $classes;