Skip to content

Commit dc3ef34

Browse files
authored
Merge pull request #437 from codepress/release/7.0.5
Release 7.0.5
2 parents 39b5c3a + ede0654 commit dc3ef34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+304
-491
lines changed

api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ function ac_get_list_screen(string $id): ?ListScreen
5353
* For usage @see https://docs.admincolumns.com/article/57-code-snippets
5454
*/
5555
if ( ! function_exists('ac_get_list_screens')) {
56-
function ac_get_list_screens(string $key): ListScreenCollection
56+
function ac_get_list_screens(string $table_id): ListScreenCollection
5757
{
5858
if ( ! did_action('wp_loaded')) {
5959
throw new RuntimeException("Call after the `wp_loaded` hook.");
6060
}
6161

6262
return Container::get_storage()->find_all_by_table_id(
63-
new TableId($key)
63+
new TableId($table_id)
6464
);
6565
}
6666
}

classes/Admin/Admin.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AC\Admin;
44

5+
use AC;
56
use AC\AdminColumns;
67
use AC\Registerable;
78

@@ -10,11 +11,11 @@ class Admin implements Registerable
1011

1112
public const NAME = 'codepress-admin-columns';
1213

13-
private $request_handler;
14+
private RequestHandlerInterface $request_handler;
1415

15-
private $location;
16+
private AC\Asset\Location $location;
1617

17-
private $scripts;
18+
private AdminScripts $scripts;
1819

1920
public function __construct(RequestHandlerInterface $request_handler, AdminColumns $plugin, AdminScripts $scripts)
2021
{

classes/Admin/Asset/Columns.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function get_pro_modal_arguments(): array
122122

123123
foreach ($items as $utm_content => $label) {
124124
$features[] = [
125-
'url' => $upgrade_page_url->add_content('usp-' . $utm_content)->get_url(),
125+
'url' => $upgrade_page_url->with_content('usp-' . $utm_content)->get_url(),
126126
'label' => $label,
127127
];
128128
}

classes/Column/ColumnFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function get_settings(Config $config): ComponentCollection
2323

2424
protected function get_context(Config $config): Context
2525
{
26-
return new Context($config);
26+
return new Context($config, $this->get_label());
2727
}
2828

2929
protected function get_formatters(Config $config): FormatterCollection

classes/Column/Context.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ class Context implements AC\Setting\Context
1212

1313
protected Config $config;
1414

15-
public function __construct(Config $config)
15+
private string $label;
16+
17+
public function __construct(Config $config, string $label)
1618
{
1719
$this->config = $config;
20+
$this->label = $label;
1821
}
1922

2023
public function get_type(): string
@@ -27,6 +30,16 @@ public function get_name(): string
2730
return $this->get('name', '');
2831
}
2932

33+
public function get_label(): string
34+
{
35+
return $this->get('label', '');
36+
}
37+
38+
public function get_type_label(): string
39+
{
40+
return $this->label;
41+
}
42+
3043
public function has(string $key): bool
3144
{
3245
return $this->config->has($key);

classes/Column/CustomFieldContext.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace AC\Column;
66

77
use AC\Setting\Config;
8+
use AC\Type\TableScreenContext;
89

910
class CustomFieldContext extends Context
1011
{
@@ -13,12 +14,20 @@ class CustomFieldContext extends Context
1314

1415
private string $meta_key;
1516

16-
public function __construct(Config $config, string $field_type, string $meta_key)
17-
{
18-
parent::__construct($config);
17+
private TableScreenContext $table;
18+
19+
public function __construct(
20+
Config $config,
21+
string $label,
22+
string $field_type,
23+
string $meta_key,
24+
TableScreenContext $table
25+
) {
26+
parent::__construct($config, $label);
1927

2028
$this->field_type = $field_type;
2129
$this->meta_key = $meta_key;
30+
$this->table = $table;
2231
}
2332

2433
public function get_field_type(): string
@@ -31,4 +40,23 @@ public function get_meta_key(): string
3140
return $this->meta_key;
3241
}
3342

43+
public function get_meta_type(): string
44+
{
45+
return (string)$this->table->get_meta_type();
46+
}
47+
48+
public function get_post_type(): ?string
49+
{
50+
return $this->table->has_post_type()
51+
? (string)$this->table->get_post_type()
52+
: null;
53+
}
54+
55+
public function get_taxonomy(): ?string
56+
{
57+
return $this->table->has_taxonomy()
58+
? (string)$this->table->get_taxonomy()
59+
: null;
60+
}
61+
3462
}

classes/ColumnFactories/BaseFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function create(TableScreen $table_screen): ColumnFactories
3939
];
4040

