| 1 |
<?php |
| 2 |
|
| 3 |
namespace Photonic_Plugin\Options; |
| 4 |
|
| 5 |
use Photonic_Plugin\Core\Utilities; |
| 6 |
|
| 7 |
class Google extends Option_Tab { |
| 8 |
private string $preface; |
| 9 |
|
| 10 |
protected function __construct() { |
| 11 |
$this->preface = "<section class='notice notice-error'><strong>API Shutdown</strong><p>Google is making a change to its APIs, which make them unusable for browsing on the web. This will prevent Photonic from working after <strong>31st March 2025</strong>. Please switch to a different platform to avoid disruption.</p></section>"; |
| 12 |
$this->options = [ |
| 13 |
[ |
| 14 |
'name' => 'Google Photos settings', |
| 15 |
'desc' => 'Control settings for Google Photos', |
| 16 |
'preface' => $this->preface, |
| 17 |
'category' => 'google-settings', |
| 18 |
'type' => 'section', |
| 19 |
], |
| 20 |
|
| 21 |
/* |
| 22 |
['name' => 'Use own Google Client ID?', |
| 23 |
'desc' => "Photonic can perform authentication with its own Client ID. Select this option if you want to use your own Client ID instead. |
| 24 |
Creating a Google Client ID can take at least 15-30 minutes, but can save you from potential API quota issues if too many people start using Photonic's ID. |
| 25 |
<strong>Note that if you have already defined a Client ID and Secret below they will be used regardless of this option.</strong> |
| 26 |
", |
| 27 |
'id' => 'google_google_use_own_keys', |
| 28 |
'grouping' => 'google-settings', |
| 29 |
'type' => 'checkbox'], |
| 30 |
*/ |
| 31 |
|
| 32 |
[ |
| 33 |
'name' => 'Google Client ID', |
| 34 |
'desc' => "Enter your Google Client ID. You can get / create one from Google's <a href='https://console.developers.google.com/apis/'>API Manager</a>. |
| 35 |
The <a href='https://aquoid.com/plugins/photonic/google-photos/#api-key'>documentation page</a> can help you with further instructions. |
| 36 |
<ol> |
| 37 |
<li>Use the option for 'OAuth Client ID', and subsequently pick 'Web applications'.</li> |
| 38 |
<li>Make sure that you add these as your Redirect URIs: |
| 39 |
<ol> |
| 40 |
<li>" . site_url() . "</li> |
| 41 |
<li>" . esc_url(admin_url('admin.php?page=photonic-auth&source=google')) . "</li> |
| 42 |
</ol> |
| 43 |
<strong>Without the above your authentication will not work.</strong> |
| 44 |
</li> |
| 45 |
</ol>", |
| 46 |
'id' => 'google_client_id', |
| 47 |
'grouping' => 'google-settings', |
| 48 |
'type' => 'text' |
| 49 |
], |
| 50 |
|
| 51 |
[ |
| 52 |
'name' => 'Google Client Secret', |
| 53 |
'desc' => "Enter your Google Client Secret.", |
| 54 |
'id' => 'google_client_secret', |
| 55 |
'grouping' => 'google-settings', |
| 56 |
'type' => 'text' |
| 57 |
], |
| 58 |
|
| 59 |
[ |
| 60 |
'name' => 'Refresh Token', |
| 61 |
'desc' => "To access any content in Google Photos you need to get a token. To get your token go to |
| 62 |
<em>Photonic → Authentication → Google Photos → Google Photos Refresh Token Getter</em>, and authenticate.", |
| 63 |
'id' => 'google_refresh_token', |
| 64 |
'grouping' => 'google-settings', |
| 65 |
'type' => 'text' |
| 66 |
], |
| 67 |
|
| 68 |
[ |
| 69 |
'name' => 'Media to show', |
| 70 |
'desc' => 'You can choose to include photos as well as videos in your output. This can be overridden by the <code>media</code> parameter in the shortcode:', |
| 71 |
'id' => 'google_media', |
| 72 |
'grouping' => 'google-settings', |
| 73 |
'type' => 'select', |
| 74 |
'options' => Utilities::media_options() |
| 75 |
], |
| 76 |
|
| 77 |
[ |
| 78 |
'name' => "Hide Photo Count in Album Title Display", |
| 79 |
'desc' => "This will hide the number of photos in your Album's title.", |
| 80 |
'id' => 'google_hide_album_photo_count_display', |
| 81 |
'grouping' => 'google-settings', |
| 82 |
'type' => 'checkbox' |
| 83 |
], |
| 84 |
|
| 85 |
[ |
| 86 |
'name' => "Photo titles and captions for the galleries / slideshows", |
| 87 |
'desc' => "What do you want to show as the photo title in the gallery / slideshow? This is used for the tooltips and title displays.", |
| 88 |
'id' => 'google_title_caption', |
| 89 |
'grouping' => 'google-settings', |
| 90 |
'type' => 'select', |
| 91 |
'options' => [ |
| 92 |
'none' => esc_html__('No title / caption / description', 'photonic'), |
| 93 |
'title' => esc_html__('Always use the photo title, even if blank', 'photonic'), |
| 94 |
] |
| 95 |
], |
| 96 |
|
| 97 |
[ |
| 98 |
'name' => "Chain queries", |
| 99 |
'desc' => "When you use Photonic to display a selected list of albums, Photonic will only display the matches from the first page of results. Select this option to let it display albums from later pages.", |
| 100 |
'id' => 'google_chain_queries', |
| 101 |
'grouping' => 'google-settings', |
| 102 |
'type' => 'checkbox' |
| 103 |
], |
| 104 |
|
| 105 |
$this->get_layout_engine_options('google_layout_engine', 'google-settings'), |
| 106 |
|
| 107 |
[ |
| 108 |
'name' => "Photos (Main Page)", |
| 109 |
'preface' => $this->preface, |
| 110 |
'desc' => "Control settings for photos from Google Photos when displayed in your page", |
| 111 |
'category' => 'google-photos', |
| 112 |
'type' => 'section', |
| 113 |
], |
| 114 |
|
| 115 |
[ |
| 116 |
'name' => "What is this section?", |
| 117 |
'desc' => "Options in this section are in effect when you use the shortcode format <code>[gallery type='google' view='photos']</code>. In other words, the photos are printed directly on the page.", |
| 118 |
'grouping' => 'google-photos', |
| 119 |
'type' => "blurb", |
| 120 |
], |
| 121 |
|
| 122 |
[ |
| 123 |
'name' => "Photo Title Display", |
| 124 |
'desc' => "How do you want the title of the photos?", |
| 125 |
'id' => 'google_photo_title_display', |
| 126 |
'grouping' => 'google-photos', |
| 127 |
'type' => 'radio', |
| 128 |
'options' => $this->title_styles() |
| 129 |
], |
| 130 |
|
| 131 |
[ |
| 132 |
'name' => "Constrain Photos Per Row", |
| 133 |
'desc' => "How do you want the control the number of photo thumbnails per row by default? This can be overridden by adding the '<code>columns</code>' parameter to the '<code>gallery</code>' shortcode.", |
| 134 |
'id' => 'google_photos_per_row_constraint', |
| 135 |
'grouping' => 'google-photos', |
| 136 |
'type' => 'select', |
| 137 |
'options' => [ |
| 138 |
'padding' => 'Automatically calculate thumbnails per row', |
| 139 |
'count' => 'Fix the number of thumbnails per row', |
| 140 |
] |
| 141 |
], |
| 142 |
|
| 143 |
[ |
| 144 |
'name' => "Fixed number of thumbnails", |
| 145 |
'desc' => " If you have fixed the number of thumbnails per row above, enter the number of thumbnails", |
| 146 |
'id' => 'google_photos_constrain_by_count', |
| 147 |
'grouping' => 'google-photos', |
| 148 |
'type' => 'select', |
| 149 |
'options' => $this->selection_range(1, 10) |
| 150 |
], |
| 151 |
|
| 152 |
[ |
| 153 |
'name' => "Photos (Overlaid Popup Panel)", |
| 154 |
'preface' => $this->preface, |
| 155 |
'desc' => "Control settings for photos from Google Photos when displayed in a popup", |
| 156 |
'category' => 'google-photos-pop', |
| 157 |
'type' => 'section', |
| 158 |
], |
| 159 |
|
| 160 |
[ |
| 161 |
'name' => "What is this section?", |
| 162 |
'desc' => "Options in this section are in effect when you use the shortcode format <code>[gallery type='google' view='albums']</code>, then click on an album to show an overlaid panel. In other words, the photos are printed directly in the overlaid panel.", |
| 163 |
'grouping' => 'google-photos-pop', |
| 164 |
'type' => "blurb", |
| 165 |
], |
| 166 |
|
| 167 |
[ |
| 168 |
'name' => "Photo Title Display", |
| 169 |
'desc' => "How do you want the title of the photos?", |
| 170 |
'id' => 'google_photo_pop_title_display', |
| 171 |
'grouping' => 'google-photos-pop', |
| 172 |
'type' => 'radio', |
| 173 |
'options' => $this->title_styles() |
| 174 |
], |
| 175 |
]; |
| 176 |
} |
| 177 |
} |
| 178 |
|