PluginProbe
Polylang / 1.8.2
Polylang v1.8.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
polylang / modules / sync / settings-sync.php

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

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