芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/ppclaunchers.com/wp-content/themes/hello-elementor/includes/module-base.php
reflection ) { try { $this->reflection = new \ReflectionClass( $this ); } catch ( \ReflectionException $e ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( $e->getMessage() ); //phpcs:ignore } } } return $this->reflection; } /** * Add module component. * * Add new component to the current module. * @access public * * @param string $id Component ID. * @param mixed $instance An instance of the component. */ public function add_component( string $id, $instance ) { $this->components[ $id ] = $instance; } /** * @access public * * @return array */ public function get_components(): array { return $this->components; } /** * Get module component. * * Retrieve the module component. * @access public * * @param string $id Component ID. * * @return mixed An instance of the component, or `null` if the component * doesn't exist. */ public function get_component( string $id ) { if ( isset( $this->components[ $id ] ) ) { return $this->components[ $id ]; } return null; } /** * Retrieve the namespace of the class * * @static * @access public * * @return string */ public static function namespace_name(): string { $class_name = static::class_name(); return substr( $class_name, 0, strrpos( $class_name, '\\' ) ); } /** * Adds an array of components. * Assumes namespace structure contains `\Components\` * * @access protected * * @param ?array $components_ids => component's class name. * @return void */ protected function register_components( array $components_ids = null ): void { if ( empty( $components_ids ) ) { $components_ids = $this->get_component_ids(); } $namespace = static::namespace_name(); foreach ( $components_ids as $component_id ) { $class_name = $namespace . '\\Components\\' . $component_id; $this->add_component( $component_id, new $class_name() ); } } /** * Registers the Module's widgets. * Assumes namespace structure contains `\Widgets\` * * @access protected * * @param \Elementor\Widgets_Manager $widgets_manager * @return void */ public function register_widgets( \Elementor\Widgets_Manager $widgets_manager ): void { $widget_ids = $this->get_widget_ids(); $namespace = static::namespace_name(); foreach ( $widget_ids as $widget_id ) { $class_name = $namespace . '\\Widgets\\' . $widget_id; $widgets_manager->register( new $class_name() ); } } /** * @access protected * * @return string[] */ protected function get_widget_ids(): array { return []; } /** * @access protected * * @return void */ protected function register_hooks(): void { add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] ); } /** * Clone. * * Disable class cloning and throw an error on object clone. * * The whole idea of the singleton design pattern is that there is a single * object. Therefore, we don't want the object to be cloned. * * @access private */ public function __clone() { // Cloning instances of the class is forbidden _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'hello-elementor' ), '0.0.1' ); // @codeCoverageIgnore } /** * Wakeup. * * Disable un-serializing of the class. * @access public */ public function __wakeup() { // Un-serializing instances of the class is forbidden _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'hello-elementor' ), '0.0.1' ); // @codeCoverageIgnore } /** * class constructor * * @access protected * * @param ?string[] $components_list */ protected function __construct( ?array $components_list = null ) { $this->register_components( $components_list ); $this->register_hooks(); } }