| 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 === self::$instance ) { |
| 34 |
self::$instance = new self(); |
| 35 |
} |
| 36 |
return self::$instance; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Construct. |
| 41 |
*/ |
| 42 |
public function __construct() { |
| 43 |
// constructor. |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Get sites by website ID. |
| 48 |
* |
| 49 |
* @param int $website_id User ID. |
| 50 |
* @param bool $selectGroups Select groups. |
| 51 |
* @param array $extra_view get extra option fields. |
| 52 |
* |
| 53 |
* @return object|null Database query results or null on failure. |
| 54 |
*/ |
| 55 |
public static function get_website_by_id( $website_id, $selectGroups = false, $extra_view = array() ) { |
| 56 |
$website = apply_filters( 'mainwp_getwebsite_by_id', false, $website_id, $selectGroups, $extra_view ); |
| 57 |
if ( ! empty( $website ) && is_object( $website ) ) { |
| 58 |
return (array) $website; |
| 59 |
} |
| 60 |
return array(); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
/** |
| 65 |
* Method update_website_option(). |
| 66 |
* |
| 67 |
* Update the website option. |
| 68 |
* |
| 69 |
* @param object|int $website website object or ID. |
| 70 |
* @param string $opt_name website. |
| 71 |
* @param string $opt_value website. |
| 72 |
*/ |
| 73 |
public static function update_website_option( $website, $opt_name, $opt_value ) { |
| 74 |
return apply_filters( 'mainwp_updatewebsiteoptions', false, $website, $opt_name, $opt_value ); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Method get_website_options(). |
| 79 |
* |
| 80 |
* Get the website options. |
| 81 |
* |
| 82 |
* @param object|int $website website object or ID. |
| 83 |
* @param string|array $options Options name. |
| 84 |
*/ |
| 85 |
public static function get_website_options( $website, $options ) { |
| 86 |
return apply_filters( 'mainwp_getwebsiteoptions', false, $website, $options ); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
/** |
| 91 |
* Method fetch_object(). |
| 92 |
* |
| 93 |
* Handle fetch object db. |
| 94 |
* |
| 95 |
* @param mixed $websites websites results. |
| 96 |
* |
| 97 |
* @return mixed results. |
| 98 |
*/ |
| 99 |
public static function fetch_object( $websites ) { |
| 100 |
return apply_filters( 'mainwp_db_fetch_object', false, $websites ); |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
/** |
| 105 |
* Method free_result(). |
| 106 |
* |
| 107 |
* Handle fetch result db. |
| 108 |
* |
| 109 |
* @param mixed $results websites results. |
| 110 |
* |
| 111 |
* @return mixed results. |
| 112 |
*/ |
| 113 |
public static function free_result( $results ) { |
| 114 |
if ( empty( $results ) ) { |
| 115 |
return; |
| 116 |
} |
| 117 |
return apply_filters( 'mainwp_db_free_result', false, $results ); |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* Method security_nonce(). |
| 122 |
* |
| 123 |
* Handle security nonce. |
| 124 |
* |
| 125 |
* @param string $action security action. |
| 126 |
*/ |
| 127 |
public static function security_nonce( $action ) { |
| 128 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 129 |
do_action( 'mainwp_secure_request', $action ); |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
|