PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.33
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.33
3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 2.44 All 141 releases
photonic / Core / Utilities.php

Utilities.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.33, at Core/Utilities.php

136 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Photonic_Plugin\Core;
4
5 class Utilities {
6 public static function get_formatted_post_type_array(): array {
7 global $photonic_post_type_array;
8 $ret = [];
9
10 $post_types = get_post_types(['show_ui' => 1], 'objects');
11 if (!empty($post_types)) {
12 foreach ($post_types as $name => $post_type) {
13 $ret[$name] = ["title" => $post_type->label . " (Post type: $name)", "depth" => 0];
14 }
15 }
16
17 $photonic_post_type_array = $ret;
18 return $ret;
19 }
20
21 public static function get_pages(): array {
22 $pages = get_pages();
23 $output = [
24 '' => '',
25 ];
26 foreach ($pages as $page) {
27 $output[$page->ID] = $page->post_title;
28 }
29 return $output;
30 }
31
32 public static function title_caption_options($blank = false, $selection = false, $alt = false): array {
33 $ret = [
34 '' => esc_html__('Default from settings', 'photonic'),
35 'none' => esc_html__('No title / caption / description', 'photonic'),
36 'title' => esc_html__('Always use the photo title, even if blank', 'photonic'),
37 'desc' => esc_html__('Always use the photo description / caption, even if blank', 'photonic'),
38 'desc-title' => esc_html__('Use the photo description / caption. If blank use the title', 'photonic'),
39 'title-desc' => esc_html__('Use the photo title. If blank use the description / caption', 'photonic'),
40 ];
41
42 if ($alt) {
43 $ret['alt'] = esc_html__('Always use the alt text, even if blank', 'photonic');
44 $ret['alt-title-desc'] = esc_html__('Use the alt text. If blank use the title. If blank use the description / caption', 'photonic');
45 $ret['alt-desc-title'] = esc_html__('Use the alt text. If blank use the description / caption. If blank use the title', 'photonic');
46
47 $ret['desc-title-alt'] = esc_html__('Use the photo description / caption. If blank use the title. If blank use the alt text', 'photonic');
48 $ret['desc-alt-title'] = esc_html__('Use the photo description / caption. If blank use the alt text. If blank use the title', 'photonic');
49
50 $ret['title-alt-desc'] = esc_html__('Use the photo title. If blank use the alt text. If blank use the description / caption', 'photonic');
51 $ret['title-desc-alt'] = esc_html__('Use the photo title. If blank use the description / caption. If blank use the alt text', 'photonic');
52 }
53 if (!$blank) {
54 unset($ret['']);
55 }
56 elseif (!empty($ret[$selection])) {
57 $ret[''] .= ' - ' . $ret[$selection];
58 }
59
60 return $ret;
61 }
62
63 public static function layout_options($show_blank = false, $blank_text = ''): array {
64 $ret = [];
65 if ($show_blank) {
66 $ret[''] = $blank_text;
67 }
68 return array_merge(
69 $ret,
70 [
71 'strip-below' => esc_html__('Thumbnail strip below slideshow', 'photonic'),
72 'strip-above' => esc_html__('Thumbnail strip above slideshow', 'photonic'),
73 'strip-right' => esc_html__('OBSOLETE - Thumbnail strip to the right of the slideshow', 'photonic'),
74 'no-strip' => esc_html__('Slideshow without thumbnails', 'photonic'),
75 'square' => esc_html__('Square thumbnail grid, lightbox', 'photonic'),
76 'circle' => esc_html__('Circular thumbnail grid, lightbox', 'photonic'),
77 'random' => esc_html__('Random justified gallery, lightbox', 'photonic'),
78 'masonry' => esc_html__('Masonry layout, lightbox', 'photonic'),
79 'mosaic' => esc_html__('Mosaic layout, lightbox', 'photonic'),
80 ]
81 );
82 }
83
84 public static function media_options($blank = false, $selection = false): array {
85 $options = [
86 '' => esc_html__('Default from settings', 'photonic'),
87 'photos' => esc_html__('Photos only', 'photonic'),
88 'videos' => esc_html__('Videos only', 'photonic'),
89 'all' => esc_html__('Both photos and videos', 'photonic'),
90 ];
91
92 if (!$blank) {
93 unset($options['']);
94 }
95 elseif (!empty($options[$selection])) {
96 $options[''] .= ' - ' . $options[$selection];
97 }
98
99 return $options;
100 }
101
102 /**
103 * @param $show_full
104 * @param bool $return_formatted
105 * @return array
106 */
107 public static function get_wp_image_sizes($show_full, bool $return_formatted = false): array {
108 global $_wp_additional_image_sizes;
109 $image_sizes = [];
110 $standard_sizes = ['thumbnail', 'medium', 'large'];
111 if ($show_full) {
112 $standard_sizes[] = 'full';
113 }
114 foreach ($standard_sizes as $standard_size) {
115 if ('full' !== $standard_size) {
116 $image_sizes[$standard_size] = ['width' => get_option($standard_size . '_size_w'), 'height' => get_option($standard_size . '_size_h')];
117 }
118 else {
119 $image_sizes[$standard_size] = ['width' => esc_html__('Original width', 'photonic'), 'height' => esc_html__('Original height', 'photonic')];
120 }
121 }
122 if (is_array($_wp_additional_image_sizes)) {
123 $image_sizes = array_merge($image_sizes, $_wp_additional_image_sizes);
124 }
125
126 if ($return_formatted) {
127 $formatted = [];
128 foreach ($image_sizes as $size_name => $size_attrs) {
129 $formatted[$size_name] = "$size_name ({$size_attrs['width']} &times; {$size_attrs['height']})";
130 }
131 return $formatted;
132 }
133 return $image_sizes;
134 }
135 }
136