/**
  * Gets the tags of the snippets currently being viewed in the table
  * @since 2.0
  */
 function get_current_tags()
 {
     global $snippets, $status;
     /* If we're not viewing a snippets table, get all used tags instead */
     if (!isset($snippets, $status)) {
         return get_all_snippet_tags();
     }
     $tags = array();
     /* Merge all tags into a single array */
     foreach ($snippets[$status] as $snippet) {
         $tags = array_merge($snippet->tags, $tags);
     }
     /* Remove duplicate tags */
     return array_values(array_unique($tags, SORT_REGULAR));
 }
示例#2
0
    /**
     * Render the interface for editing snippet tags
     * @param Snippet $snippet the snippet currently being edited
     */
    function render_tags_editor(Snippet $snippet)
    {
        ?>
		<label for="snippet_tags" style="cursor: auto;">
			<h3><?php 
        esc_html_e('Tags', 'code-snippets');
        ?>
</h3>
		</label>

		<input type="text" id="snippet_tags" name="snippet_tags" style="width: 100%;"
			placeholder="<?php 
        esc_html_e('Enter a list of tags; separated by commas', 'code-snippets');
        ?>
" value="<?php 
        echo $snippet->tags_list;
        ?>
" />

		<script type="text/javascript">
		jQuery('#snippet_tags').tagit({
			availableTags: ['<?php 
        echo implode("','", get_all_snippet_tags());
        ?>
'],
			allowSpaces: true,
			removeConfirmation: true
		});
		</script>
		<?php 
    }