Files
roi-theme/wp-content/plugins/thrive-visual-editor/inc/traits/trait-is-singleton.php
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

52 lines
1.0 KiB
PHP
Executable File

<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-theme
*/
namespace TCB\Traits;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden!
}
/**
* Trait Is_Singleton
*
* @package TCB\Traits
*/
trait Is_Singleton {
private static $_instance;
/**
* General singleton implementation for getting class instances that also require an id
*
* @param int $id
*
* @return static
*/
public static function get_instance_with_id( $id = 0 ) {
/* if we don't have any instance or when we send an id that is not the same as the previous one, we create a new instance */
if ( empty( static::$_instance ) || is_wp_error( $id ) || ( ! empty( $id ) && static::$_instance->ID !== $id ) ) {
static::$_instance = new static( $id );
}
return static::$_instance;
}
/**
* General singleton implementation for getting a class instance
*
* @return static
*/
public static function get_instance() {
if ( empty( static::$_instance ) ) {
static::$_instance = new static();
}
return static::$_instance;
}
}