PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.4.3
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.4.3
3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 3.0.0 3.0.1 All 71 releases
stockpack / src / class-stockpackmedia.php

class-stockpackmedia.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.4.3, at src/class-stockpackmedia.php

377 lines 21.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7 if ( ! class_exists( 'StockpackMedia' ) ) {
8 class StockpackMedia {
9 /**
10 * @var Singleton The reference the *Singleton* instance of this class
11 */
12 private static $instance;
13
14 /**
15 * @var WeDevs_Settings_API
16 */
17 public $settings_api;
18
19 /**
20 * Returns the *Singleton* instance of this class.
21 *
22 * @return Singleton The *Singleton* instance.
23 */
24 public static function get_instance() {
25 if ( null === self::$instance ) {
26 self::$instance = new self();
27 }
28
29 return self::$instance;
30 }
31
32 /**
33 * StockPack constructor.
34 */
35 protected function __construct() {
36 add_action( 'plugins_loaded', array( $this, 'init' ) );
37 }
38
39 /**
40 *
41 */
42 public function init() {
43 $this->filters();
44 $this->actions();
45 }
46
47
48 /**
49 *
50 */
51 public function enqueue() {
52 $screen = get_current_screen();
53 wp_enqueue_script( 'stockpack', plugins_url( '../dist/js/stockpack.js', __FILE__ ), array(
54 'media-views',
55 'wp-color-picker',
56 'jquery-ui-dialog'
57 ), false, true );
58
59 if ( $screen->id === 'settings_page_stockpack' ) {
60 wp_enqueue_script( 'stockpack-admin', plugins_url( '../dist/js/stockpack-settings.js', __FILE__ ), array( 'jquery' ), false, true );
61 wp_enqueue_style( 'settings-stockpack', plugins_url( '../dist/css/stockpack-settings.css', __FILE__ ), array(), false );
62 }
63 wp_enqueue_style( 'wp-color-picker' );
64 wp_enqueue_style( 'wp-jquery-ui-dialog' );
65 wp_enqueue_style( 'stockpack-', plugins_url( '../dist/css/stockpack.css', __FILE__ ), false );
66
67 }
68
69
70 /**
71 *
72 */
73 public function filters() {
74 add_filter( 'media_view_strings', array( $this, 'tab_text' ), 10, 2 );
75 add_filter( 'media_view_settings', array( $this, 'settings' ), 10, 2 );
76 }
77
78 public function actions() {
79 add_action( 'admin_enqueue_scripts', array( $this, 'templates' ) );
80 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
81 }
82
83
84 /**
85 *
86 */
87 public function templates() {
88 include_once( __DIR__ . '/../templates/attachment.php' );
89 include_once( __DIR__ . '/../templates/empty.php' );
90 include_once( __DIR__ . '/../templates/details.php' );
91 include_once( __DIR__ . '/../templates/downloader.php' );
92 include_once( __DIR__ . '/../templates/dialog.php' );
93 include_once( __DIR__ . '/../templates/attribution.php' );
94 include_once( __DIR__ . '/../templates/no-search.php' );
95 }
96
97 /**
98 * @param $strings
99 * @param $post
100 *
101 * @return array
102 */
103 public function tab_text( $strings, $post ) {
104 if ( ! defined( 'STOCKPACK_DASHBOARD_URL' ) ) {
105 $dashboard_url = 'https://stockpack.co';
106 } else {
107 $dashboard_url = STOCKPACK_DASHBOARD_URL;
108 }
109
110 $plugin_url = str_replace( '/src/', '', plugin_dir_url( __FILE__ ) );
111
112 $strings['stockpack'] = array(
113 'title' => __( 'StockPack', 'stockpack' ),
114 'button' => __( 'Insert into post', 'stockpack' ),
115 'retry' => __( 'Retry', 'stockpack' ),
116 'noMedia' => __( 'No images have been found', 'stockpack' ),
117 'noSearch' => __( 'Start searching for images', 'stockpack' ),
118 'inspiration' => array(
119 'unsure' => __( 'Not sure what to search for?', 'stockpack' ),
120 'random' => array(
121 'item_1' => array(
122 'message' => __( 'Try "balloons" in the top right search input', 'stockpack' ),
123 'image' => $plugin_url . '/images/balloons.png',
124 ),
125 'item_2' => array(
126 'message' => __( 'Try "unicorn" in the top right search input', 'stockpack' ),
127 'image' => $plugin_url . '/images/unicorn.png',
128 ),
129 'item_3' => array(
130 'message' => __( 'Try "ice cream" in the top right search input', 'stockpack' ),
131 'image' => $plugin_url . '/images/icecream.png',
132 ),
133 'item_4' => array(
134 'message' => __( 'Try "moon" in the top right search input', 'stockpack' ),
135 'image' => $plugin_url . '/images/moon.png',
136 ),
137 'item_5' => array(
138 'message' => __( 'Try "coffee" in the top right search input', 'stockpack' ),
139 'image' => $plugin_url . '/images/coffee.png',
140 ),
141 'item_6' => array(
142 'message' => __( 'Try "tea" in the top right search input', 'stockpack' ),
143 'image' => $plugin_url . '/images/tea.png',
144 ),
145 'item_7' => array(
146 'message' => __( 'Try "lighthouse" in the top right search input', 'stockpack' ),
147 'image' => $plugin_url . '/images/lighthouse.png',
148 ),
149 'item_8' => array(
150 'message' => __( 'Try "mountains" in the top right search input', 'stockpack' ),
151 'image' => $plugin_url . '/images/mountains.png',
152 )
153
154
155 ),
156 ),
157 'error' => __( 'There has been an issue with your license key', 'stockpack' ),
158 'link' => __( 'Set license key', 'stockpack' ),
159 'search' => __( 'Search images', 'stockpack' ),
160 'close' => __( 'Close', 'stockpack' ),
161 'download' => __( 'Download', 'stockpack' ),
162 'licenseAction' => __( 'License', 'stockpack' ),
163 'alreadyLicensed' => __( 'Licensed', 'stockpack' ),
164 'license' => __( 'Your license key is not valid', 'stockpack' ),
165 'advanced' => __( 'Advanced search', 'stockpack' ),
166 'filters' => [
167 'gender' => [
168 'label' => __( 'Gender', 'stockpack' ),
169 'female' => __( 'Female', 'stockpack' ),
170 'male' => __( 'Male', 'stockpack' ),
171 ],
172 'orientation' => [
173 'label' => __( 'Orientation', 'stockpack' ),
174 'horizontal' => __( 'Horizontal', 'stockpack' ),
175 'vertical' => __( 'Vertical', 'stockpack' ),
176 ],
177 'image_type' => [
178 'label' => __( 'Image type', 'stockpack' ),
179 'photo' => __( 'Photos', 'stockpack' ),
180 'vector' => __( 'Vectors', 'stockpack' ),
181 'illustration' => __( 'Illustrations', 'stockpack' ),
182 ],
183 'categories' => [
184 'label' => __( 'Category', 'stockpack' ),
185 'default' => __( 'Any Category', 'stockpack' ),
186 'values' => [
187 'Abstract' => __( 'Abstract', 'stockpack' ),
188 'Animals/Wildlife' => __( 'Animals/Wildlife', 'stockpack' ),
189 'The Arts' => __( 'The Arts', 'stockpack' ),
190 'Backgrounds/Textures' => __( 'Backgrounds/Textures', 'stockpack' ),
191 'Beauty/Fashion' => __( 'Beauty/Fashion', 'stockpack' ),
192 'Buildings/Landmarks' => __( 'Buildings/Landmarks', 'stockpack' ),
193 'Business/Finance' => __( 'Business/Finance', 'stockpack' ),
194 'Celebrities' => __( 'Celebrities', 'stockpack' ),
195 'Editorial' => __( 'Editorial', 'stockpack' ),
196 'Education' => __( 'Education', 'stockpack' ),
197 'Food and Drink' => __( 'Food and Drink', 'stockpack' ),
198 'Healthcare/Medical' => __( 'Healthcare/Medical', 'stockpack' ),
199 'Holidays' => __( 'Holidays', 'stockpack' ),
200 'Illustrations/Clip-Art' => __( 'Illustrations/Clip-Art', 'stockpack' ),
201 'Industrial' => __( 'Industrial', 'stockpack' ),
202 'Interiors' => __( 'Interiors', 'stockpack' ),
203 'Miscellaneous' => __( 'Miscellaneous', 'stockpack' ),
204 'Nature' => __( 'Nature', 'stockpack' ),
205 'Objects' => __( 'Objects', 'stockpack' ),
206 'Parks/Outdoor' => __( 'Parks/Outdoor', 'stockpack' ),
207 'People' => __( 'People', 'stockpack' ),
208 'Religion' => __( 'Religion', 'stockpack' ),
209 'Science' => __( 'Science', 'stockpack' ),
210 'Signs/Symbols' => __( 'Signs/Symbols', 'stockpack' ),
211 'Sports/Recreation' => __( 'Sports/Recreation', 'stockpack' ),
212 'Technology' => __( 'Technology', 'stockpack' ),
213 'Transportation' => __( 'Transportation', 'stockpack' ),
214 'Vectors' => __( 'Vectors', 'stockpack' ),
215 'Vintage' => __( 'Vintage', 'stockpack' ),
216
217 ]
218 ],
219 'safe' => [
220 'label' => __( 'Safe', 'stockpack' ),
221 'yes' => __( 'Yes', 'stockpack' ),
222 'no' => __( 'No', 'stockpack' ),
223 ],
224 'color' => [
225 'text' => __( 'Color', 'stockpack' ),
226 ],
227
228 ],
229 'terms' => [
230 'agree' => __( 'I agree', 'stockpack' ),
231 'cancel' => __( 'Cancel', 'stockpack' ),
232 'adobe_stock' => [
233 'title' => __( 'Terms agreement', 'stockpack' ),
234 'message' => __( 'Before you download the first image you need to agree to the terms of service of Adobe Stock. This will only be asked once and then we will store it for all subsequent downloads. You are a direct user of the Adobe Stock website and their terms apply. ', 'stockpack' ),
235 'link' => 'https://stock.adobe.com/license-terms'
236 ],
237 'pixabay' => [
238 'title' => __( 'Terms agreement', 'stockpack' ),
239 'message' => __( 'Before you download the first image you need to agree to the terms of service of Pixabay. This will only be asked once and then we will store it for all subsequent downloads. You are a direct user of the Pixabay website and their terms apply. ', 'stockpack' ),
240 'link' => 'https://pixabay.com/service/terms/'
241 ],
242 'unsplash' => [
243 'title' => __( 'Terms agreement', 'stockpack' ),
244 'message' => __( 'Before you download the first image you need to agree to the terms of service of Unsplash. This will only be asked once and then we will store it for all subsequent downloads. You are a direct user of the Unsplash website and their terms apply. ', 'stockpack' ),
245 'link' => 'https://unsplash.com/terms'
246 ],
247 'deposit_photos' => [
248 'title' => __( 'Terms agreement', 'stockpack' ),
249 'message' => __( 'Before you download the first image you need to agree to the terms of service of Deposit Photos. This will only be asked once and then we will store it for all subsequent downloads. You are a direct user of the Deposit Photos website and their terms apply. ', 'stockpack' ),
250 'link' => 'https://depositphotos.com/terms-of-use.html'
251 ],
252 ],
253 'licensePopup' => [
254 'proceed' => __( 'Proceed', 'stockpack' ),
255 'checkInProgress' => __( 'Cost checking is in progress, please wait', 'stockpack' ),
256 'cancel' => __( 'Cancel', 'stockpack' ),
257 'adobe_stock' => [
258 'title' => __( 'License and download', 'stockpack' ),
259 'message' => __( 'Licensing an image will provide you a non watermarked image from Adobe Stock.', 'stockpack' ),
260 'status' => __( 'Fetching cost...', 'stockpack' ),
261 'external' => __( 'Adobe stock offers multiple types of accounts and multiple types of licenses. Currently only Standard is supported trough the plugin. You can use the url bellow to license this directly on the Adobe Stock website, in case your account allows that. In the case of credits missing, you can add more credits and retry.', 'stockpack' ),
262 'directLicenseUrl' => __( 'Adobe License Page', 'stockpack' ),
263 ],
264 'deposit_photos' => [
265 'title' => __( 'License and download', 'stockpack' ),
266 'message' => __( 'Licensing an image will provide you a non watermarked image from Deposit Photos.', 'stockpack' ),
267 'status' => __( 'Fetching cost...', 'stockpack' ),
268 'external' => __( 'Currently only sizes available trough the subscription package are supported by the plugin. You can use the url bellow to license this directly on the Deposit Photos website, in case your account allows that. If you subscription expired renew it and retry.', 'stockpack' ),
269 'directLicenseUrl' => __( 'Deposit Photos License Page', 'stockpack' ),
270 ],
271 ],
272 'attribution' => [
273 'adobe_stock' => [
274 'author_info' => __( 'Image info is available in the sidebar', 'stockpack' ),
275 'message' => __( 'You are searching images from', 'stockpack' ),
276 'link' => 'https://stockpack.co/recommended/adobe_stock',
277 'link_title' => 'Adobe Stock'
278 ],
279 'default' => [
280 'author_info' => __( 'Stock provider is being fetched...', 'stockpack' ),
281 'message' => __( 'Loading data...', 'stockpack' ),
282 'link' => '',
283 'link_title' => ''
284 ],
285 'pixabay' => [
286 'author_info' => __( 'Author info is available in the sidebar', 'stockpack' ),
287 'message' => __( 'You are searching images from', 'stockpack' ),
288 'link' => 'https://stockpack.co/recommended/pixabay',
289 'link_title' => 'Pixabay'
290 ],
291 'unsplash' => [
292 'author_info' => __( 'Author info is available in the sidebar', 'stockpack' ),
293 'message' => __( 'You are searching images from', 'stockpack' ),
294 'link' => 'https://stockpack.co/recommended/unsplash',
295 'link_title' => 'Unsplash'
296 ],
297 'deposit_photos' => [
298 'author_info' => __( 'Author info is available in the sidebar', 'stockpack' ),
299 'message' => __( 'You are searching images from', 'stockpack' ),
300 'link' => 'https://stockpack.co/recommended/deposit_photos',
301 'link_title' => 'Deposit Photos',
302 'warning' => __( 'Watermarked images from Deposit Photos are allowed for testing only', 'stockpack' ),
303 ],
304 ],
305 'limit' => [
306 'premium' => [
307 'title' => __( 'Requests limit reached', 'stockpack' ),
308 'message' => __( 'You have reached the limit for the requests. This gets reset, but if you reach this often and need a bigger solution you can contact StockPack support to talk about the options.', 'stockpack' )
309 ],
310 'anonymous' => [
311 'title' => __( 'You need an account to continue', 'stockpack' ),
312 'message' => __( 'You have reached the limit for the requests without an account. ', 'stockpack' ),
313 'iframe' => [
314 'src' => $dashboard_url . '/register?skim=1',
315 'id' => 'stockpack-token-iframe',
316 ],
317 'status' => [
318 'initial' => __( 'Fetching remote website ...', 'stockpack' ),
319 'login' => __( 'Sign in using the form below to continue', 'stockpack' ),
320 'register' => __( 'Create an account in the window below to continue', 'stockpack' ),
321 'providers' => __( 'Token is being stored, you will be able to continue shortly', 'stockpack' ),
322 'elsewhere' => __( 'To get back to login you can close this window and open it again, or use the back buttons inside the window', 'stockpack' )
323 ]
324 ],
325 'free' => [
326 'title' => __( 'You need the premium upgrade to continue', 'stockpack' ),
327 'message' => __( 'You have reached the limit for the requests with the free account. ', 'stockpack' ),
328 'iframe' => [
329 'src' => $dashboard_url . '/login?skim=1&upgrade=1',
330 'id' => 'stockpack-upgrade-iframe',
331 ],
332 'status' => [
333 'initial' => __( 'Fetching remote website ...', 'stockpack' ),
334 'providers' => __( 'Refreshing token, you will be able to continue shortly', 'stockpack' ),
335 'login' => __( 'Sign in using the form below to continue', 'stockpack' ),
336 'register' => __( 'Create an account in the window below to continue', 'stockpack' ),
337 'billing' => __( 'Once you upgrade your account you will get upgraded limits which will allow you to proceed right away', 'stockpack' ),
338 'elsewhere' => __( 'To get back to login you can close this window and open it again, or use the back buttons inside the window', 'stockpack' )
339 ]
340 ],
341 'reset' => __( 'Reset time passed, you can try again', 'stockpack' ),
342 'contact' => "Contact",
343 'cancel' => "Cancel"
344 ]
345 );
346
347 return $strings;
348 }
349
350 public function settings( $strings, $post ) {
351 $strings['stockpack'] = array(
352 'terms' => [
353 'adobe_stock' => get_option( 'terms_accepted_adobe_stock', false ),
354 'pixabay' => get_option( 'terms_accepted_pixabay', false ),
355 'unsplash' => get_option( 'terms_accepted_unsplash', false ),
356 'deposit_photos' => get_option( 'terms_accepted_deposit_photos', false ),
357 ],
358 'nonce_terms' => wp_create_nonce( 'stockpack_terms' ),
359 'nonce_license_cost' => wp_create_nonce( 'stockpack_license_cost' ),
360 'nonce_query' => wp_create_nonce( 'stockpack_query' ),
361 'nonce_download' => wp_create_nonce( 'stockpack_download' ),
362 'nonce_cache' => wp_create_nonce( 'stockpack_cache' ),
363 'nonce_token' => wp_create_nonce( 'stockpack_token' ),
364 'nonce_validate' => wp_create_nonce( 'stockpack_validate' ),
365 'settings_url' => admin_url( 'options-general.php?page=stockpack' ),
366 'contact_url' => 'https://stockpack.co/contact',
367 );
368
369 return $strings;
370 }
371
372
373 }
374
375 $GLOBALS['stockpack_media'] = StockpackMedia::get_instance();
376 }
377