Featured Image From URL - Version 4.2.2

Version Description

  • Enhancement: FIFU Cloud (supports automatic uploads now); deprecated: Category Image on Grid.
Download this release

Release Info

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

Code changes from version 4.2.1 to 4.2.2

admin/api.php CHANGED
@@ -300,18 +300,44 @@ function fifu_api_create_thumbnails_list(WP_REST_Request $request) {
300
  if (!fifu_su_sign_up_complete())
301
  return json_decode(FIFU_NO_CREDENTIALS);
302
 
303
- $rows = array();
304
  $images = $request['selected'];
305
  $tfa = $request['tfa'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  $total = count($images);
307
  $url_sign = '';
308
  foreach ($images as $image) {
309
- $post_id = $image[0];
310
- $url = $image[1];
311
- $meta_key = $image[2];
312
- $meta_id = $image[3];
313
- $is_category = $image[4] == 1;
314
- $video_url = $image[5];
 
 
 
 
 
 
 
 
 
 
 
315
 
316
  if (!$url || !$post_id)
317
  continue;
@@ -336,6 +362,7 @@ function fifu_api_create_thumbnails_list(WP_REST_Request $request) {
336
  'signature' => $signature,
337
  'time' => $time,
338
  'ip' => $ip,
 
339
  'slug' => FIFU_CLIENT,
340
  'version' => fifu_version_number()
341
  )
@@ -632,6 +659,56 @@ function fifu_api_list_daily_count(WP_REST_Request $request) {
632
  return $json;
633
  }
634
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  function fifu_api_query($dataset) {
636
  $requests = array();
637
 
@@ -1084,6 +1161,11 @@ add_action('rest_api_init', function () {
1084
  'callback' => 'fifu_api_payment_info',
1085
  'permission_callback' => 'fifu_get_private_data_permissions_check',
1086
  ));
 
 
 
 
 
1087
  });
1088
 
1089
  function fifu_get_private_data_permissions_check() {
300
  if (!fifu_su_sign_up_complete())
301
  return json_decode(FIFU_NO_CREDENTIALS);
302
 
 
303
  $images = $request['selected'];
304
  $tfa = $request['tfa'];
305
+
306
+ return fifu_create_thumbnails_list($images, $tfa, false);
307
+ }
308
+
309
+ function fifu_create_thumbnails_list($images, $tfa = null, $cron = false) {
310
+ if (!fifu_su_sign_up_complete())
311
+ return json_decode(FIFU_NO_CREDENTIALS);
312
+
313
+ if ($cron) {
314
+ $code = get_option('fifu_cloud_upload_auto_code');
315
+ if (!$code)
316
+ return json_decode(FIFU_NO_CREDENTIALS);
317
+ $tfa = $code[0];
318
+ }
319
+
320
+ $rows = array();
321
  $total = count($images);
322
  $url_sign = '';
323
  foreach ($images as $image) {
324
+ if (!$cron) {
325
+ // manual
326
+ $post_id = $image[0];
327
+ $url = $image[1];
328
+ $meta_key = $image[2];
329
+ $meta_id = $image[3];
330
+ $is_category = $image[4] == 1;
331
+ $video_url = $image[5];
332
+ } else {
333
+ // upload auto
334
+ $post_id = $image->post_id;
335
+ $url = $image->url;
336
+ $meta_key = $image->meta_key;
337
+ $meta_id = $image->meta_id;
338
+ $is_category = $image->category == 1;
339
+ $video_url = $image->video_url;
340
+ }
341
 
342
  if (!$url || !$post_id)
343
  continue;
362
  'signature' => $signature,
363
  'time' => $time,
364
  'ip' => $ip,
365
+ 'upload_auto' => $cron,
366
  'slug' => FIFU_CLIENT,
367
  'version' => fifu_version_number()
368
  )
659
  return $json;
660
  }
661
 
662
+ function fifu_api_cloud_upload_auto(WP_REST_Request $request) {
663
+ if (!fifu_su_sign_up_complete())
664
+ return json_decode(FIFU_NO_CREDENTIALS);
665
+
666
+ $email = fifu_su_get_email();
667
+ $site = fifu_get_home_url();
668
+ $tfa = $request['tfa'];
669
+ $ip = fifu_get_ip();
670
+ $time = time();
671
+ $signature = fifu_create_signature($site . $email . $time . $ip . $tfa);
672
+
673
+ $enabled = $request['toggle'] == 'toggleon';
674
+
675
+ fifu_cloud_log(['cloud_upload_auto' => ['site' => $site]]);
676
+
677
+ $array = array(
678
+ 'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
679
+ 'body' => json_encode(
680
+ array(
681
+ 'site' => $site,
682
+ 'email' => $email,
683
+ 'signature' => $signature,
684
+ 'time' => $time,
685
+ 'ip' => $ip,
686
+ 'enabled' => $enabled,
687
+ 'slug' => FIFU_CLIENT,
688
+ 'version' => fifu_version_number()
689
+ )
690
+ ),
691
+ 'method' => 'POST',
692
+ 'data_format' => 'body',
693
+ 'blocking' => true,
694
+ 'timeout' => 30,
695
+ );
696
+
697
+ $response = fifu_remote_post(FIFU_SU_ADDRESS . '/upload-auto/', $array);
698
+ if (is_wp_error($response))
699
+ return json_decode(FIFU_TRY_AGAIN_LATER);
700
+
701
+ $json = json_decode($response['http_response']->get_response_object()->body);
702
+ $upload_auto_code = $json->upload_auto_code;
703
+
704
+ if ($enabled)
705
+ update_option('fifu_cloud_upload_auto_code', array($upload_auto_code));
706
+ else
707
+ delete_option('fifu_cloud_upload_auto_code');
708
+
709
+ return $json;
710
+ }
711
+
712
  function fifu_api_query($dataset) {
713
  $requests = array();
714
 
1161
  'callback' => 'fifu_api_payment_info',
1162
  'permission_callback' => 'fifu_get_private_data_permissions_check',
1163
  ));
1164
+ register_rest_route('featured-image-from-url/v2', '/cloud_upload_auto/', array(
1165
+ 'methods' => 'POST',
1166
+ 'callback' => 'fifu_api_cloud_upload_auto',
1167
+ 'permission_callback' => 'fifu_get_private_data_permissions_check',
1168
+ ));
1169
  });
