Instant Images – One Click Unsplash Uploads - Version 2.1

Version Description

  • May 12, 2017 =
  • UPDATE - Remove App ID setting - Unsplash API is now open for everyone without API limit restrictions.
  • UPDATE - Updating default image upload from 'Full' to 'Raw'. Raw files are significantly smaller size and should make uploads quicker on slower connections and help to reduce upload errors.
  • UPDATE - UI/UX tweaks and updates.
  • FIX - Updating media_buttons hook. Was causing issues with other plugins.
Download this release

Release Info

Developer dcooney
Plugin Icon 128x128 Instant Images – One Click Unsplash Uploads
Version 2.1
Comparing to
See all releases

Code changes from version 2.0.1 to 2.1

.editorconfig ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ # PHP PSR-2 Coding Standards
6
+ # http://www.php-fig.org/psr/psr-2/
7
+
8
+ root = true
9
+
10
+ [*]
11
+ charset = utf-8
12
+ end_of_line = lf
13
+ insert_final_newline = true
14
+ trim_trailing_whitespace = true
15
+ indent_style = tab
16
+ indent_size = 3
README.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Instant Images - One Click Unsplash Uploads ===
2
- Contributors: dcooney
3
  Donate link: https://connekthq.com/donate/
4
  Tags: stock photo, stock, unsplash, prototyping, photos, upload, media, media library, ajax, image upload, direct upload, free stock photos
5
  Requires at least: 3.6
6
- Tested up to: 4.7.3
7
- Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,7 @@ One click uploads of Unsplash photos directly to your WordPress media library.
12
 
13
  == Description ==
14
 
