Version Description
- Bug fixes.
=
Download this release
Release Info
Developer | marceljm |
Plugin | Featured Image From URL |
Version | 1.3.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.3.5
- admin/html/js/menu.js +14 -1
- admin/html/menu.html +40 -5
- admin/menu.php +95 -6
- admin/meta-box.php +24 -11
- featured-image-from-url.php +2 -1
- includes/thumbnail.php +14 -0
- readme.txt +6 -0
admin/html/js/menu.js
CHANGED
@@ -53,5 +53,18 @@ jQuery(function () {
|
|
53 |
}
|
54 |
});
|
55 |
});
|
56 |
-
});
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
});
|
55 |
});
|
|
|
56 |
|
57 |
+
jQuery("#fifu_form_hope").submit(function () {
|
58 |
+
|
59 |
+
var frm = jQuery("#fifu_form_hope");
|
60 |
+
|
61 |
+
jQuery.ajax({
|
62 |
+
type: frm.attr('method'),
|
63 |
+
url: url,
|
64 |
+
data: frm.serialize(),
|
65 |
+
success: function (data) {
|
66 |
+
//alert('saved');
|
67 |
+
}
|
68 |
+
});
|
69 |
+
});
|
70 |
+
});
|
admin/html/menu.html
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
|
11 |
<div class="greybox">
|
12 |
|
13 |
-
<p>Featured Image From URL plugin allows you to use an external image (from anywhere) as Featured Image of your Post, Page or Custom Post Type, such as WooCommerce Product. For WooCommerce users,
|
14 |
|
15 |
</div>
|
16 |
|
@@ -32,7 +32,7 @@
|
|
32 |
|
33 |
<div class="box">
|
34 |
|
35 |
-
<h2>Give This Plugin a 5-Star Rating
|
36 |
|
37 |
<div class="greybox">
|
38 |
|
@@ -44,11 +44,11 @@
|
|
44 |
|
45 |
<div class="box">
|
46 |
|
47 |
-
<h2>Report a Bug or Suggest an Improvement
|
48 |
|
49 |
<div class="greybox">
|
50 |
|
51 |
-
<p>Bug reports and constructive suggestions for improvement are always welcome. Just send an email to <a href="mailto:contact@marceljm.com">contact@marceljm.com</a>. You will earn a US$ 10 discount on Premium version and your request can be available in next release.</p>
|
52 |
|
53 |
</div>
|
54 |
|
@@ -128,7 +128,7 @@
|
|
128 |
|
129 |
<div class="greybox">
|
130 |
|
131 |
-
<p>
|
132 |
|
133 |
</div>
|
134 |
|
@@ -158,6 +158,41 @@
|
|
158 |
|
159 |
</div>
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
<div class="box">
|
162 |
|
163 |
<h2>About The Author</h2>
|
10 |
|
11 |
<div class="greybox">
|
12 |
|
13 |
+
<p>Featured Image From URL plugin allows you to use an external image (from anywhere) as Featured Image of your Post, Page or Custom Post Type, such as WooCommerce Product. For WooCommerce users, it's also possible to use external images in the Product Category and Product Gallery, but in this case your site should be hosted on a Linux server. All included content still has social tags to facilitate sharing on social networks. For more information, refer to <a href="https://wordpress.org/plugins/featured-image-from-url/faq/" target="_blank">FAQ</a> and <a href="https://wordpress.org/plugins/featured-image-from-url/screenshots/" target="_blank">screenshots</a>. </p>
|
14 |
|
15 |
</div>
|
16 |
|
32 |
|
33 |
<div class="box">
|
34 |
|
35 |
+
<h2>Give This Plugin a 5-Star Rating</h2>
|
36 |
|
37 |
<div class="greybox">
|
38 |
|
44 |
|
45 |
<div class="box">
|
46 |
|
47 |
+
<h2>Report a Bug or Suggest an Improvement</h2>
|
48 |
|
49 |
<div class="greybox">
|
50 |
|
51 |
+
<p>Bug reports and constructive suggestions for improvement are always welcome. Just send an email to <a href="mailto:contact@marceljm.com">contact@marceljm.com</a>. You will earn a US$ 10 discount on Premium version and your request can be available in the next release.</p>
|
52 |
|
53 |
</div>
|
54 |
|
128 |
|
129 |
<div class="greybox">
|
130 |
|
131 |
+
<p>It will sound crazy, but some themes don't show the Featured Image on the posts or pages. If it is your case and you would like to show the Featured Image there, just enable the toggle. The Featured Image will appear at the beginning of the content, before the text.</p>
|
132 |
|
133 |
</div>
|
134 |
|
158 |
|
159 |
</div>
|
160 |
|
161 |
+
<div class="box">
|
162 |
+
|
163 |
+
<h2>"This Plugin Doesn't Work, Man!"</h2>
|
164 |
+
|
165 |
+
<div class="greybox">
|
166 |
+
|
167 |
+
<p>If the external featured images of your posts or pages aren't being shown, congratulations: you're using a nonstandard theme! But there is a last hope. Enabling the toggle below, your external featured images will be associated to a symbolic file in your Media Library. It's an attempt to cheat your theme that will think that there is an internal image selected. Then when the theme tries to show the image, that doesn't exist, a JavaScript will replace your HTML code on execution time.</p>
|
168 |
+
|
169 |
+
</div>
|
170 |
+
|
171 |
+
<p/>
|
172 |
+
|
173 |
+
<form
|
174 |
+
id="fifu_form_hope"
|
175 |
+
action="javascript:void(0)"
|
176 |
+
method="post">
|
177 |
+
|
178 |
+
<input
|
179 |
+
type="image"
|
180 |
+
href="javascript:void(0)"
|
181 |
+
id="fifu_toggle_hope"
|
182 |
+
onclick="invert('hope')"
|
183 |
+
name="fifu_toggle_hope"
|
184 |
+
class="<?php echo $enable_hope; ?>"
|
185 |
+
value=" " >
|
186 |
+
|
187 |
+
<input
|
188 |
+
type="hidden"
|
189 |
+
id="fifu_input_hope"
|
190 |
+
name="fifu_input_hope"
|
191 |
+
value="" >
|
192 |
+
</form>
|
193 |
+
|
194 |
+
</div>
|
195 |
+
|
196 |
<div class="box">
|
197 |
|
198 |
<h2>About The Author</h2>
|
admin/menu.php
CHANGED
@@ -20,6 +20,7 @@ function fifu_get_menu_html() {
|
|
20 |
|
21 |
$enable_woocommerce = get_option('fifu_woocommerce');
|
22 |
$enable_content = get_option('fifu_content');
|
|
|
23 |
|
24 |
$array_cpt = array();
|
25 |
for ($x = 0; $x <= 4; $x++)
|
@@ -34,7 +35,9 @@ function fifu_get_menu_html() {
|
|
34 |
if (strpos($output, "Linux") !== false)
|
35 |
$compatible = "You server is using $output system. Great! The script will work =)";
|
36 |
else
|
37 |
-
$compatible = "You server is using $output system. The script may work. <p/>
|
|
|
|
|
38 |
}
|
39 |
|
40 |
include 'html/menu.html';
|
@@ -42,14 +45,20 @@ function fifu_get_menu_html() {
|
|
42 |
fifu_update_menu_options();
|
43 |
|
44 |
fifu_script_woocommerce();
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
function fifu_get_menu_settings() {
|
48 |
fifu_get_setting('fifu_woocommerce');
|
49 |
fifu_get_setting('fifu_content');
|
|
|
50 |
|
51 |
for ($x = 0; $x <= 4; $x++)
|
52 |
-
fifu_get_setting('fifu_cpt' . $x);
|
53 |
}
|
54 |
|
55 |
function fifu_get_setting($type) {
|
@@ -66,6 +75,7 @@ function fifu_get_setting($type) {
|
|
66 |
function fifu_update_menu_options() {
|
67 |
fifu_update_option('fifu_input_woocommerce', 'fifu_woocommerce');
|
68 |
fifu_update_option('fifu_input_content', 'fifu_content');
|
|
|
69 |
|
70 |
for ($x = 0; $x <= 4; $x++)
|
71 |
fifu_update_option('fifu_input_cpt' . $x, 'fifu_cpt' . $x);
|
@@ -73,11 +83,11 @@ function fifu_update_menu_options() {
|
|
73 |
|
74 |
function fifu_update_option($input, $type) {
|
75 |
if (isset($_POST[$input])) {
|
76 |
-
if ($_POST[$input] == 'on')
|
77 |
update_option($type, 'toggleon');
|
78 |
else if ($_POST[$input] == 'off')
|
79 |
update_option($type, 'toggleoff');
|
80 |
-
else
|
81 |
update_option($type, wp_strip_all_tags($_POST[$input]));
|
82 |
}
|
83 |
}
|
@@ -86,11 +96,90 @@ function fifu_script_woocommerce() {
|
|
86 |
if (get_option('fifu_woocommerce') == 'toggleon') {
|
87 |
$command1 = "echo " . get_template_directory() . " > ../wp-content/plugins/featured-image-from-url/scripts/tmp.txt";
|
88 |
$command2 = "sh ../wp-content/plugins/featured-image-from-url/scripts/enableWoocommerce.sh";
|
89 |
-
}
|
90 |
-
else {
|
91 |
$command1 = "sh ../wp-content/plugins/featured-image-from-url/scripts/disableWoocommerce.sh";
|
92 |
$command2 = "rm ../wp-content/plugins/featured-image-from-url/scripts/tmp.txt";
|
93 |
}
|
94 |
shell_exec($command1);
|
95 |
shell_exec($command2);
|
96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
$enable_woocommerce = get_option('fifu_woocommerce');
|
22 |
$enable_content = get_option('fifu_content');
|
23 |
+
$enable_hope = get_option('fifu_hope');
|
24 |
|
25 |
$array_cpt = array();
|
26 |
for ($x = 0; $x <= 4; $x++)
|
35 |
if (strpos($output, "Linux") !== false)
|
36 |
$compatible = "You server is using $output system. Great! The script will work =)";
|
37 |
else
|
38 |
+
$compatible = "You server is using $output system. The script may work. <p/>" .
|
39 |
+
"Please, send an email to <a href='mailto:contact@marceljm.com'>contact@marceljm.com</a> " .
|
40 |
+
"informing your server system and let me know if it worked for you.";
|
41 |
}
|
42 |
|
43 |
include 'html/menu.html';
|
45 |
fifu_update_menu_options();
|
46 |
|
47 |
fifu_script_woocommerce();
|
48 |
+
|
49 |
+
if (get_option('fifu_hope') == 'toggleon')
|
50 |
+
fifu_enable_nonstandard_compatibility();
|
51 |
+
else
|
52 |
+
fifu_disable_nonstandard_compatibility();
|
53 |
}
|
54 |
|
55 |
function fifu_get_menu_settings() {
|
56 |
fifu_get_setting('fifu_woocommerce');
|
57 |
fifu_get_setting('fifu_content');
|
58 |
+
fifu_get_setting('fifu_hope');
|
59 |
|
60 |
for ($x = 0; $x <= 4; $x++)
|
61 |
+
fifu_get_setting('fifu_cpt' . $x);
|
62 |
}
|
63 |
|
64 |
function fifu_get_setting($type) {
|
75 |
function fifu_update_menu_options() {
|
76 |
fifu_update_option('fifu_input_woocommerce', 'fifu_woocommerce');
|
77 |
fifu_update_option('fifu_input_content', 'fifu_content');
|
78 |
+
fifu_update_option('fifu_input_hope', 'fifu_hope');
|
79 |
|
80 |
for ($x = 0; $x <= 4; $x++)
|
81 |
fifu_update_option('fifu_input_cpt' . $x, 'fifu_cpt' . $x);
|
83 |
|
84 |
function fifu_update_option($input, $type) {
|
85 |
if (isset($_POST[$input])) {
|
86 |
+
if ($_POST[$input] == 'on')
|
87 |
update_option($type, 'toggleon');
|
88 |
else if ($_POST[$input] == 'off')
|
89 |
update_option($type, 'toggleoff');
|
90 |
+
else
|
91 |
update_option($type, wp_strip_all_tags($_POST[$input]));
|
92 |
}
|
93 |
}
|
96 |
if (get_option('fifu_woocommerce') == 'toggleon') {
|
97 |
$command1 = "echo " . get_template_directory() . " > ../wp-content/plugins/featured-image-from-url/scripts/tmp.txt";
|
98 |
$command2 = "sh ../wp-content/plugins/featured-image-from-url/scripts/enableWoocommerce.sh";
|
99 |
+
} else {
|
|
|
100 |
$command1 = "sh ../wp-content/plugins/featured-image-from-url/scripts/disableWoocommerce.sh";
|
101 |
$command2 = "rm ../wp-content/plugins/featured-image-from-url/scripts/tmp.txt";
|
102 |
}
|
103 |
shell_exec($command1);
|
104 |
shell_exec($command2);
|
105 |
}
|
106 |
+
|
107 |
+
function fifu_enable_nonstandard_compatibility() {
|
108 |
+
if (get_option('fifu_attachment_id'))
|
109 |
+
return;
|
110 |
+
|
111 |
+
global $wpdb;
|
112 |
+
$old_attach_id = get_option('fifu_attachment_id');
|
113 |
+
|
114 |
+
// create attachment
|
115 |
+
$filename = 'Featured Image From URL';
|
116 |
+
$parent_post_id = null;
|
117 |
+
$filetype = wp_check_filetype('fifu.png', null);
|
118 |
+
$attachment = array(
|
119 |
+
'guid' => basename($filename),
|
120 |
+
'post_mime_type' => $filetype['type'],
|
121 |
+
'post_title' => '',
|
122 |
+
'post_excerpt' => '',
|
123 |
+
'post_content' => 'Please don\'t remove that. It\'s just a symbolic file that keeps the field filled. ' .
|
124 |
+
'Some themes depend on having an attached file to work. But you are free to use any image you want instead of this file.',
|
125 |
+
'post_status' => 'inherit'
|
126 |
+
);
|
127 |
+
$attach_id = wp_insert_attachment($attachment, $filename, $parent_post_id);
|
128 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
129 |
+
$attach_data = wp_generate_attachment_metadata($attach_id, $filename);
|
130 |
+
wp_update_attachment_metadata($attach_id, $attach_data);
|
131 |
+
update_option('fifu_attachment_id', $attach_id);
|
132 |
+
|
133 |
+
// insert _thumbnail_id
|
134 |
+
$table = $wpdb->prefix . 'postmeta';
|
135 |
+
$query = "
|
136 |
+
SELECT DISTINCT post_id
|
137 |
+
FROM " . $table . " a
|
138 |
+
WHERE a.post_id in (
|
139 |
+
SELECT post_id
|
140 |
+
FROM " . $table . " b
|
141 |
+
WHERE b.meta_key = 'fifu_image_url'
|
142 |
+
AND b.meta_value IS NOT NULL
|
143 |
+
AND b.meta_value <> ''
|
144 |
+
)
|
145 |
+
AND NOT EXISTS (
|
146 |
+
SELECT 1
|
147 |
+
FROM " . $table . " c
|
148 |
+
WHERE a.post_id = c.post_id
|
149 |
+
AND c.meta_key = '_thumbnail_id'
|
150 |
+
)";
|
151 |
+
$result = $wpdb->get_results($query);
|
152 |
+
foreach ($result as $i) {
|
153 |
+
$data = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => $attach_id);
|
154 |
+
$wpdb->insert($table, $data);
|
155 |
+
}
|
156 |
+
|
157 |
+
// update _thumbnail_id
|
158 |
+
$data = array('meta_value' => $attach_id);
|
159 |
+
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => $old_attach_id);
|
160 |
+
$wpdb->update($table, $data, $where, null, null);
|
161 |
+
|
162 |
+
// update _thumbnail_id
|
163 |
+
$query = "
|
164 |
+
SELECT post_id
|
165 |
+
FROM " . $table . " a
|
166 |
+
WHERE a.meta_key = 'fifu_image_url'
|
167 |
+
AND a.meta_value IS NOT NULL
|
168 |
+
AND a.meta_value <> ''";
|
169 |
+
$result = $wpdb->get_results($query);
|
170 |
+
foreach ($result as $i) {
|
171 |
+
$data = array('meta_value' => $attach_id);
|
172 |
+
$where = array('post_id' => $i->post_id, 'meta_key' => '_thumbnail_id', 'meta_value' => -1);
|
173 |
+
$wpdb->update($table, $data, $where, null, null);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
function fifu_disable_nonstandard_compatibility() {
|
178 |
+
global $wpdb;
|
179 |
+
$table = $wpdb->prefix . 'postmeta';
|
180 |
+
$where = array('meta_key' => '_thumbnail_id', 'meta_value' => get_option('fifu_attachment_id'));
|
181 |
+
$wpdb->delete($table, $where);
|
182 |
+
|
183 |
+
wp_delete_attachment(get_option('fifu_attachment_id'));
|
184 |
+
delete_option('fifu_attachment_id');
|
185 |
+
}
|
admin/meta-box.php
CHANGED
@@ -40,12 +40,12 @@ function fifu_insert_meta_box() {
|
|
40 |
|
41 |
if ($post_type)
|
42 |
add_meta_box(
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
);
|
50 |
}
|
51 |
}
|
@@ -87,43 +87,56 @@ function fifu_wc_show_elements($post) {
|
|
87 |
$altWidth = 'width:86%;';
|
88 |
|
89 |
for ($i = 0; $i < 10; $i++) {
|
90 |
-
|
91 |
$alt[$i] = get_post_meta($post->ID, 'fifu_image_alt_' . $i, true);
|
92 |
|
93 |
if ($url[$i]) {
|
94 |
-
|
95 |
$show_alt[$i] = $show_image[$i] = $show_link[$i] = '';
|
96 |
} else {
|
97 |
$show_alt[$i] = $show_image[$i] = $show_link[$i] = 'display:none;';
|
98 |
$show_url[$i] = $show_button[$i] = '';
|
99 |
}
|
100 |
|
101 |
-
|
102 |
}
|
103 |
}
|
104 |
|
105 |
add_action('save_post', 'fifu_save_image_properties');
|
106 |
|
107 |
function fifu_save_image_properties($post_id) {
|
108 |
-
if (isset($_POST['fifu_input_url']))
|
109 |
update_post_meta($post_id, 'fifu_image_url', esc_url($_POST['fifu_input_url']));
|
110 |
|
|
|
|
|
|
|
|
|
111 |
if (isset($_POST['fifu_input_alt']))
|
112 |
update_post_meta($post_id, 'fifu_image_alt', wp_strip_all_tags($_POST['fifu_input_alt']));
|
113 |
|
114 |
if (get_post_type(get_the_ID() == 'product')) {
|
|
|
115 |
for ($i = 0; $i < 10; $i++) {
|
116 |
if (isset($_POST['fifu_input_url_' . $i]) && isset($_POST['fifu_input_alt_' . $i])) {
|
117 |
if ($_POST['fifu_input_url_' . $i] != '' && $_POST['fifu_input_alt_' . $i] != '') {
|
118 |
update_post_meta($post_id, 'fifu_image_url_' . $i, esc_url($_POST['fifu_input_url_' . $i]));
|
119 |
update_post_meta($post_id, 'fifu_image_alt_' . $i, wp_strip_all_tags($_POST['fifu_input_alt_' . $i]));
|
|
|
|
|
120 |
} else {
|
121 |
delete_post_meta($post_id, 'fifu_image_url_' . $i);
|
122 |
delete_post_meta($post_id, 'fifu_image_alt_' . $i);
|
|
|
123 |
}
|
124 |
}
|
125 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
}
|
128 |
|
129 |
-
|
40 |
|
41 |
if ($post_type)
|
42 |
add_meta_box(
|
43 |
+
'videoUrlMetaBox',
|
44 |
+
'External Featured Video',
|
45 |
+
'fifu_show_advertisement',
|
46 |
+
$post_type,
|
47 |
+
'side',
|
48 |
+
'low'
|
49 |
);
|
50 |
}
|
51 |
}
|
87 |
$altWidth = 'width:86%;';
|
88 |
|
89 |
for ($i = 0; $i < 10; $i++) {
|
90 |
+
$url[$i] = get_post_meta($post->ID, 'fifu_image_url_' . $i, true);
|
91 |
$alt[$i] = get_post_meta($post->ID, 'fifu_image_alt_' . $i, true);
|
92 |
|
93 |
if ($url[$i]) {
|
94 |
+
$show_url[$i] = $show_button[$i] = 'display:none;';
|
95 |
$show_alt[$i] = $show_image[$i] = $show_link[$i] = '';
|
96 |
} else {
|
97 |
$show_alt[$i] = $show_image[$i] = $show_link[$i] = 'display:none;';
|
98 |
$show_url[$i] = $show_button[$i] = '';
|
99 |
}
|
100 |
|
101 |
+
include 'html/wc-meta-box.html';
|
102 |
}
|
103 |
}
|
104 |
|
105 |
add_action('save_post', 'fifu_save_image_properties');
|
106 |
|
107 |
function fifu_save_image_properties($post_id) {
|
108 |
+
if (isset($_POST['fifu_input_url'])) {
|
109 |
update_post_meta($post_id, 'fifu_image_url', esc_url($_POST['fifu_input_url']));
|
110 |
|
111 |
+
if (get_option('fifu_attachment_id') && !get_post_thumbnail_id($post_id) && esc_url($_POST['fifu_input_url']))
|
112 |
+
set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
|
113 |
+
}
|
114 |
+
|
115 |
if (isset($_POST['fifu_input_alt']))
|
116 |
update_post_meta($post_id, 'fifu_image_alt', wp_strip_all_tags($_POST['fifu_input_alt']));
|
117 |
|
118 |
if (get_post_type(get_the_ID() == 'product')) {
|
119 |
+
$count = 10;
|
120 |
for ($i = 0; $i < 10; $i++) {
|
121 |
if (isset($_POST['fifu_input_url_' . $i]) && isset($_POST['fifu_input_alt_' . $i])) {
|
122 |
if ($_POST['fifu_input_url_' . $i] != '' && $_POST['fifu_input_alt_' . $i] != '') {
|
123 |
update_post_meta($post_id, 'fifu_image_url_' . $i, esc_url($_POST['fifu_input_url_' . $i]));
|
124 |
update_post_meta($post_id, 'fifu_image_alt_' . $i, wp_strip_all_tags($_POST['fifu_input_alt_' . $i]));
|
125 |
+
if (get_option('fifu_attachment_id') && !get_post_thumbnail_id($post_id) && esc_url($_POST['fifu_input_url_' . $i]))
|
126 |
+
set_post_thumbnail($post_id, get_option('fifu_attachment_id'));
|
127 |
} else {
|
128 |
delete_post_meta($post_id, 'fifu_image_url_' . $i);
|
129 |
delete_post_meta($post_id, 'fifu_image_alt_' . $i);
|
130 |
+
$count--;
|
131 |
}
|
132 |
}
|
133 |
}
|
134 |
+
if ($count == 0 && !esc_url($_POST['fifu_input_url']) && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id'))
|
135 |
+
delete_post_thumbnail($post_id);
|
136 |
+
}
|
137 |
+
else {
|
138 |
+
if (!esc_url($_POST['fifu_input_url']) && get_post_thumbnail_id($post_id) == get_option('fifu_attachment_id'))
|
139 |
+
delete_post_thumbnail($post_id);
|
140 |
}
|
141 |
}
|
142 |
|
|
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 |
*/
|
@@ -27,4 +27,5 @@ register_deactivation_hook( __FILE__, 'fifu_desactivate' );
|
|
27 |
function fifu_desactivate() {
|
28 |
update_option('fifu_woocommerce', 'toggleoff');
|
29 |
shell_exec('sh ../wp-content/plugins/featured-image-from-url/scripts/disableWoocommerce.sh');
|
|
|
30 |
}
|
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.5
|
7 |
* Author: Marcel Jacques Machado
|
8 |
* Author URI: https://marceljm.com/wordpress/featured-image-from-url-premium/
|
9 |
*/
|
27 |
function fifu_desactivate() {
|
28 |
update_option('fifu_woocommerce', 'toggleoff');
|
29 |
shell_exec('sh ../wp-content/plugins/featured-image-from-url/scripts/disableWoocommerce.sh');
|
30 |
+
fifu_disable_nonstandard_compatibility();
|
31 |
}
|
includes/thumbnail.php
CHANGED
@@ -56,3 +56,17 @@ function fifu_add_to_content($content) {
|
|
56 |
return $content;
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
return $content;
|
57 |
}
|
58 |
|
59 |
+
add_filter('wp_get_attachment_url', 'fifu_replace_attachment_url', 10, 2);
|
60 |
+
|
61 |
+
function fifu_replace_attachment_url($att_url, $att_id) {
|
62 |
+
if (get_option('fifu_attachment_id') == $att_id) {
|
63 |
+
if (is_admin())
|
64 |
+
$att_url = '/wp-content/plugins/featured-image-from-url/admin/images/fifu-text.jpg';
|
65 |
+
else {
|
66 |
+
$url = get_post_meta(get_the_ID(), 'fifu_image_url', true);
|
67 |
+
if ($url)
|
68 |
+
$att_url = $url;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
return $att_url;
|
72 |
+
}
|
readme.txt
CHANGED
@@ -208,6 +208,9 @@ was removed. To finish, a Premium version is now been presented.
|
|
208 |
= 1.3.4 =
|
209 |
* Bug fixes.
|
210 |
|
|
|
|
|
|
|
211 |
== Upgrade Notice ==
|
212 |
|
213 |
= 1.0 =
|
@@ -270,3 +273,6 @@ was removed. To finish, a Premium version is now been presented.
|
|
270 |
|
271 |
= 1.3.4 =
|
272 |
* Bug fixes.
|
|
|
|
|
|
208 |
= 1.3.4 =
|
209 |
* Bug fixes.
|
210 |
|
211 |
+
= 1.3.5 =
|
212 |
+
* Bug fixes.
|
213 |
+
|
214 |
== Upgrade Notice ==
|
215 |
|
216 |
= 1.0 =
|
273 |
|
274 |
= 1.3.4 =
|
275 |
* Bug fixes.
|
276 |
+
|
277 |
+
= 1.3.5 =
|
278 |
+
* Bug fixes.
|