254fa1fa by Jeremy Groot

plugin updates

1 parent 3305b4e1
Showing 1000 changed files with 1541 additions and 434 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 .editable-container .acf-editable-range input[type=range]{width:150px;display:inline-block;vertical-align:middle;margin-right:10px}.editable-container .acf-editable-range input[type=text]{width:50px;display:inline-block}.aceditable.-acf_range input[type=range]{width:200px;height:30px;background:none;margin-right:5px}.aceditable.-acf_range input[name=reflection]{width:60px}.ac-modal.-bulkedit .aceditable.-acf_range input[type=range]{width:100%}.ac-repeater-divider{display:block;border-bottom:1px dotted #ccc;clear:both;margin-bottom:3px}.ac-repeater-divider:before{content:"";display:block;clear:both;float:none;height:3px} 1 body.acf-admin-field-groups .tablenav.top{display:block}body.acf-admin-field-groups .tablenav.top .bulkactions{display:none}body.acf-admin-field-groups .tablenav.top .query-builder .ac-button-group button.ac-button__add-filter{border-top-left-radius:3px;border-bottom-left-radius:3px}body.acf-admin-field-groups .tablenav.top .query-builder .ac-button-group button.ac-button__segments{border-top-right-radius:3px;border-bottom-right-radius:3px}body.acf-admin-field-groups .tablenav.top .ac-search .button{height:25px}body.acf-admin-field-groups .tablenav.top .acp-nav-tab-wrapper{margin-top:0}body.acf-admin-field-groups .tablenav.top .query-builder .ac-button-group button.ac-button__segments:before{transform:none}body.acf-admin-field-groups .tablenav.top #post-query-submit{height:25px;border-radius:3px}body.acf-admin-field-groups .tablenav.top .alignleft.actions select{height:25px;border-radius:3px}.editable-container .acf-editable-range input[type=range]{width:150px;display:inline-block;vertical-align:middle;margin-right:10px}.editable-container .acf-editable-range input[type=text]{width:50px;display:inline-block}.aceditable.-acf_range input[type=range]{width:200px;height:30px;background:none;margin-right:5px}.aceditable.-acf_range input[name=reflection]{width:60px}.ac-modal.-bulkedit .aceditable.-acf_range input[type=range]{width:100%}.ac-repeater-divider{display:block;border-bottom:1px dotted #ccc;clear:both;margin-bottom:3px}.ac-repeater-divider:before{content:"";display:block;clear:both;float:none;height:3px}
......
...@@ -7,12 +7,10 @@ use AC\Registerable; ...@@ -7,12 +7,10 @@ use AC\Registerable;
7 use AC\Request; 7 use AC\Request;
8 use ACA\ACF\ConditionalFormatting\FieldFormattableFactory; 8 use ACA\ACF\ConditionalFormatting\FieldFormattableFactory;
9 use ACA\ACF\FieldGroup; 9 use ACA\ACF\FieldGroup;
10 use ACA\ACF\ListScreenFactory\FieldGroupFactory;
10 use ACA\ACF\RequestHandler\MapLegacyListScreen; 11 use ACA\ACF\RequestHandler\MapLegacyListScreen;
11 use ACA\ACF\Search; 12 use ACA\ACF\Search;
12 use ACA\ACF\Service\AddColumns; 13 use ACA\ACF\Service;
13 use ACA\ACF\Service\ColumnSettings;
14 use ACA\ACF\Service\InitColumn;
15 use ACA\ACF\Service\Scripts;
16 use ACA\ACF\Sorting; 14 use ACA\ACF\Sorting;
17 use ACP; 15 use ACP;
18 use ACP\RequestHandlerFactory; 16 use ACP\RequestHandlerFactory;
...@@ -31,6 +29,8 @@ final class AdvancedCustomFields implements Registerable { ...@@ -31,6 +29,8 @@ final class AdvancedCustomFields implements Registerable {
31 return; 29 return;
32 } 30 }
33 31
32 AC\ListScreenFactory::add( new FieldGroupFactory() );
33
34 $column_initiator = new ColumnInstantiator( 34 $column_initiator = new ColumnInstantiator(
35 new ConfigFactory( new FieldFactory() ), 35 new ConfigFactory( new FieldFactory() ),
36 new Search\ComparisonFactory(), 36 new Search\ComparisonFactory(),
...@@ -46,21 +46,22 @@ final class AdvancedCustomFields implements Registerable { ...@@ -46,21 +46,22 @@ final class AdvancedCustomFields implements Registerable {
46 $services = [ 46 $services = [
47 new ACP\Service\IntegrationStatus( 'ac-addon-acf' ), 47 new ACP\Service\IntegrationStatus( 'ac-addon-acf' ),
48 new ColumnGroup(), 48 new ColumnGroup(),
49 new Service\ColumnSettings(),
49 new Service\EditingFix(), 50 new Service\EditingFix(),
50 new Service\LegacyColumnMapper(), 51 new Service\LegacyColumnMapper(),
52 new Service\ListScreens(),
51 new Service\RemoveDeprecatedColumnFromTypeSelector(), 53 new Service\RemoveDeprecatedColumnFromTypeSelector(),
52 new AddColumns( 54 new Service\AddColumns(
53 new FieldRepository( new FieldGroup\QueryFactory() ), 55 new FieldRepository( new FieldGroup\QueryFactory() ),
54 new FieldsFactory(), 56 new FieldsFactory(),
55 new ColumnFactory( $column_initiator ) 57 new ColumnFactory( $column_initiator )
56 ), 58 ),
57 new Scripts( $this->location ), 59 new Service\Scripts( $this->location ),
58 new InitColumn( $column_initiator ), 60 new Service\InitColumn( $column_initiator ),
59 new ColumnSettings(),
60 new RequestParser( $request_handler_factory ), 61 new RequestParser( $request_handler_factory ),
61 ]; 62 ];
62 63
63 array_map( function ( Registerable $service ) { 64 array_map( static function ( Registerable $service ) {
64 $service->register(); 65 $service->register();
65 }, $services ); 66 }, $services );
66 } 67 }
......
1 <?php
2
3 namespace ACA\ACF\Column\FieldGroup;
4
5 use AC;
6 use ACA\ACF\Search;
7 use ACP\Search\Searchable;
8
9 class Location extends AC\Column implements Searchable {
10
11 public function __construct() {
12 $this
13 ->set_type( 'acf-location' )
14 ->set_original( true );
15 }
16
17 public function search() {
18 return new Search\Comparison\FieldGroup\Location();
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -13,7 +13,7 @@ class ColumnGroup implements AC\Registerable { ...@@ -13,7 +13,7 @@ class ColumnGroup implements AC\Registerable {
13 } 13 }
14 14
15 public function register_column_groups( AC\Groups $groups ) { 15 public function register_column_groups( AC\Groups $groups ) {
16 $groups->register_group( self::SLUG, 'Advanced Custom Fields', 11 ); 16 $groups->add( self::SLUG, 'Advanced Custom Fields', 11 );
17 } 17 }
18 18
19 } 19 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -20,6 +20,7 @@ class ModelFactory { ...@@ -20,6 +20,7 @@ class ModelFactory {
20 case FieldType::TYPE_RADIO: 20 case FieldType::TYPE_RADIO:
21 case FieldType::TYPE_CHECKBOX: 21 case FieldType::TYPE_CHECKBOX:
22 case FieldType::TYPE_POST: 22 case FieldType::TYPE_POST:
23 case FieldType::TYPE_GOOGLE_MAP:
23 case FieldType::TYPE_RELATIONSHIP: 24 case FieldType::TYPE_RELATIONSHIP:
24 case FieldType::TYPE_USER: 25 case FieldType::TYPE_USER:
25 case FieldType::TYPE_TAXONOMY: 26 case FieldType::TYPE_TAXONOMY:
......
1 <?php
2
3 namespace ACA\ACF\ListScreen;
4
5 use ACA\ACF;
6 use ACP;
7 use ACP\Column;
8
9 class FieldGroup extends ACP\ListScreen\Post {
10
11 public function __construct() {
12 parent::__construct( 'acf-field-group' );
13
14 $this->set_group( 'acf' );
15 }
16
17 protected function register_column_types() {
18 $this->register_column_types_from_list( [
19 Column\CustomField::class,
20 Column\Actions::class,
21 Column\Post\Author::class,
22 Column\Post\Content::class,
23 Column\Post\DatePublished::class,
24 Column\Post\ID::class,
25 Column\Post\Modified::class,
26 Column\Post\Status::class,
27 Column\Post\Title::class,
28 Column\Post\TitleRaw::class,
29 ACF\Column\FieldGroup\Location::class,
30 ] );
31 }
32
33 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\ACF\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\ACF\ListScreen\FieldGroup;
9 use LogicException;
10 use WP_Screen;
11
12 class FieldGroupFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'acf-field-group' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new FieldGroup(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'acf-field-group';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new FieldGroup(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\ACF\Search\Comparison\FieldGroup;
4
5 use AC\Helper\Select\Options;
6 use ACP\Search\Comparison;
7 use ACP\Search\Operators;
8 use ACP\Search\Query\Bindings;
9 use ACP\Search\Value;
10
11 class Location extends Comparison implements Comparison\Values {
12
13 public function __construct() {
14 $operators = new Operators( [
15 Operators::EQ,
16 ] );
17
18 parent::__construct( $operators );
19 }
20
21 protected function create_query_bindings( $operator, Value $value ) {
22 global $wpdb;
23 $binding = new Bindings();
24
25 $groups = acf_get_field_groups( [ $value->get_value() => true ] );
26 $ids = is_array( $groups ) ? wp_list_pluck( $groups, 'ID' ) : [];
27
28 if ( empty( $ids ) ) {
29 $ids = [ 0 ];
30 }
31
32 $binding->where( sprintf( $wpdb->posts . '.ID IN (%s)', implode( ',', $ids ) ) );
33
34 return $binding;
35
36 }
37
38 public function get_values() {
39 return Options::create_from_array( [
40 'block' => _x( 'Block', 'ACF location', 'codepress-admin-columns' ),
41 'user_form' => _x( 'Users', 'ACF location', 'codepress-admin-columns' ),
42 'taxonomy' => __( 'Taxonomy' ),
43 'comment' => __( 'Comment' ),
44 'post_type' => _x( 'Post Type', 'ACF location', 'codepress-admin-columns' ),
45 'widget' => _x( 'Widget', 'ACF location', 'codepress-admin-columns' ),
46 'options_page' => _x( 'Option Page', 'ACF location', 'codepress-admin-columns' ),
47 'nav_menu' => _x( 'Menu', 'ACF location', 'codepress-admin-columns' ),
48 ] );
49 }
50
51 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\ACF\Service;
4
5 use AC\Column;
6 use AC\Groups;
7 use AC\Registerable;
8 use ACA\ACF\ListScreen;
9
10 class ListScreens implements Registerable {
11
12 public function register() {
13 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_groups' ] );
14 add_filter( 'ac/export/value', [ $this, 'strip_tags_export_value' ], 10, 2 );
15 }
16
17 public function strip_tags_export_value( string $value, Column $column ) {
18 if ( $column->get_list_screen() instanceof ListScreen\FieldGroup && $column->is_original() ) {
19 $value = strip_tags( $value );
20 }
21
22 return $value;
23 }
24
25 public function register_list_screen_groups( Groups $groups ): void {
26 $groups->add( 'acf', __( 'Advanced Custom Fields', 'codepress-admin-columns' ), 7 );
27 }
28
29 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\BbPress\ListScreen;
4
5 use ACA\BbPress\Column;
6 use ACP;
7
8 class Forum extends ACP\ListScreen\Post {
9
10 public function __construct() {
11 parent::__construct( 'forum' );
12
13 $this->set_group( 'bbpress' );
14 }
15
16 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\BbPress\ListScreen;
4
5 use ACA\BbPress\Column;
6 use ACP;
7
8 class Reply extends ACP\ListScreen\Post {
9
10 public function __construct() {
11 parent::__construct( 'reply' );
12
13 $this->set_group( 'bbpress' );
14 }
15
16 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\BbPress\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\BbPress\ListScreen\Topic;
9 use LogicException;
10 use WP_Screen;
11
12 class TopicFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'topic' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new Topic(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'topic';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new Topic(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -16,7 +16,7 @@ class Columns implements Registerable { ...@@ -16,7 +16,7 @@ class Columns implements Registerable {
16 * @param AC\Groups $groups 16 * @param AC\Groups $groups
17 */ 17 */
18 public function register_column_group( AC\Groups $groups ) { 18 public function register_column_group( AC\Groups $groups ) {
19 $groups->register_group( 'bbpress', __( 'bbPress' ), 25 ); 19 $groups->add( 'bbpress', __( 'bbPress' ), 25 );
20 } 20 }
21 21
22 } 22 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
2 2
3 namespace ACA\BbPress\Service; 3 namespace ACA\BbPress\Service;
4 4
5 use AC;
6 use AC\ListScreenTypes;
7 use AC\Registerable; 5 use AC\Registerable;
8 6
9 class Editing implements Registerable { 7 class Editing implements Registerable {
...@@ -12,12 +10,6 @@ class Editing implements Registerable { ...@@ -12,12 +10,6 @@ class Editing implements Registerable {
12 add_filter( 'ac/editing/role_group', [ $this, 'editing_role_group' ], 10, 2 ); 10 add_filter( 'ac/editing/role_group', [ $this, 'editing_role_group' ], 10, 2 );
13 } 11 }
14 12
15 /**
16 * @param $group
17 * @param $role
18 *
19 * @return string
20 */
21 public function editing_role_group( $group, $role ) { 13 public function editing_role_group( $group, $role ) {
22 if ( strpos( $role, "bbp_" ) === 0 ) { 14 if ( strpos( $role, "bbp_" ) === 0 ) {
23 $group = __( 'bbPress', 'codepress-admin-columns' ); 15 $group = __( 'bbPress', 'codepress-admin-columns' );
......
...@@ -3,30 +3,37 @@ ...@@ -3,30 +3,37 @@
3 namespace ACA\BbPress\Service; 3 namespace ACA\BbPress\Service;
4 4
5 use AC; 5 use AC;
6 use AC\ListScreenPost;
6 use AC\Registerable; 7 use AC\Registerable;
7 use ACA\BbPress\ListScreen; 8 use ACA\BbPress\ListScreenFactory\TopicFactory;
8 9
9 class ListScreens implements Registerable { 10 class ListScreens implements Registerable {
10 11
11 public function register() { 12 public function register() {
12 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_group' ] ); 13 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_group' ] );
13 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ], 11 ); 14 add_action( 'ac/admin/menu_group', [ $this, 'update_menu_list_groups' ], 10, 2 );
15
16 AC\ListScreenFactory::add( new TopicFactory() );
14 } 17 }
15 18
16 public function register_list_screen_group( AC\Groups $groups ): void { 19 public function register_list_screen_group( AC\Groups $groups ): void {
17 $groups->register_group( 'bbpress', __( 'bbPress' ), 8 ); 20 $groups->add( 'bbpress', __( 'bbPress' ), 8 );
18 } 21 }
19 22
20 public function register_list_screens(): void { 23 private function get_post_list_keys(): array {
21 $list_screens = [ 24 return [
22 new ListScreen\Topic(), 25 'forum',
23 new ListScreen\Forum(), 26 'reply',
24 new ListScreen\Reply(), 27 'topic',
25 ]; 28 ];
29 }
26 30
27 foreach ( $list_screens as $list_screen ) { 31 public function update_menu_list_groups( string $group, AC\ListScreen $list_screen ): string {
28 AC\ListScreenTypes::instance()->register_list_screen( $list_screen ); 32 if ( $list_screen instanceof ListScreenPost && in_array( $list_screen->get_post_type(), $this->get_post_list_keys(), true ) ) {
33 return 'bbpress';
29 } 34 }
35
36 return $group;
30 } 37 }
31 38
32 } 39 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
2 2
3 namespace ACA\BeaverBuilder; 3 namespace ACA\BeaverBuilder;
4 4
5 use AC;
5 use AC\Registerable; 6 use AC\Registerable;
6 use ACA\BeaverBuilder\Service; 7 use ACA\BeaverBuilder\Service;
7 8
...@@ -12,6 +13,11 @@ class BeaverBuilder implements Registerable { ...@@ -12,6 +13,11 @@ class BeaverBuilder implements Registerable {
12 return; 13 return;
13 } 14 }
14 15
16 AC\ListScreenFactory::add( new ListScreenFactory\Templates() );
17 AC\ListScreenFactory::add( new ListScreenFactory\SavedColumns() );
18 AC\ListScreenFactory::add( new ListScreenFactory\SavedModules() );
19 AC\ListScreenFactory::add( new ListScreenFactory\SavedRows() );
20
15 $services = [ 21 $services = [
16 new Service\ListScreens(), 22 new Service\ListScreens(),
17 new Service\PostTypes(), 23 new Service\PostTypes(),
......
...@@ -6,33 +6,26 @@ use ACP; ...@@ -6,33 +6,26 @@ use ACP;
6 6
7 class Template extends ACP\ListScreen\Post { 7 class Template extends ACP\ListScreen\Post {
8 8
9 /* 9 public const POST_TYPE = 'fl-builder-template';
10 * @var string 10
11 */
12 private $template_page; 11 private $template_page;
13 12
14 /* 13 private $custom_label;
15 * @var string
16 */
17 private $page_label;
18 14
19 public function __construct( $page, $label ) { 15 public function __construct( string $template_page, string $label ) {
20 parent::__construct( 'fl-builder-template' ); 16 parent::__construct( 'fl-builder-template' );
21 17
22 $this->template_page = (string) $page; 18 $this->template_page = $template_page;
23 $this->page_label = (string) $label; 19 $this->custom_label = $label;
24 20
25 $this->set_key( 'fl-builder-template' . $page ) 21 $this->set_key( self::POST_TYPE . $template_page )
26 ->set_group( 'beaver_builder' ) 22 ->set_group( 'beaver_builder' )
23 ->set_label( $label )
27 ->set_screen_id( $this->get_screen_base() . '-fl-builder-template' ); 24 ->set_screen_id( $this->get_screen_base() . '-fl-builder-template' );
28 } 25 }
29 26
30 public function is_current_screen( $wp_screen ) {
31 return parent::is_current_screen( $wp_screen ) && filter_input( INPUT_GET, 'fl-builder-template-type' ) === $this->template_page;
32 }
33
34 public function get_label() { 27 public function get_label() {
35 return $this->page_label; 28 return $this->custom_label;
36 } 29 }
37 30
38 public function get_screen_link() { 31 public function get_screen_link() {
......
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\BeaverBuilder;
5
6 use AC\ListScreen;
7 use AC\ListScreenFactory\ListSettingsTrait;
8 use AC\ListScreenFactoryInterface;
9 use ACA\BeaverBuilder\ListScreen\Template;
10 use LogicException;
11 use WP_Screen;
12
13 abstract class ListScreenFactory implements ListScreenFactoryInterface {
14
15 use ListSettingsTrait;
16
17 private function create_list_screen(): Template {
18 return new Template( $this->get_page(), $this->get_label() );
19 }
20
21 abstract protected function get_label(): string;
22
23 abstract protected function get_page(): string;
24
25 public function can_create( string $key ): bool {
26 return $key === Template::POST_TYPE . $this->get_page() && post_type_exists( Template::POST_TYPE );
27 }
28
29 public function create( string $key, array $settings = [] ): ListScreen {
30 if ( ! $this->can_create( $key ) ) {
31 throw new LogicException( 'Invalid key' );
32 }
33
34 return $this->add_settings( $this->create_list_screen(), $settings );
35 }
36
37 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
38 return 'edit' === $screen->base
39 && $screen->post_type
40 && 'edit-' . $screen->post_type === $screen->id
41 && $this->get_page() === filter_input( INPUT_GET, 'fl-builder-template-type' );
42 }
43
44 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
45 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
46 throw new LogicException( 'Invalid screen' );
47 }
48
49 return $this->add_settings( $this->create_list_screen(), $settings );
50 }
51
52 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\BeaverBuilder\ListScreenFactory;
5
6 use ACA\BeaverBuilder\ListScreenFactory;
7
8 class SavedColumns extends ListScreenFactory {
9
10 protected function get_label(): string {
11 return __( 'Saved Columns', 'fl-builder' );
12 }
13
14 protected function get_page(): string {
15 return 'column';
16 }
17
18 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\BeaverBuilder\ListScreenFactory;
5
6 use ACA\BeaverBuilder\ListScreenFactory;
7
8 class SavedModules extends ListScreenFactory {
9
10 protected function get_label(): string {
11 return __( 'Saved Modules', 'fl-builder' );
12 }
13
14 protected function get_page(): string {
15 return 'module';
16 }
17
18 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\BeaverBuilder\ListScreenFactory;
5
6 use ACA\BeaverBuilder\ListScreenFactory;
7
8 class SavedRows extends ListScreenFactory {
9
10 protected function get_label(): string {
11 return __( 'Saved Rows', 'fl-builder' );
12 }
13
14 protected function get_page(): string {
15 return 'row';
16 }
17
18 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\BeaverBuilder\ListScreenFactory;
5
6 use ACA\BeaverBuilder\ListScreenFactory;
7
8 class Templates extends ListScreenFactory {
9
10 protected function get_label(): string {
11 return __( 'Templates', 'fl-builder' );
12 }
13
14 protected function get_page(): string {
15 return 'layout';
16 }
17
18 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -2,37 +2,53 @@ ...@@ -2,37 +2,53 @@
2 2
3 namespace ACA\BeaverBuilder\Service; 3 namespace ACA\BeaverBuilder\Service;
4 4
5 use AC;
6 use AC\Groups; 5 use AC\Groups;
6 use AC\ListScreen;
7 use AC\Registerable; 7 use AC\Registerable;
8 use ACA\BeaverBuilder\ListScreen; 8 use AC\Table\ListKeyCollection;
9 use AC\Type\ListKey;
10 use ACA\BeaverBuilder\ListScreen\Template;
11 use ACP\ListScreen\Taxonomy;
9 12
10 class ListScreens implements Registerable { 13 class ListScreens implements Registerable {
11 14
12 public function register(): void { 15 public function register(): void {
13 add_action( 'ac/list_screen_groups', [ $this, 'register_beaver_builder_group' ] ); 16 add_action( 'ac/list_screen_groups', [ $this, 'register_beaver_builder_group' ] );
14 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ] ); 17 add_filter( 'ac/admin/menu_group', [ $this, 'update_menu_list_groups' ], 10, 2 );
18 add_action( 'ac/list_keys', [ $this, 'add_list_keys' ] );
15 } 19 }
16 20
17 public function register_beaver_builder_group( Groups $groups ): void { 21 public function add_list_keys( ListKeyCollection $list_keys ): void {
18 $groups->register_group( 'beaver_builder', __( 'Beaver Builder', 'codepress-admin-columns' ), 6 ); 22 $templates = [
23 'column',
24 'module',
25 'row',
26 'layout',
27 ];
28
29 foreach ( $templates as $template ) {
30 $list_keys->add( new ListKey( Template::POST_TYPE . $template ) );
31 }
19 } 32 }
20 33
21 public function register_list_screens( AC\ListScreens $list_screens ): void { 34 public function register_beaver_builder_group( Groups $groups ): void {
22 if ( ! post_type_exists( PostTypes::POST_TYPE_TEMPLATE ) ) { 35 $groups->add( 'beaver_builder', __( 'Beaver Builder', 'codepress-admin-columns' ), 6 );
23 return;
24 } 36 }
25 37
26 $bb_list_screens = [ 38 public function update_menu_list_groups( string $group, ListScreen $list_screen ): string {
27 new ListScreen\Template( 'layout', __( 'Templates', 'fl-builder' ) ), 39 $keys = [
28 new ListScreen\Template( 'row', __( 'Saved Rows', 'fl-builder' ) ), 40 Template::POST_TYPE . 'column',
29 new ListScreen\Template( 'column', __( 'Saved Columns', 'fl-builder' ) ), 41 Template::POST_TYPE . 'module',
30 new ListScreen\Template( 'module', __( 'Saved Modules', 'fl-builder' ) ), 42 Template::POST_TYPE . 'row',
43 Template::POST_TYPE . 'layout',
44 Taxonomy::KEY_PREFIX . 'fl-builder-template-category',
31 ]; 45 ];
32 46
33 foreach ( $bb_list_screens as $list_screen ) { 47 if ( in_array( $list_screen->get_key(), $keys, true ) ) {
34 $list_screens->register_list_screen( $list_screen ); 48 $group = 'beaver_builder';
35 } 49 }
50
51 return $group;
36 } 52 }
37 53
38 } 54 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,6 +4,7 @@ namespace ACA\BP; ...@@ -4,6 +4,7 @@ namespace ACA\BP;
4 4
5 use AC; 5 use AC;
6 use AC\Registerable; 6 use AC\Registerable;
7 use ACA\BP\ListScreenFactory;
7 use ACA\BP\Service; 8 use ACA\BP\Service;
8 use ACP\Service\IntegrationStatus; 9 use ACP\Service\IntegrationStatus;
9 10
...@@ -29,6 +30,9 @@ final class BuddyPress implements Registerable { ...@@ -29,6 +30,9 @@ final class BuddyPress implements Registerable {
29 ]; 30 ];
30 31
31 array_map( [ $this, 'register_service' ], $services ); 32 array_map( [ $this, 'register_service' ], $services );
33
34 AC\ListScreenFactory::add( new ListScreenFactory\Email() );
35 AC\ListScreenFactory::add( new ListScreenFactory\Group() );
32 } 36 }
33 37
34 private function register_service( $service ) { 38 private function register_service( $service ) {
......
...@@ -7,24 +7,15 @@ use ACP; ...@@ -7,24 +7,15 @@ use ACP;
7 7
8 class Group implements ACP\Editing\Strategy { 8 class Group implements ACP\Editing\Strategy {
9 9
10 /** 10 public function user_can_edit_item( int $id ): bool {
11 * @param int|object $entry_id 11 return current_user_can( 'bp_moderate', $id );
12 *
13 * @return bool|int
14 */
15 public function user_can_edit_item( $entry_id ) {
16 if ( is_object( $entry_id ) ) {
17 $entry_id = $entry_id->id;
18 } 12 }
19 13
20 return current_user_can( 'bp_moderate', $entry_id ); 14 public function user_can_edit(): bool {
21 }
22
23 public function user_can_edit() {
24 return current_user_can( 'bp_moderate' ); 15 return current_user_can( 'bp_moderate' );
25 } 16 }
26 17
27 public function get_query_request_handler() { 18 public function get_query_request_handler(): ACP\Editing\RequestHandler {
28 return new RequestHandler\Query\Groups(); 19 return new RequestHandler\Query\Groups();
29 } 20 }
30 21
......
...@@ -49,10 +49,6 @@ class Group extends AC\ListScreenWP ...@@ -49,10 +49,6 @@ class Group extends AC\ListScreenWP
49 add_action( 'bp_groups_admin_get_group_custom_column', [ $this, 'manage_value' ], 100, 3 ); 49 add_action( 'bp_groups_admin_get_group_custom_column', [ $this, 'manage_value' ], 100, 3 );
50 } 50 }
51 51
52 public function is_current_screen( $wp_screen ) {
53 return $wp_screen && $wp_screen->id === $this->get_screen_id() && 'edit' !== filter_input( INPUT_GET, 'action' );
54 }
55
56 public function get_screen_link() { 52 public function get_screen_link() {
57 return add_query_arg( [ 'page' => $this->get_page(), 'layout' => $this->get_layout_id() ], $this->get_admin_url() ); 53 return add_query_arg( [ 'page' => $this->get_page(), 'layout' => $this->get_layout_id() ], $this->get_admin_url() );
58 } 54 }
......
1 <?php
2
3 namespace ACA\BP\ListScreenFactory;
4
5 use AC;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\BP\ListScreen;
9 use LogicException;
10 use WP_Screen;
11
12 class Email implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'bp-email' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): AC\ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new ListScreen\Email(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'bp-email';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): AC\ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new ListScreen\Email(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\BP\ListScreenFactory;
4
5 use AC;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\BP\ListScreen;
9 use LogicException;
10 use WP_Screen;
11
12 class Group implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'bp-groups' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): AC\ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new ListScreen\Group(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->id === 'toplevel_page_bp-groups' && 'edit' !== filter_input( INPUT_GET, 'action' );
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): AC\ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new ListScreen\Group(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -44,7 +44,7 @@ class Columns implements Registerable { ...@@ -44,7 +44,7 @@ class Columns implements Registerable {
44 * @param AC\Groups $groups 44 * @param AC\Groups $groups
45 */ 45 */
46 public function register_column_groups( AC\Groups $groups ) { 46 public function register_column_groups( AC\Groups $groups ) {
47 $groups->register_group( 'buddypress', 'BuddyPress', 11 ); 47 $groups->add( 'buddypress', 'BuddyPress', 11 );
48 } 48 }
49 49
50 } 50 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,28 +4,37 @@ namespace ACA\BP\Service; ...@@ -4,28 +4,37 @@ namespace ACA\BP\Service;
4 4
5 use AC; 5 use AC;
6 use AC\Registerable; 6 use AC\Registerable;
7 use ACA\BP\ListScreen; 7 use AC\Table\ListKeyCollection;
8 use AC\Type\ListKey;
8 9
9 final class ListScreens implements Registerable { 10 final class ListScreens implements Registerable {
10 11
11 public function register() { 12 public function register() {
12 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_group' ] ); 13 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_group' ] );
13 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ] ); 14 add_filter( 'ac/admin/menu_group', [ $this, 'update_menu_list_groups' ], 10, 2 );
15 add_action( 'ac/list_keys', [ $this, 'add_list_keys' ] );
14 } 16 }
15 17
16 /** 18 public function add_list_keys( ListKeyCollection $list_keys ): void {
17 * @param AC\AdminColumns $admin_columns 19 if ( bp_is_active( 'groups' ) ) {
18 */ 20 $list_keys->add( new ListKey( 'bp-groups' ) );
19 public function register_list_screens( AC\ListScreens $list_screens ) { 21 }
20 $list_screens->register_list_screen( new ListScreen\Email() ) 22 }
21 ->register_list_screen( new ListScreen\Group() ); 23
24 public function register_list_screen_group( AC\Groups $groups ): void {
25 $groups->add( 'buddypress', __( 'BuddyPress' ), 14 );
26 }
27
28 public function update_menu_list_groups( string $group, AC\ListScreen $list_screen ): string {
29 $keys = [
30 'bp-email',
31 ];
32
33 if ( in_array( $list_screen->get_key(), $keys, true ) ) {
34 return 'buddypress';
22 } 35 }
23 36
24 /** 37 return $group;
25 * @param AC\Groups $groups
26 */
27 public function register_list_screen_group( AC\Groups $groups ) {
28 $groups->register_group( 'buddypress', __( 'BuddyPress' ), 14 );
29 } 38 }
30 39
31 } 40 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -27,7 +27,7 @@ final class EventsCalendar implements Registerable { ...@@ -27,7 +27,7 @@ final class EventsCalendar implements Registerable {
27 new Service\Scripts( $this->location ), 27 new Service\Scripts( $this->location ),
28 new Service\TableScreen( $this->location ), 28 new Service\TableScreen( $this->location ),
29 new ImportListscreens\Message( new ImportListscreens\ImportedSetting() ), 29 new ImportListscreens\Message( new ImportListscreens\ImportedSetting() ),
30 new ImportListscreens\Controller( new AC\Request(), AC()->get_storage(), new DecoderFactory( AC\ListScreenTypes::instance() ), $this->location ), 30 new ImportListscreens\Controller( new AC\Request(), AC()->get_storage(), new DecoderFactory( new AC\ListScreenFactory() ), $this->location ),
31 new IntegrationStatus( 'ac-addon-events-calendar' ), 31 new IntegrationStatus( 'ac-addon-events-calendar' ),
32 ]; 32 ];
33 33
......
1 <?php
2
3 namespace ACA\EC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\EC\ListScreen\Event;
9 use LogicException;
10 use WP_Screen;
11
12 class EventFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'tribe_events' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new Event(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'tribe_events';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new Event(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\EC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\EC\ListScreen\EventSeries;
9 use LogicException;
10 use WP_Screen;
11
12 class EventSeriesFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'tribe_event_series' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new EventSeries(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'tribe_event_series';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new EventSeries(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\EC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\EC\ListScreen\Organizer;
9 use LogicException;
10 use WP_Screen;
11
12 class OrganizerFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'tribe_organizer' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new Organizer(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'tribe_organizer';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new Organizer(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\EC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\EC\ListScreen\Venue;
9 use LogicException;
10 use WP_Screen;
11
12 class VenueFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'tribe_venue' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new Venue(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'tribe_venue';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new Venue(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
3 namespace ACA\EC\Service; 3 namespace ACA\EC\Service;
4 4
5 use AC; 5 use AC;
6 use AC\Groups;
6 use AC\Registerable; 7 use AC\Registerable;
7 8
8 final class ColumnGroups implements Registerable { 9 final class ColumnGroups implements Registerable {
...@@ -14,12 +15,9 @@ final class ColumnGroups implements Registerable { ...@@ -14,12 +15,9 @@ final class ColumnGroups implements Registerable {
14 add_action( 'ac/column_groups', [ $this, 'register_column_groups' ] ); 15 add_action( 'ac/column_groups', [ $this, 'register_column_groups' ] );
15 } 16 }
16 17
17 /** 18 public function register_column_groups( Groups $groups ) {
18 * @param AC\Groups $groups 19 $groups->add( self::EVENTS_CALENDAR, 'The Events Calendar', 11 );
19 */ 20 $groups->add( self::EVENTS_CALENDAR_FIELDS, 'The Events Calendar' . ' - ' . __( 'Additional Fields', 'tribe-events-calendar-pro' ), 11 );
20 public function register_column_groups( $groups ) {
21 $groups->register_group( self::EVENTS_CALENDAR, 'The Events Calendar', 11 );
22 $groups->register_group( self::EVENTS_CALENDAR_FIELDS, 'The Events Calendar' . ' - ' . __( 'Additional Fields', 'tribe-events-calendar-pro' ), 11 );
23 } 21 }
24 22
25 } 23 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,27 +4,44 @@ namespace ACA\EC\Service; ...@@ -4,27 +4,44 @@ namespace ACA\EC\Service;
4 4
5 use AC; 5 use AC;
6 use AC\Registerable; 6 use AC\Registerable;
7 use ACA\EC\ListScreen; 7 use ACA\EC\ListScreenFactory;
8 8
9 final class ListScreens implements Registerable { 9 final class ListScreens implements Registerable {
10 10
11 public function register() { 11 public function register() {
12 AC\ListScreenFactory::add( new ListScreenFactory\EventFactory() );
13 AC\ListScreenFactory::add( new ListScreenFactory\OrganizerFactory() );
14 AC\ListScreenFactory::add( new ListScreenFactory\VenueFactory() );
15
16 if ( post_type_exists( 'tribe_event_series' ) ) {
17 AC\ListScreenFactory::add( new ListScreenFactory\EventSeriesFactory() );
18 }
19
12 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_groups' ] ); 20 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_groups' ] );
13 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ] ); 21 add_filter( 'ac/admin/menu_group', [ $this, 'update_menu_list_groups' ], 10, 2 );
14 } 22 }
15 23
16 public function register_list_screen_groups( AC\Groups $groups ): void { 24 public function register_list_screen_groups( AC\Groups $groups ): void {
17 $groups->register_group( 'events-calendar', 'Events Calendar', 7 ); 25 $groups->add( 'events-calendar', 'Events Calendar', 7 );
18 } 26 }
19 27
20 public function register_list_screens( AC\ListScreens $list_screens ): void { 28 private function get_post_list_keys(): array {
21 $list_screens->register_list_screen( new ListScreen\Event() ) 29 return [
22 ->register_list_screen( new ListScreen\Venue() ) 30 'tribe_organizer',
23 ->register_list_screen( new ListScreen\Organizer() ); 31 'tribe_events',
32 'tribe_event_series',
33 'tribe_venue',
34 ];
35 }
36
37 public function update_menu_list_groups( string $group, AC\ListScreen $list_screen ): string {
38 $keys = $this->get_post_list_keys();
24 39
25 if( post_type_exists( 'tribe_event_series' ) ){ 40 if ( in_array( $list_screen->get_key(), $keys, true ) ) {
26 $list_screens->register_list_screen( new ListScreen\EventSeries() ); 41 return 'events-calendar';
27 } 42 }
43
44 return $group;
28 } 45 }
29 46
30 } 47 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -68,10 +68,7 @@ class TableScreen implements Registerable { ...@@ -68,10 +68,7 @@ class TableScreen implements Registerable {
68 $prefix = 'ac_related_filter_'; 68 $prefix = 'ac_related_filter_';
69 69
70 $input = filter_input_array( INPUT_GET, [ 70 $input = filter_input_array( INPUT_GET, [
71 $prefix . 'post_type' => FILTER_SANITIZE_STRING,
72 $prefix . 'value' => FILTER_SANITIZE_NUMBER_INT, 71 $prefix . 'value' => FILTER_SANITIZE_NUMBER_INT,
73 $prefix . 'date' => FILTER_SANITIZE_STRING,
74 $prefix . 'return_url' => FILTER_SANITIZE_STRING,
75 ] ); 72 ] );
76 73
77 foreach ( $input as $k => $v ) { 74 foreach ( $input as $k => $v ) {
...@@ -81,7 +78,7 @@ class TableScreen implements Registerable { ...@@ -81,7 +78,7 @@ class TableScreen implements Registerable {
81 78
82 $input = (object) $input; 79 $input = (object) $input;
83 80
84 switch ( $input->post_type ) { 81 switch ( $input->post_type ?? '') {
85 case 'tribe_venue': 82 case 'tribe_venue':
86 $this->filter_on_venue( $input->value ); 83 $this->filter_on_venue( $input->value );
87 84
......
...@@ -25,7 +25,7 @@ final class EntryConfigurator implements AC\Registerable { ...@@ -25,7 +25,7 @@ final class EntryConfigurator implements AC\Registerable {
25 add_action( 'ac/list_screen/column_created', [ $this, 'configure_column' ] ); 25 add_action( 'ac/list_screen/column_created', [ $this, 'configure_column' ] );
26 } 26 }
27 27
28 public function configure_column( AC\Column $column ) { 28 public function configure_column( AC\Column $column ): void {
29 if ( ! $column instanceof Column\Entry ) { 29 if ( ! $column instanceof Column\Entry ) {
30 return; 30 return;
31 } 31 }
......
...@@ -4,6 +4,7 @@ namespace ACA\GravityForms\Editing\Strategy; ...@@ -4,6 +4,7 @@ namespace ACA\GravityForms\Editing\Strategy;
4 4
5 use ACA\GravityForms; 5 use ACA\GravityForms;
6 use ACP; 6 use ACP;
7 use ACP\Editing\RequestHandler;
7 use GF_Entry_List_Table; 8 use GF_Entry_List_Table;
8 use GFCommon; 9 use GFCommon;
9 10
...@@ -18,15 +19,15 @@ class Entry implements ACP\Editing\Strategy { ...@@ -18,15 +19,15 @@ class Entry implements ACP\Editing\Strategy {
18 $this->list_table = $list_table; 19 $this->list_table = $list_table;
19 } 20 }
20 21
21 public function user_can_edit() { 22 public function user_can_edit(): bool {
22 return GFCommon::current_user_can_any( GravityForms\Capabilities::EDIT_ENTRIES ); 23 return GFCommon::current_user_can_any( GravityForms\Capabilities::EDIT_ENTRIES );
23 } 24 }
24 25
25 public function user_can_edit_item( $object_id ) { 26 public function user_can_edit_item( int $id ): bool {
26 return $this->user_can_edit(); 27 return $this->user_can_edit();
27 } 28 }
28 29
29 public function get_query_request_handler() { 30 public function get_query_request_handler(): RequestHandler {
30 return new GravityForms\Editing\RequestHandler\Query\Entry( $this->list_table ); 31 return new GravityForms\Editing\RequestHandler\Query\Entry( $this->list_table );
31 } 32 }
32 33
......
...@@ -5,21 +5,19 @@ namespace ACA\GravityForms; ...@@ -5,21 +5,19 @@ namespace ACA\GravityForms;
5 use AC; 5 use AC;
6 use AC\Asset\Script; 6 use AC\Asset\Script;
7 use AC\Asset\Style; 7 use AC\Asset\Style;
8 use AC\DefaultColumnsRepository;
8 use AC\Registerable; 9 use AC\Registerable;
9 use ACA\GravityForms\Column\EntryConfigurator;
10 use ACA\GravityForms\Column\EntryFactory;
11 use ACA\GravityForms\ListScreen; 10 use ACA\GravityForms\ListScreen;
12 use ACA\GravityForms\Search\Query; 11 use ACA\GravityForms\Search\Query;
13 use ACA\GravityForms\TableScreen; 12 use ACA\GravityForms\TableScreen;
14 use ACP\Search\QueryFactory; 13 use ACP\Search\QueryFactory;
15 use ACP\Search\TableScreenFactory; 14 use ACP\Search\TableScreenFactory;
16 use ACP\Service\IntegrationStatus; 15 use ACP\Service\IntegrationStatus;
17 use GFAPI;
18 use GFCommon; 16 use GFCommon;
19 17
20 final class GravityForms implements Registerable { 18 final class GravityForms implements Registerable {
21 19
22 const GROUP = 'gravity_forms'; 20 public const GROUP = 'gravity_forms';
23 21
24 private $location; 22 private $location;
25 23
...@@ -27,9 +25,6 @@ final class GravityForms implements Registerable { ...@@ -27,9 +25,6 @@ final class GravityForms implements Registerable {
27 $this->location = $location; 25 $this->location = $location;
28 } 26 }
29 27
30 /**
31 * Register hooks
32 */
33 public function register() { 28 public function register() {
34 if ( ! class_exists( 'GFCommon', false ) ) { 29 if ( ! class_exists( 'GFCommon', false ) ) {
35 return; 30 return;
...@@ -41,25 +36,22 @@ final class GravityForms implements Registerable { ...@@ -41,25 +36,22 @@ final class GravityForms implements Registerable {
41 return; 36 return;
42 } 37 }
43 38
44 add_action( 'ac/list_screens', [ $this, 'register_list_screen' ] ); 39 AC\ListScreenFactory::add( new ListScreenFactory\EntryFactory() );
45 40
46 // Group labels
47 add_action( 'ac/column_groups', [ $this, 'register_column_group' ] ); 41 add_action( 'ac/column_groups', [ $this, 'register_column_group' ] );
48 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_group' ] );
49
50 add_action( 'ac/admin_scripts', [ $this, 'admin_scripts' ] ); 42 add_action( 'ac/admin_scripts', [ $this, 'admin_scripts' ] );
51 add_action( 'ac/table_scripts', [ $this, 'table_scripts' ] ); 43 add_action( 'ac/table_scripts', [ $this, 'table_scripts' ] );
52
53 add_filter( "gform_noconflict_styles", [ $this, 'allowed_acp_styles' ] ); 44 add_filter( "gform_noconflict_styles", [ $this, 'allowed_acp_styles' ] );
54 add_filter( "gform_noconflict_scripts", [ $this, 'allowed_acp_scripts' ] ); 45 add_filter( "gform_noconflict_scripts", [ $this, 'allowed_acp_scripts' ] );
55 46
56 $services = [ 47 $services = [
57 new TableScreen\Entry(), 48 new Service\ListScreens(),
49 new TableScreen\Entry( new AC\ListScreenFactory(), AC()->get_storage(), new DefaultColumnsRepository() ),
58 new Admin(), 50 new Admin(),
59 new IntegrationStatus( 'ac-addon-gravityforms' ), 51 new IntegrationStatus( 'ac-addon-gravityforms' ),
60 ]; 52 ];
61 53
62 array_map( function ( Registerable $service ) { 54 array_map( static function ( Registerable $service ) {
63 $service->register(); 55 $service->register();
64 }, $services ); 56 }, $services );
65 57
...@@ -68,32 +60,8 @@ final class GravityForms implements Registerable { ...@@ -68,32 +60,8 @@ final class GravityForms implements Registerable {
68 TableScreenFactory::register( ListScreen\Entry::class, Search\TableScreen\Entry::class ); 60 TableScreenFactory::register( ListScreen\Entry::class, Search\TableScreen\Entry::class );
69 } 61 }
70 62
71 public function register_list_screen() { 63 public function register_column_group( AC\Groups $groups ): void {
72 $list_screen_types = AC\ListScreenTypes::instance(); 64 $groups->add( 'gravity_forms', __( 'Gravity Forms', 'codepress-admin-columns' ), 14 );
73
74 if ( ! $list_screen_types ) {
75 return;
76 }
77
78 $forms = array_merge( GFAPI::get_forms(), GFAPI::get_forms( [ 'active' => false ] ) );
79
80 foreach ( $forms as $form ) {
81 $fieldFactory = new FieldFactory();
82 $columnFactory = new EntryFactory( new FieldFactory() );
83
84 $configurator = new EntryConfigurator( (int) $form['id'], $columnFactory, $fieldFactory );
85 $configurator->register();
86
87 $list_screen_types->register_list_screen( new ListScreen\Entry( $form['id'], $configurator ) );
88 }
89 }
90
91 public function register_list_screen_group( AC\Groups $groups ) {
92 $groups->register_group( self::GROUP, __( 'Gravity Forms', 'codepress-admin-columns' ), 8 );
93 }
94
95 public function register_column_group( $groups ) {
96 $groups->register_group( self::GROUP, __( 'Gravity Forms', 'codepress-admin-columns' ), 11 );
97 } 65 }
98 66
99 /** 67 /**
......
...@@ -10,26 +10,18 @@ use ACP\Editing; ...@@ -10,26 +10,18 @@ use ACP\Editing;
10 use ACP\Export; 10 use ACP\Export;
11 use GF_Entry_List_Table; 11 use GF_Entry_List_Table;
12 use GFAPI; 12 use GFAPI;
13 use GFForms;
14 use GFFormsModel;
15 13
16 class Entry extends AC\ListScreenWP implements Editing\ListScreen, Export\ListScreen { 14 class Entry extends AC\ListScreenWP implements Editing\ListScreen, Export\ListScreen {
17 15
18 /**
19 * @var int $form_id
20 */
21 private $form_id; 16 private $form_id;
22 17
23 /**
24 * @var EntryConfigurator
25 */
26 private $column_configurator; 18 private $column_configurator;
27 19
28 public function __construct( $form_id, EntryConfigurator $column_configurator ) { 20 public function __construct( int $form_id, EntryConfigurator $column_configurator ) {
29 $this->form_id = (int) $form_id; 21 $this->form_id = $form_id;
30 $this->column_configurator = $column_configurator; 22 $this->column_configurator = $column_configurator;
31 23
32 $this->set_group( GravityForms\GravityForms::GROUP ) 24 $this->set_group( 'gravity_forms' )
33 ->set_page( 'gf_entries' ) 25 ->set_page( 'gf_entries' )
34 ->set_screen_id( '_page_gf_entries' ) 26 ->set_screen_id( '_page_gf_entries' )
35 ->set_screen_base( '_page_gf_entries' ) 27 ->set_screen_base( '_page_gf_entries' )
...@@ -91,30 +83,6 @@ class Entry extends AC\ListScreenWP implements Editing\ListScreen, Export\ListSc ...@@ -91,30 +83,6 @@ class Entry extends AC\ListScreenWP implements Editing\ListScreen, Export\ListSc
91 return $this->form_id; 83 return $this->form_id;
92 } 84 }
93 85
94 public function is_current_screen( $wp_screen ): bool {
95 return
96 strpos( $wp_screen->id, '_page_gf_entries' ) !== false &&
97 strpos( $wp_screen->base, '_page_gf_entries' ) !== false &&
98 $this->get_current_form_id() === $this->form_id;
99 }
100
101 /**
102 * @return int
103 */
104 private function get_current_form_id() {
105 $form_id = GFForms::get( 'id' );
106
107 if ( ! $form_id ) {
108 $forms = GFFormsModel::get_forms();
109
110 if ( $forms ) {
111 $form_id = $forms[0]->id;
112 }
113 }
114
115 return (int) $form_id;
116 }
117
118 protected function get_admin_url() { 86 protected function get_admin_url() {
119 return admin_url( 'admin.php' ); 87 return admin_url( 'admin.php' );
120 } 88 }
......
1 <?php
2
3 namespace ACA\GravityForms\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\GravityForms;
9 use ACA\GravityForms\Column\EntryConfigurator;
10 use ACA\GravityForms\FieldFactory;
11 use ACA\GravityForms\ListScreen\Entry;
12 use GFForms;
13 use GFFormsModel;
14 use LogicException;
15 use WP_Screen;
16
17 class EntryFactory implements ListScreenFactoryInterface {
18
19 use ListSettingsTrait;
20
21 public function can_create( string $key ): bool {
22 return null !== $this->get_form_id_from_list_key( $key );
23 }
24
25 private function get_form_id_from_list_key( string $key ): ?int {
26 if ( ! ac_helper()->string->starts_with( $key, 'gf_entry_' ) ) {
27 return null;
28 }
29
30 $entry_id = ac_helper()->string->remove_prefix( $key, 'gf_entry_' );
31
32 return is_numeric( $entry_id )
33 ? (int) $entry_id
34 : null;
35 }
36
37 public function create( string $key, array $settings = [] ): ListScreen {
38 if ( ! $this->can_create( $key ) ) {
39 throw new LogicException( 'Invalid key' );
40 }
41
42 $form_id = $this->get_form_id_from_list_key( $key );
43
44 if ( null === $form_id ) {
45 throw new LogicException( 'Invalid form id' );
46 }
47
48 return $this->add_settings(
49 new Entry( $form_id, $this->create_entry_configurator( $form_id ) ),
50 $settings
51 );
52 }
53
54 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
55 return strpos( $screen->id, '_page_gf_entries' ) !== false &&
56 strpos( $screen->base, '_page_gf_entries' ) !== false &&
57 $this->has_form_id();
58 }
59
60 private function has_form_id(): bool {
61 return $this->get_current_form_id() > 0;
62 }
63
64 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
65 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
66 throw new LogicException( 'Invalid screen' );
67 }
68
69 $form_id = $this->get_current_form_id();
70
71 return $this->add_settings(
72 new Entry( $form_id, $this->create_entry_configurator( $form_id ) ),
73 $settings
74 );
75 }
76
77 private function get_current_form_id(): int {
78 $form_id = GFForms::get( 'id' );
79
80 if ( ! $form_id ) {
81 $forms = GFFormsModel::get_forms();
82
83 if ( $forms ) {
84 $form_id = $forms[0]->id;
85 }
86 }
87
88 return (int) $form_id;
89 }
90
91 private function create_entry_configurator( int $form_id ): EntryConfigurator {
92 $fieldFactory = new FieldFactory();
93 $columnFactory = new GravityForms\Column\EntryFactory( $fieldFactory );
94
95 $entry_configurator = new EntryConfigurator( $form_id, $columnFactory, $fieldFactory );
96 $entry_configurator->register();
97
98 return $entry_configurator;
99 }
100
101 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\GravityForms\Service;
4
5 use AC;
6 use AC\Registerable;
7 use AC\Table\ListKeyCollection;
8 use AC\Type\ListKey;
9 use GFAPI;
10
11 class ListScreens implements Registerable {
12
13 public function register() {
14 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_group' ] );
15 add_action( 'ac/list_keys', [ $this, 'add_list_keys' ] );
16 }
17
18 public function register_list_screen_group( AC\Groups $groups ): void {
19 $groups->add( 'gravity_forms', __( 'Gravity Forms', 'codepress-admin-columns' ), 8 );
20 }
21
22 public function add_list_keys( ListKeyCollection $keys ): ListKeyCollection {
23 $forms = array_merge( GFAPI::get_forms(), GFAPI::get_forms( false ) );
24
25 foreach ( $forms as $form ) {
26 $keys->add( new ListKey( 'gf_entry_' . $form['id'] ) );
27 }
28
29 return $keys;
30 }
31
32 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
3 namespace ACA\GravityForms\TableScreen; 3 namespace ACA\GravityForms\TableScreen;
4 4
5 use AC; 5 use AC;
6 use AC\DefaultColumnsRepository;
7 use AC\ListScreenFactoryInterface;
8 use AC\ListScreenRepository\Storage;
9 use AC\Type\ListScreenId;
6 use ACA\GravityForms\Column; 10 use ACA\GravityForms\Column;
7 use ACA\GravityForms\Editing; 11 use ACA\GravityForms\Editing;
8 use ACA\GravityForms\HideOnScreen\EntryFilters; 12 use ACA\GravityForms\HideOnScreen\EntryFilters;
...@@ -14,11 +18,27 @@ use GFFormsModel; ...@@ -14,11 +18,27 @@ use GFFormsModel;
14 18
15 class Entry implements AC\Registerable { 19 class Entry implements AC\Registerable {
16 20
21 private $list_screen_factory;
22
23 private $storage;
24
25 private $default_columns_repository;
26
27 public function __construct(
28 ListScreenFactoryInterface $list_screen_factory,
29 Storage $storage,
30 DefaultColumnsRepository $default_columns_repository
31 ) {
32 $this->list_screen_factory = $list_screen_factory;
33 $this->storage = $storage;
34 $this->default_columns_repository = $default_columns_repository;
35 }
36
17 public function register() { 37 public function register() {
18 add_filter( 'gform_entry_list_columns', [ $this, 'remove_selector_column' ], 11, 2 ); 38 add_filter( 'gform_entry_list_columns', [ $this, 'remove_selector_column' ], 11, 2 );
19 add_filter( 'acp/editing/result', [ $this, 'get_editing_ajax_value' ], 10, 3 ); 39 add_filter( 'acp/editing/result', [ $this, 'get_editing_ajax_value' ], 10, 3 );
20 add_action( 'ac/table/list_screen', [ $this, 'create_default_list_screen' ], 9 ); 40 add_action( 'ac/table/list_screen', [ $this, 'create_default_list_screen' ], 9 );
21 add_action( 'ac/table/list_screen', [ $this, 'store_active_gf_columns' ], 10 ); 41 add_action( 'ac/table/list_screen', [ $this, 'store_active_gf_columns' ] );
22 add_action( 'ac/table/list_screen', [ $this, 'register_table_rows' ] ); 42 add_action( 'ac/table/list_screen', [ $this, 'register_table_rows' ] );
23 add_action( 'ac/admin_head', [ $this, 'hide_entry_filters' ] ); 43 add_action( 'ac/admin_head', [ $this, 'hide_entry_filters' ] );
24 add_action( 'ac/admin_head', [ $this, 'hide_wordpress_notifications' ] ); 44 add_action( 'ac/admin_head', [ $this, 'hide_wordpress_notifications' ] );
...@@ -37,14 +57,11 @@ class Entry implements AC\Registerable { ...@@ -37,14 +57,11 @@ class Entry implements AC\Registerable {
37 <?php 57 <?php
38 } 58 }
39 59
40 /** 60 private function has_stored_default_columns( string $list_key ): bool {
41 * @return bool 61 return ! empty( $this->default_columns_repository->get( $list_key ) );
42 */
43 private function has_stored_default_columns( AC\ListScreen $list_screen ) {
44 return ! empty( ( new AC\DefaultColumnsRepository() )->get( $list_screen->get_key() ) );
45 } 62 }
46 63
47 public function hide_wordpress_notifications( AC\ListScreen $list_screen ) { 64 public function hide_wordpress_notifications( AC\ListScreen $list_screen ): void {
48 if ( ! $list_screen instanceof ListScreen\Entry || ! ( new WordPressNotifications() )->is_hidden( $list_screen ) ) { 65 if ( ! $list_screen instanceof ListScreen\Entry || ! ( new WordPressNotifications() )->is_hidden( $list_screen ) ) {
49 return; 66 return;
50 } 67 }
...@@ -77,8 +94,8 @@ class Entry implements AC\Registerable { ...@@ -77,8 +94,8 @@ class Entry implements AC\Registerable {
77 return $result; 94 return $result;
78 } 95 }
79 96
80 public function create_default_list_screen( AC\ListScreen $list_screen ) { 97 public function create_default_list_screen( AC\ListScreen $list_screen ): void {
81 if ( ! $list_screen instanceof ListScreen\Entry || ! $this->has_stored_default_columns( $list_screen ) ) { 98 if ( ! $list_screen instanceof ListScreen\Entry ) {
82 return; 99 return;
83 } 100 }
84 101
...@@ -86,52 +103,83 @@ class Entry implements AC\Registerable { ...@@ -86,52 +103,83 @@ class Entry implements AC\Registerable {
86 return; 103 return;
87 } 104 }
88 105
89 if ( $list_screen->has_id() && AC()->get_storage()->exists( $list_screen->get_id() ) ) { 106 $list_key = $list_screen->get_key();
107
108 if ( ! $this->has_stored_default_columns( $list_key ) ) {
90 return; 109 return;
91 } 110 }
92 111
93 $default_columns = GFFormsModel::get_grid_columns( $list_screen->get_form_id() ); 112 if ( $list_screen->has_id() && $this->storage->exists( $list_screen->get_id() ) ) {
94 $settings = [ 113 return;
114 }
115
116 if ( ! $this->list_screen_factory->can_create( $list_key ) ) {
117 return;
118 }
119
120 $columns = [
95 'is_starred' => [ 121 'is_starred' => [
96 'label' => '<span class="dashicons dashicons-star-filled"></span>', 122 'label' => '<span class="dashicons dashicons-star-filled"></span>',
97 'type' => 'is_starred', 123 'type' => 'is_starred',
98 ], 124 ],
99 ]; 125 ];
100 126
101 foreach ( $default_columns as $field_id => $info ) { 127 foreach ( GFFormsModel::get_grid_columns( $list_screen->get_form_id() ) as $field_id => $data ) {
102 $key = 'field_id-' . $field_id; 128 $key = 'field_id-' . $field_id;
103 $settings[ $key ] = [ 129 $columns[ $key ] = [
104 'label' => $info['label'], 130 'label' => $data['label'],
105 'type' => $key, 131 'type' => $key,
106 ]; 132 ];
107 } 133 }
108 134
109 $list_screen->set_settings( $settings ); 135 $settings = [
110 $list_screen->set_title( 'Default' ); 136 'list_id' => ListScreenId::generate()->get_id(),
111 $list_screen->set_layout_id( AC\Type\ListScreenId::generate()->get_id() ); 137 'title' => __( 'Default', 'codepress-admin-columns' ),
138 'columns' => $columns,
139 ];
140
141 $this->storage->save( $this->list_screen_factory->create( $list_key, $settings ) );
142 }
143
144 public function store_active_gf_columns( AC\ListScreen $list_screen ): void {
145 if ( ! $list_screen instanceof ListScreen\Entry ) {
146 return;
147 }
112 148
113 AC()->get_storage()->save( $list_screen ); 149 $form_id = $list_screen->get_form_id();
150
151 if ( ! $form_id ) {
152 return;
114 } 153 }
115 154
116 public function store_active_gf_columns( AC\ListScreen $list_screen ) { 155 $list_key = $list_screen->get_key();
117 if ( ! $list_screen instanceof ListScreen\Entry || ! $this->has_stored_default_columns( $list_screen ) ) { 156
157 if ( ! $this->has_stored_default_columns( $list_key ) ) {
118 return; 158 return;
119 } 159 }
120 160
121 $grid_columns = array_keys( GFFormsModel::get_grid_columns( $list_screen->get_form_id() ) ); 161 $grid_columns = array_keys( GFFormsModel::get_grid_columns( $form_id ) );
122 162
123 foreach ( $grid_columns as $key => $column ) { 163 foreach ( $grid_columns as $key => $column ) {
124 $field = GFAPI::get_field( $list_screen->get_form_id(), $column ); 164 $field = GFAPI::get_field( $form_id, $column );
165
125 if ( $field && in_array( $field['type'], $this->get_unsupported_field_types(), false ) ) { 166 if ( $field && in_array( $field['type'], $this->get_unsupported_field_types(), false ) ) {
126 unset( $grid_columns[ $key ] ); 167 unset( $grid_columns[ $key ] );
127 } 168 }
128 } 169 }
129 170
130 $current_columns = array_merge( $grid_columns, $this->get_field_ids( GFAPI::get_form( $list_screen->get_form_id() ) ), $this->get_default_table_column_names() ); 171 $forms = GFAPI::get_form( $form_id );
172 $form_fields = $forms['fields'] ?? [];
173
174 if ( ! $form_fields ) {
175 return;
176 }
177
178 $current_columns = array_merge( $grid_columns, $this->get_field_ids( $form_fields ), $this->get_default_table_column_names() );
131 $current_columns = array_unique( $current_columns ); 179 $current_columns = array_unique( $current_columns );
132 180
133 if ( md5( serialize( GFFormsModel::get_grid_column_meta( $list_screen->get_form_id() ) ) ) !== md5( serialize( $current_columns ) ) ) { 181 if ( md5( serialize( GFFormsModel::get_grid_column_meta( $form_id ) ) ) !== md5( serialize( $current_columns ) ) ) {
134 GFFormsModel::update_grid_column_meta( $list_screen->get_form_id(), $current_columns ); 182 GFFormsModel::update_grid_column_meta( $form_id, $current_columns );
135 } 183 }
136 } 184 }
137 185
...@@ -167,21 +215,18 @@ class Entry implements AC\Registerable { ...@@ -167,21 +215,18 @@ class Entry implements AC\Registerable {
167 return [ 'section', 'html', 'page' ]; 215 return [ 'section', 'html', 'page' ];
168 } 216 }
169 217
170 /** 218 private function get_field_ids( array $form_fields ): array {
171 * @param array $form
172 *
173 * @return array
174 */
175 private function get_field_ids( $form ) {
176 $field_ids = []; 219 $field_ids = [];
177 220
178 /** 221 foreach ( $form_fields as $field ) {
179 * @var GF_Field $field 222 if ( ! $field instanceof GF_Field ) {
180 */
181 foreach ( $form['fields'] as $field ) {
182 if ( in_array( $field['type'], $this->get_unsupported_field_types(), false ) ) {
183 continue; 223 continue;
184 } 224 }
225
226 if ( in_array( $field->type, $this->get_unsupported_field_types(), false ) ) {
227 continue;
228 }
229
185 $inputs = $field->get_entry_inputs(); 230 $inputs = $field->get_entry_inputs();
186 $field_ids[] = $field->id; 231 $field_ids[] = $field->id;
187 232
......
...@@ -14,8 +14,8 @@ final class ColumnGroups implements AC\Registerable { ...@@ -14,8 +14,8 @@ final class ColumnGroups implements AC\Registerable {
14 } 14 }
15 15
16 public function register_column_groups( AC\Groups $groups ) { 16 public function register_column_groups( AC\Groups $groups ) {
17 $groups->register_group( self::JET_ENGINE, __( 'JetEngine', 'codepress-admin-columns' ), 11 ); 17 $groups->add( self::JET_ENGINE, __( 'JetEngine', 'codepress-admin-columns' ), 11 );
18 $groups->register_group( self::JET_ENGINE_RELATION, __( 'JetEngine Relationship', 'codepress-admin-columns' ), 11 ); 18 $groups->add( self::JET_ENGINE_RELATION, __( 'JetEngine Relationship', 'codepress-admin-columns' ), 11 );
19 } 19 }
20 20
21 } 21 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,10 +4,11 @@ declare( strict_types=1 ); ...@@ -4,10 +4,11 @@ declare( strict_types=1 );
4 namespace ACA\MLA\Editing; 4 namespace ACA\MLA\Editing;
5 5
6 use ACP; 6 use ACP;
7 use ACP\Editing\RequestHandler;
7 8
8 class Strategy extends ACP\Editing\Strategy\Post { 9 class Strategy extends ACP\Editing\Strategy\Post {
9 10
10 public function get_query_request_handler() { 11 public function get_query_request_handler(): RequestHandler {
11 global $wp_list_table; 12 global $wp_list_table;
12 13
13 // Re-execute the query because the table object can be shared with custom plugins using the MLA filters/actions 14 // Re-execute the query because the table object can be shared with custom plugins using the MLA filters/actions
......
...@@ -17,7 +17,7 @@ class MediaLibrary extends AC\ThirdParty\MediaLibraryAssistant\ListScreen\MediaL ...@@ -17,7 +17,7 @@ class MediaLibrary extends AC\ThirdParty\MediaLibraryAssistant\ListScreen\MediaL
17 } 17 }
18 18
19 public function editing() { 19 public function editing() {
20 return new Editing\Strategy( 'attachment' ); 20 return new Editing\Strategy( get_post_type_object( 'attachment' ) );
21 } 21 }
22 22
23 public function register_column_types() { 23 public function register_column_types() {
......
1 <?php
2
3 namespace ACA\MLA\ListScreenFactory;
4
5 use AC;
6 use AC\ThirdParty\MediaLibraryAssistant\ListScreenFactory;
7 use ACA\MLA\ListScreen\MediaLibrary;
8
9 class MediaLibraryFactory extends ListScreenFactory {
10
11 protected function create_list_screen(): AC\ThirdParty\MediaLibraryAssistant\ListScreen\MediaLibrary {
12 return new MediaLibrary();
13 }
14
15 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -15,7 +15,7 @@ class ColumnGroup implements Registerable { ...@@ -15,7 +15,7 @@ class ColumnGroup implements Registerable {
15 } 15 }
16 16
17 public function register_column_group( AC\Groups $groups ) { 17 public function register_column_group( AC\Groups $groups ) {
18 $groups->register_group( self::NAME, __( 'Media Library Assistant' ), 25 ); 18 $groups->add( self::NAME, __( 'Media Library Assistant' ), 25 );
19 } 19 }
20 20
21 } 21 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,16 +4,12 @@ namespace ACA\MLA\Service; ...@@ -4,16 +4,12 @@ namespace ACA\MLA\Service;
4 4
5 use AC; 5 use AC;
6 use AC\Registerable; 6 use AC\Registerable;
7 use ACA\MLA\ListScreen; 7 use ACA\MLA\ListScreenFactory\MediaLibraryFactory;
8 8
9 class ListScreens implements Registerable { 9 class ListScreens implements Registerable {
10 10
11 public function register() { 11 public function register() {
12 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ], 11 ); 12 AC\ListScreenFactory::add( new MediaLibraryFactory() );
13 }
14
15 public function register_list_screens() {
16 AC\ListScreenTypes::instance()->register_list_screen( new ListScreen\MediaLibrary() );
17 } 13 }
18 14
19 } 15 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -43,8 +43,8 @@ class Columns implements Registerable { ...@@ -43,8 +43,8 @@ class Columns implements Registerable {
43 } 43 }
44 44
45 public function register_column_groups( AC\Groups $groups ) { 45 public function register_column_groups( AC\Groups $groups ) {
46 $groups->register_group( 'metabox', 'MetaBox', 11 ); 46 $groups->add( 'metabox', 'MetaBox', 11 );
47 $groups->register_group( 'metabox_relation', 'MetaBox Relation', 11 ); 47 $groups->add( 'metabox_relation', 'MetaBox Relation', 11 );
48 } 48 }
49 49
50 public function add_columns( AC\ListScreen $list_screen ) { 50 public function add_columns( AC\ListScreen $list_screen ) {
......
...@@ -18,7 +18,7 @@ final class Columns implements Registerable { ...@@ -18,7 +18,7 @@ final class Columns implements Registerable {
18 * @param AC\Groups $groups 18 * @param AC\Groups $groups
19 */ 19 */
20 public function register_column_groups( $groups ) { 20 public function register_column_groups( $groups ) {
21 $groups->register_group( 'pods', 'Pods', 11 ); 21 $groups->add( 'pods', 'Pods', 11 );
22 22
23 } 23 }
24 24
......
...@@ -17,7 +17,7 @@ class Columns implements Registerable { ...@@ -17,7 +17,7 @@ class Columns implements Registerable {
17 } 17 }
18 18
19 public function register_column_groups( AC\Groups $groups ): void { 19 public function register_column_groups( AC\Groups $groups ): void {
20 $groups->register_group( self::GROUP_NAME, 'Polylang', 25 ); 20 $groups->add( self::GROUP_NAME, 'Polylang', 25 );
21 } 21 }
22 22
23 public function add_columns( AC\ListScreen $list_screen ): void { 23 public function add_columns( AC\ListScreen $list_screen ): void {
......
...@@ -36,7 +36,7 @@ final class Columns implements AC\Registerable { ...@@ -36,7 +36,7 @@ final class Columns implements AC\Registerable {
36 } 36 }
37 37
38 public function register_column_groups( AC\Groups $groups ) { 38 public function register_column_groups( AC\Groups $groups ) {
39 $groups->register_group( 'types', 'Toolset Types', 11 ); 39 $groups->add( 'types', 'Toolset Types', 11 );
40 } 40 }
41 41
42 } 42 }
...\ No newline at end of file ...\ No newline at end of file
......
1 {"version":3,"sourceRoot":"","sources":["../../src/scss/_editables.scss","../../src/scss/table.scss"],"names":[],"mappings":"CAKG,wDACC,YAQF,qEACC,qBACA,WAIF,4BACC,cACA,yBACA,kBACA,aACA,cACA,eAGA,mCACC,mBACA,cAGD,kCACC,cACA,kBAEA,yCACC,WACA,kBACA,OACA,QACA,QACA,WACA,mBAQF,0CACC,YAGD,yDACC,WAOD,+EACC,YAIF,qDACC,YAKC,+EACC,WAKH,2CACC,cAOA,iDACC,kBAKD,0DACC,eAIF,6CACC,cAGD,+CACC,YACA,kBAGD,gDACC,iBACA,iBAEA,uDACC,kBACA,kBAGD,mHAEC,gBACA,qBACA,iBAMD,uEACC,2BACA,mBAEA,+FACC,2BACA,qBAOF,oFACC,YACA,kBAGD,wEACC,gBACA,mBACA,eAMF,uDACC,cAEA,6DACC,cACA,mBAOF,iDACC,2BACA,aAKA,+DACC,YACA,8BACA,iBACA,uBACA,kBACA,kBAKD,2DACC,YACA,mBACA,kBAGD,6CACC,YACA,iBAGD,wCACC,gBACA,kBAEA,6CACC,qBACA,eACA,eAIF,0CACC,iBACA,qBACA,gBACA,gBAGD,wCACC,mBAEA,oDACC,eAGD,mDACC,kBAGD,oEACC,mBAED,kEACC,mBAID,8CACC,YACA,gBACA,aACA,mBAGD,8CACC,eACA,eACA,aAGC,0DACC,kBACA,YAEA,+DACC,cACA,iCAIF,4DACC,iCACA,0BACA,eC5PL,+IACC,aAMD,uFACC,qBAIF,kDACC,+BAKC,iDACC,WAEA,uEACC,WAJF,+CACC,WAEA,qEACC,WAJF,iDACC,WAEA,uEACC,WAJF,8CACC,WAEA,oEACC,WASH,qIACC,0BAEA,mKACC,6BAKH,qBACC,qBAGD,gCACC,WAGC,4EACC,kBACA,oBAIF,2CACC,mBACA,6BAKC,wFACC,6BAKD,8GACC,mBAKH,6CACC,gBACA,eAEA,uDACC,eACA,iBAGD,mDACC,eAGD,mDACC,eACA,sBAIF,yCACC,iBAMA,qCACC,qBACA,sBACA,YACA,WACA,YACA,+BACA,kBACA,kBACA,YAEA,2CACC,qBAKD,uCACC,oCACA,YAYA,0SACC,oBAEA,sUACC,YACA,cACA,oCAaH,wDACC,YAGD,mEACC,WAQH,2CACC,cAMD,gCACC,kBACA,cAGD,gCACC,eACA,iBACA,cACA,iBAGD,gCACC,qBACA,eAGD,kCACC,cAGD,8BACC,gBACA,kBACA,sBACA,cACA,eAGD,qCACC,WAGD,gCACC,cAMD,8BACC,kBACA,iBAEA,qCACC,8BACA,WACA,gBACA,oBACA,oBACA,cACA,mCACA,oBACA,cACA,kBACA,qBACA,sBACA,mBAIF,6CACC,YACA,cAGD,+CACC,YACA,cAGD,6CACC,YACA,WAGD,4CACC,YACA,cAGD,+CACC,YACA,WAGD,gDACC,YACA,cAGD,8CACC,YACA,WAKD,iDACC,kBACA,iBAEA,wDACC,8BACA,WACA,gBACA,oBACA,oBACA,cACA,mCACA,oBACA,cACA,kBACA,qBACA,sBACA,mBAIF,+DACC,YACA,cAGD,gEACC,YACA,cAGD,kEACC,YACA,WAGD,iEACC,YACA,WAGD,gEACC,YACA,WAGD,gEACC,YACA,cAGD,uEACC,YACA,WAKD,yBACC,kBAEA,8BACC,sBACA,cACA,eAGD,+BACC,eAOF,iCACC,qBAGD,4CACC,qBACA,iBACA,sBAGD,uCACC,mBAEA,kDACC,gBAQF,iCACC,yBACA,oBACA,kBACA,WACA,UACA,eACA,gBACA,SAEA,uCACC,kCACA,WACA,gBACA,oBACA,oBACA,cACA,mCACA,SACA,cACA,kBACA,MACA,OACA,WACA,YACA,kBACA,WACA,cAGD,qGAEC,YACA,WAGD,iDACC,YACA,cAGD,+CACC,YACA,cAGD,gDACC,YACA,WAGD,8CACC,YACA,cAGD,kDACC,YACA,cAGD,iDACC,YACA,WAOF,oCACC,mBAGD,mCACC,WAGD,0CACC,WACA,kBAMC,mEACC,WACA,kBACA,mBAGD,gEACC,WAGD,qEACC,UAKD,uEACC,iBAGD,gEACC,iBAGD,mEACC,kBAOD,gIACC,iBAYF,qJACC,gBAEA,6KACC,YAIF,yKACC,kBAGD,qJACC,iBAIF,iHACC,iBASC,wDACC,YAWH,yXACC,oCACA,sBAGD,yOACC,eAGD,qKACC,wBAGD,iQACC,iBAGD,qYACC,iBAGD,iWACC,YAGD,iSACC,iBACA,eAMA,mEACC,gBAEA,8FACC,YAGD,sFACC,qBASF,uMAEC,aAKD,iGACC,wBAKD,yMAEC,aAKH,oEACC,gBAGD,uDACC,WACA,gBAGC,0HACC,YAEA,8JACC,WACA,mBACA,eAGD,gKACC,gBACA,WAEA,oNACC,gBACA,mBACA,gBACA,uBAUH,0EACC,mBAKH,oDACC","file":"table.css"}
...\ No newline at end of file ...\ No newline at end of file
1 {"version":3,"sourceRoot":"","sources":["../../src/scss/_editables.scss","../../src/scss/table.scss"],"names":[],"mappings":"CAKG,wDACC,YAQF,qEACC,qBACA,WAIF,4BACC,cACA,yBACA,kBACA,aACA,cACA,eAGA,mCACC,mBACA,cAGD,kCACC,cACA,kBAEA,yCACC,WACA,kBACA,OACA,QACA,QACA,WACA,mBAQF,0CACC,YAGD,yDACC,WAOD,+EACC,YAIF,qDACC,YAKC,+EACC,WAKH,2CACC,cAOA,iDACC,kBAKD,0DACC,eAIF,6CACC,cAGD,+CACC,YACA,kBAGD,gDACC,iBACA,iBAEA,uDACC,kBACA,kBAGD,mHAEC,gBACA,qBACA,iBAMD,uEACC,2BACA,mBAEA,+FACC,2BACA,qBAOF,oFACC,YACA,kBAGD,wEACC,gBACA,mBACA,eAMF,uDACC,cAEA,6DACC,cACA,mBAOF,iDACC,2BACA,aAKA,+DACC,YACA,8BACA,iBACA,uBACA,kBACA,kBAKD,2DACC,YACA,mBACA,kBAGD,6CACC,YACA,iBAGD,wCACC,gBACA,kBAEA,6CACC,qBACA,eACA,eAIF,0CACC,iBACA,qBACA,gBACA,gBAGD,wCACC,mBAEA,oDACC,eAGD,mDACC,kBAGD,oEACC,mBAED,kEACC,mBAID,8CACC,YACA,gBACA,aACA,mBAGD,8CACC,eACA,eACA,aAGC,0DACC,kBACA,YAEA,+DACC,cACA,iCAIF,4DACC,iCACA,0BACA,eC5PL,+IACC,aAMD,uFACC,qBAIF,kDACC,+BAKC,iDACC,WAEA,uEACC,WAJF,+CACC,WAEA,qEACC,WAJF,iDACC,WAEA,uEACC,WAJF,8CACC,WAEA,oEACC,WASH,qIACC,0BAEA,mKACC,6BAKH,qBACC,qBAGD,gCACC,WAGC,4EACC,kBACA,oBAIF,2CACC,mBACA,6BAKC,wFACC,6BAKD,8GACC,mBAKH,6CACC,gBACA,eAEA,uDACC,eACA,iBAGD,mDACC,eAGD,mDACC,eACA,sBAIF,yCACC,iBAMA,qCACC,qBACA,sBACA,YACA,WACA,YACA,+BACA,kBACA,kBACA,YAEA,2CACC,qBAKD,uCACC,oCACA,YAYA,0SACC,oBAEA,sUACC,YACA,cACA,oCAaH,wDACC,YAGD,mEACC,WAQH,2CACC,cAMD,gCACC,kBACA,cAGD,gCACC,eACA,iBACA,cACA,iBAGD,gCACC,qBACA,eAGD,kCACC,cAGD,8BACC,gBACA,kBACA,sBACA,cACA,eAGD,qCACC,WAGD,gCACC,cAMD,8BACC,kBACA,iBAEA,qCACC,8BACA,WACA,gBACA,oBACA,oBACA,cACA,mCACA,oBACA,cACA,kBACA,qBACA,sBACA,mBAIF,6CACC,YACA,cAGD,+CACC,YACA,cAGD,6CACC,YACA,WAGD,4CACC,YACA,cAGD,+CACC,YACA,WAGD,gDACC,YACA,cAGD,8CACC,YACA,WAKD,iDACC,kBACA,iBAEA,wDACC,8BACA,WACA,gBACA,oBACA,oBACA,cACA,mCACA,oBACA,cACA,kBACA,qBACA,sBACA,mBAIF,+DACC,YACA,cAGD,gEACC,YACA,cAGD,kEACC,YACA,WAGD,iEACC,YACA,WAGD,gEACC,YACA,WAGD,gEACC,YACA,cAGD,uEACC,YACA,WAKD,yBACC,kBAEA,8BACC,sBACA,cACA,eAGD,+BACC,eAOF,iCACC,qBAGD,4CACC,qBACA,iBACA,sBAGD,uCACC,mBAEA,kDACC,gBAQF,iCACC,yBACA,oBACA,kBACA,WACA,UACA,eACA,gBACA,SAEA,uCACC,kCACA,WACA,gBACA,oBACA,oBACA,cACA,mCACA,SACA,cACA,kBACA,MACA,OACA,WACA,YACA,kBACA,WACA,cAGD,qGAEC,YACA,WAGD,iDACC,YACA,cAGD,+CACC,YACA,cAGD,gDACC,YACA,WAGD,8CACC,YACA,cAGD,kDACC,YACA,cAGD,iDACC,YACA,WAOF,oCACC,mBAGD,mCACC,WAGD,0CACC,WACA,kBAMC,mEACC,WACA,kBACA,mBAGD,gEACC,WAGD,qEACC,UAKD,uEACC,iBAGD,gEACC,iBAGD,mEACC,kBAOD,gIACC,iBAYF,qJACC,gBAEA,6KACC,YAIF,yKACC,kBAGD,qJACC,iBAIF,iHACC,iBASC,wDACC,YAWH,yXACC,oCACA,sBAGD,yOACC,eAGD,qKACC,wBAGD,iQACC,iBAGD,qYACC,iBAGD,iWACC,YAGD,iSACC,iBACA,eAMA,mEACC,gBAEA,8FACC,YAGD,sFACC,qBASF,uMAEC,aAKD,iGACC,wBAKD,yMAEC,aAKH,oEACC,gBAGD,uDACC,WACA,gBAGC,0HACC,YAEA,8JACC,WACA,mBACA,eAGD,gKACC,gBACA,WAEA,oNACC,gBACA,mBACA,gBACA,uBAUH,0EACC,mBAKH,oDACC,2BAMC,wDACC,cACA,WACA,WAID,2DACC,WAED,2GACC,SAGF,kDACC,WAGD,iDACC,gBAEA,uDACC","file":"table.css"}
...\ No newline at end of file ...\ No newline at end of file
......
1 {"version":3,"file":"table-orders.js","mappings":";;UAAA;UACA;;;;;WCDA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACS","sources":["webpack://admincolumns/webpack/bootstrap","webpack://admincolumns/webpack/runtime/make namespace object","webpack://admincolumns/./js/table-orders.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","AC_SERVICES.addListener('Table.Ready', () => {\n var _a, _b;\n const numElement = document.querySelector('.tablenav-pages .displaying-num');\n if (numElement) {\n let numberFormatted = numElement.innerHTML.split(' ')[0];\n let number = numElement.innerHTML.replace(/\\D/g, '');\n (_b = (_a = AC_SERVICES.getService('Editing')) === null || _a === void 0 ? void 0 : _a.getService('BulkSelectionRow')) === null || _b === void 0 ? void 0 : _b.setTotalItems(parseInt(number), numberFormatted);\n }\n});\nAC_SERVICES.filters.addFilter('table_row_id', (item_id, payload) => {\n var _a, _b;\n let row = payload.row;\n if (Number.isNaN(item_id)) {\n item_id = (_b = (_a = row.querySelector('.check-column input[name=\"order[]\"]')) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;\n }\n return item_id;\n});\nexport {};\n"],"names":[],"sourceRoot":""}
...\ No newline at end of file ...\ No newline at end of file
...@@ -36,6 +36,10 @@ class SalePrice extends Price { ...@@ -36,6 +36,10 @@ class SalePrice extends Price {
36 if ( $this->scheduled ) { 36 if ( $this->scheduled ) {
37 $this->schedule_from = $value['schedule']['from']; 37 $this->schedule_from = $value['schedule']['from'];
38 $this->schedule_to = $value['schedule']['to']; 38 $this->schedule_to = $value['schedule']['to'];
39
40 if ( ! empty( $this->schedule_to ) ) {
41 $this->schedule_to = date( 'Y-m-d 23:59:59', strtotime( $this->schedule_to ) );
42 }
39 } 43 }
40 } 44 }
41 45
......
...@@ -36,8 +36,8 @@ class Price { ...@@ -36,8 +36,8 @@ class Price {
36 public function save() { 36 public function save() {
37 $price = $this->get_calculated_price(); 37 $price = $this->get_calculated_price();
38 38
39 if ( $price <= 0 ) { 39 if ( $price < 0 ) {
40 return new WP_Error( 'invalid-price', __( 'Price can not be zero or lower.', 'codepress-admin-columns' ) ); 40 return new WP_Error( 'invalid-price', __( 'Price can not lower than zero.', 'codepress-admin-columns' ) );
41 } 41 }
42 42
43 if ( $this->value->is_rounded() || 'flat' !== $this->value->get_price_type() ) { 43 if ( $this->value->is_rounded() || 'flat' !== $this->value->get_price_type() ) {
......
...@@ -6,7 +6,7 @@ use ACP\Editing\Strategy; ...@@ -6,7 +6,7 @@ use ACP\Editing\Strategy;
6 6
7 class Product extends Strategy\Post { 7 class Product extends Strategy\Post {
8 8
9 public function user_can_edit() { 9 public function user_can_edit(): bool {
10 return current_user_can( 'manage_woocommerce' ) && parent::user_can_edit(); 10 return current_user_can( 'manage_woocommerce' ) && parent::user_can_edit();
11 } 11 }
12 12
......
...@@ -15,7 +15,7 @@ class Product extends ACP\ListScreen\Post { ...@@ -15,7 +15,7 @@ class Product extends ACP\ListScreen\Post {
15 } 15 }
16 16
17 public function editing() { 17 public function editing() {
18 return new Editing\Strategy\Product( $this->get_post_type() ); 18 return new Editing\Strategy\Product( get_post_type_object( $this->get_post_type() ) );
19 } 19 }
20 20
21 protected function register_column_types() { 21 protected function register_column_types() {
......
1 <?php
2
3 namespace ACA\WC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\WC\ListScreen\ProductCategory;
9 use ACP\ListScreen\Taxonomy;
10 use LogicException;
11 use WP_Screen;
12
13 class ProductCategoryFactory implements ListScreenFactoryInterface {
14
15 use ListSettingsTrait;
16
17 public function can_create( string $key ): bool {
18 return Taxonomy::KEY_PREFIX . 'product_cat' === $key;
19 }
20
21 public function create( string $key, array $settings = [] ): ListScreen {
22 if ( ! $this->can_create( $key ) ) {
23 throw new LogicException( 'Invalid Listscreen key' );
24 }
25
26 return $this->add_settings( new ProductCategory(), $settings );
27 }
28
29 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
30 return 'edit-tags' === $screen->base && 'product_cat' === $screen->taxonomy;
31 }
32
33 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
34 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
35 throw new LogicException( 'Invalid Screen' );
36 }
37
38 return $this->add_settings( new ProductCategory(), $settings );
39 }
40
41 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\WC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\WC\ListScreen\Product;
9 use LogicException;
10 use WP_Screen;
11
12 class ProductFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'product' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new Product(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'product';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new Product(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\WC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\WC\ListScreen\ProductVariation;
9 use LogicException;
10 use WP_Screen;
11
12 class ProductVariationFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'product_variation' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new ProductVariation(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'product_variation';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new ProductVariation(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\WC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\WC\ListScreen\ShopCoupon;
9 use LogicException;
10 use WP_Screen;
11
12 class ShopCouponFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'shop_coupon' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new ShopCoupon(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'shop_coupon';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new ShopCoupon(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\WC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\WC\ListScreen\ShopOrder;
9 use LogicException;
10 use WP_Screen;
11
12 class ShopOrderFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'shop_order' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new ShopOrder(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'shop_order';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new ShopOrder(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\WC\ListScreenFactory;
4
5 use AC\ListScreen;
6 use AC\ListScreenFactory\ListSettingsTrait;
7 use AC\ListScreenFactoryInterface;
8 use ACA\WC\ListScreen\Subscriptions;
9 use LogicException;
10 use WP_Screen;
11
12 class ShopSubscriptionFactory implements ListScreenFactoryInterface {
13
14 use ListSettingsTrait;
15
16 public function can_create( string $key ): bool {
17 return 'shop_subscription' === $key;
18 }
19
20 public function create( string $key, array $settings = [] ): ListScreen {
21 if ( ! $this->can_create( $key ) ) {
22 throw new LogicException( 'Invalid Listscreen key' );
23 }
24
25 return $this->add_settings( new Subscriptions(), $settings );
26 }
27
28 public function can_create_by_wp_screen( WP_Screen $screen ): bool {
29 return $screen->base === 'edit' && $screen->post_type === 'shop_subscription';
30 }
31
32 public function create_by_wp_screen( WP_Screen $screen, array $settings = [] ): ListScreen {
33 if ( ! $this->can_create_by_wp_screen( $screen ) ) {
34 throw new LogicException( 'Invalid Screen' );
35 }
36
37 return $this->add_settings( new Subscriptions(), $settings );
38 }
39
40 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -12,7 +12,7 @@ class ColumnGroups implements Registerable { ...@@ -12,7 +12,7 @@ class ColumnGroups implements Registerable {
12 } 12 }
13 13
14 public function register_column_groups( Groups $groups ) { 14 public function register_column_groups( Groups $groups ) {
15 $groups->register_group( 'woocommerce', __( 'WooCommerce', 'codepress-admin-columns' ), 15 ); 15 $groups->add( 'woocommerce', __( 'WooCommerce', 'codepress-admin-columns' ), 15 );
16 } 16 }
17 17
18 } 18 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,16 +3,64 @@ ...@@ -3,16 +3,64 @@
3 namespace ACA\WC\Service; 3 namespace ACA\WC\Service;
4 4
5 use AC\Groups; 5 use AC\Groups;
6 use AC\ListScreen;
6 use AC\Registerable; 7 use AC\Registerable;
8 use ACP\ListScreen\Taxonomy;
7 9
8 class ListScreenGroups implements Registerable { 10 class ListScreenGroups implements Registerable {
9 11
10 public function register() { 12 public function register() {
11 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_groups' ] ); 13 add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_groups' ] );
14 add_action( 'ac/admin/menu_group', [ $this, 'update_menu_list_groups' ], 10, 2 );
12 } 15 }
13 16
14 public function register_list_screen_groups( Groups $groups ) { 17 public function update_menu_list_groups( string $group, ListScreen $list_screen ): string {
15 $groups->register_group( 'woocommerce', __( 'WooCommerce', 'codepress-admin-columns' ), 7 ); 18 if ( in_array( $list_screen->get_key(), $this->get_post_list_keys(), true ) ) {
19 return 'woocommerce';
20 }
21
22 if ( in_array( $list_screen->get_key(), $this->get_attribute_list_keys(), true ) ) {
23 return 'woocommerce_attributes';
24 }
25
26 if ( in_array( $list_screen->get_key(), $this->get_taxonomy_list_keys(), true ) ) {
27 return 'woocommerce_taxonomy';
28 }
29
30 return $group;
31 }
32
33 public function register_list_screen_groups( Groups $groups ): void {
34 $groups->add( 'woocommerce', __( 'WooCommerce', 'codepress-admin-columns' ), 11 );
35 $groups->add( 'woocommerce_taxonomy', sprintf( '%s - %s', __( 'WooCommerce', 'codepress-admin-columns' ), __( 'Taxonomy', 'codepress-admin-columns' ) ), 11 );
36 $groups->add( 'woocommerce_attributes', sprintf( '%s - %s', __( 'WooCommerce', 'codepress-admin-columns' ), __( 'Attribute', 'codepress-admin-columns' ) ), 11 );
37 }
38
39 private function get_attribute_list_keys(): array {
40 $taxonomies = [];
41
42 foreach ( wc_get_attribute_taxonomy_names() as $taxonomy_name ) {
43 $taxonomies[] = Taxonomy::KEY_PREFIX . $taxonomy_name;
44 }
45
46 return $taxonomies;
47 }
48
49 private function get_post_list_keys(): array {
50 return [
51 'product',
52 'product_variation',
53 'shop_order',
54 'shop_coupon',
55 'shop_subscription',
56 ];
57 }
58
59 private function get_taxonomy_list_keys(): array {
60 return [
61 Taxonomy::KEY_PREFIX . 'product_cat',
62 Taxonomy::KEY_PREFIX . 'product_tag',
63 ];
16 } 64 }
17 65
18 } 66 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,39 +2,30 @@ ...@@ -2,39 +2,30 @@
2 2
3 namespace ACA\WC\Service; 3 namespace ACA\WC\Service;
4 4
5 use AC; 5 use AC\ListScreenFactory;
6 use AC\Registerable; 6 use AC\Registerable;
7 use ACA\WC\ListScreen; 7 use ACA\WC\ListScreenFactory\ProductCategoryFactory;
8 use ACA\WC\ListScreenFactory\ProductFactory;
9 use ACA\WC\ListScreenFactory\ProductVariationFactory;
10 use ACA\WC\ListScreenFactory\ShopCouponFactory;
11 use ACA\WC\ListScreenFactory\ShopOrderFactory;
8 12
9 class ListScreens implements Registerable { 13 class ListScreens implements Registerable {
10 14
11 /**
12 * @var bool
13 */
14 private $use_product_variations; 15 private $use_product_variations;
15 16
16 public function __construct( $use_product_variations ) { 17 public function __construct( bool $use_product_variations ) {
17 $this->use_product_variations = $use_product_variations; 18 $this->use_product_variations = $use_product_variations;
18 } 19 }
19 20
20 public function register() { 21 public function register() {
21 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ] ); 22 ListScreenFactory::add( new ProductFactory() );
22 } 23 ListScreenFactory::add( new ShopCouponFactory() );
23 24 ListScreenFactory::add( new ShopOrderFactory() );
24 public function register_list_screens() { 25 ListScreenFactory::add( new ProductCategoryFactory() );
25 $list_screens = [
26 new ListScreen\ShopOrder(),
27 new ListScreen\ShopCoupon(),
28 new ListScreen\Product(),
29 new ListScreen\ProductCategory(),
30 ];
31 26
32 if ( $this->use_product_variations ) { 27 if ( $this->use_product_variations ) {
33 $list_screens[] = new ListScreen\ProductVariation; 28 ListScreenFactory::add( new ProductVariationFactory() );
34 }
35
36 foreach ( $list_screens as $list_screen ) {
37 AC\ListScreenTypes::instance()->register_list_screen( $list_screen );
38 } 29 }
39 } 30 }
40 31
......
...@@ -5,6 +5,8 @@ namespace ACA\WC; ...@@ -5,6 +5,8 @@ namespace ACA\WC;
5 use AC; 5 use AC;
6 use ACA\WC\Column; 6 use ACA\WC\Column;
7 use ACA\WC\ListScreen\Product; 7 use ACA\WC\ListScreen\Product;
8 use ACA\WC\ListScreenFactory\ShopSubscriptionFactory;
9 use ACA\WC\ListScreenFactory\WcSubscriptions;
8 use WC_Subscriptions; 10 use WC_Subscriptions;
9 11
10 /** 12 /**
...@@ -29,20 +31,14 @@ final class Subscriptions implements AC\Registerable { ...@@ -29,20 +31,14 @@ final class Subscriptions implements AC\Registerable {
29 } 31 }
30 32
31 add_action( 'ac/column_groups', [ $this, 'register_column_groups' ] ); 33 add_action( 'ac/column_groups', [ $this, 'register_column_groups' ] );
32 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ] );
33 add_action( 'ac/column_types', [ $this, 'add_product_columns' ] ); 34 add_action( 'ac/column_types', [ $this, 'add_product_columns' ] );
34 add_action( 'ac/column_types', [ $this, 'add_user_columns' ] ); 35 add_action( 'ac/column_types', [ $this, 'add_user_columns' ] );
35 }
36 36
37 public function register_list_screens( AC\ListScreens $list_screens ) { 37 AC\ListScreenFactory::add( new ShopSubscriptionFactory() );
38 $list_screens->register_list_screen( new ListScreen\Subscriptions() );
39 } 38 }
40 39
41 /** 40 public function register_column_groups( AC\Groups $groups ): void {
42 * @param AC\Groups $groups 41 $groups->add( 'woocommerce_subscriptions', __( 'WooCommerce Subscriptions', 'codepress-admin-columns' ), 15 );
43 */
44 public function register_column_groups( $groups ) {
45 $groups->register_group( 'woocommerce_subscriptions', __( 'WooCommerce Subscriptions', 'codepress-admin-columns' ), 15 );
46 } 42 }
47 43
48 public function add_product_columns( AC\ListScreen $list_screen ) { 44 public function add_product_columns( AC\ListScreen $list_screen ) {
......
...@@ -50,20 +50,12 @@ final class WooCommerce implements Registerable { ...@@ -50,20 +50,12 @@ final class WooCommerce implements Registerable {
50 ); 50 );
51 } 51 }
52 52
53 /** 53 private function use_product_variations(): bool {
54 * @return bool
55 */
56 private function use_product_variations() {
57 return apply_filters( 'acp/wc/show_product_variations', true ) && $this->is_wc_version_gte( '3.3' ); 54 return apply_filters( 'acp/wc/show_product_variations', true ) && $this->is_wc_version_gte( '3.3' );
58 } 55 }
59 56
60 /** 57 private function is_wc_version_gte( string $version ): bool {
61 * @param string $version 58 return version_compare( WC()->version, $version, '>=' );
62 *
63 * @return bool
64 */
65 private function is_wc_version_gte( $version ) {
66 return version_compare( WC()->version, (string) $version, '>=' );
67 } 59 }
68 60
69 } 61 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,10 +3,14 @@ ...@@ -3,10 +3,14 @@
3 namespace ACA\YoastSeo\Column\User; 3 namespace ACA\YoastSeo\Column\User;
4 4
5 use AC; 5 use AC;
6 use AC\MetaType;
6 use ACA\YoastSeo\Editing; 7 use ACA\YoastSeo\Editing;
7 use ACA\YoastSeo\Export; 8 use ACA\YoastSeo\Export;
8 use ACA\YoastSeo\Filtering; 9 use ACA\YoastSeo\Filtering;
9 use ACP; 10 use ACP;
11 use ACP\Editing\Service\Basic;
12 use ACP\Editing\Storage\Meta;
13 use ACP\Editing\View\TextArea;
10 14
11 class AuthorPageMetaDesc extends AC\Column\Meta 15 class AuthorPageMetaDesc extends AC\Column\Meta
12 implements ACP\Editing\Editable, ACP\Search\Searchable, ACP\ConditionalFormat\Formattable { 16 implements ACP\Editing\Editable, ACP\Search\Searchable, ACP\ConditionalFormat\Formattable {
...@@ -28,7 +32,7 @@ class AuthorPageMetaDesc extends AC\Column\Meta ...@@ -28,7 +32,7 @@ class AuthorPageMetaDesc extends AC\Column\Meta
28 } 32 }
29 33
30 public function editing() { 34 public function editing() {
31 return new ACP\Editing\Model\Meta( $this ); 35 return new Basic( new TextArea(), new Meta( $this->get_meta_key(), new MetaType( MetaType::USER ) ) );
32 } 36 }
33 37
34 } 38 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,10 +3,14 @@ ...@@ -3,10 +3,14 @@
3 namespace ACA\YoastSeo\Column\User; 3 namespace ACA\YoastSeo\Column\User;
4 4
5 use AC; 5 use AC;
6 use AC\MetaType;
6 use ACA\YoastSeo\Editing; 7 use ACA\YoastSeo\Editing;
7 use ACA\YoastSeo\Export; 8 use ACA\YoastSeo\Export;
8 use ACA\YoastSeo\Filtering; 9 use ACA\YoastSeo\Filtering;
9 use ACP; 10 use ACP;
11 use ACP\Editing\Service\Basic;
12 use ACP\Editing\Storage\Meta;
13 use ACP\Editing\View\Text;
10 14
11 class AuthorPageTitle extends AC\Column\Meta 15 class AuthorPageTitle extends AC\Column\Meta
12 implements ACP\Editing\Editable, ACP\Search\Searchable, ACP\Sorting\Sortable, ACP\ConditionalFormat\Formattable { 16 implements ACP\Editing\Editable, ACP\Search\Searchable, ACP\Sorting\Sortable, ACP\ConditionalFormat\Formattable {
...@@ -59,7 +63,7 @@ class AuthorPageTitle extends AC\Column\Meta ...@@ -59,7 +63,7 @@ class AuthorPageTitle extends AC\Column\Meta
59 } 63 }
60 64
61 public function editing() { 65 public function editing() {
62 return new ACP\Editing\Model\Meta( $this ); 66 return new Basic( new Text(), new Meta( $this->get_meta_key(), new MetaType( MetaType::USER ) ) );
63 } 67 }
64 68
65 public function sorting() { 69 public function sorting() {
......
...@@ -12,7 +12,7 @@ final class ColumnGroups implements Registerable { ...@@ -12,7 +12,7 @@ final class ColumnGroups implements Registerable {
12 } 12 }
13 13
14 public function register_column_groups( AC\Groups $groups ) { 14 public function register_column_groups( AC\Groups $groups ) {
15 $groups->register_group( 'yoast-seo', 'Yoast SEO', 25 ); 15 $groups->add( 'yoast-seo', 'Yoast SEO', 25 );
16 } 16 }
17 17
18 } 18 }
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php 1 <?php
2 /* 2 /*
3 Plugin Name: Admin Columns Pro 3 Plugin Name: Admin Columns Pro
4 Version: 6.1.3 4 Version: 6.2.2
5 Description: Customize columns on the administration screens for post(types), users and other content. Filter and sort content, and edit posts directly from the posts overview. All via an intuitive, easy-to-use drag-and-drop interface. 5 Description: Customize columns on the administration screens for post(types), users and other content. Filter and sort content, and edit posts directly from the posts overview. All via an intuitive, easy-to-use drag-and-drop interface.
6 Author: AdminColumns.com 6 Author: AdminColumns.com
7 Author URI: https://www.admincolumns.com 7 Author URI: https://www.admincolumns.com
...@@ -37,7 +37,7 @@ if ( ! is_admin() ) { ...@@ -37,7 +37,7 @@ if ( ! is_admin() ) {
37 } 37 }
38 38
39 define( 'ACP_FILE', __FILE__ ); 39 define( 'ACP_FILE', __FILE__ );
40 define( 'ACP_VERSION', '6.1.3' ); 40 define( 'ACP_VERSION', '6.2.2' );
41 41
42 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 42 require_once ABSPATH . 'wp-admin/includes/plugin.php';
43 43
......
...@@ -7,10 +7,6 @@ use AC\ListScreenCollection; ...@@ -7,10 +7,6 @@ use AC\ListScreenCollection;
7 use AC\Type\ListScreenId; 7 use AC\Type\ListScreenId;
8 use AC\Type\Url; 8 use AC\Type\Url;
9 9
10 /**
11 * @since 3.0
12 */
13 // TODO David remove the singleton, make a factory with a shared instance for AC this should be no issue
14 if ( ! function_exists( 'AC' ) ) { 10 if ( ! function_exists( 'AC' ) ) {
15 function AC(): AC\AdminColumns { 11 function AC(): AC\AdminColumns {
16 static $ac = null; 12 static $ac = null;
......
1 .acui-dropdown{position:relative;display:inline-block}.acui-dropdown-menu{position:absolute;top:100%;background:#fff;box-shadow:0 9px 24px 0 rgba(15,15,15,.2),0 3px 6px 0 rgba(15,15,15,.1),0 0 0 1px rgba(15,15,15,.05);border-radius:2px;min-width:200px;padding:8px 0;z-index:var(--menu-z-index, 20)}.acui-dropdown-menu.-bottom-left{right:0}.acui-dropdown-item{margin:0 2px;padding:6px 10px;cursor:pointer;display:block;white-space:nowrap;text-decoration:none;color:var(--ac-text-color)}.acui-dropdown-item:hover,.acui-dropdown-item:focus{background:var(--ac-button-bg);border-radius:5px}.acui-progress{--containerWidth: 100%;--baseBackground: #ddd;--defaultBarBackground: #0073aa;--warningBarBackground: #FFB900;--errorBarBackground: var(--ac-notification-red);--finishedBarBackground: #7ED321;display:block;width:var(--containerWidth)}.acui-progress__bar{background:var(--baseBackground);width:100%;height:10px;border-radius:2px;position:relative;overflow:hidden;margin:15px 0}.acui-progress__progress{height:100%;background:var(--defaultBarBackground)}.acui-progress__progress.-finished{background-color:var(--finishedBarBackground, #7ED321)}.acui-progress__progress.-warning{background-color:var(--warningBarBackground, #FFB900)}.acui-progress__progress.-error{background-color:var(--errorBarBackground, #FFB900)} 1 .acui-dropdown{position:relative;display:inline-block}.acui-dropdown-menu{position:absolute;top:100%;background:#fff;box-shadow:0 9px 24px 0 rgba(15,15,15,.2),0 3px 6px 0 rgba(15,15,15,.1),0 0 0 1px rgba(15,15,15,.05);border-radius:2px;min-width:200px;padding:8px 0;z-index:var(--menu-z-index, 20)}.acui-dropdown-menu.-bottom-left{right:0}.acui-dropdown-item{margin:0 2px;padding:6px 10px;cursor:pointer;display:block;white-space:nowrap;text-decoration:none;color:var(--ac-text-color)}.acui-dropdown-item:hover,.acui-dropdown-item:focus{background:var(--ac-button-bg);border-radius:5px}.acui-progress{--containerWidth: 100%;--baseBackground: #ddd;--defaultBarBackground: #0073aa;--warningBarBackground: #FFB900;--errorBarBackground: var(--ac-notification-red);--finishedBarBackground: #7ED321;display:block;width:var(--containerWidth)}.acui-progress__bar{background:var(--baseBackground);width:100%;height:10px;border-radius:2px;position:relative;overflow:hidden;margin:15px 0}.acui-progress__progress{height:100%;background:var(--defaultBarBackground)}.acui-progress__progress.-finished{background-color:var(--finishedBarBackground, #7ED321)}.acui-progress__progress.-warning{background-color:var(--warningBarBackground, #FFB900)}.acui-progress__progress.-error{background-color:var(--errorBarBackground, #FFB900)}.acui-toggle-buttons .button{border-radius:0}.acui-toggle-buttons .button .dashicons{transform:translateY(4px)}.acui-toggle-buttons .button:active,.acui-toggle-buttons .button:focus{box-shadow:none !important}.acui-toggle-buttons .button:first-child{border-top-left-radius:3px;border-bottom-left-radius:3px}.acui-toggle-buttons .button:last-child{border-top-right-radius:3px;border-bottom-right-radius:3px}.acui-toggle-buttons .button.button-primary{padding-left:3px}.acui-button{background:#f6f7f7;border-color:var(--ac-primary-color)}.acui-tooltip{display:inline-flex;position:relative}.acui-tooltip .acui-tooltip-content.is-top{bottom:calc(100% + 4px);left:50%;transform:translateX(-50%)}.acui-tooltip .acui-tooltip-content.is-bottom{top:calc(100% + 4px);left:50%;transform:translateX(-50%)}.acui-tooltip .acui-tooltip-content.is-left{top:50%;right:calc(100% + 5px);transform:translateY(-50%)}.acui-tooltip .acui-tooltip-content.is-right{top:50%;left:calc(100% + 5px);transform:translateY(-50%)}.acui-tooltip-content{background:#000;border-radius:3px;padding:7px 14px;color:#fff;position:absolute;display:block;transition:opacity .3s;pointer-events:none;font-size:11px;line-height:16px;z-index:100000;white-space:nowrap}.acui-tooltip-content:before{content:"";display:block;width:0;height:0;border-bottom:4px solid rgba(0,0,0,.8);border-left:6px solid rgba(0,0,0,0);border-right:6px solid rgba(0,0,0,0);position:absolute}.acui-tooltip-content.is-top{margin-top:-5px}.acui-tooltip-content.is-top:before{left:50%;bottom:-4px;transform:translateX(-4px) rotate(180deg)}.acui-tooltip-content.is-bottom{margin-top:5px}.acui-tooltip-content.is-bottom:before{left:50%;top:-4px;transform:translateX(-4px)}.acui-tooltip-content.is-left{transform:translateY(-50%) translateX(-2px)}.acui-tooltip-content.is-left:before{left:100%;top:50%;transform:translateX(-4px) translateY(-50%) rotate(90deg)}.acui-tooltip-content.is-right{transform:translateY(-50%) translateX(5px)}.acui-tooltip-content.is-right:before{right:100%;top:50%;transform:translateX(4px) translateY(-50%) rotate(270deg)}.acui-tooltip-content.is-multiline{text-align:center;white-space:normal;width:var(--acui-tooltip-width, 200px)}.acui-tooltip-content.is-multiline.is-large{width:300px}.acui-tooltip-content.hover{opacity:1}
......
...@@ -22,7 +22,7 @@ class AdminScripts implements Enqueueables { ...@@ -22,7 +22,7 @@ class AdminScripts implements Enqueueables {
22 public function get_assets() { 22 public function get_assets() {
23 return new Assets( [ 23 return new Assets( [
24 new Script( 'ac-admin-general', $this->location->with_suffix( 'assets/js/admin-general.js' ), [ 'jquery' ] ), 24 new Script( 'ac-admin-general', $this->location->with_suffix( 'assets/js/admin-general.js' ), [ 'jquery' ] ),
25 new Style( 'ac-admin', $this->location->with_suffix( 'assets/css/admin-general.css' ) ), 25 new Style( 'ac-admin', $this->location->with_suffix( 'assets/css/admin-general.css' ), [ 'ac-ui' ] ),
26 ] ); 26 ] );
27 } 27 }
28 28
......
...@@ -5,27 +5,22 @@ namespace AC\Admin\Asset; ...@@ -5,27 +5,22 @@ namespace AC\Admin\Asset;
5 use AC; 5 use AC;
6 use AC\Asset\Location; 6 use AC\Asset\Location;
7 use AC\Asset\Script; 7 use AC\Asset\Script;
8 use AC\DefaultColumnsRepository; 8 use AC\Controller\DefaultColumns;
9 use AC\ListScreen;
10 use AC\ListScreenTypes;
11 9
12 class Columns extends Script { 10 class Columns extends Script {
13 11
14 /** 12 private $list_screens;
15 * @var DefaultColumnsRepository
16 */
17 private $default_columns;
18 13
19 /** 14 private $list_key;
20 * @var ListScreen 15
21 */ 16 private $list_id;
22 private $list_screen;
23 17
24 public function __construct( 18 public function __construct(
25 string $handle, 19 string $handle,
26 Location $location, 20 Location $location,
27 DefaultColumnsRepository $default_columns, 21 array $list_screens,
28 ListScreen $list_screen 22 string $list_key,
23 string $list_id = null
29 ) { 24 ) {
30 parent::__construct( $handle, $location, [ 25 parent::__construct( $handle, $location, [
31 'jquery', 26 'jquery',
...@@ -34,27 +29,18 @@ class Columns extends Script { ...@@ -34,27 +29,18 @@ class Columns extends Script {
34 'jquery-touch-punch', 29 'jquery-touch-punch',
35 ] ); 30 ] );
36 31
37 $this->default_columns = $default_columns; 32 $this->list_screens = $list_screens;
38 $this->list_screen = $list_screen; 33 $this->list_key = $list_key;
39 } 34 $this->list_id = $list_id;
40
41 private function get_list_screens(): array {
42 return is_network_admin()
43 ? ListScreenTypes::instance()->get_list_screens( [ ListScreenTypes::ARG_NETWORK => true ] )
44 : ListScreenTypes::instance()->get_list_screens( [ ListScreenTypes::ARG_SITE => true ] );
45 } 35 }
46 36
47 public function register(): void { 37 public function register(): void {
48 parent::register(); 38 parent::register();
49 39
50 if ( null === $this->list_screen ) {
51 return;
52 }
53
54 $params = [ 40 $params = [
55 '_ajax_nonce' => wp_create_nonce( AC\Ajax\Handler::NONCE_ACTION ), 41 '_ajax_nonce' => wp_create_nonce( AC\Ajax\Handler::NONCE_ACTION ),
56 'list_screen' => $this->list_screen->get_key(), 42 'list_screen' => $this->list_key,
57 'layout' => $this->list_screen->has_id() ? $this->list_screen->get_id()->get_id() : null, 43 'layout' => $this->list_id,
58 'original_columns' => [], 44 'original_columns' => [],
59 'uninitialized_list_screens' => [], 45 'uninitialized_list_screens' => [],
60 'i18n' => [ 46 'i18n' => [
...@@ -67,16 +53,9 @@ class Columns extends Script { ...@@ -67,16 +53,9 @@ class Columns extends Script {
67 ], 53 ],
68 ]; 54 ];
69 55
70 foreach ( $this->get_list_screens() as $list_screen ) { 56 foreach ( $this->list_screens as $list_screen ) {
71 $list_key = $list_screen->get_key(); 57 $params['uninitialized_list_screens'][ $list_screen->get_key() ] = [
72 58 'screen_link' => add_query_arg( [ DefaultColumns::QUERY_PARAM => '1' ], $list_screen->get_screen_link() ),
73 if ( $this->default_columns->exists( $list_key ) ) {
74 continue;
75 }
76
77 $params['uninitialized_list_screens'][ $list_key ] = [
78 'screen_link' => add_query_arg( [ 'save-default-headings' => '1', 'list_screen' => $list_key ], $list_screen->get_screen_link() ),
79 'label' => $list_screen->get_label(),
80 ]; 59 ];
81 } 60 }
82 61
......
1 <?php
2 declare( strict_types=1 );
3
4 namespace AC\Admin;
5
6 use AC\DefaultColumnsRepository;
7 use AC\ListScreen;
8 use AC\ListScreenFactoryInterface;
9 use AC\Table\ListKeysFactoryInterface;
10 use AC\Type\ListKey;
11
12 class ListScreenUninitialized {
13
14 private $default_storage;
15
16 private $list_screen_factory;
17
18 private $list_keys_factory;
19
20 public function __construct(
21 DefaultColumnsRepository $storage,
22 ListScreenFactoryInterface $list_screen_factory,
23 ListKeysFactoryInterface $list_keys_factory
24 ) {
25 $this->default_storage = $storage;
26 $this->list_screen_factory = $list_screen_factory;
27 $this->list_keys_factory = $list_keys_factory;
28 }
29
30 public function find( ListKey $list_key ): ?ListScreen {
31 if ( $this->default_storage->exists( (string) $list_key ) ) {
32 return null;
33 }
34
35 if ( ! $this->list_screen_factory->can_create( (string) $list_key ) ) {
36 return null;
37 }
38
39 return $this->list_screen_factory->create( (string) $list_key );
40 }
41
42 public function find_all(): array {
43 $list_keys = $this->list_keys_factory->create()->all();
44 $list_screens = array_map( [ $this, 'find' ], $list_keys );
45
46 return array_filter( $list_screens );
47 }
48
49 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace AC\Admin;
4
5 interface MenuListFactory {
6
7 public function create(): MenuListItems;
8
9 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace AC\Admin\MenuListFactory;
5
6 use AC\Admin\MenuListFactory;
7 use AC\Admin\MenuListItems;
8 use AC\Admin\Type\MenuListItem;
9 use AC\ListScreen;
10 use AC\ListScreenFactory;
11 use AC\Table\ListKeysFactoryInterface;
12
13 class MenuFactory implements MenuListFactory {
14
15 private $list_keys_factory;
16
17 private $list_screen_factory;
18
19 public function __construct( ListKeysFactoryInterface $factory, ListScreenFactory $list_screen_factory ) {
20 $this->list_keys_factory = $factory;
21 $this->list_screen_factory = $list_screen_factory;
22 }
23
24 private function create_menu_item( ListScreen $list_screen ): MenuListItem {
25 $group = (string) apply_filters( 'ac/admin/menu_group', $list_screen->get_group(), $list_screen );
26
27 return new MenuListItem(
28 $list_screen->get_key(),
29 $list_screen->get_label(),
30 $group ?: 'other'
31 );
32 }
33
34 public function create(): MenuListItems {
35 $menu = new MenuListItems();
36
37 foreach ( $this->list_keys_factory->create()->all() as $list_key ) {
38 if ( $list_key->is_network() ) {
39 continue;
40 }
41
42 if ( $this->list_screen_factory->can_create( (string) $list_key ) ) {
43 $menu->add( $this->create_menu_item( $this->list_screen_factory->create( (string) $list_key ) ) );
44 }
45 }
46
47 do_action( 'ac/admin/menu_list', $menu );
48
49 return $menu;
50 }
51
52 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace AC\Admin;
5
6 use AC\Admin\Type\MenuListItem;
7
8 class MenuListItems {
9
10 /**
11 * @var MenuListItem[]
12 */
13 private $items = [];
14
15 public function __construct( array $items = [] ) {
16 array_map( [ $this, 'add' ], $items );
17 }
18
19 public function add( MenuListItem $item ): void {
20 $this->items[ $item->get_key() ] = $item;
21 }
22
23 public function get( string $key ): ?MenuListItem {
24 return $this->items[ $key ] ?? null;
25 }
26
27 public function remove( MenuListItem $item ): void {
28 unset( $this->items[ $item->get_key() ] );
29 }
30
31 /**
32 * @return MenuListItem[]
33 */
34 public function all(): array {
35 return $this->items;
36 }
37
38 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -10,51 +10,77 @@ use AC\Admin\PageFactoryInterface; ...@@ -10,51 +10,77 @@ use AC\Admin\PageFactoryInterface;
10 use AC\Admin\Preference; 10 use AC\Admin\Preference;
11 use AC\Admin\Section; 11 use AC\Admin\Section;
12 use AC\Asset\Location; 12 use AC\Asset\Location;
13 use AC\Controller\Middleware;
13 use AC\DefaultColumnsRepository; 14 use AC\DefaultColumnsRepository;
15 use AC\ListScreenFactory;
14 use AC\ListScreenRepository\Storage; 16 use AC\ListScreenRepository\Storage;
17 use AC\Request;
18 use AC\Table\ListKeysFactoryInterface;
19 use InvalidArgumentException;
15 20
16 class Columns implements PageFactoryInterface { 21 class Columns implements PageFactoryInterface {
17 22
18 /**
19 * @var Storage
20 */
21 protected $storage; 23 protected $storage;
22 24
23 /**
24 * @var Location\Absolute
25 */
26 protected $location; 25 protected $location;
27 26
28 /**
29 * @var MenuFactoryInterface
30 */
31 protected $menu_factory; 27 protected $menu_factory;
32 28
33 /** 29 protected $list_screen_factory;
34 * @var bool 30
35 */ 31 protected $list_screen_uninitialized;
32
33 private $menu_list_factory;
34
35 private $list_keys_factory;
36
36 private $is_acp_active; 37 private $is_acp_active;
37 38
38 public function __construct( 39 public function __construct(
39 Storage $storage, 40 Storage $storage,
40 Location\Absolute $location, 41 Location\Absolute $location,
41 MenuFactoryInterface $menu_factory, 42 MenuFactoryInterface $menu_factory,
43 ListScreenFactory $list_screen_factory,
44 Admin\ListScreenUninitialized $list_screen_uninitialized,
45 Admin\MenuListFactory $menu_list_factory,
46 ListKeysFactoryInterface $list_keys_factory,
42 bool $is_acp_active 47 bool $is_acp_active
43 ) { 48 ) {
44 $this->storage = $storage; 49 $this->storage = $storage;
45 $this->location = $location; 50 $this->location = $location;
46 $this->menu_factory = $menu_factory; 51 $this->menu_factory = $menu_factory;
52 $this->list_screen_factory = $list_screen_factory;
53 $this->list_screen_uninitialized = $list_screen_uninitialized;
54 $this->menu_list_factory = $menu_list_factory;
55 $this->list_keys_factory = $list_keys_factory;
47 $this->is_acp_active = $is_acp_active; 56 $this->is_acp_active = $is_acp_active;
48 } 57 }
49 58
50 public function create() { 59 public function create() {
60 $request = new Request();
61
62 $request->add_middleware(
63 new Middleware\ListScreenAdmin(
64 $this->storage,
65 new Preference\ListScreen(),
66 $this->list_screen_factory,
67 $this->list_keys_factory
68 )
69 );
70
71 $list_screen = $request->get( 'list_screen' );
72
73 if ( ! $list_screen ) {
74 throw new InvalidArgumentException( 'Invalid screen.' );
75 }
76
51 return new Page\Columns( 77 return new Page\Columns(
52 $this->location, 78 $this->location,
79 $list_screen,
53 new DefaultColumnsRepository(), 80 new DefaultColumnsRepository(),
54 new Section\Partial\Menu(), 81 $this->list_screen_uninitialized,
55 $this->storage, 82 new Section\Partial\Menu( $this->menu_list_factory ),
56 new Admin\View\Menu( $this->menu_factory->create( 'columns' ) ), 83 new Admin\View\Menu( $this->menu_factory->create( 'columns' ) ),
57 new Preference\ListScreen(),
58 $this->is_acp_active 84 $this->is_acp_active
59 ); 85 );
60 } 86 }
......
...@@ -12,14 +12,8 @@ class PageRequestHandler implements RequestHandlerInterface { ...@@ -12,14 +12,8 @@ class PageRequestHandler implements RequestHandlerInterface {
12 */ 12 */
13 private $factories; 13 private $factories;
14 14
15 /** 15 public function add( string $slug, PageFactoryInterface $factory ): self {
16 * @param string $slug 16 $this->factories[ $slug ] = $factory;
17 * @param PageFactoryInterface $factory
18 *
19 * @return $this
20 */
21 public function add( $slug, PageFactoryInterface $factory ) {
22 $this->factories[ (string) $slug ] = $factory;
23 17
24 return $this; 18 return $this;
25 } 19 }
......
...@@ -2,61 +2,43 @@ ...@@ -2,61 +2,43 @@
2 2
3 namespace AC\Admin\Section\Partial; 3 namespace AC\Admin\Section\Partial;
4 4
5 use AC\ListScreen; 5 use AC\Admin\MenuListFactory;
6 use AC\ListScreenGroups; 6 use AC\ListScreenGroupsFactory;
7 use AC\ListScreenTypes;
8 use AC\View; 7 use AC\View;
9 8
10 class Menu { 9 class Menu {
11 10
12 /** @var bool */ 11 private $menu_factory;
13 private $is_network;
14 12
15 public function __construct( $is_network = false ) { 13 public function __construct( MenuListFactory $menu_factory ) {
16 $this->is_network = (bool) $is_network; 14 $this->menu_factory = $menu_factory;
17 } 15 }
18 16
19 public function render( ListScreen $list_screen, $is_hidden = false ) { 17 public function render( string $current, string $url, bool $is_hidden = false ): string {
20 $menu = new View( [ 18 $menu = new View( [
21 'items' => $this->get_grouped_list_screens(), 19 'items' => $this->get_menu_items(),
22 'current' => $list_screen->get_key(), 20 'current' => $current,
23 'screen_link' => $list_screen->get_screen_link(), 21 'screen_link' => $url,
24 'class' => $is_hidden ? 'hidden' : '', 22 'class' => $is_hidden ? 'hidden' : '',
25 ] ); 23 ] );
26 24
27 $menu->set_template( 'admin/edit-menu' ); 25 return $menu->set_template( 'admin/edit-menu' )
28 26 ->render();
29 return $menu->render();
30 }
31
32 private function get_network_list_screens() {
33 return ListScreenTypes::instance()->get_list_screens( [ 'network_only' => true ] );
34 } 27 }
35 28
36 private function get_site_list_screens() { 29 private function get_menu_items(): array {
37 return ListScreenTypes::instance()->get_list_screens( [ 'site_only' => true ] ); 30 $items = [];
38 }
39
40 /**
41 * @return array
42 */
43 private function get_grouped_list_screens() {
44
45 $list_screens = $this->is_network
46 ? $this->get_network_list_screens()
47 : $this->get_site_list_screens();
48 31
49 $list_screens_grouped = []; 32 foreach ( $this->menu_factory->create()->all() as $item ) {
50 foreach ( $list_screens as $list_screen ) { 33 $items[ $item->get_group() ][ $item->get_key() ] = $item->get_label();
51 $list_screens_grouped[ $list_screen->get_group() ][ $list_screen->get_key() ] = $list_screen->get_label();
52 } 34 }
53 35
54 $grouped = []; 36 $grouped = [];
55 37
56 foreach ( ListScreenGroups::get_groups()->get_groups_sorted() as $group ) { 38 foreach ( ListScreenGroupsFactory::create()->get_all() as $group ) {
57 $slug = $group['slug']; 39 $slug = $group['slug'];
58 40
59 if ( empty( $list_screens_grouped[ $slug ] ) ) { 41 if ( empty( $items[ $slug ] ) ) {
60 continue; 42 continue;
61 } 43 }
62 44
...@@ -64,11 +46,11 @@ class Menu { ...@@ -64,11 +46,11 @@ class Menu {
64 $grouped[ $slug ]['title'] = $group['label']; 46 $grouped[ $slug ]['title'] = $group['label'];
65 } 47 }
66 48
67 natcasesort( $list_screens_grouped[ $slug ] ); 49 natcasesort( $items[ $slug ] );
68 50
69 $grouped[ $slug ]['options'] = $list_screens_grouped[ $slug ]; 51 $grouped[ $slug ]['options'] = $items[ $slug ];
70 52
71 unset( $list_screens_grouped[ $slug ] ); 53 unset( $items[ $slug ] );
72 } 54 }
73 55
74 return $grouped; 56 return $grouped;
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.