| @@ -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 | * |
| @@ -123,15 +47,15 @@ | ||
| 123 | 47 | ), |
| 124 | 48 | 'deactivate' => sprintf( |
| 125 | 49 | '<a title="%s" href="%s">%s</a>', |
| 126 | 50 | 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' ) ), | |
| 51 | + wp_nonce_url( '?page=mlang&tab=modules&pll_action=deactivate&noheader=true&module=' . $this->module, 'pll_deactivate' ), | |
| 128 | 52 | esc_html__( 'Deactivate', 'polylang' ) |
| 129 | 53 | ), |
| 130 | 54 | 'activate' => sprintf( |
| 131 | 55 | '<a title="%s" href="%s">%s</a>', |
| 132 | 56 | 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' ) ), | |
| 57 | + wp_nonce_url( '?page=mlang&tab=modules&pll_action=activate&noheader=true&module=' . $this->module, 'pll_activate' ), | |
| 134 | 58 | esc_html__( 'Activate', 'polylang' ) |
| 135 | 59 | ), |
| 136 | 60 | 'activated' => esc_html__( 'Activated', 'polylang' ), |
| 137 | 61 | 'deactivated' => esc_html__( 'Deactivated', 'polylang' ), |
| @@ -137,10 +61,10 @@ | ||
| 137 | 61 | 'deactivated' => esc_html__( 'Deactivated', 'polylang' ), |
| 138 | 62 | ); |
| 139 | 63 | |
| 140 | 64 | $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' ) ), | |
| 65 | + 'cancel' => sprintf( '<button type="button" class="button button-secondary cancel">%s</button>', esc_html__( 'Cancel' ) ), | |
| 66 | + 'save' => sprintf( '<button type="button" class="button button-primary save">%s</button>', esc_html__( 'Save Changes' ) ), | |
| 143 | 67 | ); |
| 144 | 68 | |
| 145 | 69 | // Ajax action to save options |
| 146 | 70 | add_action( 'wp_ajax_pll_save_options', array( $this, 'save_options' ) ); |
| @@ -230,9 +154,9 @@ | ||
| 230 | 154 | if ( ! current_user_can( 'manage_options' ) ) { |
| 231 | 155 | wp_die( -1 ); |
| 232 | 156 | } |
| 233 | 157 | |
| 234 | - if ( isset( $_POST['module'] ) && $this->module === $_POST['module'] ) { | |
| 158 | + if ( $this->module == $_POST['module'] ) { | |
| 235 | 159 | // It's up to the child class to decide which options are saved, whether there are errors or not |
| 236 | 160 | $post = array_diff_key( $_POST, array_flip( array( 'action', 'module', 'pll_ajax_backend', '_pll_nonce' ) ) ); |
| 237 | 161 | $options = $this->update( $post ); |
| 238 | 162 | $this->options = array_merge( $this->options, $options ); |
| @@ -248,9 +172,9 @@ | ||
| 248 | 172 | ob_start(); |
| 249 | 173 | |
| 250 | 174 | if ( ! get_settings_errors() ) { |
| 251 | 175 | // Send update message |
| 252 | - add_settings_error( 'general', 'settings_updated', __( 'Settings saved.', 'polylang' ), 'updated' ); | |
| 176 | + add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' ); | |
| 253 | 177 | settings_errors(); |
| 254 | 178 | $x = new WP_Ajax_Response( array( 'what' => 'success', 'data' => ob_get_clean() ) ); |
| 255 | 179 | $x->send(); |
| 256 | 180 | } else { |
| @@ -269,10 +193,8 @@ | ||
| 269 | 193 | * |
| 270 | 194 | * @return array |
| 271 | 195 | */ |
| 272 | 196 | protected function get_actions() { |
| 273 | - $actions = array(); | |
| 274 | - | |
| 275 | 197 | if ( $this->is_active() && $this->get_form() ) { |
| 276 | 198 | $actions[] = 'configure'; |
| 277 | 199 | } |
| 278 | 200 | |
| @@ -307,9 +229,9 @@ | ||
| 307 | 229 | */ |
| 308 | 230 | protected function default_upgrade_message() { |
| 309 | 231 | return sprintf( |
| 310 | 232 | '%s <a href="%s">%s</a>', |
| 311 | - __( 'To enable this feature, you need Polylang Pro.', 'polylang' ), | |
| 233 | + __( 'You need Polylang Pro to enable this feature.', 'polylang' ), | |
| 312 | 234 | 'https://polylang.pro', |
| 313 | 235 | __( 'Upgrade now.', 'polylang' ) |
| 314 | 236 | ); |
| 315 | 237 | } |