container = $container; $this->config = $config; /** * Get the list of items * * @var array */ $this->list = (array) $this->container->all(); $this->count = count( $this->list ); $this->context = get_class( $this ); // (new \ReflectionClass($this))->getShortName(); } /** * Abstract maybe_render() */ abstract protected function maybe_render(); /** * Render the output */ public function render() { /** * Prevent the output in case there is any item in the list */ if ( 0 === $this->count ) { return; } $this->maybe_render(); return apply_filters( $this->context, $this->output ); } /** * Print the output */ public function output() { echo $this->render(); } }