Featured Image From URL - Version 2.4.2

Version Description

  • Bug fixes: examples of import files; broken favicon; metadata lockscreen; URLs from WordPress sites.
Download this release

Release Info

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

Code changes from version 2.4.1 to 2.4.2

admin/api.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function fifu_enable_fake_api(WP_REST_Request $request) {
4
+ update_option('fifu_data_generation', 'toggleoff');
5
+ fifu_enable_fake2();
6
+ }
7
+
8
+ function fifu_disable_fake_api(WP_REST_Request $request) {
9
+ fifu_disable_fake2();
10
+ }
11
+
12
+ function fifu_none_fake_api(WP_REST_Request $request) {
13
+ update_option('fifu_fake_created', null, 'no');
14
+ }
15
+
16
+ function fifu_data_clean_api(WP_REST_Request $request) {
17
+ fifu_db_enable_clean();
18
+ update_option('fifu_data_clean', 'toggleoff', 'no');
19
+ }
20
+
21
+ add_action('rest_api_init', function () {
22
+ register_rest_route('featured-image-from-url/v2', '/enable_fake_api/', array(
23
+ 'methods' => 'POST',
24
+ 'callback' => 'fifu_enable_fake_api'
25
+ ));
26
+ register_rest_route('featured-image-from-url/v2', '/disable_fake_api/', array(
27
+ 'methods' => 'POST',
28
+ 'callback' => 'fifu_disable_fake_api'
29
+ ));
30
+ register_rest_route('featured-image-from-url/v2', '/none_fake_api/', array(
31
+ 'methods' => 'POST',
32
+ 'callback' => 'fifu_none_fake_api'
33
+ ));
34
+ register_rest_route('featured-image-from-url/v2', '/data_clean_api/', array(
35
+ 'methods' => 'POST',
36
+ 'callback' => 'fifu_data_clean_api'
37
+ ));
38
+ });
39
+
admin/html/js/menu.js CHANGED
@@ -2,6 +2,13 @@ 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");
@@ -64,3 +71,59 @@ jQuery(function () {
64
  jQuery("#dialog").dialog("open");
65
  });
66
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  jQuery('.wrap').css('opacity', 1);
3
  });
4
 
5
+ function homeUrl() {
6
+ var href = window.location.href;
7
+ var index = href.indexOf('/wp-admin');
8
+ var homeUrl = href.substring(0, index);
9
+ return homeUrl;
10
+ }
11
+
12
  function invert(id) {
13
  if (jQuery("#fifu_toggle_" + id).attr("class") == "toggleon") {
14
  jQuery("#fifu_toggle_" + id).attr("class", "toggleoff");
71
  jQuery("#dialog").dialog("open");
72
  });
73
  });
74
+
75
+ function fifu_fake_js() {
76
+ jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
77
+
78
+ toggle = jQuery("#fifu_toggle_fake2").attr('class');
79
+ switch (toggle) {
80
+ case "toggleon":
81
+ option = "enable_fake_api";
82
+ break;
83
+ case "toggleoff":
84
+ option = "disable_fake_api";
85
+ break;
86
+ default:
87
+ option = "none_fake_api";
88
+ }
89
+ jQuery.ajax({
90
+ method: "POST",
91
+ url: homeUrl() + '/wp-json/featured-image-from-url/v2/' + option + '/',
92
+ async: true,
93
+ success: function (data) {
94
+ jQuery('.wrap').unblock();
95
+ },
96
+ error: function (jqXHR, textStatus, errorThrown) {
97
+ jQuery('.wrap').unblock();
98
+ console.log(jqXHR);
99
+ console.log(textStatus);
100
+ console.log(errorThrown);
101
+ }
102
+ });
103
+ }
104
+
105
+ function fifu_clean_js() {
106
+ jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
107
+
108
+ if (jQuery("#fifu_toggle_data_clean").attr('class') != 'toggleon')
109
+ return;
110
+
111
+ jQuery.ajax({
112
+ method: "POST",
113
+ url: homeUrl() + '/wp-json/featured-image-from-url/v2/data_clean_api/',
114
+ async: true,
115
+ success: function (data) {
116
+ jQuery('.wrap').unblock();
117
+ window.location.href = '#tabs-j';
118
+ location.reload();
119
+ },
120
+ error: function (jqXHR, textStatus, errorThrown) {
121
+ jQuery('.wrap').unblock();
122
+ window.location.href = '#tabs-j';
123
+ location.reload();
124
+ console.log(jqXHR);
125
+ console.log(textStatus);
126
+ console.log(errorThrown);
127
+ }
128
+ });
129
+ }
admin/html/menu.html CHANGED
@@ -1,7 +1,7 @@
1
  <div class="wrap" style="opacity:0">
