Featured Image From URL - Version 2.2.7

Version Description

  • Improvement: block UI added to the menu settings.
Download this release

Release Info

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

Code changes from version 2.2.6 to 2.2.7

admin/db.php CHANGED
@@ -39,7 +39,7 @@ class FifuDb {
39
  );
40
  }
41
 
42
- /* attachment meta data */
43
 
44
  // insert 1 _wp_attached_file for each attachment
45
  function insert_attachment_meta_url($ids) {
@@ -189,6 +189,7 @@ class FifuDb {
189
  );
190
  }
191
 
 
192
  function get_attachments_without_post($post_id) {
193
  $result = $this->wpdb->get_results("
194
  SELECT GROUP_CONCAT(id) AS ids
@@ -208,6 +209,16 @@ class FifuDb {
208
  return $result ? $result[0]->ids : null;
209
  }
210
 
 
 
 
 
 
 
 
 
 
 
211
  function get_ctgr_attachments_without_post($term_id) {
212
  $result = $this->wpdb->get_results("
213
  SELECT GROUP_CONCAT(id) AS ids
@@ -242,6 +253,15 @@ class FifuDb {
242
  );
243
  }
244
 
 
 
 
 
 
 
 
 
 
245
  function get_category_image_url($term_id) {
246
  return $this->wpdb->get_results("
247
  SELECT meta_value
@@ -267,7 +287,7 @@ class FifuDb {
267
  );
268
  }
269
 
270
- // clean meta data
271
 
272
  function delete_thumbnail_ids($ids) {
273
  $this->wpdb->get_results("
@@ -393,6 +413,28 @@ class FifuDb {
393
  );
394
  }
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  /* insert attachment */
397
 
398
  function insert_attachment_by($value) {
@@ -643,6 +685,46 @@ class FifuDb {
643
  }
644
  }
645
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
646
  }
647
 
648
  /* fake internal featured image */
@@ -672,6 +754,13 @@ function fifu_db_change_url_length() {
672
  $db->change_url_length();
673
  }
674
 
 
 
 
 
 
 
 
675
  /* save post */
676
 
677
  function fifu_db_update_fake_attach_id($post_id) {
@@ -715,3 +804,22 @@ function fifu_db_before_delete_post($post_id) {
715
  $db->before_delete_post($post_id);
716
  }
717
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  );
40
  }
41
 
42
+ /* attachment metadata */
43
 
44
  // insert 1 _wp_attached_file for each attachment
45
  function insert_attachment_meta_url($ids) {
189
  );
190
  }
191
 
192
+ // get attachments without post
193
  function get_attachments_without_post($post_id) {
194
  $result = $this->wpdb->get_results("
195
  SELECT GROUP_CONCAT(id) AS ids
209
  return $result ? $result[0]->ids : null;
210
  }
211
 
212
+ function get_posts_with_valid_url() {
213
+ return $this->wpdb->get_results("
214
+ SELECT post_id
215
+ FROM " . $this->postmeta . "
216
+ WHERE meta_key = 'fifu_image_url'
217
+ AND meta_value IS NOT NULL
218
+ AND meta_value <> ''"
219
+ );
220
+ }
221
+
222
  function get_ctgr_attachments_without_post($term_id) {
223
  $result = $this->wpdb->get_results("
224
  SELECT GROUP_CONCAT(id) AS ids
253
  );
254
  }
255
 
256
+ function get_number_of_posts() {
257
+ return $this->wpdb->get_row("
258
+ SELECT count(1) AS n
259
+ FROM " . $this->posts . "
260
+ WHERE post_type IN ('$this->types')
261
+ AND post_status = 'publish'"
262
+ )->n;
263
+ }
264
+
265
  function get_category_image_url($term_id) {
266
  return $this->wpdb->get_results("
267
  SELECT meta_value
287
  );
288
  }
289
 
290
+ // clean metadata
291
 
292
  function delete_thumbnail_ids($ids) {
293
  $this->wpdb->get_results("
413
  );
414
  }
415
 
416
+ function delete_metadata() {
417
+ $fake_attach_id = get_option('fifu_fake_attach_id');
418
+ $default_attach_id = get_option('fifu_default_attach_id');
419
+ $value = '-1';
420
+ $value = $fake_attach_id ? $value . ',' . $fake_attach_id : $value;
421
+ $value = $default_attach_id ? $value . ',' . $default_attach_id : $value;
422
+ $this->wpdb->get_results("
423
+ DELETE FROM " . $this->postmeta . "
424
+ WHERE meta_key IN ('_thumbnail_id', '_product_image_gallery')
425
+ AND meta_value IN (" . $value . ")"
426
+ );
427
+ $this->wpdb->get_results("
428
+ DELETE FROM " . $this->postmeta . "
429
+ WHERE meta_key = '_wp_attached_file'
430
+ AND meta_value IN ('Featured Image from URL', 'fifu.png')"
431
+ );
432
+ $this->wpdb->get_results("
433
+ DELETE FROM " . $this->posts . "
434
+ WHERE guid = 'http://fifu.png'"
435
+ );
436
+ }
437
+
438
  /* insert attachment */
439
 
440
  function insert_attachment_by($value) {
685
  }
686
  }
687
 
688
+ /* clean metadata */
689
+
690
+ function enable_clean() {
691
+ $this->delete_metadata();
692
+ wp_delete_attachment(get_option('fifu_fake_attach_id'));
693
+ wp_delete_attachment(get_option('fifu_default_attach_id'));
694
+ delete_option('fifu_fake_attach_id');
695
+ fifu_disable_fake();
696
+ fifu_disable_fake2();
697
+ update_option('fifu_fake', 'toggleoff', 'no');
698
+ update_option('fifu_fake2', 'toggleoff', 'no');
699
+ update_option('fifu_fake_created', false, 'no');
700
+ }
701
+
702
+ /* fake internal featured image 1 */
703
+
704
+ function enable_fake1() {
705
+ $old_attach_id = get_option('fifu_fake_attach_id');
706
+ $value = $this->get_formatted_value('Featured Image from URL', null, 0);
707
+ $this->insert_attachment_by($value);
708
+ $att_id = $this->wpdb->insert_id;
709
+
710
+ update_post_meta($att_id, '_wp_attached_file', ';');
711
+ update_option('fifu_fake_attach_id', $att_id);
712
+
713
+ foreach ($this->get_posts_without_meta() as $i)
714
+ $this->wpdb->insert($this->postmeta, array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $att_id));
715
+
716
+ $this->wpdb->update($this->postmeta, array('meta_value' => $att_id), array('meta_key' => '_thumbnail_id', 'meta_value' => $old_attach_id), null, null);
717
+
718
+ foreach ($this->get_posts_with_valid_url() as $i)
719
+ $this->wpdb->update($this->postmeta, array('meta_value' => $att_id), array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => -1), null, null);
720
+ }
721
+
722
+ function disable_fake1() {
723
+ $this->wpdb->delete($this->postmeta, array('meta_key' => '_thumbnail_id', 'meta_value' => get_option('fifu_fake_attach_id')));
724
+ wp_delete_attachment(get_option('fifu_fake_attach_id'));
725
+ delete_option('fifu_fake_attach_id');
726
+ }
727
+
728
  }
