$id, 'config' => $this->read_config_for($single_item), 'path' => $single_item ]; } } return $items; } private function read_config_for( $file_path ) { $name = explode( '-', basename($file_path) ); $name = array_map( 'ucfirst', $name ); $name = implode( ' ', $name ); return [ 'name' => $name ]; $_extract_variables = [ 'config' => [] ]; if (is_readable($file_path . '/config.php')) { require $file_path . '/config.php'; foreach ( $_extract_variables as $variable_name => $default_value ) { if ( isset( $$variable_name ) ) { $_extract_variables[ $variable_name ] = $$variable_name; } } } $_extract_variables['config'] = array_merge( [ 'name' => $name, 'description' => '' ], $_extract_variables['config'] ); return $_extract_variables['config']; } public function get_options_for($panel_type = 'header', $item) { if (!is_array($item)) { return []; } if (! isset($item['path'])) { return []; } return blocksy_get_options($item['path'] . '/options.php', [ 'prefix' => $this->get_option_id_for($panel_type, $item) ], false); } public function get_header_structure_for($id, $mode = 'placements') { $base = [ 'id' => $id, 'mode' => $mode, 'desktop' => [ $this->get_bar_structure_for('top-bar'), $this->get_bar_structure_for('middle-bar'), $this->get_bar_structure_for('bottom-bar'), ], 'mobile' => [ $this->get_bar_structure_for('top-bar'), $this->get_bar_structure_for('middle-bar'), $this->get_bar_structure_for('bottom-bar'), [ 'id' => 'offcanvas-bar', 'items' => [] ] ], 'items' => [] ]; return $base; } private function get_bar_structure_for($id, $mode = 'placements') { return array_merge([ 'id' => $id, ], ( $mode === 'rows' ? [ 'row' => [] ] : [ 'placements' => [ ['id' => 'left', 'items' => []], ['id' => 'center', 'items' => []], ['id' => 'right', 'items' => []], ] ] )); } }