PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.3
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / modules / api-backups / classes / class-api-backups-helper.php

class-api-backups-helper.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.3, at modules/api-backups/classes/class-api-backups-helper.php

147 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Api Backups Utility
4 *
5 * @package MainWP\Dashboard
6 * @version 5.0
7 */
8
9 namespace MainWP\Dashboard\Module\ApiBackups;
10
11 /**
12 * Class Api_Backups_Utility
13 */
14 class Api_Backups_Helper {
15
16 /**
17 * Public static variable to hold the single instance of the class.
18 *
19 * @var mixed Default null
20 */
21 public static $instance = null;
22
23 /**
24 * Get Instance
25 *
26 * Creates public static instance.
27 *
28 * @static
29 *
30 * @return Api_Backups_Utility
31 */
32 public static function get_instance() {
33 if ( null === static::$instance ) {
34 static::$instance = new self();
35 }
36 return static::$instance;
37 }
38
39 /**
40 * Construct.
41 */
42 public function __construct() {
43 // constructor.
44 }
45
46
47 /**
48 * Clean URL.
49 * Remove http(s)://, www., and trailing slash(/) from the URL.
50 *
51 * @param string $url url.
52 * @return string clean url.
53 */
54 public static function clean_url( $url ) {
55 $clean_url = str_replace( array( 'https://www.', 'http://www.', 'https://', 'http://', 'www.' ), array( '', '', '', '', '' ), $url ); // NOSONAR - ok.
56 $clean_url = rtrim( $clean_url, '/' );
57 return $clean_url;
58 }
59
60 /**
61 * Get sites by website ID.
62 *
63 * @param int $website_id User ID.
64 * @param bool $selectGroups Select groups.
65 * @param array $extra_view get extra option fields.
66 *
67 * @return object|null Database query results or null on failure.
68 */
69 public static function get_website_by_id( $website_id, $selectGroups = false, $extra_view = array() ) {
70 $website = apply_filters( 'mainwp_getwebsite_by_id', false, $website_id, $selectGroups, $extra_view );
71 if ( ! empty( $website ) && is_object( $website ) ) {
72 return (array) $website;
73 }
74 return array();
75 }
76
77
78 /**
79 * Method update_website_option().
80 *
81 * Update the website option.
82 *
83 * @param object|int $website website object or ID.
84 * @param string $opt_name website.
85 * @param string $opt_value website.
86 */
87 public static function update_website_option( $website, $opt_name, $opt_value ) {
88 return apply_filters( 'mainwp_updatewebsiteoptions', false, $website, $opt_name, $opt_value );
89 }
90
91 /**
92 * Method get_website_options().
93 *
94 * Get the website options.
95 *
96 * @param object|int $website website object or ID.
97 * @param string|array $options Options name.
98 */
99 public static function get_website_options( $website, $options ) {
100 return apply_filters( 'mainwp_getwebsiteoptions', false, $website, $options );
101 }
102
103
104 /**
105 * Method fetch_object().
106 *
107 * Handle fetch object db.
108 *
109 * @param mixed $websites websites results.
110 *
111 * @return mixed results.
112 */
113 public static function fetch_object( $websites ) {
114 return apply_filters( 'mainwp_db_fetch_object', false, $websites );
115 }
116
117
118 /**
119 * Method free_result().
120 *
121 * Handle fetch result db.
122 *
123 * @param mixed $results websites results.
124 *
125 * @return mixed results.
126 */
127 public static function free_result( $results ) { //phpcs:ignore -- NOSONAR - complex.
128 if ( empty( $results ) ) {
129 return;
130 }
131 return apply_filters( 'mainwp_db_free_result', false, $results );
132 }
133
134 /**
135 * Method security_nonce().
136 *
137 * Handle security nonce.
138 *
139 * @param string $action security action.
140 */
141 public static function security_nonce( $action ) {
142 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
143 do_action( 'mainwp_secure_request', $action );
144 }
145 }
146 }
147