Featured Image From URL - Version 2.5.6

Version Description

  • Improvements: countdown added to Save Image Dimensions; FAQ added to WP All Import.
Download this release

Release Info

Developer marceljm
Plugin Icon 128x128 Featured Image From URL
Version 2.5.6
Comparing to
See all releases

Code changes from version 2.5.5 to 2.5.6

admin/db.php CHANGED
@@ -192,18 +192,38 @@ class FifuDb {
192
  // get posts without dimensions
193
  function get_posts_without_dimensions() {
194
  return $this->wpdb->get_results("
195
- SELECT *
196
  FROM " . $this->posts . " p
 
197
  WHERE p.post_type = 'attachment'
198
- AND post_author = " . $this->author . "
199
- AND post_status NOT IN ('auto-draft', 'trash')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  AND NOT EXISTS (
201
  SELECT 1
202
  FROM " . $this->postmeta . " pm
203
  WHERE p.id = pm.post_id
204
  AND pm.meta_key IN ('fifu_image_dimension')
205
  )
206
- ORDER BY p.ID"
207
  );
208
  }
209
 
@@ -592,8 +612,6 @@ class FifuDb {
592
 
593
  function save_dimensions_all() {
594
  $value = null;
595
- $i = 1;
596
- $count = 1;
597
  // get all posts or all posts without dimensions
598
  $result = $this->get_posts_without_dimensions();
599
  foreach ($result as $res) {
@@ -602,29 +620,20 @@ class FifuDb {
602
  // set featured image
603
  $url = $res->guid;
604
 
605
- if (!$url) {
606
- $count++;
607
  continue;
608
- }
609
 
610
  // get dimensions
611
  $dimension = fifu_get_dimension_backend($url);
612
 
613
- if (!$dimension) {
614
- $count++;
615
  continue;
616
- }
617
 
618
- $aux = $this->get_formatted_dimension_value($post_id, $dimension);
619
- $value = ($i == 1) ? $aux : ($value . "," . $aux);
620
- if ($value && (($i % $this->MAX_INSERT == 0) || ($i % $this->MAX_INSERT != 0 && count($result) == $count))) {
621
- wp_cache_flush();
622
  $this->insert_dimension_by($value);
623
  $value = null;
624
- $i = 1;
625
- } else
626
- $i++;
627
- $count++;
628
  }
629
  }
630
 
@@ -865,6 +874,14 @@ function fifu_db_clean_dimensions_all() {
865
  return $db->clean_dimensions_all();
866
  }
867
 
 
 
 
 
 
 
 
 
868
  /* clean metadata */
869
 
870
  function fifu_db_enable_clean() {
192
  // get posts without dimensions
193
  function get_posts_without_dimensions() {
194
  return $this->wpdb->get_results("
195
+ SELECT p.*
196
  FROM " . $this->posts . " p
197
+ INNER JOIN " . $this->posts . " parent ON p.post_parent = parent.id AND parent.post_status NOT IN ('auto-draft', 'trash')
198
  WHERE p.post_type = 'attachment'
199
+ AND p.post_author = " . $this->author . "
200
+ AND p.post_status NOT IN ('auto-draft', 'trash')
201
+ AND NOT EXISTS (
202
+ SELECT 1
203
+ FROM " . $this->postmeta . " pm
204
+ WHERE p.id = pm.post_id
205
+ AND pm.meta_key IN ('fifu_image_dimension')
206
+ )
207
+ ORDER BY p.id DESC"
208
+ );
209
+ }
210
+
211
+ // count images without dimensions
212
+ function get_count_posts_without_dimensions() {
213
+ return $this->wpdb->get_results("
214
+ SELECT COUNT(1) AS amount
215
+ FROM " . $this->posts . " p
216
+ INNER JOIN " . $this->posts . " parent ON p.post_parent = parent.id AND parent.post_status NOT IN ('auto-draft', 'trash')
217
+ WHERE p.post_type = 'attachment'
218
+ AND p.post_author = " . $this->author . "
219
+ AND p.post_status NOT IN ('auto-draft', 'trash')
220
  AND NOT EXISTS (
221
  SELECT 1
222
  FROM " . $this->postmeta . " pm
223
  WHERE p.id = pm.post_id
224
  AND pm.meta_key IN ('fifu_image_dimension')
225
  )
226
+ ORDER BY p.id DESC"
227
  );
228
  }
229
 
612
 
613
  function save_dimensions_all() {
614
  $value = null;
 
 
615
  // get all posts or all posts without dimensions
616
  $result = $this->get_posts_without_dimensions();
617
  foreach ($result as $res) {
620
  // set featured image
621
  $url = $res->guid;
622
 
623
+ if (!$url)
 
624
  continue;
 
625
 
626
  // get dimensions
627
  $dimension = fifu_get_dimension_backend($url);
628
 
629
+ if (!$dimension)
 
630
  continue;
 
631
 
632
+ $value = $this->get_formatted_dimension_value($post_id, $dimension);
633
+ if ($value) {
 
 
634
  $this->insert_dimension_by($value);
635
  $value = null;
636
+ }
 
 
 
637
  }
638
  }
639
 
874
  return $db->clean_dimensions_all();
875
  }
876
 
877
+ /* dimensions: amount */
878
+
879
+ function fifu_db_missing_dimensions() {
880
+ $db = new FifuDb();
881
+ $aux = $db->get_count_posts_without_dimensions()[0];
882
+ return $aux ? $aux->amount : -1;
883
+ }
884
+
885
  /* clean metadata */
886
 
887
  function fifu_db_enable_clean() {
admin/html/js/menu.js CHANGED
@@ -69,6 +69,7 @@ jQuery(function () {
69
  });
70
 
71
  jQuery("#opener").on("click", function () {
 
72
  jQuery("#dialog").dialog("open");
73
  });
74
  });
@@ -142,6 +143,10 @@ function fifu_save_dimensions_all_js() {
142
 
143
  jQuery('.wrap').block({message: 'Please wait. It can take several minutes...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
144
 
 
 
 
 
145
  jQuery.ajax({
146
  method: "POST",
147
  url: homeUrl() + '?rest_route=/featured-image-from-url/v2/save_dimensions_all_api/',
@@ -158,6 +163,8 @@ function fifu_save_dimensions_all_js() {
158
  jQuery("#fifu_toggle_save_dimensions_all").attr('class', 'toggleoff');
159
  jQuery('.wrap').unblock();
160
  }, 1000);
 
 
161
  }
162
  });
163
  }
@@ -184,6 +191,7 @@ function fifu_clean_dimensions_all_js() {
184
  jQuery("#fifu_toggle_clean_dimensions_all").attr('class', 'toggleoff');
185
  jQuery('.wrap').unblock();
186
  }, 1000);
 
187
  }
