Featured Image From URL - Version 1.3.1

Version Description

  • Bug fixes.

=

Download this release

Release Info

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

Code changes from version 1.3 to 1.3.1

admin/meta-box.php CHANGED
@@ -120,20 +120,20 @@ function fifu_save_image_properties($post_id) {
120
  update_post_meta($post_id, 'fifu_image_alt_' . $i, wp_strip_all_tags($_POST['fifu_input_alt_' . $i]));
121
  if (!get_post_thumbnail_id($post_id))
122
  set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
123
- $count--;
124
  } else {
125
  delete_post_meta($post_id, 'fifu_image_url_' . $i);
126
  delete_post_meta($post_id, 'fifu_image_alt_' . $i);
 
127
  }
128
  }
129
  }
130
- if ($count == 0 && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id'))
131
  delete_post_thumbnail($post_id);
132
  }
133
-
134
- if (esc_url($_POST['fifu_input_url']) && !get_post_thumbnail_id($post_id))
135
- set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
136
-
137
- if (!esc_url($_POST['fifu_input_url']) && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id'))
138
- delete_post_thumbnail($post_id);
139
  }
120
  update_post_meta($post_id, 'fifu_image_alt_' . $i, wp_strip_all_tags($_POST['fifu_input_alt_' . $i]));
121
  if (!get_post_thumbnail_id($post_id))
122
  set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
 
123
  } else {
124
  delete_post_meta($post_id, 'fifu_image_url_' . $i);
125
  delete_post_meta($post_id, 'fifu_image_alt_' . $i);
126
+ $count--;
127
  }
128
  }
129
  }
130
+ if ($count == 0 && !esc_url($_POST['fifu_input_url']) && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id'))
131
  delete_post_thumbnail($post_id);
132
  }
133
+ else {
134
+ if (!esc_url($_POST['fifu_input_url']) && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id'))
135
+ delete_post_thumbnail($post_id);
136
+ else if (esc_url($_POST['fifu_input_url']) && !get_post_thumbnail_id($post_id))
137
+ set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
138
+ }
139
  }
featured-image-from-url.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  * Plugin Name: Featured Image From URL
5
  * Description: Allows to use an external image as Featured Image of your post, page or Custom Post Type, such as WooCommerce Product (supports Product Gallery also).
6
- * Version: 1.3
7
  * Author: Marcel Jacques Machado
8
  * Author URI: https://marceljm.com/wordpress/featured-image-from-url-premium/
9
  */
3
  /*
4
  * Plugin Name: Featured Image From URL
5
  * Description: Allows to use an external image as Featured Image of your post, page or Custom Post Type, such as WooCommerce Product (supports Product Gallery also).
6
+ * Version: 1.3.1
7
  * Author: Marcel Jacques Machado
8
  * Author URI: https://marceljm.com/wordpress/featured-image-from-url-premium/
9
  */
includes/thumbnail-category.php CHANGED
@@ -1,24 +1,22 @@
1
  <?php
2
 
3
- add_filter( 'woocommerce_before_main_content', 'fifu_category_show_image', 30);
4
 
5
- function fifu_category_show_image() {
6
- $image_url = fifu_get_image_url();
7
- $image_alt = fifu_get_image_alt();
8
 
9
- if ($image_url)
10
- $html = fifu_category_get_html($image_url, $image_alt);
11
-
12
- echo $html;
13
  }
14
 
15
  add_filter('wp_head', 'fifu_cat_add_social_tags');
16
 
