PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.1.4
Admin Columns v7.1.4
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Table / PrimaryColumn.php
codepress-admin-columns / classes / Table Last commit date
InlineStyle 1 day ago ManageHeading 1 day ago ManageValue 1 day ago SaveHeading 1 day ago Service 1 day ago TableScreenRepository 1 day ago AdminHeadStyle.php 1 day ago ManageValueServiceFactory.php 1 day ago PrimaryColumn.php 1 day ago PrimaryColumnFactory.php 1 day ago SaveHeadingFactory.php 1 day ago Screen.php 1 day ago ScreenTools.php 1 day ago TableFormView.php 1 day ago TablePreference.php 1 day ago TableScreenCollection.php 1 day ago TableScreenRepository.php 1 day ago
PrimaryColumn.php
100 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\Table;
6
7 use AC\Helper;
8 use AC\ListScreen;
9 use AC\ListTable\Comment;
10 use AC\PostType;
11 use AC\TableScreen\Media;
12 use AC\Type\ColumnId;
13 use WP_Post;
14
15 class PrimaryColumn
16 {
17 private ListScreen $list_screen;
18
19 public function __construct(ListScreen $list_screen)
20 {
21 $this->list_screen = $list_screen;
22 }
23
24 public function set_primary_column(string $default): string
25 {
26 $default_column = $this->list_screen->get_column(new ColumnId($default));
27
28 $columns = $this->list_screen->get_columns();
29 $column = $columns->first();
30
31 if (! $default_column && $column) {
32 $default = (string)$column->get_id();
33 }
34
35 $table_screen = $this->list_screen->get_table_screen();
36
37 // If actions column is present, set it as primary
38 foreach ($columns as $column) {
39 if ('column-actions' === $column->get_type()) {
40 $default = (string)$column->get_id();
41
42 if ($table_screen instanceof Media) {
43 // Add download button to the actions column
44 add_filter('media_row_actions', [$this, 'set_media_download_row_action'], 10, 2);
45 }
46 }
47 }
48
49 // Set inline edit data if the default column (title) is not present
50 if ($table_screen instanceof PostType && 'title' !== $default) {
51 add_filter('page_row_actions', [$this, 'set_inline_edit_data'], 20, 2);
52 add_filter('post_row_actions', [$this, 'set_inline_edit_data'], 20, 2);
53 }
54
55 // Remove inline edit action if the default column (author) is not present
56 if ($table_screen instanceof Comment && 'comment' !== $default) {
57 add_filter('comment_row_actions', [$this, 'remove_quick_edit_from_actions'], 20, 2);
58 }
59
60 return $default;
61 }
62
63 public function set_media_download_row_action(array $actions, WP_Post $post): array
64 {
65 $url = wp_get_attachment_url($post->ID);
66
67 if (! $url) {
68 return $actions;
69 }
70
71 $label = __('Download', 'codepress-admin-columns');
72
73 $actions['download'] = Helper\Html::create()->link(
74 $url,
75 $label,
76 [
77 'download' => '',
78 'title' => $label,
79 ]
80 );
81
82 return $actions;
83 }
84
85 public function set_inline_edit_data($actions, WP_Post $post)
86 {
87 get_inline_data($post);
88
89 return $actions;
90 }
91
92 public function remove_quick_edit_from_actions($actions)
93 {
94 unset($actions['quickedit']);
95
96 return $actions;
97 }
98
99 }
100