PluginProbe
Polylang / 2.3.6
Polylang v2.3.6
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 | settings/settings-module.php +23 -100 2.82.3.6 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Base class for all settings
8 5 *
@@ -8,87 +5,14 @@
8 5 *
9 6 * @since 1.8
10 7 */
11 8 class PLL_Settings_Module {
12 - /**
13 - * Stores the plugin options.
14 - *
15 - * @var array
16 - */
9 + public $active_option, $configure;
10 + public $module, $title, $description;
17 11 public $options;
12 + protected $action_links, $buttons, $form = false;
18 13
19 14 /**
20 - * Instance of PLL_Model.
21 - *
22 - * @var PLL_Model
23 - */
24 - public $model;
25 -
26 - /**
27 - * Instance of a child class of PLL_Links_Model.
28 - *
29 - * @var PLL_Links_Model
30 - */
31 - public $links_model;
32 -
33 - /**
34 - * Stores if the module is active.
35 - *
36 - * @var bool
37 - */
38 - public $active_option;
39 -
40 - /**
41 - * Stores the display order priority.
42 - *
43 - * @var int
44 - */
45 - public $priority = 100;
46 -
47 - /**
48 - * Stores the module name.
49 - * It must be unique.
50 - *
51 - * @var string
52 - */
53 - public $module;
54 -
55 - /**
56 - * Stores the module title.
57 - *
58 - * @var string
59 - */
60 - public $title;
61 -
62 - /**
63 - * Stores the module description.
64 - *
65 - * @var string
66 - */
67 - public $description;
68 -
69 - /**
70 - * Stores the settings actions.
71 - *
72 - * @var array
73 - */
74 - protected $action_links;
75 -
76 - /**
77 - * Stores html fragment for the buttons.
78 - *
79 - * @var array
80 - */
81 - protected $buttons;
82 -
83 - /**
84 - * Stores html form when provided by a child class.
85 - *
86 - * @var bool|string
87 - */
88 - protected $form = false;
89 -
90 - /**
91 15 * Constructor
92 16 *
93 17 * @since 1.8
94 18 *
@@ -99,16 +23,13 @@
99 23 $this->options = &$polylang->options;
100 24 $this->model = &$polylang->model;
101 25 $this->links_model = &$polylang->links_model;
102 26
103 - $args = wp_parse_args(
104 - $args,
105 - array(
106 - 'title' => '',
107 - 'description' => '',
108 - 'active_option' => false,
109 - )
110 - );
27 + $args = wp_parse_args( $args, array(
28 + 'title' => '',
29 + 'description' => '',
30 + 'active_option' => false,
31 + ) );
111 32
112 33 foreach ( $args as $prop => $value ) {
113 34 $this->$prop = $value;
114 35 }
@@ -114,33 +35,37 @@
114 35 }
115 36
116 37 // All possible action links, even if not always a link ;-)
117 38 $this->action_links = array(
118 - 'configure' => sprintf(
39 + 'configure' => sprintf(
119 40 '<a title="%s" href="%s">%s</a>',
120 41 esc_attr__( 'Configure this module', 'polylang' ),
121 42 '#',
122 43 esc_html__( 'Settings', 'polylang' )
123 44 ),
124 - 'deactivate' => sprintf(
45 +
46 + 'deactivate' => sprintf(
125 47 '<a title="%s" href="%s">%s</a>',
126 48 esc_attr__( 'Deactivate this module', 'polylang' ),
127 - esc_url( wp_nonce_url( '?page=mlang&tab=modules&pll_action=deactivate&noheader=true&module=' . $this->module, 'pll_deactivate' ) ),
49 + wp_nonce_url( '?page=mlang&amp;tab=modules&amp;pll_action=deactivate&amp;noheader=true&amp;module=' . $this->module, 'pll_deactivate' ),
128 50 esc_html__( 'Deactivate', 'polylang' )
129 51 ),
130 - 'activate' => sprintf(
52 +
53 + 'activate' => sprintf(
131 54 '<a title="%s" href="%s">%s</a>',
132 55 esc_attr__( 'Activate this module', 'polylang' ),
133 - esc_url( wp_nonce_url( '?page=mlang&tab=modules&pll_action=activate&noheader=true&module=' . $this->module, 'pll_activate' ) ),
56 + wp_nonce_url( '?page=mlang&amp;tab=modules&amp;pll_action=activate&amp;noheader=true&amp;module=' . $this->module, 'pll_activate' ),
134 57 esc_html__( 'Activate', 'polylang' )
135 58 ),
136 - 'activated' => esc_html__( 'Activated', 'polylang' ),
59 +
60 + 'activated' => esc_html__( 'Activated', 'polylang' ),
61 +
137 62 'deactivated' => esc_html__( 'Deactivated', 'polylang' ),
138 63 );
139 64
140 65 $this->buttons = array(
141 - 'cancel' => sprintf( '<button type="button" class="button button-secondary cancel">%s</button>', esc_html__( 'Cancel', 'polylang' ) ),
142 - 'save' => sprintf( '<button type="button" class="button button-primary save">%s</button>', esc_html__( 'Save Changes', 'polylang' ) ),
66 + 'cancel' => sprintf( '<button type="button" class="button button-secondary cancel">%s</button>', esc_html__( 'Cancel' ) ),
67 + 'save' => sprintf( '<button type="button" class="button button-primary save">%s</button>', esc_html__( 'Save Changes' ) ),
143 68 );
144 69
145 70 // Ajax action to save options
146 71 add_action( 'wp_ajax_pll_save_options', array( $this, 'save_options' ) );
@@ -230,9 +155,9 @@
230 155 if ( ! current_user_can( 'manage_options' ) ) {
231 156 wp_die( -1 );
232 157 }
233 158
234 - if ( isset( $_POST['module'] ) && $this->module === $_POST['module'] ) {
159 + if ( $this->module == $_POST['module'] ) {
235 160 // It's up to the child class to decide which options are saved, whether there are errors or not
236 161 $post = array_diff_key( $_POST, array_flip( array( 'action', 'module', 'pll_ajax_backend', '_pll_nonce' ) ) );
237 162 $options = $this->update( $post );
238 163 $this->options = array_merge( $this->options, $options );
@@ -248,9 +173,9 @@
248 173 ob_start();
249 174
250 175 if ( ! get_settings_errors() ) {
251 176 // Send update message
252 - add_settings_error( 'general', 'settings_updated', __( 'Settings saved.', 'polylang' ), 'updated' );
177 + add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' );
253 178 settings_errors();
254 179 $x = new WP_Ajax_Response( array( 'what' => 'success', 'data' => ob_get_clean() ) );
255 180 $x->send();
256 181 } else {
@@ -269,10 +194,8 @@
269 194 *
270 195 * @return array
271 196 */
272 197 protected function get_actions() {
273 - $actions = array();
274 -
275 198 if ( $this->is_active() && $this->get_form() ) {
276 199 $actions[] = 'configure';
277 200 }
278 201
@@ -307,9 +230,9 @@
307 230 */
308 231 protected function default_upgrade_message() {
309 232 return sprintf(
310 233 '%s <a href="%s">%s</a>',
311 - __( 'To enable this feature, you need Polylang Pro.', 'polylang' ),
234 + __( 'You need Polylang Pro to enable this feature.', 'polylang' ),
312 235 'https://polylang.pro',
313 236 __( 'Upgrade now.', 'polylang' )
314 237 );
315 238 }