PluginProbe
Polylang / 2.0
Polylang v2.0
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.0, at modules/sync/settings-sync.php

99 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( $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 ) );
23 }
24
25 /**
26 * deactivates the module
27 *
28 * @since 1.8
29 */
30 public function deactivate() {
31 $this->options['sync'] = array();
32 update_option( 'polylang', $this->options );
33 }
34
35 /**
36 * displays the settings form
37 *
38 * @since 1.8
39 */
40 protected function form() {?>
41 <ul class="pll-inline-block-list"><?php
42 foreach ( self::list_metas_to_sync() as $key => $str ) {
43 printf(
44 '<li><label><input name="sync[%s]" type="checkbox" value="1" %s /> %s</label></li>',
45 esc_attr( $key ),
46 in_array( $key, $this->options['sync'] ) ? 'checked="checked"' : '',
47 esc_html( $str )
48 );
49 } ?>
50 </ul><?php
51 }
52
53 /**
54 * sanitizes the settings before saving
55 *
56 * @since 1.8
57 *
58 * @param array $options
59 */
60 protected function update( $options ) {
61 $newoptions['sync'] = empty( $options['sync'] ) ? array() : array_keys( $options['sync'], 1 );
62 return $newoptions; // take care to return only validated options
63 }
64
65 /**
66 * get the row actions
67 *
68 * @since 1.8
69 *
70 * @return array
71 */
72 protected function get_actions() {
73 return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' );
74 }
75
76 /**
77 * list the post metas to synchronize
78 *
79 * @since 1.0
80 *
81 * @return array
82 */
83 static public function list_metas_to_sync() {
84 return array(
85 'taxonomies' => __( 'Taxonomies', 'polylang' ),
86 'post_meta' => __( 'Custom fields', 'polylang' ),
87 'comment_status' => __( 'Comment status', 'polylang' ),
88 'ping_status' => __( 'Ping status', 'polylang' ),
89 'sticky_posts' => __( 'Sticky posts', 'polylang' ),
90 'post_date' => __( 'Published date', 'polylang' ),
91 'post_format' => __( 'Post format', 'polylang' ),
92 'post_parent' => __( 'Page parent', 'polylang' ),
93 '_wp_page_template' => __( 'Page template', 'polylang' ),
94 'menu_order' => __( 'Page order', 'polylang' ),
95 '_thumbnail_id' => __( 'Featured image', 'polylang' ),
96 );
97 }
98 }
99