PluginProbe
Polylang / 2.7
Polylang v2.7
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
polylang / modules / sync / settings-sync.php

settings-sync.php in Polylang 2.7, at modules/sync/settings-sync.php

106 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Settings class for synchronization settings management
5 *
6 * @since 1.8
7 */
8 class PLL_Settings_Sync extends PLL_Settings_Module {
9
10 /**
11 * Constructor
12 *
13 * @since 1.8
14 *
15 * @param object $polylang polylang object
16 */
17 public function __construct( &$polylang ) {
18 parent::__construct(
19 $polylang,
20 array(
21 'module' => 'sync',
22 'title' => __( 'Synchronization', 'polylang' ),
23 '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' ),
24 )
25 );
26 }
27
28 /**
29 * Deactivates the module
30 *
31 * @since 1.8
32 */
33 public function deactivate() {
34 $this->options['sync'] = array();
35 update_option( 'polylang', $this->options );
36 }
37
38 /**
39 * Displays the settings form
40 *
41 * @since 1.8
42 */
43 protected function form() {
44 ?>
45 <ul class="pll-inline-block-list">
46 <?php
47 foreach ( self::list_metas_to_sync() as $key => $str ) {
48 printf(
49 '<li><label><input name="sync[%s]" type="checkbox" value="1" %s /> %s</label></li>',
50 esc_attr( $key ),
51 checked( in_array( $key, $this->options['sync'] ), true, false ),
52 esc_html( $str )
53 );
54 }
55 ?>
56 </ul>
57 <?php
58 }
59
60 /**
61 * Sanitizes the settings before saving
62 *
63 * @since 1.8
64 *
65 * @param array $options
66 */
67 protected function update( $options ) {
68 $newoptions = array( 'sync' => empty( $options['sync'] ) ? array() : array_keys( $options['sync'], 1 ) );
69 return $newoptions; // take care to return only validated options
70 }
71
72 /**
73 * Get the row actions
74 *
75 * @since 1.8
76 *
77 * @return array
78 */
79 protected function get_actions() {
80 return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' );
81 }
82
83 /**
84 * List the post metas to synchronize
85 *
86 * @since 1.0
87 *
88 * @return array
89 */
90 public static function list_metas_to_sync() {
91 return array(
92 'taxonomies' => __( 'Taxonomies', 'polylang' ),
93 'post_meta' => __( 'Custom fields', 'polylang' ),
94 'comment_status' => __( 'Comment status', 'polylang' ),
95 'ping_status' => __( 'Ping status', 'polylang' ),
96 'sticky_posts' => __( 'Sticky posts', 'polylang' ),
97 'post_date' => __( 'Published date', 'polylang' ),
98 'post_format' => __( 'Post format', 'polylang' ),
99 'post_parent' => __( 'Page parent', 'polylang' ),
100 '_wp_page_template' => __( 'Page template', 'polylang' ),
101 'menu_order' => __( 'Page order', 'polylang' ),
102 '_thumbnail_id' => __( 'Featured image', 'polylang' ),
103 );
104 }
105 }
106