/** * Initialize the Properties * * Sadly we must be coupled to Core directly as Widgets are instantiated in the * registration process within the Widget Factory itself. We could use the global * to gain access directly to the "public" widget registry within the factory; * however,then we are coupled to that implementation, meaning if down the road the * process changes within WordPress Core, our widgets will break. * * A compromise then is to fetch core and then instantiate the config stored * in Core's IoC Container here within this method. * * @since 1.1.1 * * @return null * @throws RuntimeException */ protected function init_properties() { $this->core = Core::getCore(); $widget_container_key = get_class($this); if (!$this->core->has($widget_container_key)) { throw new RuntimeException(sprintf('%s %s', __('The specified widget config file is not available in the container.', 'wpdc'), $widget_container_key)); } $this->config = $this->core[$widget_container_key]; }
/** * Initialize Events * * @since 1.0.0 * * @return null */ protected function init_events() { add_filter('genesis_pre_get_option_site_layout', $this->core['site_layout']); if ($this->core->has('body_classes')) { add_filter('body_class', function ($classes) { return array_merge($classes, $this->core['body_classes']); }); } if (array_key_exists('related', $this->core['config'])) { add_action('genesis_meta', array($this, 'init_related')); } $this->init_child_events(); }
/** * Register formatters, if configured * * @since 1.0.0 * * @return null */ protected function register_formatters() { if ($this->config->has('formatter_html')) { $this->core->register_formatter($this->config->formatter_html); } }