PluginProbe
Polylang / 2.5.2
Polylang v2.5.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | settings/settings-cpt.php +8 -46 2.82.5.2 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Settings class for custom post types and taxonomies language and translation management
8 5 *
@@ -8,44 +5,11 @@
8 5 *
9 6 * @since 1.8
10 7 */
11 8 class PLL_Settings_CPT extends PLL_Settings_Module {
12 - /**
13 - * Stores the display order priority.
14 - *
15 - * @var int
16 - */
17 - public $priority = 40;
9 + private $post_types, $disabled_post_types, $taxonomies, $disabled_taxonomies;
18 10
19 11 /**
20 - * The list of post types to show in the form.
21 - *
22 - * @var array
23 - */
24 - private $post_types;
25 -
26 - /**
27 - * The list of post types to disable in the form.
28 - *
29 - * @var array
30 - */
31 - private $disabled_post_types;
32 -
33 - /**
34 - * The list of taxonomies to show in the form.
35 - *
36 - * @var array
37 - */
38 - private $taxonomies;
39 -
40 - /**
41 - * The list of taxonomies to disable in the form.
42 - *
43 - * @var array
44 - */
45 - private $disabled_taxonomies;
46 -
47 - /**
48 12 * Constructor
49 13 *
50 14 * @since 1.8
51 15 *
@@ -56,9 +20,9 @@
56 20 $polylang,
57 21 array(
58 22 'module' => 'cpt',
59 23 'title' => __( 'Custom post types and Taxonomies', 'polylang' ),
60 - 'description' => __( 'Activate languages and translations management for the custom post types and the taxonomies.', 'polylang' ),
24 + 'description' => __( 'Activate the languages and translations management for the custom post types and taxonomies.', 'polylang' ),
61 25 )
62 26 );
63 27
64 28 $public_post_types = get_post_types( array( 'public' => true, '_builtin' => false ) );
@@ -64,10 +28,10 @@
64 28 $public_post_types = get_post_types( array( 'public' => true, '_builtin' => false ) );
65 29 /** This filter is documented in include/model.php */
66 30 $this->post_types = array_unique( apply_filters( 'pll_get_post_types', $public_post_types, true ) );
67 31
32 + $programmatically_active_post_types = array_unique( apply_filters( 'pll_get_post_types', array(), false ) );
68 33 /** This filter is documented in include/model.php */
69 - $programmatically_active_post_types = array_unique( apply_filters( 'pll_get_post_types', array(), false ) );
70 34 $this->disabled_post_types = array_intersect( $programmatically_active_post_types, $this->post_types );
71 35
72 36 $public_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) );
73 37 $public_taxonomies = array_diff( $public_taxonomies, get_taxonomies( array( '_pll' => true ) ) );
@@ -73,10 +37,10 @@
73 37 $public_taxonomies = array_diff( $public_taxonomies, get_taxonomies( array( '_pll' => true ) ) );
74 38 /** This filter is documented in include/model.php */
75 39 $this->taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', $public_taxonomies, true ) );
76 40
41 + $programmatically_active_taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', array(), false ) );
77 42 /** This filter is documented in include/model.php */
78 - $programmatically_active_taxonomies = array_unique( apply_filters( 'pll_get_taxonomies', array(), false ) );
79 43 $this->disabled_taxonomies = array_intersect( $programmatically_active_taxonomies, $this->taxonomies );
80 44 }
81 45
82 46 /**
@@ -106,10 +70,10 @@
106 70 $disabled = in_array( $post_type, $this->disabled_post_types );
107 71 printf(
108 72 '<li><label><input name="post_types[%s]" type="checkbox" value="1" %s %s/> %s</label></li>',
109 73 esc_attr( $post_type ),
110 - checked( in_array( $post_type, $this->options['post_types'] ) || $disabled, true, false ),
111 - disabled( $disabled, true, false ),
74 + in_array( $post_type, $this->options['post_types'] ) || $disabled ? 'checked="checked"' : '',
75 + $disabled ? 'disabled="disabled"' : '',
112 76 esc_html( $pt->labels->name )
113 77 );
114 78 }
115 79 }
@@ -130,10 +94,10 @@
130 94 $disabled = in_array( $taxonomy, $this->disabled_taxonomies );
131 95 printf(
132 96 '<li><label><input name="taxonomies[%s]" type="checkbox" value="1" %s %s/> %s</label></li>',
133 97 esc_attr( $taxonomy ),
134 - checked( in_array( $taxonomy, $this->options['taxonomies'] ) || $disabled, true, false ),
135 - disabled( $disabled, true, false ),
98 + in_array( $taxonomy, $this->options['taxonomies'] ) || $disabled ? 'checked="checked"' : '',
99 + $disabled ? 'disabled="disabled"' : '',
136 100 esc_html( $tax->labels->name )
137 101 );
138 102 }
139 103 }
@@ -151,10 +115,8 @@
151 115 *
152 116 * @param array $options
153 117 */
154 118 protected function update( $options ) {
155 - $newoptions = array();
156 -
157 119 foreach ( array( 'post_types', 'taxonomies' ) as $key ) {
158 120 $newoptions[ $key ] = empty( $options[ $key ] ) ? array() : array_keys( $options[ $key ], 1 );
159 121 }
160 122 return $newoptions; // Take care to return only validated options