Changeset 3352132
- Timestamp:
- 08/28/2025 03:57:03 PM (7 months ago)
- Location:
- featured-image-from-url/trunk
- Files:
-
- 18 edited
-
admin/block.php (modified) (1 diff)
-
admin/db.php (modified) (9 diffs)
-
admin/html/js/column.js (modified) (2 diffs)
-
admin/html/js/menu-su.js (modified) (1 diff)
-
admin/html/menu.html (modified) (3 diffs)
-
admin/meta-box.php (modified) (1 diff)
-
admin/strings.php (modified) (6 diffs)
-
elementor/elementor-fifu-extension.php (modified) (2 diffs)
-
elementor/widgets/widget-video.php (modified) (2 diffs)
-
elementor/widgets/widget.php (modified) (3 diffs)
-
featured-image-from-url.php (modified) (1 diff)
-
includes/attachment.php (modified) (2 diffs)
-
includes/html/js/json-ld.js (modified) (1 diff)
-
includes/html/og-image.html (modified) (1 diff)
-
includes/html/social-home.html (modified) (1 diff)
-
includes/html/twitter-image.html (modified) (1 diff)
-
includes/thumbnail.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
featured-image-from-url/trunk/admin/block.php
r3341179 r3352132 2 2 3 3 function fifu_register_blocks() { 4 // Prevent block registration in Customizer 5 if (is_admin() && isset($GLOBALS['wp_customize']) && $GLOBALS['wp_customize'] instanceof WP_Customize_Manager) { 6 return; 7 } 8 4 9 $block_strings = fifu_get_strings_block(); 5 10 register_block_type( -
featured-image-from-url/trunk/admin/db.php
r3328447 r3352132 517 517 false AS category 518 518 FROM {$this->postmeta} pm 519 INNER JOIN {$this->posts} p ON pm.post_id = p.id {$filter} 519 INNER JOIN {$this->posts} p ON pm.post_id = p.id {$filter} AND p.post_title <> '' 520 520 INNER JOIN {$this->posts} att ON ( 521 521 pm.meta_key = '_thumbnail_id' … … 830 830 // featured group 831 831 if (count($featured_list) > 0) { 832 $att_ids_map = $this->get_thumbnail_ids($featured_list, false);833 if (count($att_ids_map ) > 0) {834 $this->revert_attachments($urls, $featured_list, $att_ids_map );835 $meta_ids_map = $this->get_thumbnail_meta_ids($featured_list, $att_ids_map);836 if (count($meta_ids_map ) > 0)837 $this->revert_attachments_meta($urls, $featured_list, $meta_ids_map );832 $att_ids_map_featured = $this->get_thumbnail_ids($featured_list, false); 833 if (count($att_ids_map_featured) > 0) { 834 $this->revert_attachments($urls, $featured_list, $att_ids_map_featured); 835 $meta_ids_map_featured = $this->get_thumbnail_meta_ids($featured_list, $att_ids_map_featured); 836 if (count($meta_ids_map_featured) > 0) 837 $this->revert_attachments_meta($urls, $featured_list, $meta_ids_map_featured); 838 838 } 839 839 } … … 1043 1043 function insert_attachment_by($value) { 1044 1044 $this->wpdb->query(" 1045 INSERT INTO {$this->posts} (post_author, guid, post_title, post_ mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_excerpt, to_ping, pinged, post_content_filtered)1045 INSERT INTO {$this->posts} (post_author, guid, post_title, post_excerpt, post_mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, to_ping, pinged, post_content_filtered) 1046 1046 VALUES " . str_replace('\\', '', $value)); 1047 1047 } … … 1049 1049 function insert_ctgr_attachment_by($value) { 1050 1050 $this->wpdb->query(" 1051 INSERT INTO {$this->posts} (post_author, guid, post_title, post_ mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_excerpt, to_ping, pinged, post_content_filtered, post_name)1051 INSERT INTO {$this->posts} (post_author, guid, post_title, post_excerpt, post_mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, to_ping, pinged, post_content_filtered, post_name) 1052 1052 VALUES " . str_replace('\\', '', $value)); 1053 1053 } … … 1055 1055 function get_formatted_value($url, $alt, $post_parent) { 1056 1056 $alt = $alt ?? ''; 1057 return "({$this->author}, '', '" . str_replace("'", "", $alt) . "', 'image/jpeg', 'attachment', 'inherit', '{$post_parent}', now(), now(), now(), now(), '', '', '', '', '{$url}')"; 1057 $alt = str_replace("'", "", $alt); 1058 return "({$this->author}, '', '{$alt}', '{$alt}', 'image/jpeg', 'attachment', 'inherit', '{$post_parent}', now(), now(), now(), now(), '', '', '', '{$url}')"; 1058 1059 } 1059 1060 1060 1061 function get_ctgr_formatted_value($url, $alt, $post_parent) { 1061 1062 $alt = $alt ?? ''; 1062 return "({$this->author}, '', '" . str_replace("'", "", $alt) . "', 'image/jpeg', 'attachment', 'inherit', '{$post_parent}', now(), now(), now(), now(), '', '', '', '', '{$url}', 'fifu-category-{$post_parent}')"; 1063 $alt = str_replace("'", "", $alt); 1064 return "({$this->author}, '', '{$alt}', '{$alt}', 'image/jpeg', 'attachment', 'inherit', '{$post_parent}', now(), now(), now(), now(), '', '', '', '{$url}', 'fifu-category-{$post_parent}')"; 1063 1065 } 1064 1066 … … 1113 1115 update_post_meta($att_id, '_wp_attached_file', $url); 1114 1116 $alt ? update_post_meta($att_id, '_wp_attachment_image_alt', $alt) : delete_post_meta($att_id, '_wp_attachment_image_alt'); 1115 $this->wpdb->update($this->posts, $set = array('post_title' => $alt, 'post_ content_filtered' => $url), $where = array('id' => $att_id), null, null);1117 $this->wpdb->update($this->posts, $set = array('post_title' => $alt, 'post_excerpt' => $alt, 'post_content_filtered' => $url), $where = array('id' => $att_id), null, null); 1116 1118 } 1117 1119 // insert … … 1153 1155 update_post_meta($att_id, '_wp_attached_file', $url); 1154 1156 $alt ? update_post_meta($att_id, '_wp_attachment_image_alt', $alt) : delete_post_meta($att_id, '_wp_attachment_image_alt'); 1155 $this->wpdb->update($this->posts, $set = array('post_content_filtered' => $url, 'post_title' => $alt ), $where = array('id' => $att_id), null, null);1157 $this->wpdb->update($this->posts, $set = array('post_content_filtered' => $url, 'post_title' => $alt, 'post_excerpt' => $alt), $where = array('id' => $att_id), null, null); 1156 1158 } 1157 1159 // insert … … 1697 1699 try { 1698 1700 $this->wpdb->query(" 1699 INSERT INTO {$this->posts} (post_author, guid, post_title, post_ mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_excerpt, to_ping, pinged, post_content_filtered)1701 INSERT INTO {$this->posts} (post_author, guid, post_title, post_excerpt, post_mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, to_ping, pinged, post_content_filtered) 1700 1702 VALUES " . str_replace('\\', '', $value)); 1701 1703 … … 1827 1829 try { 1828 1830 $this->wpdb->query(" 1829 INSERT INTO {$this->posts} (post_author, guid, post_title, post_ mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_excerpt, to_ping, pinged, post_content_filtered, post_name)1831 INSERT INTO {$this->posts} (post_author, guid, post_title, post_excerpt, post_mime_type, post_type, post_status, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, to_ping, pinged, post_content_filtered, post_name) 1830 1832 VALUES " . str_replace('\\', '', $value)); 1831 1833 -
featured-image-from-url/trunk/admin/html/js/column.js
r3348282 r3352132 8 8 // Check all .fifu-quick thumbnails for invalid images 9 9 fifu_check_image_validity(); 10 11 // Add MutationObserver safely12 if (document.body) {13 observer.observe(document.body, {14 childList: true,15 subtree: true16 });17 }18 10 }); 19 11 … … 73 65 }); 74 66 }); 67 68 // Start observing 69 if (document.body) { 70 observer.observe(document.body, { 71 childList: true, 72 subtree: true 73 }); 74 } 75 75 76 76 var currentLightbox = null; -
featured-image-from-url/trunk/admin/html/js/menu-su.js
r3348282 r3352132 234 234 }, 235 235 action: function () { 236 jQuery("#su-dialog-remove").dialog("open"); 237 update = true; 236 if (table.rows({selected: true}).count() > 0) { 237 jQuery("#su-dialog-remove").dialog("open"); 238 update = true; 239 } 238 240 } 239 241 }, -
featured-image-from-url/trunk/admin/html/menu.html
r3348282 r3352132 5744 5744 <table style="background-color: #fff; border-radius: 13px;"> 5745 5745 <tr> 5746 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5746 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5747 5747 <i class="fa-solid fa-robot" style="font-size:30px"></i> 5748 5748 </td> 5749 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5749 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5750 5750 <i class="fa-solid fa-glasses" style="font-size:30px"></i> 5751 </td>5752 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">5753 <i class="fab fa-facebook" style="font-size:30px"></i>5754 5751 </td> 5755 5752 </tr> 5756 5753 <tr> 5757 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5754 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5758 5755 <i><?php $fifu['support']['wp-automatic']() ?></i> 5759 5756 </td> 5760 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5757 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5761 5758 <i><?php $fifu['support']['resolution']() ?></i> 5762 </td>5763 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">5764 <i><?php $fifu['support']['facebook']() ?></i>5765 5759 </td> 5766 5760 </tr> … … 5772 5766 <?php $fifu['support']['resolution-desc']() ?> 5773 5767 </td> 5774 <td style="vertical-align: top;">5775 <?php $fifu['support']['facebook-desc']() ?>5776 </td>5777 5768 </tr> 5778 5769 </table> 5779 5780 5770 <br> 5781 5782 5771 <table style="background-color: #fff; border-radius: 13px;"> 5783 5772 <tr> 5784 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important"> 5785 <i class="fas fa-exclamation-triangle" style="font-size:30px"></i> 5786 </td> 5787 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important"> 5773 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5788 5774 <i class="fas fa-plug" style="font-size:30px"></i> 5789 5775 </td> 5790 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5791 <i class="fa -solid fa-rotate-right" style="font-size:30px"></i>5776 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5777 <i class="fas fa-exclamation-triangle" style="font-size:30px"></i> 5792 5778 </td> 5793 5779 </tr> 5794 5780 <tr> 5795 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important"> 5796 <i><?php $fifu['support']['disappeared']() ?></i> 5797 </td> 5798 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important"> 5781 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5799 5782 <i><?php $fifu['support']['plugin']() ?></i> 5800 5783 </td> 5801 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5802 <i><?php $fifu['support'][' others']() ?></i>5784 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5785 <i><?php $fifu['support']['disappeared']() ?></i> 5803 5786 </td> 5804 5787 </tr> 5805 5788 <tr> 5806 5789 <td style="vertical-align: top;"> 5807 <?php $fifu['support']['disappeared-desc']() ?>5808 </td>5809 <td style="vertical-align: top;">5810 5790 <?php $fifu['support']['plugin-desc']() ?> 5811 5791 </td> 5812 5792 <td style="vertical-align: top;"> 5813 <?php $fifu['support'][' others-desc']() ?>5793 <?php $fifu['support']['disappeared-desc']() ?> 5814 5794 </td> 5815 5795 </tr> 5816 5796 </table> 5817 5818 5797 <br> 5819 5820 5798 <table style="background-color: #fff; border-radius: 13px;"> 5821 5799 <tr> 5822 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5800 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5823 5801 <i class="fa-solid fa-icons" style="font-size:30px"></i> 5824 5802 </td> 5825 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5803 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5826 5804 <i class="fa-solid fa-file-circle-xmark" style="font-size:30px"></i> 5827 </td>5828 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">5829 5830 5805 </td> 5831 5806 </tr> 5832 5807 <tr> 5833 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5808 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5834 5809 <i><?php $fifu['support']['media-library']() ?></i> 5835 5810 </td> 5836 <td style="width: 33%;text-align:center;border-bottom: 1px solid #ddd !important">5811 <td style="width:50%;text-align:center;border-bottom: 1px solid #ddd !important"> 5837 5812 <i><?php $fifu['support']['money']() ?></i> 5838 </td>5839 <td style="width:33%;text-align:center;border-bottom: 1px solid #ddd !important">5840 5841 5813 </td> 5842 5814 </tr> … … 5848 5820 <?php $fifu['support']['money-desc']() ?> 5849 5821 </td> 5850 <td style="vertical-align: top;">5851 5852 </td>5853 5822 </tr> 5854 5823 </table> -
featured-image-from-url/trunk/admin/meta-box.php
r3348282 r3352132 300 300 } 301 301 302 /* woocommerce variation elements */303 304 // add_action('woocommerce_product_after_variable_attributes', 'fifu_variation_settings_fields', 10, 3);305 306 function fifu_variation_settings_fields($loop, $variation_data, $variation) {307 $fifu = fifu_get_strings_meta_box_php();308 309 // variation310 woocommerce_wp_text_input(311 array(312 'id' => "fifu_image_url{$loop}",313 'name' => "fifu_image_url[{$loop}]",314 'value' => get_post_meta($variation->ID, 'fifu_image_url', true),315 'label' => '<span class="dashicons dashicons-camera" style="font-size:20px"></span>' . $fifu['variation']['field'](),316 'desc_tip' => true,317 'description' => $fifu['variation']['info'](),318 'placeholder' => $fifu['variation']['image'](),319 'wrapper_class' => 'form-row form-row-full',320 )321 );322 // variation gallery323 for ($i = 0; $i < 3; $i++) {324 woocommerce_wp_text_input(325 array(326 'id' => "fifu_image_url_" . $i . "{$loop}",327 'name' => "fifu_image_url_" . $i . "[{$loop}]",328 'value' => get_post_meta($variation->ID, 'fifu_image_url_' . $i, true),329 'label' => '<span class="dashicons dashicons-format-gallery" style="font-size:20px"></span>' . $fifu['variation']['images']() . ' #' . ($i + 1),330 'desc_tip' => true,331 'placeholder' => $fifu['variation']['image'](),332 'wrapper_class' => 'form-row form-row-full',333 )334 );335 }336 }337 338 302 /* dimensions */ 339 303 -
featured-image-from-url/trunk/admin/strings.php
r3348282 r3352132 467 467 _e("A plugin isn't working with FIFU", FIFU_SLUG); 468 468 }; 469 $fifu['support']['facebook'] = function () {470 _e("Facebook doesn't share images", FIFU_SLUG);471 };472 469 $fifu['support']['money'] = function () { 473 470 _e("Broken image icon", FIFU_SLUG); … … 482 479 _e("Contact us. If you are available to discuss the details, we should provide an integration. Or contact its developer and ask him to use the functions at 'Developers → FIFU API'.", FIFU_SLUG); 483 480 }; 484 $fifu['support']['facebook-desc'] = function () {485 _e("You probably have a plugin or theme that sets a default image as the Facebook image (og:image meta tag). Just find and disable the option.", FIFU_SLUG);486 };487 481 $fifu['support']['money-desc'] = function () { 488 482 _e("Possibilities: a) CDN can't serve it; b) image deleted by owner; c) hotlink protection; d) incorrect URL. For (a), disable 'Image → Optimized images' temporarily and contact us. For (b) or (c), try FIFU Cloud.", FIFU_SLUG); … … 497 491 _e("Images saved in the media library", FIFU_SLUG); 498 492 }; 499 $fifu['support']['others'] = function () {500 _e("Changes have no effect", FIFU_SLUG);501 };502 493 $fifu['support']['wp-automatic-desc'] = function () { 503 494 _e("Notify WP Automatic (or WPeMatico) support that image URLs are not sent to FIFU. Alternatively, use our PRO version to obtain images using page addresses or post titles.", FIFU_SLUG); … … 505 496 $fifu['support']['media-library-desc'] = function () { 506 497 _e("This plugin doesn't save images to the media library unless you're using the 'Image → Save in the media library' feature. So, another plugin or your theme may be causing this.", FIFU_SLUG); 507 };508 $fifu['support']['others-desc'] = function () {509 _e("If you're using a performance plugin, clearing the cache may help. This ensures that backend changes propagate effectively to the frontend.", FIFU_SLUG);510 498 }; 511 499 … … 1830 1818 1831 1819 // variation 1832 $fifu['variation']['field'] = function () { 1833 return __("Product Image (URL)", FIFU_SLUG); 1834 }; 1835 $fifu['variation']['info'] = function () { 1836 return __("Powered by FIFU plugin", FIFU_SLUG); 1837 }; 1838 $fifu['variation']['image'] = function () { 1839 return __("Image URL", FIFU_SLUG); 1840 }; 1841 $fifu['variation']['images'] = function () { 1842 return __("Gallery Image (URL)", FIFU_SLUG); 1843 }; 1844 $fifu['variation']['upload'] = function () { 1820 $fifu['variation']['new']['upload'] = function () { 1845 1821 return __("Upload to media library", FIFU_SLUG); 1822 }; 1823 $fifu['variation']['new']['images'] = function () { 1824 return __("Images", FIFU_SLUG); 1825 }; 1826 $fifu['variation']['new']['help'] = function () { 1827 return __("The first slot is for the featured image, and the others are for the image gallery.", FIFU_SLUG); 1846 1828 }; 1847 1829 … … 2299 2281 // media 2300 2282 $fifu['media']['desc'] = function () { 2301 _e(" Before uploading local images to the cloud, you should copy their URLs to FIFU custom fields by clicking the \"link\" button. Have a database backup as post metadata will be replaced, making this plugin responsible for displaying images. Do not delete images from the media library until ensuring they were saved in the cloud.", FIFU_SLUG);2283 _e("To have local images listed on the 'Upload' tab, you should first select them here and click the 'link' button, which will copy the local image URLs to the FIFU custom field, making FIFU responsible for displaying the images. Then you should be able to upload the local images to the cloud. Do not delete any image from the media library before doing this.", FIFU_SLUG); 2302 2284 }; 2303 2285 -
featured-image-from-url/trunk/elementor/elementor-fifu-extension.php
r2926179 r3352132 18 18 public function __construct() { 19 19 add_action('init', [$this, 'i18n']); 20 add_action('plugins_loaded', [$this, 'init']); 20 21 // Use current Elementor hooks for widgets and controls registration 22 add_action('elementor/widgets/register', [$this, 'on_widgets_register']); 23 add_action('elementor/controls/register', [$this, 'on_controls_register']); 24 25 // Enqueue frontend scripts at the recommended timing 26 add_action('elementor/frontend/after_enqueue_scripts', [$this, 'enqueue_widget_scripts']); 21 27 } 22 28 … … 25 31 } 26 32 27 public function init() {28 // Add Plugin actions29 add_action('elementor/widgets/widgets_registered', [$this, 'init_widgets']);30 add_action('elementor/controls/controls_registered', [$this, 'init_controls']);33 // Register widgets using the new API (>= 3.5) 34 public function on_widgets_register(\Elementor\Widgets_Manager $widgets_manager) { 35 require_once(__DIR__ . '/widgets/widget.php'); 36 $widgets_manager->register(new \Elementor_FIFU_Widget()); 31 37 32 // Register Widget Scripts33 add_action('elementor/frontend/after_register_scripts', [$this, 'widget_scripts']);38 require_once(__DIR__ . '/widgets/widget-video.php'); 39 $widgets_manager->register(new \Elementor_FIFU_Video_Widget()); 34 40 } 35 41 36 public function init_widgets() { 37 // Include Widget files and register widget 38 require_once( __DIR__ . '/widgets/widget.php' ); 39 \Elementor\Plugin::instance()->widgets_manager->register_widget_type(new \Elementor_FIFU_Widget()); 40 41 require_once( __DIR__ . '/widgets/widget-video.php' ); 42 \Elementor\Plugin::instance()->widgets_manager->register_widget_type(new \Elementor_FIFU_Video_Widget()); 42 // Register custom controls if needed 43 public function on_controls_register($controls_manager) { 44 // Add custom controls registration here if needed 43 45 } 44 46 45 public function init_controls() { 46 47 // Enqueue frontend scripts/styles at the recommended hook 48 public function enqueue_widget_scripts() { 49 // Example: wp_enqueue_script('fifu-el-frontend', plugins_url('assets/js/frontend.js', __FILE__), ['elementor-frontend'], '1.0.0', true); 47 50 } 48 49 public function widget_scripts() {50 51 }52 53 51 } 54 52 -
featured-image-from-url/trunk/elementor/widgets/widget-video.php
r2926179 r3352132 20 20 } 21 21 22 protected function _register_controls() {22 protected function register_controls() { 23 23 $strings = fifu_get_strings_elementor(); 24 24 … … 48 48 49 49 } 50 51 50 } 52 51 -
featured-image-from-url/trunk/elementor/widgets/widget.php
r3341179 r3352132 20 20 } 21 21 22 protected function _register_controls() { 22 // Use the current API method name (no underscore) 23 protected function register_controls() { 23 24 $strings = fifu_get_strings_elementor(); 24 25 … … 50 51 'input_type' => 'text', 51 52 'placeholder' => '', 52 'description' => $strings['help']['alt'](), // Add help text here53 'description' => $strings['help']['alt'](), 53 54 ] 54 55 ); … … 70 71 } 71 72 72 function fifu_image_after_save_elementor_data($post_id, $editor_data) { 73 foreach ($editor_data as $data) { 74 if (isset($data['elements'][0]['widgetType'])) { 75 $widgetType = $data['elements'][0]['widgetType']; 76 if (strpos($widgetType, 'fifu') !== false) { 77 $settings = $data['elements'][0]['settings'] ?? []; 73 // Recursively traverse the editor data tree and apply logic to FIFU widgets 74 function fifu_walk_elements_and_apply($elements, $post_id) { 75 if (!is_array($elements)) 76 return; 78 77 79 if ($widgetType == 'fifu-elementor') { 80 if (isset($settings['fifu_input_url'])) { 81 $image_url = $settings['fifu_input_url']; 82 if (filter_var($image_url, FILTER_VALIDATE_URL) === false) 83 $image_url = ''; 84 fifu_dev_set_image($post_id, $image_url); 85 } 86 // Save alternative text 87 if (isset($settings['fifu_input_alt'])) { 88 $alt = esc_html(wp_strip_all_tags($settings['fifu_input_alt'])); 89 fifu_update_or_delete_value($post_id, 'fifu_image_alt', $alt); 78 foreach ($elements as $el) { 79 if ( 80 isset($el['elType']) && $el['elType'] === 'widget' && 81 isset($el['widgetType']) 82 ) { 83 $widgetType = $el['widgetType']; 84 $settings = $el['settings'] ?? []; 85 86 if ($widgetType == 'fifu-elementor') { 87 if (isset($settings['fifu_input_url'])) { 88 $image_url = $settings['fifu_input_url']; 89 if ($image_url && filter_var($image_url, FILTER_VALIDATE_URL) === false) 90 $image_url = ''; 91 fifu_dev_set_image($post_id, $image_url); 92 $att_id = get_post_thumbnail_id($post_id); 93 if ($att_id && $image_url) { 94 $image_sizes = getimagesize($image_url); 95 if ($image_sizes && isset($image_sizes[0], $image_sizes[1])) { 96 fifu_save_dimensions($att_id, $image_sizes[0], $image_sizes[1]); 97 } 90 98 } 91 99 } 100 // Save alternative text 101 if (isset($settings['fifu_input_alt'])) { 102 $alt = esc_html(wp_strip_all_tags($settings['fifu_input_alt'])); 103 fifu_update_or_delete_value($post_id, 'fifu_image_alt', $alt); 104 } 92 105 } 106 } 107 108 // Recursively process child elements 109 if (!empty($el['elements']) && is_array($el['elements'])) { 110 fifu_walk_elements_and_apply($el['elements'], $post_id); 93 111 } 94 112 } 95 113 } 96 114 115 function fifu_image_after_save_elementor_data($post_id, $editor_data) { 116 if (!is_array($editor_data)) 117 return; 118 fifu_walk_elements_and_apply($editor_data, $post_id); 119 } 120 97 121 add_action('elementor/editor/after_save', 'fifu_image_after_save_elementor_data', 10, 2); 98 122 -
featured-image-from-url/trunk/featured-image-from-url.php
r3348282 r3352132 5 5 * Plugin URI: https://fifu.app/ 6 6 * Description: Use remote media as the featured image and beyond. 7 * Version: 5.2. 57 * Version: 5.2.6 8 8 * Author: fifu.app 9 9 * Author URI: https://fifu.app/ 10 10 * WC requires at least: 4.0 11 * WC tested up to: 10.1. 111 * WC tested up to: 10.1.2 12 12 * Text Domain: featured-image-from-url 13 13 * License: GPLv3 -
featured-image-from-url/trunk/includes/attachment.php
r3341179 r3352132 198 198 /* img */ 199 199 200 $buffer = fifu_filter_og_images($buffer); 201 200 202 $srcType = "src"; 201 203 $imgList = array(); … … 407 409 add_action('wp_ajax_get-attachment', 'custom_get_attachment_intercept', 0); 408 410 411 function fifu_filter_og_images($buffer) { 412 // Regex to match FIFU blocks 413 $pattern_blocks = '/<!--\s*FIFU:meta:begin:[a-z]+\s*-->.*?<!--\s*FIFU:meta:end:[a-z]+\s*-->/is'; 414 415 // Extract all FIFU blocks 416 $blocks = []; 417 if (preg_match_all($pattern_blocks, $buffer, $matches, PREG_OFFSET_CAPTURE)) { 418 foreach ($matches[0] as $match) { 419 $blocks[] = $match[0]; 420 } 421 } 422 423 // Check if there is at least one og:image inside any FIFU block 424 $has_fifu_ogimage = false; 425 foreach ($blocks as $block) { 426 if (preg_match('/<meta\s+[^>]*property=["\']og:image[^"\']*["\']/i', $block)) { 427 $has_fifu_ogimage = true; 428 break; 429 } 430 } 431 432 // If no og:image was found inside FIFU blocks, return original buffer 433 if (!$has_fifu_ogimage) { 434 return $buffer; 435 } 436 437 // Otherwise, protect blocks and remove unwanted tags outside them 438 $buffer_preserve = $buffer; 439 foreach ($blocks as $i => $block) { 440 $buffer_preserve = str_replace($block, "___FIFU_BLOCK_" . ($i + 1) . "___", $buffer_preserve); 441 } 442 443 // Remove ALL <meta property="og:image..."> tags outside FIFU blocks 444 $buffer_preserve = preg_replace('/<meta\s+[^>]*property=["\']og:image[^"\']*["\'][^>]*>\s*/i', '', $buffer_preserve); 445 446 // Remove ALL <meta name="twitter:image..."> tags outside FIFU blocks 447 $buffer_preserve = preg_replace('/<meta\s+[^>]*name=["\']twitter:image[^"\']*["\'][^>]*>\s*/i', '', $buffer_preserve); 448 449 // Restore preserved FIFU blocks in their original positions 450 foreach ($blocks as $i => $block) { 451 $buffer_preserve = str_replace("___FIFU_BLOCK_" . ($i + 1) . "___", $block, $buffer_preserve); 452 } 453 454 return $buffer_preserve; 455 } 456 -
featured-image-from-url/trunk/includes/html/js/json-ld.js
r3089471 r3352132 1 1 (function () { 2 2 if (typeof fifuJsonLd !== 'undefined' && fifuJsonLd.url) { 3 // Map string/objects to ImageObject with @id and url; dedup per list 4 function toImageObjects(img) { 5 var arr = Array.isArray(img) ? img : (img ? [img] : []); 6 var out = []; 7 var seen = Object.create(null); 8 9 for (var i = 0; i < arr.length; i++) { 10 var it = arr[i]; 11 if (!it) 12 continue; 13 14 if (typeof it === 'string') { 15 if (seen[it]) 16 continue; 17 seen[it] = 1; 18 out.push({ 19 "@type": "ImageObject", 20 "@id": it, 21 "url": it 22 }); 23 } else if (typeof it === 'object') { 24 // If already an object, ensure it has @type/@id/url 25 var id = it['@id'] || it.url; 26 if (!id) 27 continue; 28 if (seen[id]) 29 continue; 30 seen[id] = 1; 31 32 var obj = {}; 33 for (var k in it) 34 if (Object.prototype.hasOwnProperty.call(it, k)) 35 obj[k] = it[k]; 36 obj['@type'] = obj['@type'] || 'ImageObject'; 37 obj['@id'] = id; 38 obj['url'] = obj['url'] || id; 39 out.push(obj); 40 } 41 } 42 return out; 43 } 44 3 45 var jsonData = { 4 "@context": "http://schema.org", 5 "@type": "ImageObject", 6 "url": fifuJsonLd.url, 7 "image": fifuJsonLd.url 46 "@context": fifuJsonLd["@context"], 47 "@type": fifuJsonLd["@type"], 48 "url": fifuJsonLd.url 8 49 }; 9 50 10 // Create a script element for the JSON-LD structured data 51 // Product-level images -> ImageObject[] 52 if (fifuJsonLd.image) { 53 jsonData.image = toImageObjects(fifuJsonLd.image); 54 } 55 56 if (fifuJsonLd.headline) { 57 jsonData.headline = fifuJsonLd.headline; // BlogPosting 58 } 59 60 if (fifuJsonLd.name) { 61 jsonData.name = fifuJsonLd.name; // Product 62 } 63 64 var commentBegin = document.createComment(' FIFU:jsonld:begin'); 65 document.head.appendChild(commentBegin); 66 11 67 var script = document.createElement('script'); 12 68 script.type = 'application/ld+json'; 13 69 script.textContent = JSON.stringify(jsonData); 14 70 document.head.appendChild(script); 71 72 var commentEnd = document.createComment(' FIFU:jsonld:end'); 73 document.head.appendChild(commentEnd); 15 74 } 16 75 })(); -
featured-image-from-url/trunk/includes/html/og-image.html
r2932443 r3352132 1 <!-- FIFU: meta tags for featured image (begin)-->1 <!-- FIFU:meta:begin:image --> 2 2 <meta property="og:image" content="<?php echo $url ?>" /> 3 <!-- FIFU: meta tags for featured image (end)-->3 <!-- FIFU:meta:end:image --> -
featured-image-from-url/trunk/includes/html/social-home.html
r3024872 r3352132 1 <!-- FIFU: meta tags for home (begin)-->1 <!-- FIFU:meta:begin:home --> 2 2 <meta property="og:image" content="<?php echo $url ?>" /> 3 <!-- FIFU: meta tags for home (end)-->3 <!-- FIFU:meta:end:home --> -
featured-image-from-url/trunk/includes/html/twitter-image.html
r2295697 r3352132 1 <!-- FIFU:meta:begin:twitter --> 1 2 <meta name="twitter:image" content="<?php echo $url ?>" /> 3 <!-- FIFU:meta:end:twitter --> -
featured-image-from-url/trunk/includes/thumbnail.php
r3344902 r3352132 91 91 $description = str_replace("'", "'", wp_strip_all_tags(get_post_field('post_excerpt', $post_id))); 92 92 93 $arr = array($url); 94 95 // https://search.google.com/test/rich-results 96 // Add JSON-LD for WordPress posts and products 97 $type = get_post_type($post_id); 98 if (is_singular($type)) { 99 wp_enqueue_script('fifu-json-ld', plugins_url('/html/js/json-ld.js', __FILE__), array(), fifu_version_number_enq()); 100 $json_ld = [ 101 "@context" => "https://schema.org", 102 "url" => get_permalink($post_id), 103 "image" => $arr, 104 ]; 105 if ($type === 'product') { 106 $json_ld["@type"] = "Product"; 107 $json_ld["name"] = get_the_title($post_id); 108 } else { 109 $json_ld["@type"] = "BlogPosting"; 110 $json_ld["headline"] = get_the_title($post_id); 111 } 112 wp_localize_script('fifu-json-ld', 'fifuJsonLd', $json_ld); 113 } 114 93 115 if ($url) { 94 116 if (fifu_is_from_speedup($url)) … … 98 120 } 99 121 include 'html/og-image.html'; 100 101 wp_enqueue_script('fifu-json-ld', plugins_url('/html/js/json-ld.js', __FILE__), array(), fifu_version_number_enq());102 wp_localize_script('fifu-json-ld', 'fifuJsonLd', [103 'url' => $url,104 ]);105 122 } 106 123 -
featured-image-from-url/trunk/readme.txt
r3348282 r3352132 5 5 Requires at least: 5.6 6 6 Tested up to: 6.8.2 7 Stable tag: 5.2. 57 Stable tag: 5.2.6 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 247 247 == Changelog == 248 248 249 = 5.2.6 = 250 * Enhancement: improved integration with Rich Results from Google; Enhancement: alternative text can now be displayed as captions at the bottom of the image; Fix: images defined by other plugins were being displayed on social media instead of the remote featured image; Fix: Elementor widget not working with newer Elementor versions. 251 249 252 = 5.2.5 = 250 253 * Enhancement: Improved translations and support for 40 new languages; Enhancement: Alternative Text field now opens in the lightbox for easier editing; Enhancement: Redirects to the plugin settings after activation; Fix: Quick Edit not working for variable products with multiple attributes; Fix: Google Drive images not displaying in the admin area. … … 277 280 == Upgrade Notice == 278 281 279 = 5.2. 5=280 * Enhancement: Improved translations and support for 40 new languages; Enhancement: Alternative Text field now opens in the lightbox for easier editing; Enhancement: Redirects to the plugin settings after activation; Fix: Quick Edit not working for variable products with multiple attributes; Fix: Google Drive images not displaying in the admin area.282 = 5.2.6 = 283 * Enhancement: improved integration with Rich Results from Google; Enhancement: alternative text can now be displayed as captions at the bottom of the image; Fix: images defined by other plugins were being displayed on social media instead of the remote featured image; Fix: Elementor widget not working with newer Elementor versions.
Note: See TracChangeset
for help on using the changeset viewer.