PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.0.11
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.0.11
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 6.0.11, at modules/api-backups/classes/class-api-backups-helper.php

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