4141
if ($table_screen instanceof TableScreen\MetaType) {
42-
$defaults['table_screen_context'] = TableScreenContext::from_table_screen($table_screen);
42+
$defaults['table_context'] = TableScreenContext::from_table_screen($table_screen);
4343
}
4444

4545
foreach ($factories as $factory) {

classes/ColumnFactories/PostFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function get_factories(TableScreen $table_screen): ColumnFactoryDefini
3333
new ColumnFactoryDefinition(
3434
AC\ColumnFactory\CustomFieldFactory::class,
3535
[
36-
'table_screen_context' => $table_screen_context,
36+
'table_context' => $table_screen_context,
3737
]
3838
)
3939
);

classes/ColumnFactory/CustomFieldFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CustomFieldFactory extends BaseColumnFactory
2222

2323
private FieldType $field_type;
2424

25-
private TableScreenContext $table_screen_context;
25+
private TableScreenContext $table_context;
2626

2727
private ComponentFactory\BeforeAfter $before_after;
2828

@@ -31,7 +31,7 @@ class CustomFieldFactory extends BaseColumnFactory
3131
public function __construct(
3232
DefaultSettingsBuilder $default_settings_builder,
3333
ComponentFactory\CustomFieldFactory $custom_field_factory,
34-
TableScreenContext $table_screen_context,
34+
TableScreenContext $table_context,
3535
FieldType $field_type,
3636
ComponentFactory\BeforeAfter $before_after,
3737
ComponentFactory\Pro\TogglePromotionFactory $pro_promotion_factory
@@ -42,15 +42,15 @@ public function __construct(
4242

4343
$this->custom_field_factory = $custom_field_factory;
4444
$this->field_type = $field_type;
45-
$this->table_screen_context = $table_screen_context;
45+
$this->table_context = $table_context;
4646
$this->before_after = $before_after;
4747
$this->pro_promotion_factory = $pro_promotion_factory;
4848
}
4949

5050
protected function get_settings(Config $config): ComponentCollection
5151
{
5252
return new ComponentCollection([
53-
$this->custom_field_factory->create($this->table_screen_context)->create($config),
53+
$this->custom_field_factory->create($this->table_context)->create($config),
5454
$this->field_type->create($config),
5555
$this->before_after->create($config),
5656
$this->pro_promotion_factory->create(__('Enable Editing', 'codepress-admin-columns'))->create($config),
@@ -80,15 +80,15 @@ protected function get_formatters(Config $config): FormatterCollection
8080
return $formatters->prepend(
8181
Aggregate::from_array([
8282
new AC\Formatter\MetaCollection(
83-
$this->table_screen_context->get_meta_type(), $config->get('field', '')
83+
$this->table_context->get_meta_type(), $config->get('field', '')
8484
),
8585
new AC\Formatter\Count(),
8686
])
8787
);
8888
}
8989

9090
return $formatters->prepend(
91-
new AC\Formatter\Meta($this->table_screen_context->get_meta_type(), $config->get('field', ''))
91+
new AC\Formatter\Meta($this->table_context->get_meta_type(), $config->get('field', ''))
9292
);
9393
}
9494

classes/ColumnFactory/Media/FileSizeFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace AC\ColumnFactory\Media;
66

77
use AC\Column\BaseColumnFactory;
8+
use AC\Formatter\FileSizeReadable;
89
use AC\Formatter\Media\FileSize;
9-
use AC\Formatter\ReadableFileSize;
1010
use AC\FormatterCollection;
1111
use AC\Setting\Config;
1212

@@ -28,7 +28,7 @@ protected function get_formatters(Config $config): FormatterCollection
2828
$formatters = parent::get_formatters($config);
2929

3030
$formatters->add(new FileSize());
31-
$formatters->add(new ReadableFileSize());
31+
$formatters->add(new FileSizeReadable());
3232

3333
return $formatters;
3434
}

0 commit comments

Comments
 (0)