188
  });
189
  }
69
  });
70
 
71
  jQuery("#opener").on("click", function () {
72
+ jQuery("#dialog").load(location.href + " #dialog");
73
  jQuery("#dialog").dialog("open");
74
  });
75
  });
143
 
144
  jQuery('.wrap').block({message: 'Please wait. It can take several minutes...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
145
 
146
+ interval = setInterval(function () {
147
+ jQuery("#countdown").load(location.href + " #countdown");
148
+ }, 3000);
149
+
150
  jQuery.ajax({
151
  method: "POST",
152
  url: homeUrl() + '?rest_route=/featured-image-from-url/v2/save_dimensions_all_api/',
163
  jQuery("#fifu_toggle_save_dimensions_all").attr('class', 'toggleoff');
164
  jQuery('.wrap').unblock();
165
  }, 1000);
166
+ jQuery("#countdown").load(location.href + " #countdown");
167
+ clearInterval(interval);
168
  }
169
  });
170
  }
191
  jQuery("#fifu_toggle_clean_dimensions_all").attr('class', 'toggleoff');
192
  jQuery('.wrap').unblock();
193
  }, 1000);
194
+ jQuery("#countdown").load(location.href + " #countdown");
195
  }
196
  });
197
  }
admin/html/menu.html CHANGED
@@ -51,11 +51,11 @@
51
  <td style="width:20%">
52
  <center>
53
  <div>
54
- <form action="https://bitpay.com/checkout" method="post" >
55
  <input type="hidden" name="action" value="checkout" />
56
  <input type="hidden" name="posData" value="" />
57
- <input type="hidden" name="data" value="Pckctxne2UGVgpP6lkzkpuMUwLjgOobhW3Sv8ita38+NMu0p/Ze7qZ9rLeOZ6dz5kJ+7LE77/T6Su8/Ka5alM6NHO1gFtptBCVhAkkoqQ5p8QX5YzXqP4//nu9S5YYO4INuEJbDgoo74xznf9mTJ0JIK/0YL5l38bnB66Gw7razFAlrZ8BGDS1+gvUENIgK+aIY1bJ8Epf/3UhV4G9RLo/R4LXdF9SIjAvMfsJHFu9c=" />
58
- <input type="image" src="https://bitpay.com/cdn/en_US/bp-btn-pay-currencies.svg" name="submit" style="width:168px;" alt="BitPay, the easy way to pay with bitcoins." >
59
  </form>
