[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/ -> MP_newsletter_processor_post_type_.class.php (source)

   1  <?php
   2  abstract class MP_newsletter_processor_post_type_ extends MP_newsletter_processor_post_
   3  {
   4  	function what_else()
   5      {
   6      // find taxonomy
   7          if ( !isset( $this->newsletter['params']['taxonomy'] ) ) return true;
   8  
   9          $taxonomy = $this->newsletter['params']['taxonomy'];
  10          $term_id  = $this->newsletter['params']['term_id'];
  11  
  12          $terms = $this->get_terms( $term_id, $taxonomy );
  13  
  14          if ( empty( $terms ) )
  15          {
  16              $post_type = $this->newsletter['params']['post_type'];
  17              MP_Newsletter_processors::message_report( $this->newsletter, "no terms for $post_type #{$this->post_id} in $taxonomy", $this->trace );
  18              return false;
  19          }
  20  
  21          if ( !is_object_in_term( $this->post_id, $taxonomy, $terms ) ) 
  22          {
  23              $post_type = $this->newsletter['params']['post_type'];
  24              MP_Newsletter_processors::message_report( $this->newsletter, "newsletter $taxonomy ( terms/ids ) : " . join( ',', $terms ), $this->trace );
  25              MP_Newsletter_processors::message_report( false, "$post_type #{$this->post_id} not in required $taxonomy", $this->trace );
  26              return false;
  27          }
  28  
  29          return true;
  30      }
  31  
  32  	function get_terms( $term_id, $taxonomy )
  33      {
  34          if ( !isset( $this->newsletter[$this->args]['query_posts'][$taxonomy] ) ) return array();
  35          $terms = ( array ) $this->newsletter[$this->args]['query_posts'][$taxonomy];
  36  
  37          if ( is_taxonomy_hierarchical( $taxonomy ) )
  38          {
  39              $children = get_term_children( $term_id, $taxonomy );
  40              if ( !is_a( $children, 'WP_Error' ) ) $terms = array_merge( $terms, $children );
  41          }
  42  
  43          return $terms;
  44      }
  45  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1