2
 
3
  <div class="header-box" style="background-color:#23282d">
4
- <h1 style="color:white"><img src="/wp-content/plugins/featured-image-from-url/admin/images/favicon.png" alt=""> <b> featured image from url</b> 2</h1>
5
  </div>
6
 
7
  <div id="tabs-top">
@@ -857,11 +857,7 @@
857
  href="javascript:void(0)"
858
  id="fifu_toggle_fake2"
859
  onclick="invert('fake2');
860
- time = '<?php echo fifu_db_number_of_posts();?>' / 2;
861
- jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
862
- setTimeout(function () {
863
- jQuery('.wrap').unblock();
864
- }, time > 10000 ? time : 5000);";
865
  name="fifu_toggle_fake2"
866
  class="<?php echo $enable_fake2; ?>"
867
  value=""
@@ -909,12 +905,7 @@
909
  href="javascript:void(0)"
910
  id="fifu_toggle_data_clean"
911
  onclick="invert('data_clean');
912
- time = '<?php echo fifu_db_number_of_posts();?>' / 2;
913
- jQuery('.wrap').block({message: 'Please wait some seconds...', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
914
- setTimeout(function () {
915
- window.location.href = '#tabs-j';
916
- location.reload();
917
- }, time > 10000 ? time : 5000);";
918
  name="fifu_toggle_data_clean"
919
  class="<?php echo $enable_data_clean; ?>"
920
  value=""
@@ -1857,28 +1848,28 @@
1857
 
1858
  <div id="tabs-3">
1859
 
1860
- <iframe src="../wp-content/plugins/featured-image-from-url/admin/html/txt/product.txt"
1861
  width="800px" height="250px" ></iframe>
1862
 
1863
  </div>
1864
 
1865
  <div id="tabs-4">
1866
 
1867
- <iframe src="../wp-content/plugins/featured-image-from-url/admin/html/txt/product-variation.txt"
1868
  width="800px" height="450px" ></iframe>
1869
 
1870
  </div>
1871
 
1872
  <div id="tabs-5">
1873
 
1874
- <iframe src="../wp-content/plugins/featured-image-from-url/admin/html/txt/post.txt"
1875
  width="800px" height="150px" ></iframe>
1876
 
1877
  </div>
1878
 
1879
  <div id="tabs-6">
1880
 
1881
- <iframe src="../wp-content/plugins/featured-image-from-url/admin/html/txt/product-category.txt"
1882
  width="800px" height="225px" ></iframe>
1883
 
1884
  </div>
@@ -2176,7 +2167,7 @@
2176
  </div>
2177
 
2178
  <div id="tabs-3">
2179
- <a href="../wp-content/plugins/featured-image-from-url/admin/html/txt/csv-woo.txt">CSV example</a>
2180
  <br>
2181
  <br>
2182
  <center><img src="https://c1.staticflickr.com/1/216/31480097476_bf4915184b_o_d.jpg" style="width:90%"></center>
@@ -2299,7 +2290,7 @@
2299
  </div>
2300
 
2301
  <div id="tabs-3">
2302
- <a href="../wp-content/plugins/featured-image-from-url/admin/html/txt/csv.txt">CSV example</a>
2303
  <br>
2304
  <br>
2305
  <img src="https://c1.staticflickr.com/5/4860/44640581850_30311e210a_c_d.jpg" style="width:100%">
1
  <div class="wrap" style="opacity:0">
2
 
3
  <div class="header-box" style="background-color:#23282d">
4
+ <h1 style="color:white"><img src="<?php echo plugins_url()?>/featured-image-from-url/admin/images/favicon.png" alt=""> <b> featured image from url</b> 2</h1>
5
  </div>
6
 
7
  <div id="tabs-top">
857
  href="javascript:void(0)"
858
  id="fifu_toggle_fake2"
859
  onclick="invert('fake2');
860
+ fifu_fake_js();";
 
 
 
 
861
  name="fifu_toggle_fake2"
862
  class="<?php echo $enable_fake2; ?>"
863
  value=""
905
  href="javascript:void(0)"
906
  id="fifu_toggle_data_clean"
907
  onclick="invert('data_clean');
908
+ fifu_clean_js();";
 
 
 
 
 
909
  name="fifu_toggle_data_clean"
910
  class="<?php echo $enable_data_clean; ?>"
911
  value=""
1848
 
1849
  <div id="tabs-3">
1850
 
1851
+ <iframe src="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/product.txt"
1852
  width="800px" height="250px" ></iframe>
1853
 
1854
  </div>
1855
 
1856
  <div id="tabs-4">
1857
 
1858
+ <iframe src="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/product-variation.txt"
1859
  width="800px" height="450px" ></iframe>
1860
 
1861
  </div>
1862
 
1863
  <div id="tabs-5">
1864
 
1865
+ <iframe src="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/post.txt"
1866
  width="800px" height="150px" ></iframe>
1867
 
1868
  </div>
1869
 
1870
  <div id="tabs-6">
1871
 
1872
+ <iframe src="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/product-category.txt"
1873
  width="800px" height="225px" ></iframe>
1874
 
1875
  </div>
2167
  </div>
2168
 
2169
  <div id="tabs-3">
2170
+ <a href="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/csv-woo.txt">CSV example</a>
2171
  <br>
2172
  <br>
2173
  <center><img src="https://c1.staticflickr.com/1/216/31480097476_bf4915184b_o_d.jpg" style="width:90%"></center>
2290
  </div>
2291
 
2292
  <div id="tabs-3">
2293
+ <a href="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/csv.txt">CSV example</a>
2294
  <br>
2295
  <br>
2296
  <img src="https://c1.staticflickr.com/5/4860/44640581850_30311e210a_c_d.jpg" style="width:100%">
admin/menu.php CHANGED
@@ -61,15 +61,6 @@ function fifu_get_menu_html() {
61
  } else
62
  fifu_disable_fake();
63
 
64
- // fake 2
65
- if (fifu_is_on('fifu_fake2')) {
66
- update_option('fifu_data_generation', 'toggleoff');
67
- fifu_enable_fake2();
68
- } else if (fifu_is_off('fifu_fake2')) {
69
- fifu_disable_fake2();
70
- } else
71
- update_option('fifu_fake_created', null, 'no');
72
-
73
  // default
74
  if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake2')) {
75
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
@@ -80,12 +71,6 @@ function fifu_get_menu_html() {
80
  fifu_db_update_default_url($default_url);
81
  } else
82
  fifu_db_delete_default_url();
83
-
84
- // clean
85
- if (fifu_is_on('fifu_data_clean')) {
86
- fifu_db_enable_clean();
87
- update_option('fifu_data_clean', 'toggleoff', 'no');
88
- }
89
  }
90
 
91
  function fifu_get_menu_settings() {
61
  } else
62
  fifu_disable_fake();
63
 
 
 
 
 
 
 
 
 
 
64
  // default
65
  if (!empty($default_url) && fifu_is_on('fifu_enable_default_url') && fifu_is_on('fifu_fake2')) {
66
  if (!wp_get_attachment_url(get_option('fifu_default_attach_id'))) {
71
  fifu_db_update_default_url($default_url);
72
  } else
73
  fifu_db_delete_default_url();
 
 
 
 
 
 
74
  }
75
 
76
  function fifu_get_menu_settings() {
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.4.1
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
@@ -14,20 +14,19 @@ define('FIFU_INCLUDES_DIR', FIFU_PLUGIN_DIR . 'includes');
14
  define('FIFU_ADMIN_DIR', FIFU_PLUGIN_DIR . 'admin');
15
 
16
  require_once (FIFU_INCLUDES_DIR . '/attachment.php');
17
- require_once( FIFU_INCLUDES_DIR . '/convert-url.php' );
18
- require_once( FIFU_INCLUDES_DIR . '/external-post.php' );
19
- require_once( FIFU_INCLUDES_DIR . '/thumbnail.php' );
20
- require_once( FIFU_INCLUDES_DIR . '/thumbnail-category.php' );
21
  require_once (FIFU_INCLUDES_DIR . '/util.php');
22
  require_once (FIFU_INCLUDES_DIR . '/woo.php');
23
 
24
- if (is_admin()) {
25
- require_once( FIFU_ADMIN_DIR . '/category.php' );
26
- require_once( FIFU_ADMIN_DIR . '/column.php' );
27
- require_once( FIFU_ADMIN_DIR . '/menu.php' );
28
- }
29
  require_once (FIFU_ADMIN_DIR . '/db.php');
30
- require_once( FIFU_ADMIN_DIR . '/meta-box.php' );
 
 
 
31
 
32
  register_activation_hook(__FILE__, 'fifu_activate');
33
 
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.4.2
8
  * Author: Marcel Jacques Machado
9
  * Author URI: https://www.linkedin.com/in/marceljm/
10
  */
14
  define('FIFU_ADMIN_DIR', FIFU_PLUGIN_DIR . 'admin');
15
 
16
  require_once (FIFU_INCLUDES_DIR . '/attachment.php');
17
+ require_once (FIFU_INCLUDES_DIR . '/convert-url.php');
18
+ require_once (FIFU_INCLUDES_DIR . '/external-post.php');
19
+ require_once (FIFU_INCLUDES_DIR . '/thumbnail.php');
20
+ require_once (FIFU_INCLUDES_DIR . '/thumbnail-category.php');
21
  require_once (FIFU_INCLUDES_DIR . '/util.php');
22
  require_once (FIFU_INCLUDES_DIR . '/woo.php');
23
 
24
+ require_once (FIFU_ADMIN_DIR . '/api.php');
 
 
 
 
25
  require_once (FIFU_ADMIN_DIR . '/db.php');
26
+ require_once (FIFU_ADMIN_DIR . '/category.php');
27
+ require_once (FIFU_ADMIN_DIR . '/column.php');
28
+ require_once (FIFU_ADMIN_DIR . '/menu.php');
29
+ require_once (FIFU_ADMIN_DIR . '/meta-box.php');
30
 
31
  register_activation_hook(__FILE__, 'fifu_activate');
32
 
includes/attachment.php CHANGED
@@ -9,7 +9,7 @@ function fifu_replace_attached_file($att_url, $att_id) {
9
  if ($att_url) {
10
  $url = explode(";", $att_url);
11
  if (sizeof($url) > 1)
12
- return strpos($url[1], "/wp-content/uploads/") !== false ? get_post($att_id)->guid : $url[1];
13
  }
14
  }
15
  return $att_url;
@@ -22,7 +22,17 @@ function fifu_replace_attachment_url($att_url, $att_id) {
22
  if ($att_url) {
23
  $url = explode(";", $att_url);
24
  if (sizeof($url) > 1)
25
- return strpos($url[1], "/wp-content/uploads/") !== false ? get_post($att_id)->guid : $url[1];
 
 
 
 
 
 
 
 
 
 
26
  }
27
  }
28
 
@@ -59,14 +69,14 @@ function fifu_replace_attachment_image_src($image, $att_id, $size) {
59
  $image_size = fifu_get_image_size($size);
60
  if (fifu_is_on('fifu_original')) {
61
  return array(
62
- strpos($image[0], "/wp-content/uploads/") !== false ? get_post($att_id)->guid : $image[0],
63
  null,
64
  null,
65
  null,
66
  );
67
  }
68
  return array(
69
- strpos($image[0], "/wp-content/uploads/") !== false ? get_post($att_id)->guid : $image[0],
70
  isset($image_size['width']) ? $image_size['width'] : (get_option('fifu_default_width') ? get_option('fifu_default_width') : 800),
71
  isset($image_size['height']) ? $image_size['height'] : 600,
72
  isset($image_size['crop']) ? $image_size['crop'] : '',
@@ -94,3 +104,7 @@ function fifu_is_internal_image($image) {
94
  return $image && $image[1] > 1 && $image[2] > 1;
95
  }
96
 
 
 
 
 
9
  if ($att_url) {
10
  $url = explode(";", $att_url);
11
  if (sizeof($url) > 1)
12
+ return strpos($url[1], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $url[1];
13
  }
14
  }
15
  return $att_url;
22
  if ($att_url) {
23
  $url = explode(";", $att_url);
24
  if (sizeof($url) > 1)
25
+ return strpos($url[1], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $url[1];
26
+ else {
27
+ // external wordpress images
28
+ if (sizeof($url) > 0 && strpos($url[0], fifu_get_internal_image_path()) !== false) {
29
+ if (get_post($att_id)) {
30
+ $url = get_post($att_id)->guid;
31
+ if ($url)
32
+ return $url;
33
+ }
34
+ }
35
+ }
36
  }
37
  }
38
 
69
  $image_size = fifu_get_image_size($size);
70
  if (fifu_is_on('fifu_original')) {
71
  return array(
72
+ strpos($image[0], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $image[0],
73
  null,
74
  null,
75
  null,
76
  );
77
  }
78
  return array(
79
+ strpos($image[0], fifu_get_internal_image_path()) !== false ? get_post($att_id)->guid : $image[0],
80
  isset($image_size['width']) ? $image_size['width'] : (get_option('fifu_default_width') ? get_option('fifu_default_width') : 800),
81
  isset($image_size['height']) ? $image_size['height'] : 600,
82
  isset($image_size['crop']) ? $image_size['crop'] : '',
104
  return $image && $image[1] > 1 && $image[2] > 1;
105
  }
106
 
107
+ function fifu_get_internal_image_path() {
108
+ return $_SERVER['SERVER_NAME'] . "/wp-content/uploads/";
109
+ }
110
+
readme.txt CHANGED
@@ -157,6 +157,9 @@ Features:
157
 
158
  == Changelog ==
159
 
 
 
 
160
  = 2.4.1 =
161
  * Improvement: integration with REST API + Custom Post Types.
162
 
@@ -550,6 +553,9 @@ was removed. To finish, a Premium version is now been presented.
550
 
551
  == Upgrade Notice ==
552
 
 
 
 
553
  = 2.4.1 =
554
  * Improvement: integration with REST API + Custom Post Types.
555
 
157
 
158
  == Changelog ==
159
 
160
+ = 2.4.2 =
161
+ * Bug fixes: examples of import files; broken favicon; metadata lockscreen; URLs from WordPress sites.
162
+
163
  = 2.4.1 =
164
  * Improvement: integration with REST API + Custom Post Types.
165
 
553
 
554
  == Upgrade Notice ==
555
 
556
+ = 2.4.2 =
557
+ * Bug fixes: examples of import files; broken favicon; metadata lockscreen; URLs from WordPress sites.
558
+
559
  = 2.4.1 =
560
  * Improvement: integration with REST API + Custom Post Types.
561