aef5a431 by Jeff Balicki

Plugin update

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent fd4fb5eb
Showing 1000 changed files with 1752 additions and 180 deletions

Too many changes to show.

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

...@@ -11,13 +11,13 @@ class Admin extends AC\Asset\Script { ...@@ -11,13 +11,13 @@ class Admin extends AC\Asset\Script {
11 */ 11 */
12 private $assets_url; 12 private $assets_url;
13 13
14 public function __construct( $handle, AC\Asset\Location\Absolute $location ) { 14 public function __construct( string $handle, AC\Asset\Location\Absolute $location ) {
15 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) ); 15 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) );
16 16
17 $this->assets_url = $location->with_suffix( 'assets/' )->get_url(); 17 $this->assets_url = $location->with_suffix( 'assets/' )->get_url();
18 } 18 }
19 19
20 public function register() { 20 public function register(): void {
21 parent::register(); 21 parent::register();
22 22
23 $this->add_inline_variable( 'aca_acf_admin', [ 23 $this->add_inline_variable( 'aca_acf_admin', [
......
...@@ -9,7 +9,9 @@ use ACP\Export\Model\StrippedValue; ...@@ -9,7 +9,9 @@ use ACP\Export\Model\StrippedValue;
9 class Unsupported extends Column { 9 class Unsupported extends Column {
10 10
11 public function get_value( $id ) { 11 public function get_value( $id ) {
12 return (string) get_field( $this->get_meta_key(), $id ); 12 $value = get_field( $this->get_meta_key(), $id );
13
14 return is_scalar( $value ) ? (string) $value : __( 'Unsupported value format', 'codepress-admin-columns' );
13 } 15 }
14 16
15 public function export() { 17 public function export() {
......
...@@ -41,6 +41,7 @@ class ModelFactory implements EditingModelFactory { ...@@ -41,6 +41,7 @@ class ModelFactory implements EditingModelFactory {
41 case FieldType::TYPE_RADIO: 41 case FieldType::TYPE_RADIO:
42 case FieldType::TYPE_RANGE: 42 case FieldType::TYPE_RANGE:
43 case FieldType::TYPE_TEXT: 43 case FieldType::TYPE_TEXT:
44 case FieldType::TYPE_TIME_PICKER:
44 case FieldType::TYPE_TEXTAREA: 45 case FieldType::TYPE_TEXTAREA:
45 case FieldType::TYPE_URL: 46 case FieldType::TYPE_URL:
46 case FieldType::TYPE_OEMBED: 47 case FieldType::TYPE_OEMBED:
...@@ -88,15 +89,23 @@ class ModelFactory implements EditingModelFactory { ...@@ -88,15 +89,23 @@ class ModelFactory implements EditingModelFactory {
88 : new ACP\Editing\Service\User( $view, $storage, $paginated ); 89 : new ACP\Editing\Service\User( $view, $storage, $paginated );
89 90
90 case FieldType::TYPE_RELATIONSHIP: 91 case FieldType::TYPE_RELATIONSHIP:
92 $tax_query = $field instanceof Field\TaxonomyFilterable
93 ? $this->get_related_tax_query( $field->get_taxonomies() )
94 : [];
95
91 return new ACP\Editing\Service\Posts( 96 return new ACP\Editing\Service\Posts(
92 $this->view_factory->create( $field ), 97 $this->view_factory->create( $field ),
93 $this->storage_factory->create( $column ), 98 $this->storage_factory->create( $column ),
94 new PaginatedOptions\Posts( $field instanceof Field\PostTypeFilterable ? $field->get_post_type() : [ 'any' ] ) 99 new PaginatedOptions\Posts( $field instanceof Field\PostTypeFilterable ? $field->get_post_type() : [ 'any' ], [ 'tax_query' => $tax_query ] )
95 ); 100 );
96 101
97 case FieldType::TYPE_POST: 102 case FieldType::TYPE_POST:
98 case FieldType::TYPE_PAGE_LINK: 103 case FieldType::TYPE_PAGE_LINK:
99 $paginated = new PaginatedOptions\Posts( $field instanceof Field\PostTypeFilterable ? $field->get_post_type() : [ 'any' ] ); 104 $tax_query = $field instanceof Field\TaxonomyFilterable
105 ? $this->get_related_tax_query( $field->get_taxonomies() )
106 : [];
107
108 $paginated = new PaginatedOptions\Posts( $field instanceof Field\PostTypeFilterable ? $field->get_post_type() : [ 'any' ], [ 'tax_query' => $tax_query ] );
100 $view = $this->view_factory->create( $field ); 109 $view = $this->view_factory->create( $field );
101 $storage = $this->storage_factory->create( $column ); 110 $storage = $this->storage_factory->create( $column );
102 111
...@@ -117,4 +126,18 @@ class ModelFactory implements EditingModelFactory { ...@@ -117,4 +126,18 @@ class ModelFactory implements EditingModelFactory {
117 return false; 126 return false;
118 } 127 }
119 128
129 private function get_related_tax_query( array $terms ): array {
130 $tax_query = [ 'relation' => 'OR' ];
131
132 foreach ( $terms as $term ) {
133 $tax_query[] = [
134 'taxonomy' => $term->taxonomy,
135 'field' => 'slug',
136 'terms' => $term->slug,
137 ];
138 }
139
140 return $tax_query;
141 }
142
120 } 143 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,11 +2,18 @@ ...@@ -2,11 +2,18 @@
2 2
3 namespace ACA\ACF\Export\Model; 3 namespace ACA\ACF\Export\Model;
4 4
5 use AC\Column;
5 use ACA; 6 use ACA;
6 use ACP; 7 use ACP;
7 use DateTime; 8 use DateTime;
8 9
9 class Date extends ACP\Export\Model { 10 class Date implements ACP\Export\Service {
11
12 private $column;
13
14 public function __construct( Column $column ) {
15 $this->column = $column;
16 }
10 17
11 public function get_value( $id ) { 18 public function get_value( $id ) {
12 $value = $this->column->get_raw_value( $id ); 19 $value = $this->column->get_raw_value( $id );
...@@ -17,7 +24,9 @@ class Date extends ACP\Export\Model { ...@@ -17,7 +24,9 @@ class Date extends ACP\Export\Model {
17 24
18 $date = DateTime::createFromFormat( 'Ymd', $value ); 25 $date = DateTime::createFromFormat( 'Ymd', $value );
19 26
20 return $date ? $date->format( 'Y-m-d' ) : ''; 27 return $date
28 ? $date->format( 'Y-m-d' )
29 : '';
21 } 30 }
22 31
23 } 32 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,19 +2,22 @@ ...@@ -2,19 +2,22 @@
2 2
3 namespace ACA\ACF\Export\Model; 3 namespace ACA\ACF\Export\Model;
4 4
5 use AC\Column;
5 use ACA; 6 use ACA;
6 use ACP; 7 use ACP;
7 8
8 class Link extends ACP\Export\Model { 9 class Link implements ACP\Export\Service {
10
11 private $column;
12
13 public function __construct( Column $column ) {
14 $this->column = $column;
15 }
9 16
10 public function get_value( $id ) { 17 public function get_value( $id ) {
11 $link = $this->column->get_raw_value( $id ); 18 $link = $this->column->get_raw_value( $id );
12 19
13 if ( empty( $link ) ) { 20 return $link['url'] ?? '';
14 return '';
15 }
16
17 return $link['url'];
18 } 21 }
19 22
20 } 23 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,18 +6,17 @@ use ACA; ...@@ -6,18 +6,17 @@ use ACA;
6 use ACA\ACF\Column; 6 use ACA\ACF\Column;
7 use ACP; 7 use ACP;
8 8
9 /** 9 class RepeaterSubField implements ACP\Export\Service {
10 * @property Column/Repeater $column 10
11 */ 11 private $column;
12 class RepeaterSubField extends ACP\Export\Model {
13 12
14 public function __construct( Column\Repeater $column ) { 13 public function __construct( Column\Repeater $column ) {
15 parent::__construct( $column ); 14 $this->column = $column;
16 } 15 }
17 16
18 public function get_value( $id ) { 17 public function get_value( $id ) {
19 $value = $this->column->get_value( $id ); 18 $value = $this->column->get_value( $id );
20 $delimiter = apply_filters( 'acp/acf/export/repeater/delimiter', ';', $this->column ); 19 $delimiter = (string) apply_filters( 'acp/acf/export/repeater/delimiter', ';', $this->column );
21 20
22 return strip_tags( str_replace( $this->column->get_separator(), $delimiter, $value ) ); 21 return strip_tags( str_replace( $this->column->get_separator(), $delimiter, $value ) );
23 } 22 }
......
...@@ -9,14 +9,12 @@ use ACP; ...@@ -9,14 +9,12 @@ use ACP;
9 9
10 class ModelFactory { 10 class ModelFactory {
11 11
12 public function create( $type, AC\Column $column ) { 12 public function create( string $type, AC\Column $column ): ACP\Export\Service {
13 switch ( $type ) { 13 switch ( $type ) {
14 case FieldType::TYPE_DATE_PICKER: 14 case FieldType::TYPE_DATE_PICKER:
15 return new Model\Date( $column ); 15 return new Model\Date( $column );
16
17 case FieldType::TYPE_LINK: 16 case FieldType::TYPE_LINK:
18 return new Model\Link( $column ); 17 return new Model\Link( $column );
19
20 case FieldType::TYPE_BUTTON_GROUP: 18 case FieldType::TYPE_BUTTON_GROUP:
21 case FieldType::TYPE_SELECT: 19 case FieldType::TYPE_SELECT:
22 case FieldType::TYPE_RADIO: 20 case FieldType::TYPE_RADIO:
...@@ -31,7 +29,6 @@ class ModelFactory { ...@@ -31,7 +29,6 @@ class ModelFactory {
31 case FieldType::TYPE_GALLERY: 29 case FieldType::TYPE_GALLERY:
32 case FieldType::TYPE_IMAGE: 30 case FieldType::TYPE_IMAGE:
33 return new ACP\Export\Model\CustomField\Image( $column ); 31 return new ACP\Export\Model\CustomField\Image( $column );
34
35 default: 32 default:
36 return new ACP\Export\Model\RawValue( $column ); 33 return new ACP\Export\Model\RawValue( $column );
37 } 34 }
......
...@@ -4,9 +4,6 @@ namespace ACA\ACF\Field; ...@@ -4,9 +4,6 @@ namespace ACA\ACF\Field;
4 4
5 interface TaxonomyFilterable { 5 interface TaxonomyFilterable {
6 6
7 /** 7 public function get_taxonomies(): array;
8 * @return array
9 */
10 public function get_taxonomies();
11 8
12 } 9 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,7 +6,7 @@ use WP_Term; ...@@ -6,7 +6,7 @@ use WP_Term;
6 6
7 trait TaxonomyFilterableTrait { 7 trait TaxonomyFilterableTrait {
8 8
9 public function get_taxonomies() { 9 public function get_taxonomies(): array {
10 if ( empty( $this->settings['taxonomy'] ) ) { 10 if ( empty( $this->settings['taxonomy'] ) ) {
11 return []; 11 return [];
12 } 12 }
......
...@@ -8,7 +8,7 @@ use ACA\ACF\Value\Formatter; ...@@ -8,7 +8,7 @@ use ACA\ACF\Value\Formatter;
8 class DefaultFormatter extends Formatter { 8 class DefaultFormatter extends Formatter {
9 9
10 public function format( $value, $id = null ) { 10 public function format( $value, $id = null ) {
11 if ( empty( $value ) ) { 11 if ( empty( $value ) && ! is_numeric( $value ) ) {
12 return $this->column->get_empty_char(); 12 return $this->column->get_empty_char();
13 } 13 }
14 14
......
...@@ -31,7 +31,7 @@ class Maps extends Formatter { ...@@ -31,7 +31,7 @@ class Maps extends Formatter {
31 return add_query_arg( 31 return add_query_arg(
32 [ 32 [
33 'query' => implode( ',', $arguments ), 33 'query' => implode( ',', $arguments ),
34 'zoom' => $data['zoom'] ?: 15, 34 'zoom' => $data['zoom'] ?? 15,
35 ], 35 ],
36 $base 36 $base
37 ); 37 );
......
...@@ -14,15 +14,13 @@ class Select extends Formatter { ...@@ -14,15 +14,13 @@ class Select extends Formatter {
14 ? $this->field->get_choices() 14 ? $this->field->get_choices()
15 : []; 15 : [];
16 16
17 if ( empty( $value ) ) {
18 return $this->column->get_empty_char();
19 }
20
21 $result = []; 17 $result = [];
22 foreach ( (array) $value as $v ) { 18 foreach ( (array) $value as $v ) {
23 $result[] = isset( $labels[ $v ] ) 19 $result[] = $labels[ $v ] ?? $v;
24 ? $labels[ $v ] 20 }
25 : $v; 21
22 if ( empty( $result ) ) {
23 return $this->column->get_empty_char();
26 } 24 }
27 25
28 $separator = $this->column->get_separator(); 26 $separator = $this->column->get_separator();
......
...@@ -11,18 +11,18 @@ class Admin extends AC\Asset\Script { ...@@ -11,18 +11,18 @@ class Admin extends AC\Asset\Script {
11 */ 11 */
12 private $assets_url; 12 private $assets_url;
13 13
14 public function __construct( $handle, AC\Asset\Location\Absolute $location) { 14 public function __construct( string $handle, AC\Asset\Location\Absolute $location ) {
15 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) ); 15 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) );
16 16
17 $this->assets_url = $location->with_suffix( 'assets/' )->get_url(); 17 $this->assets_url = $location->with_suffix( 'assets/' )->get_url();
18 } 18 }
19 19
20 public function register() { 20 public function register(): void {
21 parent::register(); 21 parent::register();
22 22
23 $this->add_inline_variable( 'aca_bp_admin', [ 23 $this->add_inline_variable( 'aca_bp_admin', [
24 'assets' => $this->assets_url . '/' 24 'assets' => $this->assets_url . '/',
25 ]); 25 ] );
26 } 26 }
27 27
28 } 28 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -8,10 +8,12 @@ use ACP; ...@@ -8,10 +8,12 @@ use ACP;
8 /** 8 /**
9 * @property Column\Profile $column 9 * @property Column\Profile $column
10 */ 10 */
11 class MultipleValues extends ACP\Export\Model { 11 class MultipleValues implements ACP\Export\Service {
12
13 private $column;
12 14
13 public function __construct( Column\Profile $column ) { 15 public function __construct( Column\Profile $column ) {
14 parent::__construct( $column ); 16 $this->column = $column;
15 } 17 }
16 18
17 public function get_value( $id ) { 19 public function get_value( $id ) {
......
...@@ -12,13 +12,13 @@ class Admin extends Script { ...@@ -12,13 +12,13 @@ class Admin extends Script {
12 */ 12 */
13 private $assets_url; 13 private $assets_url;
14 14
15 public function __construct( $handle, AC\Asset\Location\Absolute $location ) { 15 public function __construct( string $handle, AC\Asset\Location\Absolute $location ) {
16 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) ); 16 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) );
17 17
18 $this->assets_url = $location->with_suffix( 'assets/' )->get_url(); 18 $this->assets_url = $location->with_suffix( 'assets/' )->get_url();
19 } 19 }
20 20
21 public function register() { 21 public function register(): void {
22 parent::register(); 22 parent::register();
23 23
24 $this->add_inline_variable( 'aca_ec_admin', [ 24 $this->add_inline_variable( 'aca_ec_admin', [
......
...@@ -33,7 +33,7 @@ class Categories extends AC\Column ...@@ -33,7 +33,7 @@ class Categories extends AC\Column
33 } 33 }
34 34
35 public function export() { 35 public function export() {
36 return new ACP\Export\Model\Post\Taxonomy( $this ); 36 return new ACP\Export\Model\Post\Taxonomy( $this->get_taxonomy() );
37 } 37 }
38 38
39 public function search() { 39 public function search() {
......
...@@ -15,7 +15,7 @@ class Events extends AC\Column implements ACP\Export\Exportable { ...@@ -15,7 +15,7 @@ class Events extends AC\Column implements ACP\Export\Exportable {
15 } 15 }
16 16
17 public function export() { 17 public function export() {
18 return new Export\Model\EventSeries\Events( $this ); 18 return new Export\Model\EventSeries\Events( );
19 } 19 }
20 20
21 } 21 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,18 +2,23 @@ ...@@ -2,18 +2,23 @@
2 2
3 namespace ACA\EC\Export\Model\Event; 3 namespace ACA\EC\Export\Model\Event;
4 4
5 use AC\Column;
5 use ACP; 6 use ACP;
6 7
7 /** 8 class AllDayEvent implements ACP\Export\Service {
8 * Export Model for AllDayEvent column 9
9 * @since 1.0.2 10 private $column;
10 */ 11
11 class AllDayEvent extends ACP\Export\Model { 12 public function __construct( Column $column ) {
13 $this->column = $column;
14 }
12 15
13 public function get_value( $id ) { 16 public function get_value( $id ) {
14 $value = $this->column->get_raw_value( $id ); 17 $value = $this->column->get_raw_value( $id );
15 18
16 return $value ? 1 : ''; 19 return $value
20 ? '1'
21 : '';
17 } 22 }
18 23
19 } 24 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -9,10 +9,10 @@ use TEC; ...@@ -9,10 +9,10 @@ use TEC;
9 * Export Model for AllDayEvent column 9 * Export Model for AllDayEvent column
10 * @since 1.0.2 10 * @since 1.0.2
11 */ 11 */
12 class Events extends ACP\Export\Model { 12 class Events implements ACP\Export\Service {
13 13
14 public function get_value( $id ) { 14 public function get_value( $id ): string {
15 if ( ! class_exists( 'TEC\Events_Pro\Custom_Tables\V1\Repository\Events' ) || ! function_exists( 'tribe' ) ) { 15 if ( ! class_exists( TEC\Events_Pro\Custom_Tables\V1\Repository\Events::class ) || ! function_exists( 'tribe' ) ) {
16 return ''; 16 return '';
17 } 17 }
18 18
......
...@@ -2,22 +2,23 @@ ...@@ -2,22 +2,23 @@
2 2
3 namespace ACA\EC\Export\Model; 3 namespace ACA\EC\Export\Model;
4 4
5 use AC\Column;
5 use ACP; 6 use ACP;
6 7
7 /** 8 class UpcomingEvent implements ACP\Export\Service {
8 * Export Model for Upcoming Event column 9
9 * @since 1.0.2 10 private $column;
10 */ 11
11 class UpcomingEvent extends ACP\Export\Model { 12 public function __construct( Column $column ) {
13 $this->column = $column;
14 }
12 15
13 public function get_value( $id ) { 16 public function get_value( $id ) {
14 $event_id = $this->column->get_raw_value( $id ); 17 $event_id = $this->column->get_raw_value( $id );
15 18
16 if ( ! $event_id ) { 19 return $event_id
17 return false; 20 ? get_the_title( (int) $event_id )
18 } 21 : '';
19
20 return get_the_title( $event_id );
21 } 22 }
22 23
23 } 24 }
...\ 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\EC\Service; 3 namespace ACA\EC\Service;
4 4
5 use AC;
5 use AC\Asset\Location; 6 use AC\Asset\Location;
6 use AC\Asset\Style; 7 use AC\Asset\Style;
7 use AC\Registerable; 8 use AC\Registerable;
...@@ -38,7 +39,7 @@ class TableScreen implements Registerable { ...@@ -38,7 +39,7 @@ class TableScreen implements Registerable {
38 add_action( 'parse_query', [ $this, 'parse_query' ], 51 ); 39 add_action( 'parse_query', [ $this, 'parse_query' ], 51 );
39 } 40 }
40 41
41 public function table_scripts() { 42 public function table_scripts(): void {
42 $script = new Style( 'aca-ec-table', $this->location->with_suffix( 'assets/css/table.css' ) ); 43 $script = new Style( 'aca-ec-table', $this->location->with_suffix( 'assets/css/table.css' ) );
43 $script->enqueue(); 44 $script->enqueue();
44 } 45 }
...@@ -46,7 +47,7 @@ class TableScreen implements Registerable { ...@@ -46,7 +47,7 @@ class TableScreen implements Registerable {
46 /** 47 /**
47 * @param WP_Query $query 48 * @param WP_Query $query
48 */ 49 */
49 public function parse_query( WP_Query $query ) { 50 public function parse_query( WP_Query $query ): void {
50 if ( 'tribe_events' !== $query->get( 'post_type' ) ) { 51 if ( 'tribe_events' !== $query->get( 'post_type' ) ) {
51 return; 52 return;
52 } 53 }
...@@ -59,7 +60,7 @@ class TableScreen implements Registerable { ...@@ -59,7 +60,7 @@ class TableScreen implements Registerable {
59 $query->tribe_is_event = false; 60 $query->tribe_is_event = false;
60 } 61 }
61 62
62 public function add_events_filter_vars( $list_screen ) { 63 public function add_events_filter_vars( $list_screen ): void {
63 if ( ! $list_screen instanceof ListScreen\Event ) { 64 if ( ! $list_screen instanceof ListScreen\Event ) {
64 return; 65 return;
65 } 66 }
...@@ -151,7 +152,7 @@ class TableScreen implements Registerable { ...@@ -151,7 +152,7 @@ class TableScreen implements Registerable {
151 /** 152 /**
152 * @param WP_Query $wp_query 153 * @param WP_Query $wp_query
153 */ 154 */
154 public function events_query_callback( WP_Query $wp_query ) { 155 public function events_query_callback( WP_Query $wp_query ): void {
155 if ( ! $wp_query->is_main_query() ) { 156 if ( ! $wp_query->is_main_query() ) {
156 return; 157 return;
157 } 158 }
...@@ -159,7 +160,7 @@ class TableScreen implements Registerable { ...@@ -159,7 +160,7 @@ class TableScreen implements Registerable {
159 $wp_query->query_vars = array_merge( $wp_query->query_vars, $this->filter_vars ); 160 $wp_query->query_vars = array_merge( $wp_query->query_vars, $this->filter_vars );
160 } 161 }
161 162
162 public function display_notices() { 163 public function display_notices(): void {
163 foreach ( $this->notices as $notice ) : ?> 164 foreach ( $this->notices as $notice ) : ?>
164 <div class="notice notice-<?php echo $notice['type']; ?> notice-aca-ec-filter"> 165 <div class="notice notice-<?php echo $notice['type']; ?> notice-aca-ec-filter">
165 <div class="info"> 166 <div class="info">
...@@ -169,7 +170,7 @@ class TableScreen implements Registerable { ...@@ -169,7 +170,7 @@ class TableScreen implements Registerable {
169 <?php endforeach; 170 <?php endforeach;
170 } 171 }
171 172
172 private function filter_on_venue( $value ) { 173 private function filter_on_venue( $value ): void {
173 $column = new Column\Event\Venue(); 174 $column = new Column\Event\Venue();
174 175
175 $this->filter_vars['meta_query'][] = [ 176 $this->filter_vars['meta_query'][] = [
...@@ -178,7 +179,7 @@ class TableScreen implements Registerable { ...@@ -178,7 +179,7 @@ class TableScreen implements Registerable {
178 ]; 179 ];
179 } 180 }
180 181
181 private function filter_on_organizer( $value ) { 182 private function filter_on_organizer( $value ): void {
182 $column = new Column\Event\Organizer(); 183 $column = new Column\Event\Organizer();
183 184
184 $this->filter_vars['meta_query'][] = [ 185 $this->filter_vars['meta_query'][] = [
...@@ -187,7 +188,7 @@ class TableScreen implements Registerable { ...@@ -187,7 +188,7 @@ class TableScreen implements Registerable {
187 ]; 188 ];
188 } 189 }
189 190
190 private function filter_on_past_events() { 191 private function filter_on_past_events(): void {
191 $column = new Column\Event\EndDate(); 192 $column = new Column\Event\EndDate();
192 193
193 $this->filter_vars['meta_query'][] = [ 194 $this->filter_vars['meta_query'][] = [
...@@ -197,7 +198,7 @@ class TableScreen implements Registerable { ...@@ -197,7 +198,7 @@ class TableScreen implements Registerable {
197 ]; 198 ];
198 } 199 }
199 200
200 private function filter_on_future_events() { 201 private function filter_on_future_events(): void {
201 $column = new Column\Event\StartDate(); 202 $column = new Column\Event\StartDate();
202 203
203 $this->filter_vars['meta_query'][] = [ 204 $this->filter_vars['meta_query'][] = [
...@@ -207,7 +208,7 @@ class TableScreen implements Registerable { ...@@ -207,7 +208,7 @@ class TableScreen implements Registerable {
207 ]; 208 ];
208 } 209 }
209 210
210 public function register_event_sorting_fix( \AC\ListScreen $list_screen ) { 211 public function register_event_sorting_fix( AC\ListScreen $list_screen ): void {
211 if ( $list_screen instanceof ListScreen\Event ) { 212 if ( $list_screen instanceof ListScreen\Event ) {
212 $service = new Sorting\EventSortingFix( $list_screen ); 213 $service = new Sorting\EventSortingFix( $list_screen );
213 $service->register(); 214 $service->register();
......
1 !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);class r{place(){let e=o(),t=document.querySelector(".gform-settings__content"),n=document.querySelector("#ac-s");t&&n&&(t.parentElement.insertBefore(e,t),e.append(n),e.insertAdjacentHTML("beforeend",'<div class="gf-acs-button-container"><button class="button">Filter</button></div>'))}}const o=()=>{let e=document.createElement("form");e.id="gf-acs-form",e.addEventListener("submit",()=>{let t=AC_SERVICES.getService("Search").getRules();if(AC_SERVICES.getService("Search").disableFields(),0===t.rules.length)return;let n=document.createElement("input");n.type="hidden",n.name="ac-rules",n.value=JSON.stringify(t),e.append(n)});const t=new URLSearchParams(window.location.search);return["page","id"].forEach(n=>{let r=t.get(n);r&&e.insertAdjacentHTML("afterbegin",`<input type="hidden" name="${n}" value="${r}">`)}),e};document.addEventListener("DOMContentLoaded",()=>{let e=document.querySelector("#gf_form_toolbar");e&&e.insertAdjacentHTML("afterend",'<div class="wp-header-end"></div>')}),AC_SERVICES.addListener("Table.Ready",e=>{var t,n;let r=document.querySelector(".layout-switcher"),o=document.querySelector(".gform-form-toolbar__container #gform-form-toolbar__menu");if(r&&o&&o.parentElement.insertBefore(r,o),document.body.classList.contains("forms_page_gf_entries")){let e=document.querySelector(".tablenav-pages .displaying-num");if(e){let r=e.innerHTML.split(" ")[0],o=r.replace(",","").replace(".","");"undefined"!=typeof ACP_Export&&(ACP_Export.total_num_items=o),null===(n=null===(t=AC_SERVICES.getService("Editing"))||void 0===t?void 0:t.getService("BulkSelectionRow"))||void 0===n||n.setTotalItems(parseInt(o),r)}}}),AC_SERVICES.addListener("Service.Registered.Search",e=>{e.placementFactory.register("gravity_forms_entry",new r)})}]);
...\ No newline at end of file ...\ No newline at end of file
1 !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t);class n{place(){let e=o(),t=document.querySelector(".gform-settings__content"),r=document.querySelector("#ac-s");t&&r&&(t.parentElement.insertBefore(e,t),e.append(r),e.insertAdjacentHTML("beforeend",'<div class="gf-acs-button-container"><button class="button">Filter</button></div>'))}}const o=()=>{let e=document.createElement("form");e.id="gf-acs-form",e.addEventListener("submit",()=>{let t=AC_SERVICES.getService("Search").getRules();if(AC_SERVICES.getService("Search").disableFields(),0===t.rules.length)return;let r=document.createElement("input");r.type="hidden",r.name="ac-rules",r.value=JSON.stringify(t),e.append(r)});const t=new URLSearchParams(window.location.search);return["page","id"].forEach(r=>{let n=t.get(r);n&&e.insertAdjacentHTML("afterbegin",`<input type="hidden" name="${r}" value="${n}">`)}),e};document.addEventListener("DOMContentLoaded",()=>{let e=document.querySelector("#gf_form_toolbar");e&&e.insertAdjacentHTML("afterend",'<div class="wp-header-end"></div>')}),AC_SERVICES.addListener("Table.Ready",()=>{var e,t;let r=document.querySelector(".layout-switcher"),n=document.querySelector(".gform-form-toolbar__container #gform-form-toolbar__menu");if(r&&n&&n.parentElement.insertBefore(r,n),AC.list_screen.indexOf("gf_entry")>-1){let r=document.querySelector(".tablenav-pages .displaying-num");if(r){let n=r.innerHTML.split(" ")[0],o=n.replace(",","").replace(".","");"undefined"!=typeof ACP_Export&&(ACP_Export.total_num_items=o),null===(t=null===(e=AC_SERVICES.getService("Editing"))||void 0===e?void 0:e.getService("BulkSelectionRow"))||void 0===t||t.setTotalItems(parseInt(o),n)}}}),AC_SERVICES.addListener("Service.Registered.Search",e=>{e.placementFactory.register("gravity_forms_entry",new n)})}]);
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -7,6 +7,7 @@ use ACA\GravityForms\HideOnScreen\EntryFilters; ...@@ -7,6 +7,7 @@ use ACA\GravityForms\HideOnScreen\EntryFilters;
7 use ACA\GravityForms\HideOnScreen\WordPressNotifications; 7 use ACA\GravityForms\HideOnScreen\WordPressNotifications;
8 use ACA\GravityForms\ListScreen\Entry; 8 use ACA\GravityForms\ListScreen\Entry;
9 use ACP; 9 use ACP;
10 use ACP\Type\HideOnScreen\Group;
10 11
11 final class Admin implements AC\Registerable { 12 final class Admin implements AC\Registerable {
12 13
...@@ -14,11 +15,14 @@ final class Admin implements AC\Registerable { ...@@ -14,11 +15,14 @@ final class Admin implements AC\Registerable {
14 add_action( 'acp/admin/settings/hide_on_screen', [ $this, 'add_hide_on_screen' ], 10, 2 ); 15 add_action( 'acp/admin/settings/hide_on_screen', [ $this, 'add_hide_on_screen' ], 10, 2 );
15 } 16 }
16 17
17 public function add_hide_on_screen( ACP\Settings\ListScreen\HideOnScreenCollection $collection, AC\ListScreen $list_screen ) { 18 public function add_hide_on_screen(
19 ACP\Settings\ListScreen\HideOnScreenCollection $collection,
20 AC\ListScreen $list_screen
21 ) {
18 if ( $list_screen instanceof Entry ) { 22 if ( $list_screen instanceof Entry ) {
19 $collection->remove( new ACP\Settings\ListScreen\HideOnScreen\Search() ); 23 $collection->remove( new ACP\Settings\ListScreen\HideOnScreen\Search() )
20 $collection->add( new EntryFilters() ); 24 ->add( new EntryFilters(), new Group( Group::ELEMENT ) )
21 $collection->add( new WordPressNotifications() ); 25 ->add( new WordPressNotifications(), new Group( Group::ELEMENT ) );
22 } 26 }
23 27
24 } 28 }
......
...@@ -2,9 +2,16 @@ ...@@ -2,9 +2,16 @@
2 2
3 namespace ACA\GravityForms\Export\Model\Entry; 3 namespace ACA\GravityForms\Export\Model\Entry;
4 4
5 use AC\Column;
5 use ACP\Export; 6 use ACP\Export;
6 7
7 class Address extends Export\Model { 8 class Address implements Export\Service {
9
10 private $column;
11
12 public function __construct( Column $column ) {
13 $this->column = $column;
14 }
8 15
9 public function get_value( $id ) { 16 public function get_value( $id ) {
10 return strip_tags( str_replace( '<br />', '; ', $this->column->get_value( $id ) ) ); 17 return strip_tags( str_replace( '<br />', '; ', $this->column->get_value( $id ) ) );
......
...@@ -2,12 +2,21 @@ ...@@ -2,12 +2,21 @@
2 2
3 namespace ACA\GravityForms\Export\Model\Entry; 3 namespace ACA\GravityForms\Export\Model\Entry;
4 4
5 use AC\Column;
5 use ACP\Export; 6 use ACP\Export;
6 7
7 class Check extends Export\Model { 8 class Check implements Export\Service {
9
10 private $column;
11
12 public function __construct( Column $column ) {
13 $this->column = $column;
14 }
8 15
9 public function get_value( $id ) { 16 public function get_value( $id ) {
10 return $this->column->get_value( $id ) ? 'checked' : ''; 17 return $this->column->get_value( $id )
18 ? 'checked'
19 : '';
11 } 20 }
12 21
13 } 22 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,9 +2,16 @@ ...@@ -2,9 +2,16 @@
2 2
3 namespace ACA\GravityForms\Export\Model\Entry; 3 namespace ACA\GravityForms\Export\Model\Entry;
4 4
5 use AC\Column;
5 use ACP\Export; 6 use ACP\Export;
6 7
7 class ItemList extends Export\Model { 8 class ItemList implements Export\Service {
9
10 private $column;
11
12 public function __construct( Column $column ) {
13 $this->column = $column;
14 }
8 15
9 public function get_value( $id ) { 16 public function get_value( $id ) {
10 $items = unserialize( (string) $this->column->get_raw_value( $id ), [ 'allowed_classes' => false ] ); 17 $items = unserialize( (string) $this->column->get_raw_value( $id ), [ 'allowed_classes' => false ] );
......
...@@ -9,10 +9,7 @@ use ACP; ...@@ -9,10 +9,7 @@ use ACP;
9 9
10 class EntryFactory { 10 class EntryFactory {
11 11
12 /** 12 public function create( Column\Entry $column, Field\Field $field ): ACP\Export\Service {
13 * @return ACP\Export\Model
14 */
15 public function create( Column\Entry $column, Field\Field $field ) {
16 13
17 switch ( true ) { 14 switch ( true ) {
18 case $field instanceof Field\Type\Address: 15 case $field instanceof Field\Type\Address:
......
...@@ -12,13 +12,13 @@ class Admin extends Script { ...@@ -12,13 +12,13 @@ class Admin extends Script {
12 */ 12 */
13 private $assets_url; 13 private $assets_url;
14 14
15 public function __construct( $handle, AC\Asset\Location\Absolute $location ) { 15 public function __construct( string $handle, AC\Asset\Location\Absolute $location ) {
16 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) ); 16 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) );
17 17
18 $this->assets_url = $location->with_suffix( 'assets/' )->get_url(); 18 $this->assets_url = $location->with_suffix( 'assets/' )->get_url();
19 } 19 }
20 20
21 public function register() { 21 public function register(): void {
22 parent::register(); 22 parent::register();
23 23
24 $this->add_inline_variable( 'aca_jetengine_admin', [ 24 $this->add_inline_variable( 'aca_jetengine_admin', [
......
...@@ -38,7 +38,7 @@ class Meta extends AC\Column implements ACP\Export\Exportable { ...@@ -38,7 +38,7 @@ class Meta extends AC\Column implements ACP\Export\Exportable {
38 } 38 }
39 39
40 public function export() { 40 public function export() {
41 return ( new Export\ModelFactory() )->create( $this, $this->field ); 41 return ( new Export\ModelFactory() )->create( $this, $this->field ) ?: false;
42 } 42 }
43 43
44 } 44 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -9,13 +9,7 @@ use ACP; ...@@ -9,13 +9,7 @@ use ACP;
9 9
10 final class ModelFactory { 10 final class ModelFactory {
11 11
12 /** 12 public function create( Column\Meta $column, Field $field ): ?ACP\Export\Service {
13 * @param Column\Meta $column
14 * @param Field $field
15 *
16 * @return ACP\Export\Model|false
17 */
18 public function create( Column\Meta $column, Field $field ) {
19 switch ( true ) { 13 switch ( true ) {
20 case $field instanceof Type\DateTime: 14 case $field instanceof Type\DateTime:
21 case $field instanceof Type\Date: 15 case $field instanceof Type\Date:
...@@ -28,7 +22,7 @@ final class ModelFactory { ...@@ -28,7 +22,7 @@ final class ModelFactory {
28 return new ACP\Export\Model\StrippedValue( $column ); 22 return new ACP\Export\Model\StrippedValue( $column );
29 23
30 case $field instanceof Type\Repeater: 24 case $field instanceof Type\Repeater:
31 return false; 25 return null;
32 26
33 default: 27 default:
34 return new ACP\Export\Model\RawValue( $column ); 28 return new ACP\Export\Model\RawValue( $column );
......
...@@ -68,7 +68,7 @@ class RepeaterField extends Column { ...@@ -68,7 +68,7 @@ class RepeaterField extends Column {
68 } 68 }
69 } 69 }
70 70
71 return null; 71 return $this->field->get_repeated_fields()[0] ?? null;
72 } 72 }
73 73
74 protected function get_setting_field() { 74 protected function get_setting_field() {
......
1
2 <svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3 <g id="Logo-&amp;-icons" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
4 <g id="Icon-Squared-/-Select2" transform="translate(-140.000000, -580.000000)">
5 <g id="media-library-assistant" transform="translate(140.000000, 580.000000)">
6 <rect id="BG" fill="#1547AB" x="0" y="0" width="20" height="20" rx="2"></rect>
7 <path d="M12.7558594,10.2617188 L12.7558594,4.98828125 C12.7558594,4.79296875 12.6826172,4.62207031 12.5361328,4.47558594 C12.3896484,4.32910156 12.2089844,4.25585938 11.9941406,4.25585938 L10.734375,4.25585938 L9.73828125,2.76171875 L6.75,2.76171875 L5.75390625,4.25585938 L4.49414062,4.25585938 C4.29882812,4.25585938 4.12792969,4.32910156 3.98144531,4.47558594 C3.83496094,4.62207031 3.76171875,4.79296875 3.76171875,4.98828125 L3.76171875,10.2617188 C3.76171875,10.4570312 3.83496094,10.6279297 3.98144531,10.7744141 C4.12792969,10.9208984 4.29882812,10.9941406 4.49414062,10.9941406 L11.9941406,10.9941406 C12.2089844,10.9941406 12.3896484,10.9208984 12.5361328,10.7744141 C12.6826172,10.6279297 12.7558594,10.4570312 12.7558594,10.2617188 Z M8.24414062,5.36914062 C8.77148438,5.36914062 9.21582031,5.5546875 9.57714844,5.92578125 C9.93847656,6.296875 10.1191406,6.74121094 10.1191406,7.25878906 C10.1191406,7.77636719 9.93847656,8.21582031 9.57714844,8.57714844 C9.21582031,8.93847656 8.77636719,9.11914062 8.25878906,9.11914062 C7.74121094,9.11914062 7.296875,8.93847656 6.92578125,8.57714844 C6.5546875,8.21582031 6.36914062,7.77636719 6.36914062,7.25878906 C6.36914062,6.74121094 6.5546875,6.296875 6.92578125,5.92578125 C7.296875,5.5546875 7.73632812,5.36914062 8.24414062,5.36914062 Z M13.4882812,6.51171875 L17.2382812,6.51171875 L17.2382812,14.3632812 C17.2382812,14.890625 17.0576172,15.3349609 16.6962891,15.6962891 C16.3349609,16.0576172 15.8955078,16.2382812 15.3779297,16.2382812 C14.8603516,16.2382812 14.4160156,16.0576172 14.0449219,15.6962891 C13.6738281,15.3349609 13.4882812,14.8955078 13.4882812,14.3779297 C13.4882812,13.8603516 13.6738281,13.4160156 14.0449219,13.0449219 C14.4160156,12.6738281 14.8554688,12.4882812 15.3632812,12.4882812 C15.4804688,12.4882812 15.6074219,12.5078125 15.7441406,12.546875 L15.7441406,8.73828125 L13.4882812,8.73828125 L13.4882812,6.51171875 Z M10.5,12.546875 L10.5,11.7558594 L11.9941406,11.7558594 L11.9941406,14.3632812 C11.9941406,14.890625 11.8134766,15.3349609 11.4521484,15.6962891 C11.0908203,16.0576172 10.6513672,16.2382812 10.1337891,16.2382812 C9.61621094,16.2382812 9.171875,16.0576172 8.80078125,15.6962891 C8.4296875,15.3349609 8.24414062,14.8955078 8.24414062,14.3779297 C8.24414062,13.8603516 8.4296875,13.4160156 8.80078125,13.0449219 C9.171875,12.6738281 9.61132812,12.4882812 10.1191406,12.4882812 C10.2363281,12.4882812 10.3632812,12.5078125 10.5,12.546875 Z" id="MLA" fill="#FFFFFF" fill-rule="nonzero"></path>
8 </g>
9 </g>
10 </g>
11 </svg>
...\ No newline at end of file ...\ No newline at end of file
1 const isMlaColumn = result => {
2 if ( result.element ) {
3 let group = result.element.parentElement;
4
5 if ( group && 'Media Library Assistant' === group.label ) {
6 return true;
7 }
8 }
9
10 return false;
11 }
12
13 document.addEventListener( 'DOMContentLoaded', () => {
14 let bpIcon = aca_mla_admin.assets + 'images/mla.svg';
15
16 AC_SERVICES.filters.addFilter( 'column_type_templates', ( value, pl ) => {
17 if ( pl.result.hasOwnProperty( 'id' ) && isMlaColumn( pl.result ) ) {
18 value += `<img src="${bpIcon}" alt="MLA" class="ac-column-type-icon"/>`;
19 }
20
21 return value;
22 }, 10 );
23
24 } );
...\ No newline at end of file ...\ No newline at end of file
1 /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
4 /******/
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
7 /******/
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId]) {
10 /******/ return installedModules[moduleId].exports;
11 /******/ }
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
14 /******/ i: moduleId,
15 /******/ l: false,
16 /******/ exports: {}
17 /******/ };
18 /******/
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 /******/
22 /******/ // Flag the module as loaded
23 /******/ module.l = true;
24 /******/
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
27 /******/ }
28 /******/
29 /******/
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
32 /******/
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
35 /******/
36 /******/ // define getter function for harmony exports
37 /******/ __webpack_require__.d = function(exports, name, getter) {
38 /******/ if(!__webpack_require__.o(exports, name)) {
39 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40 /******/ }
41 /******/ };
42 /******/
43 /******/ // define __esModule on exports
44 /******/ __webpack_require__.r = function(exports) {
45 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47 /******/ }
48 /******/ Object.defineProperty(exports, '__esModule', { value: true });
49 /******/ };
50 /******/
51 /******/ // create a fake namespace object
52 /******/ // mode & 1: value is a module id, require it
53 /******/ // mode & 2: merge all properties of value into the ns
54 /******/ // mode & 4: return value when already ns object
55 /******/ // mode & 8|1: behave like require
56 /******/ __webpack_require__.t = function(value, mode) {
57 /******/ if(mode & 1) value = __webpack_require__(value);
58 /******/ if(mode & 8) return value;
59 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60 /******/ var ns = Object.create(null);
61 /******/ __webpack_require__.r(ns);
62 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64 /******/ return ns;
65 /******/ };
66 /******/
67 /******/ // getDefaultExport function for compatibility with non-harmony modules
68 /******/ __webpack_require__.n = function(module) {
69 /******/ var getter = module && module.__esModule ?
70 /******/ function getDefault() { return module['default']; } :
71 /******/ function getModuleExports() { return module; };
72 /******/ __webpack_require__.d(getter, 'a', getter);
73 /******/ return getter;
74 /******/ };
75 /******/
76 /******/ // Object.prototype.hasOwnProperty.call
77 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78 /******/
79 /******/ // __webpack_public_path__
80 /******/ __webpack_require__.p = "";
81 /******/
82 /******/
83 /******/ // Load entry module and return exports
84 /******/ return __webpack_require__(__webpack_require__.s = "./js/table.ts");
85 /******/ })
86 /************************************************************************/
87 /******/ ({
88
89 /***/ "./js/table.ts":
90 /*!*********************!*\
91 !*** ./js/table.ts ***!
92 \*********************/
93 /*! no exports provided */
94 /***/ (function(module, __webpack_exports__, __webpack_require__) {
95
96 "use strict";
97 __webpack_require__.r(__webpack_exports__);
98 const getNumberOfItemsFromPage = () => {
99 var _a, _b;
100 let numberOfItems = (_b = (_a = document.querySelector('.tablenav-pages .displaying-num')) === null || _a === void 0 ? void 0 : _a.innerHTML.split(' ')[0]) !== null && _b !== void 0 ? _b : '';
101 return numberOfItems.replace(',', '').replace('.', '');
102 };
103 AC_SERVICES.addListener('Table.Ready', (payload) => {
104 var _a, _b, _c, _d, _e;
105 if (document.body.classList.contains('ac-mla-media-assistant')) {
106 let number = getNumberOfItemsFromPage();
107 if (typeof ACP_Export !== 'undefined') {
108 ACP_Export.total_num_items = number;
109 }
110 if (parseInt(number) === 0) {
111 let exportButton = (_b = (_a = AC_SERVICES.getService('Export')) === null || _a === void 0 ? void 0 : _a.getService('Exporter')) === null || _b === void 0 ? void 0 : _b.button;
112 if (exportButton) {
113 exportButton.element.style.display = 'none';
114 }
115 (_c = payload.table.Actions) === null || _c === void 0 ? void 0 : _c.refresh();
116 }
117 (_e = (_d = AC_SERVICES.getService('Editing')) === null || _d === void 0 ? void 0 : _d.getService('BulkSelectionRow')) === null || _e === void 0 ? void 0 : _e.setTotalItems(parseInt(number), number);
118 }
119 });
120
121
122
123 /***/ })
124
125 /******/ });
126 //# sourceMappingURL=table.js.map
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Asset\Script;
4
5 use AC;
6
7 class Admin extends AC\Asset\Script {
8
9 private $assets_url;
10
11 public function __construct( string $handle, AC\Asset\Location\Absolute $location ) {
12 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) );
13
14 $this->assets_url = $location->with_suffix( 'assets/' )->get_url();
15 }
16
17 public function register(): void {
18 parent::register();
19
20 $this->add_inline_variable( 'aca_mla_admin', [
21 'assets' => $this->assets_url . '/',
22 ] );
23 }
24
25 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class AltText extends Column implements ACP\Editing\Editable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'alt_text' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function editing() {
18 return new ACP\Editing\Service\Media\AlternateText();
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Export\Model;
7 use ACA\MLA\Service\ColumnGroup;
8 use ACP;
9
10 class AttachedTo extends Column implements ACP\Export\Exportable {
11
12 public function __construct() {
13 $this->set_original( true )
14 ->set_type( 'attached_to' )
15 ->set_group( ColumnGroup::NAME );
16 }
17
18 public function export() {
19 return new Model\AttachedTo();
20 }
21
22 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class Author extends Column implements ACP\Editing\Editable, ACP\Export\Exportable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'author' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function editing() {
18 return new ACP\Editing\Service\Post\Author();
19 }
20
21 public function export() {
22 return new ACP\Export\Model\Post\Author();
23 }
24
25 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7
8 class BaseFile extends Column {
9
10 public function __construct() {
11 $this->set_original( true )
12 ->set_type( 'base_file' )
13 ->set_group( ColumnGroup::NAME );
14 }
15
16 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class Caption extends Column implements ACP\Editing\Editable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'caption' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function editing() {
18 return new ACP\Editing\Service\Media\Caption();
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Export;
7 use ACA\MLA\Service\ColumnGroup;
8 use ACP\Export\Exportable;
9
10 class CustomField extends Column implements Exportable {
11
12 /**
13 * Define column properties
14 * set_type( 'c_' . field number ) is done by the calling function.
15 */
16 public function __construct() {
17 // type is set runtime
18 $this->set_original( true )
19 ->set_group( ColumnGroup::NAME );
20 }
21
22 public function export() {
23 return new Export\Model\CustomField( $this->get_name() );
24 }
25
26 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class Date extends Column implements ACP\Export\Exportable, ACP\Editing\Editable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'date' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function editing() {
18 return new ACP\Editing\Service\Media\Date();
19 }
20
21 public function export() {
22 return new ACP\Export\Model\Post\Date();
23 }
24
25 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class Description extends Column implements ACP\Export\Exportable, ACP\Editing\Editable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'description' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function editing() {
18 return new ACP\Editing\Service\Post\Content( new ACP\Editing\View\TextArea() );
19 }
20
21 public function export() {
22 return new ACP\Export\Model\StrippedValue( $this );
23 }
24
25 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Export;
7 use ACA\MLA\Service\ColumnGroup;
8 use ACP;
9 use MLACore;
10
11 class Features extends Column implements ACP\Export\Exportable {
12
13 public function __construct() {
14 $this->set_original( true )
15 ->set_type( 'featured' )
16 ->set_group( ColumnGroup::NAME );
17 }
18
19 public function export() {
20 if ( ! MLACore::$process_featured_in ) {
21 return false;
22 }
23
24 return new Export\Model\FeaturedIn();
25 }
26
27 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7
8 class FileUrl extends Column {
9
10 public function __construct() {
11 $this->set_original( true )
12 ->set_type( 'file_url' )
13 ->set_group( ColumnGroup::NAME );
14 }
15
16 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Export;
7 use ACA\MLA\Service\ColumnGroup;
8 use ACP;
9 use MLACore;
10
11 class Galleries extends Column implements ACP\Export\Exportable {
12
13 public function __construct() {
14 $this->set_original( true )
15 ->set_type( 'galleries' )
16 ->set_group( ColumnGroup::NAME );
17 }
18
19 public function export() {
20 if ( ! MLACore::$process_gallery_in ) {
21 return false;
22 }
23
24 return new Export\Model\MlaGalleryIn( 'galleries' );
25 }
26
27 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Export;
7 use ACA\MLA\Service\ColumnGroup;
8 use ACP;
9 use MLACore;
10
11 class GalleriesMla extends Column implements ACP\Export\Exportable {
12
13 public function __construct() {
14 $this->set_original( true )
15 ->set_type( 'mla_galleries' )
16 ->set_group( ColumnGroup::NAME );
17 }
18
19 public function export() {
20 if ( ! MLACore::$process_mla_gallery_in ) {
21 return false;
22 }
23
24 return new Export\Model\MlaGalleryIn( 'mla_galleries' );
25 }
26
27 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class IdParent extends Column implements ACP\Export\Exportable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'ID_parent' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function export() {
18 return new ACP\Export\Model\Post\Id();
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Export\Model\Inserted;
7 use ACA\MLA\Service\ColumnGroup;
8 use ACP;
9 use MLACore;
10
11 class Inserts extends Column implements ACP\Export\Exportable {
12
13 public function __construct() {
14 $this->set_original( true )
15 ->set_type( 'inserted' )
16 ->set_group( ColumnGroup::NAME );
17 }
18
19 public function export() {
20 if ( ! MLACore::$process_inserted_in ) {
21 return false;
22 }
23
24 return new Inserted( );
25 }
26
27 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP\Editing;
8 use ACP\Export;
9
10 class MenuOrder extends Column implements Export\Exportable, Editing\Editable {
11
12 public function __construct() {
13 $this->set_original( true )
14 ->set_type( 'menu_order' )
15 ->set_group( ColumnGroup::NAME );
16 }
17
18 public function export() {
19 return new Export\Model\Post\PostField( 'menu_order' );
20 }
21
22 public function editing() {
23 return new Editing\Service\Post\Order();
24 }
25
26 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class MimeType extends Column implements ACP\Export\Exportable, ACP\Editing\Editable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'post_mime_type' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function editing() {
18 return new ACP\Editing\Service\Media\MimeType();
19 }
20
21 public function export() {
22 return new ACP\Export\Model\Post\PostField( 'post_mime_type' );
23 }
24
25 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class Modified extends Column implements ACP\Export\Exportable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'modified' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function export() {
18 return new ACP\Export\Model\Post\PostField( 'post_modified' );
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class Name extends Column implements ACP\Export\Exportable, ACP\Editing\Editable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'post_name' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function export() {
18 return new ACP\Export\Model\Post\PostField( 'post_name' );
19 }
20
21 public function editing() {
22 return new ACP\Editing\Service\Post\Slug();
23 }
24
25 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class PostParent extends Column implements ACP\Export\Exportable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'parent' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function export() {
18 return new ACP\Export\Model\Post\Id( );
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Export;
7 use ACA\MLA\Service\ColumnGroup;
8 use ACP;
9
10 class Taxonomy extends Column implements ACP\Export\Exportable, ACP\Editing\Editable {
11
12 public function __construct() {
13 // type is set runtime
14 $this->set_original( true )
15 ->set_group( ColumnGroup::NAME );
16 }
17
18 public function editing() {
19 return new ACP\Editing\Service\Post\Taxonomy( $this->get_taxonomy(), false );
20 }
21
22 public function export() {
23 return new Export\Model\Taxonomy( $this->get_taxonomy() );
24 }
25
26 /**
27 * @return string
28 */
29 public function get_taxonomy() {
30 return substr( $this->get_type(), 2 );
31 }
32
33 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class Title extends Column implements ACP\Export\Exportable, ACP\Editing\Editable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'post_title' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function export() {
18 return new ACP\Export\Model\Post\Title();
19 }
20
21 public function editing() {
22 return new ACP\Editing\Service\Media\Title();
23 }
24
25 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Column;
4
5 use AC\Column;
6 use ACA\MLA\Service\ColumnGroup;
7 use ACP;
8
9 class TitleName extends Column implements ACP\Export\Exportable {
10
11 public function __construct() {
12 $this->set_original( true )
13 ->set_type( 'title_name' )
14 ->set_group( ColumnGroup::NAME );
15 }
16
17 public function export() {
18 return new ACP\Export\Model\Post\Title();
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Editing;
5
6 use ACP;
7
8 class Strategy extends ACP\Editing\Strategy\Post {
9
10 public function get_query_request_handler() {
11 global $wp_list_table;
12
13 // Re-execute the query because the table object can be shared with custom plugins using the MLA filters/actions
14 $wp_list_table->prepare_items();
15
16 return parent::get_query_request_handler();
17 }
18
19 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Editing\TableRows;
5
6 use AC\ThirdParty\MediaLibraryAssistant\WpListTableFactory;
7 use ACP\Editing\Ajax\TableRows;
8
9 class MediaLibraryRows extends TableRows {
10
11 public function register() {
12 add_action( 'mla_list_table_prepare_items', [ $this, 'handle_request' ] );
13
14 // Triggers hook above
15 ( new WpListTableFactory() )->create();
16 }
17
18 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Export;
4
5 use MLAData;
6 use WP_Post;
7
8 trait ExtendedPostTrait {
9
10 public function get_extended_post( int $id ): ?WP_Post {
11 $data = MLAData::mla_get_attachment_by_id( $id );
12
13 return $data
14 ? new WP_Post( (object) $data )
15 : null;
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\MLA\Export\Model;
5
6 use ACA\MLA\Export\ExtendedPostTrait;
7 use ACP\Export\Service;
8 use WP_Post;
9 use WP_Post_Type;
10
11 class AttachedTo implements Service {
12
13 use ExtendedPostTrait;
14
15 private function format_post_status( string $post_status ): ?string {
16 switch ( $post_status ) {
17 case 'draft' :
18 return __( 'Draft' );
19 case 'future' :
20 return __( 'Scheduled' );
21 case 'pending' :
22 return _x( 'Pending', 'post state' );
23 case 'trash' :
24 return __( 'Trash' );
25 default:
26 return null;
27 }
28 }
29
30 private function user_can_read_parent( WP_Post $post ): bool {
31 $post_type = get_post_type_object( $post->parent_type ?? '' );
32
33 if ( ! $post_type instanceof WP_Post_Type ) {
34 return false;
35 }
36
37 return ! $post_type->show_ui || current_user_can( $post_type->cap->read_post, $post->post_parent );
38 }
39
40 public function get_value( $id ) {
41 $post = $this->get_extended_post( (int) $id );
42
43 $parent_title = $post->parent_title ?? null;
44
45 if ( $post && $parent_title ) {
46 $parent_type = $post->parent_type ?? '';
47 $parent_date = $post->parent_date ?? '';
48 $parent_status = $post->parent_status ?? '';
49
50 $user_can_read_parent = $this->user_can_read_parent( $post );
51
52 $value = $user_can_read_parent
53 ? esc_attr( $parent_title )
54 : __( '(Private post)' );
55
56 if ( $parent_date && $user_can_read_parent ) {
57 $value .= "\n" . mysql2date( __( 'Y/m/d', 'media-library-assistant' ), $parent_date );
58 }
59
60 if ( $parent_type && $user_can_read_parent ) {
61 $_parent = $post->post_parent;
62 $_status = $this->format_post_status( $parent_status );
63
64 if ( $_status ) {
65 $_parent = sprintf( '%s, %s', $_parent, $_status );
66 }
67
68 $value .= sprintf( "\n(%s %s)", $parent_type, $_parent );
69 }
70
71 return $value;
72 }
73
74 return sprintf( '(%s)', _x( 'Unattached', 'table_view_singular', 'media-library-assistant' ) );
75 }
76
77 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Export\Model;
5
6 use ACA\MLA\Export\ExtendedPostTrait;
7 use ACP\Export\Service;
8 use MLACore;
9 use MLAData;
10 use WP_Post;
11
12 class CustomField implements Service {
13
14 use ExtendedPostTrait;
15
16 /**
17 * @var string
18 */
19 private $column_name;
20
21 public function __construct( string $column_name ) {
22 $this->column_name = $column_name;
23 }
24
25 private function get_custom_column(): ?string {
26 static $custom_columns = null;
27
28 if ( null === $custom_columns ) {
29 $custom_columns = MLACore::mla_custom_field_support( 'custom_columns' );
30 }
31
32 return $custom_columns[ $this->column_name ] ?? null;
33 }
34
35 private function is_meta(): bool {
36 $custom_column = $this->get_custom_column();
37
38 return $custom_column && 0 === strpos( $custom_column, 'meta:' );
39 }
40
41 private function get_custom_values( WP_Post $item ): ?array {
42 $custom_column = $this->get_custom_column();
43
44 if ( ! $custom_column ) {
45 return null;
46 }
47
48 if ( $this->is_meta() ) {
49 $meta_key = substr( $custom_column, 5 );
50 $meta_data = $item->mla_wp_attachment_metadata ?? null;
51
52 if ( empty( $meta_data ) ) {
53 return null;
54 }
55
56 $values = MLAData::mla_find_array_element(
57 $meta_key,
58 $meta_data,
59 'array'
60 );
61
62 if ( is_scalar( $values ) ) {
63 return [ $values ];
64 }
65
66 return (array) $values;
67 }
68
69 $post_meta = get_post_meta( $item->ID, $custom_column );
70
71 if ( ! is_array( $post_meta ) ) {
72 return null;
73 }
74
75 return $post_meta;
76 }
77
78 private function flatten_value( $value ): string {
79 if ( is_array( $value ) ) {
80 $flatten = (string) ac_helper()->array->implode_recursive( __( ', ' ), $value );
81
82 return sprintf( 'array( %s )', $flatten );
83 }
84
85 if ( ! is_scalar( $value ) ) {
86 return '';
87 }
88
89 if ( $this->is_meta() ) {
90 return (string) $value;
91 }
92
93 return esc_html( (string) $value );
94 }
95
96 public function get_value( $id ) {
97 $item = $this->get_extended_post( (int) $id );
98
99 $values = $item
100 ? $this->get_custom_values( $item )
101 : null;
102
103 if ( empty( $values ) ) {
104 return '';
105 }
106
107 $list = array_map( [ $this, 'flatten_value' ], $values );
108
109 if ( count( $list ) > 1 ) {
110 return sprintf( '[%s]', implode( '],[', $list ) );
111 }
112
113 return $list[0];
114
115 }
116
117 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Export\Model;
5
6 use ACA\MLA\Export\ExtendedPostTrait;
7 use ACP\Export\Service;
8
9 class FeaturedIn implements Service {
10
11 use ExtendedPostTrait,
12 FormatPostStatusTrait,
13 UnshiftArrayTrait;
14
15 public function get_value( $id ) {
16 $item = $this->get_extended_post( (int) $id );
17
18 if ( $item === null ) {
19 return '';
20 }
21
22 $features = $item->mla_references['features'] ?? [];
23 $features = $this->shift_element_to_top( $features, $item->post_parent );
24
25 $values = [];
26 foreach ( $features as $feature ) {
27 $parent = $feature->ID === $item->post_parent
28 ? sprintf( ", %s", __( 'PARENT', 'media-library-assistant' ) )
29 : '';
30
31 $values[] = sprintf(
32 "%1\$s (%2\$s %3\$s%4\$s%5\$s)",
33 esc_attr( $feature->post_title ),
34 esc_attr( $feature->post_type ),
35 $feature->ID,
36 $this->format_post_status( $feature->post_status ),
37 $parent
38 );
39 }
40
41 return implode( ",\n", $values );
42 }
43
44 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Export\Model;
4
5 trait FormatPostStatusTrait {
6
7 private function format_post_status( string $post_status ): ?string {
8 switch ( $post_status ) {
9 case 'draft' :
10 return __( 'Draft' );
11 case 'future' :
12 return __( 'Scheduled' );
13 case 'pending' :
14 return _x( 'Pending', 'post state' );
15 case 'trash' :
16 return __( 'Trash' );
17 default:
18 return null;
19 }
20 }
21
22 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Export\Model;
5
6 use ACA\MLA\Export\ExtendedPostTrait;
7 use ACP;
8
9 class Inserted implements ACP\Export\Service {
10
11 use ExtendedPostTrait,
12 FormatPostStatusTrait,
13 UnshiftArrayTrait;
14
15 public function get_value( $id ) {
16 $item = $this->get_extended_post( (int) $id );
17
18 if ( $item === null ) {
19 return '';
20 }
21
22 $_inserts = $item->mla_references['inserts'] ?? [];
23 $_inserted_option = $item->mla_references['inserted_option'] ?? '';
24
25 $values = [];
26
27 foreach ( $_inserts as $file => $inserts ) {
28 $value = '';
29
30 if ( 'base' !== $_inserted_option ) {
31 $value .= $file . "\n";
32 }
33
34 $inserts = $this->shift_element_to_top( $inserts, $item->post_parent );
35
36 foreach ( $inserts as $insert ) {
37 $parent = $insert->ID === $item->post_parent
38 ? sprintf( ", %s", __( 'PARENT', 'media-library-assistant' ) )
39 : '';
40
41 $value .= sprintf(
42 "%1\$s (%2\$s %3\$s%4\$s%5\$s)",
43 esc_attr( $insert->post_title ),
44 esc_attr( $insert->post_type ),
45 $insert->ID,
46 $this->format_post_status( $insert->post_status ),
47 $parent
48 );
49 }
50
51 $values[] = $value;
52 }
53
54 return implode( ",\n", $values );
55 }
56
57 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Export\Model;
5
6 use ACA\MLA\Export\ExtendedPostTrait;
7 use ACP;
8 use InvalidArgumentException;
9
10 class MlaGalleryIn implements ACP\Export\Service {
11
12 use ExtendedPostTrait,
13 FormatPostStatusTrait,
14 UnshiftArrayTrait;
15
16 private $reference_key;
17
18 public function __construct( string $reference_key ) {
19 $this->reference_key = $reference_key;
20
21 $this->validate();
22 }
23
24 private function validate(): void {
25 if ( ! in_array( $this->reference_key, [ 'mla_galleries', 'galleries' ], true ) ) {
26 throw new InvalidArgumentException( 'Invalid gallery reference key.' );
27 }
28 }
29
30 public function get_value( $id ) {
31 $item = $this->get_extended_post( (int) $id );
32
33 if ( $item === null ) {
34 return '';
35 }
36
37 $galleries = $item->mla_references[ $this->reference_key ] ?? [];
38 $galleries = $this->shift_element_to_top( $galleries, $item->post_parent );
39
40 $values = [];
41 foreach ( $galleries as $gallery ) {
42 $parent = $gallery['ID'] === $item->post_parent
43 ? sprintf( ", %s", __( 'PARENT', 'media-library-assistant' ) )
44 : '';
45
46 $values[] = sprintf(
47 "%1\$s (%2\$s %3\$s%4\$s%5\$s)",
48 esc_attr( $gallery['post_title'] ),
49 esc_attr( $gallery['post_type'] ),
50 $gallery['ID'],
51 $this->format_post_status( $gallery['post_status'] ),
52 $parent
53 );
54 }
55
56 return implode( ",\n", $values );
57 }
58
59 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php 1 <?php
2 declare( strict_types=1 );
2 3
3 namespace ACA\WC\Export\ShopOrder; 4 namespace ACA\MLA\Export\Model;
4 5
5 use ACP; 6 use ACP;
6 7
7 /** 8 class Taxonomy implements ACP\Export\Service {
8 * WooCommerce order customer role (default column) exportability model 9
9 * @since 2.2.1 10 /**
10 */ 11 * @var string
11 class CustomerRole extends ACP\Export\Model { 12 */
13 private $taxonomy;
14
15 public function __construct( string $taxonomy ) {
16 $this->taxonomy = $taxonomy;
17 }
12 18
13 public function get_value( $id ) { 19 public function get_value( $id ) {
14 $user = wc_get_order( $id )->get_user(); 20 $terms = wp_get_post_terms( $id, $this->taxonomy, [ 'fields' => 'names' ] );
15 21
16 if ( empty( $user->roles ) ) { 22 if ( ! $terms || is_wp_error( $terms ) ) {
17 return ''; 23 return '';
18 } 24 }
19 25
20 return implode( ', ', $user->roles ); 26 return implode( ', ', $terms );
21 } 27 }
22 28
23 } 29 }
...\ No newline at end of file ...\ No newline at end of file
......
1 <?php
2
3 namespace ACA\MLA\Export\Model;
4
5 trait UnshiftArrayTrait {
6
7 private function shift_element_to_top( array $array, int $key ): array {
8 if ( isset( $array[ $key ] ) ) {
9 $current = $array[ $key ];
10
11 unset( $array[ $key ] );
12
13 array_unshift( $array, $current );
14 }
15
16 return $array;
17 }
18
19 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Export;
5
6 use AC\ListTable;
7 use AC\ThirdParty\MediaLibraryAssistant\WpListTableFactory;
8 use ACA\MLA\ListScreen;
9 use ACA\MLA\ListTableFactory;
10 use ACP;
11
12 class Strategy extends ACP\Export\Strategy {
13
14 public function __construct( ListScreen\MediaLibrary $list_screen ) {
15 parent::__construct( $list_screen );
16 }
17
18 private function get_wp_list_table_factory(): WpListTableFactory {
19 return new WpListTableFactory();
20 }
21
22 protected function get_list_table(): ?ListTable {
23 return ( new ListTableFactory( $this->get_wp_list_table_factory() ) )->create();
24 }
25
26 public function get_total_items(): ?int {
27 // will be populated through JS
28 return 1;
29 }
30
31 protected function ajax_export(): void {
32 add_filter( 'mla_list_table_query_final_terms', [ $this, 'query' ], 1e6 );
33 add_action( 'mla_list_table_prepare_items', [ $this, 'prepare_items' ], 10, 2 );
34 add_filter( 'posts_clauses', [ $this, 'filter_ids' ] );
35
36 // Trigger above hooks early by initiating list table. This prevents "headers already sent".
37 $this->get_wp_list_table_factory()->create();
38 }
39
40 public function filter_ids( $clauses ) {
41 global $wpdb;
42
43 $ids = $this->get_requested_ids();
44
45 if ( $ids ) {
46 $clauses['where'] .= sprintf( "\nAND $wpdb->posts.ID IN( %s )", implode( ',', $ids ) );
47 }
48
49 return $clauses;
50 }
51
52 public function query( $request ) {
53 $per_page = $this->get_num_items_per_iteration();
54
55 $request['offset'] = $this->get_export_counter() * $per_page;
56 $request['posts_per_page'] = $per_page;
57 $request['posts_per_archive_page'] = $per_page;
58
59 return $request;
60 }
61
62 public function prepare_items( $query ): void {
63 $this->export( wp_list_pluck( $query->items, 'ID' ) );
64 }
65
66 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\ListScreen;
5
6 use AC;
7 use ACA\MLA\Column;
8 use ACA\MLA\Editing;
9 use ACA\MLA\Export;
10 use ACP;
11 use MLACore;
12
13 class MediaLibrary extends AC\ThirdParty\MediaLibraryAssistant\ListScreen\MediaLibrary implements ACP\Export\ListScreen, ACP\Editing\ListScreen {
14
15 public function export() {
16 return new Export\Strategy( $this );
17 }
18
19 public function editing() {
20 return new Editing\Strategy( 'attachment' );
21 }
22
23 public function register_column_types() {
24 parent::register_column_types();
25
26 $columns = [
27 Column\AltText::class,
28 Column\AttachedTo::class,
29 Column\Author::class,
30 Column\BaseFile::class,
31 Column\Caption::class,
32 Column\CustomField::class,
33 Column\Date::class,
34 Column\Description::class,
35 Column\Features::class,
36 Column\FileUrl::class,
37 Column\Galleries::class,
38 Column\GalleriesMla::class,
39 Column\IdParent::class,
40 Column\Inserts::class,
41 Column\MenuOrder::class,
42 Column\MimeType::class,
43 Column\Modified::class,
44 Column\Name::class,
45 Column\PostParent::class,
46 Column\Taxonomy::class,
47 Column\Title::class,
48 Column\TitleName::class,
49 ];
50
51 $this->register_column_types_from_list( $columns );
52
53 // Custom Fields
54 foreach ( MLACore::mla_custom_field_support( 'custom_columns' ) as $type => $label ) {
55 $column = new Column\CustomField();
56 $column->set_type( $type )
57 ->set_label( $label );
58
59 $this->register_column_type( $column );
60 }
61
62 // Taxonomies
63 foreach ( get_taxonomies( [ 'show_ui' => true ], 'objects' ) as $taxonomy ) {
64 if ( MLACore::mla_taxonomy_support( $taxonomy->name ) ) {
65 $column = new Column\Taxonomy();
66 $column->set_type( 't_' . $taxonomy->name )
67 ->set_label( $taxonomy->label );
68
69 $this->register_column_type( $column );
70 }
71 }
72 }
73
74 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\ListTable;
5
6 use AC\ListTable;
7 use MLA_List_Table;
8 use MLAData;
9
10 class MediaLibraryTable implements ListTable {
11
12 private $table;
13
14 public function __construct( MLA_List_Table $table ) {
15 $this->table = $table;
16 }
17
18 public function get_total_items(): int {
19 return $this->table->get_pagination_arg( 'total_items' );
20 }
21
22 public function get_column_value( $column, $id ) {
23 $item = (object) MLAData::mla_get_attachment_by_id( $id );
24
25 if ( ! $item ) {
26 return null;
27 }
28
29 $method = 'column_' . $column;
30
31 if ( method_exists( $this->table, $method ) ) {
32 return call_user_func( [ $this->table, $method ], $item );
33 }
34
35 return $this->table->column_default( $item, $column );
36 }
37
38 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA;
5
6 use AC\ThirdParty\MediaLibraryAssistant\WpListTableFactory;
7 use ACA\MLA\ListTable\MediaLibraryTable;
8
9 class ListTableFactory {
10
11 private $wp_list_table_factory;
12
13 public function __construct( WpListTableFactory $wp_list_table_factory ) {
14 $this->wp_list_table_factory = $wp_list_table_factory;
15 }
16
17 public function create(): MediaLibraryTable {
18 return new MediaLibraryTable( $this->wp_list_table_factory->create() );
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,18 +3,32 @@ declare( strict_types=1 ); ...@@ -3,18 +3,32 @@ declare( strict_types=1 );
3 3
4 namespace ACA\MLA; 4 namespace ACA\MLA;
5 5
6 use AC\PluginInformation; 6 use AC;
7 use AC\Registerable; 7 use AC\Registerable;
8 use ACA\MLA\Service;
9 use ACP\Service\IntegrationStatus;
8 10
9 class MediaLibraryAssistant implements Registerable { 11 class MediaLibraryAssistant implements Registerable {
10 12
13 private $location;
14
15 public function __construct( AC\Asset\Location\Absolute $location ) {
16 $this->location = $location;
17 }
18
11 public function register() { 19 public function register() {
12 if ( ! defined( 'MLA_PLUGIN_PATH' ) ) { 20 if ( ! defined( 'MLA_PLUGIN_PATH' ) ) {
13 return; 21 return;
14 } 22 }
15 23
16 $services = [ 24 $services = [
17 new Service\IntegratedMlaSupport( new PluginInformation( MLA_PLUGIN_BASENAME . '/index.php' ) ), 25 new Service\Admin( $this->location ),
26 new Service\ColumnGroup(),
27 new Service\Editing(),
28 new Service\Export(),
29 new Service\ListScreens(),
30 new Service\TableScreen( $this->location ),
31 new IntegrationStatus( 'ac-addon-media-library-assistant' ),
18 ]; 32 ];
19 33
20 array_map( [ $this, 'register_service' ], $services ); 34 array_map( [ $this, 'register_service' ], $services );
......
1 <?php
2
3 namespace ACA\MLA\Service;
4
5 use AC;
6 use AC\Registerable;
7 use ACA\MLA\Asset;
8
9 class Admin implements Registerable {
10
11 /**
12 * @var AC\Asset\Location\Absolute
13 */
14 private $location;
15
16 /**
17 * @param AC\Asset\Location\Absolute $location
18 */
19 public function __construct( AC\Asset\Location\Absolute $location ) {
20 $this->location = $location;
21 }
22
23 public function register(): void {
24 add_action( 'ac/admin_scripts', [ $this, 'admin_scripts' ] );
25 }
26
27 public function admin_scripts(): void {
28 $script = new Asset\Script\Admin( 'aca-mla-admin', $this->location );
29 $script->enqueue();
30 }
31
32 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Service;
5
6 use AC;
7 use AC\Registerable;
8
9 class ColumnGroup implements Registerable {
10
11 public const NAME = 'media-library-assistant';
12
13 public function register() {
14 add_action( 'ac/column_groups', [ $this, 'register_column_group' ] );
15 }
16
17 public function register_column_group( AC\Groups $groups ) {
18 $groups->register_group( self::NAME, __( 'Media Library Assistant' ), 25 );
19 }
20
21 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Service;
5
6 use AC\Registerable;
7 use ACA\MLA\Editing\TableRows\MediaLibraryRows;
8 use ACA\MLA\ListScreen;
9 use ACP\Editing\Ajax\TableRowsFactory;
10
11 class Editing implements Registerable {
12
13 public function register() {
14 TableRowsFactory::register( ListScreen\MediaLibrary::class, MediaLibraryRows::class );
15 }
16
17 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 declare( strict_types=1 );
3
4 namespace ACA\MLA\Service;
5
6 use AC;
7 use AC\Registerable;
8 use ACA\MLA\Export\Strategy;
9 use ACP;
10
11 class Export implements Registerable {
12
13 public function register() {
14 add_action( 'ac/export/headers', [ $this, 'fix_excel_issue' ], 10, 2 );
15 add_filter( 'ac/export/value', [ $this, 'strip_tags_value' ], 10, 3 );
16 }
17
18 public function strip_tags_value( $value, AC\Column $column ) {
19 if ( $column->get_group() === ColumnGroup::NAME ) {
20 $value = strip_tags( (string) $value );
21 }
22
23 return $value;
24 }
25
26 /**
27 * Error 'SYLK: File format is not valid' in Excel
28 * MS Excel 2003 and 2013 does not allow the first label to start with 'ID'
29 */
30 public function fix_excel_issue( array $headers, ACP\Export\Strategy $strategy ) {
31 if ( ! $strategy instanceof Strategy ) {
32 return $headers;
33 }
34
35 foreach ( $headers as $name => $label ) {
36 $first = substr( $label, 0, 2 );
37 $end = substr( $label, 2 );
38
39 // Rename label 'ID' to 'id'
40 if ( 'ID' === $first ) {
41 $headers[ $name ] = strtolower( $first ) . $end;
42 }
43 break;
44 }
45
46 return $headers;
47 }
48
49 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Service;
4
5 use AC\Plugin\Version;
6 use AC\PluginInformation;
7 use AC\Registerable;
8
9 class IntegratedMlaSupport implements Registerable {
10
11 private $plugin_information;
12
13 public function __construct( PluginInformation $plugin_information ) {
14 $this->plugin_information = $plugin_information;
15 }
16
17 public function register() {
18 if ( method_exists( 'MLACore', 'register_list_screen' ) && $this->plugin_information->get_version()->is_lt( new Version( '3.05' ) ) ) {
19 remove_action( 'ac/list_screens', 'MLACore::register_list_screen' );
20 }
21 }
22
23 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Service;
4
5 use AC;
6 use AC\Registerable;
7 use ACA\MLA\ListScreen;
8
9 class ListScreens implements Registerable {
10
11 public function register() {
12 add_action( 'ac/list_screens', [ $this, 'register_list_screens' ], 11 );
13 }
14
15 public function register_list_screens() {
16 AC\ListScreenTypes::instance()->register_list_screen( new ListScreen\MediaLibrary() );
17 }
18
19 }
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2
3 namespace ACA\MLA\Service;
4
5 use AC\Asset\Location\Absolute;
6 use AC\Asset\Script;
7 use AC\Registerable;
8
9 class TableScreen implements Registerable {
10
11 private $location;
12
13 public function __construct( Absolute $location ) {
14 $this->location = $location;
15 }
16
17 public function register() {
18 add_action( 'ac/table_scripts', [ $this, 'table_scripts' ], 11 );
19 }
20
21 public function table_Scripts() {
22 $script = new Script( 'aca-mla-table', $this->location->with_suffix( 'assets/js/table.js' ) );
23 $script->enqueue();
24 }
25
26 }
...\ No newline at end of file ...\ No newline at end of file
...@@ -12,17 +12,17 @@ class Admin extends Script { ...@@ -12,17 +12,17 @@ class Admin extends Script {
12 */ 12 */
13 private $assets_url; 13 private $assets_url;
14 14
15 public function __construct( $handle, AC\Asset\Location\Absolute $location ) { 15 public function __construct( string $handle, AC\Asset\Location\Absolute $location ) {
16 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) ); 16 parent::__construct( $handle, $location->with_suffix( 'assets/js/admin.js' ) );
17 17
18 $this->assets_url = $location->with_suffix( 'assets/' )->get_url(); 18 $this->assets_url = $location->with_suffix( 'assets/' )->get_url();
19 } 19 }
20 20
21 public function register() { 21 public function register(): void {
22 parent::register(); 22 parent::register();
23 23
24 $this->add_inline_variable( 'aca_metabox_admin', [ 24 $this->add_inline_variable( 'aca_metabox_admin', [
25 'assets' => $this->assets_url .'/', 25 'assets' => $this->assets_url . '/',
26 ] ); 26 ] );
27 } 27 }
28 28
......
...@@ -111,7 +111,7 @@ class Column extends AC\Column\Meta ...@@ -111,7 +111,7 @@ class Column extends AC\Column\Meta
111 case 'post': 111 case 'post':
112 return rwmb_get_object_fields( $this->get_post_type() ); 112 return rwmb_get_object_fields( $this->get_post_type() );
113 case 'term': 113 case 'term':
114 return rwmb_get_object_fields( $this->get_taxonomy(), 'term' ); 114 return rwmb_get_object_fields( $this->get_list_screen()->get_taxonomy(), 'term' );
115 default: 115 default:
116 return []; 116 return [];
117 } 117 }
...@@ -140,7 +140,7 @@ class Column extends AC\Column\Meta ...@@ -140,7 +140,7 @@ class Column extends AC\Column\Meta
140 } 140 }
141 141
142 public function export() { 142 public function export() {
143 return ( new Export\Factory )->create( $this ); 143 return ( new Export\Factory() )->create( $this );
144 } 144 }
145 145
146 } 146 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,15 +4,15 @@ namespace ACA\MetaBox\Export; ...@@ -4,15 +4,15 @@ namespace ACA\MetaBox\Export;
4 4
5 use ACA\MetaBox; 5 use ACA\MetaBox;
6 use ACA\MetaBox\Column; 6 use ACA\MetaBox\Column;
7 use ACP\Export\Model\StrippedValue;
8 use ACP\Export\Service;
7 9
8 class Factory extends MetaBox\Factory { 10 class Factory {
9 11
10 public function create( Column $column ) { 12 public function create( Column $column ): Service {
11 return $this->create_default( $column );
12 }
13
14 public function create_default( Column $column ) {
15 switch ( true ) { 13 switch ( true ) {
14 case $column instanceof Column\TextList:
15 return new StrippedValue( $column );
16 case $column instanceof Column\File: 16 case $column instanceof Column\File:
17 case $column instanceof Column\Image: 17 case $column instanceof Column\Image:
18 case $column instanceof Column\Video: 18 case $column instanceof Column\Video:
...@@ -27,13 +27,9 @@ class Factory extends MetaBox\Factory { ...@@ -27,13 +27,9 @@ class Factory extends MetaBox\Factory {
27 case $column instanceof Column\Taxonomy: 27 case $column instanceof Column\Taxonomy:
28 case $column instanceof Column\User: 28 case $column instanceof Column\User:
29 return new MetaBox\Export\Model\Formatted( $column ); 29 return new MetaBox\Export\Model\Formatted( $column );
30 default:
31 return new MetaBox\Export\Model\Raw( $column );
30 } 32 }
31
32 return new MetaBox\Export\Model\Raw( $column );
33 }
34
35 public function create_disabled( Column $column ) {
36 return false;
37 } 33 }
38 34
39 } 35 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
2 2
3 namespace ACA\MetaBox\Export\Model; 3 namespace ACA\MetaBox\Export\Model;
4 4
5 use ACA\MetaBox\Column;
6
7 /**
8 * @property Column $column
9 */
10 class FieldsetText extends Raw { 5 class FieldsetText extends Raw {
11 6
12 public function format_single_value( $value, $id = null ) { 7 public function format_single_value( $value, $id = null ) {
......
...@@ -4,13 +4,10 @@ namespace ACA\MetaBox\Export\Model; ...@@ -4,13 +4,10 @@ namespace ACA\MetaBox\Export\Model;
4 4
5 use ACA\MetaBox\Column; 5 use ACA\MetaBox\Column;
6 6
7 /**
8 * @property Column $column
9 */
10 class File extends Raw { 7 class File extends Raw {
11 8
12 public function format_single_value( $value, $id = null ) { 9 public function format_single_value( $value, $id = null ) {
13 if ( empty( $value ) ) { 10 if ( empty( $value ) || ! is_array( $value ) ) {
14 return ''; 11 return '';
15 } 12 }
16 13
......
...@@ -4,9 +4,6 @@ namespace ACA\MetaBox\Export\Model; ...@@ -4,9 +4,6 @@ namespace ACA\MetaBox\Export\Model;
4 4
5 use ACA\MetaBox\Column; 5 use ACA\MetaBox\Column;
6 6
7 /**
8 * @property Column $column
9 */
10 class Formatted extends Raw { 7 class Formatted extends Raw {
11 8
12 public function format_single_value( $value, $id = null ) { 9 public function format_single_value( $value, $id = null ) {
......
...@@ -6,33 +6,42 @@ use AC; ...@@ -6,33 +6,42 @@ use AC;
6 use ACA\MetaBox\Column; 6 use ACA\MetaBox\Column;
7 use ACP; 7 use ACP;
8 8
9 /** 9 class Raw implements ACP\Export\Service {
10 * @property Column $column 10
11 */ 11 protected $column;
12 class Raw extends ACP\Export\Model\RawValue {
13 12
14 public function __construct( Column $column ) { 13 public function __construct( Column $column ) {
15 parent::__construct( $column ); 14 $this->column = $column;
16 } 15 }
17 16
18 public function get_value( $id ) { 17 public function get_value( $id ) {
19 if ( $this->column->is_clonable() ) { 18 if ( $this->column->is_clonable() ) {
20 return $this->get_multiple_values( $id ); 19 return (string) $this->get_multiple_values( $id );
21 } 20 }
22 21
23 return $this->format_single_value( rwmb_get_value( $this->column->get_meta_key(), [ 'object_type' => $this->column->get_meta_type() ], $id ), $id ); 22 $single_value = $this->get_rmwb_value( (int) $id );
23
24 return $this->format_single_value( $single_value, $id );
24 } 25 }
25 26
26 public function format_single_value( $value, $id = null ) { 27 private function get_rmwb_value( int $id ) {
27 if ( ! $value ) { 28 return rwmb_get_value(
28 return ''; 29 $this->column->get_meta_key(),
29 } 30 [
31 'object_type' => $this->column->get_meta_type(),
32 ],
33 $id
34 );
35 }
30 36
31 return $value; 37 public function format_single_value( $value, $id = null ) {
38 return $value
39 ? (string) $value
40 : '';
32 } 41 }
33 42
34 public function get_multiple_values( $id ) { 43 public function get_multiple_values( $id ) {
35 $value = rwmb_get_value( $this->column->get_meta_key(), [ 'object_type' => $this->column->get_meta_type() ], $id ); 44 $value = $this->get_rmwb_value( (int) $id );
36 45
37 if ( ! $value ) { 46 if ( ! $value ) {
38 return null; 47 return null;
......
...@@ -26,7 +26,11 @@ class Columns implements Registerable { ...@@ -26,7 +26,11 @@ class Columns implements Registerable {
26 */ 26 */
27 private $relationship_repository; 27 private $relationship_repository;
28 28
29 public function __construct( ColumnFactory $column_factory, RelationColumnFactory $relation_column_factory, RelationshipRepository $relationship_repository ) { 29 public function __construct(
30 ColumnFactory $column_factory,
31 RelationColumnFactory $relation_column_factory,
32 RelationshipRepository $relationship_repository
33 ) {
30 $this->column_factory = $column_factory; 34 $this->column_factory = $column_factory;
31 $this->relation_column_factory = $relation_column_factory; 35 $this->relation_column_factory = $relation_column_factory;
32 $this->relationship_repository = $relationship_repository; 36 $this->relationship_repository = $relationship_repository;
...@@ -103,7 +107,7 @@ class Columns implements Registerable { ...@@ -103,7 +107,7 @@ class Columns implements Registerable {
103 } 107 }
104 108
105 public function add_relation_columns( AC\ListScreen $list_screen ) { 109 public function add_relation_columns( AC\ListScreen $list_screen ) {
106 if ( ! class_exists( 'MB_Relationships_API', false ) ) { 110 if ( ! class_exists( 'MB_Relationships_API', false ) || ! method_exists( 'MB_Relationships_API', 'get_all_relationships' ) ) {
107 return; 111 return;
108 } 112 }
109 113
......
...@@ -11,7 +11,7 @@ const isAddonColumn = result => { ...@@ -11,7 +11,7 @@ const isAddonColumn = result => {
11 } 11 }
12 12
13 document.addEventListener( 'DOMContentLoaded', () => { 13 document.addEventListener( 'DOMContentLoaded', () => {
14 let icon = aca_pods_admin.assets + 'images/pods.svg'; 14 let icon = aca_pods_admin.assets + '/images/pods.svg';
15 15
16 AC_SERVICES.filters.addFilter( 'column_type_templates', ( value, pl ) => { 16 AC_SERVICES.filters.addFilter( 'column_type_templates', ( value, pl ) => {
17 if ( pl.result.hasOwnProperty( 'id' ) && isAddonColumn( pl.result ) ) { 17 if ( pl.result.hasOwnProperty( 'id' ) && isAddonColumn( pl.result ) ) {
......
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.