1170
 
1171
  function fifu_get_private_data_permissions_check() {
admin/cli-commands.php CHANGED
@@ -352,17 +352,6 @@ class fifu_cli extends WP_CLI_Command {
352
  }
353
  return;
354
  }
355
- if (!empty($assoc_args['category-grid'])) {
356
- switch ($args[0]) {
357
- case 'on':
358
- update_option('fifu_grid_category', 'toggleon', 'no'); // toggle
359
- break;
360
- case 'off':
361
- update_option('fifu_grid_category', 'toggleoff', 'no'); // toggle
362
- break;
363
- }
364
- return;
365
- }
366
  }
367
 
368
  }
352
  }
353
  return;
354
  }
 
 
 
 
 
 
 
 
 
 
 
355
  }
356
 
357
  }
admin/cron.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function fifu_add_cron_schedules($schedules) {
4
+ if (!isset($schedules["fifu_schedule_cloud_upload_auto"])) {
5
+ $schedules['fifu_schedule_cloud_upload_auto'] = array(
6
+ 'interval' => 2 * 60,
7
+ 'display' => __('fifu-cloud-upload-auto')
8
+ );
9
+ }
10
+ return $schedules;
11
+ }
12
+
13
+ add_filter('cron_schedules', 'fifu_add_cron_schedules');
14
+
15
+ function fifu_create_cloud_upload_auto_hook() {
16
+ if (fifu_active_job('fifu_cloud_upload_auto_semaphore', 5))
17
+ return;
18
+
19
+ $urls = fifu_db_get_all_urls(0);
20
+ fifu_create_thumbnails_list($urls, null, true);
21
+
22
+ delete_transient('fifu_cloud_upload_auto_semaphore');
23
+ }
24
+
25
+ add_action('fifu_create_cloud_upload_auto_event', 'fifu_create_cloud_upload_auto_hook');
26
+
27
+ function fifu_active_job($semaphore, $minutes) {
28
+ $date = get_transient($semaphore);
29
+ if (!$date)
30
+ return false;
31
+
32
+ if (gettype($date) != 'object') {
33
+ set_transient($semaphore, new DateTime(), 0);
34
+ return true;
35
+ }
36
+
37
+ return date_diff(new DateTime(), $date)->format('%i') < $minutes;
38
+ }
39
+
40
+ function fifu_stop_job($option_name) {
41
+ $field = $option_name . '_stop';
42
+ update_option($field, true, 'no');
43
+ }
44
+
45
+ function fifu_should_stop_job($option_name) {
46
+ $field = $option_name . '_stop';
47
+
48
+ global $wpdb;
49
+ if ($wpdb->get_col("SELECT option_value FROM " . $wpdb->options . " WHERE option_name = '" . $field . "'")) {
50
+ delete_option($field);
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+
56
+ function fifu_run_cron_now() {
57
+ wp_remote_request(site_url('wp-cron.php'));
58
+ }
59
+
admin/db.php CHANGED
@@ -593,6 +593,7 @@ class FifuDb {
593
  INNER JOIN " . $this->posts . " p ON pm.post_id = p.id
594
  WHERE pm.meta_key = 'fifu_image_url'
595
  AND pm.meta_value NOT LIKE '%https://cdn.fifu.app/%'
 
596
  AND p.post_status <> 'trash'
597
  )
598
  ";
@@ -605,6 +606,7 @@ class FifuDb {
605
  INNER JOIN " . $this->terms . " t ON tm.term_id = t.term_id
606
  WHERE tm.meta_key IN ('fifu_image_url')
607
  AND tm.meta_value NOT LIKE '%https://cdn.fifu.app/%'
 
608
  )
609
  ";
610
  }
593
  INNER JOIN " . $this->posts . " p ON pm.post_id = p.id
594
  WHERE pm.meta_key = 'fifu_image_url'
595
  AND pm.meta_value NOT LIKE '%https://cdn.fifu.app/%'
596
+ AND pm.meta_value NOT LIKE 'http://localhost/%'
597
  AND p.post_status <> 'trash'
598
  )
599
  ";
606
  INNER JOIN " . $this->terms . " t ON tm.term_id = t.term_id
607
  WHERE tm.meta_key IN ('fifu_image_url')
608
  AND tm.meta_value NOT LIKE '%https://cdn.fifu.app/%'
609
+ AND tm.meta_value NOT LIKE 'http://localhost/%'
610
  )
611
  ";
612
  }