729
 
730
  /* fake internal featured image */
754
  $db->change_url_length();
755
  }
756
 
757
+ /* clean metadata */
758
+
759
+ function fifu_db_enable_clean() {
760
+ $db = new FifuDb();
761
+ $db->enable_clean();
762
+ }
763
+
764
  /* save post */
765
 
766
  function fifu_db_update_fake_attach_id($post_id) {
804
  $db->before_delete_post($post_id);
805
  }
806
 
807
+ /* number of posts */
808
+
809
+ function fifu_db_number_of_posts() {
810
+ $db = new FifuDb();
811
+ return $db->get_number_of_posts();
812
+ }
813
+
814
+ /* fake internal featured image 1 */
815
+
816
+ function fifu_db_enable_fake1() {
817
+ $db = new FifuDb();
818
+ return $db->enable_fake1();
819
+ }
820
+
821
+ function fifu_db_disable_fake1() {
822
+ $db = new FifuDb();
823
+ return $db->disable_fake1();
824
+ }
825
+
admin/html/css/menu.css CHANGED
@@ -1,12 +1,6 @@
1
  .wrap {
2
  max-width: 1000px;
3
  margin: 20px 20px 20px 15px;
4
-
5
- display: block;
6
- -webkit-animation: fadeInFromNone 0.5s step-end;
7
- -moz-animation: fadeInFromNone 0.5s step-end;
8
- -o-animation: fadeInFromNone 0.5s step-end;
9
- animation: fadeInFromNone 0.5s step-end;
10
  }
11
 
