PluginProbe ʕ •ᴥ•ʔ
ShortPixel Image Optimizer – Optimize Images, Convert WebP & AVIF / 6.5.3
ShortPixel Image Optimizer – Optimize Images, Convert WebP & AVIF v6.5.3
6.5.3 6.5.2 6.5.1 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.6 1.2.0 1.3.1 1.3.5 1.4.0 1.4.1 1.5.0 1.5.3 1.6.0 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.6 1.6.7 1.6.8 1.6.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.2 3.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 4.0.0 4.0.1 4.0.2 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.7 4.10.0 4.10.1 4.10.2 4.10.3 4.10.4 4.10.5 4.11.0 4.11.1 4.11.2 4.11.3 4.12.0 4.12.1 4.12.2 4.12.3 4.12.4 4.12.5 4.12.6 4.12.7 4.12.8 4.13.0 4.13.1 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.15.0 4.15.1 4.15.2 4.15.3 4.15.4 4.16.0 4.16.1 4.16.2 4.16.3 4.16.4 4.17.0 4.17.1 4.17.2 4.17.3 4.17.4 4.18.0 4.18.1 4.19.0 4.19.1 4.19.2 4.19.3 4.2.0 4.2.1 4.2.2 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.20.0 4.20.1 4.20.2 4.21.0 4.21.1 4.21.2 4.22.0 4.22.1 4.22.10 4.22.2 4.22.3 4.22.4 4.22.5 4.22.6 4.22.7 4.22.8 4.22.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.5.3 4.5.5 4.6.0 4.7.0 4.7.1 4.7.2 4.8.0 4.8.1 4.8.2 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 4.9.0 4.9.1 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.2.0 5.2.1 5.2.2 5.2.3 5.3.0 5.4.0 5.4.1 5.4.2 5.4.3 5.5.0 5.5.1 5.5.2 5.5.3 5.5.4 5.5.5 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.2.2 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.4.0 6.4.1 6.4.2 6.4.3 6.4.4 6.5.0
shortpixel-image-optimiser / class / Controller.php
shortpixel-image-optimiser / class Last commit date
Controller 6 days ago Helper 3 weeks ago Model 6 days ago external 6 days ago view 6 days ago .gitignore 5 years ago BuildAutoLoader.php 3 weeks ago Controller.php 3 weeks ago Model.php 3 weeks ago ViewController.php 3 weeks ago plugin.json 1 month ago
Controller.php
62 lines
1 <?php
2 namespace ShortPixel;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 use ShortPixel\Helper\UiHelper as UiHelper;
9
10 /**
11 * Proto parent class for all controllers.
12 *
13 * So far none of the controllers need or implement similar enough functions for a parent
14 * to make sense. Perhaps this will change over time, so most controllers extend this parent.
15 *
16 * @package ShortPixel
17 */
18
19 class Controller
20 {
21
22 /** @var mixed|null Connected model instance. */
23 protected $model;
24
25 /** @var bool Whether the current user has sufficient privileges to use the plugin. */
26 protected $userIsAllowed = false;
27
28 public function __construct()
29 {
30 $this->userIsAllowed = $this->checkUserPrivileges();
31 }
32
33
34 /**
35 * Determines whether the current WordPress user has the required capabilities
36 * to interact with the plugin (manage_options, upload_files, or edit_posts).
37 *
38 * @return bool True if the user is allowed, false otherwise.
39 */
40 protected function checkUserPrivileges()
41 {
42 if ((current_user_can( 'manage_options' ) || current_user_can( 'upload_files' ) || current_user_can( 'edit_posts' )))
43 return true;
44
45 return false;
46 }
47
48 /**
49 * Formats a number for display, delegating to UiHelper::formatNumber.
50 *
51 * @param int|float $number The number to format.
52 * @param int $precision Number of decimal places. Default 2.
53 * @return string Formatted number string.
54 */
55 // helper for a helper.
56 protected function formatNumber($number, $precision = 2)
57 {
58 return UIHelper::formatNumber($number, $precision);
59 }
60
61 } // class
62