admin/html/cloud.html CHANGED
@@ -558,6 +558,46 @@
558
  </tr>
559
  </table>
560
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
561
  </div>
562
  </div>
563
  </div>
558
  </tr>
559
  </table>
560
  </div>
561
+
562
+ <div id="upload-auto-box">
563
+ <br>
564
+ <div style="background: white; padding: 10px; border-radius: 1em;">
565
+ <div style="background-color:#32373c; text-align:center; width:98%; color:white; padding:6px; border-radius:5px;">
566
+ <b><?php $fifucloud['upload']['automatic']['title']() ?></b>
567
+ </div>
568
+ <table style="text-align:left; width:100%">
569
+
570
+ <tr class="color">
571
+ <th style="width:20px;">
572
+ <form
573
+ id="fifu_form_cloud_upload_auto"
574
+ action="javascript:void(0)"
575
+ method="post">
576
+ <?php wp_nonce_field(FIFU_ACTION_CLOUD, 'nonce_fifu_form_cloud_upload_auto'); ?>
577
+ <input
578
+ type="submit"
579
+ href="javascript:void(0)"
580
+ id="fifu_toggle_cloud_upload_auto"
581
+ onclick="invert('cloud_upload_auto');set_upload_auto()"
582
+ name="fifu_toggle_cloud_upload_auto"
583
+ class="<?php echo $enable_cloud_upload_auto; ?>"
584
+ value=""
585
+ style="display:block;border:none">
586
+
587
+ <input
588
+ type="hidden"
589
+ id="fifu_input_cloud_upload_auto"
590
+ name="fifu_input_cloud_upload_auto"
591
+ value="" >
592
+ </form>
593
+ </th>
594
+ <th>
595
+ <?php $fifucloud['upload']['automatic']['desc']() ?>
596
+ </th>
597
+ </tr>
598
+ </table>
599
+ </div>
600
+ </div>
601
  </div>
602
  </div>
603
  </div>
admin/html/js/cloud.js CHANGED
@@ -31,3 +31,41 @@ jQuery(function () {
31
  window.scrollTo(0, 0);
32
  jQuery('.wrap').css('opacity', 1);
33
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  window.scrollTo(0, 0);
32
  jQuery('.wrap').css('opacity', 1);
33
  });
34
+
35
+ function invert(id) {
36
+ if (jQuery("#fifu_toggle_" + id).attr("class") == "toggleon") {
37
+ jQuery("#fifu_toggle_" + id).attr("class", "toggleoff");
38
+ jQuery("#fifu_input_" + id).val('off');
39
+ } else {
40
+ jQuery("#fifu_toggle_" + id).attr("class", "toggleon");
41
+ jQuery("#fifu_input_" + id).val('on');
42
+ }
43
+ }
44
+
45
+ jQuery(function () {
46
+ var url = window.location.href;
47
+
48
+ //forms with id started by...
49
+ jQuery("form[id^=fifu_form]").each(function (i, el) {
50
+ //onchange
51
+ jQuery(this).change(function () {
52
+ save(this);
53
+ });
54
+ //onsubmit
55
+ jQuery(this).submit(function () {
56
+ save(this);
57
+ });
58
+ });
59
+ });
60
+
61
+ function save(formName, url) {
62
+ var frm = jQuery(formName);
63
+ jQuery.ajax({
64
+ type: frm.attr('method'),
65
+ url: url,
66
+ data: frm.serialize(),
67
+ success: function (data) {
68
+ //alert('saved');
69
+ }
70
+ });
71
+ }
admin/html/js/menu-su.js CHANGED
@@ -821,6 +821,7 @@ function fifu_show_login() {
821
  jQuery("#payment-info-box").hide();
822
  jQuery("#cancel-box").hide();
823
  jQuery("#su_login_2fa").val('');
 
824
  }
825
 
826
  function fifu_hide_log_in() {
@@ -828,6 +829,7 @@ function fifu_hide_log_in() {
828
  jQuery("#log-out-box").show();
829
  jQuery("#payment-info-box").show();
830
  jQuery("#cancel-box").show();
 
831
  }
832
 
833
  function fifu_disable_edition_buttons() {
@@ -1024,3 +1026,36 @@ function listDailyCount() {
1024
  }
1025
  });
1026
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
821
  jQuery("#payment-info-box").hide();
822
  jQuery("#cancel-box").hide();
823
  jQuery("#su_login_2fa").val('');
824
+ jQuery("#upload-auto-box").hide();
825
  }
826
 
827
  function fifu_hide_log_in() {
829
  jQuery("#log-out-box").show();
830
  jQuery("#payment-info-box").show();
831
  jQuery("#cancel-box").show();
832
+ jQuery("#upload-auto-box").show();
833
  }
834
 
835
  function fifu_disable_edition_buttons() {
1026
  }
1027
  });
1028
  }
