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