PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.4.8
Admin Columns v2.4.8
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / third_party / wpml.php
codepress-admin-columns / classes / third_party Last commit date
acf.php 10 years ago all-in-seo.php 10 years ago bbpress.php 10 years ago ninja_forms.php 10 years ago wpml.php 10 years ago yoast_seo.php 10 years ago
wpml.php
133 lines
1 <?php
2
3 /**
4 * WPML: display correct flags on the overview screens
5 */
6 class CPAC_WPML_COLUMN {
7
8 CONST COLUMN_NAME = 'icl_translations';
9
10 private $column;
11
12 function __construct( $post_type ) {
13 add_filter( "manage_{$post_type}_posts_columns", array( $this, 'store_wpml_column' ), 11 ); // prio just after WPML set's it's column
14 add_filter( "manage_edit-{$post_type}_columns", array( $this, 'replace_wpml_column' ), 101 ); // prio just after AC overwrite all columns
15 }
16 public function store_wpml_column( $columns ) {
17 if ( empty( $this->column ) && isset( $columns[ self::COLUMN_NAME ] ) ) {
18 $this->column = $columns[ self::COLUMN_NAME ];
19 }
20 return $columns;
21 }
22 public function replace_wpml_column( $columns ) {
23 if ( $this->column && isset( $columns[ self::COLUMN_NAME ] ) ) {
24 $columns[ self::COLUMN_NAME ] = $this->column;
25 }
26 return $columns;
27 }
28 }
29
30 /**
31 * WPML compatibility
32 */
33 class CPAC_WPML {
34
35 function __construct() {
36
37 // load wpml columns in AC columns menu
38 add_action( 'cac/set_columns', array( $this, 'add_columns_to_settings_menu' ) );
39
40 // display correct flags on the overview screens
41 add_action( 'cac/loaded', array( $this, 'replace_flags' ) );
42
43 // enable the translation of the column labels
44 add_action( 'wp_loaded', array( $this, 'register_column_labels' ), 99 );
45
46 // enable the WPML translation of column headings
47 add_filter( 'cac/headings/label', array( $this, 'register_translated_label' ), 10, 4 );
48
49 // set WPML to be a columns screen for translation so that storage models are loaded
50 add_filter( 'cac/is_cac_screen', array( $this, 'is_cac_screen' ) );
51 }
52
53 public function replace_flags( $cac ) {
54 if ( ! class_exists( 'SitePress', false ) ) {
55 return;
56 }
57 if ( ! $cac->is_columns_screen() ) {
58 return;
59 }
60
61 $settings = get_option( 'icl_sitepress_settings' );
62 if ( ! isset( $settings['custom_posts_sync_option'] ) ) {
63 return;
64 }
65 $post_types = (array) $settings['custom_posts_sync_option'];
66 $post_types['post'] = 1;
67 $post_types['page'] = 1;
68 foreach ( $post_types as $post_type => $value ) {
69 if ( $value ) {
70 new CPAC_WPML_COLUMN( $post_type );
71 }
72 }
73 }
74
75 public function add_columns_to_settings_menu( $storage_model ) {
76 if ( ! class_exists( 'SitePress', false ) ) {
77 return;
78 }
79 if ( 'post' !== $storage_model->type ) {
80 return;
81 }
82
83 global $pagenow, $cpac;
84
85 // check if we are on the correct page or when a column is being refreshed by ajax.
86 if ( ( 'options-general.php' !== $pagenow ) && ( empty( $_POST['action'] ) || 'cpac_column_refresh' !== $_POST['action'] ) ) {
87 return;
88 }
89
90 // prevent PHP errors from SitePress
91 global $sitepress, $posts;
92 $posts = get_posts( array(
93 'post_type' => $storage_model->post_type,
94 'posts_per_page' => 1
95 ));
96
97 add_filter( 'manage_' . $storage_model->post_type . 's_columns', array( $sitepress, 'add_posts_management_column' ) );
98 }
99
100 public function register_column_labels() {
101 global $cpac;
102
103 // dont load this unless required by WPML
104 if ( ! isset( $_GET['page'] ) || 'wpml-string-translation/menu/string-translation.php' !== $_GET['page'] ) {
105 return;
106 }
107
108 foreach ( $cpac->storage_models as $storage_model ) {
109 foreach ( $storage_model->get_stored_columns() as $column_name => $options ) {
110 icl_register_string( 'Admin Columns', $storage_model->key . '_' . $column_name, stripslashes( $options['label'] ) );
111 }
112 }
113 }
114
115 public function register_translated_label( $label, $column_name, $column_options, $storage_model ) {
116
117 if ( function_exists( 'icl_t' ) ) {
118 $name = $storage_model->key . '_' . $column_name;
119 $label = icl_t( 'Admin Columns', $name, $label );
120 }
121 return $label;
122 }
123
124 public function is_cac_screen( $is_columns_screen ) {
125
126 if ( isset( $_GET['page'] ) && 'wpml-string-translation/menu/string-translation.php' == $_GET['page'] ) {
127 return true;
128 }
129 return $is_columns_screen;
130 }
131 }
132 new CPAC_WPML;
133