1029
+
1030
+ function set_upload_auto() {
1031
+ toggle = jQuery("#fifu_toggle_cloud_upload_auto").attr('class');
1032
+
1033
+ var code = null;
1034
+
1035
+ fifu_block();
1036
+
1037
+ jQuery.ajax({
1038
+ method: "POST",
1039
+ url: restUrl + 'featured-image-from-url/v2/cloud_upload_auto/',
1040
+ data: {
1041
+ "tfa": Cookies.get('fifu-tfa'),
1042
+ "toggle": toggle,
1043
+ },
1044
+ async: true,
1045
+ beforeSend: function (xhr) {
1046
+ xhr.setRequestHeader('X-WP-Nonce', fifuScriptVars.nonce);
1047
+ },
1048
+ success: function (data) {
1049
+ code = data['code'];
1050
+ },
1051
+ error: function (jqXHR, textStatus, errorThrown) {
1052
+ console.log(jqXHR);
1053
+ console.log(textStatus);
1054
+ console.log(errorThrown);
1055
+ },
1056
+ complete: function (data) {
1057
+ fifu_unblock();
1058
+ }
1059
+ });
1060
+ return code;
1061
+ }
admin/html/menu.html CHANGED
@@ -1954,21 +1954,6 @@
1954
  on, off
1955
  </th>
1956
  </tr>
1957
- <tr class="color">
1958
- <th>
1959
- <?php $fifu['tab']['woo']() ?>
1960
- </th>
1961
- <th>
1962
- <?php $fifu['title']['grid']() ?>
1963
- </th>
1964
- <th></th>
1965
- <th>
1966
- wp fifu woo --category-grid &lt;toggle&gt;
1967
- </th>
1968
- <th>
1969
- on, off
1970
- </th>
1971
- </tr>
1972
  <tr class="color">
1973
  <th>
1974
  <?php $fifu['tab']['woo']() ?>
@@ -5148,41 +5133,6 @@
5148
  </table>
5149
  </div>
5150
 
5151
- <div class="box">
5152
- <h2><?php $fifu['title']['grid']() ?></h2>
5153
- <div class="greybox">
5154
- <?php $fifu['grid']['desc']() ?>
5155
- </div>
5156
- <br>
5157
- <table style="text-align:left">
5158
- <tr>
5159
- <th>
5160
- <form
5161
- id="fifu_form_grid_category"
5162
- action="javascript:void(0)"
5163
- method="post">
5164
- <?php wp_nonce_field(FIFU_ACTION_SETTINGS, 'nonce_fifu_form_grid_category'); ?>
5165
- <input
5166
- type="submit"
5167
- href="javascript:void(0)"
5168
- id="fifu_toggle_grid_category"
5169
- onclick="invert('grid_category')"
5170
- name="fifu_toggle_grid_category"
5171
- class="<?php echo $enable_grid_category; ?>"
5172
- value=""
5173
- style="display:block;border:none">
5174
-
5175
- <input
5176
- type="hidden"
5177
- id="fifu_input_grid_category"
5178
- name="fifu_input_grid_category"
5179
- value="" >
5180
- </form>
5181
- </th>
5182
- </tr>
5183
- </table>
5184
- </div>
5185
-
5186
  <div class="box">
5187
  <div class="fifu-pro"><a class="fifu-pro-link" href="https://fifu.app/" target="_blank" title="Unlock all PRO features"><span class="dashicons dashicons-lock fifu-pro-icon"></span></a></div>
5188
  <h2><?php $fifu['title']['import']() ?></h2>
1954
  on, off
1955
  </th>
1956
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1957
  <tr class="color">
1958
  <th>
1959
  <?php $fifu['tab']['woo']() ?>
5133
  </table>
5134
  </div>
5135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5136
  <div class="box">
5137
  <div class="fifu-pro"><a class="fifu-pro-link" href="https://fifu.app/" target="_blank" title="Unlock all PRO features"><span class="dashicons dashicons-lock fifu-pro-icon"></span></a></div>
5138
  <h2><?php $fifu['title']['import']() ?></h2>
admin/menu.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
 
3
- define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_skip', 'fifu_html_cpt', 'fifu_lazy', 'fifu_photon', 'fifu_cdn_social', 'fifu_cdn_crop', 'fifu_cdn_content', 'fifu_reset', 'fifu_content', 'fifu_content_page', 'fifu_content_cpt', 'fifu_enable_default_url', 'fifu_spinner_nth', 'fifu_fake', 'fifu_default_url', 'fifu_default_cpt', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_run_delete_all', 'fifu_decode', 'fifu_check', 'fifu_grid_category', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean')));
4
  define('FIFU_ACTION_SETTINGS', '/wp-admin/admin.php?page=featured-image-from-url');
 
5
 
6
  define('FIFU_SLUG', 'featured-image-from-url');
7
 
@@ -70,7 +71,24 @@ function fifu_cloud() {
70
  'availableImages' => fifu_db_count_available_images(),
71
  ]);
72
 
 
 
