/** * Gets all of the used tags from the database * @since 2.0 */ function get_all_snippet_tags() { /** @var wpdb $wpdb */ global $wpdb; /* Grab all tags from the database */ $tags = array(); $table = get_snippets_table_name(); $all_tags = $wpdb->get_col("SELECT `tags` FROM {$table}"); /* Merge all tags into a single array */ foreach ($all_tags as $snippet_tags) { $snippet_tags = code_snippets_build_tags_array($snippet_tags); $tags = array_merge($snippet_tags, $tags); } /* Remove duplicate tags */ return array_values(array_unique($tags, SORT_REGULAR)); }
/** * Prepare the snippet tags by ensuring they are in the correct format * @param string|array $tags The tags as provided * @return array The tags as an array */ private function prepare_tags($tags) { return code_snippets_build_tags_array($tags); }
/** * Unescape snippet data after retrieval from the database * ready for use * * @since 2.0 * @param mixed $snippet An object or array containing the data to unescape * @return object The resulting snippet object, with data unescaped */ function unescape_snippet_data($snippet) { $snippet = build_snippet_object($snippet); /* Ensure the tags are a valid array */ $snippet->tags = code_snippets_build_tags_array($snippet->tags); return apply_filters('code_snippets/unescape_snippet_data', $snippet); }