ACF.php
5 years ago
NinjaForms.php
5 years ago
WPML.php
5 years ago
WPMLColumn.php
5 years ago
WooCommerce.php
5 years ago
WPMLColumn.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\ThirdParty; |
| 4 | |
| 5 | /** |
| 6 | * WPML: display correct flags on the overview screens |
| 7 | */ |
| 8 | class WPMLColumn { |
| 9 | |
| 10 | const COLUMN_NAME = 'icl_translations'; |
| 11 | |
| 12 | private $column; |
| 13 | |
| 14 | function __construct( $post_type ) { |
| 15 | add_filter( "manage_{$post_type}_posts_columns", [ $this, 'store_wpml_column' ], 11 ); // priority just after WPML set's it's column |
| 16 | add_filter( "manage_edit-{$post_type}_columns", [ $this, 'replace_wpml_column' ], 201 ); // priority just after AC overwrite all columns |
| 17 | } |
| 18 | |
| 19 | public function store_wpml_column( $columns ) { |
| 20 | if ( empty( $this->column ) && isset( $columns[ self::COLUMN_NAME ] ) ) { |
| 21 | $this->column = $columns[ self::COLUMN_NAME ]; |
| 22 | } |
| 23 | |
| 24 | return $columns; |
| 25 | } |
| 26 | |
| 27 | public function replace_wpml_column( $columns ) { |
| 28 | if ( $this->column && isset( $columns[ self::COLUMN_NAME ] ) ) { |
| 29 | $columns[ self::COLUMN_NAME ] = $this->column; |
| 30 | } |
| 31 | |
| 32 | return $columns; |
| 33 | } |
| 34 | } |