pmpro_post_classes

Adds custom classes to the array of post classes.

Description

(array) pmpro_post_classes( (array) $classes, $class, $post_id ); 

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

Returns (array)

Parameters (3)

0. $classes (array)
Classes for the post element.
1. $class
The class.
2. $post_id
The post id.

Usage

  1. if ( !function_exists( 'pmpro_post_classes' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/content.php'; 
  3.  
  4. // Classes for the post element. 
  5. $classes = array(); 
  6.  
  7. // The class. 
  8. $class = null; 
  9.  
  10. // The post id. 
  11. $post_id = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pmpro_post_classes($classes, $class, $post_id); 
  15.  

Defined (1)

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

/includes/content.php  
  1. function pmpro_post_classes( $classes, $class, $post_id ) {  
  2.  
  3. $post = get_post($post_id); 
  4.  
  5. if(empty($post)) 
  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-level-required'; 
  14. foreach($post_levels[1] as $post_level) 
  15. $classes[] = 'pmpro-level-' . $post_level[0]; 
  16. if(!empty($post_levels[0]) && $post_levels[0] == true) 
  17. $classes[] = 'pmpro-has-access'; 
  18. else 
  19. $classes[] = 'pmpro-no-access'; 
  20. return $classes;