/** * Builds content of the snippet name column * @param object $snippet The snippet object being used for the current row * @return string The content of the column to output */ function column_name($snippet) { /* Build row actions */ $actions = array(); $screen = get_current_screen(); if ($snippet->active) { $actions['deactivate'] = sprintf('<a href="%2$s">%1$s</a>', $screen->is_network ? __('Network Deactivate', 'code-snippets') : __('Deactivate', 'code-snippets'), esc_url(add_query_arg(array('action' => 'deactivate', 'id' => $snippet->id)))); } else { $actions['activate'] = sprintf('<a href="%2$s">%1$s</a>', $screen->is_network ? __('Network Activate', 'code-snippets') : __('Activate', 'code-snippets'), esc_url(add_query_arg(array('action' => 'activate', 'id' => $snippet->id)))); } $actions['edit'] = sprintf('<a href="%2$s">%1$s</a>', __('Edit', 'code-snippets'), get_snippet_edit_url($snippet->id)); $actions['export'] = sprintf('<a href="%2$s">%1$s</a>', __('Export', 'code-snippets'), esc_url(add_query_arg(array('action' => 'export', 'id' => $snippet->id)))); $actions['delete'] = sprintf('<a href="%2$s" class="delete" onclick="%3$s">%1$s</a>', __('Delete', 'code-snippets'), esc_url(add_query_arg(array('action' => 'delete', 'id' => $snippet->id))), esc_js(sprintf('return confirm("%s");', __("You are about to permanently delete the selected item.\n\t\t\t\t'Cancel' to stop, 'OK' to delete.", 'code-snippets')))); if (!empty($snippet->name)) { $title = $snippet->name; } else { $title = sprintf(__('Untitled #%d', 'code-snippets'), $snippet->id); } $row_actions = $this->row_actions($actions, apply_filters('code_snippets/list_table/row_actions_always_visiable', false)); /* Return the name contents */ return apply_filters('code_snippets/list_table/column_name', sprintf('<a href="%2$s"><strong>%1$s</strong></a>', $title, get_snippet_edit_url($snippet->id)) . $row_actions, $snippet); }
/** * Build the content of the snippet name column * * @param Snippet $snippet The snippet being used for the current row * @return string The content of the column to output */ protected function column_name($snippet) { $action_links = $snippet->shared_network ? $this->get_shared_network_snippet_action_links($snippet) : $this->get_snippet_action_links($snippet); $title = empty($snippet->name) ? sprintf(__('Untitled #%d', 'code-snippets'), $snippet->id) : $snippet->name; $row_actions = $this->row_actions($action_links, apply_filters('code_snippets/list_table/row_actions_always_visible', false)); $out = sprintf('<a href="%s"><strong>%s</strong></a>', get_snippet_edit_url($snippet->id, $snippet->network ? 'network' : 'admin'), $title); if ($snippet->shared_network && !current_user_can(apply_filters('code_snippets_network_cap', 'manage_network_snippets'))) { $out = sprintf('<a><strong>%s</strong></a>', $title); } if ($snippet->shared_network) { $out .= ' <span class="badge">' . esc_html__('Shared on Network', 'code-snippets') . '</span>'; } /* Return the name contents */ return apply_filters('code_snippets/list_table/column_name', $out, $snippet) . $row_actions; }