60
  </div>
61
  </center>
@@ -1040,6 +1040,9 @@
1040
  <th>
1041
  save the image dimensions of all external featured images now (it shoud take 1-5 seconds by image and requires php-curl installed)
1042
  </th>
 
 
 
1043
  </tr>
1044
  <tr>
1045
  <th>
@@ -2531,6 +2534,7 @@
2531
  <li><a href="#tabs-3">Importing products...</a></li>
2532
  <li><a href="#tabs-1">Custom Fields</a></li>
2533
  <li><a href="#tabs-2">Custom Fields (Premium)</a></li>
 
2534
  </ul>
2535
  <div id="tabs-1">
2536
 
@@ -2631,6 +2635,30 @@
2631
  </table>
2632
  </div>
2633
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2634
  <div id="tabs-3">
2635
  <a href="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/csv.txt">CSV example</a>
2636
  <br>
@@ -2668,6 +2696,8 @@ WordPress:<?php echo get_bloginfo('version') ?>;
2668
  Pages:<?php echo wp_count_posts('page')->publish ?>;
2669
  Posts:<?php echo wp_count_posts('post')->publish ?>;
2670
  Products:<?php echo class_exists('WooCommerce') ? wp_count_posts('product')->publish : null ?>;
 
 
2671
  Plugins:<?php echo fifu_get_plugins_list() ?>;
2672
  Active Plugins:<?php echo fifu_get_active_plugins_list() ?>;
2673
  fifu_auto_alt:<?php echo $enable_auto_alt ?>;
51
  <td style="width:20%">
52
  <center>
53
  <div>
54
+ <form action="https://bitpay.com/checkout" method="post">
55
  <input type="hidden" name="action" value="checkout" />
56
  <input type="hidden" name="posData" value="" />
57
+ <input type="hidden" name="data" value="Pckctxne2UGVgpP6lkzkpuMUwLjgOobhW3Sv8ita38+NMu0p/Ze7qZ9rLeOZ6dz5IkCHcy2ypFLkrN8yTFXtiLNC3aoEqZ5ixFBEcWAxgt4nG1p4bHnIKI77FRXb3tH/2GaF8OCwvRZwL3QudvjdIoZcQtCsN2Gh/sQnrTvb0r8dkWP8YSvh7T5a6Qwcb+kpdBDv/3VPzvlhNT9XkzXtMcHB5WzTgJxVusjKe/OFUnvDwz11IzbojBkNWVWlL7rWGZLIsCxmkaVnDacGM60tvg==" />
58
+ <input type="image" src="https://bitpay.com/cdn/en_US/bp-btn-pay-currencies.svg" name="submit" style="width: 146px" alt="BitPay, the easy way to pay with bitcoins.">
59
  </form>
60
  </div>
61
  </center>
1040
  <th>
1041
  save the image dimensions of all external featured images now (it shoud take 1-5 seconds by image and requires php-curl installed)
1042
  </th>
1043
+ <th>
1044
+ <div id="countdown"><?php echo fifu_db_missing_dimensions() ?></div>
1045
+ </th>
1046
  </tr>
1047
  <tr>
1048
  <th>
2534
  <li><a href="#tabs-3">Importing products...</a></li>
2535
  <li><a href="#tabs-1">Custom Fields</a></li>
2536
  <li><a href="#tabs-2">Custom Fields (Premium)</a></li>
2537
+ <li><a href="#tabs-4">FAQ</a></li>
2538
  </ul>
2539
  <div id="tabs-1">
2540
 
2635
  </table>
2636
  </div>
2637
 
2638
+ <div id="tabs-4">
2639
+
2640
+ <table style="text-align:left">
2641
+ <tr>
2642
+ <th>
2643
+ 1)
2644
+ </th>
2645
+ <th>
2646
+ <a href="http://www.wpallimport.com/documentation/custom-fields/theme-plugin-fields/">How To Import To Your Theme (Or Plugin) - Custom Fields</a>
2647
+ </th>
2648
+ </tr>
2649
+ <tr>
2650
+ <th>
2651
+ 2)
2652
+ </th>
2653
+ <th>
2654
+ <a href="http://www.wpallimport.com/documentation/woocommerce/variable-products/">Importing Variable Products to WooCommerce</a>
2655
+ </th>
2656
+ </tr>
2657
+ </table>
2658
+
2659
+ <br/>
2660
+ </div>
2661
+
2662
  <div id="tabs-3">
