Sin descripción

Posts.php 858B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace MailPoet\WP;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\WP\Functions as WPFunctions;
  5. class Posts {
  6. public static function getTerms($args) {
  7. // Since WordPress 4.5.0 signature of get_terms changed to require
  8. // one argument array, where taxonomy is key of that array
  9. if (version_compare(WPFunctions::get()->getBloginfo('version'), '4.5.0', '>=')) {
  10. return WPFunctions::get()->getTerms($args);
  11. } else {
  12. $taxonomy = $args['taxonomy'];
  13. unset($args['taxonomy']);
  14. return WPFunctions::get()->getTerms($taxonomy, $args);
  15. }
  16. }
  17. public static function getTypes($args = [], $output = 'names', $operator = 'and') {
  18. $defaults = [
  19. 'exclude_from_search' => false,
  20. ];
  21. $args = array_merge($defaults, $args);
  22. return WPFunctions::get()->getPostTypes($args, $output, $operator);
  23. }
  24. }