12
  .header-box {
@@ -71,72 +65,4 @@ th {
71
  #grad2 {
72
  border: 1px dashed red;
73
  border-radius: 1px;
74
- }
75
-
76
- @-webkit-keyframes fadeInFromNone {
77
- 0% {
78
- display: none;
79
- opacity: 0;
80
- }
81
-
82
- 1% {
83
- display: block;
84
- opacity: 0;
85
- }
86
-
87
- 100% {
88
- display: block;
89
- opacity: 1;
90
- }
91
- }
92
-
93
- @-moz-keyframes fadeInFromNone {
94
- 0% {
95
- display: none;
96
- opacity: 0;
97
- }
98
-
99
- 1% {
100
- display: block;
101
- opacity: 0;
102
- }
103
-
104
- 100% {
105
- display: block;
106
- opacity: 1;
107
- }
108
- }
109
-
110
- @-o-keyframes fadeInFromNone {
111
- 0% {
112
- display: none;
113
- opacity: 0;
114
- }
115
-
116
- 1% {
117
- display: block;
118
- opacity: 0;
119
- }
120
-
121
- 100% {
122
- display: block;
123
- opacity: 1;
124
- }
125
- }
126
-
127
- @keyframes fadeInFromNone {
128
- 0% {
129
- display: none;
130
- opacity: 0;
131
- }
132
-
133
- 1% {
134
- display: block;
135
- opacity: 0;
136
- }
137
-
138
- 100% {
139
- display: block;
140
- opacity: 1;
141
- }
142
- }
1
  .wrap {
2
  max-width: 1000px;
3
  margin: 20px 20px 20px 15px;
 
 
 
 
 
 
4
  }
5
 
6
  .header-box {
65
  #grad2 {
66
  border: 1px dashed red;
67
  border-radius: 1px;
68
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/html/js/menu.js CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  function invert(id) {
2
  if (jQuery("#fifu_toggle_" + id).attr("class") == "toggleon") {
3
  jQuery("#fifu_toggle_" + id).attr("class", "toggleoff");
1
+ jQuery(document).ready(function () {
2
+ jQuery('.wrap').css('opacity', 1);
3
+ });
4
+
5
  function invert(id) {
6
  if (jQuery("#fifu_toggle_" + id).attr("class") == "toggleon") {
7
  jQuery("#fifu_toggle_" + id).attr("class", "toggleoff");
admin/html/menu.html CHANGED
@@ -1,4 +1,4 @@
1
- <div class="wrap">
2
 
3
  <div class="header-box" style="background-color:#23282d">
4
  <h1 style="color:white"><img src="http://localhost/wp-content/plugins/featured-image-from-url/admin/images/favicon.png" alt=""> <b>Featured Image from URL</b> 2</h1>
@@ -8,11 +8,10 @@
8
  <ul>
9
  <li><a href="#tabs-d">Help</a></li>
10
  <li><a href="#tabs-k">Admin Area</a></li>
11
- <li><a href="#tabs-b">Auto Set</a></li>
12
  <li><a href="#tabs-g">Featured Image</a></li>
13
  <li><a href="#tabs-j">Metadata</a></li>
14
  <li><a href="#tabs-i">Performance</a></li>
15
- <li><a href="#tabs-f">Product Category</a></li>
16
  <li><a href="#tabs-q">REST API</a></li>
17
  <li><a href="#tabs-l">Shortcode</a></li>
18
  <li><a href="#tabs-m">Slider</a></li>
@@ -773,7 +772,12 @@
773
  type="image"
774
  href="javascript:void(0)"
775
  id="fifu_toggle_fake2"
776
- onclick="invert('fake2')"
 
 
 
 
 
777
  name="fifu_toggle_fake2"
778
  class="<?php echo $enable_fake2; ?>"
779
  value=""
@@ -799,7 +803,7 @@
799
 
800
  <div class="box">
801
 
802
- <h2>Clean meta data</h2>
803
 
804
  <div class="greybox">
805
 
@@ -810,7 +814,7 @@
810
  <br>
811
 
812
  <div id="accordionClean">
813
- <h3>&nbsp;&nbsp;&nbsp;clean meta data</h3>
814
  <div>
815
  <form
816
  id="fifu_form_data_clean"
@@ -820,7 +824,13 @@
820
  type="image"
821
  href="javascript:void(0)"
822
  id="fifu_toggle_data_clean"
823
- onclick="invert('data_clean')"
 
 
 
 
 
 
824
  name="fifu_toggle_data_clean"
825
  class="<?php echo $enable_data_clean; ?>"
826
  value=""
@@ -834,7 +844,7 @@
834
  </form>
835
  </div>
836
 
837
- <h3>&nbsp;&nbsp;&nbsp;meta data generation</h3>
838
  <div>
839
  <form
840
  id="fifu_form_data_generation"
@@ -860,69 +870,6 @@
860
  </div>
861
  </div>
862
  </div>
863
- <div id="tabs-f">
864
- <a name="category"></a>
865
- <div class="box">
866
- <h2>Auto Set Product Category Images</h2>
867
- <div class="greybox" id="grad2">
868
- <b>Premium feature</b><br><br>
869
- Enable the toggle below to set one external image to each product category. The image will be the external featured image from the most recent product from that category.
870
- </div>
871
- <br>
872
- <table style="text-align:left">
873
- <tr>
874
- <th>
875
- <input
876
- type="image"
877
- href="javascript:void(0)"
878
- class="toggleoff"
879
- value=""
880
- style="display:block">
881
- </th>
882
- <th>
883
- set category images
884
- </th>
885
- </tr>
886
- </table>
887
- </div>
888
-
889
- <div class="box">
890
- <h2>Category Image on Product Grid</h2>
891
- <div class="greybox">
892
- That's possible to show the external featured image of your category on category page, immediately before the product grid. To do that, enable the toggle below.
893
- </div>
894
- <br>
895
- <table style="text-align:left">
896
- <tr>
897
- <th>
898
- <form
899
- id="fifu_form_grid_category"
900
- action="javascript:void(0)"
901
- method="post">
902
- <input
903
- type="image"
904
- href="javascript:void(0)"
905
- id="fifu_toggle_grid_category"
906
- onclick="invert('grid_category')"
907
- name="fifu_toggle_grid_category"
908
- class="<?php echo $enable_grid_category; ?>"
909
- value=""
910
- style="display:block">
911
-
912
- <input
913
- type="hidden"
914
- id="fifu_input_grid_category"
915
- name="fifu_input_grid_category"
916
- value="" >
917
- </form>
918
- </th>
919
- <th>
920
- show category image on product grid
921
- </th>
922
- </tr>
923
- </table>
924
- </div>
925
- </div>
926
  <div id="tabs-l">
927
  <div class="box">
928
 
@@ -1784,6 +1731,68 @@
1784
  </table>
1785
  </div>
1786
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1787
  <a name="variable"></a>
1788
 
1789
  <div class="box">
1
+ <div class="wrap" style="opacity:0">
2
 
3
  <div class="header-box" style="background-color:#23282d">
4
  <h1 style="color:white"><img src="http://localhost/wp-content/plugins/featured-image-from-url/admin/images/favicon.png" alt=""> <b>Featured Image from URL</b> 2</h1>
8
  <ul>
9
  <li><a href="#tabs-d">Help</a></li>
10
  <li><a href="#tabs-k">Admin Area</a></li>
11
+ <li><a href="#tabs-b">Auto Set First Image</a></li>
12
  <li><a href="#tabs-g">Featured Image</a></li>
13
  <li><a href="#tabs-j">Metadata</a></li>
14
  <li><a href="#tabs-i">Performance</a></li>
 
15
  <li><a href="#tabs-q">REST API</a></li>
16
  <li><a href="#tabs-l">Shortcode</a></li>
17
  <li><a href="#tabs-m">Slider</a></li>
772
  type="image"
773
  href="javascript:void(0)"
774
  id="fifu_toggle_fake2"
775
+ onclick="invert('fake2');
776
+ time = '<?php echo fifu_db_number_of_posts();?>' / 2;
777
+ jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
778
+ setTimeout(function () {
779
+ jQuery('.wrap').unblock();
780
+ }, time > 10000 ? time : 5000);";
781
  name="fifu_toggle_fake2"
782
  class="<?php echo $enable_fake2; ?>"
783
  value=""
803
 
804
  <div class="box">
805
 
806
+ <h2>Clean metadata</h2>
807
 
808
  <div class="greybox">
809
 
814
  <br>
815
 
816
  <div id="accordionClean">
817
+ <h3>&nbsp;&nbsp;&nbsp;clean metadata</h3>
818
  <div>
819
  <form
820
  id="fifu_form_data_clean"
824
  type="image"
825
  href="javascript:void(0)"
826
  id="fifu_toggle_data_clean"
827
+ onclick="invert('data_clean');
828
+ time = '<?php echo fifu_db_number_of_posts();?>' / 2;
829
+ jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
830
+ setTimeout(function () {
831
+ window.location.href = '#tabs-j';
832
+ location.reload();
833
+ }, time > 10000 ? time : 5000);";
834
  name="fifu_toggle_data_clean"
835
  class="<?php echo $enable_data_clean; ?>"
836
  value=""
844
  </form>
845
  </div>
846
 
847
+ <h3>&nbsp;&nbsp;&nbsp;metadata generation</h3>
848
  <div>
849
  <form
850
  id="fifu_form_data_generation"
870
  </div>
871
  </div>
872
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
873
  <div id="tabs-l">
874
  <div class="box">
875
 
1731
  </table>
1732
  </div>
1733
 
1734
+ <a name="category"></a>
1735
+ <div class="box">
1736
+ <h2>Auto Set Product Category Images</h2>
1737
+ <div class="greybox" id="grad2">
1738
+ <b>Premium feature</b><br><br>
1739
+ Enable the toggle below to set one external image to each product category. The image will be the external featured image from the most recent product from that category.
1740
+ </div>
1741
+ <br>
1742
+ <table style="text-align:left">
1743
+ <tr>
1744
+ <th>
1745
+ <input
1746
+ type="image"
1747
+ href="javascript:void(0)"
1748
+ class="toggleoff"
1749
+ value=""
1750
+ style="display:block">
1751
+ </th>
1752
+ <th>
1753
+ set category images
1754
+ </th>
1755
+ </tr>
1756
+ </table>
1757
+ </div>
1758
+
1759
+ <div class="box">
1760
+ <h2>Category Image on Product Grid</h2>
1761
+ <div class="greybox">
1762
+ That's possible to show the external featured image of your category on category page, immediately before the product grid. To do that, enable the toggle below.
1763
+ </div>
1764
+ <br>
1765
+ <table style="text-align:left">
1766
+ <tr>
1767
+ <th>
1768
+ <form
1769
+ id="fifu_form_grid_category"
1770
+ action="javascript:void(0)"
1771
+ method="post">
1772
+ <input
1773
+ type="image"
1774
+ href="javascript:void(0)"
1775
+ id="fifu_toggle_grid_category"
1776
+ onclick="invert('grid_category')"
1777
+ name="fifu_toggle_grid_category"
1778
+ class="<?php echo $enable_grid_category; ?>"
1779
+ value=""
1780
+ style="display:block">
1781
+
1782
+ <input
1783
+ type="hidden"
1784
+ id="fifu_input_grid_category"
1785
+ name="fifu_input_grid_category"
1786
+ value="" >
1787
+ </form>
1788
+ </th>
1789
+ <th>
1790
+ show category image on product grid
1791
+ </th>
1792
+ </tr>
1793
+ </table>
1794
+ </div>
1795
+
1796
  <a name="variable"></a>
1797
 
1798
  <div class="box">
admin/menu.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  add_action('admin_menu', 'fifu_insert_menu');
4
 
5
  function fifu_insert_menu() {
@@ -7,6 +9,7 @@ function fifu_insert_menu() {
7
  wp_enqueue_style('jquery-css', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.min.css');
8
  wp_enqueue_script('jquery-ui', 'https://code.jquery.com/ui/1.11.4/jquery-ui.min.js');
9
  wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-1.11.3.min.js');
 
10
 
11
  add_menu_page('Featured Image from URL', 'Featured Image from URL', 'administrator', 'featured-image-from-url', 'fifu_get_menu_html', plugins_url() . '/featured-image-from-url/admin/images/favicon.png', 57);
12
 
@@ -49,13 +52,14 @@ function fifu_get_menu_html() {
49
 
50
  fifu_update_menu_options();
51
 
 
52
  if (fifu_is_on('fifu_fake')) {
53
  update_option('fifu_data_generation', 'toggleon');
54
  fifu_enable_fake();
55
- } else {
56
  fifu_disable_fake();
57
- }
58
 
 
59
  if (fifu_is_on('fifu_fake2')) {
60
  update_option('fifu_data_generation', 'toggleoff');
61
  fifu_enable_fake2();
@@ -64,6 +68,7 @@ function fifu_get_menu_html() {
64
  } else
65
  update_option('fifu_fake_created', null, 'no');
66
 
 
67
  if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake2')) {
68
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
69
  $att_id = fifu_db_create_attachment($default_url);
@@ -74,37 +79,16 @@ function fifu_get_menu_html() {
74
  } else
75
  fifu_db_delete_default_url();
76
 
 
77
  if (fifu_is_on('fifu_data_clean')) {
78
- fifu_enable_clean();
79
  update_option('fifu_data_clean', 'toggleoff', 'no');
80
  }
81
  }
82
 
83
  function fifu_get_menu_settings() {
84
- fifu_get_setting('fifu_social');
85
- fifu_get_setting('fifu_original');
86
- fifu_get_setting('fifu_lazy');
87
- fifu_get_setting('fifu_content');
88
- fifu_get_setting('fifu_content_page');
89
- fifu_get_setting('fifu_enable_default_url');
90
- fifu_get_setting('fifu_fake');
91
- fifu_get_setting('fifu_fake2');
92
- fifu_get_setting('fifu_css');
93
- fifu_get_setting('fifu_default_url');
94
- fifu_get_setting('fifu_default_width');
95
- fifu_get_setting('fifu_wc_lbox');
96
- fifu_get_setting('fifu_wc_zoom');
97
- fifu_get_setting('fifu_hide_page');
98
- fifu_get_setting('fifu_hide_post');
99
- fifu_get_setting('fifu_get_first');
100
- fifu_get_setting('fifu_pop_first');
101
- fifu_get_setting('fifu_ovw_first');
102
- fifu_get_setting('fifu_column_height');
103
- fifu_get_setting('fifu_priority');
104
- fifu_get_setting('fifu_grid_category');
105
- fifu_get_setting('fifu_auto_alt');
106
- fifu_get_setting('fifu_data_generation');
107
- fifu_get_setting('fifu_data_clean');
108
  }
109
 
110
  function fifu_get_setting($type) {
@@ -177,6 +161,8 @@ function fifu_enable_fake2() {
177
  }
178
 
179
  function fifu_disable_fake2() {
 
 
180
  if (!get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
181
  return;
182
  update_option('fifu_fake_created', false, 'no');
@@ -188,116 +174,11 @@ function fifu_disable_fake2() {
188
  function fifu_enable_fake() {
189
  if (get_option('fifu_fake_attach_id'))
190
  return;
191
-
192
- global $wpdb;
193
- $old_attach_id = get_option('fifu_fake_attach_id');
194
-
195
- // create attachment
196
- $filename = 'Featured Image from URL';
197
- $parent_post_id = null;
198
- $filetype = wp_check_filetype('fifu.png', null);
199
- $attachment = array(
200
- 'guid' => basename($filename),
201
- 'post_mime_type' => $filetype['type'],
202
- 'post_title' => '',
203
- 'post_excerpt' => '',
204
- 'post_content' => 'Please don\'t remove that. It\'s just an empty symbolic file',
205
- 'post_status' => 'inherit'
206
- );
207
- $attach_id = wp_insert_attachment($attachment, $filename, $parent_post_id);
208
- require_once( ABSPATH . 'wp-admin/includes/image.php' );
209
- $attach_data = wp_generate_attachment_metadata($attach_id, $filename);
210
- wp_update_attachment_metadata($attach_id, $attach_data);
211
- update_option('fifu_fake_attach_id', $attach_id);
212
-
213
- // insert _thumbnail_id
214
- $table = $wpdb->prefix . 'postmeta';
215
- $query = "
216
- SELECT DISTINCT post_id
217
- FROM " . $table . " a
218
- WHERE a.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
219
- AND a.meta_value IS NOT NULL
220
- AND a.meta_value <> ''
221
- AND NOT EXISTS (
222
- SELECT 1
223
- FROM " . $table . " c
224
- WHERE a.post_id = c.post_id
225
- AND c.meta_key = '_thumbnail_id'
226
- )";
227
- $result = $wpdb->get_results($query);
228
- foreach ($result as $i) {
229
- $data = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $attach_id);
230
- $wpdb->insert($table, $data);
231
- }
232
-
233
- // update _thumbnail_id
234
- $data = array('meta_value' => $attach_id);
235
- $where = array('meta_key' => '_thumbnail_id', 'meta_value' => $old_attach_id);
236
- $wpdb->update($table, $data, $where, null, null);
237
-
238
- // update _thumbnail_id
239
- $query = "
240
- SELECT post_id
241
- FROM " . $table . " a
242
- WHERE a.meta_key IN ('fifu_image_url', 'fifu_video_url', 'fifu_slider_image_url_0', 'fifu_shortcode')
243
- AND a.meta_value IS NOT NULL
244
- AND a.meta_value <> ''";
245
- $result = $wpdb->get_results($query);
246
- foreach ($result as $i) {
247
- $data = array('meta_value' => $attach_id);
248
- $where = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => -1);
249
- $wpdb->update($table, $data, $where, null, null);
250
- }
251
  }
252
 
253
  function fifu_disable_fake() {
254
- global $wpdb;
255
- $table = $wpdb->prefix . 'postmeta';
256
- $where = array('meta_key' => '_thumbnail_id', 'meta_value' => get_option('fifu_fake_attach_id'));
257
- $wpdb->delete($table, $where);
258
-
259
- wp_delete_attachment(get_option('fifu_fake_attach_id'));
260
- delete_option('fifu_fake_attach_id');
261
- }
262
-
263
- function fifu_enable_clean() {
264
- global $wpdb;
265
-
266
- $table = $wpdb->prefix . 'postmeta';
267
- $table_posts = $wpdb->prefix . 'posts';
268
-
269
- $where = array('meta_key' => '_thumbnail_id', 'meta_value' => -1);
270
- $wpdb->delete($table, $where);
271
-
272
- $where = array('meta_key' => '_thumbnail_id', 'meta_value' => get_option('fifu_fake_attach_id'));
273
- $wpdb->delete($table, $where);
274
-
275
- $where = array('meta_key' => '_thumbnail_id', 'meta_value' => get_option('fifu_default_attach_id'));
276
- $wpdb->delete($table, $where);
277
-
278
- $where = array('meta_key' => '_product_image_gallery', 'meta_value' => -1);
279
- $wpdb->delete($table, $where);
280
-
281
- $where = array('meta_key' => '_product_image_gallery', 'meta_value' => get_option('fifu_fake_attach_id'));
282
- $wpdb->delete($table, $where);
283
-
284
- $where = array('meta_key' => '_wp_attached_file', 'meta_value' => 'Featured Image from URL');
285
- $wpdb->delete($table, $where);
286
-
287
- $where = array('meta_key' => '_wp_attached_file', 'meta_value' => 'fifu.png');
288
- $wpdb->delete($table, $where);
289
-
290
- $where = array('guid' => 'http://fifu.png');
291
- $wpdb->delete($table_posts, $where);
292
-
293
- wp_delete_attachment(get_option('fifu_fake_attach_id'));
294
- wp_delete_attachment(get_option('fifu_default_attach_id'));
295
- delete_option('fifu_fake_attach_id');
296
- fifu_disable_fake();
297
- fifu_disable_fake2();
298
- update_option('fifu_fake', 'toggleoff');
299
- update_option('fifu_fake2', 'toggleoff');
300
- update_option('fifu_fake_created', false, 'no');
301
  }
302
 
303
  function fifu_version() {
1
  <?php
2
 
3
+ define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_original', 'fifu_lazy', 'fifu_content', 'fifu_content_page', 'fifu_enable_default_url', 'fifu_fake', 'fifu_fake2', 'fifu_css', 'fifu_default_url', 'fifu_default_width', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_column_height', 'fifu_priority', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_data_generation', 'fifu_data_clean')));
4
+
5
  add_action('admin_menu', 'fifu_insert_menu');
6
 
7
  function fifu_insert_menu() {
9
  wp_enqueue_style('jquery-css', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.min.css');
10
  wp_enqueue_script('jquery-ui', 'https://code.jquery.com/ui/1.11.4/jquery-ui.min.js');
11
  wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-1.11.3.min.js');
12
+ wp_enqueue_script('jquery-block-ui', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js');
13
 
14
  add_menu_page('Featured Image from URL', 'Featured Image from URL', 'administrator', 'featured-image-from-url', 'fifu_get_menu_html', plugins_url() . '/featured-image-from-url/admin/images/favicon.png', 57);
15
 
52
 
53
  fifu_update_menu_options();
54
 
55
+ // fake 1
56
  if (fifu_is_on('fifu_fake')) {
57
  update_option('fifu_data_generation', 'toggleon');
58
  fifu_enable_fake();
59
+ } else
60
  fifu_disable_fake();
 
61
 
62
+ // fake 2
63
  if (fifu_is_on('fifu_fake2')) {
64
  update_option('fifu_data_generation', 'toggleoff');
65
  fifu_enable_fake2();
68
  } else
69
  update_option('fifu_fake_created', null, 'no');
70
 
71
+ // default
72
  if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake2')) {
73
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
74
  $att_id = fifu_db_create_attachment($default_url);
79
  } else
80
  fifu_db_delete_default_url();
81
 
82
+ // clean
83
  if (fifu_is_on('fifu_data_clean')) {
84
+ fifu_db_enable_clean();
85
  update_option('fifu_data_clean', 'toggleoff', 'no');
86
  }
87
  }
88
 
89
  function fifu_get_menu_settings() {
90
+ foreach (unserialize(FIFU_SETTINGS) as $i)
91
+ fifu_get_setting($i);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
 
94
  function fifu_get_setting($type) {
161
  }
162
 
163
  function fifu_disable_fake2() {
164
+ if (fifu_is_on('fifu_fake'))
165
+ return;
166
  if (!get_option('fifu_fake_created') && get_option('fifu_fake_created') != null)
167
  return;
168
  update_option('fifu_fake_created', false, 'no');
174
  function fifu_enable_fake() {
175
  if (get_option('fifu_fake_attach_id'))
176
  return;
177
+ fifu_db_enable_fake1();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
 
180
  function fifu_disable_fake() {
181
+ fifu_db_disable_fake1();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
 
184
  function fifu_version() {
admin/meta-box.php CHANGED
@@ -85,6 +85,10 @@ function fifu_save_properties($post_id) {
85
  fifu_update_or_delete_alt($post_id, 'fifu_image_alt', $alt);
86
  }
87
 
 
 
 
 
88
  fifu_update_fake_attach_id($post_id);
89
  }
90
 
85
  fifu_update_or_delete_alt($post_id, 'fifu_image_alt', $alt);
86
  }
87
 
88
+ fifu_save($post_id);
89
+ }
90
+
91
+ function fifu_save($post_id) {
92
  fifu_update_fake_attach_id($post_id);
93
  }
94
 
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.2.6
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.2.7
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
readme.txt CHANGED
@@ -157,6 +157,9 @@ Features:
157
 
158
  == Changelog ==
159
 
 
 
 
160
  = 2.2.6 =
161
  * Bug fixes: menu settings, product category and default external image.
162
 
@@ -188,7 +191,7 @@ Features:
188
  * Improvement: WP All Import usage example.
189
 
190
  = 2.1.6 =
191
- * Bug fixes: product category; clean meta data; style issues.
192
 
193
  = 2.1.5 =
194
  * Bug fix: parse error on menu.html; Style issue: Gutemberg + Meta Box; Improvement (Premium): integration with Product Variation + WooCommerce Rest API + Product Image Gallery.
@@ -239,7 +242,7 @@ Features:
239
  * Beta Version (NOT STABLE): a lot of changes were done to overcome some old known issues in FIFU 1, such as problems in image sizes or images that were not shown in some areas, including WooCommerce lightbox and categories. Fake Internal Featured Image and Default External Featured Image features have changed. And Default Width was created.
240
 
241
  = 1.9.13 =
242
- * Improvement: clean meta data feature.
243
 
244
  = 1.9.12 =
245
  * Improvement: 10 fields for Custom Post Types.
@@ -536,7 +539,7 @@ was removed. To finish, a Premium version is now been presented.
536
  * Improvement: WP All Import usage example.
537
 
538
  = 2.1.6 =
539
- * Bug fixes: product category; clean meta data; style issues.
540
 
541
  = 2.1.5 =
542
  * Bug fix: parse error on menu.html; Style issue: Gutemberg + Meta Box; Improvement (Premium): integration with Product Variation + WooCommerce Rest API + Product Image Gallery.
@@ -587,7 +590,7 @@ was removed. To finish, a Premium version is now been presented.
587
  * Beta Version (NOT STABLE): a lot of changes were done to overcome some old known issues in FIFU 1, such as problems in image sizes or images that were not shown in some areas, including WooCommerce lightbox and categories. Fake Internal Featured Image and Default External Featured Image features have changed. And Default Width was created.
588
 
589
  = 1.9.13 =
590
- * Improvement: clean meta data feature.
591
 
592
  = 1.9.12 =
593
  * Improvement: 10 fields for Custom Post Types.
157
 
158
  == Changelog ==
159
 
160
+ = 2.2.7 =
161
+ * Improvement: block UI added to the menu settings.
162
+
163
  = 2.2.6 =
164
  * Bug fixes: menu settings, product category and default external image.
165
 
191
  * Improvement: WP All Import usage example.
192
 
193
  = 2.1.6 =
194
+ * Bug fixes: product category; clean metadata; style issues.
195
 
196
  = 2.1.5 =
197
  * Bug fix: parse error on menu.html; Style issue: Gutemberg + Meta Box; Improvement (Premium): integration with Product Variation + WooCommerce Rest API + Product Image Gallery.
242
  * Beta Version (NOT STABLE): a lot of changes were done to overcome some old known issues in FIFU 1, such as problems in image sizes or images that were not shown in some areas, including WooCommerce lightbox and categories. Fake Internal Featured Image and Default External Featured Image features have changed. And Default Width was created.
243
 
244
  = 1.9.13 =
245
+ * Improvement: clean metadata feature.
246
 
247
  = 1.9.12 =
248
  * Improvement: 10 fields for Custom Post Types.
539
  * Improvement: WP All Import usage example.
540
 
541
  = 2.1.6 =
542
+ * Bug fixes: product category; clean metadata; style issues.
543
 
544
  = 2.1.5 =
545
  * Bug fix: parse error on menu.html; Style issue: Gutemberg + Meta Box; Improvement (Premium): integration with Product Variation + WooCommerce Rest API + Product Image Gallery.
590
  * Beta Version (NOT STABLE): a lot of changes were done to overcome some old known issues in FIFU 1, such as problems in image sizes or images that were not shown in some areas, including WooCommerce lightbox and categories. Fake Internal Featured Image and Default External Featured Image features have changed. And Default Width was created.
591
 
592
  = 1.9.13 =
593
+ * Improvement: clean metadata feature.
594
 
595
  = 1.9.12 =
596
  * Improvement: 10 fields for Custom Post Types.