Version Description
- New feature: FIFU has its own WP All Import add-on now. ACF add-on is not required anymore.
Download this release
Release Info
Developer | marceljm |
Plugin | Featured Image From URL |
Version | 2.7.2 |
Comparing to | |
See all releases |
Code changes from version 2.7.1 to 2.7.2
- admin/html/css/editor.css +4 -0
- admin/html/css/menu.css +1 -1
- admin/html/menu.html +31 -29
- admin/html/meta-box.html +1 -1
- admin/meta-box.php +0 -3
- admin/rapid-addon.php +1256 -0
- admin/wai-addon.php +40 -0
- featured-image-from-url.php +2 -1
- readme.txt +9 -3
admin/html/css/editor.css
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
.components-responsive-wrapper > div {
|
2 |
padding-bottom: 0px !important;
|
3 |
}
|
1 |
+
.components-responsive-wrapper > span {
|
2 |
+
padding-bottom: 0px !important;
|
3 |
+
}
|
4 |
+
|
5 |
.components-responsive-wrapper > div {
|
6 |
padding-bottom: 0px !important;
|
7 |
}
|
admin/html/css/menu.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
.wrap {
|
2 |
-
max-width:
|
3 |
margin: 20px 20px 20px 15px;
|
4 |
}
|
5 |
|
1 |
.wrap {
|
2 |
+
max-width: 1020px;
|
3 |
margin: 20px 20px 20px 15px;
|
4 |
}
|
5 |
|
admin/html/menu.html
CHANGED
@@ -2488,12 +2488,14 @@
|
|
2488 |
</div>
|
2489 |
<div id="tabs-p">
|
2490 |
<div class="box">
|
2491 |
-
<h2>
|
2492 |
<div class="greybox">
|
2493 |
-
|
|
|
|
|
|
|
2494 |
<br/>
|
2495 |
<br/>
|
2496 |
-
|
2497 |
<div id="tabsWpAllImport">
|
2498 |
<ul>
|
2499 |
<li><a href="#tabs-3">Importing products...</a></li>
|
@@ -2513,7 +2515,7 @@
|
|
2513 |
</tr>
|
2514 |
<tr>
|
2515 |
<th>
|
2516 |
-
Image
|
2517 |
</th>
|
2518 |
<th>
|
2519 |
fifu_image_url
|
@@ -2521,7 +2523,7 @@
|
|
2521 |
</tr>
|
2522 |
<tr>
|
2523 |
<th>
|
2524 |
-
Alt
|
2525 |
</th>
|
2526 |
<th>
|
2527 |
fifu_image_alt
|
@@ -2543,23 +2545,7 @@
|
|
2543 |
</tr>
|
2544 |
<tr>
|
2545 |
<th>
|
2546 |
-
|
2547 |
-
</th>
|
2548 |
-
<th>
|
2549 |
-
fifu_image_url
|
2550 |
-
</th>
|
2551 |
-
</tr>
|
2552 |
-
<tr>
|
2553 |
-
<th>
|
2554 |
-
Alt
|
2555 |
-
</th>
|
2556 |
-
<th>
|
2557 |
-
fifu_image_alt
|
2558 |
-
</th>
|
2559 |
-
</tr>
|
2560 |
-
<tr>
|
2561 |
-
<th>
|
2562 |
-
Video
|
2563 |
</th>
|
2564 |
<th>
|
2565 |
fifu_video_url
|
@@ -2567,7 +2553,7 @@
|
|
2567 |
</tr>
|
2568 |
<tr>
|
2569 |
<th>
|
2570 |
-
Image +
|
2571 |
</th>
|
2572 |
<th>
|
2573 |
fifu_list_url
|
@@ -2575,7 +2561,7 @@
|
|
2575 |
</tr>
|
2576 |
<tr>
|
2577 |
<th>
|
2578 |
-
Alt +
|
2579 |
</th>
|
2580 |
<th>
|
2581 |
fifu_list_alt
|
@@ -2583,7 +2569,7 @@
|
|
2583 |
</tr>
|
2584 |
<tr>
|
2585 |
<th>
|
2586 |
-
Video +
|
2587 |
</th>
|
2588 |
<th>
|
2589 |
fifu_list_video_url
|
@@ -2591,7 +2577,7 @@
|
|
2591 |
</tr>
|
2592 |
<tr>
|
2593 |
<th>
|
2594 |
-
Slider (URLs delimited by "|")
|
2595 |
</th>
|
2596 |
<th>
|
2597 |
fifu_slider_list_url
|
@@ -2628,12 +2614,12 @@
|
|
2628 |
<a href="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/csv.txt">CSV example</a>
|
2629 |
<br>
|
2630 |
<br>
|
2631 |
-
<img src="https://
|
2632 |
<br>
|
2633 |
<br>
|
2634 |
-
Result
|
2635 |
<br>
|
2636 |
-
<img src="https://
|
2637 |
</div>
|
2638 |
</div>
|
2639 |
</div>
|
@@ -2654,6 +2640,22 @@
|
|
2654 |
From <b>September 2019</b>, always you guys report an issue between FIFU and another plugin or theme, the solution will be posted here.
|
2655 |
</div>
|
2656 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2657 |
<div class="box">
|
2658 |
<table>
|
2659 |
<tr>
|
2488 |
</div>
|
2489 |
<div id="tabs-p">
|
2490 |
<div class="box">
|
2491 |
+
<h2>FIFU Add-On</h2>
|
2492 |
<div class="greybox">
|
2493 |
+
As you can see below, FIFU has its own WP All Import add-on now. So you don't need to buy/use ACF Add-On¹ anymore.
|
2494 |
+
<br/>
|
2495 |
+
<br/>
|
2496 |
+
¹ since you just saved US$ 69,00, why not to buy FIFU Premium? <i class="far fa-smile-wink fa-2x" style="font-size: 1.1rem;"></i> Or you can also help this project giving FIFU a <a href='https://wordpress.org/support/plugin/featured-image-from-url/reviews/?filter=5'>5-star</a> rating.
|
2497 |
<br/>
|
2498 |
<br/>
|
|
|
2499 |
<div id="tabsWpAllImport">
|
2500 |
<ul>
|
2501 |
<li><a href="#tabs-3">Importing products...</a></li>
|
2515 |
</tr>
|
2516 |
<tr>
|
2517 |
<th>
|
2518 |
+
Featured Image URL
|
2519 |
</th>
|
2520 |
<th>
|
2521 |
fifu_image_url
|
2523 |
</tr>
|
2524 |
<tr>
|
2525 |
<th>
|
2526 |
+
Featured Image Alt/Title
|
2527 |
</th>
|
2528 |
<th>
|
2529 |
fifu_image_alt
|
2545 |
</tr>
|
2546 |
<tr>
|
2547 |
<th>
|
2548 |
+
Featured Video URL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2549 |
</th>
|
2550 |
<th>
|
2551 |
fifu_video_url
|
2553 |
</tr>
|
2554 |
<tr>
|
2555 |
<th>
|
2556 |
+
Featured Image URL + WooCommerce Product Gallery URLs (URLs delimited by "|")
|
2557 |
</th>
|
2558 |
<th>
|
2559 |
fifu_list_url
|
2561 |
</tr>
|
2562 |
<tr>
|
2563 |
<th>
|
2564 |
+
Featured Image Alt/Title + WooCommerce Product Gallery Alt/Titles (Alt/Titles delimited by "|")
|
2565 |
</th>
|
2566 |
<th>
|
2567 |
fifu_list_alt
|
2569 |
</tr>
|
2570 |
<tr>
|
2571 |
<th>
|
2572 |
+
Featured Video URL + WooCommerce Product Gallery URLs (URLs delimited by "|")
|
2573 |
</th>
|
2574 |
<th>
|
2575 |
fifu_list_video_url
|
2577 |
</tr>
|
2578 |
<tr>
|
2579 |
<th>
|
2580 |
+
Featured Slider URLs (URLs delimited by "|")
|
2581 |
</th>
|
2582 |
<th>
|
2583 |
fifu_slider_list_url
|
2614 |
<a href="<?php echo plugins_url()?>/featured-image-from-url/admin/html/txt/csv.txt">CSV example</a>
|
2615 |
<br>
|
2616 |
<br>
|
2617 |
+
<img src="https://storage.googleapis.com/featuredimagefromurl/wp-all-import-addon.jpg" style="width:100%">
|
2618 |
<br>
|
2619 |
<br>
|
2620 |
+
<h3>Result:</h3>
|
2621 |
<br>
|
2622 |
+
<img src="https://storage.googleapis.com/featuredimagefromurl/wp-all-import-result.jpg">
|
2623 |
</div>
|
2624 |
</div>
|
2625 |
</div>
|
2640 |
From <b>September 2019</b>, always you guys report an issue between FIFU and another plugin or theme, the solution will be posted here.
|
2641 |
</div>
|
2642 |
</div>
|
2643 |
+
<div class="box">
|
2644 |
+
<table>
|
2645 |
+
<tr>
|
2646 |
+
<td style="border-bottom:none">2019-11-17</td>
|
2647 |
+
<td style="border-bottom:none"><h3>WP All Import</h3></td>
|
2648 |
+
<td style="border-bottom:none">plugin</td>
|
2649 |
+
</tr>
|
2650 |
+
</table>
|
2651 |
+
<div class="greybox" style="position: relative; top: -10px">
|
2652 |
+
Avoiding updates on unchanged image data:<br>
|
2653 |
+
1) access "WP All Import > Import Settings";<br>
|
2654 |
+
2) select "Update existing posts/products with changed data in your file > Choose which data to update";<br>
|
2655 |
+
3) uncheck "Images" (otherwise WP All Import will delete the image metadata and FIFU will need to create that again);<br>
|
2656 |
+
4) select "Custom Fields > Update only these Custom Fields, leave the rest alone".<br>
|
2657 |
+
</div>
|
2658 |
+
</div>
|
2659 |
<div class="box">
|
2660 |
<table>
|
2661 |
<tr>
|
admin/html/meta-box.html
CHANGED
@@ -61,7 +61,7 @@
|
|
61 |
<p style="font-size: 12px; padding: 10px; border-bottom: 2px solid orange; border-top: 2px solid orange; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
62 |
background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">Product Gallery, Video and Slider fields are only available in <a href="admin.php?page=featured-image-from-url#tabs-a"><b>premium</b></a> version</p>
|
63 |
<p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #34ba1c; border-top: 2px solid #34ba1c; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
64 |
-
background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New
|
65 |
<!--p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #538dd3; border-top: 2px solid #538dd3; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
66 |
background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: tips about the integration between FIFU and other plugins will be posted <a href='admin.php?page=featured-image-from-url#tabs-t'>here</a></p-->
|
67 |
<!--p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #7e600e ; border-top: 2px solid #7e600e ; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
61 |
<p style="font-size: 12px; padding: 10px; border-bottom: 2px solid orange; border-top: 2px solid orange; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
62 |
background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">Product Gallery, Video and Slider fields are only available in <a href="admin.php?page=featured-image-from-url#tabs-a"><b>premium</b></a> version</p>
|
63 |
<p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #34ba1c; border-top: 2px solid #34ba1c; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
64 |
+
background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: FIFU has its own <b>WP All Import <a href='admin.php?page=featured-image-from-url#tabs-p'>add-on</a></b> now. You don't need to buy ACF add-on anymore.</p>
|
65 |
<!--p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #538dd3; border-top: 2px solid #538dd3; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
66 |
background-color: whitesmoke; border-radius: 15px 5px 15px 5px; position: relative; top: 5px;">New: tips about the integration between FIFU and other plugins will be posted <a href='admin.php?page=featured-image-from-url#tabs-t'>here</a></p-->
|
67 |
<!--p style="font-size: 12px; padding: 10px; border-bottom: 2px solid #7e600e ; border-top: 2px solid #7e600e ; color: black; background: repeating-linear-gradient(-55deg,white,white 2px,whitesmoke 2px,white 5px);
|
admin/meta-box.php
CHANGED
@@ -131,12 +131,9 @@ function fifu_update_or_delete_value($post_id, $field, $value) {
|
|
131 |
delete_post_meta($post_id, $field, $value);
|
132 |
}
|
133 |
|
134 |
-
add_action('pmxi_saved_post', 'fifu_wai_save');
|
135 |
-
|
136 |
function fifu_wai_save($post_id) {
|
137 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
138 |
fifu_update_or_delete($post_id, 'fifu_image_url', $url);
|
139 |
-
fifu_save($post_id);
|
140 |
}
|
141 |
|
142 |
add_action('before_delete_post', 'fifu_db_before_delete_post');
|
131 |
delete_post_meta($post_id, $field, $value);
|
132 |
}
|
133 |
|
|
|
|
|
134 |
function fifu_wai_save($post_id) {
|
135 |
$url = get_post_meta($post_id, 'fifu_image_url', true);
|
136 |
fifu_update_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|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* RapidAddon
|
4 |
+
*
|
5 |
+
* @package WP All Import RapidAddon
|
6 |
+
* @copyright Copyright (c) 2014, Soflyy
|
7 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
8 |
+
* @version 1.1.1
|
9 |
+
*/
|
10 |
+
/* https://github.com/soflyy/wp-all-import-rapid-addon/edit/master/rapid-addon.php */
|
11 |
+
|
12 |
+
if (!class_exists('RapidAddon')) {
|
13 |
+
|
14 |
+
class RapidAddon {
|
15 |
+
|
16 |
+
public $name;
|
17 |
+
public $slug;
|
18 |
+
public $fields;
|
19 |
+
public $options = array();
|
20 |
+
public $accordions = array();
|
21 |
+
public $image_sections = array();
|
22 |
+
public $import_function;
|
23 |
+
public $post_saved_function;
|
24 |
+
public $notice_text;
|
25 |
+
public $logger = null;
|
26 |
+
public $when_to_run = false;
|
27 |
+
public $image_options = array(
|
28 |
+
'download_images' => 'yes',
|
29 |
+
'download_featured_delim' => ',',
|
30 |
+
'download_featured_image' => '',
|
31 |
+
'gallery_featured_image' => '',
|
32 |
+
'gallery_featured_delim' => ',',
|
33 |
+
'featured_image' => '',
|
34 |
+
'featured_delim' => ',',
|
35 |
+
'search_existing_images' => 1,
|
36 |
+
'is_featured' => 0,
|
37 |
+
'create_draft' => 'no',
|
38 |
+
'set_image_meta_title' => 0,
|
39 |
+
'image_meta_title_delim' => ',',
|
40 |
+
'image_meta_title' => '',
|
41 |
+
'set_image_meta_caption' => 0,
|
42 |
+
'image_meta_caption_delim' => ',',
|
43 |
+
'image_meta_caption' => '',
|
44 |
+
'set_image_meta_alt' => 0,
|
45 |
+
'image_meta_alt_delim' => ',',
|
46 |
+
'image_meta_alt' => '',
|
47 |
+
'set_image_meta_description' => 0,
|
48 |
+
'image_meta_description_delim' => ',',
|
49 |
+
'image_meta_description_delim_logic' => 'separate',
|
50 |
+
'image_meta_description' => '',
|
51 |
+
'auto_rename_images' => 0,
|
52 |
+
'auto_rename_images_suffix' => '',
|
53 |
+
'auto_set_extension' => 0,
|
54 |
+
'new_extension' => '',
|
55 |
+
'do_not_remove_images' => 1,
|
56 |
+
'search_existing_images_logic' => 'by_url'
|
57 |
+
);
|
58 |
+
protected $isWizard = true;
|
59 |
+
|
60 |
+
function __construct($name, $slug) {
|
61 |
+
$this->name = $name;
|
62 |
+
$this->slug = $slug;
|
63 |
+
if (!empty($_GET['id'])) {
|
64 |
+
$this->isWizard = false;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
function set_import_function($name) {
|
69 |
+
$this->import_function = $name;
|
70 |
+
}
|
71 |
+
|
72 |
+
function set_post_saved_function($name) {
|
73 |
+
$this->post_saved_function = $name;
|
74 |
+
}
|
75 |
+
|
76 |
+
function is_active_addon($post_type = null) {
|
77 |
+
|
78 |
+
if (!is_plugin_active('wp-all-import-pro/wp-all-import-pro.php') and ! is_plugin_active('wp-all-import/plugin.php')) {
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
|
82 |
+
$addon_active = false;
|
83 |
+
|
84 |
+
if ($post_type !== null) {
|
85 |
+
if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
|
86 |
+
$addon_active = true;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
if ($addon_active) {
|
91 |
+
|
92 |
+
$current_theme = wp_get_theme();
|
93 |
+
|
94 |
+
$parent_theme = $current_theme->parent();
|
95 |
+
|
96 |
+
$theme_name = $current_theme->get('Name');
|
97 |
+
|
98 |
+
$addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
|
99 |
+
|
100 |
+
if (!$addon_active and $parent_theme) {
|
101 |
+
$parent_theme_name = $parent_theme->get('Name');
|
102 |
+
$addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
|
103 |
+
}
|
104 |
+
|
105 |
+
if ($addon_active and ! empty($this->active_plugins)) {
|
106 |
+
|
107 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
108 |
+
|
109 |
+
foreach ($this->active_plugins as $plugin) {
|
110 |
+
if (!is_plugin_active($plugin)) {
|
111 |
+
$addon_active = false;
|
112 |
+
break;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
if ($this->when_to_run == "always") {
|
119 |
+
$addon_active = true;
|
120 |
+
}
|
121 |
+
|
122 |
+
return apply_filters('rapid_is_active_add_on', $addon_active, $post_type, $this->slug);
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
*
|
127 |
+
* Add-On Initialization
|
128 |
+
*
|
129 |
+
* @param array $conditions - list of supported themes and post types
|
130 |
+
*
|
131 |
+
*/
|
132 |
+
function run($conditions = array()) {
|
133 |
+
|
134 |
+
if (empty($conditions)) {
|
135 |
+
$this->when_to_run = "always";
|
136 |
+
}
|
137 |
+
|
138 |
+
@$this->active_post_types = (!empty($conditions['post_types'])) ? $conditions['post_types'] : array();
|
139 |
+
@$this->active_themes = (!empty($conditions['themes'])) ? $conditions['themes'] : array();
|
140 |
+
@$this->active_plugins = (!empty($conditions['plugins'])) ? $conditions['plugins'] : array();
|
141 |
+
|
142 |
+
add_filter('pmxi_addons', array($this, 'wpai_api_register'));
|
143 |
+
add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
|
144 |
+
add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
|
145 |
+
add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
|
146 |
+
add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
|
147 |
+
add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
|
148 |
+
add_filter('pmxi_custom_types', array($this, 'filter_post_types'), 10, 2);
|
149 |
+
add_filter('pmxi_post_list_order', array($this, 'sort_post_types'), 10, 1);
|
150 |
+
add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1);
|
151 |
+
add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 2);
|
152 |
+
add_action('admin_init', array($this, 'admin_notice_ignore'));
|
153 |
+
}
|
154 |
+
|
155 |
+
function parse($data) {
|
156 |
+
|
157 |
+
if (!$this->is_active_addon($data['import']->options['custom_type']))
|
158 |
+
return false;
|
159 |
+
|
160 |
+
$parsedData = $this->helper_parse($data, $this->options_array());
|
161 |
+
return $parsedData;
|
162 |
+
}
|
163 |
+
|
164 |
+
function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') {
|
165 |
+
|
166 |
+
$field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text);
|
167 |
+
|
168 |
+
$this->fields[$field_slug] = $field;
|
169 |
+
|
170 |
+
if (!empty($enum_values)) {
|
171 |
+
foreach ($enum_values as $key => $value) {
|
172 |
+
if (is_array($value)) {
|
173 |
+
if ($field['type'] == 'accordion') {
|
174 |
+
$this->fields[$value['slug']]['is_sub_field'] = true;
|
175 |
+
} else {
|
176 |
+
foreach ($value as $n => $param) {
|
177 |
+
if (is_array($param) and ! empty($this->fields[$param['slug']])) {
|
178 |
+
$this->fields[$param['slug']]['is_sub_field'] = true;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
return $field;
|
187 |
+
}
|
188 |
+
|
189 |
+
function add_acf_field($field) {
|
190 |
+
$this->fields[$field->post_name] = array(
|
191 |
+
'type' => 'acf',
|
192 |
+
'field_obj' => $field
|
193 |
+
);
|
194 |
+
}
|
195 |
+
|
196 |
+
private $acfGroups = array();
|
197 |
+
|
198 |
+
function use_acf_group($acf_group) {
|
199 |
+
$this->add_text(
|
200 |
+
'<div class="postbox acf_postbox default acf_signle_group rad4">
|
201 |
+
<h3 class="hndle" style="margin-top:0;"><span>' . $acf_group['title'] . '</span></h3>
|
202 |
+
<div class="inside">');
|
203 |
+
$acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
|
204 |
+
if (!empty($acf_fields)) {
|
205 |
+
foreach ($acf_fields as $field) {
|
206 |
+
$this->add_acf_field($field);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
$this->add_text('</div></div>');
|
210 |
+
$this->acfGroups[] = $acf_group['ID'];
|
211 |
+
add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2);
|
212 |
+
}
|
213 |
+
|
214 |
+
function acf_is_show_group($is_show, $acf_group) {
|
215 |
+
return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
*
|
220 |
+
* Add an option to WP All Import options list
|
221 |
+
*
|
222 |
+
* @param string $slug - option name
|
223 |
+
* @param string $default_value - default option value
|
224 |
+
*
|
225 |
+
*/
|
226 |
+
function add_option($slug, $default_value = '') {
|
227 |
+
$this->options[$slug] = $default_value;
|
228 |
+
}
|
229 |
+
|
230 |
+
function options_array() {
|
231 |
+
|
232 |
+
$options_list = array();
|
233 |
+
|
234 |
+
if (!empty($this->fields)) {
|
235 |
+
|
236 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
237 |
+
if (in_array($field_params['type'], array('title', 'plain_text', 'acf')))
|
238 |
+
continue;
|
239 |
+
$default_value = '';
|
240 |
+
if (!empty($field_params['enum_values'])) {
|
241 |
+
foreach ($field_params['enum_values'] as $key => $value) {
|
242 |
+
$default_value = $key;
|
243 |
+
break;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
$options_list[$field_slug] = $default_value;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
if (!empty($this->options)) {
|
251 |
+
foreach ($this->options as $slug => $value) {
|
252 |
+
$options_arr[$slug] = $value;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
$options_arr[$this->slug] = $options_list;
|
257 |
+
$options_arr['rapid_addon'] = plugin_basename(__FILE__);
|
258 |
+
|
259 |
+
return $options_arr;
|
260 |
+
}
|
261 |
+
|
262 |
+
function wpai_api_options($all_options) {
|
263 |
+
|
264 |
+
$all_options = $all_options + $this->options_array();
|
265 |
+
|
266 |
+
return $all_options;
|
267 |
+
}
|
268 |
+
|
269 |
+
function wpai_api_register($addons) {
|
270 |
+
|
271 |
+
if (empty($addons[$this->slug])) {
|
272 |
+
$addons[$this->slug] = 1;
|
273 |
+
}
|
274 |
+
|
275 |
+
return $addons;
|
276 |
+
}
|
277 |
+
|
278 |
+
function wpai_api_parse($functions) {
|
279 |
+
|
280 |
+
$functions[$this->slug] = array($this, 'parse');
|
281 |
+
return $functions;
|
282 |
+
}
|
283 |
+
|
284 |
+
function wpai_api_post_saved($functions) {
|
285 |
+
$functions[$this->slug] = array($this, 'post_saved');
|
286 |
+
return $functions;
|
287 |
+
}
|
288 |
+
|
289 |
+
function wpai_api_import($functions) {
|
290 |
+
|
291 |
+
$functions[$this->slug] = array($this, 'import');
|
292 |
+
return $functions;
|
293 |
+
}
|
294 |
+
|
295 |
+
function post_saved($importData) {
|
296 |
+
|
297 |
+
if (is_callable($this->post_saved_function))
|
298 |
+
call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']);
|
299 |
+
}
|
300 |
+
|
301 |
+
function import($importData, $parsedData) {
|
302 |
+
|
303 |
+
if (!$this->is_active_addon($importData['post_type'])) {
|
304 |
+
return;
|
305 |
+
}
|
306 |
+
|
307 |
+
$import_options = $importData['import']['options'][$this->slug];
|
308 |
+
|
309 |
+
// echo "<pre>";
|
310 |
+
// print_r($import_options);
|
311 |
+
// echo "</pre>";
|
312 |
+
|
313 |
+
if (!empty($parsedData)) {
|
314 |
+
|
315 |
+
$this->logger = $importData['logger'];
|
316 |
+
|
317 |
+
$post_id = $importData['pid'];
|
318 |
+
$index = $importData['i'];
|
319 |
+
$data = array();
|
320 |
+
if (!empty($this->fields)) {
|
321 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
322 |
+
if (in_array($field_params['type'], array('title', 'plain_text')))
|
323 |
+
continue;
|
324 |
+
switch ($field_params['type']) {
|
325 |
+
|
326 |
+
case 'image':
|
327 |
+
|
328 |
+
// import the specified image, then set the value of the field to the image ID in the media library
|
329 |
+
|
330 |
+
$image_url_or_path = $parsedData[$field_slug][$index];
|
331 |
+
|
332 |
+
$download = $import_options['download_image'][$field_slug];
|
333 |
+
|
334 |
+
$uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);
|
335 |
+
|
336 |
+
$data[$field_slug] = array(
|
337 |
+
"attachment_id" => $uploaded_image,
|
338 |
+
"image_url_or_path" => $image_url_or_path,
|
339 |
+
"download" => $download
|
340 |
+
);
|
341 |
+
|
342 |
+
break;
|
343 |
+
|
344 |
+
case 'file':
|
345 |
+
|
346 |
+
$image_url_or_path = $parsedData[$field_slug][$index];
|
347 |
+
|
348 |
+
$download = $import_options['download_image'][$field_slug];
|
349 |
+
|
350 |
+
$uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);
|
351 |
+
|
352 |
+
$data[$field_slug] = array(
|
353 |
+
"attachment_id" => $uploaded_file,
|
354 |
+
"image_url_or_path" => $image_url_or_path,
|
355 |
+
"download" => $download
|
356 |
+
);
|
357 |
+
|
358 |
+
break;
|
359 |
+
|
360 |
+
default:
|
361 |
+
// set the field data to the value of the field after it's been parsed
|
362 |
+
$data[$field_slug] = $parsedData[$field_slug][$index];
|
363 |
+
break;
|
364 |
+
}
|
365 |
+
|
366 |
+
// apply mapping rules if they exist
|
367 |
+
if (!empty($import_options['mapping'][$field_slug])) {
|
368 |
+
$mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
|
369 |
+
|
370 |
+
if (!empty($mapping_rules) and is_array($mapping_rules)) {
|
371 |
+
foreach ($mapping_rules as $rule_number => $map_to) {
|
372 |
+
if (isset($map_to[trim($data[$field_slug])])) {
|
373 |
+
$data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
|
374 |
+
break;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
}
|
379 |
+
// --------------------
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
function wpai_api_metabox($post_type, $current_values) {
|
388 |
+
|
389 |
+
if (!$this->is_active_addon($post_type)) {
|
390 |
+
return;
|
391 |
+
}
|
392 |
+
|
393 |
+
echo $this->helper_metabox_top($this->name);
|
394 |
+
|
395 |
+
$visible_fields = 0;
|
396 |
+
|
397 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
398 |
+
if ($field_params['is_sub_field'])
|
399 |
+
continue;
|
400 |
+
$visible_fields++;
|
401 |
+
}
|
402 |
+
|
403 |
+
$counter = 0;
|
404 |
+
|
405 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
406 |
+
|
407 |
+
// do not render sub fields
|
408 |
+
if ($field_params['is_sub_field'])
|
409 |
+
continue;
|
410 |
+
|
411 |
+
$counter++;
|
412 |
+
|
413 |
+
$this->render_field($field_params, $field_slug, $current_values, $visible_fields == $counter);
|
414 |
+
|
415 |
+
//if ( $field_params['type'] != 'accordion' ) echo "<br />";
|
416 |
+
}
|
417 |
+
|
418 |
+
echo $this->helper_metabox_bottom();
|
419 |
+
|
420 |
+
if (!empty($this->image_sections)) {
|
421 |
+
$is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type);
|
422 |
+
foreach ($this->image_sections as $k => $section) {
|
423 |
+
$section_options = array();
|
424 |
+
foreach ($this->image_options as $slug => $value) {
|
425 |
+
$section_options[$section['slug'] . $slug] = $value;
|
426 |
+
}
|
427 |
+
if (!$is_images_section_enabled and ! $k) {
|
428 |
+
$section_options[$section['slug'] . 'is_featured'] = 1;
|
429 |
+
}
|
430 |
+
PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']);
|
431 |
+
}
|
432 |
+
}
|
433 |
+
}
|
434 |
+
|
435 |
+
function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false) {
|
436 |
+
|
437 |
+
if (!isset($current_values[$this->slug][$field_slug])) {
|
438 |
+
$current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : '';
|
439 |
+
}
|
440 |
+
|
441 |
+
if ($field_params['type'] == 'text') {
|
442 |
+
|
443 |
+
PMXI_API::add_field(
|
444 |
+
'simple',
|
445 |
+
$field_params['name'],
|
446 |
+
array(
|
447 |
+
'tooltip' => $field_params['tooltip'],
|
448 |
+
'field_name' => $this->slug . "[" . $field_slug . "]",
|
449 |
+
'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
|
450 |
+
)
|
451 |
+
);
|
452 |
+
} else if ($field_params['type'] == 'textarea') {
|
453 |
+
|
454 |
+
PMXI_API::add_field(
|
455 |
+
'textarea',
|
456 |
+
$field_params['name'],
|
457 |
+
array(
|
458 |
+
'tooltip' => $field_params['tooltip'],
|
459 |
+
'field_name' => $this->slug . "[" . $field_slug . "]",
|
460 |
+
'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
|
461 |
+
)
|
462 |
+
);
|
463 |
+
} else if ($field_params['type'] == 'wp_editor') {
|
464 |
+
|
465 |
+
PMXI_API::add_field(
|
466 |
+
'wp_editor',
|
467 |
+
$field_params['name'],
|
468 |
+
array(
|
469 |
+
'tooltip' => $field_params['tooltip'],
|
470 |
+
'field_name' => $this->slug . "[" . $field_slug . "]",
|
471 |
+
'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
|
472 |
+
)
|
473 |
+
);
|
474 |
+
} else if ($field_params['type'] == 'image' or $field_params['type'] == 'file') {
|
475 |
+
|
476 |
+
if (!isset($current_values[$this->slug]['download_image'][$field_slug])) {
|
477 |
+
$current_values[$this->slug]['download_image'][$field_slug] = '';
|
478 |
+
}
|
479 |
+
|
480 |
+
PMXI_API::add_field(
|
481 |
+
$field_params['type'],
|
482 |
+
$field_params['name'],
|
483 |
+
array(
|
484 |
+
'tooltip' => $field_params['tooltip'],
|
485 |
+
'field_name' => $this->slug . "[" . $field_slug . "]",
|
486 |
+
'field_value' => $current_values[$this->slug][$field_slug],
|
487 |
+
'download_image' => $current_values[$this->slug]['download_image'][$field_slug],
|
488 |
+
'field_key' => $field_slug,
|
489 |
+
'addon_prefix' => $this->slug
|
490 |
+
)
|
491 |
+
);
|
492 |
+
} else if ($field_params['type'] == 'radio') {
|
493 |
+
|
494 |
+
if (!isset($current_values[$this->slug]['mapping'][$field_slug])) {
|
495 |
+
$current_values[$this->slug]['mapping'][$field_slug] = array();
|
496 |
+
}
|
497 |
+
if (!isset($current_values[$this->slug]['xpaths'][$field_slug])) {
|
498 |
+
$current_values[$this->slug]['xpaths'][$field_slug] = '';
|
499 |
+
}
|
500 |
+
|
501 |
+
PMXI_API::add_field(
|
502 |
+
'enum',
|
503 |
+
$field_params['name'],
|
504 |
+
array(
|
505 |
+
'tooltip' => $field_params['tooltip'],
|
506 |
+
'field_name' => $this->slug . "[" . $field_slug . "]",
|
507 |
+
'field_value' => $current_values[$this->slug][$field_slug],
|
508 |
+
'enum_values' => $field_params['enum_values'],
|
509 |
+
'mapping' => true,
|
510 |
+
'field_key' => $field_slug,
|
511 |
+
'mapping_rules' => $current_values[$this->slug]['mapping'][$field_slug],
|
512 |
+
'xpath' => $current_values[$this->slug]['xpaths'][$field_slug],
|
513 |
+
'addon_prefix' => $this->slug,
|
514 |
+
'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values)
|
515 |
+
)
|
516 |
+
);
|
517 |
+
} else if ($field_params['type'] == 'accordion') {
|
518 |
+
|
519 |
+
PMXI_API::add_field(
|
520 |
+
'accordion',
|
521 |
+
$field_params['name'],
|
522 |
+
array(
|
523 |
+
'tooltip' => $field_params['tooltip'],
|
524 |
+
'field_name' => $this->slug . "[" . $field_slug . "]",
|
525 |
+
'field_key' => $field_slug,
|
526 |
+
'addon_prefix' => $this->slug,
|
527 |
+
'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values),
|
528 |
+
'in_the_bottom' => $in_the_bottom
|
529 |
+
)
|
530 |
+
);
|
531 |
+
} else if ($field_params['type'] == 'acf') {
|
532 |
+
$fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array();
|
533 |
+
$fieldData['ID'] = $field_params['field_obj']->ID;
|
534 |
+
$fieldData['id'] = $field_params['field_obj']->ID;
|
535 |
+
$fieldData['label'] = $field_params['field_obj']->post_title;
|
536 |
+
$fieldData['key'] = $field_params['field_obj']->post_name;
|
537 |
+
if (empty($fieldData['name']))
|
538 |
+
$fieldData['name'] = $field_params['field_obj']->post_excerpt;
|
539 |
+
if (function_exists('pmai_render_field')) {
|
540 |
+
echo pmai_render_field($fieldData, (!empty($current_values) ) ? $current_values : array() );
|
541 |
+
}
|
542 |
+
} else if ($field_params['type'] == 'title') {
|
543 |
+
?>
|
544 |
+
<h4 class="wpallimport-add-on-options-title"><?php _e($field_params['name'], 'wp_all_import_plugin'); ?><?php if (!empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4>
|
545 |
+
<?php
|
546 |
+
} else if ($field_params['type'] == 'plain_text') {
|
547 |
+
if ($field_params['is_html']):
|
548 |
+
echo $field_params['name'];
|
549 |
+
else:
|
550 |
+
?>
|
551 |
+
<p style="margin: 0 0 12px 0;"><?php echo $field_params['name']; ?></p>
|
552 |
+
<?php
|
553 |
+
endif;
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
*
|
559 |
+
* Helper function for nested radio fields
|
560 |
+
*
|
561 |
+
*/
|
562 |
+
function get_sub_fields($field_params, $field_slug, $current_values) {
|
563 |
+
$sub_fields = array();
|
564 |
+
if (!empty($field_params['enum_values'])) {
|
565 |
+
foreach ($field_params['enum_values'] as $key => $value) {
|
566 |
+
$sub_fields[$key] = array();
|
567 |
+
if (is_array($value)) {
|
568 |
+
if ($field_params['type'] == 'accordion') {
|
569 |
+
$sub_fields[$key][] = $this->convert_field($value, $current_values);
|
570 |
+
} else {
|
571 |
+
foreach ($value as $k => $sub_field) {
|
572 |
+
if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']])) {
|
573 |
+
$sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
|
574 |
+
}
|
575 |
+
}
|
576 |
+
}
|
577 |
+
}
|
578 |
+
}
|
579 |
+
}
|
580 |
+
return $sub_fields;
|
581 |
+
}
|
582 |
+
|
583 |
+
function convert_field($sub_field, $current_values) {
|
584 |
+
$field = array();
|
585 |
+
if (!isset($current_values[$this->slug][$sub_field['slug']])) {
|
586 |
+
$current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : '';
|
587 |
+
}
|
588 |
+
switch ($this->fields[$sub_field['slug']]['type']) {
|
589 |
+
case 'text':
|
590 |
+
$field = array(
|
591 |
+
'type' => 'simple',
|
592 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
593 |
+
'params' => array(
|
594 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
595 |
+
'field_name' => $this->slug . "[" . $sub_field['slug'] . "]",
|
596 |
+
'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
|
597 |
+
'is_main_field' => $sub_field['is_main_field']
|
598 |
+
)
|
599 |
+
);
|
600 |
+
break;
|
601 |
+
case 'textarea':
|
602 |
+
$field = array(
|
603 |
+
'type' => 'textarea',
|
604 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
605 |
+
'params' => array(
|
606 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
607 |
+
'field_name' => $this->slug . "[" . $sub_field['slug'] . "]",
|
608 |
+
'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
|
609 |
+
'is_main_field' => $sub_field['is_main_field']
|
610 |
+
)
|
611 |
+
);
|
612 |
+
break;
|
613 |
+
case 'wp_editor':
|
614 |
+
$field = array(
|
615 |
+
'type' => 'wp_editor',
|
616 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
617 |
+
'params' => array(
|
618 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
619 |
+
'field_name' => $this->slug . "[" . $sub_field['slug'] . "]",
|
620 |
+
'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
|
621 |
+
'is_main_field' => $sub_field['is_main_field']
|
622 |
+
)
|
623 |
+
);
|
624 |
+
break;
|
625 |
+
case 'image':
|
626 |
+
$field = array(
|
627 |
+
'type' => 'image',
|
628 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
629 |
+
'params' => array(
|
630 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
631 |
+
'field_name' => $this->slug . "[" . $sub_field['slug'] . "]",
|
632 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
633 |
+
'download_image' => null,
|
634 |
+
'field_key' => $sub_field['slug'],
|
635 |
+
'addon_prefix' => $this->slug,
|
636 |
+
'is_main_field' => $sub_field['is_main_field']
|
637 |
+
)
|
638 |
+
);
|
639 |
+
|
640 |
+
if (array_key_exists('download_image', $current_values[$this->slug])) {
|
641 |
+
$field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
|
642 |
+
}
|
643 |
+
break;
|
644 |
+
case 'file':
|
645 |
+
$field = array(
|
646 |
+
'type' => 'file',
|
647 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
648 |
+
'params' => array(
|
649 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
650 |
+
'field_name' => $this->slug . "[" . $sub_field['slug'] . "]",
|
651 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
652 |
+
'download_image' => null,
|
653 |
+
'field_key' => $sub_field['slug'],
|
654 |
+
'addon_prefix' => $this->slug,
|
655 |
+
'is_main_field' => $sub_field['is_main_field']
|
656 |
+
)
|
657 |
+
);
|
658 |
+
|
659 |
+
if (array_key_exists('download_image', $current_values[$this->slug])) {
|
660 |
+
$field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
|
661 |
+
}
|
662 |
+
|
663 |
+
break;
|
664 |
+
case 'radio':
|
665 |
+
$field = array(
|
666 |
+
'type' => 'enum',
|
667 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
668 |
+
'params' => array(
|
669 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
670 |
+
'field_name' => $this->slug . "[" . $sub_field['slug'] . "]",
|
671 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
672 |
+
'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
|
673 |
+
'mapping' => true,
|
674 |
+
'field_key' => $sub_field['slug'],
|
675 |
+
'mapping_rules' => isset($current_values[$this->slug]['mapping'][$sub_field['slug']]) ? $current_values[$this->slug]['mapping'][$sub_field['slug']] : array(),
|
676 |
+
'xpath' => isset($current_values[$this->slug]['xpaths'][$sub_field['slug']]) ? $current_values[$this->slug]['xpaths'][$sub_field['slug']] : '',
|
677 |
+
'addon_prefix' => $this->slug,
|
678 |
+
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
679 |
+
'is_main_field' => $sub_field['is_main_field']
|
680 |
+
)
|
681 |
+
);
|
682 |
+
break;
|
683 |
+
case 'accordion':
|
684 |
+
$field = array(
|
685 |
+
'type' => 'accordion',
|
686 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
687 |
+
'params' => array(
|
688 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
689 |
+
'field_name' => $this->slug . "[" . $sub_field['slug'] . "]",
|
690 |
+
'field_key' => $sub_field['slug'],
|
691 |
+
'addon_prefix' => $this->slug,
|
692 |
+
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
693 |
+
'in_the_bottom' => false
|
694 |
+
)
|
695 |
+
);
|
696 |
+
break;
|
697 |
+
default:
|
698 |
+
# code...
|
699 |
+
break;
|
700 |
+
}
|
701 |
+
return $field;
|
702 |
+
}
|
703 |
+
|
704 |
+
/**
|
705 |
+
*
|
706 |
+
* Add accordion options
|
707 |
+
*
|
708 |
+
*
|
709 |
+
*/
|
710 |
+
function add_options($main_field = false, $title = '', $fields = array()) {
|
711 |
+
|
712 |
+
if (!empty($fields)) {
|
713 |
+
|
714 |
+
if ($main_field) {
|
715 |
+
|
716 |
+
$main_field['is_main_field'] = true;
|
717 |
+
$fields[] = $main_field;
|
718 |
+
}
|
719 |
+
|
720 |
+
return $this->add_field('accordion_' . $fields[0]['slug'], $title, 'accordion', $fields);
|
721 |
+
}
|
722 |
+
}
|
723 |
+
|
724 |
+
function add_title($title = '', $tooltip = '') {
|
725 |
+
|
726 |
+
if (empty($title))
|
727 |
+
return;
|
728 |
+
|
729 |
+
return $this->add_field(sanitize_key($title) . time(), $title, 'title', null, $tooltip);
|
730 |
+
}
|
731 |
+
|
732 |
+
function add_text($text = '', $is_html = false) {
|
733 |
+
|
734 |
+
if (empty($text))
|
735 |
+
return;
|
736 |
+
|
737 |
+
$count = is_array($this->fields) ? count($this->fields) : 0;
|
738 |
+
|
739 |
+
return $this->add_field(sanitize_key($text) . time() . uniqid() . $count, $text, 'plain_text', null, "", $is_html);
|
740 |
+
}
|
741 |
+
|
742 |
+
function helper_metabox_top($name) {
|
743 |
+
|
744 |
+
return '
|
745 |
+
<style type="text/css">
|
746 |
+
.wpallimport-plugin .wpallimport-addon div.input {
|
747 |
+
margin-bottom: 15px;
|
748 |
+
}
|
749 |
+
.wpallimport-plugin .wpallimport-addon .custom-params tr td.action{
|
750 |
+
width: auto !important;
|
751 |
+
}
|
752 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-custom-fields-actions{
|
753 |
+
right:0 !important;
|
754 |
+
}
|
755 |
+
.wpallimport-plugin .wpallimport-addon table tr td.wpallimport-enum-input-wrapper{
|
756 |
+
width: 80%;
|
757 |
+
}
|
758 |
+
.wpallimport-plugin .wpallimport-addon table tr td.wpallimport-enum-input-wrapper input{
|
759 |
+
width: 100%;
|
760 |
+
}
|
761 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-custom-fields-actions{
|
762 |
+
float: right;
|
763 |
+
right: 30px;
|
764 |
+
position: relative;
|
765 |
+
border: 1px solid #ddd;
|
766 |
+
margin-bottom: 10px;
|
767 |
+
}
|
768 |
+
|
769 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options {
|
770 |
+
margin-bottom: 15px;
|
771 |
+
margin-top: -16px;
|
772 |
+
}
|
773 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-content-section{
|
774 |
+
padding-bottom: 8px;
|
775 |
+
margin:0;
|
776 |
+
border: none;
|
777 |
+
padding-top: 1px;
|
778 |
+
background: #f1f2f2;
|
779 |
+
}
|
780 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-collapsed-header{
|
781 |
+
padding-left: 13px;
|
782 |
+
}
|
783 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-collapsed-header h3{
|
784 |
+
font-size: 14px;
|
785 |
+
margin: 6px 0;
|
786 |
+
}
|
787 |
+
|
788 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options-full-width{
|
789 |
+
bottom: -40px;
|
790 |
+
margin-bottom: 0;
|
791 |
+
margin-left: -25px;
|
792 |
+
margin-right: -25px;
|
793 |
+
position: relative;
|
794 |
+
}
|
795 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options-full-width .wpallimport-content-section{
|
796 |
+
margin:0;
|
797 |
+
border-top:1px solid #ddd;
|
798 |
+
border-bottom: none;
|
799 |
+
border-right: none;
|
800 |
+
border-left: none;
|
801 |
+
background: #f1f2f2;
|
802 |
+
}
|
803 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options-full-width .wpallimport-collapsed-header h3{
|
804 |
+
margin: 14px 0;
|
805 |
+
}
|
806 |
+
|
807 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-dependent-options{
|
808 |
+
margin-left: 1px;
|
809 |
+
margin-right: -1px;
|
810 |
+
}
|
811 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-dependent-options .wpallimport-content-section{
|
812 |
+
border: 1px solid #ddd;
|
813 |
+
border-top: none;
|
814 |
+
}
|
815 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-full-with-bottom{
|
816 |
+
margin-left: -25px;
|
817 |
+
margin-right: -25px;
|
818 |
+
}
|
819 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-full-with-not-bottom{
|
820 |
+
margin: 25px -1px 25px 1px;
|
821 |
+
}
|
822 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-full-with-not-bottom .wpallimport-content-section{
|
823 |
+
border: 1px solid #ddd;
|
824 |
+
}
|
825 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-add-on-options-title{
|
826 |
+
font-size: 14px;
|
827 |
+
margin: 45px 0 15px 0;
|
828 |
+
}
|
829 |
+
</style>
|
830 |
+
<div class="wpallimport-collapsed wpallimport-section wpallimport-addon ' . $this->slug . ' closed">
|
831 |
+
<div class="wpallimport-content-section">
|
832 |
+
<div class="wpallimport-collapsed-header">
|
833 |
+
<h3>' . __($name, 'pmxi_plugin') . '</h3>
|
834 |
+
</div>
|
835 |
+
<div class="wpallimport-collapsed-content" style="padding: 0;">
|
836 |
+
<div class="wpallimport-collapsed-content-inner">
|
837 |
+
<table class="form-table" style="max-width:none;">
|
838 |
+
<tr>
|
839 |
+
<td colspan="3">';
|
840 |
+
}
|
841 |
+
|
842 |
+
function helper_metabox_bottom() {
|
843 |
+
|
844 |
+
return ' </td>
|
845 |
+
</tr>
|
846 |
+
</table>
|
847 |
+
</div>
|
848 |
+
</div>
|
849 |
+
</div>
|
850 |
+
</div>';
|
851 |
+
}
|
852 |
+
|
853 |
+
/**
|
854 |
+
*
|
855 |
+
* simply add an additional section for attachments
|
856 |
+
*
|
857 |
+
*/
|
858 |
+
function import_files($slug, $title) {
|
859 |
+
$this->import_images($slug, $title, 'files');
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
*
|
864 |
+
* simply add an additional section
|
865 |
+
*
|
866 |
+
*/
|
867 |
+
function import_images($slug, $title, $type = 'images') {
|
868 |
+
|
869 |
+
if (empty($title) or empty($slug))
|
870 |
+
return;
|
871 |
+
|
872 |
+
$section_slug = 'pmxi_' . $slug;
|
873 |
+
|
874 |
+
$this->image_sections[] = array(
|
875 |
+
'title' => $title,
|
876 |
+
'slug' => $section_slug,
|
877 |
+
'type' => $type
|
878 |
+
);
|
879 |
+
|
880 |
+
foreach ($this->image_options as $option_slug => $value) {
|
881 |
+
$this->add_option($section_slug . $option_slug, $value);
|
882 |
+
}
|
883 |
+
|
884 |
+
if (count($this->image_sections) > 1) {
|
885 |
+
add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2);
|
886 |
+
}
|
887 |
+
|
888 |
+
add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2);
|
889 |
+
|
890 |
+
if (function_exists($slug))
|
891 |
+
add_action($section_slug, $slug, 10, 4);
|
892 |
+
}
|
893 |
+
|
894 |
+
/**
|
895 |
+
*
|
896 |
+
* filter to allow import images for free edition of WP All Import
|
897 |
+
*
|
898 |
+
*/
|
899 |
+
function is_allow_import_images($is_allow, $post_type) {
|
900 |
+
return ($this->is_active_addon($post_type)) ? true : $is_allow;
|
901 |
+
}
|
902 |
+
|
903 |
+
/**
|
904 |
+
*
|
905 |
+
* filter to control additional images sections
|
906 |
+
*
|
907 |
+
*/
|
908 |
+
function additional_sections($sections) {
|
909 |
+
if (!empty($this->image_sections)) {
|
910 |
+
foreach ($this->image_sections as $add_section) {
|
911 |
+
$sections[] = $add_section;
|
912 |
+
}
|
913 |
+
}
|
914 |
+
|
915 |
+
return $sections;
|
916 |
+
}
|
917 |
+
|
918 |
+
/**
|
919 |
+
*
|
920 |
+
* remove the 'Don't touch existing images, append new images' when more than one image section is in use.
|
921 |
+
*
|
922 |
+
*/
|
923 |
+
function filter_is_show_add_new_images($is_show, $post_type) {
|
924 |
+
return ($this->is_active_addon($post_type)) ? false : $is_show;
|
925 |
+
}
|
926 |
+
|
927 |
+
/**
|
928 |
+
*
|
929 |
+
* disable the default images section
|
930 |
+
*
|
931 |
+
*/
|
932 |
+
function disable_default_images($post_type = false) {
|
933 |
+
|
934 |
+
add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2);
|
935 |
+
}
|
936 |
+
|
937 |
+
function is_enable_default_images_section($is_enabled, $post_type) {
|
938 |
+
|
939 |
+
return ($this->is_active_addon($post_type)) ? false : true;
|
940 |
+
}
|
941 |
+
|
942 |
+
function helper_parse($parsingData, $options) {
|
943 |
+
|
944 |
+
extract($parsingData);
|
945 |
+
|
946 |
+
$data = array(); // parsed data
|
947 |
+
|
948 |
+
if (!empty($import->options[$this->slug])) {
|
949 |
+
|
950 |
+
$this->logger = $parsingData['logger'];
|
951 |
+
|
952 |
+
$cxpath = $xpath_prefix . $import->xpath;
|
953 |
+
|
954 |
+
$tmp_files = array();
|
955 |
+
|
956 |
+
foreach ($options[$this->slug] as $option_name => $option_value) {
|
957 |
+
if (isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') {
|
958 |
+
if ($import->options[$this->slug][$option_name] == "xpath") {
|
959 |
+
if ($import->options[$this->slug]['xpaths'][$option_name] == "") {
|
960 |
+
$count and $data[$option_name] = array_fill(0, $count, "");
|
961 |
+
} else {
|
962 |
+
$data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse();
|
963 |
+
$tmp_files[] = $file;
|
964 |
+
}
|
965 |
+
} else {
|
966 |
+
$data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug][$option_name], $file)->parse();
|
967 |
+
$tmp_files[] = $file;
|
968 |
+
}
|
969 |
+
} else {
|
970 |
+
$data[$option_name] = array_fill(0, $count, "");
|
971 |
+
}
|
972 |
+
}
|
973 |
+
|
974 |
+
foreach ($tmp_files as $file) { // remove all temporary files created
|
975 |
+
unlink($file);
|
976 |
+
}
|
977 |
+
}
|
978 |
+
|
979 |
+
return $data;
|
980 |
+
}
|
981 |
+
|
982 |
+
function can_update_meta($meta_key, $import_options) {
|
983 |
+
|
984 |
+
//echo "<pre>";
|
985 |
+
//print_r($import_options['options']);
|
986 |
+
//echo "</pre>";
|
987 |
+
|
988 |
+
$import_options = $import_options['options'];
|
989 |
+
|
990 |
+
if ($import_options['update_all_data'] == 'yes')
|
991 |
+
return true;
|
992 |
+
|
993 |
+
if (!$import_options['is_update_custom_fields'])
|
994 |
+
return false;
|
995 |
+
|
996 |
+
if ($import_options['update_custom_fields_logic'] == "full_update")
|
997 |
+
return true;
|
998 |
+
if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']))
|
999 |
+
return true;
|
1000 |
+
if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) ))
|
1001 |
+
return true;
|
1002 |
+
|
1003 |
+
return false;
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
function can_update_taxonomy($tax_name, $import_options) {
|
1007 |
+
|
1008 |
+
//echo "<pre>";
|
1009 |
+
//print_r($import_options['options']);
|
1010 |
+
//echo "</pre>";
|
1011 |
+
|
1012 |
+
$import_options = $import_options['options'];
|
1013 |
+
|
1014 |
+
if ($import_options['update_all_data'] == 'yes')
|
1015 |
+
return true;
|
1016 |
+
|
1017 |
+
if (!$import_options['is_update_categories'])
|
1018 |
+
return false;
|
1019 |
+
|
1020 |
+
if ($import_options['update_categories_logic'] == "full_update")
|
1021 |
+
return true;
|
1022 |
+
if ($import_options['update_categories_logic'] == "only" and ! empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list']))
|
1023 |
+
return true;
|
1024 |
+
if ($import_options['update_categories_logic'] == "all_except" and ( empty($import_options['taxonomies_list']) or ! in_array($tax_name, $import_options['taxonomies_list']) ))
|
1025 |
+
return true;
|
1026 |
+
|
1027 |
+
return false;
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
function can_update_image($import_options) {
|
1031 |
+
|
1032 |
+
$import_options = $import_options['options'];
|
1033 |
+
|
1034 |
+
if ($import_options['update_all_data'] == 'yes')
|
1035 |
+
return true;
|
1036 |
+
|
1037 |
+
if (!$import_options['is_update_images'])
|
1038 |
+
return false;
|
1039 |
+
|
1040 |
+
if ($import_options['is_update_images'])
|
1041 |
+
return true;
|
1042 |
+
|
1043 |
+
return false;
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
function admin_notice_ignore() {
|
1047 |
+
if (isset($_GET[$this->slug . '_ignore']) && '0' == $_GET[$this->slug . '_ignore']) {
|
1048 |
+
update_option($this->slug . '_ignore', 'true');
|
1049 |
+
}
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
function display_admin_notice() {
|
1053 |
+
|
1054 |
+
|
1055 |
+
if ($this->notice_text) {
|
1056 |
+
$notice_text = $this->notice_text;
|
1057 |
+
} else {
|
1058 |
+
$notice_text = $this->name . ' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
if (!get_option(sanitize_key($this->slug) . '_notice_ignore')) {
|
1062 |
+
?>
|
1063 |
+
|
1064 |
+
<div class="error notice is-dismissible wpallimport-dismissible" style="margin-top: 10px;" rel="<?php echo sanitize_key($this->slug); ?>">
|
1065 |
+
<p><?php
|
1066 |
+
_e(
|
1067 |
+
sprintf(
|
1068 |
+
$notice_text,
|
1069 |
+
'?' . $this->slug . '_ignore=0'
|
1070 |
+
),
|
1071 |
+
'rapid_addon_' . $this->slug
|
1072 |
+
);
|
1073 |
+
?></p>
|
1074 |
+
</div>
|
1075 |
+
|
1076 |
+
<?php
|
1077 |
+
}
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
/*
|
1081 |
+
*
|
1082 |
+
* $conditions - array('themes' => array('Realia'), 'plugins' => array('plugin-directory/plugin-file.php', 'plugin-directory2/plugin-file.php'))
|
1083 |
+
*
|
1084 |
+
*/
|
1085 |
+
|
1086 |
+
function admin_notice($notice_text = '', $conditions = array()) {
|
1087 |
+
|
1088 |
+
$is_show_notice = false;
|
1089 |
+
|
1090 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
1091 |
+
|
1092 |
+
if (!is_plugin_active('wp-all-import-pro/wp-all-import-pro.php') and ! is_plugin_active('wp-all-import/plugin.php')) {
|
1093 |
+
$is_show_notice = true;
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
// Supported Themes
|
1097 |
+
if (!$is_show_notice and ! empty($conditions['themes'])) {
|
1098 |
+
|
1099 |
+
$themeInfo = wp_get_theme();
|
1100 |
+
$parentInfo = $themeInfo->parent();
|
1101 |
+
$currentTheme = $themeInfo->get('Name');
|
1102 |
+
|
1103 |
+
$is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;
|
1104 |
+
|
1105 |
+
if ($is_show_notice and $parentInfo) {
|
1106 |
+
$parent_theme = $parentInfo->get('Name');
|
1107 |
+
$is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true;
|
1108 |
+
}
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
// Required Plugins
|
1112 |
+
if (!$is_show_notice and ! empty($conditions['plugins'])) {
|
1113 |
+
|
1114 |
+
$requires_counter = 0;
|
1115 |
+
foreach ($conditions['plugins'] as $plugin) {
|
1116 |
+
if (is_plugin_active($plugin))
|
1117 |
+
$requires_counter++;
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
if ($requires_counter != count($conditions['plugins'])) {
|
1121 |
+
$is_show_notice = true;
|
1122 |
+
}
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
if ($is_show_notice) {
|
1126 |
+
|
1127 |
+
if ($notice_text != '') {
|
1128 |
+
$this->notice_text = $notice_text;
|
1129 |
+
}
|
1130 |
+
|
1131 |
+
add_action('admin_notices', array($this, 'display_admin_notice'));
|
1132 |
+
}
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
function log($m = false) {
|
1136 |
+
|
1137 |
+
$m and $this->logger and call_user_func($this->logger, $m);
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
public function remove_post_type($type = '') {
|
1141 |
+
if (!empty($type)) {
|
1142 |
+
$this->add_option('post_types_to_remove', $type);
|
1143 |
+
}
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
public function filter_post_types($custom_types = array(), $custom_type = '') {
|
1147 |
+
$options = $this->options_array();
|
1148 |
+
$option_key = 'post_types_to_remove';
|
1149 |
+
|
1150 |
+
if (array_key_exists($option_key, $options)) {
|
1151 |
+
$type = $options[$option_key];
|
1152 |
+
|
1153 |
+
if (!empty($type)) {
|
1154 |
+
if (!is_array($type)) {
|
1155 |
+
if (array_key_exists($type, $custom_types)) {
|
1156 |
+
unset($custom_types[$type]);
|
1157 |
+
}
|
1158 |
+
} else {
|
1159 |
+
foreach ($type as $key => $post_type) {
|
1160 |
+
if (array_key_exists($post_type, $custom_types)) {
|
1161 |
+
unset($custom_types[$post_type]);
|
1162 |
+
}
|
1163 |
+
}
|
1164 |
+
}
|
1165 |
+
}
|
1166 |
+
}
|
1167 |
+
return $custom_types;
|
1168 |
+
}
|
1169 |
+
|
1170 |
+
public function sort_post_types(array $order) {
|
1171 |
+
$options = $this->options_array();
|
1172 |
+
$option_key = 'post_type_move';
|
1173 |
+
|
1174 |
+
if (array_key_exists($option_key, $options)) {
|
1175 |
+
$move_rules = maybe_unserialize($options[$option_key]);
|
1176 |
+
|
1177 |
+
foreach ($move_rules as $rule) {
|
1178 |
+
$move_this = $rule['move_this'];
|
1179 |
+
$move_to = $rule['move_to'];
|
1180 |
+
if ($move_to > count($order)) {
|
1181 |
+
if (( $rm_key = array_search($move_this, $order) ) !== false) {
|
1182 |
+
unset($order[$rm_key]);
|
1183 |
+
}
|
1184 |
+
array_push($order, $move_this);
|
1185 |
+
} else {
|
1186 |
+
if (( $rm_key = array_search($move_this, $order) ) !== false) {
|
1187 |
+
unset($order[$rm_key]);
|
1188 |
+
}
|
1189 |
+
array_splice($order, $move_to, 0, $move_this);
|
1190 |
+
}
|
1191 |
+
}
|
1192 |
+
|
1193 |
+
return $order;
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
return $order;
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
public function move_post_type($move_this = null, $move_to = null) {
|
1200 |
+
$move_rules = array();
|
1201 |
+
|
1202 |
+
if (!is_array($move_this) && !is_array($move_to)) {
|
1203 |
+
$move_rules[] = array(
|
1204 |
+
'move_this' => $move_this,
|
1205 |
+
'move_to' => $move_to
|
1206 |
+
);
|
1207 |
+
} else {
|
1208 |
+
foreach ($move_this as $key => $move_post) {
|
1209 |
+
$move_rules[] = array(
|
1210 |
+
'move_this' => $move_post,
|
1211 |
+
'move_to' => $move_to[$key]
|
1212 |
+
);
|
1213 |
+
}
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
$this->add_option('post_type_move', $move_rules);
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
public function set_post_type_image($post_type = null, $image = null) {
|
1220 |
+
$post_type_image_rules = array();
|
1221 |
+
|
1222 |
+
if (!is_array($post_type)) {
|
1223 |
+
|
1224 |
+
$post_type_image_rules[$post_type] = array(
|
1225 |
+
'post_type' => $post_type,
|
1226 |
+
'image' => $image
|
1227 |
+
);
|
1228 |
+
} else {
|
1229 |
+
|
1230 |
+
if (count($post_type) == count($image)) {
|
1231 |
+
|
1232 |
+
foreach ($post_type as $key => $post_name) {
|
1233 |
+
$post_type_image_rules[$post_name] = array(
|
1234 |
+
'post_type' => $post_name,
|
1235 |
+
'image' => $image[$key]
|
1236 |
+
);
|
1237 |
+
}
|
1238 |
+
}
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
$this->add_option('post_type_image', $post_type_image_rules);
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
public function post_type_image($image) {
|
1245 |
+
$options = $this->options_array();
|
1246 |
+
$option_key = 'post_type_image';
|
1247 |
+
if (array_key_exists($option_key, $options)) {
|
1248 |
+
$post_type_image_rules = maybe_unserialize($options[$option_key]);
|
1249 |
+
return $post_type_image_rules;
|
1250 |
+
}
|
1251 |
+
return $image;
|
1252 |
+
}
|
1253 |
+
|
1254 |
+
}
|
1255 |
+
|
1256 |
+
}
|
admin/wai-addon.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
include 'rapid-addon.php';
|
4 |
+
|
5 |
+
$fifu_wai_addon = new RapidAddon('<div style="color:#777"><img src="' . plugins_url() . '/featured-image-from-url/admin/images/favicon.png" style="filter: invert(50%);height:18px;padding-right:4px;position:relative;top:2px"> Featured Image from URL</div>', 'fifu_wai_addon');
|
6 |
+
$fifu_wai_addon->add_field('fifu_image_url', '<div title="fifu_image_url">Featured Image URL</div>', 'text', null, null, false, null);
|
7 |
+
$fifu_wai_addon->add_field('fifu_image_alt', '<div title="fifu_image_alt">Featured Image Alt/Title</div>', 'text', null, null, false, null);
|
8 |
+
$fifu_wai_addon->set_import_function('fifu_wai_addon_save');
|
9 |
+
$fifu_wai_addon->run();
|
10 |
+
|
11 |
+
function fifu_wai_addon_save($post_id, $data, $import_options, $article) {
|
12 |
+
$fields = array();
|
13 |
+
|
14 |
+
if (!empty('fifu_image_url'))
|
15 |
+
array_push($fields, 'fifu_image_url');
|
16 |
+
|
17 |
+
if (!empty('fifu_image_alt'))
|
18 |
+
array_push($fields, 'fifu_image_alt');
|
19 |
+
|
20 |
+
if (empty($fields))
|
21 |
+
return;
|
22 |
+
|
23 |
+
$update = false;
|
24 |
+
foreach ($fields as $field) {
|
25 |
+
$current_value = get_post_meta($post_id, $field, true);
|
26 |
+
if ($current_value != $data[$field]) {
|
27 |
+
$update = true;
|
28 |
+
update_post_meta($post_id, $field, $data[$field]);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
global $fifu_wai_addon;
|
33 |
+
if (!$update && !$fifu_wai_addon->can_update_image($import_options))
|
34 |
+
return;
|
35 |
+
|
36 |
+
fifu_wai_save($post_id);
|
37 |
+
|
38 |
+
/* metadata */
|
39 |
+
add_action('pmxi_saved_post', 'fifu_update_fake_attach_id');
|
40 |
+
}
|
featured-image-from-url.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Featured Image from URL
|
5 |
* Plugin URI: https://featuredimagefromurl.com/
|
6 |
* Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
|
7 |
-
* Version: 2.7.
|
8 |
* Author: Marcel Jacques Machado
|
9 |
* Author URI: https://www.linkedin.com/in/marceljm/
|
10 |
*/
|
@@ -27,6 +27,7 @@ require_once (FIFU_ADMIN_DIR . '/category.php');
|
|
27 |
require_once (FIFU_ADMIN_DIR . '/column.php');
|
28 |
require_once (FIFU_ADMIN_DIR . '/menu.php');
|
29 |
require_once (FIFU_ADMIN_DIR . '/meta-box.php');
|
|
|
30 |
|
31 |
register_activation_hook(__FILE__, 'fifu_activate');
|
32 |
|
4 |
* Plugin Name: Featured Image from URL
|
5 |
* Plugin URI: https://featuredimagefromurl.com/
|
6 |
* Description: Use an external image as Featured Image of your post/page/custom post type (WooCommerce). Includes Auto Set (External Post), Product Gallery, Social Tags and more.
|
7 |
+
* Version: 2.7.2
|
8 |
* Author: Marcel Jacques Machado
|
9 |
* Author URI: https://www.linkedin.com/in/marceljm/
|
10 |
*/
|
27 |
require_once (FIFU_ADMIN_DIR . '/column.php');
|
28 |
require_once (FIFU_ADMIN_DIR . '/menu.php');
|
29 |
require_once (FIFU_ADMIN_DIR . '/meta-box.php');
|
30 |
+
require_once (FIFU_ADMIN_DIR . '/wai-addon.php');
|
31 |
|
32 |
register_activation_hook(__FILE__, 'fifu_activate');
|
33 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Plugin Name ===
|
2 |
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, vimeo, featured video, hover, effects, hover effects, sirv, wp all import, css, style, slider, thumbnail, social, network, auto, publish, hide, first image, content, lightbox, size, grid, auto post thumbnail, link, uri, affiliate, wp, rest, api, wp rest api, lazy, load, google, drive, instagram, validation, jetpack, visual composer, play, pause, crop, resize, zoom, enable, disable, default, automatic, auto set, cloudinary, schedule, event, cron, seo, variable, tumblr, variation, product variation, shortcode, facebook, instagram, imgur, 9gag, wcfm
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 2.7.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -159,6 +159,9 @@ Features:
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
|
|
|
|
|
|
162 |
= 2.7.1 =
|
163 |
* New feature: Text > Auto Set Image Alt > always use the post title; Improvement: icons added to menu settings.
|
164 |
|
@@ -642,6 +645,9 @@ was removed. To finish, a Premium version is now been presented.
|
|
642 |
|
643 |
== Upgrade Notice ==
|
644 |
|
|
|
|
|
|
|
645 |
= 2.7.1 =
|
646 |
* New feature: Text > Auto Set Image Alt > always use the post title; Improvement: icons added to menu settings.
|
647 |
|
1 |
=== Plugin Name ===
|
2 |
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, vimeo, featured video, hover, effects, hover effects, sirv, wp all import, css, style, slider, thumbnail, social, network, auto, publish, hide, first image, content, lightbox, size, grid, auto post thumbnail, link, uri, affiliate, wp, rest, api, wp rest api, lazy, load, google, drive, instagram, validation, jetpack, visual composer, play, pause, crop, resize, zoom, enable, disable, default, automatic, auto set, cloudinary, schedule, event, cron, seo, variable, tumblr, variation, product variation, shortcode, facebook, instagram, imgur, 9gag, wcfm, add-on
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 5.4
|
7 |
+
Stable tag: 2.7.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
+
= 2.7.2 =
|
163 |
+
* New feature: FIFU has its own WP All Import add-on now. ACF add-on is not required anymore.
|
164 |
+
|
165 |
= 2.7.1 =
|
166 |
* New feature: Text > Auto Set Image Alt > always use the post title; Improvement: icons added to menu settings.
|
167 |
|
645 |
|
646 |
== Upgrade Notice ==
|
647 |
|
648 |
+
= 2.7.2 =
|
649 |
+
* New feature: FIFU has its own WP All Import add-on now. ACF add-on is not required anymore.
|
650 |
+
|
651 |
= 2.7.1 =
|
652 |
* New feature: Text > Auto Set Image Alt > always use the post title; Improvement: icons added to menu settings.
|
653 |
|