/** * Overwrite initial output value for Grid blocks * * @since 0.1.0 * @access protected **/ protected function create_output() { // If a grid is created inside a story, make this into an aside class. if (is_single() || is_page()) { $el = 'aside'; } else { $el = 'div'; } $colour = '#' . $GLOBALS['EXCHANGE_PLUGIN_CONFIG']['COLOURS']['salmon-1-web']; $this->set_grid_items(); // Create grid with posts embedded. if ($this->has_grid_items) { $this->set_modifier_class('colour', $colour); $this->set_attribute('data', 'background-colour', $colour); $this->set_attribute('data', 'equalizer', true); $this->set_attribute('data', 'equalize-on', 'medium'); $this->set_attribute('data', 'children', count($this->grid_items)); $header_text = __('Read more', 'exchange'); if ('collaboration' === $this->context && 'has_stories' === $this->modifiers['related']) { $header_text = __('Shared stories', 'exchange'); } $header = new SectionHeader($header_text, $this->element); $this->output .= $header->embed(); $this->output_tag_open($el); foreach ($this->grid_items as $item) { $this->output .= $item->embed(); } $this->output_tag_close($el); } }
protected function build_block_elements() { // Subheader. $section_header_text = !empty($this->input['uploaded_files_header']) ? $this->input['uploaded_files_header'] : __('Available downloads', EXCHANGE_PLUGIN); $section_header_mods = array('type' => 'taped_header', 'colour' => exchange_slug_to_hex('blue-3')); $section_header = new SectionHeader($section_header_text, $this->element, $section_header_mods); $this->output .= $section_header->embed(); // Paragraph. $paragraph_text = '<ul class="documentblock__file-list dont-break-out">'; foreach ($this->input['add_file'] as $doc) { if (!is_numeric($doc['file'])) { continue; } if (function_exists('acf_get_attachment')) { $meta = acf_get_attachment($doc['file']); } if (empty($meta)) { continue; } $description = !empty($meta['description']) ? $meta['description'] : $meta['filename']; $paragraph_text .= '<li class="documentblock__file-list__item">'; $paragraph_text .= '<a href="' . $meta['url'] . '" target="_blank">' . $description . '</a>'; $paragraph_text .= '</li>'; } $paragraph_text .= '</ul>'; $paragraph = new Paragraph($paragraph_text, $this->element); $this->output .= $paragraph->embed(); }