PluginProbe
Polylang / 2.0.3
Polylang v2.0.3
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 | modules/sync/settings-sync.php +20 -36 3.02.0.3 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Settings class for synchronization settings management
8 5 *
@@ -8,17 +5,11 @@
8 5 *
9 6 * @since 1.8
10 7 */
11 8 class PLL_Settings_Sync extends PLL_Settings_Module {
12 - /**
13 - * Stores the display order priority.
14 - *
15 - * @var int
16 - */
17 - public $priority = 50;
18 9
19 10 /**
20 - * Constructor
11 + * constructor
21 12 *
22 13 * @since 1.8
23 14 *
24 15 * @param object $polylang polylang object
@@ -23,20 +14,17 @@
23 14 *
24 15 * @param object $polylang polylang object
25 16 */
26 17 public function __construct( &$polylang ) {
27 - parent::__construct(
28 - $polylang,
29 - array(
30 - 'module' => 'sync',
31 - 'title' => __( 'Synchronization', 'polylang' ),
32 - 'description' => __( 'The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page.', 'polylang' ),
33 - )
34 - );
18 + parent::__construct( $polylang, array(
19 + 'module' => 'sync',
20 + 'title' => __( 'Synchronization', 'polylang' ),
21 + 'description' => __( 'The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page.', 'polylang' ),
22 + ) );
35 23 }
36 24
37 25 /**
38 - * Deactivates the module
26 + * deactivates the module
39 27 *
40 28 * @since 1.8
41 29 */
42 30 public function deactivate() {
@@ -44,31 +32,27 @@
44 32 update_option( 'polylang', $this->options );
45 33 }
46 34
47 35 /**
48 - * Displays the settings form
36 + * displays the settings form
49 37 *
50 38 * @since 1.8
51 39 */
52 - protected function form() {
53 - ?>
54 - <ul class="pll-inline-block-list">
55 - <?php
40 + protected function form() {?>
41 + <ul class="pll-inline-block-list"><?php
56 42 foreach ( self::list_metas_to_sync() as $key => $str ) {
57 43 printf(
58 44 '<li><label><input name="sync[%s]" type="checkbox" value="1" %s /> %s</label></li>',
59 45 esc_attr( $key ),
60 - checked( in_array( $key, $this->options['sync'] ), true, false ),
46 + in_array( $key, $this->options['sync'] ) ? 'checked="checked"' : '',
61 47 esc_html( $str )
62 48 );
63 - }
64 - ?>
65 - </ul>
66 - <?php
49 + } ?>
50 + </ul><?php
67 51 }
68 52
69 53 /**
70 - * Sanitizes the settings before saving
54 + * sanitizes the settings before saving
71 55 *
72 56 * @since 1.8
73 57 *
74 58 * @param array $options
@@ -73,18 +57,18 @@
73 57 *
74 58 * @param array $options
75 59 */
76 60 protected function update( $options ) {
77 - $newoptions = array( 'sync' => empty( $options['sync'] ) ? array() : array_keys( $options['sync'], 1 ) );
61 + $newoptions['sync'] = empty( $options['sync'] ) ? array() : array_keys( $options['sync'], 1 );
78 62 return $newoptions; // take care to return only validated options
79 63 }
80 64
81 65 /**
82 - * Get the row actions.
66 + * get the row actions
83 67 *
84 68 * @since 1.8
85 69 *
86 - * @return string[] Row actions.
70 + * @return array
87 71 */
88 72 protected function get_actions() {
89 73 return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' );
90 74 }
@@ -89,15 +73,15 @@
89 73 return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' );
90 74 }
91 75
92 76 /**
93 - * Get the list of synchronization settings.
77 + * list the post metas to synchronize
94 78 *
95 79 * @since 1.0
96 80 *
97 - * @return string[] Array synchronization options.
81 + * @return array
98 82 */
99 - public static function list_metas_to_sync() {
83 + static public function list_metas_to_sync() {
100 84 return array(
101 85 'taxonomies' => __( 'Taxonomies', 'polylang' ),
102 86 'post_meta' => __( 'Custom fields', 'polylang' ),
103 87 'comment_status' => __( 'Comment status', 'polylang' ),