PluginProbe
Polylang / 3.3.1
Polylang v3.3.1
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 3.3.1, at modules/sync/settings-sync.php

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