17
  function fifu_cat_add_social_tags() {
18
- $url = fifu_get_image_url();
19
  $title = single_cat_title('', false);
20
 
21
- $term_id = fifu_get_term_id();
22
  if ($term_id)
23
  $description = wp_strip_all_tags(category_description($term_id));
24
 
@@ -26,25 +24,17 @@ function fifu_cat_add_social_tags() {
26
  include 'html/social.html';
27
  }
28
 
29
- function fifu_get_image_url () {
30
- $term_id = fifu_get_term_id();
31
  return get_term_meta($term_id, 'fifu_image_url', true);
32
  }
33
 
34
- function fifu_get_image_alt() {
35
- $term_id = fifu_get_term_id();
36
  return get_term_meta($term_id, 'fifu_image_alt', true);
37
  }
38
 
39
- function fifu_get_term_id() {
40
  global $wp_query;
41
-
42
- if ($wp_query->queried_object)
43
- return $wp_query->queried_object->term_id;
44
- else
45
- return null;
46
- }
47
-
48
- function fifu_category_get_html($image_url, $image_alt) {
49
- return sprintf('<!-- Featured Image From URL plugin --> <img src="%s" alt="%s"></img>', $image_url, $image_alt);
50
  }
1
  <?php
2
 
3
+ add_filter('woocommerce_before_main_content', 'fifu_cat_show_image', 30);
4
 
5
+ function fifu_cat_show_image() {
6
+ $url = fifu_cat_get_url();
7
+ $alt = fifu_cat_get_alt();
8
 
9
+ if ($url)
10
+ echo fifu_get_html($url, $alt);
 
 
11
  }
12
 
13
  add_filter('wp_head', 'fifu_cat_add_social_tags');
14
 
15
  function fifu_cat_add_social_tags() {
16
+ $url = fifu_cat_get_url();
17
  $title = single_cat_title('', false);
18
 
19
+ $term_id = fifu_cat_get_term_id();
20
  if ($term_id)
21
  $description = wp_strip_all_tags(category_description($term_id));
22
 
24
  include 'html/social.html';
25
  }
26
 
27
+ function fifu_cat_get_url() {
28
+ $term_id = fifu_cat_get_term_id();
29
  return get_term_meta($term_id, 'fifu_image_url', true);
30
  }
31
 
32
+ function fifu_cat_get_alt() {
33
+ $term_id = fifu_cat_get_term_id();
34
  return get_term_meta($term_id, 'fifu_image_alt', true);
35
  }
36
 
37
+ function fifu_cat_get_term_id() {
38
  global $wp_query;
39
+ return $wp_query->get_queried_object_id();
 
 
 
 
 
 
 
 
40
  }
includes/thumbnail.php CHANGED
@@ -9,7 +9,7 @@ function fifu_add_social_tags() {
9
  $description = wp_strip_all_tags(get_post_field('post_content', $post_id));
10
 
11
  if ($url)
12
- include 'html/social.html';
13
  }
14
 
15
  add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
@@ -18,7 +18,7 @@ function fifu_replace($html, $post_id) {
18
  $image_url = get_post_meta($post_id, 'fifu_image_url', true);
19
  $image_alt = get_post_meta($post_id, 'fifu_image_alt', true);
20
 
21
- if ($image_url)
22
  $html = fifu_get_html($image_url, $image_alt);
23
 
24
  return $html;
@@ -28,23 +28,26 @@ function fifu_get_html($image_url, $image_alt) {
28
  return sprintf('<!-- Featured Image From URL plugin --> <img src="%s" alt="%s"></img>', $image_url, $image_alt);
29
  }
30
 
 
 
 
 
 
 
 
 
 
31
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
32
 
33
  function fifu_replace_attachment_url($att_url, $att_id) {
34
  if (get_option('fifu_attachment_id') == $att_id) {
35
  if (is_admin())
36
  $att_url = '/wp-content/plugins/featured-image-from-url/admin/images/fifu-text.jpg';
37
- else
38
- $att_url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
 
 
 
39
  }
40
  return $att_url;
41
  }
42
-
43
- add_filter('the_content', 'fifu_add_to_content');
44
-
45
- function fifu_add_to_content($content) {
46
- if (is_singular() && has_post_thumbnail() && get_option('fifu_content') == 'toggleon')
47
- return get_the_post_thumbnail() . $content;
48
- else
49
- return $content;
50
- }
9
  $description = wp_strip_all_tags(get_post_field('post_content', $post_id));
10
 
11
  if ($url)
12
+ include 'html/social.html';
13
  }
14
 
15
  add_filter('post_thumbnail_html', 'fifu_replace', 10, 2);
18
  $image_url = get_post_meta($post_id, 'fifu_image_url', true);
19
  $image_alt = get_post_meta($post_id, 'fifu_image_alt', true);
20
 
21
+ if ($image_url)
22
  $html = fifu_get_html($image_url, $image_alt);
23
 
24
  return $html;
28
  return sprintf('<!-- Featured Image From URL plugin --> <img src="%s" alt="%s"></img>', $image_url, $image_alt);
29
  }
30
 
