/** * Get field HTML * * @param string $html * @param mixed $meta * @param array $field * * @return string */ static function html($html, $meta, $field) { $meta_defaults = array('select' => 'all', 'type' => 'albums', 'posts_ids' => array(), 'terms_ids' => array()); // in taxonomy mode change default type to 'category' if ('taxonomy' == $field['mode']) { $meta_defaults['type'] = 'category'; } $meta = wp_parse_args($meta, $meta_defaults); if (!is_array($meta['posts_ids'])) { $meta['posts_ids'] = explode(',', $meta['posts_ids']); } if (!is_array($meta['terms_ids'])) { $meta['terms_ids'] = explode(',', $meta['terms_ids']); } // store field self::$field = $field; self::$meta = $meta; $html = $posts_html = $taxonomy_html = ''; if (in_array($field['mode'], array('both', 'posts'))) { if (!empty($field['post_type'])) { self::$post_type_obj = get_post_type_object($field['post_type']); self::$posts_query = new WP_Query(array('post_type' => $field['post_type'], 'posts_per_page' => -1, 'post_status' => 'publish')); } $posts_html = self::get_posts_tab(); } if (in_array($field['mode'], array('both', 'taxonomy'))) { if ($field['taxonomy']) { self::$taxonomy_obj = get_taxonomy($field['taxonomy']); self::$tax_query = get_terms($field['taxonomy'], array('hide_empty' => true, 'hierarchical' => false, 'pad_counts' => false)); } $taxonomy_html = self::get_taxonomy_tab(); } $html .= self::get_tabs(); $html .= '<div class="dt_tabs-content">'; $html .= self::get_main_tab(); $html .= '<div class="dt_tab-select hide-if-js">'; $html .= $posts_html . $taxonomy_html; $html .= '</div><!-- /.dt_tab-select -->'; $html .= '</div><!-- /.dt_tabs-content -->'; return $html; }
/** * Get field HTML * * @param string $html * @param mixed $meta * @param array $field * * @return string */ static function html($html, $meta, $field) { $meta_defaults = array('select' => 'all', 'type' => 'albums', 'posts_ids' => array(), 'terms_ids' => array()); // in taxonomy mode change default type to 'category' if ('taxonomy' == $field['mode']) { $meta_defaults['type'] = 'category'; } $meta = wp_parse_args($meta, $meta_defaults); if (!is_array($meta['posts_ids'])) { $meta['posts_ids'] = explode(',', $meta['posts_ids']); } if (!is_array($meta['terms_ids'])) { $meta['terms_ids'] = explode(',', $meta['terms_ids']); } // store field self::$field = $field; self::$meta = $meta; $html = $posts_html = $taxonomy_html = ''; if (in_array($field['mode'], array('both', 'posts'))) { if (!empty($field['post_type'])) { self::$post_type_obj = get_post_type_object($field['post_type']); $query = self::get_posts_query($field['post_type']); update_post_thumbnail_cache($query); } $posts_html = self::get_posts_tab(); } if (in_array($field['mode'], array('both', 'taxonomy'))) { if ($field['taxonomy']) { self::$taxonomy_obj = get_taxonomy($field['taxonomy']); self::get_taxonomy_query($field['taxonomy']); } $taxonomy_html = self::get_taxonomy_tab(); } $html .= self::get_tabs(); $html .= '<div class="dt_tabs-content">'; $html .= self::get_main_tab(); $html .= '<div class="dt_tab-select hide-if-js">'; $html .= $posts_html . $taxonomy_html; $html .= '</div><!-- /.dt_tab-select -->'; $html .= '</div><!-- /.dt_tabs-content -->'; return $html; }