library = esc_attr(Photonic::$library); $this->prompt_title = esc_attr__('Protected Content', 'photonic'); $this->prompt_submit = esc_attr__('Access', 'photonic'); $this->prompt_text = esc_attr__('This album is password-protected. Please provide a valid password.', 'photonic'); } final public static function get_instance() { static $instances = array(); $called_class = get_called_class(); if (!isset($instances[$called_class])) { $instances[$called_class] = new $called_class(); } return $instances[$called_class]; } /** * Generates the markup for a single photo. * * @param Single_Photo $photo Pertinent pieces of information about the photo - the source (src), the photo page (href), title and caption. * @param Base $module The object calling this. A CSS class is created in the header, photonic-single-$module->provider-photo-header. * @return string */ public function generate_single_photo_markup(Single_Photo $photo, Base $module): string { $module->push_to_stack('Generate single photo markup'); $ret = ''; if (empty($photo->src)) { $module->pop_from_stack(); return $ret; } global $photonic_external_links_in_new_tab; if (!empty($photo->title)) { $ret .= "\t" . '

' . $photo->title . "

\n"; } $img = '' . esc_attr($photo->caption ?: $photo->title) . ''; if (!empty($photo->href)) { $img = '' . $img . ''; } if (!empty($photo->caption)) { $ret .= "\t" . '
' . "\n\t\t" . $img . "\n\t\t" . '
' . wp_kses_post($photo->caption) . "
\n\t
\n"; } else { $ret .= $img; } $module->pop_from_stack(); return $ret; } /** * Generates the markup for a Header element. A header typically consists of a thumbnail, a title and some * information about the child counts. * * @param Header $header * @param Base $module * @return string */ public function generate_header_markup(Header $header, Base $module): string { if ('lightbox' === $header->display_location || $this instanceof Slideshow) { return ''; } $ret = ''; global $photonic_gallery_template_page, $photonic_page_content; if (!empty($photonic_gallery_template_page) && is_page($photonic_gallery_template_page) && in_array($photonic_page_content, ['replace-if-available', 'append-if-available'], true)) { $ret = wptexturize(wp_kses_post($header->description)); } elseif ((empty($photonic_gallery_template_page) || !is_page() || (is_page() && !empty($photonic_gallery_template_page) && !is_page($photonic_gallery_template_page))) && !empty($header->title)) { global $photonic_external_links_in_new_tab; $title = esc_attr($header->title); if (!empty($photonic_external_links_in_new_tab)) { $target = ' target="_blank" '; } else { $target = ''; } $anchor = ''; if (!empty($header->thumb_url)) { $image = '' . $title . ''; if ($header->enable_link) { $anchor = "" . $image . ""; } else { $anchor = "
$image
"; } } if (empty($header->hidden_elements['thumbnail']) || empty($header->hidden_elements['title']) || empty($header->hidden_elements['counter']) || empty($header->iterate_level_3)) { $popup_header_class = ''; if ('modal' === $header->display_location) { $popup_header_class = 'photonic-panel-header'; } $ret .= "
"; if (empty($header->hidden_elements['thumbnail'])) { $ret .= $anchor; } if (empty($header->hidden_elements['title']) || empty($header->hidden_elements['counter']) || empty($header->iterate_level_3)) { $ret .= "
"; if (empty($header->hidden_elements['title']) || empty($header->iterate_level_3)) { $expand = empty($header->iterate_level_3) ? ' ' : ''; if ($header->enable_link) { $ret .= "'; } else { $ret .= "
" . wptexturize($title) . $expand . '
'; } } if (empty($header->hidden_elements['counter'])) { $counter_texts = []; if (!empty($header->counters['groups'])) { $counter_texts[] = esc_html(sprintf(_n('%s group', '%s groups', $header->counters['groups'], 'photonic'), $header->counters['groups'])); } if (!empty($header->counters['sets'])) { $counter_texts[] = esc_html(sprintf(_n('%s set', '%s sets', $header->counters['sets'], 'photonic'), $header->counters['sets'])); } if (!empty($header->counters['photos'])) { $counter_texts[] = esc_html(sprintf(_n('%s photo', '%s photos', $header->counters['photos'], 'photonic'), $header->counters['photos'])); } if (!empty($header->counters['videos'])) { $counter_texts[] = esc_html(sprintf(_n('%s video', '%s videos', $header->counters['videos'], 'photonic'), $header->counters['videos'])); } apply_filters('photonic_modify_counter_texts', $counter_texts, $header->counters); if (!empty($counter_texts)) { $ret .= "" . implode(', ', $counter_texts) . ''; } } $ret .= "
"; } $ret .= "
"; } } return $ret; } /** * @return string|void */ public function get_library(): string { return $this->library; } public function get_title($title, $titles = [], $short_code = []): string { if (empty($short_code['caption']) || 'none' === $short_code['caption']) { return ''; } else { $priority = explode('-', $short_code['caption']); if (count($priority) === 1) { return $titles[$priority[0]] ?? ''; } else { foreach ($priority as $p) { if (!empty($titles[$p])) { return $titles[$p]; } } } } return $title; } }