73
  include 'html/cloud.html';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
  function fifu_troubleshooting() {
@@ -130,10 +148,10 @@ function fifu_support_data() {
130
  $enable_run_delete_all_time = get_option('fifu_run_delete_all_time');
131
  $enable_decode = get_option('fifu_decode');
132
  $enable_check = get_option('fifu_check');
133
- $enable_grid_category = get_option('fifu_grid_category');
134
  $enable_auto_alt = get_option('fifu_auto_alt');
135
  $enable_dynamic_alt = get_option('fifu_dynamic_alt');
136
  $enable_data_clean = 'toggleoff';
 
137
 
138
  include 'html/support-data.html';
139
  }
@@ -142,6 +160,7 @@ function fifu_get_menu_html() {
142
  flush();
143
 
144
  $fifu = fifu_get_strings_settings();
 
145
 
146
  // css and js
147
  wp_enqueue_style('fifu-base-ui-css', plugins_url('/html/css/base-ui.css', __FILE__), array(), fifu_version_number());
@@ -187,7 +206,6 @@ function fifu_get_menu_html() {
187
  $enable_run_delete_all_time = get_option('fifu_run_delete_all_time');
188
  $enable_decode = get_option('fifu_decode');
189
  $enable_check = get_option('fifu_check');
190
- $enable_grid_category = get_option('fifu_grid_category');
191
  $enable_auto_alt = get_option('fifu_auto_alt');
192
  $enable_dynamic_alt = get_option('fifu_dynamic_alt');
193
  $enable_data_clean = 'toggleoff';
@@ -350,9 +368,6 @@ function fifu_update_menu_options() {
350
  if (fifu_is_valid_nonce('nonce_fifu_form_check'))
351
  fifu_update_option('fifu_input_check', 'fifu_check');
352
 
353
- if (fifu_is_valid_nonce('nonce_fifu_form_grid_category'))
354
- fifu_update_option('fifu_input_grid_category', 'fifu_grid_category');
355
-
356
  if (fifu_is_valid_nonce('nonce_fifu_form_auto_alt'))
357
  fifu_update_option('fifu_input_auto_alt', 'fifu_auto_alt');
358
 
@@ -389,7 +404,7 @@ function fifu_update_option($input, $field) {
389
 
390
  $value = $_POST[$input];
391
 
392
- $arr_boolean = array('fifu_auto_alt', 'fifu_cdn_content', 'fifu_cdn_crop', 'fifu_cdn_social', 'fifu_check', 'fifu_content', 'fifu_content_cpt', 'fifu_content_page', 'fifu_data_clean', 'fifu_decode', 'fifu_dynamic_alt', 'fifu_enable_default_url', 'fifu_fake', 'fifu_get_first', 'fifu_grid_category', 'fifu_hide_cpt', 'fifu_hide_page', 'fifu_hide_post', 'fifu_lazy', 'fifu_ovw_first', 'fifu_photon', 'fifu_pop_first', 'fifu_query_strings', 'fifu_reset', 'fifu_run_delete_all', 'fifu_social', 'fifu_social_image_only', 'fifu_wc_lbox', 'fifu_wc_zoom');
393
  if (in_array($field, $arr_boolean)) {
394
  if (in_array($value, array('on', 'off')))
395
  update_option($field, 'toggle' . $value);
@@ -487,7 +502,7 @@ function fifu_number_of_users() {
487
  return count_users()['total_users'];
488
  }
489
 
490
- function fifu_is_valid_nonce($nonce) {
491
- return isset($_POST[$nonce]) && wp_verify_nonce($_POST[$nonce], FIFU_ACTION_SETTINGS);
492
  }
493
 
1
  <?php
2
 
3
+ define('FIFU_SETTINGS', serialize(array('fifu_social', 'fifu_social_image_only', 'fifu_skip', 'fifu_html_cpt', 'fifu_lazy', 'fifu_photon', 'fifu_cdn_social', 'fifu_cdn_crop', 'fifu_cdn_content', 'fifu_reset', 'fifu_content', 'fifu_content_page', 'fifu_content_cpt', 'fifu_enable_default_url', 'fifu_spinner_nth', 'fifu_fake', 'fifu_default_url', 'fifu_default_cpt', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_hide_page', 'fifu_hide_post', 'fifu_hide_cpt', 'fifu_get_first', 'fifu_pop_first', 'fifu_ovw_first', 'fifu_query_strings', 'fifu_run_delete_all', 'fifu_decode', 'fifu_check', 'fifu_auto_alt', 'fifu_dynamic_alt', 'fifu_data_clean', 'fifu_cloud_upload_auto')));
4
  define('FIFU_ACTION_SETTINGS', '/wp-admin/admin.php?page=featured-image-from-url');
5
+ define('FIFU_ACTION_CLOUD', '/wp-admin/admin.php?page=fifu-cloud');
6
 
7
  define('FIFU_SLUG', 'featured-image-from-url');
8
 
71
  'availableImages' => fifu_db_count_available_images(),
72
  ]);
73
 
74
+ $enable_cloud_upload_auto = get_option('fifu_cloud_upload_auto');
75
+
76
  include 'html/cloud.html';
77
+
78
+ if (fifu_is_valid_nonce('nonce_fifu_form_cloud_upload_auto', FIFU_ACTION_CLOUD))
79
+ fifu_update_option('fifu_input_cloud_upload_auto', 'fifu_cloud_upload_auto');
80
+
81
+ // schedule upload
82
+ if (fifu_is_on('fifu_cloud_upload_auto')) {
83
+ if (!wp_next_scheduled('fifu_create_cloud_upload_auto_event')) {
84
+ wp_schedule_event(time(), 'fifu_schedule_cloud_upload_auto', 'fifu_create_cloud_upload_auto_event');
85
+ fifu_run_cron_now();
86
+ }
87
+ } else {
88
+ wp_clear_scheduled_hook('fifu_create_cloud_upload_auto_event');
89
+ delete_transient('fifu_cloud_upload_auto_semaphore');
90
+ fifu_stop_job('fifu_cloud_upload_auto');
91
+ }
92
  }
93
 
94
  function fifu_troubleshooting() {
148
  $enable_run_delete_all_time = get_option('fifu_run_delete_all_time');
149
  $enable_decode = get_option('fifu_decode');
150
  $enable_check = get_option('fifu_check');
 
151
  $enable_auto_alt = get_option('fifu_auto_alt');
152
  $enable_dynamic_alt = get_option('fifu_dynamic_alt');
153
  $enable_data_clean = 'toggleoff';
154
+ $enable_cloud_upload_auto = get_option('fifu_cloud_upload_auto');
155
 
156
  include 'html/support-data.html';
157
  }
160
  flush();
161
 
162
  $fifu = fifu_get_strings_settings();
163
+ $fifucloud = fifu_get_strings_cloud();
164
 
165
  // css and js
166
  wp_enqueue_style('fifu-base-ui-css', plugins_url('/html/css/base-ui.css', __FILE__), array(), fifu_version_number());
206
  $enable_run_delete_all_time = get_option('fifu_run_delete_all_time');
207
  $enable_decode = get_option('fifu_decode');
208
  $enable_check = get_option('fifu_check');
 
209
  $enable_auto_alt = get_option('fifu_auto_alt');
210
  $enable_dynamic_alt = get_option('fifu_dynamic_alt');
211
  $enable_data_clean = 'toggleoff';
368
  if (fifu_is_valid_nonce('nonce_fifu_form_check'))
369
  fifu_update_option('fifu_input_check', 'fifu_check');
370
 
 
 
 
371
  if (fifu_is_valid_nonce('nonce_fifu_form_auto_alt'))
372
  fifu_update_option('fifu_input_auto_alt', 'fifu_auto_alt');
373
 
404
 
405
  $value = $_POST[$input];
406
 
407
+ $arr_boolean = array('fifu_auto_alt', 'fifu_cdn_content', 'fifu_cdn_crop', 'fifu_cdn_social', 'fifu_check', 'fifu_content', 'fifu_content_cpt', 'fifu_content_page', 'fifu_data_clean', 'fifu_decode', 'fifu_dynamic_alt', 'fifu_enable_default_url', 'fifu_fake', 'fifu_get_first', 'fifu_hide_cpt', 'fifu_hide_page', 'fifu_hide_post', 'fifu_lazy', 'fifu_ovw_first', 'fifu_photon', 'fifu_pop_first', 'fifu_query_strings', 'fifu_reset', 'fifu_run_delete_all', 'fifu_social', 'fifu_social_image_only', 'fifu_wc_lbox', 'fifu_wc_zoom', 'fifu_cloud_upload_auto');
408
  if (in_array($field, $arr_boolean)) {
409
  if (in_array($value, array('on', 'off')))
410
  update_option($field, 'toggle' . $value);
502
  return count_users()['total_users'];
503
  }
504
 
505
+ function fifu_is_valid_nonce($nonce, $action = FIFU_ACTION_SETTINGS) {
506
+ return isset($_POST[$nonce]) && wp_verify_nonce($_POST[$nonce], $action);
507
  }
508
 
admin/strings.php CHANGED
@@ -196,6 +196,9 @@ function fifu_get_strings_settings() {
196
  $fifu['tab']['key'] = function () {
197
  _e("License key", FIFU_SLUG);
198
  };
 
 
 
199
 
200
  // titles
201
  $fifu['title']['support'] = function () {
@@ -339,9 +342,6 @@ function fifu_get_strings_settings() {
339
  $fifu['title']['category'] = function () {
340
  _e("Auto Set Category Images", FIFU_SLUG);
341
  };
342
- $fifu['title']['grid'] = function () {
343
- _e("Category Image on Grid", FIFU_SLUG);
344
- };
345
  $fifu['title']['variable'] = function () {
346
  _e("Variable Product", FIFU_SLUG);
347
  };
@@ -735,7 +735,7 @@ function fifu_get_strings_settings() {
735
 
736
  // block
737
  $fifu['block']['desc'] = function () {
738
- _e("Disable right-click on images.", FIFU_SLUG);
739
  };
740
 
741
  // redirection
@@ -1259,11 +1259,6 @@ function fifu_get_strings_settings() {
1259
  _e("Set one image for each category. The chosen image is the featured image from the most recent product from that category.", FIFU_SLUG);
1260
  };
1261
 
1262
- // grid
1263
- $fifu['grid']['desc'] = function () {
1264
- _e("Show the category image on the category page, immediately before the product grid.", FIFU_SLUG);
1265
- };
1266
-
1267
  // gallery
1268
  $fifu['gallery']['desc'] = function () {
1269
  _e("It is known that some galleries provided by some themes work only when the dimensions of the images are saved in the database, which is often impracticable due to the slowness of this process. So FIFU offers a product gallery that does not depend on the dimensions of the external images to work correctly. You can configure the behavior of this gallery in the \"Featured slider\" tab. To change the aspect ratio, access \"Featured image > Same Height > Size ratio\".", FIFU_SLUG);
@@ -1968,6 +1963,12 @@ function fifu_get_strings_cloud() {
1968
  $fifu['upload']['desc'] = function () {
1969
  _e("When an image is uploaded to the cloud, it starts to generate costs from the uploaded date.");
1970
  };
 
 
 
 
 
 
1971
 
1972
  // delete
1973
  $fifu['delete']['desc'] = function () {
196
  $fifu['tab']['key'] = function () {
197
  _e("License key", FIFU_SLUG);
198
  };
199
+ $fifu['tab']['cloud'] = function () {
200
+ _e("Cloud", FIFU_SLUG);
201
+ };
202
 
203
  // titles
204
  $fifu['title']['support'] = function () {
342
  $fifu['title']['category'] = function () {
343
  _e("Auto Set Category Images", FIFU_SLUG);
344
  };
 
 
 
345
  $fifu['title']['variable'] = function () {
346
  _e("Variable Product", FIFU_SLUG);
347
  };
735
 
736
  // block
737
  $fifu['block']['desc'] = function () {
738
+ _e("Disable right-click on all images.", FIFU_SLUG);
739
  };
740
 
741
  // redirection
1259
  _e("Set one image for each category. The chosen image is the featured image from the most recent product from that category.", FIFU_SLUG);
1260
  };
1261
 
 
 
 
 
 
1262
  // gallery
1263
  $fifu['gallery']['desc'] = function () {
1264
  _e("It is known that some galleries provided by some themes work only when the dimensions of the images are saved in the database, which is often impracticable due to the slowness of this process. So FIFU offers a product gallery that does not depend on the dimensions of the external images to work correctly. You can configure the behavior of this gallery in the \"Featured slider\" tab. To change the aspect ratio, access \"Featured image > Same Height > Size ratio\".", FIFU_SLUG);
1963
  $fifu['upload']['desc'] = function () {
1964
  _e("When an image is uploaded to the cloud, it starts to generate costs from the uploaded date.");
1965
  };
1966
+ $fifu['upload']['automatic']['title'] = function () {
1967
+ _e("Automatic upload");
1968
+ };
1969
+ $fifu['upload']['automatic']['desc'] = function () {
1970
+ _e("uploads external images to the cloud automatically.");
1971
+ };
1972
 
1973
  // delete
1974
  $fifu['delete']['desc'] = function () {
featured-image-from-url.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Featured Image from URL (FIFU)
5
  * Plugin URI: https://fifu.app/
6
  * Description: Use an external image/video/audio as featured image of a post or WooCommerce product.
7
- * Version: 4.2.1
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 4.0
@@ -36,6 +36,7 @@ require_once (FIFU_ADMIN_DIR . '/api.php');
36
  require_once (FIFU_ADMIN_DIR . '/db.php');
37
  require_once (FIFU_ADMIN_DIR . '/category.php');
38
  require_once (FIFU_ADMIN_DIR . '/column.php');
 
39
  require_once (FIFU_ADMIN_DIR . '/log.php');
40
  require_once (FIFU_ADMIN_DIR . '/menu.php');
41
  require_once (FIFU_ADMIN_DIR . '/meta-box.php');
@@ -75,7 +76,7 @@ function fifu_activate_actions() {
75
  register_deactivation_hook(__FILE__, 'fifu_deactivation');
76
 
77
  function fifu_deactivation() {
78
-
79
  }
80
 
81
  add_action('upgrader_process_complete', 'fifu_upgrade', 10, 2);
4
  * Plugin Name: Featured Image from URL (FIFU)
5
  * Plugin URI: https://fifu.app/
6
  * Description: Use an external image/video/audio as featured image of a post or WooCommerce product.
7
+ * Version: 4.2.2
8
  * Author: fifu.app
9
  * Author URI: https://fifu.app/
10
  * WC requires at least: 4.0
36
  require_once (FIFU_ADMIN_DIR . '/db.php');
37
  require_once (FIFU_ADMIN_DIR . '/category.php');
38
  require_once (FIFU_ADMIN_DIR . '/column.php');
39
+ require_once (FIFU_ADMIN_DIR . '/cron.php');
40
  require_once (FIFU_ADMIN_DIR . '/log.php');
41
  require_once (FIFU_ADMIN_DIR . '/menu.php');
42
  require_once (FIFU_ADMIN_DIR . '/meta-box.php');
76
  register_deactivation_hook(__FILE__, 'fifu_deactivation');
77
 
78
  function fifu_deactivation() {
79
+ wp_clear_scheduled_hook('fifu_create_cloud_upload_auto_event');
80
  }
81
 
82
  add_action('upgrader_process_complete', 'fifu_upgrade', 10, 2);
includes/html/js/uninstall.js CHANGED
@@ -76,7 +76,7 @@ jQuery(document).ready(function ($) {
76
  });
77
 
78
  // activating fifu pro
79
- jQuery('a#activate-fifu-premium').click(function (e) {
80
  e.preventDefault();
81
 
82
  jQuery('div#wpwrap').block({message: '', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
@@ -91,6 +91,8 @@ jQuery(document).ready(function ($) {
91
  },
92
  success: function (data) {
93
  href = jQuery('a#activate-fifu-premium').attr('href');
 
 
94
  window.location.href = href;
95
  },
96
  error: function (jqXHR, textStatus, errorThrown) {
76
  });
77
 
78
  // activating fifu pro
79
+ jQuery('a#activate-fifu-premium, a#activate-featured-image-from-url-fifu-premium').click(function (e) {
80
  e.preventDefault();
81
 
82
  jQuery('div#wpwrap').block({message: '', css: {backgroundColor: 'none', border: 'none', color: 'white'}});
91
  },
92
  success: function (data) {
93
  href = jQuery('a#activate-fifu-premium').attr('href');
94
+ if (!href)
95
+ href = jQuery('a#activate-featured-image-from-url-fifu-premium').attr('href');
96
  window.location.href = href;
97
  },
98
  error: function (jqXHR, textStatus, errorThrown) {
includes/jetpack.php CHANGED
@@ -31,7 +31,7 @@ function fifu_jetpack_blocked($url) {
31
  if (fifu_is_photon_url($url))
32
  return true;
33
 
34
- $blocklist = array('localhost', 'amazon-adsystem.com', 'sapo.io', 'i.guim.co.uk', 's.yimg.com', 's1.yimg.com', 'www.washingtonpost.com', 'pbs.twimg.com', 'www.aljazeera.com', 'image.influenster.com', 'api.screenshotmachine.com', 'rackcdn.com', 'googleusercontent.com', 'drive.google.com', 'img.brownsfashion.com', 'accounts.parrotproducts.biz', 'www.dropbox.com', 'fbcdn.net', 'teespring.com', 'nitrocdn.com', 'img.youtube.com', 'cdn.fifu.app', 'cloud.fifu.app', 'images.placeholders.dev');
35
  foreach ($blocklist as $domain) {
36
  if (strpos($url, $domain) !== false)
37
  return true;
31
  if (fifu_is_photon_url($url))
32
  return true;
33
 
34
+ $blocklist = array('localhost', 'amazon-adsystem.com', 'sapo.io', 'i.guim.co.uk', 's.yimg.com', 's1.yimg.com', 'www.washingtonpost.com', 'pbs.twimg.com', 'www.aljazeera.com', 'image.influenster.com', 'api.screenshotmachine.com', 'rackcdn.com', 'googleusercontent.com', 'drive.google.com', 'img.brownsfashion.com', 'accounts.parrotproducts.biz', 'www.dropbox.com', 'fbcdn.net', 'teespring.com', 'nitrocdn.com', 'brightspotcdn.com', 'img.youtube.com', 'cdn.fifu.app', 'cloud.fifu.app', 'images.placeholders.dev');
35
  foreach ($blocklist as $domain) {
36
  if (strpos($url, $domain) !== false)
37
  return true;
includes/thumbnail-category.php CHANGED
@@ -1,18 +1,5 @@
1
  <?php
2
 
3
- add_filter('woocommerce_before_main_content', 'fifu_ctgr_show_image', 30);
4
-
5
- function fifu_ctgr_show_image() {
6
- if (fifu_is_off('fifu_grid_category'))
7
- return;
8
-
9
- $url = fifu_ctgr_get_url();
10
- $alt = fifu_ctgr_get_alt();
11
-
12
- if ($url)
13
- echo fifu_get_html($url, $alt, null, null);
14
- }
15
-
16
  add_filter('wp_head', 'fifu_ctgr_add_social_tags');
17
 
18
  function fifu_ctgr_add_social_tags() {
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  add_filter('wp_head', 'fifu_ctgr_add_social_tags');
4
 
5
  function fifu_ctgr_add_social_tags() {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://donorbox.org/fifu
4
  Tags: featured, image, url, video, woocommerce
5
  Requires at least: 5.3
6
  Tested up to: 6.1.2
7
- Stable tag: 4.2.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -68,7 +68,6 @@ Use an external image as featured image of your post, page or custom post type.
68
 
69
  * External product image
70
  * Lightbox and zoom
71
- * Category image on grid
72
  * **[PRO]** External image gallery
73
  * **[PRO]** External video gallery
74
  * **[PRO]** Auto set category images
@@ -258,20 +257,20 @@ Featured Image, Figurë e Zgjedhur, Image mise en avant, Uitgelichte afbeelding,
258
 
259
  == Changelog ==
260
 
 
 
 
261
  = 4.2.1 =
262
  * Deprecated: Featured Shortcode.
263
 
264
  = 4.2.0 =
265
  * Enhancement: integration with BEAR Bulk Editor plugin; fix: deactivation lightbox (conflict with BudyBoss plugin); fix: WooCommerce HPOS incompatibility message; deprecated: Hover Effects.
266
 
267
- = 4.1.9 =
268
- * New option: Auto set featured media from post content > post types; enhancement: Featured Video (supports Odysee videos now); fix: CDN + Optimized Thumbnails > apply to content images (low resolution images); deprecated: Gallery Icon.
269
-
270
  = others =
271
  * [more](https://fifu.app/changelog)
272
 
273
 
274
  == Upgrade Notice ==
275
 
276
- = 4.2.1 =
277
- * Deprecated: Featured Shortcode.
4
  Tags: featured, image, url, video, woocommerce
5
  Requires at least: 5.3
6
  Tested up to: 6.1.2
7
+ Stable tag: 4.2.2
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
68
 
69
  * External product image
70
  * Lightbox and zoom
 
71
  * **[PRO]** External image gallery
72
  * **[PRO]** External video gallery
73
  * **[PRO]** Auto set category images
257
 
258
  == Changelog ==
259
 
260
+ = 4.2.2 =
261
+ * Enhancement: FIFU Cloud (supports automatic uploads now); deprecated: Category Image on Grid.
262
+
263
  = 4.2.1 =
264
  * Deprecated: Featured Shortcode.
265
 
266
  = 4.2.0 =
267
  * Enhancement: integration with BEAR Bulk Editor plugin; fix: deactivation lightbox (conflict with BudyBoss plugin); fix: WooCommerce HPOS incompatibility message; deprecated: Hover Effects.
268
 
 
 
 
269
  = others =
270
  * [more](https://fifu.app/changelog)
271
 
272
 
273
  == Upgrade Notice ==
274
 
275
+ = 4.2.2 =
276
+ * Enhancement: FIFU Cloud (supports automatic uploads now); deprecated: Category Image on Grid.