2663
  <a href="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/csv.txt">CSV example</a>
2664
  <br>
2696
  Pages:<?php echo wp_count_posts('page')->publish ?>;
2697
  Posts:<?php echo wp_count_posts('post')->publish ?>;
2698
  Products:<?php echo class_exists('WooCommerce') ? wp_count_posts('product')->publish : null ?>;
2699
+ Images without Dimensions:<?php echo fifu_db_missing_dimensions() ?>;
2700
+ php-curl:<?php echo fifu_has_curl() ? 'yes' : 'no' ?>;
2701
  Plugins:<?php echo fifu_get_plugins_list() ?>;
2702
  Active Plugins:<?php echo fifu_get_active_plugins_list() ?>;
2703
  fifu_auto_alt:<?php echo $enable_auto_alt ?>;
admin/html/meta-box.html CHANGED
@@ -61,9 +61,9 @@
61
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid orange; border-top: 2px solid orange; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
62
  background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">Product Gallery, Video and Slider fields are only available in <a href="admin.php?page=featured-image-from-url#tabs-a"><b>premium</b></a> version</p>
63
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #34ba1c; border-top: 2px solid #34ba1c; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
64
- background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: option to show/hide the external images in media library</p>
65
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #538dd3; border-top: 2px solid #538dd3; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
66
- background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: clean image dimensions option</p>
67
- <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #7e600e ; border-top: 2px solid #7e600e ; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
68
- background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: integration with WooCommerce TM Extra Product Options</b></a> plugin</p>
69
  </div>
61
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid orange; border-top: 2px solid orange; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
62
  background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">Product Gallery, Video and Slider fields are only available in <a href="admin.php?page=featured-image-from-url#tabs-a"><b>premium</b></a> version</p>
63
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #34ba1c; border-top: 2px solid #34ba1c; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
64
+ background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: countdown added to "Save Image Dimensions"</p>
65
  <p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #538dd3; border-top: 2px solid #538dd3; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
66
+ background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: FAQ added to "WP All Import"</p>
67
+ <!--p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #7e600e ; border-top: 2px solid #7e600e ; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
68
+ background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: integration with WooCommerce TM Extra Product Options</b></a> plugin</p-->
69
  </div>
admin/menu.php CHANGED
@@ -232,3 +232,7 @@ function fifu_get_active_plugins_list() {
232
  return $list;
233
  }
234
 
 
 
 
 
232
  return $list;
233
  }
234
 
235
+ function fifu_has_curl() {
236
+ return function_exists('curl_version');
237
+ }
238
+
featured-image-from-url.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://featuredimagefromurl.com/
6
  * Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
7
- * Version: 2.5.5
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
4
  * Plugin Name: Featured Image from URL
5
  * Plugin URI: https://featuredimagefromurl.com/
6
  * Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
7
+ * Version: 2.5.6
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
readme.txt CHANGED
@@ -159,6 +159,9 @@ Features:
159
 
160
  == Changelog ==
161
 
 
 
 
162
  = 2.5.5 =
163
  * Improvements: option to show/hide external images in media library; option to clean image dimensions.
164
 
@@ -594,6 +597,9 @@ was removed. To finish, a Premium version is now been presented.
594
 
595
  == Upgrade Notice ==
596
 
 
 
 
597
  = 2.5.5 =
598
  * Improvements: option to show/hide external images in media library; option to clean image dimensions.
599
 
159
 
160
  == Changelog ==
161
 
162
+ = 2.5.6 =
163
+ * Improvements: countdown added to Save Image Dimensions; FAQ added to WP All Import.
164
+
165
  = 2.5.5 =
166
  * Improvements: option to show/hide external images in media library; option to clean image dimensions.
167
 
597
 
598
  == Upgrade Notice ==
599
 
600
+ = 2.5.6 =
601
+ * Improvements: countdown added to Save Image Dimensions; FAQ added to WP All Import.
602
+
603
  = 2.5.5 =
604
  * Improvements: option to show/hide external images in media library; option to clean image dimensions.
605