Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/royal-el.../base
File: module-base.php
<?php
[0] Fix | Delete
namespace WprAddons\Base;
[1] Fix | Delete
[2] Fix | Delete
abstract class Module_Base {
[3] Fix | Delete
[4] Fix | Delete
/**
[5] Fix | Delete
* @var \ReflectionClass
[6] Fix | Delete
*/
[7] Fix | Delete
private $reflection;
[8] Fix | Delete
[9] Fix | Delete
private $components = [];
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* @var Module_Base
[13] Fix | Delete
*/
[14] Fix | Delete
protected static $_instances = [];
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Throw error on object clone
[18] Fix | Delete
*
[19] Fix | Delete
* The whole idea of the singleton design pattern is that there is a single
[20] Fix | Delete
* object therefore, we don't want the object to be cloned.
[21] Fix | Delete
*
[22] Fix | Delete
* @since 1.0
[23] Fix | Delete
* @return void
[24] Fix | Delete
*/
[25] Fix | Delete
public function __clone() {
[26] Fix | Delete
// Cloning instances of the class is forbidden
[27] Fix | Delete
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin huh?', 'wpr-addons' ), '1.0' );
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Disable unserializing of the class
[32] Fix | Delete
*
[33] Fix | Delete
* @since 1.0
[34] Fix | Delete
* @return void
[35] Fix | Delete
*/
[36] Fix | Delete
public function __wakeup() {
[37] Fix | Delete
// Unserializing instances of the class is forbidden
[38] Fix | Delete
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin huh?', 'wpr-addons' ), '1.0' );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
public static function class_name() {
[42] Fix | Delete
return get_called_class();
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* @return Module_Base
[47] Fix | Delete
*/
[48] Fix | Delete
public static function instance() {
[49] Fix | Delete
if ( empty( static::$_instances[ static::class_name() ] ) ) {
[50] Fix | Delete
static::$_instances[ static::class_name() ] = new static();
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
return static::$_instances[ static::class_name() ];
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
abstract public function get_name();
[57] Fix | Delete
[58] Fix | Delete
public function get_assets_url() {
[59] Fix | Delete
return WPR_ADDONS_MODULES_URL . $this->get_name() . '/assets/';
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
public function get_widgets() {
[63] Fix | Delete
return [];
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
public function __construct() {
[67] Fix | Delete
$this->reflection = new \ReflectionClass( $this );
[68] Fix | Delete
[69] Fix | Delete
// GOGA
[70] Fix | Delete
// add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] );
[71] Fix | Delete
add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
public function init_widgets() {
[75] Fix | Delete
$widget_manager = \Elementor\Plugin::instance()->widgets_manager;
[76] Fix | Delete
[77] Fix | Delete
foreach ( $this->get_widgets() as $widget ) {
[78] Fix | Delete
$class_name = $this->reflection->getNamespaceName() .'\Widgets\\'. $widget;
[79] Fix | Delete
// $widget_manager->register_widget_type( new $class_name() );
[80] Fix | Delete
$widget_manager->register( new $class_name() );
[81] Fix | Delete
}
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
public function add_component( $id, $instance ) {
[85] Fix | Delete
$this->components[ $id ] = $instance;
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
public function get_component( $id ) {
[89] Fix | Delete
if ( isset( $this->components[ $id ] ) ) {
[90] Fix | Delete
return $this->components[ $id ];
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
return false;
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function