$post_types = esc_sql($tax_obj->object_type); } // Get the object and term ids and stick them in a lookup table $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM {$wpdb->term_relationships} INNER JOIN {$wpdb->posts} ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $post_types) . "') AND post_status in ( '" . implode("', '", $post_stati) . "' )"); foreach ($results as $row) { $id = $term_ids[$row->term_taxonomy_id]; $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1; } // Touch every ancestor's lookup row for each post in each term foreach ($term_ids as $term_id) { $child = $term_id; while (!empty($terms_by_id[$child]) && ($parent = $terms_by_id[$child]->parent)) { if (!empty($term_items[$term_id])) { foreach ($term_items[$term_id] as $item_id => $touches) { $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id] : 1; } } $child = $parent; } } // Transfer the touched cells foreach ((array) $term_items as $id => $items) { if (isset($terms_by_id[$id])) { $terms_by_id[$id]->count = count($items); } } } } // Class MLAShortcode_Support MLAShortcode_Support::mla_load_custom_templates();
/** * Put user-defined markup templates to $mla_templates and database * * @since 0.80 * * @param array name => value for all user-defined markup templates * @return boolean true if success, false if failure */ public static function mla_put_markup_templates($templates) { if (MLACore::mla_update_option('markup_templates', $templates)) { MLAShortcode_Support::mla_load_custom_templates(); return true; } return false; }