15
- **Instant Images** is the fastest and easiest way to upload high quality stock photos from [unsplash.com](http://unsplash.com) directly to your media library — **all without ever leaving WordPress**!
16
 
17
  [youtube https://www.youtube.com/watch?v=s6Q7Kfi2f1c]
18
 
@@ -57,16 +57,11 @@ All photos published on Unsplash are licensed under Creative Commons Zero which
57
  All photos published on Unsplash are licensed under Creative Commons Zero which means you can copy, modify, distribute and use the photos for free, including commercial purposes, without asking permission from or providing attribution to the photographer or Unsplash.
58
  [Learn More](http://creativecommons.org/publicdomain/zero/1.0/)
59
 
60
-
61
- = Is there an API limit for Unsplash photos with Instant Images? =
62
- Unsplash requires an Application ID for access to their API. Applications are capped at 5000 requests per hour. We have provided our Application key to get you started and recommend you sign up for Unsplash and create your own application to unlock additional API requests.
63
- ** [Learn More](https://connekthq.com/plugins/instant-images/api-access/)
64
-
65
  = Are the images upload to the Media Library? =
66
  Yes, once clicked, the images are processed on the server then uploaded to the Media Library into the various sizes set in your functions.php file.
67
 
68
  = Are there server requirements? =
69
- Yes, this plugin is required to write temporary images into an /instant-images directory within your WordPress uploads directory for image processing prior to being uploaded to the media library.
70
 
71
  Some hosts lock down their servers and you may be required to update your php.ini or .htaccess in order to use this plugin.
72
 
@@ -107,8 +102,16 @@ How to install Instant Images.
107
 
108
  == Changelog ==
109
 
110
- = 2.0.1 - January 12, 2016 =
111
- * FIX - Update to instant_img_resize_image function to remove unnecessary function arguments. These args were causing issues on some servers.
 
 
 
 
 
 
 
 
112
  * NEW - Refresh Media Library content when uploading images through the Instant Images uploader on edit screen for posts and pages.
113
  * UI Enhancements
114
 
1
  === Instant Images - One Click Unsplash Uploads ===
2
+ Contributors: dcooney, connekthq
3
  Donate link: https://connekthq.com/donate/
4
  Tags: stock photo, stock, unsplash, prototyping, photos, upload, media, media library, ajax, image upload, direct upload, free stock photos
5
  Requires at least: 3.6
6
+ Tested up to: 4.7.4
7
+ Stable tag: 2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ **Instant Images** is the fastest and easiest way to upload high quality stock photos from [unsplash.com](http://unsplash.com) directly to your media library — **all without ever leaving WordPress**!
16
 
17
  [youtube https://www.youtube.com/watch?v=s6Q7Kfi2f1c]
18
 
57
  All photos published on Unsplash are licensed under Creative Commons Zero which means you can copy, modify, distribute and use the photos for free, including commercial purposes, without asking permission from or providing attribution to the photographer or Unsplash.
58
  [Learn More](http://creativecommons.org/publicdomain/zero/1.0/)
59
 
 
 
 
 
 
60
  = Are the images upload to the Media Library? =
61
  Yes, once clicked, the images are processed on the server then uploaded to the Media Library into the various sizes set in your functions.php file.
62
 
63
  = Are there server requirements? =
64
+ Yes, this plugin is required to write temporary images into an `/instant-images` directory within your WordPress `uploads` directory for image processing prior to being uploaded to the media library.
65
 
66
  Some hosts lock down their servers and you may be required to update your php.ini or .htaccess in order to use this plugin.
67
 
102
 
103
  == Changelog ==
104
 
105
+
106
+ = 2.1 - May 12, 2017 =
107
+ * UPDATE - Remove App ID setting - Unsplash API is now open for everyone without API limit restrictions.
108
+ * UPDATE - Updating default image upload from 'Full' to 'Raw'. Raw files are significantly smaller size and should make uploads quicker on slower connections and help to reduce upload errors.
109
+ * UPDATE - UI/UX tweaks and updates.
110
+ * FIX - Updating media_buttons hook. Was causing issues with other plugins.
111
+
112
+
113
+ = 2.0.1 - January 12, 2017 =
114
+ * FIX - Update to instant_img_resize_image function to remove unnecessary function arguments. These args were causing issues on some servers.
115
  * NEW - Refresh Media Library content when uploading images through the Instant Images uploader on edit screen for posts and pages.
116
  * UI Enhancements
117
 
admin/admin.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
 
4
  /*
5
  * instant_img_admin_vars
6
  * Create admin variables and ajax nonce
@@ -8,21 +9,21 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
  * @since 2.0
9
  */
10
 
11
- function instant_img_admin_vars() {
12
- $options = get_option( 'instant_img_settings' );
13
  $download_w = isset($options['unsplash_download_w']) ? $options['unsplash_download_w'] : 1600; // width of download file
14
- $download_h = isset($options['unsplash_download_h']) ? $options['unsplash_download_h'] : 1200; // height of downloads
15
- $app_id = instant_img_get_app_id(); // APPLICATION ID
16
  ?>
17
  <script type='text/javascript'>
18
  /* <![CDATA[ */
19
- var instant_img_localize = <?php echo json_encode( array(
20
  'ajax_url' => admin_url('admin-ajax.php'),
21
  'admin_nonce' => wp_create_nonce('instant_img_nonce'),
22
  'download_width' => $download_w,
23
  'download_height' => $download_h,
24
  'unsplash_default_app_id' => INSTANT_IMG_DEFAULT_APP_ID,
25
- 'unsplash_app_id' => $app_id,
26
  'error_msg_title' => __('Error accessing Unsplash API', 'instant-images'),
27
  'error_msg_desc' => __('Please check your Application ID.', 'instant-images'),
28
  'error_upload' => __('Unable to save image, please check your server permissions.', 'instant-images'),
@@ -51,8 +52,8 @@ add_action( 'admin_head', 'instant_img_admin_vars' );
51
  * @since 2.0
52
  */
53
 
54
- function instant_img_admin_menu() {
55
- $usplash_settings_page = add_submenu_page( 'upload.php', INSTANT_IMG_TITLE, INSTANT_IMG_TITLE, 'edit_theme_options', INSTANT_IMG_NAME, 'instant_img_settings_page');
56
  add_action( 'load-' . $usplash_settings_page, 'instant_img_load_scripts' ); //Add our admin scripts
57
  }
58
  add_action( 'admin_menu', 'instant_img_admin_menu' );
@@ -86,10 +87,10 @@ function instant_img_enqueue_scripts(){
86
  wp_enqueue_style('font-awesome-instant-image', INSTANT_IMG_ADMIN_URL. 'assets/css/font-awesome.min.css');
87
  wp_enqueue_script('jquery');
88
  wp_enqueue_script('jquery-form');
89
- wp_enqueue_script('jquery-masonry');
90
  wp_enqueue_script('imagesLoaded', INSTANT_IMG_ADMIN_URL. 'assets/js/libs/imagesloaded.pkgd.min.js', 'jquery');
91
- wp_enqueue_script('unsplash-helpers', INSTANT_IMG_ADMIN_URL. 'assets/js/helpers.unsplash.js', array( 'jquery' ));
92
- wp_enqueue_script('unsplash', INSTANT_IMG_ADMIN_URL. 'assets/js/unsplash.js', array( 'unsplash-helpers' ));
93
  wp_enqueue_script('instant-images', INSTANT_IMG_ADMIN_URL. 'assets/js/admin.js', 'jquery');
94
  }
95
 
@@ -103,19 +104,18 @@ function instant_img_enqueue_scripts(){
103
  * @since 2.0
104
  */
105
 
106
- function instant_img_media_popup($context) {
107
 
108
  // popup title
109
- $title = INSTANT_IMG_TITLE;
110
  $title_txt = INSTANT_IMG_TITLE .' - '. __('Direct image uploads to your media library', 'instant-images');
111
- $context .= "<a href='#TB_inline?width=600&height=600&inlineId=instant_images_modal'
112
  class='button thickbox instant-images' title='$title_txt'>
113
  <span class='dashicons dashicons-format-gallery' style='font-size: 16px; top: 6px;'></span> ".INSTANT_IMG_TITLE."</a>";
114
 
115
- return $context;
116
-
117
  }
118
- add_action( 'media_buttons_context', 'instant_img_media_popup' );
119
 
120
 
121
 
@@ -132,7 +132,7 @@ function instant_img_media_popup_content() {
132
  wp_enqueue_style( 'font-awesome', INSTANT_IMG_ADMIN_URL. 'assets/css/font-awesome.min.css');
133
  wp_enqueue_script('jquery');
134
  wp_enqueue_script('jquery-form');
135
- wp_enqueue_script('jquery-masonry');
136
  wp_enqueue_script('imagesLoaded', INSTANT_IMG_ADMIN_URL. 'assets/js/libs/imagesloaded.pkgd.min.js', 'jquery');
137
  wp_enqueue_script('unsplash-helpers', INSTANT_IMG_ADMIN_URL. 'assets/js/helpers.unsplash.js', array( 'jquery' ));
138
  wp_enqueue_script('unsplash', INSTANT_IMG_ADMIN_URL. 'assets/js/unsplash.js', array( 'unsplash-helpers' ));
@@ -141,7 +141,7 @@ function instant_img_media_popup_content() {
141
  <div id="instant_images_modal" style="display:none;">
142
  <div class="instant-img-container relax">
143
  <?php include( INSTANT_IMG_PATH . 'admin/views/unsplash-app.php'); ?>
144
- </div>
145
  </div>
146
  <?php
147
  }
@@ -159,7 +159,7 @@ add_action( 'admin_head-edit.php', 'instant_img_media_popup_content' );
159
  * @since 2.0
160
  */
161
 
162
- function instant_img_settings_page(){
163
  include( INSTANT_IMG_PATH . 'admin/views/unsplash.php');
164
  }
165
 
@@ -174,48 +174,48 @@ function instant_img_settings_page(){
174
  */
175
 
176
  function instant_img_upload_image(){
177
-
178
  if (current_user_can( 'edit_theme_options' )){
179
-
180
- error_reporting(E_ALL|E_STRICT);
181
-
182
- $options = get_option( 'instant_img_settings' );
183
  $download_w = isset($options['unsplash_download_w']) ? $options['unsplash_download_w'] : 1600; // width
184
- $download_h = isset($options['unsplash_download_h']) ? $options['unsplash_download_h'] : 1200; // height
185
-
186
  $nonce = sanitize_key($_POST["nonce"]);
187
  if (! wp_verify_nonce( $nonce, 'instant_img_nonce' ))
188
- die('Unable to verify WP nonce');
189
-
190
  // Create /instant-images directory inside /uploads to temporarily store images
191
  $dir = INSTANT_IMG_UPLOAD_PATH;
192
  if(!is_dir($dir)){
193
  mkdir($dir);
194
  }
195
-
196
  // Is directory writeable, if not exit with an error
197
  if (!is_writable(INSTANT_IMG_UPLOAD_PATH.'/')) {
198
- $json = json_encode(
199
  array(
200
  'error' => true,
201
  'msg' => __('Unable to save image, check your server permissions', 'instant-images')
202
  )
203
- );
204
- echo $json;
205
  die();
206
  }
207
-
208
  // Get image variables
209
  $id = sanitize_key($_POST["id"]); // Image ID
210
  $img = sanitize_text_field($_POST["image"]); // Image URL
211
  $desc = sanitize_text_field($_POST["description"]); // Image Description
212
  $path = INSTANT_IMG_UPLOAD_PATH.'/'; // Temp Image Path
213
  $url = INSTANT_IMG_UPLOAD_URL; // Full url path for image upload
214
-
215
  // Create temp. image variable
216
  $filename = $id.'.jpg';
217
- $tmp_img = $path .''.$filename;
218
-
219
  // Generate temp image from URL and store it on server for upload
220
  $ch = curl_init(); // Lets use cURL
221
  curl_setopt($ch, CURLOPT_URL, $img);
@@ -224,17 +224,17 @@ function instant_img_upload_image(){
224
  curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
225
  $picture = curl_exec($ch);
226
  curl_close($ch);
227
-
228
  // Save file to server
229
- $saved_file = file_put_contents($tmp_img, $picture);
230
-
231
  // Was the temporary image saved?
232
-
233
- if ($saved_file) {
234
-
235
  if(file_exists($path.''.$filename)){
236
  // Successfully saved
237
- $json = json_encode(
238
  array(
239
  'error' => false,
240
  'msg' => __('Image successfully saved to server.', 'instant-images'),
@@ -246,27 +246,27 @@ function instant_img_upload_image(){
246
  );
247
  }else{
248
  // File does NOT exist
249
- $json = json_encode(
250
  array(
251
  'error' => true,
252
  'msg' => __('Saved file not found, ensure you have proper permissions set on the uploads directory.', 'instant-images')
253
  )
254
  );
255
- }
256
-
257
  } else {
258
-
259
  // Error on save
260
- $json = json_encode(
261
  array(
262
  'error' => true,
263
  'msg' => __('Unable to save image to uploads directory, check your server permissions.', 'instant-images')
264
  )
265
- );
266
-
267
  }
268
-
269
- echo $json;
270
  die();
271
  }
272
  }
@@ -284,112 +284,58 @@ add_action( 'wp_ajax_instant_img_upload_image', 'instant_img_upload_image' ); //
284
  */
285
 
286
  function instant_img_resize_image(){
287
-
288
  if (current_user_can( 'edit_theme_options' )){
289
-
290
  $nonce = sanitize_key($_POST["nonce"]);
291
  if (! wp_verify_nonce( $nonce, 'instant_img_nonce' ))
292
- die('Unable to verify WP nonce');
293
-
294
  $path = sanitize_text_field($_POST["path"]);
295
  $filename = sanitize_text_field($_POST["filename"]);
296
  $desc = sanitize_text_field($_POST["desc"]);
297
  $url = sanitize_text_field($_POST["url"]);
298
-
299
  // Get size options
300
- $options = get_option( 'instant_img_settings' );
301
  $download_w = isset($options['unsplash_download_w']) ? $options['unsplash_download_w'] : 1600; // width
302
- $download_h = isset($options['unsplash_download_h']) ? $options['unsplash_download_h'] : 1200; // height
303
-
304
  // Resize image
305
  $image = wp_get_image_editor( $path.''.$filename );
306
  if ( ! is_wp_error( $image ) ) {
307
  $image->resize( $download_w, $download_h, false );
308
  $image->save($path.''.$filename);
309
  }
310
-
311
  // Send to media library
312
  $file = media_sideload_image($url.''.$filename, 0, $desc);
313
-
314
  // Delete tmp image
315
  if(file_exists($path.''.$filename)){
316
  unlink($path.''.$filename);
317
  // Send response
318
- $json = json_encode(
319
  array(
320
  'error' => false,
321
  'msg' => __('Image successfully uploaded to media library!', 'instant-images')
322
  )
323
- );
324
  }else{
325
- $json = json_encode(
326
  array(
327
  'error' => true,
328
  'msg' => __('There was an error sending to image to the Media Library, check your server permissions.', 'instant-images')
329
  )
330
- );
331
- }
332
-
333
  echo $json;
334
  die();
335
  }
336
-
337
- }
338
- add_action( 'wp_ajax_instant_img_resize_image', 'instant_img_resize_image' ); // Ajax Resize + Add to Media library
339
-
340
-
341
 
342
- /*
343
- * instant_img_api_limit
344
- * Update the API limit counter
345
- *
346
- * @since 2.0
347
- */
348
- function instant_img_api_limit() {
349
-
350
- if (current_user_can( 'edit_theme_options' )){
351
-
352
- $nonce = sanitize_key($_POST["nonce"]);
353
- // Check our nonce, if they don't match then bounce!
354
- if (! wp_verify_nonce( $nonce, 'instant_img_nonce' ))
355
- die('Unable to verify WP nonce');
356
-
357
- $current = (int)get_option('unsplash_api_count');
358
- $current++;
359
- update_option('unsplash_api_count', $current);
360
-
361
- echo $current;
362
-
363
- die();
364
- }
365
-
366
  }
367
- add_action( 'wp_ajax_instant_img_api_limit', 'instant_img_api_limit' );
368
-
369
-
370
-
371
-
372
- /*
373
- * instant_img_dismiss_warning
374
- * Dismiss the API warning displayed on the photos page
375
- *
376
- * @since 2.0
377
- */
378
- function instant_img_dismiss_warning() {
379
- if (current_user_can( 'edit_theme_options' )){
380
-
381
- $nonce = sanitize_key($_POST["nonce"]);
382
- // Check our nonce, if they don't match then bounce!
383
- if (! wp_verify_nonce( $nonce, 'instant_img_nonce' ))
384
- die('Unable to verify WP nonce');
385
-
386
- update_option('unsplash_api_warning', 'true');
387
- echo 'ok';
388
- die();
389
-
390
- }
391
- }
392
- add_action( 'wp_ajax_instant_img_dismiss_warning', 'instant_img_dismiss_warning' );
393
 
394
 
395
 
@@ -401,12 +347,12 @@ add_action( 'wp_ajax_instant_img_dismiss_warning', 'instant_img_dismiss_warning'
401
  * @since 2.0
402
  */
403
 
404
- function instant_img_filter_admin_footer_text( $text ) {
405
  $screen = get_current_screen();
406
  $base = 'media_page_'.INSTANT_IMG_NAME;
407
  if($screen->base === $base){
408
  echo INSTANT_IMG_TITLE .' '.'is made with <span style="color: #e25555;">♥</span> by <a href="https://connekthq.com" target="_blank" style="font-weight: 500;">Connekt</a> - <a href="https://connekthq.com/plugins/instant-images/" target="_blank">Get Support</a>';
409
- }
410
  }
411
  add_filter( 'admin_footer_text', 'instant_img_filter_admin_footer_text'); // Admin menu text
412
 
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+
5
  /*
6
  * instant_img_admin_vars
7
  * Create admin variables and ajax nonce
9
  * @since 2.0
10
  */
11
 
12
+ function instant_img_admin_vars() {
13
+ $options = get_option( 'instant_img_settings' );
14
  $download_w = isset($options['unsplash_download_w']) ? $options['unsplash_download_w'] : 1600; // width of download file
15
+ $download_h = isset($options['unsplash_download_h']) ? $options['unsplash_download_h'] : 1200; // height of downloads
16
+ $app_id = instant_img_get_app_id(); // APPLICATION ID
17
  ?>
18
  <script type='text/javascript'>
19
  /* <![CDATA[ */
20
+ var instant_img_localize = <?php echo json_encode( array(
21
  'ajax_url' => admin_url('admin-ajax.php'),
22
  'admin_nonce' => wp_create_nonce('instant_img_nonce'),
23
  'download_width' => $download_w,
24
  'download_height' => $download_h,
25
  'unsplash_default_app_id' => INSTANT_IMG_DEFAULT_APP_ID,
26
+ 'unsplash_app_id' => INSTANT_IMG_DEFAULT_APP_ID,
27
  'error_msg_title' => __('Error accessing Unsplash API', 'instant-images'),
28
  'error_msg_desc' => __('Please check your Application ID.', 'instant-images'),
29
  'error_upload' => __('Unable to save image, please check your server permissions.', 'instant-images'),
52
  * @since 2.0
53
  */
54
 
55
+ function instant_img_admin_menu() {
56
+ $usplash_settings_page = add_submenu_page( 'upload.php', INSTANT_IMG_TITLE, INSTANT_IMG_TITLE, 'edit_theme_options', INSTANT_IMG_NAME, 'instant_img_settings_page');
57
  add_action( 'load-' . $usplash_settings_page, 'instant_img_load_scripts' ); //Add our admin scripts
58
  }
59
  add_action( 'admin_menu', 'instant_img_admin_menu' );
87
  wp_enqueue_style('font-awesome-instant-image', INSTANT_IMG_ADMIN_URL. 'assets/css/font-awesome.min.css');
88
  wp_enqueue_script('jquery');
89
  wp_enqueue_script('jquery-form');
90
+ wp_enqueue_script('jquery-masonry');
91
  wp_enqueue_script('imagesLoaded', INSTANT_IMG_ADMIN_URL. 'assets/js/libs/imagesloaded.pkgd.min.js', 'jquery');
92
+ //wp_enqueue_script('unsplash-helpers', INSTANT_IMG_ADMIN_URL. 'assets/js/helpers.unsplash.js', array( 'jquery' ));
93
+ wp_enqueue_script('unsplash', INSTANT_IMG_ADMIN_URL. 'assets/js/unsplash.js');
94
  wp_enqueue_script('instant-images', INSTANT_IMG_ADMIN_URL. 'assets/js/admin.js', 'jquery');
95
  }
96
 
104
  * @since 2.0
105
  */
106
 
107
+ function instant_img_media_popup() {
108
 
109
  // popup title
 
110
  $title_txt = INSTANT_IMG_TITLE .' - '. __('Direct image uploads to your media library', 'instant-images');
111
+ $context = "<a href='#TB_inline?width=600&height=600&inlineId=instant_images_modal'
112
  class='button thickbox instant-images' title='$title_txt'>
113
  <span class='dashicons dashicons-format-gallery' style='font-size: 16px; top: 6px;'></span> ".INSTANT_IMG_TITLE."</a>";
114
 
115
+ echo $context;
116
+
117
  }
118
+ add_action( 'media_buttons', 'instant_img_media_popup', 15 );
119
 
120
 
121
 
132
  wp_enqueue_style( 'font-awesome', INSTANT_IMG_ADMIN_URL. 'assets/css/font-awesome.min.css');
133
  wp_enqueue_script('jquery');
134
  wp_enqueue_script('jquery-form');
135
+ wp_enqueue_script('jquery-masonry');
136
  wp_enqueue_script('imagesLoaded', INSTANT_IMG_ADMIN_URL. 'assets/js/libs/imagesloaded.pkgd.min.js', 'jquery');
137
  wp_enqueue_script('unsplash-helpers', INSTANT_IMG_ADMIN_URL. 'assets/js/helpers.unsplash.js', array( 'jquery' ));
138
  wp_enqueue_script('unsplash', INSTANT_IMG_ADMIN_URL. 'assets/js/unsplash.js', array( 'unsplash-helpers' ));
141
  <div id="instant_images_modal" style="display:none;">
142
  <div class="instant-img-container relax">
143
  <?php include( INSTANT_IMG_PATH . 'admin/views/unsplash-app.php'); ?>
144
+ </div>
145
  </div>
146
  <?php
147
  }
159
  * @since 2.0
160
  */
161
 
162
+ function instant_img_settings_page(){
163
  include( INSTANT_IMG_PATH . 'admin/views/unsplash.php');
164
  }
165
 
174
  */
175
 
176
  function instant_img_upload_image(){
177
+
178
  if (current_user_can( 'edit_theme_options' )){
179
+
180
+ error_reporting(E_ALL|E_STRICT);
181
+
182
+ $options = get_option( 'instant_img_settings' );
183
  $download_w = isset($options['unsplash_download_w']) ? $options['unsplash_download_w'] : 1600; // width
184
+ $download_h = isset($options['unsplash_download_h']) ? $options['unsplash_download_h'] : 1200; // height
185
+
186
  $nonce = sanitize_key($_POST["nonce"]);
187
  if (! wp_verify_nonce( $nonce, 'instant_img_nonce' ))
188
+ die('Unable to verify WP nonce');
189
+
190
  // Create /instant-images directory inside /uploads to temporarily store images
191
  $dir = INSTANT_IMG_UPLOAD_PATH;
192
  if(!is_dir($dir)){
193
  mkdir($dir);
194
  }
195
+
196
  // Is directory writeable, if not exit with an error
197
  if (!is_writable(INSTANT_IMG_UPLOAD_PATH.'/')) {
198
+ $json = json_encode(
199
  array(
200
  'error' => true,
201
  'msg' => __('Unable to save image, check your server permissions', 'instant-images')
202
  )
203
+ );
204
+ echo $json;
205
  die();
206
  }
207
+
208
  // Get image variables
209
  $id = sanitize_key($_POST["id"]); // Image ID
210
  $img = sanitize_text_field($_POST["image"]); // Image URL
211
  $desc = sanitize_text_field($_POST["description"]); // Image Description
212
  $path = INSTANT_IMG_UPLOAD_PATH.'/'; // Temp Image Path
213
  $url = INSTANT_IMG_UPLOAD_URL; // Full url path for image upload
214
+
215
  // Create temp. image variable
216
  $filename = $id.'.jpg';
217
+ $tmp_img = $path .''.$filename;
218
+
219
  // Generate temp image from URL and store it on server for upload
220
  $ch = curl_init(); // Lets use cURL
221
  curl_setopt($ch, CURLOPT_URL, $img);
224
  curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
225
  $picture = curl_exec($ch);
226
  curl_close($ch);
227
+
228
  // Save file to server
229
+ $saved_file = file_put_contents($tmp_img, $picture);
230
+
231
  // Was the temporary image saved?
232
+
233
+ if ($saved_file) {
234
+
235
  if(file_exists($path.''.$filename)){
236
  // Successfully saved
237
+ $json = json_encode(
238
  array(
239
  'error' => false,
240
  'msg' => __('Image successfully saved to server.', 'instant-images'),
246
  );
247
  }else{
248
  // File does NOT exist
249
+ $json = json_encode(
250
  array(
251
  'error' => true,
252
  'msg' => __('Saved file not found, ensure you have proper permissions set on the uploads directory.', 'instant-images')
253
  )
254
  );
255
+ }
256
+
257
  } else {
258
+
259
  // Error on save
260
+ $json = json_encode(
261
  array(
262
  'error' => true,
263
  'msg' => __('Unable to save image to uploads directory, check your server permissions.', 'instant-images')
264
  )
265
+ );
266
+
267
  }
268
+
269
+ echo $json;
270
  die();
271
  }
272
  }
284
  */
285
 
286
  function instant_img_resize_image(){
287
+
288
  if (current_user_can( 'edit_theme_options' )){
289
+
290
  $nonce = sanitize_key($_POST["nonce"]);
291
  if (! wp_verify_nonce( $nonce, 'instant_img_nonce' ))
292
+ die('Unable to verify WP nonce');
293
+
294
  $path = sanitize_text_field($_POST["path"]);
295
  $filename = sanitize_text_field($_POST["filename"]);
296
  $desc = sanitize_text_field($_POST["desc"]);
297
  $url = sanitize_text_field($_POST["url"]);
298
+
299
  // Get size options
300
+ $options = get_option( 'instant_img_settings' );
301
  $download_w = isset($options['unsplash_download_w']) ? $options['unsplash_download_w'] : 1600; // width
302
+ $download_h = isset($options['unsplash_download_h']) ? $options['unsplash_download_h'] : 1200; // height
303
+
304
  // Resize image
305
  $image = wp_get_image_editor( $path.''.$filename );
306
  if ( ! is_wp_error( $image ) ) {
307
  $image->resize( $download_w, $download_h, false );
308
  $image->save($path.''.$filename);
309
  }
310
+
311
  // Send to media library
312
  $file = media_sideload_image($url.''.$filename, 0, $desc);
313
+
314
  // Delete tmp image
315
  if(file_exists($path.''.$filename)){
316
  unlink($path.''.$filename);
317
  // Send response
318
+ $json = json_encode(
319
  array(
320
  'error' => false,
321
  'msg' => __('Image successfully uploaded to media library!', 'instant-images')
322
  )
323
+ );
324
  }else{
325
+ $json = json_encode(
326
  array(
327
  'error' => true,
328
  'msg' => __('There was an error sending to image to the Media Library, check your server permissions.', 'instant-images')
329
  )
330
+ );
331
+ }
332
+
333
  echo $json;
334
  die();
335
  }
 
 
 
 
 
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  }
338
+ add_action( 'wp_ajax_instant_img_resize_image', 'instant_img_resize_image' ); // Ajax Resize + Add to Media library
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
 
340
 
341
 
347
  * @since 2.0
348
  */
349
 
350
+ function instant_img_filter_admin_footer_text( $text ) {
351
  $screen = get_current_screen();
352
  $base = 'media_page_'.INSTANT_IMG_NAME;
353
  if($screen->base === $base){
354
  echo INSTANT_IMG_TITLE .' '.'is made with <span style="color: #e25555;">♥</span> by <a href="https://connekthq.com" target="_blank" style="font-weight: 500;">Connekt</a> - <a href="https://connekthq.com/plugins/instant-images/" target="_blank">Get Support</a>';
355
+ }
356
  }
357
  add_filter( 'admin_footer_text', 'instant_img_filter_admin_footer_text'); // Admin menu text
358
 
admin/assets/css/admin.css CHANGED
@@ -110,21 +110,21 @@ Copyright: Darren Cooney & Connekt Media
110
  display: none;
111
  }
112
  .instant-img-container #initialize h2{
113
- font-size: 28px;
114
  font-weight: 700;
115
  color: #333;
116
- margin: 15px 0 20px;
117
- font-style: italic;
118
  }
119
  .instant-img-container #initialize p{
120
  display: block;
121
- padding: 10px 15% 0;
122
  font-size: 16px;
123
- line-height: 24px;
124
  }
125
  .instant-img-container #initialize p.sm{
126
  font-size: 14px;
127
- padding-top: 15px;
128
  }
129
  .instant-img-container #initialize p span{
130
  color: #999;
@@ -952,6 +952,10 @@ a.button.instant-images span{
952
  margin: 0;
953
  width: 100%;
954
  }
 
 
 
 
955
  .instant-img-container input[type=text],
956
  .instant-img-container input[type=number]{
957
  padding: 10px;
@@ -1007,13 +1011,23 @@ a.button.instant-images span{
1007
  }
1008
  .cnkt-sidebar h2{
1009
  border: none;
1010
- padding: 0;
1011
- margin: 5px 0 10px;
1012
  font-size: 16px;
 
 
 
 
 
 
 
 
 
 
 
1013
  }
1014
  .instant-img-container .cnkt-sidebar .cta{
1015
  background: #fff;
1016
- padding: 18px 20px 20px;
1017
  margin: 0 0 20px;
1018
  overflow: hidden;
1019
  position: relative;
@@ -1031,13 +1045,15 @@ a.button.instant-images span{
1031
  display: block;
1032
  width: 100%;
1033
  font-size: 12px;
 
 
 
 
1034
  }
1035
-
1036
- .instant-img-container .cnkt-sidebar .plugin-listing{}
1037
  .instant-img-container .cnkt-sidebar .plugin-listing li{
1038
  position: relative;
1039
  padding-left: 53px;
1040
- margin: 10px 0;
1041
  min-height: 48px;
1042
  }
1043
  .instant-img-container .cnkt-sidebar .plugin-listing img{
@@ -1194,3 +1210,7 @@ a.button.instant-images span{
1194
  }
1195
  }
1196
 
 
 
 
 
110
  display: none;
111
  }
112
  .instant-img-container #initialize h2{
113
+ font-size: 29px;
114
  font-weight: 700;
115
  color: #333;
116
+ margin: 15px 0;
117
+ word-spacing: -0.1em;
118
  }
119
  .instant-img-container #initialize p{
120
  display: block;
121
+ padding: 10px 15% 10px;
122
  font-size: 16px;
123
+ line-height: 28px;
124
  }
125
  .instant-img-container #initialize p.sm{
126
  font-size: 14px;
127
+ padding-top: 20px;
128
  }
129
  .instant-img-container #initialize p span{
130
  color: #999;
952
  margin: 0;
953
  width: 100%;
954
  }
955
+ #unsplash-form-options h2,
956
+ #unsplash-form-options p.desc{
957
+ display: none;
958
+ }
959
  .instant-img-container input[type=text],
960
  .instant-img-container input[type=number]{
961
  padding: 10px;
1011
  }
1012
  .cnkt-sidebar h2{
1013
  border: none;
1014
+ padding: 15px 20px 3px;
 
1015
  font-size: 16px;
1016
+ }
1017
+ .cnkt-sidebar h2 + p{
1018
+ padding: 0 20px 15px;
1019
+ margin: 0 !important;
1020
+ border-bottom: 1px solid #e7e7e7;
1021
+ font-style: italic;
1022
+ }
1023
+ .cnkt-sidebar h2,
1024
+ .cnkt-sidebar h2 + p{
1025
+ background: #f7f7f7;
1026
+ margin: 0;
1027
  }
1028
  .instant-img-container .cnkt-sidebar .cta{
1029
  background: #fff;
1030
+ padding: 0 0 20px;
1031
  margin: 0 0 20px;
1032
  overflow: hidden;
1033
  position: relative;
1045
  display: block;
1046
  width: 100%;
1047
  font-size: 12px;
1048
+ }
1049
+ .instant-img-container .cnkt-sidebar .cta-wrap{
1050
+ display: block;
1051
+ padding: 5px 20px 0;
1052
  }
 
 
1053
  .instant-img-container .cnkt-sidebar .plugin-listing li{
1054
  position: relative;
1055
  padding-left: 53px;
1056
+ margin: 10px 0 0;
1057
  min-height: 48px;
1058
  }
1059
  .instant-img-container .cnkt-sidebar .plugin-listing img{
1210
  }
1211
  }
1212
 
1213
+ input:-webkit-autofill {
1214
+ -webkit-box-shadow: 0 0 0px 1000px white inset;
1215
+ }
1216
+
admin/assets/js/admin.js CHANGED
@@ -5,7 +5,6 @@ jQuery(document).ready(function($) {
5
 
6
 
7
 
8
-
9
  /*
10
  * Dropdowns
11
  *
@@ -50,7 +49,7 @@ jQuery(document).ready(function($) {
50
  instant.dropDown(e);
51
  return false;
52
  });
53
- });
54
 
55
 
56
 
5
 
6
 
7
 
 
8
  /*
9
  * Dropdowns
10
  *
49
  instant.dropDown(e);
50
  return false;
51
  });
52
+ });
53
 
54
 
55
 
admin/assets/js/helpers.unsplash.js DELETED
@@ -1,59 +0,0 @@
1
- jQuery(document).ready(function($) {
2
- "use strict";
3
-
4
-
5
- /*
6
- * unsplashwp.trackUsage
7
- * Track API Usage
8
- *
9
- */
10
- $.fn.trackUsage = function(){
11
- // Track API usage if App ID is still the default APP Id
12
- if(instant_img_localize.unsplash_app_id === instant_img_localize.unsplash_default_app_id){
13
- $.ajax({
14
- type: 'POST',
15
- url: instant_img_localize.ajax_url,
16
- data: {
17
- action: 'instant_img_api_limit',
18
- nonce: instant_img_localize.admin_nonce,
19
- },
20
- success: function(response) {
21
- //console.log('API Usage: '+response+' requests');
22
- if($('#unplash-api-usage').length){
23
- //$('#unplash-api-usage').text(response);
24
- }
25
- }
26
- });
27
- }
28
- }
29
-
30
-
31
-
32
- /*
33
- * unsplashwp.dismissWarning
34
- * Dismiss the API warning displayed on the photos page
35
- *
36
- */
37
- $.fn.dismissWarning = function(){
38
- $.ajax({
39
- type: 'POST',
40
- url: instant_img_localize.ajax_url,
41
- data: {
42
- action: 'instant_img_dismiss_warning',
43
- nonce: instant_img_localize.admin_nonce,
44
- },
45
- success: function(response) {
46
- $('#unsplashwp-api-warning').slideUp(200, function(){
47
- console.log('Warning dismissed');
48
- });
49
- }
50
- });
51
- }
52
-
53
- $('#unsplashwp-api-warning .dismiss').on('click', function(e){
54
- e.preventDefault();
55
- $.fn.dismissWarning();
56
- });
57
-
58
-
59
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/assets/js/unsplash.js CHANGED
@@ -39,10 +39,6 @@ jQuery(document).ready(function($) {
39
  var photos = [],
40
  api = 'https://api.unsplash.com/photos',
41
  app_id = instant_img_localize.unsplash_app_id;
42
-
43
- if(app_id === ''){
44
- app_id = instant_img_localize.unsplash_default_app_id;
45
- }
46
 
47
  var url = api +"/?client_id="+ app_id +"&per_page="+ unsplash.posts_per_page +"&page="+ unsplash.page +"&order_by=" + unsplash.orderby +"";
48
 
@@ -114,23 +110,24 @@ jQuery(document).ready(function($) {
114
  var photo = photos[i],
115
  id = photo.id,
116
  img = photo.urls.small,
117
- full_size = photo.urls.full,
 
118
  author = photo.user.name,
119
  username = photo.user.username,
120
  link = photo.links.html,
121
  likes = photo.likes;
122
 
123
- // Build element
124
  el += '<div class="item">';
125
- el += '<div class="img-wrap">';
126
- el += '<a class="upload" href="'+ link +'" data-id="'+id+'" data-url="'+full_size+'" data-desc="'+instant_img_localize.photo_by+' '+author+'" title="'+instant_img_localize.photo_by+' '+author+' - '+instant_img_localize.upload+'">';
127
- el += '<div class="notice-msg"></div>';
128
- el += '<img src="'+ img +'" alt="'+instant_img_localize.photo_by+' '+author+'" />'
129
- el += '</a>';
130
- el += '<span class="num zoom-in" data-href="'+link+'" title="'+instant_img_localize.full_size+'"><i class="fa fa-search-plus"></i></span>';
131
- el += '<span class="num profile" data-href="https://unsplash.com/@'+username+'" title="'+instant_img_localize.view_all+' '+username+' @ unsplash.com"><i class="fa fa-user"></i></span>';
132
- el += '<span class="likes" title="'+likes+' '+instant_img_localize.likes+'">❤ '+likes+'</span>';
133
- el +='</div>';
134
  el += '</div>';
135
 
136
  }
@@ -210,7 +207,7 @@ jQuery(document).ready(function($) {
210
  }
211
  },
212
  error: function(xhr, status, error) {
213
- console.log(error);
214
  unsplash.uploadError(el);
215
  }
216
  });
@@ -241,8 +238,8 @@ jQuery(document).ready(function($) {
241
  url: url,
242
  nonce: instant_img_localize.admin_nonce,
243
  },
244
- success: function(response) {
245
- //console.log(response);
246
  $('.notice-msg', el).removeClass('active').text('');
247
 
248
  if(response){
@@ -280,7 +277,7 @@ jQuery(document).ready(function($) {
280
 
281
  },
282
  error: function(xhr, status, error) {
283
- console.log(error);
284
  unsplash.uploadError(el);
285
  }
286
  });
@@ -459,7 +456,6 @@ jQuery(document).ready(function($) {
459
  unsplash.initialize.slideUp(250);
460
  unsplash.init = false;
461
  }
462
- $.fn.trackUsage();
463
  unsplash.loader.show();
464
  unsplash.btn.addClass('loading');
465
  unsplash.is_loading = true;
39
  var photos = [],
40
  api = 'https://api.unsplash.com/photos',
41
  app_id = instant_img_localize.unsplash_app_id;
 
 
 
 
42
 
43
  var url = api +"/?client_id="+ app_id +"&per_page="+ unsplash.posts_per_page +"&page="+ unsplash.page +"&order_by=" + unsplash.orderby +"";
44
 
110
  var photo = photos[i],
111
  id = photo.id,
112
  img = photo.urls.small,
113
+ //full_size = photo.urls.full, // updated in 2.1
114
+ full_size = photo.urls.raw,
115
  author = photo.user.name,
116
  username = photo.user.username,
117
  link = photo.links.html,
118
  likes = photo.likes;
119
 
120
+ // Photo Template
121
  el += '<div class="item">';
122
+ el += '<div class="img-wrap">';
123
+ el += '<a class="upload" href="'+ link +'" data-id="'+id+'" data-url="'+full_size+'" data-desc="'+instant_img_localize.photo_by+' '+author+'" title="'+instant_img_localize.photo_by+' '+author+' - '+instant_img_localize.upload+'">';
124
+ el += '<div class="notice-msg"></div>';
125
+ el += '<img src="'+ img +'" alt="'+instant_img_localize.photo_by+' '+author+'" />'
126
+ el += '</a>';
127
+ el += '<span class="num zoom-in" data-href="'+link+'" title="'+instant_img_localize.full_size+'"><i class="fa fa-search-plus"></i></span>';
128
+ el += '<span class="num profile" data-href="https://unsplash.com/@'+username+'" title="'+instant_img_localize.view_all+' '+username+' @ unsplash.com"><i class="fa fa-user"></i></span>';
129
+ el += '<span class="likes" title="'+likes+' '+instant_img_localize.likes+'">❤ '+likes+'</span>';
130
+ el +='</div>';
131
  el += '</div>';
132
 
133
  }
207
  }
208
  },
209
  error: function(xhr, status, error) {
210
+ console.log(xhr, status, error);
211
  unsplash.uploadError(el);
212
  }
213
  });
238
  url: url,
239
  nonce: instant_img_localize.admin_nonce,
240
  },
241
+ success: function(response) {
242
+
243
  $('.notice-msg', el).removeClass('active').text('');
244
 
245
  if(response){
277
 
278
  },
279
  error: function(xhr, status, error) {
280
+ console.log(xhr, status, error);
281
  unsplash.uploadError(el);
282
  }
283
  });
456
  unsplash.initialize.slideUp(250);
457
  unsplash.init = false;
458
  }
 
459
  unsplash.loader.show();
460
  unsplash.btn.addClass('loading');
461
  unsplash.is_loading = true;
admin/functions.php CHANGED
@@ -2,18 +2,12 @@
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
 
4
 
5
-
6
  /*
7
  * instant_img_get_app_id
8
  * Get the current app id from settings
9
  *
10
  * @since 2.0
11
- */
12
  function instant_img_get_app_id(){
13
- $options = get_option( 'instant_img_settings' );
14
- $app_id = isset($options['unsplash_app_id']) ? $options['unsplash_app_id'] : INSTANT_IMG_DEFAULT_APP_ID;
15
- if(empty($app_id)){
16
- $app_id = INSTANT_IMG_DEFAULT_APP_ID;
17
- }
18
- return $app_id;
19
- }
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
 
4
 
 
5
  /*
6
  * instant_img_get_app_id
7
  * Get the current app id from settings
8
  *
9
  * @since 2.0
10
+ */
11
  function instant_img_get_app_id(){
12
+ return INSTANT_IMG_DEFAULT_APP_ID;
13
+ }
 
 
 
 
 
admin/includes/cta/about.php CHANGED
@@ -3,21 +3,24 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  ?>
4
  <div class="cta padding-bottom">
5
  <h2>Our Plugins</h2>
6
- <ul class="plugin-listing">
7
- <li>
8
- <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/alm-logo-48x48.png" alt"" />
9
- <strong><a href="https://connekthq.com/plugins/ajax-load-more/" target="blank">Ajax Load More</a></strong><br>A powerful plugin to add infinite scroll functionality to your website.</li>
10
- <li>
11
- <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/eq-logo-48x48.png" alt"" />
12
- <strong><a href="https://connekthq.com/plugins/easy-query/" target="blank">Easy Query</a></strong><br>Build and display complex queries without touching a line of code.</li>
13
- <li>
14
- <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/post-explorer-logo-48x48.png" alt"" />
15
- <strong><a href="https://connekthq.com/plugins/post-explorer/" target="blank">Post Explorer</a></strong><br>Load single posts and custom post types with Ajax.</li>
16
- <li>
17
- <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/velocity-logo-48x48.png" alt"" />
18
- <strong><a href="https://connekthq.com/plugins/velocity/" target="blank">Velocity</a></strong><br>Improve website performance by lazy loading embedded media.</li>
19
- </ul>
20
- <hr style="margin: 6px 0 20px;"/>
21
  <p><strong><?php echo INSTANT_IMG_TITLE; ?></strong> is made with <span style="color: #e25555;">♥</span> by <a target="blank" href="https://connekthq.com">Connekt</a></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  <a class="visit" target="blank" href="https://connekthq.com/plugins/instant-images/"><i class="fa fa-globe"></i> Visit Plugin Website</a>
23
- </div>
3
  ?>
4
  <div class="cta padding-bottom">
5
  <h2>Our Plugins</h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  <p><strong><?php echo INSTANT_IMG_TITLE; ?></strong> is made with <span style="color: #e25555;">♥</span> by <a target="blank" href="https://connekthq.com">Connekt</a></p>
7
+
8
+ <div class="cta-wrap">
9
+ <ul class="plugin-listing">
10
+ <li>
11
+ <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/alm-logo-48x48.png" alt"" />
12
+ <strong><a href="https://connekthq.com/plugins/ajax-load-more/" target="blank">Ajax Load More</a></strong><br>A powerful plugin to add infinite scroll functionality to your website.</li>
13
+ <li>
14
+ <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/eq-logo-48x48.png" alt"" />
15
+ <strong><a href="https://connekthq.com/plugins/easy-query/" target="blank">Easy Query</a></strong><br>Build and display complex queries without touching a line of code.</li>
16
+ <li>
17
+ <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/post-explorer-logo-48x48.png" alt"" />
18
+ <strong><a href="https://connekthq.com/plugins/post-explorer/" target="blank">Post Explorer</a></strong><br>Load single posts and custom post types with Ajax.</li>
19
+ <li>
20
+ <img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/velocity-logo-48x48.png" alt"" />
21
+ <strong><a href="https://connekthq.com/plugins/velocity/" target="blank">Velocity</a></strong><br>Improve website performance by lazy loading embedded media.</li>
22
+ </ul>
23
+ </div>
24
+
25
  <a class="visit" target="blank" href="https://connekthq.com/plugins/instant-images/"><i class="fa fa-globe"></i> Visit Plugin Website</a>
26
+ </div>
admin/includes/cta/permissions.php CHANGED
@@ -9,9 +9,11 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9
  // Does directory exist and is it writeable
10
  if (!is_writable(INSTANT_IMG_UPLOAD_PATH.'/')) { ?>
11
  <div class="cta error-warning">
12
- <h3><i class="fa fa-exclamation-triangle" aria-hidden="true" style="color: #d54343;"></i> <?php _e('Permissions Error', 'instant-images'); ?></h3>
13
- <p><?php _e('Instant Images is unable to save downloads to your server. Please enable write access to the following directory', 'instant-images'); ?>:
14
- </p>
15
- <input type="text" value="<?php echo INSTANT_IMG_UPLOAD_URL; ?>">
16
- </div>
17
- <?php } ?>
 
 
9
  // Does directory exist and is it writeable
10
  if (!is_writable(INSTANT_IMG_UPLOAD_PATH.'/')) { ?>
11
  <div class="cta error-warning">
12
+ <div class="cta-wrap" style="padding-top: 20px;">
13
+ <h3><i class="fa fa-exclamation-triangle" aria-hidden="true" style="color: #d54343;"></i> <?php _e('Permissions Error', 'instant-images'); ?></h3>
14
+ <p><?php _e('Instant Images is unable to save downloads to your server. Please enable write access to the following directory', 'instant-images'); ?>:
15
+ </p>
16
+ <input type="text" value="<?php echo INSTANT_IMG_UPLOAD_URL; ?>">
17
+ </div>
18
+ </div>
19
+ <?php } ?>
admin/includes/settings.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
  /*
5
  * instant_img_admin_init
6
  * Initiate the plugin, create our setting variables.
@@ -10,45 +10,36 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
 
11
  add_action( 'admin_init', 'instant_img_admin_init');
12
  function instant_img_admin_init(){
13
- register_setting(
14
- 'instant-img-setting-group',
15
- 'instant_img_settings',
16
- 'unsplash_sanitize'
 
 
 
 
 
 
 
17
  );
18
-
19
- add_settings_section(
20
- 'unsplash_general_settings',
21
- __('Unsplash Settings', 'instant-images'),
22
- 'unsplash_general_settings_callback',
23
- 'instant-images'
24
- );
25
-
26
  // Download Width
27
- add_settings_field(
28
- 'unsplash_download_w',
29
- __('Upload Image Width', 'instant-images' ),
30
- 'unsplash_download_w_callback',
31
- 'instant-images',
32
- 'unsplash_general_settings'
33
- );
34
-
35
  // Download Height
36
- add_settings_field(
37
- 'unsplash_download_h',
38
- __('Upload Image Height', 'instant-images' ),
39
- 'unsplash_download_h_callback',
40
- 'instant-images',
41
- 'unsplash_general_settings'
42
- );
43
-
44
- // API Key
45
- add_settings_field(
46
- 'unsplash_app_id',
47
- __('Unplash Application ID', 'instant-images' ),
48
- 'unsplash_app_id_callback',
49
- 'instant-images',
50
- 'unsplash_general_settings'
51
- );
52
  }
53
 
54
 
@@ -86,12 +77,12 @@ function unsplash_sanitize( $input ) {
86
 
87
  function unsplash_download_w_callback(){
88
  $options = get_option( 'instant_img_settings' );
89
-
90
- if(!isset($options['unsplash_download_w']))
91
  $options['unsplash_download_w'] = '1600';
92
-
93
  echo '<label for="instant_img_settings[unsplash_download_w]"><strong>'.__('Max Image Upload Width:', 'instant-images').'</strong></label>';
94
- echo '<input type="number" id="instant_img_settings[unsplash_download_w]" name="instant_img_settings[unsplash_download_w]" value="'.$options['unsplash_download_w'].'" class="sm" step="20" max="3200" /> ';
95
  }
96
 
97
 
@@ -105,35 +96,10 @@ function unsplash_download_w_callback(){
105
 
106
  function unsplash_download_h_callback(){
107
  $options = get_option( 'instant_img_settings' );
108
-
109
- if(!isset($options['unsplash_download_h']))
110
- $options['unsplash_download_h'] = '1200';
111
-
112
- echo '<label for="instant_img_settings[unsplash_download_h]"><strong>'.__('Max Image Upload Height:', 'instant-images').'</strong></label>';
113
- echo '<input type="number" id="instant_img_settings[unsplash_download_h]" name="instant_img_settings[unsplash_download_h]" value="'.$options['unsplash_download_h'].'" class="sm" step="20" max="3200" /> ';
114
- }
115
-
116
-
117
 
 
 
118
 
119
- /*
120
- * unsplash_app_id_callback
121
- * Application ID
122
- *
123
- * @since 1.0
124
- */
125
-
126
- function unsplash_app_id_callback(){
127
- $options = get_option( 'instant_img_settings' );
128
- $unsplash_api_count = get_option('unsplash_api_count');
129
-
130
- if(!isset($options['unsplash_app_id'])){
131
- $app_id = '';
132
- } else {
133
- $app_id = $options['unsplash_app_id'];
134
- }
135
-
136
- echo '<label for="instant_img_settings[unsplash_app_id]"><strong>'.__('Unsplash App ID:', 'instant-images').'</strong> <span style="font-size: 0.9em; float: right;"><a href="'.INSTANT_IMG_HELP_URL.'" target="_blank">'. __('What\'s This?', 'instant-images').'</a></span></label>';
137
- echo '<input type="text" id="instant_img_settings[unsplash_app_id]" name="instant_img_settings[unsplash_app_id]" value="'.$app_id.'" class="sm" /> ';
138
-
139
  }
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
  /*
5
  * instant_img_admin_init
6
  * Initiate the plugin, create our setting variables.
10
 
11
  add_action( 'admin_init', 'instant_img_admin_init');
12
  function instant_img_admin_init(){
13
+ register_setting(
14
+ 'instant-img-setting-group',
15
+ 'instant_img_settings',
16
+ 'unsplash_sanitize'
17
+ );
18
+
19
+ add_settings_section(
20
+ 'unsplash_general_settings',
21
+ __('Unsplash Settings', 'instant-images'),
22
+ 'unsplash_general_settings_callback',
23
+ 'instant-images'
24
  );
25
+
 
 
 
 
 
 
 
26
  // Download Width
27
+ add_settings_field(
28
+ 'unsplash_download_w',
29
+ __('Upload Image Width', 'instant-images' ),
30
+ 'unsplash_download_w_callback',
31
+ 'instant-images',
32
+ 'unsplash_general_settings'
33
+ );
34
+
35
  // Download Height
36
+ add_settings_field(
37
+ 'unsplash_download_h',
38
+ __('Upload Image Height', 'instant-images' ),
39
+ 'unsplash_download_h_callback',
40
+ 'instant-images',
41
+ 'unsplash_general_settings'
42
+ );
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
 
77
 
78
  function unsplash_download_w_callback(){
79
  $options = get_option( 'instant_img_settings' );
80
+
81
+ if(!isset($options['unsplash_download_w']))
82
  $options['unsplash_download_w'] = '1600';
83
+
84
  echo '<label for="instant_img_settings[unsplash_download_w]"><strong>'.__('Max Image Upload Width:', 'instant-images').'</strong></label>';
85
+ echo '<input type="number" id="instant_img_settings[unsplash_download_w]" name="instant_img_settings[unsplash_download_w]" value="'.$options['unsplash_download_w'].'" class="sm" step="20" max="3200" /> ';
86
  }
87
 
88
 
96
 
97
  function unsplash_download_h_callback(){
98
  $options = get_option( 'instant_img_settings' );
 
 
 
 
 
 
 
 
 
99
 
100
+ if(!isset($options['unsplash_download_h']))
101
+ $options['unsplash_download_h'] = '1200';
102
 
103
+ echo '<label for="instant_img_settings[unsplash_download_h]"><strong>'.__('Max Image Upload Height:', 'instant-images').'</strong></label>';
104
+ echo '<input type="number" id="instant_img_settings[unsplash_download_h]" name="instant_img_settings[unsplash_download_h]" value="'.$options['unsplash_download_h'].'" class="sm" step="20" max="3200" /> ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
admin/includes/warning.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
- ?>
4
-
5
- <div id="unsplashwp-api-warning">
6
- <div class="inner">
7
- <h4><?php _e('Did you know', 'instant-images'); ?>?</h4>
8
- <p>Unsplash has a rate limit of 5000 API calls per hour. You can help offset the API usage of Instant Images by simply <a href="https://unsplash.com/developers/register" target="_blank">registering as a developer</a> then creating your own application directly @ <a href="https://unsplash.com/login" target="_blank">Unsplash</a>.</p>
9
-
10
- <a href="<?php echo INSTANT_IMG_HELP_URL; ?>" target="_blank" class="button button-primary"><i class="fa fa-chevron-right"></i>&nbsp; <?php _e('Learn More', 'instant-images'); ?></a> &nbsp;
11
- <a href="#" class="button dismiss"><i class="fa fa-times-circle"></i>&nbsp; <?php _e('No Thanks', 'instant-images'); ?></a>
12
- </div>
13
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/views/unsplash-app.php CHANGED
@@ -1,20 +1,9 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  ?>
4
- <?php
5
- $unsplash_api_count = get_option('unsplash_api_count');
6
- $warning = get_option('unsplash_api_warning');
7
- $app_id = instant_img_get_app_id();
8
-
9
- // Is the APP ID unique? If so, we don't need to display API warnings.
10
- $unique_app_id = false;
11
- if($app_id !== INSTANT_IMG_DEFAULT_APP_ID){
12
- $unique_app_id = true;
13
- }
14
- ?>
15
 
16
  <div class="unsplashwp-search">
17
- <form id="photo-search">
18
  <div class="field-wrap">
19
  <label for="unsplashwp-search" class="offscreen"><?php _e('Enter Search term', 'instant-images'); ?></label>
20
  <input type="search" id="unsplashwp-search" value="" placeholder="<?php _e('Search for Toronto, Computers, Coffee + Breakfast etc...', 'instant-images'); ?>">
@@ -25,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
25
  <div class="drop-options btn">
26
  <a href="#"><i class="fa fa-cog"></i><span><?php _e('Options', 'instant-images'); ?></span></a>
27
  <div class="dropdown">
28
- <h4><?php _e('Order by:', 'instant-images'); ?></h4>
29
  <ul id="unsplash-order">
30
  <li><a href="#" data-id="latest"><span></span> <?php _e('Newest', 'instant-images'); ?></a></li>
31
  <li><a href="#" data-id="oldest"><span></span> <?php _e('Oldest', 'instant-images'); ?></a></li>
@@ -40,15 +29,6 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
40
  </form>
41
  </div>
42
 
43
- <?php
44
- // API Usage Msg
45
- $showing_warning = false;
46
- if($unsplash_api_count > round(INSTANT_IMG_WARNING) && $warning !== 'true' && !$unique_app_id){
47
- $showing_warning = true;
48
- include( INSTANT_IMG_PATH . 'admin/includes/warning.php');
49
- }
50
- ?>
51
-
52
  <div id="initialize">
53
  <div class="init-content-wrap">
54
  <h2><?php _e('Search Unsplash', 'instant-images'); ?></h2>
@@ -61,11 +41,10 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
61
  <button type="button" class="button" data-id="popular"><i class="fa fa-heart"></i>&nbsp; <?php _e('Most Popular', 'instant-images'); ?></button>
62
  </div>
63
  </div>
64
- <div class="search-arrow<?php if($showing_warning){ echo ' hide';} ?>"><img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>/assets/img/arrow-up.png" alt="" /></div>
65
  </div>
66
 
67
  <div id="unsplashwp">
68
- <div id="unsplashwp-api-message"><h3></h3><p></p></div>
69
  <div id="photos"></div>
70
  </div>
71
 
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  ?>
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  <div class="unsplashwp-search">
6
+ <form id="photo-search" autocomplete="off">
7
  <div class="field-wrap">
8
  <label for="unsplashwp-search" class="offscreen"><?php _e('Enter Search term', 'instant-images'); ?></label>
9
  <input type="search" id="unsplashwp-search" value="" placeholder="<?php _e('Search for Toronto, Computers, Coffee + Breakfast etc...', 'instant-images'); ?>">
14
  <div class="drop-options btn">
15
  <a href="#"><i class="fa fa-cog"></i><span><?php _e('Options', 'instant-images'); ?></span></a>
16
  <div class="dropdown">
17
+ <h4><?php _e('Order by:', 'instant-images'); ?></h4>
18
  <ul id="unsplash-order">
19
  <li><a href="#" data-id="latest"><span></span> <?php _e('Newest', 'instant-images'); ?></a></li>
20
  <li><a href="#" data-id="oldest"><span></span> <?php _e('Oldest', 'instant-images'); ?></a></li>
29
  </form>
30
  </div>
31
 
 
 
 
 
 
 
 
 
 
32
  <div id="initialize">
33
  <div class="init-content-wrap">
34
  <h2><?php _e('Search Unsplash', 'instant-images'); ?></h2>
41
  <button type="button" class="button" data-id="popular"><i class="fa fa-heart"></i>&nbsp; <?php _e('Most Popular', 'instant-images'); ?></button>
42
  </div>
43
  </div>
44
+ <div class="search-arrow"><img src="<?php echo INSTANT_IMG_ADMIN_URL; ?>assets/img/arrow-up.png" alt=""></div>
45
  </div>
46
 
47
  <div id="unsplashwp">
 
48
  <div id="photos"></div>
49
  </div>
50
 
admin/views/unsplash.php CHANGED
@@ -3,58 +3,66 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  ?>
4
  <div class="instant-img-container relax">
5
  <div class="wrap">
6
-
7
  <div class="header-wrap">
8
  <h1><?php echo INSTANT_IMG_TITLE; ?> <span><?php echo INSTANT_IMG_VERSION; ?></span></h1>
9
- <p><?php _e('One click uploads of <a href="https://unsplash.com/" target="_blank">unsplash.com</a> photos directly to your media library (formally UnsplashWP)', 'instant-images'); ?></p>
10
  </div>
11
-
12
  <div class="cnkt-main">
13
- <div class="group">
14
- <?php include( INSTANT_IMG_PATH . 'admin/views/unsplash-app.php'); ?>
15
  </div>
16
  <a href="#" class="expand" title="Expand/Collapse"><i class="fa fa-expand open" aria-hidden="true"></i><i class="fa fa-close close"></i><span><?php _e('Expand', 'instant-images'); ?></span></a>
17
- </div>
18
-
19
  <div class="cnkt-sidebar">
20
  <?php include( INSTANT_IMG_PATH . 'admin/includes/cta/permissions.php'); ?>
21
-
22
- <div class="cta">
23
-
24
- <form action="options.php" method="post" id="unsplash-form-options">
25
- <?php
26
- settings_fields( 'instant-img-setting-group' );
27
- do_settings_sections( 'instant-images' );
28
- //get the older values, wont work the first time
29
- $options = get_option( 'instant_img_settings' );
30
- ?>
31
- <div class="save-settings">
32
- <?php submit_button(__('Save Settings', 'instant-images')); ?>
33
- <div class="loading"></div>
34
- </div>
35
- <script type="text/javascript">
36
- jQuery(document).ready(function() {
37
- jQuery('#unsplash-form-options').submit(function() {
38
- jQuery('.save-settings .loading').fadeIn();
39
- jQuery(this).ajaxSubmit({
40
- success: function(){
41
- jQuery('.save-settings .loading').fadeOut(250, function(){
42
- window.location.reload();
43
- });
44
- },
45
- error: function(){
46
- jQuery('.save-settings .loading').fadeOut();
47
- alert("<?php _e('Sorry, settings could not be saved.', 'instant-images'); ?>");
48
- }
49
- });
50
- return false;
 
 
 
 
 
 
51
  });
52
- });
53
- </script>
54
- </form>
 
 
55
  </div>
56
  <?php include( INSTANT_IMG_PATH . 'admin/includes/cta/about.php'); ?>
57
- </div>
58
  </div>
59
-
60
- </div>
3
  ?>
4
  <div class="instant-img-container relax">
5
  <div class="wrap">
6
+
7
  <div class="header-wrap">
8
  <h1><?php echo INSTANT_IMG_TITLE; ?> <span><?php echo INSTANT_IMG_VERSION; ?></span></h1>
9
+ <p><?php _e('One click uploads of <a href="https://unsplash.com/" target="_blank">unsplash.com</a> photos directly to your media library (formally UnsplashWP)', 'instant-images'); ?></p>
10
  </div>
11
+
12
  <div class="cnkt-main">
13
+ <div class="group">
14
+ <?php include( INSTANT_IMG_PATH . 'admin/views/unsplash-app.php'); ?>
15
  </div>
16
  <a href="#" class="expand" title="Expand/Collapse"><i class="fa fa-expand open" aria-hidden="true"></i><i class="fa fa-close close"></i><span><?php _e('Expand', 'instant-images'); ?></span></a>
17
+ </div>
18
+
19
  <div class="cnkt-sidebar">
20
  <?php include( INSTANT_IMG_PATH . 'admin/includes/cta/permissions.php'); ?>
21
+
22
+ <div class="cta">
23
+
24
+ <h2><?php _e('Unsplash Settings', 'instant-images'); ?></h2>
25
+ <p><?php _e('Manage your media upload settings', 'instant-images'); ?></p>
26
+
27
+ <div class="cta-wrap">
28
+
29
+ <form action="options.php" method="post" id="unsplash-form-options">
30
+ <?php
31
+ settings_fields( 'instant-img-setting-group' );
32
+ do_settings_sections( 'instant-images' );
33
+ //get the older values, wont work the first time
34
+ $options = get_option( 'instant_img_settings' );
35
+ ?>
36
+ <div class="save-settings">
37
+ <?php submit_button(__('Save Settings', 'instant-images')); ?>
38
+ <div class="loading"></div>
39
+ </div>
40
+ <script type="text/javascript">
41
+ jQuery(document).ready(function() {
42
+ jQuery('#unsplash-form-options').submit(function() {
43
+ jQuery('.save-settings .loading').fadeIn();
44
+ jQuery(this).ajaxSubmit({
45
+ success: function(){
46
+ jQuery('.save-settings .loading').fadeOut(250, function(){
47
+ window.location.reload();
48
+ });
49
+ },
50
+ error: function(){
51
+ jQuery('.save-settings .loading').fadeOut();
52
+ alert("<?php _e('Sorry, settings could not be saved.', 'instant-images'); ?>");
53
+ }
54
+ });
55
+ return false;
56
+ });
57
  });
58
+ </script>
59
+ </form>
60
+
61
+ </div>
62
+
63
  </div>
64
  <?php include( INSTANT_IMG_PATH . 'admin/includes/cta/about.php'); ?>
65
+ </div>
66
  </div>
67
+
68
+ </div>
instant-images.php CHANGED
@@ -6,7 +6,7 @@ Description: One click photo uploads directly to your media library.
6
  Author: Darren Cooney
7
  Twitter: @connekthq
8
  Author URI: https://connekthq.com
9
- Version: 2.0.1
10
  License: GPL
11
  Copyright: Darren Cooney & Connekt Media
12
  */
@@ -32,59 +32,59 @@ register_activation_hook( __FILE__, 'instant_images_activate' );
32
 
33
 
34
 
35
- class InstantImages {
36
-
37
- function __construct() {
38
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'instant_images_add_action_links') );
39
- load_plugin_textdomain( 'instant-images', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); // load text domain
40
- $this->includes();
41
- $this->constants();
42
  }
43
-
44
-
45
-
46
  /*
47
  * includes
48
  * Include these files in the admin
49
  *
50
  * @since 2.0
51
  */
52
-
53
  private function includes(){
54
  if( is_admin()){
55
  include_once('admin/admin.php');
56
  include_once('admin/functions.php');
57
  include_once('admin/includes/settings.php');
58
- }
59
- }
60
-
61
-
62
-
63
  /*
64
  * constants
65
  * Include these files in the admin
66
  *
67
  * @since 2.0
68
  */
69
-
70
- private function constants(){
71
- define('INSTANT_IMG_VERSION', '2.0.1');
72
- define('INSTANT_IMG_RELEASE', 'January 12, 2017');
73
  define('INSTANT_IMG_TITLE', 'Instant Images');
74
  $upload_dir = wp_upload_dir();
75
  define('INSTANT_IMG_UPLOAD_PATH', $upload_dir['basedir'].'/instant-images');
76
  define('INSTANT_IMG_UPLOAD_URL', $upload_dir['baseurl'].'/instant-images/');
77
  define('INSTANT_IMG_PATH', plugin_dir_path(__FILE__));
78
- define('INSTANT_IMG_ADMIN_URL', plugins_url('admin/', __FILE__));
79
  define('INSTANT_IMG_WPADMIN_URL', admin_url( 'upload.php?page=instant-images' ));
80
  define('INSTANT_IMG_HELP_URL', 'https://connekthq.com/plugins/instant-images/api-access/');
81
- define('INSTANT_IMG_NAME', 'instant-images');
82
  define('INSTANT_IMG_DEFAULT_APP_ID', '5746b12f75e91c251bddf6f83bd2ad0d658122676e9bd2444e110951f9a04af8');
83
- define('INSTANT_IMG_WARNING', '100');
84
- }
85
-
86
-
87
-
88
  /*
89
  * instant_images_add_action_links
90
  * Add custom links to plugins.php
@@ -92,13 +92,13 @@ class InstantImages {
92
  * @since 2.0
93
  */
94
  function instant_images_add_action_links ( $links ) {
95
-
96
  $mylinks = array(
97
  '<a href="' . INSTANT_IMG_WPADMIN_URL . '">Upload Photos</a>',
98
  );
99
  return array_merge( $mylinks, $links );
100
- }
101
-
102
  }
103
 
104
 
@@ -111,12 +111,12 @@ class InstantImages {
111
  */
112
 
113
  function InstantImages(){
114
- global $InstantImages;
115
  if( !isset($InstantImages)){
116
  $InstantImages = new InstantImages();
117
- }
118
  return $InstantImages;
119
- }
120
  // initialize
121
  InstantImages();
122
 
6
  Author: Darren Cooney
7
  Twitter: @connekthq
8
  Author URI: https://connekthq.com
9
+ Version: 2.1
10
  License: GPL
11
  Copyright: Darren Cooney & Connekt Media
12
  */
32
 
33
 
34
 
35
+ class InstantImages {
36
+
37
+ function __construct() {
38
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'instant_images_add_action_links') );
39
+ load_plugin_textdomain( 'instant-images', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); // load text domain
40
+ $this->includes();
41
+ $this->constants();
42
  }
43
+
44
+
45
+
46
  /*
47
  * includes
48
  * Include these files in the admin
49
  *
50
  * @since 2.0
51
  */
52
+
53
  private function includes(){
54
  if( is_admin()){
55
  include_once('admin/admin.php');
56
  include_once('admin/functions.php');
57
  include_once('admin/includes/settings.php');
58
+ }
59
+ }
60
+
61
+
62
+
63
  /*
64
  * constants
65
  * Include these files in the admin
66
  *
67
  * @since 2.0
68
  */
69
+
70
+ private function constants(){
71
+ define('INSTANT_IMG_VERSION', '2.1');
72
+ define('INSTANT_IMG_RELEASE', 'May 12, 2017');
73
  define('INSTANT_IMG_TITLE', 'Instant Images');
74
  $upload_dir = wp_upload_dir();
75
  define('INSTANT_IMG_UPLOAD_PATH', $upload_dir['basedir'].'/instant-images');
76
  define('INSTANT_IMG_UPLOAD_URL', $upload_dir['baseurl'].'/instant-images/');
77
  define('INSTANT_IMG_PATH', plugin_dir_path(__FILE__));
78
+ define('INSTANT_IMG_ADMIN_URL', plugins_url('admin/', __FILE__));
79
  define('INSTANT_IMG_WPADMIN_URL', admin_url( 'upload.php?page=instant-images' ));
80
  define('INSTANT_IMG_HELP_URL', 'https://connekthq.com/plugins/instant-images/api-access/');
81
+ define('INSTANT_IMG_NAME', 'instant-images');
82
  define('INSTANT_IMG_DEFAULT_APP_ID', '5746b12f75e91c251bddf6f83bd2ad0d658122676e9bd2444e110951f9a04af8');
83
+ define('INSTANT_IMG_WARNING', '100');
84
+ }
85
+
86
+
87
+
88
  /*
89
  * instant_images_add_action_links
90
  * Add custom links to plugins.php
92
  * @since 2.0
93
  */
94
  function instant_images_add_action_links ( $links ) {
95
+
96
  $mylinks = array(
97
  '<a href="' . INSTANT_IMG_WPADMIN_URL . '">Upload Photos</a>',
98
  );
99
  return array_merge( $mylinks, $links );
100
+ }
101
+
102
  }
103
 
104
 
111
  */
112
 
113
  function InstantImages(){
114
+ global $InstantImages;
115
  if( !isset($InstantImages)){
116
  $InstantImages = new InstantImages();
117
+ }
118
  return $InstantImages;
119
+ }
120
  // initialize
121
  InstantImages();
122
 
lang/instant-images.pot CHANGED
@@ -1,65 +1,65 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Instant Images\n"
4
- "POT-Creation-Date: 2017-01-12 11:53-0500\n"
5
- "PO-Revision-Date: 2017-01-12 11:53-0500\n"
6
  "Last-Translator: Darren Cooney <dcooney@ecentricarts.com>\n"
7
  "Language-Team: \n"
8
  "Language: en_CA\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.6.4\n"
13
  "X-Poedit-Basepath: .\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
  "X-Poedit-KeywordsList: __;_e\n"
16
  "X-Poedit-SearchPath-0: ..\n"
17
 
18
- #: ../admin/admin.php:26
19
  msgid "Error accessing Unsplash API"
20
  msgstr ""
21
 
22
- #: ../admin/admin.php:27
23
  msgid "Please check your Application ID."
24
  msgstr ""
25
 
26
- #: ../admin/admin.php:28
27
  msgid "Unable to save image, please check your server permissions."
28
  msgstr ""
29
 
30
- #: ../admin/admin.php:29
31
  msgid "Photo by"
32
  msgstr ""
33
 
34
- #: ../admin/admin.php:30
35
  msgid "View all photos by"
36
  msgstr ""
37
 
38
- #: ../admin/admin.php:31
39
  msgid "click to upload"
40
  msgstr ""
41
 
42
- #: ../admin/admin.php:32
43
  msgid "View Full Size"
44
  msgstr ""
45
 
46
- #: ../admin/admin.php:33
47
  msgid "Like(s)"
48
  msgstr ""
49
 
50
- #: ../admin/admin.php:34
51
  msgid "Downloading photo"
52
  msgstr ""
53
 
54
- #: ../admin/admin.php:35
55
  msgid "Resizing photo"
56
  msgstr ""
57
 
58
- #: ../admin/admin.php:36
59
  msgid "Sorry, nothing matched your query"
60
  msgstr ""
61
 
62
- #: ../admin/admin.php:37
63
  msgid "Please try adjusting your search criteria"
64
  msgstr ""
65
 
@@ -96,17 +96,17 @@ msgid ""
96
  "permissions."
97
  msgstr ""
98
 
99
- #: ../admin/includes/cta/permissions.php:12
100
  msgid "Permissions Error"
101
  msgstr ""
102
 
103
- #: ../admin/includes/cta/permissions.php:13
104
  msgid ""
105
  "Instant Images is unable to save downloads to your server. Please enable "
106
  "write access to the following directory"
107
  msgstr ""
108
 
109
- #: ../admin/includes/settings.php:21
110
  msgid "Unsplash Settings"
111
  msgstr ""
112
 
@@ -118,103 +118,79 @@ msgstr ""
118
  msgid "Upload Image Height"
119
  msgstr ""
120
 
121
- #: ../admin/includes/settings.php:47
122
- msgid "Unplash Application ID"
123
- msgstr ""
124
-
125
- #: ../admin/includes/settings.php:64
126
  msgid "Manage your media upload settings"
127
  msgstr ""
128
 
129
- #: ../admin/includes/settings.php:93
130
  msgid "Max Image Upload Width:"
131
  msgstr ""
132
 
133
- #: ../admin/includes/settings.php:112
134
  msgid "Max Image Upload Height:"
135
  msgstr ""
136
 
137
- #: ../admin/includes/settings.php:136
138
- msgid "Unsplash App ID:"
139
- msgstr ""
140
-
141
- #: ../admin/includes/settings.php:136
142
- msgid "What's This?"
143
- msgstr ""
144
-
145
- #: ../admin/includes/warning.php:7
146
- msgid "Did you know"
147
- msgstr ""
148
-
149
- #: ../admin/includes/warning.php:10
150
- msgid "Learn More"
151
- msgstr ""
152
-
153
- #: ../admin/includes/warning.php:11
154
- msgid "No Thanks"
155
- msgstr ""
156
-
157
- #: ../admin/views/unsplash-app.php:19
158
  msgid "Enter Search term"
159
  msgstr ""
160
 
161
- #: ../admin/views/unsplash-app.php:20
162
  msgid "Search for Toronto, Computers, Coffee + Breakfast etc..."
163
  msgstr ""
164
 
165
- #: ../admin/views/unsplash-app.php:21
166
  #, fuzzy
167
  msgid "Search"
168
  msgstr "Recherche"
169
 
170
- #: ../admin/views/unsplash-app.php:26
171
  msgid "Options"
172
  msgstr ""
173
 
174
- #: ../admin/views/unsplash-app.php:28
175
  msgid "Order by:"
176
  msgstr ""
177
 
178
- #: ../admin/views/unsplash-app.php:30 ../admin/views/unsplash-app.php:59
179
  msgid "Newest"
180
  msgstr ""
181
 
182
- #: ../admin/views/unsplash-app.php:31 ../admin/views/unsplash-app.php:60
183
  msgid "Oldest"
184
  msgstr ""
185
 
186
- #: ../admin/views/unsplash-app.php:32 ../admin/views/unsplash-app.php:61
187
  msgid "Most Popular"
188
  msgstr ""
189
 
190
- #: ../admin/views/unsplash-app.php:35
191
  msgid "Note"
192
  msgstr ""
193
 
194
- #: ../admin/views/unsplash-app.php:35
195
  msgid "Ordering is not supported with Unsplash search."
196
  msgstr ""
197
 
198
- #: ../admin/views/unsplash-app.php:54
199
  msgid "Search Unsplash"
200
  msgstr ""
201
 
202
- #: ../admin/views/unsplash-app.php:55
203
  msgid ""
204
  "Enter a search term above to begin searching images from <a href=\"https://"
205
  "unsplash.com\" target=\"_blank\">unsplash.com</a>. You can search for single "
206
  "terms or join terms using the [<i>+</i>] symbol."
207
  msgstr ""
208
 
209
- #: ../admin/views/unsplash-app.php:58
210
  msgid "Not sure what to search for"
211
  msgstr ""
212
 
213
- #: ../admin/views/unsplash-app.php:58
214
  msgid "You can browse Unsplash photos using the options below"
215
  msgstr ""
216
 
217
- #: ../admin/views/unsplash-app.php:74
218
  msgid "Load More Images"
219
  msgstr ""
220
 
@@ -229,11 +205,11 @@ msgstr ""
229
  msgid "Expand"
230
  msgstr ""
231
 
232
- #: ../admin/views/unsplash.php:32
233
  msgid "Save Settings"
234
  msgstr ""
235
 
236
- #: ../admin/views/unsplash.php:47
237
  msgid "Sorry, settings could not be saved."
238
  msgstr ""
239
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Instant Images\n"
4
+ "POT-Creation-Date: 2017-05-12 15:33-0500\n"
5
+ "PO-Revision-Date: 2017-05-12 15:33-0500\n"
6
  "Last-Translator: Darren Cooney <dcooney@ecentricarts.com>\n"
7
  "Language-Team: \n"
8
  "Language: en_CA\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.7\n"
13
  "X-Poedit-Basepath: .\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
  "X-Poedit-KeywordsList: __;_e\n"
16
  "X-Poedit-SearchPath-0: ..\n"
17
 
18
+ #: ../admin/admin.php:27
19
  msgid "Error accessing Unsplash API"
20
  msgstr ""
21
 
22
+ #: ../admin/admin.php:28
23
  msgid "Please check your Application ID."
24
  msgstr ""
25
 
26
+ #: ../admin/admin.php:29
27
  msgid "Unable to save image, please check your server permissions."
28
  msgstr ""
29
 
30
+ #: ../admin/admin.php:30
31
  msgid "Photo by"
32
  msgstr ""
33
 
34
+ #: ../admin/admin.php:31
35
  msgid "View all photos by"
36
  msgstr ""
37
 
38
+ #: ../admin/admin.php:32
39
  msgid "click to upload"
40
  msgstr ""
41
 
42
+ #: ../admin/admin.php:33
43
  msgid "View Full Size"
44
  msgstr ""
45
 
46
+ #: ../admin/admin.php:34
47
  msgid "Like(s)"
48
  msgstr ""
49
 
50
+ #: ../admin/admin.php:35
51
  msgid "Downloading photo"
52
  msgstr ""
53
 
54
+ #: ../admin/admin.php:36
55
  msgid "Resizing photo"
56
  msgstr ""
57
 
58
+ #: ../admin/admin.php:37
59
  msgid "Sorry, nothing matched your query"
60
  msgstr ""
61
 
62
+ #: ../admin/admin.php:38
63
  msgid "Please try adjusting your search criteria"
64
  msgstr ""
65
 
96
  "permissions."
97
  msgstr ""
98
 
99
+ #: ../admin/includes/cta/permissions.php:13
100
  msgid "Permissions Error"
101
  msgstr ""
102
 
103
+ #: ../admin/includes/cta/permissions.php:14
104
  msgid ""
105
  "Instant Images is unable to save downloads to your server. Please enable "
106
  "write access to the following directory"
107
  msgstr ""
108
 
109
+ #: ../admin/includes/settings.php:21 ../admin/views/unsplash.php:24
110
  msgid "Unsplash Settings"
111
  msgstr ""
112
 
118
  msgid "Upload Image Height"
119
  msgstr ""
120
 
121
+ #: ../admin/includes/settings.php:55 ../admin/views/unsplash.php:25
 
 
 
 
122
  msgid "Manage your media upload settings"
123
  msgstr ""
124
 
125
+ #: ../admin/includes/settings.php:84
126
  msgid "Max Image Upload Width:"
127
  msgstr ""
128
 
129
+ #: ../admin/includes/settings.php:103
130
  msgid "Max Image Upload Height:"
131
  msgstr ""
132
 
133
+ #: ../admin/views/unsplash-app.php:8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  msgid "Enter Search term"
135
  msgstr ""
136
 
137
+ #: ../admin/views/unsplash-app.php:9
138
  msgid "Search for Toronto, Computers, Coffee + Breakfast etc..."
139
  msgstr ""
140
 
141
+ #: ../admin/views/unsplash-app.php:10
142
  #, fuzzy
143
  msgid "Search"
144
  msgstr "Recherche"
145
 
146
+ #: ../admin/views/unsplash-app.php:15
147
  msgid "Options"
148
  msgstr ""
149
 
150
+ #: ../admin/views/unsplash-app.php:17
151
  msgid "Order by:"
152
  msgstr ""
153
 
154
+ #: ../admin/views/unsplash-app.php:19 ../admin/views/unsplash-app.php:39
155
  msgid "Newest"
156
  msgstr ""
157
 
158
+ #: ../admin/views/unsplash-app.php:20 ../admin/views/unsplash-app.php:40
159
  msgid "Oldest"
160
  msgstr ""
161
 
162
+ #: ../admin/views/unsplash-app.php:21 ../admin/views/unsplash-app.php:41
163
  msgid "Most Popular"
164
  msgstr ""
165
 
166
+ #: ../admin/views/unsplash-app.php:24
167
  msgid "Note"
168
  msgstr ""
169
 
170
+ #: ../admin/views/unsplash-app.php:24
171
  msgid "Ordering is not supported with Unsplash search."
172
  msgstr ""
173
 
174
+ #: ../admin/views/unsplash-app.php:34
175
  msgid "Search Unsplash"
176
  msgstr ""
177
 
178
+ #: ../admin/views/unsplash-app.php:35
179
  msgid ""
180
  "Enter a search term above to begin searching images from <a href=\"https://"
181
  "unsplash.com\" target=\"_blank\">unsplash.com</a>. You can search for single "
182
  "terms or join terms using the [<i>+</i>] symbol."
183
  msgstr ""
184
 
185
+ #: ../admin/views/unsplash-app.php:38
186
  msgid "Not sure what to search for"
187
  msgstr ""
188
 
189
+ #: ../admin/views/unsplash-app.php:38
190
  msgid "You can browse Unsplash photos using the options below"
191
  msgstr ""
192
 
193
+ #: ../admin/views/unsplash-app.php:53
194
  msgid "Load More Images"
195
  msgstr ""
196
 
205
  msgid "Expand"
206
  msgstr ""
207
 
208
+ #: ../admin/views/unsplash.php:37
209
  msgid "Save Settings"
210
  msgstr ""
211
 
212
+ #: ../admin/views/unsplash.php:52
213
  msgid "Sorry, settings could not be saved."
214
  msgstr ""
215