set_parent( $parent ); return $this; } /* Operations */ /** * Add content to page * @uses parent::add_content() * @param string $id Module ID * @param string $title Module title * @param mixed $callback Callback method or other data for building module UI * @param string $context (optional) Context to add module to (Default: primary) * @param string $priority (optional) Controls module ordering (Default: default) * @param array $callback_args (optional) Additional data to pass callback (Default: NULL) * @return object Page instance reference */ public function add_content( $id, $title, $callback = null, $context = 'primary', $priority = 'default', $callback_args = null ) { $opts = [ 'id' => $id, 'title' => $title, 'callback' => $callback, 'context' => $context, 'priority' => $priority, 'callback_args' => $callback_args, ]; return parent::add_content( $id, $opts ); } /** * Parse content by parameters * Sets content value */ protected function parse_content() { // Get raw content $raw = $this->get_content( false ); // Group by context $content = array(); foreach ( $raw as $c ) { // Add new context if ( ! isset( $content[ $c->context ] ) ) { $content[ $c->context ] = array(); } // Add item to context $content[ $c->context ][] = $c; } return $content; } /** * Render content blocks * @param string $context (optional) Context to render */ protected function render_content( $context = 'primary' ) { // Get content $content = $this->get_content(); // Check for context if ( ! isset( $content[ $context ] ) ) { return false; } $content = $content[ $context ]; $out = ''; // Render content ?>