function gather_all_tags($post) { $tags = array(); // If we're on wp-admin, then tags are POSTed if (!empty($_POST['tax_input']['post_tag'])) { $post_tags = explode(',', $_POST['tax_input']['post_tag']); $tags = array_merge($tags, $post_tags); } // Extract inline tags from the post_content $inline_tags = o2_Tags::find_tags($post->post_content, true); if (!empty($inline_tags)) { $tags = array_merge($tags, $inline_tags); } $tags = array_unique($tags); return $tags; }
function gather_all_tags($post) { $tags = array(); // If we're on wp-admin, then tags are POSTed (Quick Edit) or GETed (Bulk Edit). $new_tags = array(); if (!empty($_POST['tax_input']['post_tag'])) { $new_tags = $_POST['tax_input']['post_tag']; } else { if (!empty($_GET['tax_input']['post_tag'])) { $new_tags = explode(',', $_GET['tax_input']['post_tag']); $old_tags = wp_get_post_terms($post->ID, 'post_tag'); foreach ($old_tags as $old_tag) { $new_tags[] = $old_tag->slug; } $new_tags = array_unique($new_tags); } } if (!empty($new_tags)) { if (is_array($new_tags)) { $post_tags = $new_tags; } else { $post_tags = preg_split('/\\s*,\\s*/', $new_tags); } foreach ($post_tags as $tag) { if (is_int($tag)) { /* * Deal with edit_post() which converts taxonomy input to term IDs to avoid ambiguity. * See https://core.trac.wordpress.org/changeset/31359 */ $term = get_term($tag, 'post_tag'); if (!empty($term) && !is_wp_error($term)) { $tags[] = $term->slug; } } else { $tags[] = trim($tag); } } } // Extract inline tags from the post_content. $inline_tags = o2_Tags::find_tags($post->post_content, true); if (!empty($inline_tags)) { $tags = array_merge($tags, $inline_tags); } $tags = array_unique($tags); return $tags; }