| 1 |
<?php |
| 2 |
namespace Photonic_Plugin\Options; |
| 3 |
use Photonic_Plugin\Core\Utilities; |
| 4 |
|
| 5 |
class Google extends Option_Tab { |
| 6 |
private static $instance; |
| 7 |
|
| 8 |
private function __construct() { |
| 9 |
$this->options = [ |
| 10 |
['name' => 'Google Photos settings', |
| 11 |
'desc' => 'Control settings for Google Photos', |
| 12 |
'category' => 'google-settings', |
| 13 |
'type' => 'section',], |
| 14 |
|
| 15 |
/* ['name' => 'Use own Google Client ID?', |
| 16 |
'desc' => "Photonic can perform authentication with its own Client ID. Select this option if you want to use your own Client ID instead. |
| 17 |
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. |
| 18 |
<strong>Note that if you have already defined a Client ID and Secret below they will be used regardless of this option.</strong> |
| 19 |
", |
| 20 |
'id' => "google_google_use_own_keys", |
| 21 |
'grouping' => 'google-settings', |
| 22 |
'type' => 'checkbox'],*/ |
| 23 |
|
| 24 |
['name' => 'Google Client ID', |
| 25 |
'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>. |
| 26 |
The <a href='https://aquoid.com/plugins/photonic/google-photos/#api-key'>documentation page</a> can help you with further instructions. |
| 27 |
If you have previously obtained a Client ID for Picasa you can use that here, provided you follow the additional instructions in the documentation. |
| 28 |
<ol> |
| 29 |
<li>Use the option for 'OAuth Client ID', and subsequently pick 'Web applications'.</li> |
| 30 |
<li>Make sure that you add these as your Redirect URIs: |
| 31 |
<ol> |
| 32 |
<li>" . site_url() . "</li> |
| 33 |
<li>" . admin_url('admin.php?page=photonic-auth&source=google') . "</li> |
| 34 |
</ol> |
| 35 |
<strong>Without the above your authentication will not work.</strong> |
| 36 |
</li> |
| 37 |
</ol>", |
| 38 |
'id' => 'google_client_id', |
| 39 |
'grouping' => 'google-settings', |
| 40 |
'type' => 'text'], |
| 41 |
|
| 42 |
['name' => 'Google Client Secret', |
| 43 |
'desc' => "Enter your Google Client Secret.", |
| 44 |
'id' => 'google_client_secret', |
| 45 |
'grouping' => 'google-settings', |
| 46 |
'type' => 'text'], |
| 47 |
|
| 48 |
['name' => 'Refresh Token (for Back-end / Server-side Authentication)', |
| 49 |
'desc' => "To access any content in Google Photos you need to get a token. To get your token go to |
| 50 |
<em>Photonic → Authentication → Google Photos → Google Photos Refresh Token Getter</em>, and authenticate.", |
| 51 |
'id' => 'google_refresh_token', |
| 52 |
'grouping' => 'google-settings', |
| 53 |
'type' => 'text'], |
| 54 |
|
| 55 |
['name' => 'Media to show', |
| 56 |
'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:', |
| 57 |
'id' => 'google_media', |
| 58 |
'grouping' => 'google-settings', |
| 59 |
'type' => 'select', |
| 60 |
'options' => Utilities::media_options()], |
| 61 |
|
| 62 |
['name' => "Hide Photo Count in Album Title Display", |
| 63 |
'desc' => "This will hide the number of photos in your Album's title.", |
| 64 |
'id' => "google_hide_album_photo_count_display", |
| 65 |
'grouping' => 'google-settings', |
| 66 |
'type' => 'checkbox'], |
| 67 |
|
| 68 |
['name' => "Photo titles and captions", |
| 69 |
'desc' => "What do you want to show as the photo title in the tooltip and lightbox?", |
| 70 |
'id' => "google_title_caption", |
| 71 |
'grouping' => "google-settings", |
| 72 |
'type' => 'select', |
| 73 |
'options' => [ |
| 74 |
'none' => esc_html__('No title / caption / description', 'photonic'), |
| 75 |
'title' => esc_html__('Always use the photo title, even if blank', 'photonic'), |
| 76 |
]], |
| 77 |
|
| 78 |
['name' => "Chain queries", |
| 79 |
'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.", |
| 80 |
'id' => "google_chain_queries", |
| 81 |
'grouping' => 'google-settings', |
| 82 |
'type' => 'checkbox'], |
| 83 |
|
| 84 |
['name' => "Photos (Main Page)", |
| 85 |
'desc' => "Control settings for photos from Google Photos when displayed in your page", |
| 86 |
'category' => 'google-photos', |
| 87 |
'type' => 'section',], |
| 88 |
|
| 89 |
['name' => "What is this section?", |
| 90 |
'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.", |
| 91 |
'grouping' => 'google-photos', |
| 92 |
'type' => "blurb",], |
| 93 |
|
| 94 |
['name' => "Photo Title Display", |
| 95 |
'desc' => "How do you want the title of the photos?", |
| 96 |
'id' => "google_photo_title_display", |
| 97 |
'grouping' => 'google-photos', |
| 98 |
'type' => 'radio', |
| 99 |
'options' => $this->title_styles()], |
| 100 |
|
| 101 |
['name' => "Constrain Photos Per Row", |
| 102 |
'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.", |
| 103 |
'id' => "google_photos_per_row_constraint", |
| 104 |
'grouping' => 'google-photos', |
| 105 |
'type' => 'select', |
| 106 |
'options' => ["padding" => "Fix the padding around the thumbnails", |
| 107 |
"count" => "Fix the number of thumbnails per row", |
| 108 |
]], |
| 109 |
|
| 110 |
['name' => "Constrain by padding", |
| 111 |
'desc' => " If you have constrained by padding above, enter the number of pixels here to pad the thumbs by", |
| 112 |
'id' => "google_photos_constrain_by_padding", |
| 113 |
'grouping' => 'google-photos', |
| 114 |
'type' => 'text', |
| 115 |
'hint' => "Enter the number of pixels here (don't enter 'px'). Non-integers will be ignored."], |
| 116 |
|
| 117 |
['name' => "Constrain by number of thumbnails", |
| 118 |
'desc' => " If you have constrained by number of thumbnails per row above, enter the number of thumbnails", |
| 119 |
'id' => "google_photos_constrain_by_count", |
| 120 |
'grouping' => 'google-photos', |
| 121 |
'type' => 'select', |
| 122 |
'options' => $this->selection_range(1, 25)], |
| 123 |
|
| 124 |
['name' => "Photos (Overlaid Popup Panel)", |
| 125 |
'desc' => "Control settings for photos from Google Photos when displayed in a popup", |
| 126 |
'category' => 'google-photos-pop', |
| 127 |
'type' => 'section',], |
| 128 |
|
| 129 |
['name' => "What is this section?", |
| 130 |
'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.", |
| 131 |
'grouping' => 'google-photos-pop', |
| 132 |
'type' => "blurb",], |
| 133 |
|
| 134 |
['name' => "Photo Title Display", |
| 135 |
'desc' => "How do you want the title of the photos?", |
| 136 |
'id' => "google_photo_pop_title_display", |
| 137 |
'grouping' => 'google-photos-pop', |
| 138 |
'type' => 'radio', |
| 139 |
'options' => $this->title_styles()], |
| 140 |
|
| 141 |
['name' => "Constrain Photos Per Row", |
| 142 |
'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.", |
| 143 |
'id' => "google_photos_pop_per_row_constraint", |
| 144 |
'grouping' => 'google-photos-pop', |
| 145 |
'type' => 'select', |
| 146 |
'options' => ["padding" => "Fix the padding around the thumbnails", |
| 147 |
"count" => "Fix the number of thumbnails per row", |
| 148 |
]], |
| 149 |
|
| 150 |
['name' => "Constrain by padding", |
| 151 |
'desc' => " If you have constrained by padding above, enter the number of pixels here to pad the thumbs by", |
| 152 |
'id' => "google_photos_pop_constrain_by_padding", |
| 153 |
'grouping' => 'google-photos-pop', |
| 154 |
'type' => 'text', |
| 155 |
'hint' => "Enter the number of pixels here (don't enter 'px'). Non-integers will be ignored."], |
| 156 |
|
| 157 |
['name' => "Constrain by number of thumbnails", |
| 158 |
'desc' => " If you have constrained by number of thumbnails per row above, enter the number of thumbnails", |
| 159 |
'id' => "google_photos_pop_constrain_by_count", |
| 160 |
'grouping' => 'google-photos-pop', |
| 161 |
'type' => 'select', |
| 162 |
'options' => $this->selection_range(1, 25)], |
| 163 |
]; |
| 164 |
} |
| 165 |
|
| 166 |
public static function get_instance() { |
| 167 |
if (self::$instance == null) { |
| 168 |
self::$instance = new Google(); |
| 169 |
} |
| 170 |
return self::$instance; |
| 171 |
} |
| 172 |
} |
| 173 |
|