| @@ -1,5 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * @package Polylang | |
| 4 | + */ | |
| 2 | 5 | |
| 3 | 6 | /** |
| 4 | 7 | * Base class for all settings |
| 5 | 8 | * |
| @@ -5,14 +8,85 @@ | ||
| 5 | 8 | * |
| 6 | 9 | * @since 1.8 |
| 7 | 10 | */ |
| 8 | 11 | class PLL_Settings_Module { |
| 9 | - public $active_option, $configure; | |
| 10 | - public $module, $title, $description; | |
| 12 | + /** | |
| 13 | + * Stores the plugin options. | |
| 14 | + * | |
| 15 | + * @var array | |
| 16 | + */ | |
| 11 | 17 | public $options; |
| 12 | - protected $action_links, $buttons, $form = false; | |
| 13 | 18 | |
| 14 | 19 | /** |
| 20 | + * @var PLL_Model | |
| 21 | + */ | |
| 22 | + public $model; | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * Instance of a child class of PLL_Links_Model. | |
| 26 | + * | |
| 27 | + * @var PLL_Links_Model | |
| 28 | + */ | |
| 29 | + public $links_model; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * Stores if the module is active. | |
| 33 | + * | |
| 34 | + * @var bool | |
| 35 | + */ | |
| 36 | + public $active_option; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * Stores the display order priority. | |
| 40 | + * | |
| 41 | + * @var int | |
| 42 | + */ | |
| 43 | + public $priority = 100; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Stores the module name. | |
| 47 | + * It must be unique. | |
| 48 | + * | |
| 49 | + * @var string | |
| 50 | + */ | |
| 51 | + public $module; | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Stores the module title. | |
| 55 | + * | |
| 56 | + * @var string | |
| 57 | + */ | |
| 58 | + public $title; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Stores the module description. | |
| 62 | + * | |
| 63 | + * @var string | |
| 64 | + */ | |
| 65 | + public $description; | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Stores the settings actions. | |
| 69 | + * | |
| 70 | + * @var array | |
| 71 | + */ | |
| 72 | + protected $action_links; | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * Stores html fragment for the buttons. | |
| 76 | + * | |
| 77 | + * @var array | |
| 78 | + */ | |
| 79 | + protected $buttons; | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * Stores html form when provided by a child class. | |
| 83 | + * | |
| 84 | + * @var bool|string | |
| 85 | + */ | |
| 86 | + protected $form = false; | |
| 87 | + | |
| 88 | + /** | |
| 15 | 89 | * Constructor |
| 16 | 90 | * |
| 17 | 91 | * @since 1.8 |
| 18 | 92 | * |
| @@ -84,8 +158,10 @@ | ||
| 84 | 158 | /** |
| 85 | 159 | * Activates the module |
| 86 | 160 | * |
| 87 | 161 | * @since 1.8 |
| 162 | + * | |
| 163 | + * @return void | |
| 88 | 164 | */ |
| 89 | 165 | public function activate() { |
| 90 | 166 | if ( ! empty( $this->active_option ) ) { |
| 91 | 167 | $this->options[ $this->active_option ] = true; |
| @@ -96,8 +172,10 @@ | ||
| 96 | 172 | /** |
| 97 | 173 | * Deactivates the module |
| 98 | 174 | * |
| 99 | 175 | * @since 1.8 |
| 176 | + * | |
| 177 | + * @return void | |
| 100 | 178 | */ |
| 101 | 179 | public function deactivate() { |
| 102 | 180 | if ( ! empty( $this->active_option ) ) { |
| 103 | 181 | $this->options[ $this->active_option ] = false; |
| @@ -108,8 +186,10 @@ | ||
| 108 | 186 | /** |
| 109 | 187 | * Protected method to display a configuration form |
| 110 | 188 | * |
| 111 | 189 | * @since 1.8 |
| 190 | + * | |
| 191 | + * @return void | |
| 112 | 192 | */ |
| 113 | 193 | protected function form() { |
| 114 | 194 | // Child classes can provide a form |
| 115 | 195 | } |
| @@ -139,9 +219,9 @@ | ||
| 139 | 219 | * |
| 140 | 220 | * @param array $options Raw options |
| 141 | 221 | * @return array Options |
| 142 | 222 | */ |
| 143 | - protected function update( $options ) { | |
| 223 | + protected function update( $options ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 144 | 224 | return array(); // It's responsibility of the child class to decide what is saved |
| 145 | 225 | } |
| 146 | 226 | |
| 147 | 227 | /** |
| @@ -147,8 +227,10 @@ | ||
| 147 | 227 | /** |
| 148 | 228 | * Ajax method to save the options |
| 149 | 229 | * |
| 150 | 230 | * @since 1.8 |
| 231 | + * | |
| 232 | + * @return void | |
| 151 | 233 | */ |
| 152 | 234 | public function save_options() { |
| 153 | 235 | check_ajax_referer( 'pll_options', '_pll_nonce' ); |
| 154 | 236 | if ( ! current_user_can( 'manage_options' ) ) { |
| @@ -186,13 +268,13 @@ | ||
| 186 | 268 | } |
| 187 | 269 | } |
| 188 | 270 | |
| 189 | 271 | /** |
| 190 | - * Get the row actions | |
| 272 | + * Get the row actions. | |
| 191 | 273 | * |
| 192 | 274 | * @since 1.8 |
| 193 | 275 | * |
| 194 | - * @return array | |
| 276 | + * @return string[] | |
| 195 | 277 | */ |
| 196 | 278 | protected function get_actions() { |
| 197 | 279 | $actions = array(); |
| 198 | 280 | |
| @@ -211,13 +293,13 @@ | ||
| 211 | 293 | return $actions; |
| 212 | 294 | } |
| 213 | 295 | |
| 214 | 296 | /** |
| 215 | - * Get the actions links | |
| 297 | + * Get the actions links. | |
| 216 | 298 | * |
| 217 | 299 | * @since 1.8 |
| 218 | 300 | * |
| 219 | - * @return array | |
| 301 | + * @return string[] Action links. | |
| 220 | 302 | */ |
| 221 | 303 | public function get_action_links() { |
| 222 | 304 | return array_intersect_key( $this->action_links, array_flip( $this->get_actions() ) ); |
| 223 | 305 | } |
| @@ -249,13 +331,13 @@ | ||
| 249 | 331 | return ''; |
| 250 | 332 | } |
| 251 | 333 | |
| 252 | 334 | /** |
| 253 | - * Get the buttons | |
| 335 | + * Get the buttons. | |
| 254 | 336 | * |
| 255 | 337 | * @since 1.9 |
| 256 | 338 | * |
| 257 | - * @return array | |
| 339 | + * @return string[] An array of html fragment for the buttons. | |
| 258 | 340 | */ |
| 259 | 341 | public function get_buttons() { |
| 260 | 342 | return $this->buttons; |
| 261 | 343 | } |