# mainwp/trunk/modules/api-backups/classes/class-api-backups-manager.php

MainWP Dashboard: Self-hosted WordPress Management for Agencies, version trunk. 109 lines.

- Page: https://pluginprobe.com/plugins/mainwp/trunk/code/modules/api-backups/classes/class-api-backups-manager.php
- Raw: https://pluginprobe.com/plugins/mainwp/trunk/raw/modules/api-backups/classes/class-api-backups-manager.php
- Modified: 2026-02-24T16:08:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/mainwp/trunk/code/modules/api-backups/classes/class-api-backups-manager.php#L10-L20`.

```php
<?php
/**
 * MainWP Module API Backups Admin class.
 *
 * @package MainWP\Dashboard
 * @version 5.0
 */

namespace MainWP\Dashboard\Module\ApiBackups;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Class Api_Backups_Manager
 */
class Api_Backups_Manager {


    /**
     * Static variable to hold the single instance of the class.
     *
     * @static
     *
     * @var mixed Default null
     */
    public static $instance = null;

    /**
     * Get Instance
     *
     * Creates public static instance.
     *
     * @static
     *
     * @return Api_Backups_Manager
     */
    public static function get_instance() {
        if ( null === static::$instance ) {
            static::$instance = new self();
        }
        return static::$instance;
    }

    /**
     * Constructor
     *
     * Runs each time the class is called.
     */
    public function __construct() {
        spl_autoload_register( array( $this, 'autoload' ) );
        Api_Backups_Admin::get_instance();
    }

    /**
     * Autoloader for classes.
     *
     * @param string $class_name class name.
     */
    public function autoload( $class_name ) {

        if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class_name, $matches ) ) {
            return;
        }

        static $reflection;

        if ( empty( $reflection ) ) {
            $reflection = new \ReflectionObject( $this );
        }

        if ( $reflection->getNamespaceName() !== $matches['namespace'] ) {
            return;
        }

        $autoload_name = $matches['autoload'];
        $autoload_dir  = static::get_location_path();

        $load_dirs = array(
            'classes' => 'class',
        );
        foreach ( $load_dirs as $dir => $prefix ) {
            $dir           = $dir . DIRECTORY_SEPARATOR;
            $autoload_path = sprintf( '%s%s%s-%s.php', $autoload_dir, $dir, $prefix, strtolower( str_replace( '_', '-', $autoload_name ) ) );
            if ( is_readable( $autoload_path ) ) {
                require_once $autoload_path; // NOSONAR - WP compatible.
                return;
            }
        }
    }

    /**
     * Method get_location().
     *
     * @param string $path what to get path/url.
     *
     * @return string value.
     */
    public static function get_location_path( $path = 'dir' ) {
        $location = array(
            'dir' => MAINWP_MODULES_DIR . 'api-backups' . DIRECTORY_SEPARATOR,
            'url' => MAINWP_MODULES_URL . 'api-backups/',
        );
        return isset( $location[ $path ] ) ? $location[ $path ] : '';
    }
}

```
