# marqueex/0.6.0/includes/Traits/Singleton.php

MarqueeX – Smooth Marquee Slider, News Ticker &amp; Post Marquee for Block Editor &amp; Elementor, version 0.6.0. 53 lines.

- Page: https://pluginprobe.com/plugins/marqueex/0.6.0/code/includes/Traits/Singleton.php
- Raw: https://pluginprobe.com/plugins/marqueex/0.6.0/raw/includes/Traits/Singleton.php
- Modified: 2026-09-12T09:56:54+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/marqueex/0.6.0/code/includes/Traits/Singleton.php#L10-L20`.

```php
<?php

namespace Wpxero\Marqueex\Traits;

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

/**
 * Singleton Trait
 *
 * Provides singleton functionality to classes
 */
trait Singleton {
    /**
     * Instance of this class
     *
     * @var static
     */
    protected static $instance = null;

    /**
     * Get instance of this class
     *
     * @return static
     */
    public static function get_instance() {
        if (null === static::$instance) {
            static::$instance = new static();
        }

        return static::$instance;
    }

    /**
     * Prevent cloning of the instance
     *
     * @return void
     */
    private function __clone() {
    }

    /**
     * Prevent unserializing of the instance
     *
     * @throws \Exception When attempting to unserialize
     * @return void
     */
    public function __wakeup() {
        throw new \Exception('Cannot unserialize singleton');
    }
}

```