31
+ add_filter('the_content', 'fifu_add_to_content');
32
+
33
+ function fifu_add_to_content($content) {
34
+ if (is_singular() && has_post_thumbnail() && get_option('fifu_content') == 'toggleon')
35
+ return get_the_post_thumbnail() . $content;
36
+ else
37
+ return $content;
38
+ }
39
+
40
  add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
41
 
42
  function fifu_replace_attachment_url($att_url, $att_id) {
43
  if (get_option('fifu_attachment_id') == $att_id) {
44
  if (is_admin())
45
  $att_url = '/wp-content/plugins/featured-image-from-url/admin/images/fifu-text.jpg';
46
+ else {
47
+ $url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
48
+ if ($url)
49
+ $att_url = $url;
50
+ }
51
  }
52
  return $att_url;
53
  }
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: marceljm
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8BLDLZ3HDBGQG
4
  Tags: featured image, external featured image, featured image from url, url featured image, featured, image, external, url, flickr, s3, picasa, woocommerce, product image, product gallery, product, gallery, column, list, page, post, all, content, custom, type, custom post type, category, video, external video, youtube, featured video
5
  Requires at least: 4.0
6
- Tested up to: 4.4.2
7
- Stable tag: 4.4.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -196,6 +196,9 @@ was removed. To finish, a Premium version is now been presented.
196
  = 1.3 =
197
  * The plugin should be compatible with any theme now.
198
 
 
 
 
199
  == Upgrade Notice ==
200
 
201
  = 1.0 =
@@ -246,3 +249,6 @@ was removed. To finish, a Premium version is now been presented.
246
 
247
  = 1.3 =
248
  * The plugin should be compatible with any theme now.
 
 
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8BLDLZ3HDBGQG
4
  Tags: featured image, external featured image, featured image from url, url featured image, featured, image, external, url, flickr, s3, picasa, woocommerce, product image, product gallery, product, gallery, column, list, page, post, all, content, custom, type, custom post type, category, video, external video, youtube, featured video
5
  Requires at least: 4.0
6
+ Tested up to: 4.5
7
+ Stable tag: 4.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
196
  = 1.3 =
197
  * The plugin should be compatible with any theme now.
198
 
199
+ = 1.3.1 =
200
+ * Bug fixes.
201
+
202
  == Upgrade Notice ==
203
 
204
  = 1.0 =
249
 
250
  = 1.3 =
251
  * The plugin should be compatible with any theme now.
252
+
253
+ = 1.3.1 =
254
+ * Bug fixes.
scripts/disableWoocommerce.sh CHANGED
@@ -5,13 +5,13 @@ themeDir=`cat ../wp-content/plugins/featured-image-from-url/scripts/tmp.txt`
5
 
6
  restoreProductImage()
7
  {
8
- file=$dir'product-image.php'
9
  overwrite
10
  }
11
 
12
  restoreProductThumbnails()
13
  {
14
- file=$dir'product-thumbnails.php'
15
  overwrite
16
  }
17
 
@@ -28,8 +28,10 @@ overwrite()
28
 
29
  restore()
30
  {
31
- restoreProductImage
32
- restoreProductThumbnails
 
 
33
  restoreCategory
34
  }
35
 
5
 
6
  restoreProductImage()
7
  {
8
+ file=$1
9
  overwrite
10
  }
11
 
12
  restoreProductThumbnails()
13
  {
14
+ file=$1
15
  overwrite
16
  }
17
 
28
 
29
  restore()
30
  {
31
+ restoreProductImage $dir'product-image.php'
32
+ restoreProductImage `find $themeDir . -iname product-thumbnails.php`
33
+ restoreProductThumbnails $dir'product-thumbnails.php'
34
+ restoreProductThumbnails `find $themeDir . -iname product-thumbnails.php`
35
  restoreCategory
36
  }
37
 
scripts/enableWoocommerce.sh CHANGED
@@ -42,7 +42,7 @@ category()
42
  {
43
  file=$themeDir'/woocommerce.php'
44
  old='woocommerce_content()'
45
- new='fifu_category_show_image();woocommerce_content()'
46
  replace
47
  }
48
 
42
  {
43
  file=$themeDir'/woocommerce.php'
44
  old='woocommerce_content()'
45
+ new='fifu_cat_show_image();woocommerce_content()'
46
  replace
47
  }
48