public function init() { global $sitepress; $tax_get = filter_input(INPUT_GET, 'taxonomy'); require ICL_PLUGIN_PATH . '/menu/term-taxonomy-menus/wpml-term-language-filter.class.php'; if (($trid = filter_input(INPUT_GET, 'trid')) && ($source_lang = filter_input(INPUT_GET, 'source_lang')) && get_taxonomy($tax_get) !== false) { $translations = $sitepress->get_element_translations($trid, 'tax_' . $this->taxonomy); if (isset($translations[$_GET['lang']]) && !empty($translations[$_GET['lang']]->term_id)) { wp_redirect(get_edit_term_link($translations[$_GET['lang']]->term_id, $tax_get)); exit; } else { add_action('admin_notices', array($this, '_tax_adding')); } } $term_lang_filter = new WPML_Term_Language_Filter(icl_get_setting('default_language')); if ($this->taxonomy === 'category') { add_action('edit_category_form', array($this, 'wpml_edit_term_form')); } else { add_action('add_tag_form', array($this, 'wpml_edit_term_form')); add_action('edit_tag_form', array($this, 'wpml_edit_term_form')); } add_action('admin_print_scripts-edit-tags.php', array($this, 'js_scripts_tags')); add_filter('wp_dropdown_cats', array($this, 'wp_dropdown_cats_select_parent'), 10, 2); add_action('admin_footer', array($term_lang_filter, 'terms_language_filter')); }
function ubik_terms_edit_link($content = '', $class = '') { // Exit early if not logged in if (!is_user_logged_in()) { return; } // Fetch the current query object $term = get_queried_object(); // Bail if something went wrong if (!empty($term) && is_user_logged_in()) { // Fetch the taxonomy and test the current user's capabilities $tax = get_taxonomy($term->taxonomy); if (empty($tax) || !current_user_can($tax->cap->edit_terms)) { return; } // If we made it this far let's grab the raw edit term link $link = get_edit_term_link($term->term_id, $term->taxonomy); // Content if (empty($content) || !is_string($content)) { $content = __('Edit', 'ubik'); } // Class if (!empty($class)) { $class = ' class="' . $class . '"'; } // Put it all together if (!empty($link)) { return '<a href="' . $link . '"' . $class . ' rel="nofollow">' . $content . '</a>'; } } }
public static function uploaded_icon($id) { $post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; // 2nd case for quick edit $taxonomy = isset($GLOBALS['taxonomy']) ? $GLOBALS['taxonomy'] : $_REQUEST['taxonomy']; $link = get_edit_term_link($id, $taxonomy, $post_type); return self::display_icon('uploaded', $link); }
/** * Get term in backend * * @param array $term * @param string $taxonomy * @return array|bool */ private function get_admin_translation(array $term, $taxonomy) { if (!current_user_can('edit_terms', $taxonomy)) { return FALSE; } $url = get_edit_term_link((int) $term['term_id'], $taxonomy); return array('target_url' => new Mlp_Url($url), 'target_title' => $term['name']); }
function column_name($item) { $term_id = (int) $item->term_id; $delete_url = add_query_arg('action', 'delete', get_edit_term_link($term_id, 'event-venue', 'event')); //Build row actions $actions = array('edit' => sprintf('<a href="%s">' . __('Edit') . '</a>', get_edit_term_link($term_id, 'event-venue', 'event')), 'delete' => sprintf('<a href="%s">' . __('Delete') . '</a>', wp_nonce_url($delete_url, 'eventorganiser_delete_venue_' . $item->slug)), 'view' => sprintf('<a href="%s">' . __('View') . '</a>', eo_get_venue_link($term_id))); //Return the title contents return sprintf('<a href="%1$s" class="row-title">%2$s</a>%3$s', get_edit_term_link($term_id, 'event-venue', 'event'), esc_html($item->name), $this->row_actions($actions)); }
/** * @ticket 35922 */ public function test_cap_check_should_use_correct_taxonomy_when_taxonomy_is_not_specified() { register_taxonomy('wptests_tax_subscriber', 'post', array('manage_terms' => 'read')); $t = self::factory()->term->create(array('taxonomy' => 'wptests_tax', 'name' => 'foo')); $u = self::factory()->user->create(array('role' => 'subscriber')); wp_set_current_user($u); $actual = get_edit_term_link($t); $this->assertNull($actual); }
protected function get_edit_link($term_id) { if (empty($term_id)) { return null; } $url = get_edit_term_link($term_id, $this->config['args']['taxonomy']); $result = \Cibulka::Base('HTML', 'a', array('target' => '_blank', 'href' => $url, 'class' => 'edit-link'), false, 'Upravit rubriku'); return $result; }
/** * Add action links to Stream drop row in admin list screen * * @filter wp_stream_action_links_{connector} * @param array $links Previous links registered * @param int $record Stream record * @return array Action links */ public static function action_links($links, $record) { if ($record->object_id && 'deleted' !== $record->action && ($term = get_term_by('term_taxonomy_id', $record->object_id, $record->context))) { if (!is_wp_error($term)) { $tax_obj = get_taxonomy($term->taxonomy); $tax_label = isset($tax_obj->labels->singular_name) ? $tax_obj->labels->singular_name : null; $links[sprintf(_x('Edit %s', 'Term singular name', 'stream'), $tax_label)] = get_edit_term_link($term->term_id, $term->taxonomy); $links[__('View', 'stream')] = get_term_link($term->term_id, $term->taxonomy); } } return $links; }
/** * Add action links to Stream drop row in admin list screen * * @filter wp_stream_action_links_{connector} * * @param array $links Previous links registered * @param Record $record Stream record * * @return array Action links */ public function action_links($links, $record) { if ($record->object_id && 'deleted' !== $record->action && ($term = get_term_by('term_taxonomy_id', $record->object_id, $record->context))) { if (!is_wp_error($term)) { $tax_obj = get_taxonomy($term->taxonomy); $tax_label = isset($tax_obj->labels->singular_name) ? $tax_obj->labels->singular_name : null; if (function_exists('wp_get_split_term')) { $term_id = wp_get_split_term($term->term_id, $term->taxonomy); } $term_id = empty($term_id) ? $term->term_id : $term_id; $links[sprintf(_x('Edit %s', 'Term singular name', 'stream'), $tax_label)] = get_edit_term_link($term_id, $term->taxonomy); $links[esc_html__('View', 'stream')] = wp_stream_is_vip() ? \wpcom_vip_get_term_link($term_id, $term->taxonomy) : get_term_link($term_id, $term->taxonomy); } } return $links; }
/** * Print the columns information * * @param $rec \YITH_Commission * @param $column_name * * @return string */ public function column_default($rec, $column_name) { switch ($column_name) { case 'user': if (empty($rec->display_name)) { return "<em>" . __('User deleted', 'yith_wc_product_vendors') . "</em>"; } $user_url = get_edit_user_link($rec->ID); $user_name = $rec->display_name; return !empty($user_url) ? "<a href='{$user_url}' target='_blank'>{$user_name}</a>" : $user_name; break; case 'vendor': $vendor = yith_get_vendor($rec->ID, 'user'); if (!$vendor->is_valid()) { return "<em>" . __('Vendor deleted', 'yith_wc_product_vendors') . "</em>"; } $vendor_url = get_edit_term_link($vendor->id, $vendor->taxonomy); $vendor_name = $vendor->name; return !empty($vendor_url) ? "<a href='{$vendor_url}' target='_blank'>{$vendor_name}</a>" : $vendor_name; break; case 'amount': $amount = get_user_meta($rec->ID, '_vendor_commission_credit', true); return wc_price($amount); break; case 'user_actions': if ($this->_vendor->is_super_user()) { printf('<a class="button tips pay" href="%1$s" data-tip="%2$s">%2$s</a>', esc_url(wp_nonce_url(add_query_arg(array('action' => 'pay_commission', 'commission_id' => $rec->ID), admin_url('admin.php')), 'yith-vendors-pay-commission')), __('Pay', 'yith_wc_product_vendors')); } break; case 'oldest_commission': $commissions = YITH_Commissions()->get_commissions(array('user_id' => $rec->ID, 'fields' => 'last_edit', 'order' => 'ASC')); $oldest_commission_date = array_shift($commissions); $t_time = date_i18n(__('Y/m/d g:i:s A'), mysql2date('U', $oldest_commission_date)); $m_time = $oldest_commission_date; $time = mysql2date('G', $oldest_commission_date); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } return $h_time ? '<abbr title="' . $t_time . '">' . $h_time . '</abbr>' : '<small class="meta">-</small>'; break; } return null; }
} if ($referer && false !== strpos($referer, 'edit-tags.php')) { $location = $referer; } $location = add_query_arg('message', 6, $location); break; case 'edit': if (!isset($_REQUEST['tag_ID'])) { break; } $term_id = (int) $_REQUEST['tag_ID']; $term = get_term($term_id); if (!$term instanceof WP_Term) { wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); } wp_redirect(esc_url_raw(get_edit_term_link($term_id, $taxonomy, $post_type))); exit; case 'editedtag': $tag_ID = (int) $_POST['tag_ID']; check_admin_referer('update-tag_' . $tag_ID); if (!current_user_can('edit_term', $tag_ID)) { wp_die('<h1>' . __('Cheatin’ uh?') . '</h1>' . '<p>' . __('Sorry, you are not allowed to edit this item.') . '</p>', 403); } $tag = get_term($tag_ID, $taxonomy); if (!$tag) { wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); } $ret = wp_update_term($tag_ID, $taxonomy, $_POST); $location = 'edit-tags.php?taxonomy=' . $taxonomy; if ('post' != $post_type) { $location .= '&post_type=' . $post_type;
function _eventorganiser_add_venue_admin_bar_edit_menu() { global $wp_admin_bar; if (is_admin()) { $current_screen = get_current_screen(); if ('event_page_venues' == $current_screen->base && isset($_GET['action']) && 'edit' == $_GET['action'] && ($tax = get_taxonomy('event-venue')) && $tax->public) { $wp_admin_bar->add_menu(array('id' => 'view', 'title' => $tax->labels->view_item, 'href' => eo_get_venue_link($_GET['event-venue']))); } } else { $current_object = get_queried_object(); if (!eo_is_venue()) { return; } if (($tax = get_taxonomy($current_object->taxonomy)) && current_user_can($tax->cap->edit_terms)) { $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => get_edit_term_link($current_object->term_id, $current_object->taxonomy))); } } }
/** * Get link to edit a term * @param int $value term id * @return string */ public function get_edit_link($value) { $term = $this->get_term($value); return sprintf('<a target="_new" class="fm-autocomplete-edit-link %s" href="%s">%s</a>', empty($value) ? 'fm-hidden' : '', empty($value) ? '#' : esc_url(get_edit_term_link($term->term_id, $term->taxonomy)), esc_html__('Edit', 'fieldmanager')); }
/** * Provide an edit link for posts and terms. * * @since 3.1.0 */ function wp_admin_bar_edit_menu($wp_admin_bar) { global $tag, $wp_the_query; if (is_admin()) { $current_screen = get_current_screen(); $post = get_post(); if ('post' == $current_screen->base && 'add' != $current_screen->action && ($post_type_object = get_post_type_object($post->post_type)) && current_user_can($post_type_object->cap->read_post, $post->ID) && $post_type_object->public && $post_type_object->show_in_admin_bar) { $wp_admin_bar->add_menu(array('id' => 'view', 'title' => $post_type_object->labels->view_item, 'href' => get_permalink($post->ID))); } elseif ('edit-tags' == $current_screen->base && isset($tag) && is_object($tag) && ($tax = get_taxonomy($tag->taxonomy)) && $tax->public) { $wp_admin_bar->add_menu(array('id' => 'view', 'title' => $tax->labels->view_item, 'href' => get_term_link($tag))); } } else { $current_object = $wp_the_query->get_queried_object(); if (empty($current_object)) { return; } if (!empty($current_object->post_type) && ($post_type_object = get_post_type_object($current_object->post_type)) && current_user_can($post_type_object->cap->edit_post, $current_object->ID) && $post_type_object->show_ui && $post_type_object->show_in_admin_bar) { $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => get_edit_post_link($current_object->ID))); } elseif (!empty($current_object->taxonomy) && ($tax = get_taxonomy($current_object->taxonomy)) && current_user_can($tax->cap->edit_terms) && $tax->show_ui) { $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => get_edit_term_link($current_object->term_id, $current_object->taxonomy))); } } }
function column_name($tag) { global $taxonomy, $tax, $post_type; $default_term = get_option('default_' . $taxonomy); $pad = str_repeat('— ', max(0, $this->level)); $name = apply_filters('term_name', $pad . ' ' . $tag->name, $tag); $qe_data = get_term($tag->term_id, $taxonomy, OBJECT, 'edit'); $edit_link = get_edit_term_link($tag->term_id, $taxonomy, $post_type); $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />'; $actions = array(); if (current_user_can($tax->cap->edit_terms)) { $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; } if (current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term) { $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy={$taxonomy}&tag_ID={$tag->term_id}", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>"; } $actions = apply_filters('tag_row_actions', $actions, $tag); $actions = apply_filters("{$taxonomy}_row_actions", $actions, $tag); $out .= $this->row_actions($actions); $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; $out .= '<div class="name">' . $qe_data->name . '</div>'; $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>'; $out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>'; return $out; }
/** * Print the columns information * * @param $rec \YITH_Commission * @param $column_name * * @return string */ public function column_default($rec, $column_name) { switch ($column_name) { case 'commission_id': $order = wc_get_order($rec->order_id); $order ? printf('<a href="%s"><strong>#%d</strong></a>', $rec->get_view_url('admin'), $rec->id) : printf('<strong>#%d</strong>', $rec->id); break; case 'commission_status': $display = $rec->get_status('display'); return "<mark data-tip='{$display}' class='{$rec->status} tips'>{$display}</mark>"; break; case 'order_id': /** @var WC_Order $order */ $order = wc_get_order($rec->order_id); if (!$order) { echo '<small class="meta">' . __('Order Deleted', 'yith_wc_product_vendors') . '</small>'; return; } if ($order->get_user_id()) { $user_info = $order->get_user(); } if (!empty($user_info)) { $current_user_can = current_user_can('edit_users') || get_current_user_id() == $user_info->ID; $username = $current_user_can ? '<a href="user-edit.php?user_id=' . absint($user_info->ID) . '">' : ''; if ($user_info->first_name || $user_info->last_name) { $username .= esc_html(ucfirst($user_info->first_name) . ' ' . ucfirst($user_info->last_name)); } else { $username .= esc_html(ucfirst($user_info->display_name)); } if ($current_user_can) { $username .= '</a>'; } } else { if ($order->billing_first_name || $order->billing_last_name) { $username = trim($order->billing_first_name . ' ' . $order->billing_last_name); } else { $username = __('Guest', 'woocommerce'); } } $order_number = '<strong>#' . esc_attr($order->get_order_number()) . '</strong>'; $order_uri = '<a href="' . admin_url('post.php?post=' . absint($order->id) . '&action=edit') . '">' . $order_number . '</a>'; $order_info = $this->_vendor->is_super_user() ? $order_uri : $order_number; printf(_x('%s by %s', 'Order number by user', 'yith_wc_product_vendors'), $order_info, $username); if ($order->billing_email) { echo '<small class="meta email"><a href="' . esc_url('mailto:' . $order->billing_email) . '">' . esc_html($order->billing_email) . '</a></small>'; } do_action('yith_wpv_after_order_column', $order); break; case 'line_item': $product = $rec->get_item(); if (!$product) { return '<small class="meta">-</small>'; } $product_url = get_edit_post_link($product['product_id']); return !empty($product_url) ? "<a target='_blank' href='{$product_url}'><strong>{$product['name']}</strong></a>" : "<strong>{$product['name']}</strong>"; break; case 'rate': return $rec->rate * 100 . '%'; break; case 'user': $user = $rec->get_user(); if (empty($user)) { return "<em>" . __('User deleted', 'yith_wc_product_vendors') . "</em>"; } $user_url = get_edit_user_link($rec->user_id); $user_name = $user->display_name; return !empty($user_url) ? "<a href='{$user_url}' target='_blank'>{$user_name}</a>" : $user_name; break; case 'vendor': $vendor = $rec->get_vendor(); if (!$vendor->is_valid()) { return "<em>" . __('Vendor deleted', 'yith_wc_product_vendors') . "</em>"; } $vendor_url = get_edit_term_link($vendor->id, $vendor->taxonomy); $vendor_name = $vendor->name; return !empty($vendor_url) ? "<a href='{$vendor_url}' target='_blank'>{$vendor_name}</a>" : $vendor_name; break; case 'amount': return wc_price($rec->amount); break; case 'user_actions': printf('<a class="button tips view" href="%1$s" data-tip="%2$s">%2$s</a>', $rec->get_view_url('admin'), __('View', 'yith_wc_product_vendors')); break; case 'date': $date = $rec->get_date(); $t_time = date_i18n(__('Y/m/d g:i:s A'), mysql2date('U', $date)); $m_time = $date; $time = mysql2date('G', $date); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } echo $h_time ? '<abbr title="' . $t_time . '">' . $h_time . '</abbr>' : '<small class="meta">-</small>'; break; case 'date_edit': $date = !empty($rec->last_edit) && strpos($rec->last_edit, '0000-00-00') ? $rec->last_edit : $rec->get_date(); $t_time = date_i18n(__('Y/m/d g:i:s A'), mysql2date('U', $date)); $m_time = $date; $time = mysql2date('G', !empty($rec->last_edit_gmt) && strpos($rec->last_edit_gmt, '0000-00-00') ? $rec->last_edit : $rec->get_date()); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < WEEK_IN_SECONDS) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } echo $h_time ? '<abbr title="' . $t_time . '">' . $h_time . '</abbr>' : '<small class="meta">-</small>'; break; } return null; }
public function term_column($out, $column, $term_id) { $inline = defined('DOING_AJAX') && $_REQUEST['action'] == 'inline-save-tax' && isset($_POST['inline_lang_choice']); if (false === strpos($column, 'language_') || !($lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->get_term_language($term_id))) { return $out; } $post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; // 2nd case for quick edit $taxonomy = isset($GLOBALS['taxonomy']) ? $GLOBALS['taxonomy'] : $_REQUEST['taxonomy']; if (!post_type_exists($post_type) || !taxonomy_exists($taxonomy)) { return $out; } $term_id = (int) $term_id; $language = $this->model->get_language(substr($column, 9)); if ($column == $this->get_first_language_column()) { $out = sprintf('<div class="hidden" id="lang_%d">%s</div>', $term_id, esc_html($lang->slug)); // identify the default categories to disable the language dropdown in js if (in_array(get_option('default_category'), $this->model->get_translations('term', $term_id))) { $out .= sprintf('<div class="hidden" id="default_cat_%1$d">%1$d</div>', $term_id); } } // link to edit term (or a translation) if (($id = $this->model->get_term($term_id, $language)) && ($term = get_term($id, $taxonomy))) { $out .= sprintf('<a class="%1$s" title="%2$s" href="%3$s"></a>', $id == $term_id ? 'pll_icon_tick' : esc_attr('pll_icon_edit translation_' . $id), esc_attr($term->name), esc_url(get_edit_term_link($id, $taxonomy, $post_type))); } else { $out .= sprintf('<a class="pll_icon_add" title="%1$s" href="%2$s"></a>', __('Add new translation', 'polylang'), esc_url($this->links->get_new_term_translation_link($term_id, $taxonomy, $post_type, $language))); } return $out; }
/** * Returst Edit Term Link * * @param object $term * @return string */ public static function editTermLink($term) { $st = mvb_Model_Helper::shortTitle($term->name); $link = '<a href="' . get_edit_term_link($term->term_id, 'category') . '" target="_blank" title="' . esc_attr($term->name) . '">' . $st . '</a>'; return $link; }
/** * Output column data for a taxonomy's term names. * * @param string $taxonomy The taxonomy name * @param array $args Optional array of arguments for this field */ public function col_taxonomy($taxonomy, array $args = array()) { global $post; $terms = get_the_terms($post, $taxonomy); $tax = get_taxonomy($taxonomy); if (is_wp_error($terms)) { echo $terms->get_error_message(); return; } if (empty($terms)) { echo '—'; return; } $out = array(); foreach ($terms as $term) { if ($args['link']) { switch ($args['link']) { case 'view': if ($tax->public) { $out[] = sprintf('<a href="%1$s">%2$s</a>', get_term_link($term), $term->name); } else { $out[] = $term->name; } break; case 'edit': if (current_user_can($tax->cap->edit_terms)) { $out[] = sprintf('<a href="%1$s">%2$s</a>', get_edit_term_link($term, $taxonomy, $post->post_type), $term->name); } else { $out[] = $term->name; } break; case 'list': $link = add_query_arg(array('post_type' => $post->post_type, $taxonomy => $term->slug), admin_url('edit.php')); $out[] = sprintf('<a href="%1$s">%2$s</a>', $link, $term->name); break; } } else { $out[] = $term->name; } } echo implode(', ', $out); }
/** * Display tag cloud. * * The text size is set by the 'smallest' and 'largest' arguments, which will * use the 'unit' argument value for the CSS text size unit. The 'format' * argument can be 'flat' (default), 'list', or 'array'. The flat value for the * 'format' argument will separate tags with spaces. The list value for the * 'format' argument will format the tags in a UL HTML list. The array value for * the 'format' argument will return in PHP array type format. * * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'. * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'. * * The 'number' argument is how many tags to return. By default, the limit will * be to return the top 45 tags in the tag cloud list. * * The 'topic_count_text' argument is a nooped plural from _n_noop() to generate the * text for the tooltip of the tag link. * * The 'topic_count_text_callback' argument is a function, which given the count * of the posts with that tag returns a text for the tooltip of the tag link. * * The 'post_type' argument is used only when 'link' is set to 'edit'. It determines the post_type * passed to edit.php for the popular tags edit links. * * The 'exclude' and 'include' arguments are used for the get_tags() function. Only one * should be used, because only one will be used and the other ignored, if they are both set. * * @since 2.3.0 * * @param array|string|null $args Optional. Override default arguments. * @return void|array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument. * Otherwise, this function outputs the tag cloud. */ function wp_tag_cloud($args = '') { $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'post_type' => '', 'echo' => true); $args = wp_parse_args($args, $defaults); $tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC'))); // Always query top tags if (empty($tags) || is_wp_error($tags)) { return; } foreach ($tags as $key => $tag) { if ('edit' == $args['link']) { $link = get_edit_term_link($tag->term_id, $tag->taxonomy, $args['post_type']); } else { $link = get_term_link(intval($tag->term_id), $tag->taxonomy); } if (is_wp_error($link)) { return; } $tags[$key]->link = $link; $tags[$key]->id = $tag->term_id; } $return = wp_generate_tag_cloud($tags, $args); // Here's where those top tags get sorted according to $args /** * Filters the tag cloud output. * * @since 2.3.0 * * @param string $return HTML output of the tag cloud. * @param array $args An array of tag cloud arguments. */ $return = apply_filters('wp_tag_cloud', $return, $args); if ('array' == $args['format'] || empty($args['echo'])) { return $return; } echo $return; }
function _taxonomy_languages_menu() { // tags language selection global $pagenow; if ($pagenow == 'edit-tags.php') { // handle case of the tax edit page (after a taxonomy has been added) // needs to redirect back to if (isset($_GET['trid']) && isset($_GET['source_lang'])) { $translations = $this->get_element_translations($_GET['trid'], 'tax_' . $_GET['taxonomy']); if (isset($translations[$_GET['lang']])) { wp_redirect(get_edit_term_link($translations[$_GET['lang']]->term_id, $_GET['taxonomy'])); exit; } else { add_action('admin_notices', array($this, '_tax_adding')); } } $taxonomy = isset($_GET['taxonomy']) ? esc_sql($_GET['taxonomy']) : 'post_tag'; if ($this->is_translated_taxonomy($taxonomy)) { add_action('admin_print_scripts-edit-tags.php', array($this, 'js_scripts_tags')); if ($taxonomy == 'category') { add_action('edit_category_form', array($this, 'edit_term_form')); } else { add_action('add_tag_form', array($this, 'edit_term_form')); add_action('edit_tag_form', array($this, 'edit_term_form')); } add_action('admin_footer', array($this, 'terms_language_filter')); add_filter('wp_dropdown_cats', array($this, 'wp_dropdown_cats_select_parent')); } } }
/** * Provide an edit link for posts and terms. * * @since 3.1.0 * * @param WP_Admin_Bar $wp_admin_bar */ function wp_admin_bar_edit_menu($wp_admin_bar) { global $tag, $wp_the_query; if (is_admin()) { $current_screen = get_current_screen(); $post = get_post(); if ('post' == $current_screen->base && 'add' != $current_screen->action && ($post_type_object = get_post_type_object($post->post_type)) && current_user_can('read_post', $post->ID) && $post_type_object->public && $post_type_object->show_in_admin_bar) { if ('draft' == $post->post_status) { $preview_link = set_url_scheme(get_permalink($post->ID)); /** This filter is documented in wp-admin/includes/meta-boxes.php */ $preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post); $wp_admin_bar->add_menu(array('id' => 'preview', 'title' => $post_type_object->labels->view_item, 'href' => esc_url($preview_link), 'meta' => array('target' => 'wp-preview-' . $post->ID))); } else { $wp_admin_bar->add_menu(array('id' => 'view', 'title' => $post_type_object->labels->view_item, 'href' => get_permalink($post->ID))); } } elseif ('edit-tags' == $current_screen->base && isset($tag) && is_object($tag) && ($tax = get_taxonomy($tag->taxonomy)) && $tax->public) { $wp_admin_bar->add_menu(array('id' => 'view', 'title' => $tax->labels->view_item, 'href' => get_term_link($tag))); } } else { $current_object = $wp_the_query->get_queried_object(); if (empty($current_object)) { return; } if (!empty($current_object->post_type) && ($post_type_object = get_post_type_object($current_object->post_type)) && current_user_can('edit_post', $current_object->ID) && $post_type_object->show_ui && $post_type_object->show_in_admin_bar && ($edit_post_link = get_edit_post_link($current_object->ID))) { $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => $edit_post_link)); } elseif (!empty($current_object->taxonomy) && ($tax = get_taxonomy($current_object->taxonomy)) && current_user_can($tax->cap->edit_terms) && $tax->show_ui && ($edit_term_link = get_edit_term_link($current_object->term_id, $current_object->taxonomy))) { $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => $edit_term_link)); } } }
/** * Remove the description column from taxonomy table * * @Author Andrea Grillo <*****@*****.**> * @since 1.0.0 * * @param $custom_column Filter value * @param $column_name Column name * @param $term_id The term id * * @internal param \The $columns columns * * @return array The columns list * @use manage_{$this->screen->taxonomy}_custom_column filter */ public function custom_columns($custom_column, $column_name, $term_id) { $vendor = yith_get_vendor($term_id); switch ($column_name) { case 'registration_date': return $vendor->get_registration_date('display'); break; case 'owner': $owner = get_user_by('id', $vendor->get_owner()); $edit_link = esc_url(get_edit_term_link($term_id, $this->_taxonomy_name, 'product')); return $owner instanceof WP_User ? sprintf('<a href="%s" target="_blank">%s</a>', get_edit_user_link($owner->ID), $owner->display_name) : sprintf('<a href="%s" class="set-an-owner">%s</a>', $edit_link, __('Set an owner', 'yith_wc_product_vendors')); break; case 'commission_rate': return $vendor->get_commission() * 100 . ' %'; break; case 'enable_sales': $shop_owner = $vendor->get_owner(); $sales = 'yes' == $vendor->enable_selling ? 'enabled' : 'disabled'; $pending = 'yes' == $vendor->pending ? 'pending' : ''; $owner = !empty($shop_owner) ? '' : 'no-owner'; $return = ''; if (!empty($pending)) { $return = $pending; } else { $return = !empty($shop_owner) ? $sales : $owner; } return sprintf('<mark class="%1$s">%1$s</mark>', $return); break; case 'vat': return sprintf('<mark class="%1$s">%1$s</mark>', empty($vendor->vat) ? 'no-vat' : 'vat'); break; case 'user_actions': $edit_link = esc_url(get_edit_term_link($term_id, $this->_taxonomy_name, 'product')); return sprintf('<a href="%s" class="button tips edit_extra_info">%s</a>', $edit_link, __('Edit extra info', 'yith_wc_product_vendors')); break; } }
/** * This function mimics the WordPress function get_edit_term_link() * because we cannot hook into the function without receiving errors. * * @since 1.0 * @uses $cpt_onomies_manager * @param int $term_id Term ID * @param string $taxonomy Taxonomy * @param string $object_type The object type * @return string */ public function get_edit_term_link($term_id, $taxonomy, $object_type = '') { global $cpt_onomies_manager; /** * This function only processes registered CPT-onomies. * If this is a normal taxonomy, then use the WordPress function. */ if (!$cpt_onomies_manager->is_registered_cpt_onomy($taxonomy)) { return get_edit_term_link($term_id, $taxonomy, $object_type); } $post_type = get_post_type_object($taxonomy); if (!current_user_can($post_type->cap->edit_posts)) { return; } $term = $this->get_term($term_id, $taxonomy); if (!$term) { return; } $args = array('post' => $term->term_id, 'action' => 'edit'); if ($object_type) { $args['post_type'] = $object_type; } $location = add_query_arg($args, admin_url('post.php')); return apply_filters('get_edit_term_link', $location, $term_id, $taxonomy, $object_type); }
/** * Generates and displays row action links. * * @since 4.3.0 * @access protected * * @param object $tag Tag being acted upon. * @param string $column_name Current column name. * @param string $primary Primary column name. * @return string Row actions output for terms. */ protected function handle_row_actions($tag, $column_name, $primary) { if ($primary !== $column_name) { return ''; } $taxonomy = $this->screen->taxonomy; $tax = get_taxonomy($taxonomy); $default_term = get_option('default_' . $taxonomy); $edit_link = esc_url(get_edit_term_link($tag->term_id, $taxonomy, $this->screen->post_type)); $actions = array(); if (current_user_can($tax->cap->edit_terms)) { $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; } if (current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term) { $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy={$taxonomy}&tag_ID={$tag->term_id}", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>"; } if ($tax->public) { $actions['view'] = '<a href="' . get_term_link($tag) . '">' . __('View') . '</a>'; } /** * Filter the action links displayed for each term in the Tags list table. * * @since 2.8.0 * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead. * * @param array $actions An array of action links to be displayed. Default * 'Edit', 'Quick Edit', 'Delete', and 'View'. * @param object $tag Term object. */ $actions = apply_filters('tag_row_actions', $actions, $tag); /** * Filter the action links displayed for each term in the terms list table. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * @since 3.0.0 * * @param array $actions An array of action links to be displayed. Default * 'Edit', 'Quick Edit', 'Delete', and 'View'. * @param object $tag Term object. */ $actions = apply_filters("{$taxonomy}_row_actions", $actions, $tag); return $this->row_actions($actions); }
/** * Get the edit permalink * @link http://codex.wordpress.org/Function_Reference/get_edit_term_link * @param string $object_type * @return string */ public function getEditPermalink($object_type = null) { // WordPress get_edit_term_link requires an object_type // but if this object was created by \Taco\Post::getTerms // then it will have an object_id, which also works if (is_null($object_type)) { $object_type = $this->get('object_id'); if (!$object_type) { throw new \Exception('No object_type nor object_id'); } } return get_edit_term_link($this->get('term_id'), $this->getTaxonomyKey(), $object_type); }
/** * Display or retrieve edit term link with formatting. * * @since 3.1.0 * * @param string $link Optional. Anchor text. * @param string $before Optional. Display before edit link. * @param string $after Optional. Display after edit link. * @param object $term Term object * @return string HTML content. */ function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true) { if (is_null($term)) { $term = get_queried_object(); } $tax = get_taxonomy($term->taxonomy); if (!current_user_can($tax->cap->edit_terms)) { return; } if (empty($link)) { $link = __('Edit This'); } $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '" title="' . $link . '">' . $link . '</a>'; $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after; if ($echo) { echo $link; } else { return $link; } }
public function edit_translation_link($term_id, $taxonomy, $post_type) { return sprintf('<div class="spinner"></div><a href="%1$s" class="pll_icon_edit title="%2$s"></a></td>', esc_url(get_edit_term_link($term_id, $taxonomy, $post_type)), __('Edit', 'polylang')); }
/** * Display or retrieve edit term link with formatting. * * @since 3.1.0 * * @param string $link Optional. Anchor text. Default empty. * @param string $before Optional. Display before edit link. Default empty. * @param string $after Optional. Display after edit link. Default empty. * @param object $term Optional. Term object. If null, the queried object will be inspected. Default null. * @param bool $echo Optional. Whether or not to echo the return. Default true. * @return string|void HTML content. */ function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true) { if (is_null($term)) { $term = get_queried_object(); } if (!$term) { return; } $tax = get_taxonomy($term->taxonomy); if (!current_user_can($tax->cap->edit_terms)) { return; } if (empty($link)) { $link = __('Edit This'); } $link = '<a href="' . get_edit_term_link($term->term_id, $term->taxonomy) . '">' . $link . '</a>'; /** * Filter the anchor tag for the edit link of a term. * * @since 3.1.0 * * @param string $link The anchor tag for the edit link. * @param int $term_id Term ID. */ $link = $before . apply_filters('edit_term_link', $link, $term->term_id) . $after; if ($echo) { echo $link; } else { return $link; } }
/** * Provide an edit link for posts and terms. * * @since 3.1.0 * * @global WP_Term $tag * @global WP_Query $wp_the_query * * @param WP_Admin_Bar $wp_admin_bar */ function wp_admin_bar_edit_menu($wp_admin_bar) { global $tag, $wp_the_query; if (is_admin()) { $current_screen = get_current_screen(); $post = get_post(); if ('post' == $current_screen->base && 'add' != $current_screen->action && ($post_type_object = get_post_type_object($post->post_type)) && current_user_can('read_post', $post->ID) && $post_type_object->public && $post_type_object->show_in_admin_bar) { if ('draft' == $post->post_status) { $preview_link = get_preview_post_link($post); $wp_admin_bar->add_menu(array('id' => 'preview', 'title' => $post_type_object->labels->view_item, 'href' => esc_url($preview_link), 'meta' => array('target' => 'wp-preview-' . $post->ID))); } else { $wp_admin_bar->add_menu(array('id' => 'view', 'title' => $post_type_object->labels->view_item, 'href' => get_permalink($post->ID))); } } elseif ('term' == $current_screen->base && isset($tag) && is_object($tag) && !is_wp_error($tag) && ($tax = get_taxonomy($tag->taxonomy)) && $tax->public) { $wp_admin_bar->add_menu(array('id' => 'view', 'title' => $tax->labels->view_item, 'href' => get_term_link($tag))); } } else { $current_object = $wp_the_query->get_queried_object(); if (empty($current_object)) { return; } if (!empty($current_object->post_type) && ($post_type_object = get_post_type_object($current_object->post_type)) && current_user_can('edit_post', $current_object->ID) && $post_type_object->show_in_admin_bar && ($edit_post_link = get_edit_post_link($current_object->ID))) { $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => $edit_post_link)); } elseif (!empty($current_object->taxonomy) && ($tax = get_taxonomy($current_object->taxonomy)) && current_user_can($tax->cap->edit_terms) && ($edit_term_link = get_edit_term_link($current_object->term_id, $current_object->taxonomy))) { $wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => $edit_term_link)); } } }