Version Description
Current Version of Popup Builder is 3.1
Download this release
Release Info
Developer | Sygnoos |
Plugin | Popup Builder – Responsive WordPress Pop up |
Version | 3.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.9.1 to 3.1
- com/classes/Actions.php +28 -1
- com/classes/Ajax.php +54 -0
- com/classes/Filters.php +11 -1
- com/classes/Installer.php +23 -0
- com/classes/PopupChecker.php +4 -0
- com/classes/Updates.php +6 -3
- com/classes/extension/SgpbPopupExtension.php +3 -2
- com/classes/popups/SGPopup.php +3 -3
- com/config/config.php +3 -0
- com/config/configPackage.php +1 -1
- com/config/dataConfig.php +1 -1
- com/helpers/AdminHelper.php +310 -4
- com/helpers/ConfigDataHelper.php +17 -2
- com/libs/Importer.php +1237 -0
- com/libs/parsers.php +700 -0
- languages/popupBuilder.pot +1 -1
- popup-builder.php +1 -1
- public/css/popupAdminStyles.css +33 -5
- public/js/MediaButton.js +13 -3
- public/js/Popup.js +1 -1
- public/js/PopupBuilder.js +1 -1
- public/views/conditionsView.php +13 -22
- public/views/importSettingsView.php +34 -0
- public/views/mainActionButtons.php +21 -0
- public/views/settings.php +6 -61
- public/views/settingsOptions.php +65 -0
- readme.txt +8 -2
com/classes/Actions.php
CHANGED
@@ -15,6 +15,7 @@ class Actions
|
|
15 |
|
16 |
public function init()
|
17 |
{
|
|
|
18 |
add_action('init', array($this, 'postTypeInit'), 9999);
|
19 |
add_action('admin_menu', array($this, 'addSubMenu'));
|
20 |
add_action('admin_menu', array($this, 'supportLinks'), 999);
|
@@ -49,9 +50,24 @@ class Actions
|
|
49 |
// for change admin popup list order
|
50 |
add_action('pre_get_posts', array($this, 'preGetPosts'));
|
51 |
add_action('template_redirect',array($this, 'redirectFromPopupPage'));
|
|
|
|
|
|
|
52 |
new Ajax();
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
/**
|
56 |
* Loads the plugin language files
|
57 |
*/
|
@@ -130,6 +146,10 @@ class Actions
|
|
130 |
if (!get_option('SGPB_PROMOTIONAL_BANNER_CLOSED') && $post_type == SG_POPUP_POST_TYPE) {
|
131 |
require_once(SG_POPUP_VIEWS_PATH.'mainRateUsBanner.php');
|
132 |
}
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
|
135 |
public function pluginNotices()
|
@@ -168,8 +188,16 @@ class Actions
|
|
168 |
return true;
|
169 |
}
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
public function pluginLoaded()
|
172 |
{
|
|
|
173 |
$versionPopup = get_option('SG_POPUP_VERSION');
|
174 |
$convert = get_option('sgpbConvertToNewVersion');
|
175 |
$unsubscribeColumnFixed = get_option('sgpbUnsubscribeColumnFixed');
|
@@ -506,7 +534,6 @@ class Actions
|
|
506 |
}
|
507 |
|
508 |
$unsubscribeArgs = $this->collectUnsubscriberArgs();
|
509 |
-
|
510 |
if (!empty($unsubscribeArgs)) {
|
511 |
$this->unsubscribe($unsubscribeArgs);
|
512 |
}
|
15 |
|
16 |
public function init()
|
17 |
{
|
18 |
+
add_action('init', array($this, 'wpInit'), 9999999999);
|
19 |
add_action('init', array($this, 'postTypeInit'), 9999);
|
20 |
add_action('admin_menu', array($this, 'addSubMenu'));
|
21 |
add_action('admin_menu', array($this, 'supportLinks'), 999);
|
50 |
// for change admin popup list order
|
51 |
add_action('pre_get_posts', array($this, 'preGetPosts'));
|
52 |
add_action('template_redirect',array($this, 'redirectFromPopupPage'));
|
53 |
+
|
54 |
+
|
55 |
+
add_filter('views_edit-popupbuilder', array($this, 'mainActionButtons'), 10, 1);
|
56 |
new Ajax();
|
57 |
}
|
58 |
|
59 |
+
public function wpInit()
|
60 |
+
{
|
61 |
+
new Updates();
|
62 |
+
}
|
63 |
+
|
64 |
+
public function mainActionButtons($views)
|
65 |
+
{
|
66 |
+
require_once(SG_POPUP_VIEWS_PATH.'mainActionButtons.php');
|
67 |
+
|
68 |
+
return $views;
|
69 |
+
}
|
70 |
+
|
71 |
/**
|
72 |
* Loads the plugin language files
|
73 |
*/
|
146 |
if (!get_option('SGPB_PROMOTIONAL_BANNER_CLOSED') && $post_type == SG_POPUP_POST_TYPE) {
|
147 |
require_once(SG_POPUP_VIEWS_PATH.'mainRateUsBanner.php');
|
148 |
}
|
149 |
+
|
150 |
+
if (!get_option('SGPB_ASK_FOR_REVIEW_BANNER_CLOSED') && $post_type == SG_POPUP_POST_TYPE) {
|
151 |
+
echo AdminHelper::showReviewPopup();
|
152 |
+
}
|
153 |
}
|
154 |
|
155 |
public function pluginNotices()
|
188 |
return true;
|
189 |
}
|
190 |
|
191 |
+
private function registerImporter()
|
192 |
+
{
|
193 |
+
require_once SG_POPUP_LIBS_PATH.'Importer.php';
|
194 |
+
$importer = new WP_Import();
|
195 |
+
register_importer(SG_POPUP_POST_TYPE, SG_POPUP_POST_TYPE, __('Importer', SG_POPUP_TEXT_DOMAIN), array($importer, 'dispatch'));
|
196 |
+
}
|
197 |
+
|
198 |
public function pluginLoaded()
|
199 |
{
|
200 |
+
$this->registerImporter();
|
201 |
$versionPopup = get_option('SG_POPUP_VERSION');
|
202 |
$convert = get_option('sgpbConvertToNewVersion');
|
203 |
$unsubscribeColumnFixed = get_option('sgpbUnsubscribeColumnFixed');
|
534 |
}
|
535 |
|
536 |
$unsubscribeArgs = $this->collectUnsubscriberArgs();
|
|
|
537 |
if (!empty($unsubscribeArgs)) {
|
538 |
$this->unsubscribe($unsubscribeArgs);
|
539 |
}
|
com/classes/Ajax.php
CHANGED
@@ -58,14 +58,61 @@ class Ajax
|
|
58 |
add_action('wp_ajax_sgpb_add_subscribers', array($this, 'addSubscribers'));
|
59 |
add_action('wp_ajax_sgpb_send_newsletter', array($this, 'sendNewsletter'));
|
60 |
add_action('wp_ajax_sgpb_send_to_open_counter', array($this, 'addToCounter'));
|
|
|
|
|
|
|
|
|
61 |
add_action('wp_ajax_nopriv_sgpb_send_to_open_counter', array($this, 'addToCounter'));
|
62 |
add_action('wp_ajax_sgpb_close_banner', array($this, 'closeMainRateUsBanner'));
|
|
|
63 |
add_action('wp_ajax_sgpb_reset_popup_opening_count', array($this, 'resetPopupOpeningCount'));
|
64 |
/*Extension notification panel*/
|
65 |
add_action('wp_ajax_sgpb_dont_show_extension_panel', array($this, 'extensionNotificationPanel'));
|
66 |
add_action('wp_ajax_sgpb_dont_show_problem_alert', array($this, 'dontShowProblemAlert'));
|
67 |
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
public function resetPopupOpeningCount()
|
70 |
{
|
71 |
check_ajax_referer(SG_AJAX_NONCE, 'nonce');
|
@@ -86,6 +133,12 @@ class Ajax
|
|
86 |
|
87 |
update_option('SgpbCounter', $allPopupsCount);
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
echo SGPB_AJAX_STATUS_TRUE;
|
90 |
wp_die();
|
91 |
}
|
@@ -436,6 +489,7 @@ class Ajax
|
|
436 |
}
|
437 |
}
|
438 |
}
|
|
|
439 |
$savedData['value'] = array();
|
440 |
$savedData['hiddenOption'] = @$conditionConfig['hiddenOptionData'][$paramName];
|
441 |
|
58 |
add_action('wp_ajax_sgpb_add_subscribers', array($this, 'addSubscribers'));
|
59 |
add_action('wp_ajax_sgpb_send_newsletter', array($this, 'sendNewsletter'));
|
60 |
add_action('wp_ajax_sgpb_send_to_open_counter', array($this, 'addToCounter'));
|
61 |
+
add_action('wp_ajax_sgpb_change_review_popup_show_period', array($this, 'changeReviewPopupPeriod'));
|
62 |
+
add_action('wp_ajax_nopriv_sgpb_change_review_popup_show_period', array($this, 'changeReviewPopupPeriod'));
|
63 |
+
add_action('wp_ajax_sgpb_dont_show_review_popup', array($this, 'dontShowReviewPopup'));
|
64 |
+
add_action('wp_ajax_nopriv_sgpb_dont_show_review_popup', array($this, 'dontShowReviewPopup'));
|
65 |
add_action('wp_ajax_nopriv_sgpb_send_to_open_counter', array($this, 'addToCounter'));
|
66 |
add_action('wp_ajax_sgpb_close_banner', array($this, 'closeMainRateUsBanner'));
|
67 |
+
add_action('wp_ajax_sgpb_hide_ask_review_popup', array($this, 'dontShowAskReviewBanner'));
|
68 |
add_action('wp_ajax_sgpb_reset_popup_opening_count', array($this, 'resetPopupOpeningCount'));
|
69 |
/*Extension notification panel*/
|
70 |
add_action('wp_ajax_sgpb_dont_show_extension_panel', array($this, 'extensionNotificationPanel'));
|
71 |
add_action('wp_ajax_sgpb_dont_show_problem_alert', array($this, 'dontShowProblemAlert'));
|
72 |
}
|
73 |
|
74 |
+
public function dontShowReviewPopup()
|
75 |
+
{
|
76 |
+
check_ajax_referer(SG_AJAX_NONCE, 'nonce');
|
77 |
+
update_option('SGPBCloseReviewPopup', true);
|
78 |
+
wp_die();
|
79 |
+
}
|
80 |
+
|
81 |
+
public function changeReviewPopupPeriod()
|
82 |
+
{
|
83 |
+
check_ajax_referer(SG_AJAX_NONCE, 'nonce');
|
84 |
+
$messageType = sanitize_text_field($_POST['messageType']);
|
85 |
+
|
86 |
+
if ($messageType == 'count') {
|
87 |
+
$maxPopupCount = get_option('SGPBMaxOpenCount');
|
88 |
+
if (!$maxPopupCount) {
|
89 |
+
$maxPopupCount = SGPB_ASK_REVIEW_POPUP_COUNT;
|
90 |
+
}
|
91 |
+
$maxPopupData = AdminHelper::getMaxOpenPopupId();
|
92 |
+
if (!empty($maxPopupData['maxCount'])) {
|
93 |
+
$maxPopupCount = $maxPopupData['maxCount'];
|
94 |
+
}
|
95 |
+
|
96 |
+
$maxPopupCount += SGPB_ASK_REVIEW_POPUP_COUNT;
|
97 |
+
update_option('SGPBMaxOpenCount', $maxPopupCount);
|
98 |
+
wp_die();
|
99 |
+
}
|
100 |
+
|
101 |
+
$popupTimeZone = get_option('timezone_string');
|
102 |
+
if (!$popupTimeZone) {
|
103 |
+
$popupTimeZone = SG_POPUP_DEFAULT_TIME_ZONE;
|
104 |
+
}
|
105 |
+
$timeDate = new \DateTime('now', new \DateTimeZone($popupTimeZone));
|
106 |
+
$timeDate->modify('+'.SGPB_REVIEW_POPUP_PERIOD.' day');
|
107 |
+
|
108 |
+
$timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
|
109 |
+
update_option('SGPBOpenNextTime', $timeNow);
|
110 |
+
$usageDays = get_option('SGPBUsageDays');
|
111 |
+
$usageDays += SGPB_REVIEW_POPUP_PERIOD;
|
112 |
+
update_option('SGPBUsageDays', $usageDays);
|
113 |
+
wp_die();
|
114 |
+
}
|
115 |
+
|
116 |
public function resetPopupOpeningCount()
|
117 |
{
|
118 |
check_ajax_referer(SG_AJAX_NONCE, 'nonce');
|
133 |
|
134 |
update_option('SgpbCounter', $allPopupsCount);
|
135 |
|
136 |
+
}
|
137 |
+
|
138 |
+
public function dontShowAskReviewBanner()
|
139 |
+
{
|
140 |
+
check_ajax_referer(SG_AJAX_NONCE, 'nonce');
|
141 |
+
update_option('sgpbDontShowAskReviewBanner', 1);
|
142 |
echo SGPB_AJAX_STATUS_TRUE;
|
143 |
wp_die();
|
144 |
}
|
489 |
}
|
490 |
}
|
491 |
}
|
492 |
+
// by default set empty value for users' role (adv. tar.)
|
493 |
$savedData['value'] = array();
|
494 |
$savedData['hiddenOption'] = @$conditionConfig['hiddenOptionData'][$paramName];
|
495 |
|
com/classes/Filters.php
CHANGED
@@ -25,6 +25,16 @@ class Filters
|
|
25 |
add_filter('sgpbPopupEvents', array($this, 'popupEvents'), 10, 1);
|
26 |
add_filter('sgpbAdditionalMetaboxes', array($this, 'metaboxes'), 10, 1);
|
27 |
add_filter('sgpbOptionAvailable', array($this, 'filterOption'), 10, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
|
30 |
public function filterOption($filterOption)
|
@@ -283,7 +293,7 @@ class Filters
|
|
283 |
unset($columns['date']);
|
284 |
|
285 |
$additionalItems = array();
|
286 |
-
$additionalItems['counter'] = __('
|
287 |
$additionalItems['onOff'] = __('Enabled (show popup)', SG_POPUP_TEXT_DOMAIN);
|
288 |
$additionalItems['type'] = __('Type', SG_POPUP_TEXT_DOMAIN);
|
289 |
$additionalItems['shortcode'] = __('Shortcode', SG_POPUP_TEXT_DOMAIN);
|
25 |
add_filter('sgpbPopupEvents', array($this, 'popupEvents'), 10, 1);
|
26 |
add_filter('sgpbAdditionalMetaboxes', array($this, 'metaboxes'), 10, 1);
|
27 |
add_filter('sgpbOptionAvailable', array($this, 'filterOption'), 10, 1);
|
28 |
+
add_filter('export_wp_filename', array($this, 'exportFileName'), 10, 1);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function exportFileName($fileName)
|
32 |
+
{
|
33 |
+
if (!empty($_GET['sgpbExportAction'])) {
|
34 |
+
return SGPB_POPUP_EXPORT_FILE_NAME;
|
35 |
+
}
|
36 |
+
|
37 |
+
return $fileName;
|
38 |
}
|
39 |
|
40 |
public function filterOption($filterOption)
|
293 |
unset($columns['date']);
|
294 |
|
295 |
$additionalItems = array();
|
296 |
+
$additionalItems['counter'] = __('Views', SG_POPUP_TEXT_DOMAIN);
|
297 |
$additionalItems['onOff'] = __('Enabled (show popup)', SG_POPUP_TEXT_DOMAIN);
|
298 |
$additionalItems['type'] = __('Type', SG_POPUP_TEXT_DOMAIN);
|
299 |
$additionalItems['shortcode'] = __('Shortcode', SG_POPUP_TEXT_DOMAIN);
|
com/classes/Installer.php
CHANGED
@@ -70,6 +70,8 @@ class Installer
|
|
70 |
|
71 |
self::createTables($filteredTables);
|
72 |
|
|
|
|
|
73 |
// get_current_blog_id() == 1 When plugin activated inside the child of multisite instance
|
74 |
if (is_multisite() && get_current_blog_id() == 1) {
|
75 |
global $wp_version;
|
@@ -97,6 +99,27 @@ class Installer
|
|
97 |
}
|
98 |
}
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
public static function uninstall()
|
101 |
{
|
102 |
delete_option('sgpb-user-roles');
|
70 |
|
71 |
self::createTables($filteredTables);
|
72 |
|
73 |
+
self::setupInstallationsDateConfig($filteredTables);
|
74 |
+
|
75 |
// get_current_blog_id() == 1 When plugin activated inside the child of multisite instance
|
76 |
if (is_multisite() && get_current_blog_id() == 1) {
|
77 |
global $wp_version;
|
99 |
}
|
100 |
}
|
101 |
|
102 |
+
public static function setupInstallationsDateConfig()
|
103 |
+
{
|
104 |
+
$usageDays = get_option('SGPBUsageDays');
|
105 |
+
if (!$usageDays) {
|
106 |
+
update_option('SGPBUsageDays', 0);
|
107 |
+
|
108 |
+
$timeDate = new \DateTime('now');
|
109 |
+
$installTime = strtotime($timeDate->format('Y-m-d H:i:s'));
|
110 |
+
update_option('SGPBInstallDate', $installTime);
|
111 |
+
$timeDate->modify('+'.SGPB_REVIEW_POPUP_PERIOD.' day');
|
112 |
+
|
113 |
+
$timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
|
114 |
+
update_option('SGPBOpenNextTime', $timeNow);
|
115 |
+
}
|
116 |
+
|
117 |
+
$maxPopupCount = get_option('SGPBMaxOpenCount');
|
118 |
+
if (!$maxPopupCount) {
|
119 |
+
update_option('SGPBMaxOpenCount', SGPB_ASK_REVIEW_POPUP_COUNT);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
public static function uninstall()
|
124 |
{
|
125 |
delete_option('sgpb-user-roles');
|
com/classes/PopupChecker.php
CHANGED
@@ -324,6 +324,10 @@ class PopupChecker
|
|
324 |
else if ($targetData['param'] == 'post_category' && !empty($targetData['value'])) {
|
325 |
$values = $targetData['value'];
|
326 |
$currentPostCategories = get_the_category($postId);
|
|
|
|
|
|
|
|
|
327 |
|
328 |
foreach ($currentPostCategories as $categoryName) {
|
329 |
if (in_array($categoryName->term_id, $values)) {
|
324 |
else if ($targetData['param'] == 'post_category' && !empty($targetData['value'])) {
|
325 |
$values = $targetData['value'];
|
326 |
$currentPostCategories = get_the_category($postId);
|
327 |
+
$currentPostType = get_post_type($postId);
|
328 |
+
if (empty($currentPostCategories) && $currentPostType == 'product') {
|
329 |
+
$currentPostCategories = get_the_terms($postId, 'product_cat');
|
330 |
+
}
|
331 |
|
332 |
foreach ($currentPostCategories as $categoryName) {
|
333 |
if (in_array($categoryName->term_id, $values)) {
|
com/classes/Updates.php
CHANGED
@@ -74,6 +74,11 @@ class Updates
|
|
74 |
}
|
75 |
|
76 |
$version = @constant('SG_VERSION_'.$key);
|
|
|
|
|
|
|
|
|
|
|
77 |
$sgpbUpdater = new EDD_SL_Plugin_Updater($storeURL, $pluginMainFilePath, array(
|
78 |
'version' => $version, // current version number
|
79 |
'license' => $licenseKey, // license key (used get_option above to retrieve from DB)
|
@@ -242,6 +247,4 @@ class Updates
|
|
242 |
}
|
243 |
}
|
244 |
}
|
245 |
-
}
|
246 |
-
|
247 |
-
new Updates();
|
74 |
}
|
75 |
|
76 |
$version = @constant('SG_VERSION_'.$key);
|
77 |
+
|
78 |
+
// If the version of the extension is not found, update will not possibly be shown
|
79 |
+
if(empty($version)) {
|
80 |
+
continue;
|
81 |
+
}
|
82 |
$sgpbUpdater = new EDD_SL_Plugin_Updater($storeURL, $pluginMainFilePath, array(
|
83 |
'version' => $version, // current version number
|
84 |
'license' => $licenseKey, // license key (used get_option above to retrieve from DB)
|
247 |
}
|
248 |
}
|
249 |
}
|
250 |
+
}
|
|
|
|
com/classes/extension/SgpbPopupExtension.php
CHANGED
@@ -25,7 +25,7 @@ class SgpbPopupExtension implements SgpbIPopupExtension
|
|
25 |
$newsletterPage = $this->getNewsletterPageKey();
|
26 |
$settingsPage = $this->getSettingsPageKey();
|
27 |
|
28 |
-
$jsFiles[] = array('folderUrl'=> SG_POPUP_JS_URL, 'filename' => 'ExtensionsNotification.js');
|
29 |
$localizeData[] = array(
|
30 |
'handle' => 'ExtensionsNotification.js',
|
31 |
'name' => 'SGPB_JS_EXTENSIONS_PARAMS',
|
@@ -34,7 +34,8 @@ class SgpbPopupExtension implements SgpbIPopupExtension
|
|
34 |
'popupPostType' => SG_POPUP_POST_TYPE,
|
35 |
'extendPage' => SG_POPUP_EXTEND_PAGE,
|
36 |
'supportUrl' => SG_POPUP_SUPPORT_URL,
|
37 |
-
'allExtensionsUrl' => SG_POPUP_ALL_EXTENSIONS_URL
|
|
|
38 |
)
|
39 |
);
|
40 |
|
25 |
$newsletterPage = $this->getNewsletterPageKey();
|
26 |
$settingsPage = $this->getSettingsPageKey();
|
27 |
|
28 |
+
$jsFiles[] = array('folderUrl'=> SG_POPUP_JS_URL, 'filename' => 'ExtensionsNotification.js', 'dep' => array('jquery'));
|
29 |
$localizeData[] = array(
|
30 |
'handle' => 'ExtensionsNotification.js',
|
31 |
'name' => 'SGPB_JS_EXTENSIONS_PARAMS',
|
34 |
'popupPostType' => SG_POPUP_POST_TYPE,
|
35 |
'extendPage' => SG_POPUP_EXTEND_PAGE,
|
36 |
'supportUrl' => SG_POPUP_SUPPORT_URL,
|
37 |
+
'allExtensionsUrl' => SG_POPUP_ALL_EXTENSIONS_URL,
|
38 |
+
'reviewUrl' => SG_POPUP_RATE_US_URL
|
39 |
)
|
40 |
);
|
41 |
|
com/classes/popups/SGPopup.php
CHANGED
@@ -249,7 +249,7 @@ abstract class SGPopup
|
|
249 |
return false;
|
250 |
}
|
251 |
|
252 |
-
$type =
|
253 |
|
254 |
$popupClassName = self::getPopupClassNameFormType($type);
|
255 |
$typePath = self::getPopupTypeClassPath($type);
|
@@ -1527,7 +1527,7 @@ abstract class SGPopup
|
|
1527 |
$popupCountFromAnalyticsData = 0;
|
1528 |
$tableName = $wpdb->prefix.'sgpb_analytics';
|
1529 |
if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
|
1530 |
-
$popupCountFromAnalyticsData =
|
1531 |
}
|
1532 |
if (isset($popupsCounterData[$popupId])) {
|
1533 |
$allCount += $popupsCounterData[$popupId];
|
@@ -1537,7 +1537,7 @@ abstract class SGPopup
|
|
1537 |
return $allCount;
|
1538 |
}
|
1539 |
|
1540 |
-
public function getAnalyticsDataByPopupId($popupId)
|
1541 |
{
|
1542 |
global $wpdb;
|
1543 |
// 7, 12, 13 => exclude close, subscription success, contact success events
|
249 |
return false;
|
250 |
}
|
251 |
|
252 |
+
$type = @$savedData['sgpb-type'];
|
253 |
|
254 |
$popupClassName = self::getPopupClassNameFormType($type);
|
255 |
$typePath = self::getPopupTypeClassPath($type);
|
1527 |
$popupCountFromAnalyticsData = 0;
|
1528 |
$tableName = $wpdb->prefix.'sgpb_analytics';
|
1529 |
if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
|
1530 |
+
$popupCountFromAnalyticsData = self::getAnalyticsDataByPopupId($popupId);
|
1531 |
}
|
1532 |
if (isset($popupsCounterData[$popupId])) {
|
1533 |
$allCount += $popupsCounterData[$popupId];
|
1537 |
return $allCount;
|
1538 |
}
|
1539 |
|
1540 |
+
public static function getAnalyticsDataByPopupId($popupId)
|
1541 |
{
|
1542 |
global $wpdb;
|
1543 |
// 7, 12, 13 => exclude close, subscription success, contact success events
|
com/config/config.php
CHANGED
@@ -103,6 +103,9 @@ class SgpbPopupConfig
|
|
103 |
self::addDefine('SGPB_POPUP_SCHEDULING_EXTENSION_KEY', 'popupbuilder-scheduling/PopupBuilderScheduling.php');
|
104 |
self::addDefine('SGPB_POPUP_GEO_TARGETING_EXTENSION_KEY', 'popupbuilder-geo-targeting/PopupBuilderGeoTargeting.php');
|
105 |
self::addDefine('SGPB_POPUP_ADVANCED_TARGETING_EXTENSION_KEY', 'popupbuilder-advanced-targeting/PopupBuilderAdvancedTargeting.php');
|
|
|
|
|
|
|
106 |
self::popupTypesInit();
|
107 |
}
|
108 |
|
103 |
self::addDefine('SGPB_POPUP_SCHEDULING_EXTENSION_KEY', 'popupbuilder-scheduling/PopupBuilderScheduling.php');
|
104 |
self::addDefine('SGPB_POPUP_GEO_TARGETING_EXTENSION_KEY', 'popupbuilder-geo-targeting/PopupBuilderGeoTargeting.php');
|
105 |
self::addDefine('SGPB_POPUP_ADVANCED_TARGETING_EXTENSION_KEY', 'popupbuilder-advanced-targeting/PopupBuilderAdvancedTargeting.php');
|
106 |
+
self::addDefine('SGPB_ASK_REVIEW_POPUP_COUNT', 80);
|
107 |
+
self::addDefine('SGPB_REVIEW_POPUP_PERIOD', 30);
|
108 |
+
self::addDefine('SGPB_POPUP_EXPORT_FILE_NAME', 'PopupBuilderPopups.xml');
|
109 |
self::popupTypesInit();
|
110 |
}
|
111 |
|
com/config/configPackage.php
CHANGED
@@ -3,6 +3,6 @@ if (!defined('ABSPATH')) {
|
|
3 |
exit();
|
4 |
}
|
5 |
|
6 |
-
define('SG_POPUP_VERSION', '3.
|
7 |
define('SGPB_POPUP_PKG', SGPB_POPUP_PKG_FREE);
|
8 |
define('POPUP_BUILDER_BASENAME', 'popupbuilder-platinum/popup-builder.php');
|
3 |
exit();
|
4 |
}
|
5 |
|
6 |
+
define('SG_POPUP_VERSION', '3.1');
|
7 |
define('SGPB_POPUP_PKG', SGPB_POPUP_PKG_FREE);
|
8 |
define('POPUP_BUILDER_BASENAME', 'popupbuilder-platinum/popup-builder.php');
|
com/config/dataConfig.php
CHANGED
@@ -523,7 +523,7 @@ class SgpbDataConfig
|
|
523 |
);
|
524 |
$keys[] = array(
|
525 |
'label' => __('Restriction', SG_POPUP_TEXT_DOMAIN),
|
526 |
-
'pluginKey' => 'popupbuilder-restriction/
|
527 |
'key' => 'ageRestriction',
|
528 |
'url' => SG_POPUP_RESTRICTION_URL
|
529 |
);
|
523 |
);
|
524 |
$keys[] = array(
|
525 |
'label' => __('Restriction', SG_POPUP_TEXT_DOMAIN),
|
526 |
+
'pluginKey' => 'popupbuilder-restriction/PopupBuilderAgerestriction.php',
|
527 |
'key' => 'ageRestriction',
|
528 |
'url' => SG_POPUP_RESTRICTION_URL
|
529 |
);
|
com/helpers/AdminHelper.php
CHANGED
@@ -38,6 +38,37 @@ class AdminHelper
|
|
38 |
return $extensionOptions;
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
public static function buildCreatePopupUrl($popupType)
|
42 |
{
|
43 |
$isAvailable = $popupType->isAvailable();
|
@@ -875,7 +906,6 @@ class AdminHelper
|
|
875 |
return $currentPostType;
|
876 |
}
|
877 |
|
878 |
-
|
879 |
/**
|
880 |
* Get image encoded data from URL
|
881 |
*
|
@@ -906,9 +936,6 @@ class AdminHelper
|
|
906 |
$popup = '';
|
907 |
$noSubscriber = true;
|
908 |
|
909 |
-
if (!isset($params['sgpbUnsubscribe'])) {
|
910 |
-
return false;
|
911 |
-
}
|
912 |
if (isset($params['token'])) {
|
913 |
$token = $params['token'];
|
914 |
}
|
@@ -1012,4 +1039,283 @@ class AdminHelper
|
|
1012 |
|
1013 |
return $isActive;
|
1014 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1015 |
}
|
38 |
return $extensionOptions;
|
39 |
}
|
40 |
|
41 |
+
public static function getPopupTypesPageURL()
|
42 |
+
{
|
43 |
+
return admin_url('edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SG_POPUP_POST_TYPE);
|
44 |
+
}
|
45 |
+
|
46 |
+
public static function getSettingsURL($args = array())
|
47 |
+
{
|
48 |
+
$url = admin_url('/edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SG_POPUP_SETTINGS_PAGE);
|
49 |
+
|
50 |
+
return self::addArgsToURl($url, $args);
|
51 |
+
}
|
52 |
+
|
53 |
+
public static function getPopupExportURL()
|
54 |
+
{
|
55 |
+
$exportURL = admin_url('export.php');
|
56 |
+
$url = add_query_arg(array(
|
57 |
+
'download' => true,
|
58 |
+
'content' => SG_POPUP_POST_TYPE,
|
59 |
+
'sgpbExportAction' => 1
|
60 |
+
), $exportURL);
|
61 |
+
|
62 |
+
return $url;
|
63 |
+
}
|
64 |
+
|
65 |
+
public static function addArgsToURl($url, $args = array())
|
66 |
+
{
|
67 |
+
$resultURl = add_query_arg($args, $url);
|
68 |
+
|
69 |
+
return $resultURl;
|
70 |
+
}
|
71 |
+
|
72 |
public static function buildCreatePopupUrl($popupType)
|
73 |
{
|
74 |
$isAvailable = $popupType->isAvailable();
|
906 |
return $currentPostType;
|
907 |
}
|
908 |
|
|
|
909 |
/**
|
910 |
* Get image encoded data from URL
|
911 |
*
|
936 |
$popup = '';
|
937 |
$noSubscriber = true;
|
938 |
|
|
|
|
|
|
|
939 |
if (isset($params['token'])) {
|
940 |
$token = $params['token'];
|
941 |
}
|
1039 |
|
1040 |
return $isActive;
|
1041 |
}
|
1042 |
+
|
1043 |
+
public static function getMaxCountPopup()
|
1044 |
+
{
|
1045 |
+
$allPopups = SGPopup::getAllPopups();
|
1046 |
+
$dontShowPopup = get_option('sgpbDontShowAskReviewBanner');
|
1047 |
+
if ($dontShowPopup) {
|
1048 |
+
return false;
|
1049 |
+
}
|
1050 |
+
$result = array();
|
1051 |
+
|
1052 |
+
if (empty($allPopups)) {
|
1053 |
+
return false;
|
1054 |
+
}
|
1055 |
+
foreach ($allPopups as $popup) {
|
1056 |
+
if (empty($popup)) {
|
1057 |
+
continue;
|
1058 |
+
}
|
1059 |
+
$popupId = $popup->getId();
|
1060 |
+
$count = SGPopup::getPopupOpeningCountById($popupId);
|
1061 |
+
|
1062 |
+
$title = $popup->getTitle();
|
1063 |
+
$result['title'] = $title;
|
1064 |
+
$result['count'] = $count;
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
return $result;
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
public static function showReviewPopup()
|
1071 |
+
{
|
1072 |
+
$popupContent = '';
|
1073 |
+
$maxOpenPopupStatus = self::shouldOpenForMaxOpenPopupMessage();
|
1074 |
+
|
1075 |
+
if ($maxOpenPopupStatus) {
|
1076 |
+
$popupContent = self::getMaxOpenPopupsMessage();
|
1077 |
+
self::addContentToFooter($popupContent);
|
1078 |
+
return;
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
$shouldOpenForDays = self::shouldOpenReviewPopupForDays();
|
1082 |
+
|
1083 |
+
if ($shouldOpenForDays) {
|
1084 |
+
$popupContent = self::getMaxOpenDaysMessage();
|
1085 |
+
self::addContentToBanner($popupContent);
|
1086 |
+
return;
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
public static function getMaxOpenDaysMessage()
|
1091 |
+
{
|
1092 |
+
$getUsageDays = self::getPopupUsageDays();
|
1093 |
+
$firstHeader = '<h1 class="sgpb-review-h1"><strong class="sgrb-review-strong">Wow!</strong> You’ve been using Popup Builder on your site for '.$getUsageDays.' days</h1>';
|
1094 |
+
$popupContent = self::getMaxOpenPopupContent($firstHeader, 'days');
|
1095 |
+
|
1096 |
+
return $popupContent;
|
1097 |
+
}
|
1098 |
+
|
1099 |
+
public static function getPopupUsageDays()
|
1100 |
+
{
|
1101 |
+
$installDate = get_option('SGPBInstallDate');
|
1102 |
+
|
1103 |
+
$timeDate = new \DateTime('now');
|
1104 |
+
$timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
|
1105 |
+
$diff = $timeNow-$installDate;
|
1106 |
+
$days = floor($diff/(60*60*24));
|
1107 |
+
|
1108 |
+
return $days;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
public static function getMaxOpenPopupContent($firstHeader, $type)
|
1112 |
+
{
|
1113 |
+
ob_start();
|
1114 |
+
?>
|
1115 |
+
<style>
|
1116 |
+
.sgpb-buttons-wrapper .press{
|
1117 |
+
box-sizing:border-box;
|
1118 |
+
cursor:pointer;
|
1119 |
+
display:inline-block;
|
1120 |
+
font-size:1em;
|
1121 |
+
margin:0;
|
1122 |
+
padding:0.5em 0.75em;
|
1123 |
+
text-decoration:none;
|
1124 |
+
transition:background 0.15s linear
|
1125 |
+
}
|
1126 |
+
.sgpb-buttons-wrapper .press-grey {
|
1127 |
+
background-color:#9E9E9E;
|
1128 |
+
border:2px solid #9E9E9E;
|
1129 |
+
color: #FFF;
|
1130 |
+
}
|
1131 |
+
.sgpb-buttons-wrapper .press-lightblue {
|
1132 |
+
background-color:#03A9F4;
|
1133 |
+
border:2px solid #03A9F4;
|
1134 |
+
color: #FFF;
|
1135 |
+
}
|
1136 |
+
.sgpb-review-wrapper{
|
1137 |
+
text-align: center;
|
1138 |
+
padding: 20px;
|
1139 |
+
}
|
1140 |
+
.sgpb-review-wrapper p {
|
1141 |
+
color: black;
|
1142 |
+
}
|
1143 |
+
.sgpb-review-h1 {
|
1144 |
+
font-size: 22px;
|
1145 |
+
font-weight: normal;
|
1146 |
+
line-height: 1.384;
|
1147 |
+
}
|
1148 |
+
.sgrb-review-h2{
|
1149 |
+
font-size: 20px;
|
1150 |
+
font-weight: normal;
|
1151 |
+
}
|
1152 |
+
:root {
|
1153 |
+
--main-bg-color: #1ac6ff;
|
1154 |
+
}
|
1155 |
+
.sgrb-review-strong{
|
1156 |
+
color: var(--main-bg-color);
|
1157 |
+
}
|
1158 |
+
.sgrb-review-mt20{
|
1159 |
+
margin-top: 20px
|
1160 |
+
}
|
1161 |
+
</style>
|
1162 |
+
<div class="sgpb-review-wrapper">
|
1163 |
+
<div class="sgpb-review-description">
|
1164 |
+
<?php echo $firstHeader; ?>
|
1165 |
+
<h2 class="sgrb-review-h2"><?php _e('This is really great for your website score.', SG_POPUP_TEXT_DOMAIN); ?></h2>
|
1166 |
+
<p class="sgrb-review-mt20"><?php _e('Have your input in the development of our plugin, and we’ll provide better conversions for your site!<br /> Leave your 5-star positive review and help us go further to the perfection!', SG_POPUP_TEXT_DOMAIN); ?></p>
|
1167 |
+
</div>
|
1168 |
+
<div class="sgpb-buttons-wrapper">
|
1169 |
+
<button class="press press-grey sgpb-button-1 sg-already-did-review"><?php _e('I already did', SG_POPUP_TEXT_DOMAIN); ?></button>
|
1170 |
+
<button class="press press-lightblue sgpb-button-3 sg-you-worth-it"><?php _e('You worth it!', SG_POPUP_TEXT_DOMAIN); ?></button>
|
1171 |
+
<button class="press press-grey sgpb-button-2 sg-show-popup-period" data-message-type="<?php echo $type; ?>"><?php _e('Maybe later', SG_POPUP_TEXT_DOMAIN); ?></button></div>
|
1172 |
+
<div> </div>
|
1173 |
+
</div>
|
1174 |
+
<?php
|
1175 |
+
$popupContent = ob_get_clean();
|
1176 |
+
|
1177 |
+
return $popupContent;
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
public static function shouldOpenReviewPopupForDays()
|
1181 |
+
{
|
1182 |
+
$shouldOpen = true;
|
1183 |
+
$dontShowAgain = get_option('SGPBCloseReviewPopup');
|
1184 |
+
$periodNextTime = get_option('SGPBOpenNextTime');
|
1185 |
+
|
1186 |
+
if ($dontShowAgain) {
|
1187 |
+
return false;
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
// When period next time does not exits it means the user is old
|
1191 |
+
if (!$periodNextTime) {
|
1192 |
+
$usageDays = self::getPopupMainTableCreationDate();
|
1193 |
+
update_option('SGPBUsageDays', $usageDays);
|
1194 |
+
// For old users
|
1195 |
+
if ($usageDays > SG_REVIEW_POPUP_PERIOD && !$dontShowAgain) {
|
1196 |
+
return $shouldOpen;
|
1197 |
+
}
|
1198 |
+
$remainingDays = SG_REVIEW_POPUP_PERIOD - $usageDays;
|
1199 |
+
|
1200 |
+
$popupTimeZone = @SgPopupGetData::getPopupTimeZone();
|
1201 |
+
$timeDate = new DateTime('now', new DateTimeZone($popupTimeZone));
|
1202 |
+
$timeDate->modify('+'.$remainingDays.' day');
|
1203 |
+
|
1204 |
+
$timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
|
1205 |
+
update_option('SGPBOpenNextTime', $timeNow);
|
1206 |
+
|
1207 |
+
return false;
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
$currentData = new \DateTime('now');
|
1211 |
+
$timeNow = $currentData->format('Y-m-d H:i:s');
|
1212 |
+
$timeNow = strtotime($timeNow);
|
1213 |
+
|
1214 |
+
if ($periodNextTime > $timeNow) {
|
1215 |
+
$shouldOpen = false;
|
1216 |
+
}
|
1217 |
+
|
1218 |
+
return $shouldOpen;
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
public static function getPopupMainTableCreationDate()
|
1222 |
+
{
|
1223 |
+
global $wpdb;
|
1224 |
+
|
1225 |
+
$query = $wpdb->prepare('SELECT table_name,create_time FROM information_schema.tables WHERE table_schema="%s" AND table_name="%s"', DB_NAME, $wpdb->prefix.'sgpb_subscribers');
|
1226 |
+
$results = $wpdb->get_results($query, ARRAY_A);
|
1227 |
+
if(empty($results)) {
|
1228 |
+
return 0;
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
$createTime = $results[0]['create_time'];
|
1232 |
+
$createTime = strtotime($createTime);
|
1233 |
+
update_option('SGPBInstallDate', $createTime);
|
1234 |
+
$diff = time() - $createTime;
|
1235 |
+
$days = floor($diff/(60*60*24));
|
1236 |
+
|
1237 |
+
return $days;
|
1238 |
+
}
|
1239 |
+
|
1240 |
+
public static function addContentToBanner($popupContent)
|
1241 |
+
{
|
1242 |
+
echo '<div class="sgpb-wrapper sgpb-review-popup-banner-wrapper">'.$popupContent.'</div>';
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
public static function addContentToFooter($popupContent)
|
1246 |
+
{
|
1247 |
+
if (function_exists('get_current_screen')) {
|
1248 |
+
$screen = get_current_screen();
|
1249 |
+
if ($screen->base == 'post') {
|
1250 |
+
self::addContentToBanner($popupContent);
|
1251 |
+
return;
|
1252 |
+
}
|
1253 |
+
}
|
1254 |
+
add_action('admin_footer', function() use ($popupContent) {
|
1255 |
+
$popupId = 0;
|
1256 |
+
$popupOptions = array();
|
1257 |
+
$events = array(array('onload'));
|
1258 |
+
$events = json_encode($events);
|
1259 |
+
$popupContent = '<div style="position:absolute;top: -999999999999999999999px;">
|
1260 |
+
<div class="sg-popup-builder-content" id="sg-popup-content-wrapper-'.$popupId.'" data-id="'.esc_attr($popupId).'" data-events="'.esc_attr($events).'" data-options="'.esc_attr($popupOptions).'">
|
1261 |
+
<div class="sgpb-popup-builder-content-'.esc_attr($popupId).' sgpb-popup-builder-content-html">'.$popupContent.'</div>
|
1262 |
+
</div>
|
1263 |
+
</div>';
|
1264 |
+
|
1265 |
+
echo $popupContent;
|
1266 |
+
});
|
1267 |
+
}
|
1268 |
+
|
1269 |
+
public static function shouldOpenForMaxOpenPopupMessage()
|
1270 |
+
{
|
1271 |
+
$counterMaxPopup = self::getMaxOpenPopupId();
|
1272 |
+
|
1273 |
+
if (empty($counterMaxPopup)) {
|
1274 |
+
return false;
|
1275 |
+
}
|
1276 |
+
$dontShowAgain = get_option('SGPBCloseReviewPopup');
|
1277 |
+
$maxCountDefine = get_option('SGPBMaxOpenCount');
|
1278 |
+
|
1279 |
+
if (!$maxCountDefine) {
|
1280 |
+
$maxCountDefine = SGPB_ASK_REVIEW_POPUP_COUNT;
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
return $counterMaxPopup['maxCount'] >= $maxCountDefine && !$dontShowAgain;
|
1284 |
+
}
|
1285 |
+
|
1286 |
+
public static function getMaxOpenPopupId()
|
1287 |
+
{
|
1288 |
+
$popupsCounterData = get_option('SgpbCounter');
|
1289 |
+
if (!$popupsCounterData) {
|
1290 |
+
return 0;
|
1291 |
+
}
|
1292 |
+
|
1293 |
+
$counters = array_values($popupsCounterData);
|
1294 |
+
$maxCount = max($counters);
|
1295 |
+
$popupId = array_search($maxCount, $popupsCounterData);
|
1296 |
+
|
1297 |
+
$maxPopupData = array(
|
1298 |
+
'popupId' => $popupId,
|
1299 |
+
'maxCount' => $maxCount
|
1300 |
+
);
|
1301 |
+
|
1302 |
+
return $maxPopupData;
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
public static function getMaxOpenPopupsMessage()
|
1306 |
+
{
|
1307 |
+
$counterMaxPopup = self::getMaxOpenPopupId();
|
1308 |
+
$popupTitle = '';
|
1309 |
+
$maxCountDefine = get_option('SGPBMaxOpenCount');
|
1310 |
+
$popupTitle = get_the_title($counterMaxPopup['popupId']);
|
1311 |
+
|
1312 |
+
if (!empty($counterMaxPopup['maxCount'])) {
|
1313 |
+
$maxCountDefine = $counterMaxPopup['maxCount'];
|
1314 |
+
}
|
1315 |
+
|
1316 |
+
$firstHeader = __('<h1 class="sgpb-review-h1"><strong class="sgrb-review-strong">Wow!</strong> <b>Popup Builder</b> plugin helped you to share your message via <strong class="sgrb-review-strong">'.$popupTitle.'</strong> popup with your users for <strong class="sgrb-review-strong">'.$maxCountDefine.' times!</strong></h1>', SG_POPUP_TEXT_DOMAIN);
|
1317 |
+
$popupContent = self::getMaxOpenPopupContent($firstHeader, 'count');
|
1318 |
+
|
1319 |
+
return $popupContent;
|
1320 |
+
}
|
1321 |
}
|
com/helpers/ConfigDataHelper.php
CHANGED
@@ -141,7 +141,7 @@ class ConfigDataHelper
|
|
141 |
public static function getPostsAllCategories()
|
142 |
{
|
143 |
|
144 |
-
$cats =
|
145 |
array(
|
146 |
'hide_empty' => 0,
|
147 |
'type' => 'post',
|
@@ -149,9 +149,16 @@ class ConfigDataHelper
|
|
149 |
'order' => 'ASC'
|
150 |
)
|
151 |
);
|
|
|
|
|
|
|
152 |
$catsParams = array();
|
153 |
foreach ($cats as $cat) {
|
154 |
-
|
|
|
|
|
|
|
|
|
155 |
$id = $cat->term_id;
|
156 |
$name = $cat->name;
|
157 |
$catsParams[$id] = $name;
|
@@ -361,6 +368,14 @@ class ConfigDataHelper
|
|
361 |
'100' => '100%'
|
362 |
);
|
363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
$data['closeButtonPositions'] = array(
|
365 |
'topLeft' => __('top-left', SG_POPUP_TEXT_DOMAIN),
|
366 |
'topRight' => __('top-right', SG_POPUP_TEXT_DOMAIN),
|
141 |
public static function getPostsAllCategories()
|
142 |
{
|
143 |
|
144 |
+
$cats = get_terms(
|
145 |
array(
|
146 |
'hide_empty' => 0,
|
147 |
'type' => 'post',
|
149 |
'order' => 'ASC'
|
150 |
)
|
151 |
);
|
152 |
+
|
153 |
+
$supportedTaxonomies = array('category', 'product_cat');
|
154 |
+
|
155 |
$catsParams = array();
|
156 |
foreach ($cats as $cat) {
|
157 |
+
if (isset($cat->taxonomy)) {
|
158 |
+
if (!in_array($cat->taxonomy, $supportedTaxonomies)) {
|
159 |
+
continue;
|
160 |
+
}
|
161 |
+
}
|
162 |
$id = $cat->term_id;
|
163 |
$name = $cat->name;
|
164 |
$catsParams[$id] = $name;
|
368 |
'100' => '100%'
|
369 |
);
|
370 |
|
371 |
+
$data['freeConditions'] = array(
|
372 |
+
'devices' => __('Devices', SG_POPUP_TEXT_DOMAIN),
|
373 |
+
'user-status' => __('User Status', SG_POPUP_TEXT_DOMAIN),
|
374 |
+
'after-x' => __('After x pages visit', SG_POPUP_TEXT_DOMAIN),
|
375 |
+
'user-role' => __('User Role', SG_POPUP_TEXT_DOMAIN),
|
376 |
+
'countries' => __('Countries', SG_POPUP_TEXT_DOMAIN)
|
377 |
+
);
|
378 |
+
|
379 |
$data['closeButtonPositions'] = array(
|
380 |
'topLeft' => __('top-left', SG_POPUP_TEXT_DOMAIN),
|
381 |
'topRight' => __('top-right', SG_POPUP_TEXT_DOMAIN),
|
com/libs/Importer.php
ADDED
@@ -0,0 +1,1237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace sgpb;
|
3 |
+
use \WP_Importer;
|
4 |
+
|
5 |
+
if (!class_exists('WP_Importer')) {
|
6 |
+
$class_wp_importer = ABSPATH.'wp-admin/includes/class-wp-importer.php';
|
7 |
+
if (file_exists($class_wp_importer)) {
|
8 |
+
require $class_wp_importer;
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
require_once SG_POPUP_LIBS_PATH.'parsers.php';
|
13 |
+
|
14 |
+
class WP_Import extends WP_Importer
|
15 |
+
{
|
16 |
+
var $max_wxr_version = 1.2; // max. supported WXR version
|
17 |
+
|
18 |
+
var $id; // WXR attachment ID
|
19 |
+
|
20 |
+
// information to import from WXR file
|
21 |
+
var $version;
|
22 |
+
var $authors = array();
|
23 |
+
var $posts = array();
|
24 |
+
var $terms = array();
|
25 |
+
var $categories = array();
|
26 |
+
var $tags = array();
|
27 |
+
var $base_url = '';
|
28 |
+
|
29 |
+
// mappings from old information to new
|
30 |
+
var $processed_authors = array();
|
31 |
+
var $author_mapping = array();
|
32 |
+
var $processed_terms = array();
|
33 |
+
var $processed_posts = array();
|
34 |
+
var $post_orphans = array();
|
35 |
+
var $processed_menu_items = array();
|
36 |
+
var $menu_item_orphans = array();
|
37 |
+
var $missing_menu_items = array();
|
38 |
+
|
39 |
+
var $fetch_attachments = false;
|
40 |
+
var $url_remap = array();
|
41 |
+
var $featured_images = array();
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Registered callback function for the WordPress Importer
|
45 |
+
*
|
46 |
+
* Manages the three separate stages of the WXR import process
|
47 |
+
*/
|
48 |
+
public function dispatch()
|
49 |
+
{
|
50 |
+
$this->header();
|
51 |
+
|
52 |
+
$step = empty($_GET['step']) ? 0 : (int) $_GET['step'];
|
53 |
+
switch ($step) {
|
54 |
+
case 0:
|
55 |
+
$this->greet();
|
56 |
+
break;
|
57 |
+
case 1:
|
58 |
+
check_admin_referer('import-upload');
|
59 |
+
if ($this->handle_upload()) {
|
60 |
+
$this->import_options();
|
61 |
+
}
|
62 |
+
break;
|
63 |
+
case 2:
|
64 |
+
check_admin_referer('import-wordpress');
|
65 |
+
$this->fetch_attachments = (!empty($_POST['fetch_attachments']) && $this->allow_fetch_attachments());
|
66 |
+
$this->id = (int) $_POST['import_id'];
|
67 |
+
$file = get_attached_file($this->id);
|
68 |
+
set_time_limit(0);
|
69 |
+
$this->import($file);
|
70 |
+
break;
|
71 |
+
}
|
72 |
+
|
73 |
+
$this->footer();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* The main controller for the actual import stage.
|
78 |
+
*
|
79 |
+
* @param string $file Path to the WXR file for importing
|
80 |
+
*/
|
81 |
+
public function import($file)
|
82 |
+
{
|
83 |
+
add_filter('import_post_meta_key', array($this, 'is_valid_meta_key'));
|
84 |
+
add_filter('http_request_timeout', array(&$this, 'bump_request_timeout'));
|
85 |
+
|
86 |
+
$this->import_start($file);
|
87 |
+
|
88 |
+
$this->get_author_mapping();
|
89 |
+
|
90 |
+
wp_suspend_cache_invalidation(true);
|
91 |
+
$this->process_categories();
|
92 |
+
$this->process_tags();
|
93 |
+
$this->process_terms();
|
94 |
+
$this->process_posts();
|
95 |
+
wp_suspend_cache_invalidation(false);
|
96 |
+
|
97 |
+
// update incorrect/missing information in the DB
|
98 |
+
$this->backfill_attachment_urls();
|
99 |
+
$this->remap_featured_images();
|
100 |
+
|
101 |
+
$this->import_end();
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Parses the WXR file and prepares us for the task of processing parsed data
|
106 |
+
*
|
107 |
+
* @param string $file Path to the WXR file for importing
|
108 |
+
*/
|
109 |
+
public function import_start($file)
|
110 |
+
{
|
111 |
+
if (!is_file($file)) {
|
112 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', SG_POPUP_TEXT_DOMAIN) . '</strong><br />';
|
113 |
+
echo __('The file does not exist, please try again.', SG_POPUP_TEXT_DOMAIN) . '</p>';
|
114 |
+
$this->footer();
|
115 |
+
die();
|
116 |
+
}
|
117 |
+
|
118 |
+
$import_data = $this->parse($file);
|
119 |
+
|
120 |
+
if (is_wp_error($import_data)) {
|
121 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', SG_POPUP_TEXT_DOMAIN) . '</strong><br />';
|
122 |
+
echo esc_html($import_data->get_error_message()) . '</p>';
|
123 |
+
$this->footer();
|
124 |
+
die();
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->version = $import_data['version'];
|
128 |
+
$this->get_authors_from_import($import_data);
|
129 |
+
$this->posts = $import_data['posts'];
|
130 |
+
$this->terms = $import_data['terms'];
|
131 |
+
$this->categories = $import_data['categories'];
|
132 |
+
$this->tags = $import_data['tags'];
|
133 |
+
$this->base_url = esc_url($import_data['base_url']);
|
134 |
+
|
135 |
+
wp_defer_term_counting(true);
|
136 |
+
wp_defer_comment_counting(true);
|
137 |
+
|
138 |
+
do_action('import_start');
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Performs post-import cleanup of files and the cache
|
143 |
+
*/
|
144 |
+
public function import_end()
|
145 |
+
{
|
146 |
+
wp_import_cleanup($this->id);
|
147 |
+
|
148 |
+
wp_cache_flush();
|
149 |
+
foreach (get_taxonomies() as $tax) {
|
150 |
+
delete_option("{$tax}_children");
|
151 |
+
_get_term_hierarchy($tax);
|
152 |
+
}
|
153 |
+
|
154 |
+
wp_defer_term_counting(false);
|
155 |
+
wp_defer_comment_counting(false);
|
156 |
+
|
157 |
+
echo '<p>'.__('All done.', SG_POPUP_TEXT_DOMAIN).' <a href="'.admin_url().'edit.php?post_type='.SG_POPUP_POST_TYPE.'">'.__('Have fun!', SG_POPUP_TEXT_DOMAIN).'</a>'.'</p>';
|
158 |
+
|
159 |
+
do_action('import_end');
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Handles the WXR upload and initial parsing of the file to prepare for
|
164 |
+
* displaying author import options
|
165 |
+
*
|
166 |
+
* @return bool False if error uploading or invalid file, true otherwise
|
167 |
+
*/
|
168 |
+
public function handle_upload()
|
169 |
+
{
|
170 |
+
$file = wp_import_handle_upload();
|
171 |
+
|
172 |
+
if (isset($file['error'])) {
|
173 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', SG_POPUP_TEXT_DOMAIN).'</strong><br />';
|
174 |
+
echo esc_html($file['error']).'</p>';
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
else if (!file_exists($file['file'])) {
|
178 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', SG_POPUP_TEXT_DOMAIN).'</strong><br />';
|
179 |
+
printf(__('The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', SG_POPUP_TEXT_DOMAIN), esc_html($file['file']));
|
180 |
+
echo '</p>';
|
181 |
+
return false;
|
182 |
+
}
|
183 |
+
|
184 |
+
$this->id = (int)$file['id'];
|
185 |
+
$import_data = $this->parse($file['file']);
|
186 |
+
if (is_wp_error($import_data)) {
|
187 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', SG_POPUP_TEXT_DOMAIN).'</strong><br />';
|
188 |
+
echo esc_html($import_data->get_error_message()).'</p>';
|
189 |
+
return false;
|
190 |
+
}
|
191 |
+
|
192 |
+
$this->version = $import_data['version'];
|
193 |
+
if ($this->version > $this->max_wxr_version) {
|
194 |
+
echo '<div class="error"><p><strong>';
|
195 |
+
printf(__('This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', SG_POPUP_TEXT_DOMAIN), esc_html($import_data['version']));
|
196 |
+
echo '</strong></p></div>';
|
197 |
+
}
|
198 |
+
|
199 |
+
$this->get_authors_from_import($import_data);
|
200 |
+
|
201 |
+
return true;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Retrieve authors from parsed WXR data
|
206 |
+
*
|
207 |
+
* Uses the provided author information from WXR 1.1 files
|
208 |
+
* or extracts info from each post for WXR 1.0 files
|
209 |
+
*
|
210 |
+
* @param array $import_data Data returned by a WXR parser
|
211 |
+
*/
|
212 |
+
public function get_authors_from_import($import_data)
|
213 |
+
{
|
214 |
+
if (!empty($import_data['authors'])) {
|
215 |
+
$this->authors = $import_data['authors'];
|
216 |
+
// no author information, grab it from the posts
|
217 |
+
}
|
218 |
+
else {
|
219 |
+
foreach ($import_data['posts'] as $post) {
|
220 |
+
$login = sanitize_user($post['post_author'], true);
|
221 |
+
if (empty($login)) {
|
222 |
+
printf(__('Failed to import author %s. Their posts will be attributed to the current user.', SG_POPUP_TEXT_DOMAIN), esc_html($post['post_author']));
|
223 |
+
echo '<br />';
|
224 |
+
continue;
|
225 |
+
}
|
226 |
+
|
227 |
+
if (!isset($this->authors[$login])) {
|
228 |
+
$this->authors[$login] = array(
|
229 |
+
'author_login' => $login,
|
230 |
+
'author_display_name' => $post['post_author']
|
231 |
+
);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Display pre-import options, author importing/mapping and option to
|
239 |
+
* fetch attachments
|
240 |
+
*/
|
241 |
+
public function import_options()
|
242 |
+
{
|
243 |
+
$j = 0;
|
244 |
+
?>
|
245 |
+
<form action="<?php echo admin_url('admin.php?import='.SG_POPUP_POST_TYPE.'&step=2'); ?>" method="post">
|
246 |
+
<?php wp_nonce_field('import-wordpress'); ?>
|
247 |
+
<input type="hidden" name="import_id" value="<?php echo $this->id; ?>" />
|
248 |
+
|
249 |
+
<?php if (!empty($this->authors)) : ?>
|
250 |
+
<h3><?php _e('Assign Authors', SG_POPUP_TEXT_DOMAIN); ?></h3>
|
251 |
+
<p><?php _e('To make it easier for you to edit and save the imported content, you may want to reassign the author of the imported item to an existing user of this site. For example, you may want to import all the entries as <code>admin</code>s entries.', SG_POPUP_TEXT_DOMAIN); ?></p>
|
252 |
+
<?php if ($this->allow_create_users()) : ?>
|
253 |
+
<p><?php printf(__('If a new user is created by WordPress, a new password will be randomly generated and the new user’s role will be set as %s. Manually changing the new user’s details will be necessary.', SG_POPUP_TEXT_DOMAIN), esc_html(get_option('default_role'))); ?></p>
|
254 |
+
<?php endif; ?>
|
255 |
+
<ol id="authors">
|
256 |
+
<?php foreach ($this->authors as $author) : ?>
|
257 |
+
<li><?php $this->author_select($j++, $author); ?></li>
|
258 |
+
<?php endforeach; ?>
|
259 |
+
</ol>
|
260 |
+
<?php endif; ?>
|
261 |
+
|
262 |
+
<p class="submit"><input type="submit" class="button" value="<?php esc_attr_e('Submit', SG_POPUP_TEXT_DOMAIN); ?>" /></p>
|
263 |
+
</form>
|
264 |
+
<?php
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Display import options for an individual author. That is, either create
|
269 |
+
* a new user based on import info or map to an existing user
|
270 |
+
*
|
271 |
+
* @param int $n Index for each author in the form
|
272 |
+
* @param array $author Author information, e.g. login, display name, email
|
273 |
+
*/
|
274 |
+
public function author_select($n, $author)
|
275 |
+
{
|
276 |
+
_e('Import author:', SG_POPUP_TEXT_DOMAIN);
|
277 |
+
echo ' <strong>' . esc_html($author['author_display_name']);
|
278 |
+
if ($this->version != '1.0') echo ' (' . esc_html($author['author_login']) . ')';
|
279 |
+
echo '</strong><br />';
|
280 |
+
|
281 |
+
if ($this->version != '1.0')
|
282 |
+
echo '<div style="margin-left:18px">';
|
283 |
+
|
284 |
+
$create_users = $this->allow_create_users();
|
285 |
+
if ($create_users) {
|
286 |
+
if ($this->version != '1.0') {
|
287 |
+
_e('or create new user with login name:', SG_POPUP_TEXT_DOMAIN);
|
288 |
+
$value = '';
|
289 |
+
} else {
|
290 |
+
_e('as a new user:', SG_POPUP_TEXT_DOMAIN);
|
291 |
+
$value = esc_attr(sanitize_user($author['author_login'], true));
|
292 |
+
}
|
293 |
+
|
294 |
+
echo ' <input type="text" name="user_new['.$n.']" value="'. $value .'" /><br />';
|
295 |
+
}
|
296 |
+
|
297 |
+
if (!$create_users && $this->version == '1.0')
|
298 |
+
_e('assign posts to an existing user:', SG_POPUP_TEXT_DOMAIN);
|
299 |
+
else
|
300 |
+
_e('or assign posts to an existing user:', SG_POPUP_TEXT_DOMAIN);
|
301 |
+
wp_dropdown_users(array('name' => "user_map[$n]", 'multi' => true, 'show_option_all' => __('- Select -', SG_POPUP_TEXT_DOMAIN)));
|
302 |
+
echo '<input type="hidden" name="imported_authors['.$n.']" value="' . esc_attr($author['author_login']) . '" />';
|
303 |
+
|
304 |
+
if ($this->version != '1.0')
|
305 |
+
echo '</div>';
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Map old author logins to local user IDs based on decisions made
|
310 |
+
* in import options form. Can map to an existing user, create a new user
|
311 |
+
* or falls back to the current user in case of error with either of the previous
|
312 |
+
*/
|
313 |
+
public function get_author_mapping()
|
314 |
+
{
|
315 |
+
if (!isset($_POST['imported_authors'])) {
|
316 |
+
return;
|
317 |
+
}
|
318 |
+
|
319 |
+
$create_users = $this->allow_create_users();
|
320 |
+
|
321 |
+
foreach ((array) $_POST['imported_authors'] as $i => $old_login) {
|
322 |
+
// Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts.
|
323 |
+
$santized_old_login = sanitize_user($old_login, true);
|
324 |
+
$old_id = isset($this->authors[$old_login]['author_id']) ? intval($this->authors[$old_login]['author_id']) : false;
|
325 |
+
|
326 |
+
if (!empty($_POST['user_map'][$i])) {
|
327 |
+
$user = get_userdata(intval($_POST['user_map'][$i]));
|
328 |
+
if (isset($user->ID)) {
|
329 |
+
if ($old_id)
|
330 |
+
$this->processed_authors[$old_id] = $user->ID;
|
331 |
+
$this->author_mapping[$santized_old_login] = $user->ID;
|
332 |
+
}
|
333 |
+
} else if ($create_users) {
|
334 |
+
if (!empty($_POST['user_new'][$i])) {
|
335 |
+
$user_id = wp_create_user($_POST['user_new'][$i], wp_generate_password());
|
336 |
+
} else if ($this->version != '1.0') {
|
337 |
+
$user_data = array(
|
338 |
+
'user_login' => $old_login,
|
339 |
+
'user_pass' => wp_generate_password(),
|
340 |
+
'user_email' => isset($this->authors[$old_login]['author_email']) ? $this->authors[$old_login]['author_email'] : '',
|
341 |
+
'display_name' => $this->authors[$old_login]['author_display_name'],
|
342 |
+
'first_name' => isset($this->authors[$old_login]['author_first_name']) ? $this->authors[$old_login]['author_first_name'] : '',
|
343 |
+
'last_name' => isset($this->authors[$old_login]['author_last_name']) ? $this->authors[$old_login]['author_last_name'] : '',
|
344 |
+
);
|
345 |
+
$user_id = wp_insert_user($user_data);
|
346 |
+
}
|
347 |
+
|
348 |
+
if (!is_wp_error($user_id)) {
|
349 |
+
if ($old_id)
|
350 |
+
$this->processed_authors[$old_id] = $user_id;
|
351 |
+
$this->author_mapping[$santized_old_login] = $user_id;
|
352 |
+
} else {
|
353 |
+
printf(__('Failed to create new user for %s. Their posts will be attributed to the current user.', SG_POPUP_TEXT_DOMAIN), esc_html($this->authors[$old_login]['author_display_name']));
|
354 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
355 |
+
echo ' ' . $user_id->get_error_message();
|
356 |
+
echo '<br />';
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
// failsafe: if the user_id was invalid, default to the current user
|
361 |
+
if (!isset($this->author_mapping[$santized_old_login])) {
|
362 |
+
if ($old_id)
|
363 |
+
$this->processed_authors[$old_id] = (int) get_current_user_id();
|
364 |
+
$this->author_mapping[$santized_old_login] = (int) get_current_user_id();
|
365 |
+
}
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Create new categories based on import information
|
371 |
+
*
|
372 |
+
* Doesn't create a new category if its slug already exists
|
373 |
+
*/
|
374 |
+
public function process_categories()
|
375 |
+
{
|
376 |
+
$this->categories = apply_filters('wp_import_categories', $this->categories);
|
377 |
+
|
378 |
+
if (empty($this->categories))
|
379 |
+
return;
|
380 |
+
|
381 |
+
foreach ($this->categories as $cat) {
|
382 |
+
// if the category already exists leave it alone
|
383 |
+
$term_id = term_exists($cat['category_nicename'], 'category');
|
384 |
+
if ($term_id) {
|
385 |
+
if (is_array($term_id)) $term_id = $term_id['term_id'];
|
386 |
+
if (isset($cat['term_id']))
|
387 |
+
$this->processed_terms[intval($cat['term_id'])] = (int) $term_id;
|
388 |
+
continue;
|
389 |
+
}
|
390 |
+
|
391 |
+
$category_parent = empty($cat['category_parent']) ? 0 : category_exists($cat['category_parent']);
|
392 |
+
$category_description = isset($cat['category_description']) ? $cat['category_description'] : '';
|
393 |
+
$catarr = array(
|
394 |
+
'category_nicename' => $cat['category_nicename'],
|
395 |
+
'category_parent' => $category_parent,
|
396 |
+
'cat_name' => $cat['cat_name'],
|
397 |
+
'category_description' => $category_description
|
398 |
+
);
|
399 |
+
$catarr = wp_slash($catarr);
|
400 |
+
|
401 |
+
$id = wp_insert_category($catarr);
|
402 |
+
if (!is_wp_error($id)) {
|
403 |
+
if (isset($cat['term_id']))
|
404 |
+
$this->processed_terms[intval($cat['term_id'])] = $id;
|
405 |
+
} else {
|
406 |
+
printf(__('Failed to import category %s', SG_POPUP_TEXT_DOMAIN), esc_html($cat['category_nicename']));
|
407 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
408 |
+
echo ': ' . $id->get_error_message();
|
409 |
+
echo '<br />';
|
410 |
+
continue;
|
411 |
+
}
|
412 |
+
|
413 |
+
$this->process_termmeta($cat, $id['term_id']);
|
414 |
+
}
|
415 |
+
|
416 |
+
unset($this->categories);
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Create new post tags based on import information
|
421 |
+
*
|
422 |
+
* Doesn't create a tag if its slug already exists
|
423 |
+
*/
|
424 |
+
public function process_tags()
|
425 |
+
{
|
426 |
+
$this->tags = apply_filters('wp_import_tags', $this->tags);
|
427 |
+
|
428 |
+
if (empty($this->tags))
|
429 |
+
return;
|
430 |
+
|
431 |
+
foreach ($this->tags as $tag) {
|
432 |
+
// if the tag already exists leave it alone
|
433 |
+
$term_id = term_exists($tag['tag_slug'], 'post_tag');
|
434 |
+
if ($term_id) {
|
435 |
+
if (is_array($term_id)) $term_id = $term_id['term_id'];
|
436 |
+
if (isset($tag['term_id']))
|
437 |
+
$this->processed_terms[intval($tag['term_id'])] = (int) $term_id;
|
438 |
+
continue;
|
439 |
+
}
|
440 |
+
|
441 |
+
$tag = wp_slash($tag);
|
442 |
+
$tag_desc = isset($tag['tag_description']) ? $tag['tag_description'] : '';
|
443 |
+
$tagarr = array('slug' => $tag['tag_slug'], 'description' => $tag_desc);
|
444 |
+
|
445 |
+
$id = wp_insert_term($tag['tag_name'], 'post_tag', $tagarr);
|
446 |
+
if (!is_wp_error($id)) {
|
447 |
+
if (isset($tag['term_id']))
|
448 |
+
$this->processed_terms[intval($tag['term_id'])] = $id['term_id'];
|
449 |
+
} else {
|
450 |
+
printf(__('Failed to import post tag %s', SG_POPUP_TEXT_DOMAIN), esc_html($tag['tag_name']));
|
451 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
452 |
+
echo ': ' . $id->get_error_message();
|
453 |
+
echo '<br />';
|
454 |
+
continue;
|
455 |
+
}
|
456 |
+
|
457 |
+
$this->process_termmeta($tag, $id['term_id']);
|
458 |
+
}
|
459 |
+
|
460 |
+
unset($this->tags);
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Create new terms based on import information
|
465 |
+
*
|
466 |
+
* Doesn't create a term its slug already exists
|
467 |
+
*/
|
468 |
+
public function process_terms()
|
469 |
+
{
|
470 |
+
$this->terms = apply_filters('wp_import_terms', $this->terms);
|
471 |
+
|
472 |
+
if (empty($this->terms))
|
473 |
+
return;
|
474 |
+
|
475 |
+
foreach ($this->terms as $term) {
|
476 |
+
// if the term already exists in the correct taxonomy leave it alone
|
477 |
+
$term_id = term_exists($term['slug'], $term['term_taxonomy']);
|
478 |
+
if ($term_id) {
|
479 |
+
if (is_array($term_id)) $term_id = $term_id['term_id'];
|
480 |
+
if (isset($term['term_id']))
|
481 |
+
$this->processed_terms[intval($term['term_id'])] = (int) $term_id;
|
482 |
+
continue;
|
483 |
+
}
|
484 |
+
|
485 |
+
if (empty($term['term_parent'])) {
|
486 |
+
$parent = 0;
|
487 |
+
} else {
|
488 |
+
$parent = term_exists($term['term_parent'], $term['term_taxonomy']);
|
489 |
+
if (is_array($parent)) $parent = $parent['term_id'];
|
490 |
+
}
|
491 |
+
$term = wp_slash($term);
|
492 |
+
$description = isset($term['term_description']) ? $term['term_description'] : '';
|
493 |
+
$termarr = array('slug' => $term['slug'], 'description' => $description, 'parent' => intval($parent));
|
494 |
+
|
495 |
+
$id = wp_insert_term($term['term_name'], $term['term_taxonomy'], $termarr);
|
496 |
+
if (!is_wp_error($id)) {
|
497 |
+
if (isset($term['term_id']))
|
498 |
+
$this->processed_terms[intval($term['term_id'])] = $id['term_id'];
|
499 |
+
} else {
|
500 |
+
printf(__('Failed to import %s %s', SG_POPUP_TEXT_DOMAIN), esc_html($term['term_taxonomy']), esc_html($term['term_name']));
|
501 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
502 |
+
echo ': ' . $id->get_error_message();
|
503 |
+
echo '<br />';
|
504 |
+
continue;
|
505 |
+
}
|
506 |
+
|
507 |
+
$this->process_termmeta($term, $id['term_id']);
|
508 |
+
}
|
509 |
+
|
510 |
+
unset($this->terms);
|
511 |
+
}
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Add metadata to imported term.
|
515 |
+
*
|
516 |
+
* @since 3.1.0
|
517 |
+
*
|
518 |
+
* @param array $term Term data from WXR import.
|
519 |
+
* @param int $term_id ID of the newly created term.
|
520 |
+
*/
|
521 |
+
protected function process_termmeta($term, $term_id)
|
522 |
+
{
|
523 |
+
if (!isset($term['termmeta'])) {
|
524 |
+
$term['termmeta'] = array();
|
525 |
+
}
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Filters the metadata attached to an imported term.
|
529 |
+
*
|
530 |
+
* @since 3.1.0
|
531 |
+
*
|
532 |
+
* @param array $termmeta Array of term meta.
|
533 |
+
* @param int $term_id ID of the newly created term.
|
534 |
+
* @param array $term Term data from the WXR import.
|
535 |
+
*/
|
536 |
+
$term['termmeta'] = apply_filters('wp_import_term_meta', $term['termmeta'], $term_id, $term);
|
537 |
+
|
538 |
+
if (empty($term['termmeta'])) {
|
539 |
+
return;
|
540 |
+
}
|
541 |
+
|
542 |
+
foreach ($term['termmeta'] as $meta) {
|
543 |
+
/**
|
544 |
+
* Filters the meta key for an imported piece of term meta.
|
545 |
+
*
|
546 |
+
* @since 3.1.0
|
547 |
+
*
|
548 |
+
* @param string $meta_key Meta key.
|
549 |
+
* @param int $term_id ID of the newly created term.
|
550 |
+
* @param array $term Term data from the WXR import.
|
551 |
+
*/
|
552 |
+
$key = apply_filters('import_term_meta_key', $meta['key'], $term_id, $term);
|
553 |
+
if (!$key) {
|
554 |
+
continue;
|
555 |
+
}
|
556 |
+
|
557 |
+
// Export gets meta straight from the DB so could have a serialized string
|
558 |
+
$value = maybe_unserialize($meta['value']);
|
559 |
+
|
560 |
+
add_term_meta($term_id, $key, $value);
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Fires after term meta is imported.
|
564 |
+
*
|
565 |
+
* @since 3.1.0
|
566 |
+
*
|
567 |
+
* @param int $term_id ID of the newly created term.
|
568 |
+
* @param string $key Meta key.
|
569 |
+
* @param mixed $value Meta value.
|
570 |
+
*/
|
571 |
+
do_action('import_term_meta', $term_id, $key, $value);
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Create new posts based on import information
|
577 |
+
*
|
578 |
+
* Posts marked as having a parent which doesn't exist will become top level items.
|
579 |
+
* Doesn't create a new post if: the post type doesn't exist, the given post ID
|
580 |
+
* is already noted as imported or a post with the same title and date already exists.
|
581 |
+
* Note that new/updated terms, comments and meta are imported for the last of the above.
|
582 |
+
*/
|
583 |
+
public function process_posts()
|
584 |
+
{
|
585 |
+
$this->posts = apply_filters('wp_import_posts', $this->posts);
|
586 |
+
|
587 |
+
foreach ($this->posts as $post) {
|
588 |
+
$post = apply_filters('wp_import_post_data_raw', $post);
|
589 |
+
|
590 |
+
if (!post_type_exists($post['post_type'])) {
|
591 |
+
printf(__('Failed to import “%s”: Invalid post type %s', SG_POPUP_TEXT_DOMAIN),
|
592 |
+
esc_html($post['post_title']), esc_html($post['post_type']));
|
593 |
+
echo '<br />';
|
594 |
+
do_action('wp_import_post_exists', $post);
|
595 |
+
continue;
|
596 |
+
}
|
597 |
+
|
598 |
+
if (isset($this->processed_posts[$post['post_id']]) && !empty($post['post_id'])) {
|
599 |
+
continue;
|
600 |
+
}
|
601 |
+
|
602 |
+
if ($post['status'] == 'auto-draft') {
|
603 |
+
continue;
|
604 |
+
}
|
605 |
+
|
606 |
+
if ('nav_menu_item' == $post['post_type']) {
|
607 |
+
$this->process_menu_item($post);
|
608 |
+
continue;
|
609 |
+
}
|
610 |
+
|
611 |
+
$post_type_object = get_post_type_object($post['post_type']);
|
612 |
+
|
613 |
+
$post_exists = post_exists($post['post_title'], '', $post['post_date']);
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Filter ID of the existing post corresponding to post currently importing.
|
617 |
+
*
|
618 |
+
* Return 0 to force the post to be imported. Filter the ID to be something else
|
619 |
+
* to override which existing post is mapped to the imported post.
|
620 |
+
*
|
621 |
+
* @see post_exists()
|
622 |
+
* @since 3.1.0
|
623 |
+
*
|
624 |
+
* @param int $post_exists Post ID, or 0 if post did not exist.
|
625 |
+
* @param array $post The post array to be inserted.
|
626 |
+
*/
|
627 |
+
$post_exists = apply_filters('wp_import_existing_post', $post_exists, $post);
|
628 |
+
|
629 |
+
if ($post_exists && get_post_type($post_exists) == $post['post_type']) {
|
630 |
+
printf(__('%s “%s” already exists.', SG_POPUP_TEXT_DOMAIN), $post_type_object->labels->singular_name, esc_html($post['post_title']));
|
631 |
+
echo '<br />';
|
632 |
+
$comment_post_ID = $post_id = $post_exists;
|
633 |
+
$this->processed_posts[ intval($post['post_id']) ] = intval($post_exists);
|
634 |
+
} else {
|
635 |
+
$post_parent = (int) $post['post_parent'];
|
636 |
+
if ($post_parent) {
|
637 |
+
// if we already know the parent, map it to the new local ID
|
638 |
+
if (isset($this->processed_posts[$post_parent])) {
|
639 |
+
$post_parent = $this->processed_posts[$post_parent];
|
640 |
+
// otherwise record the parent for later
|
641 |
+
} else {
|
642 |
+
$this->post_orphans[intval($post['post_id'])] = $post_parent;
|
643 |
+
$post_parent = 0;
|
644 |
+
}
|
645 |
+
}
|
646 |
+
|
647 |
+
// map the post author
|
648 |
+
$author = sanitize_user($post['post_author'], true);
|
649 |
+
if (isset($this->author_mapping[$author])) {
|
650 |
+
$author = $this->author_mapping[$author];
|
651 |
+
}
|
652 |
+
else {
|
653 |
+
$author = (int) get_current_user_id();
|
654 |
+
}
|
655 |
+
|
656 |
+
$postdata = array(
|
657 |
+
'import_id' => $post['post_id'], 'post_author' => $author, 'post_date' => $post['post_date'],
|
658 |
+
'post_date_gmt' => $post['post_date_gmt'], 'post_content' => $post['post_content'],
|
659 |
+
'post_excerpt' => $post['post_excerpt'], 'post_title' => $post['post_title'],
|
660 |
+
'post_status' => $post['status'], 'post_name' => $post['post_name'],
|
661 |
+
'comment_status' => $post['comment_status'], 'ping_status' => $post['ping_status'],
|
662 |
+
'guid' => $post['guid'], 'post_parent' => $post_parent, 'menu_order' => $post['menu_order'],
|
663 |
+
'post_type' => $post['post_type'], 'post_password' => $post['post_password']
|
664 |
+
);
|
665 |
+
|
666 |
+
$original_post_ID = $post['post_id'];
|
667 |
+
$postdata = apply_filters('wp_import_post_data_processed', $postdata, $post);
|
668 |
+
|
669 |
+
$postdata = wp_slash($postdata);
|
670 |
+
|
671 |
+
if ('attachment' == $postdata['post_type']) {
|
672 |
+
$remote_url = !empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid'];
|
673 |
+
|
674 |
+
// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
|
675 |
+
// e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
|
676 |
+
$postdata['upload_date'] = $post['post_date'];
|
677 |
+
if (isset($post['postmeta'])) {
|
678 |
+
foreach($post['postmeta'] as $meta) {
|
679 |
+
if ($meta['key'] == '_wp_attached_file') {
|
680 |
+
if (preg_match('%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches))
|
681 |
+
$postdata['upload_date'] = $matches[0];
|
682 |
+
break;
|
683 |
+
}
|
684 |
+
}
|
685 |
+
}
|
686 |
+
|
687 |
+
$comment_post_ID = $post_id = $this->process_attachment($postdata, $remote_url);
|
688 |
+
} else {
|
689 |
+
$comment_post_ID = $post_id = wp_insert_post($postdata, true);
|
690 |
+
do_action('wp_import_insert_post', $post_id, $original_post_ID, $postdata, $post);
|
691 |
+
}
|
692 |
+
|
693 |
+
if (is_wp_error($post_id)) {
|
694 |
+
printf(__('Failed to import %s “%s”', SG_POPUP_TEXT_DOMAIN),
|
695 |
+
$post_type_object->labels->singular_name, esc_html($post['post_title']));
|
696 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
697 |
+
echo ': ' . $post_id->get_error_message();
|
698 |
+
echo '<br />';
|
699 |
+
continue;
|
700 |
+
}
|
701 |
+
|
702 |
+
if ($post['is_sticky'] == 1) {
|
703 |
+
stick_post($post_id);
|
704 |
+
}
|
705 |
+
}
|
706 |
+
|
707 |
+
// map pre-import ID to local ID
|
708 |
+
$this->processed_posts[intval($post['post_id'])] = (int) $post_id;
|
709 |
+
|
710 |
+
if (!isset($post['terms']))
|
711 |
+
$post['terms'] = array();
|
712 |
+
|
713 |
+
$post['terms'] = apply_filters('wp_import_post_terms', $post['terms'], $post_id, $post);
|
714 |
+
|
715 |
+
// add categories, tags and other terms
|
716 |
+
if (!empty($post['terms'])) {
|
717 |
+
$terms_to_set = array();
|
718 |
+
foreach ($post['terms'] as $term) {
|
719 |
+
// back compat with WXR 1.0 map 'tag' to 'post_tag'
|
720 |
+
$taxonomy = ('tag' == $term['domain']) ? 'post_tag' : $term['domain'];
|
721 |
+
$term_exists = term_exists($term['slug'], $taxonomy);
|
722 |
+
$term_id = is_array($term_exists) ? $term_exists['term_id'] : $term_exists;
|
723 |
+
if (!$term_id) {
|
724 |
+
$t = wp_insert_term($term['name'], $taxonomy, array('slug' => $term['slug']));
|
725 |
+
if (!is_wp_error($t)) {
|
726 |
+
$term_id = $t['term_id'];
|
727 |
+
do_action('wp_import_insert_term', $t, $term, $post_id, $post);
|
728 |
+
} else {
|
729 |
+
printf(__('Failed to import %s %s', SG_POPUP_TEXT_DOMAIN), esc_html($taxonomy), esc_html($term['name']));
|
730 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
731 |
+
echo ': ' . $t->get_error_message();
|
732 |
+
echo '<br />';
|
733 |
+
do_action('wp_import_insert_term_failed', $t, $term, $post_id, $post);
|
734 |
+
continue;
|
735 |
+
}
|
736 |
+
}
|
737 |
+
$terms_to_set[$taxonomy][] = intval($term_id);
|
738 |
+
}
|
739 |
+
|
740 |
+
foreach ($terms_to_set as $tax => $ids) {
|
741 |
+
$tt_ids = wp_set_post_terms($post_id, $ids, $tax);
|
742 |
+
do_action('wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post);
|
743 |
+
}
|
744 |
+
unset($post['terms'], $terms_to_set);
|
745 |
+
}
|
746 |
+
|
747 |
+
if (!isset($post['comments']))
|
748 |
+
$post['comments'] = array();
|
749 |
+
|
750 |
+
$post['comments'] = apply_filters('wp_import_post_comments', $post['comments'], $post_id, $post);
|
751 |
+
|
752 |
+
// add/update comments
|
753 |
+
if (!empty($post['comments'])) {
|
754 |
+
$num_comments = 0;
|
755 |
+
$inserted_comments = array();
|
756 |
+
foreach ($post['comments'] as $comment) {
|
757 |
+
$comment_id = $comment['comment_id'];
|
758 |
+
$newcomments[$comment_id]['comment_post_ID'] = $comment_post_ID;
|
759 |
+
$newcomments[$comment_id]['comment_author'] = $comment['comment_author'];
|
760 |
+
$newcomments[$comment_id]['comment_author_email'] = $comment['comment_author_email'];
|
761 |
+
$newcomments[$comment_id]['comment_author_IP'] = $comment['comment_author_IP'];
|
762 |
+
$newcomments[$comment_id]['comment_author_url'] = $comment['comment_author_url'];
|
763 |
+
$newcomments[$comment_id]['comment_date'] = $comment['comment_date'];
|
764 |
+
$newcomments[$comment_id]['comment_date_gmt'] = $comment['comment_date_gmt'];
|
765 |
+
$newcomments[$comment_id]['comment_content'] = $comment['comment_content'];
|
766 |
+
$newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
|
767 |
+
$newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
|
768 |
+
$newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
|
769 |
+
$newcomments[$comment_id]['commentmeta'] = isset($comment['commentmeta']) ? $comment['commentmeta'] : array();
|
770 |
+
if (isset($this->processed_authors[$comment['comment_user_id']]))
|
771 |
+
$newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
|
772 |
+
}
|
773 |
+
ksort($newcomments);
|
774 |
+
|
775 |
+
foreach ($newcomments as $key => $comment) {
|
776 |
+
// if this is a new post we can skip the comment_exists() check
|
777 |
+
if (!$post_exists || !comment_exists($comment['comment_author'], $comment['comment_date'])) {
|
778 |
+
if (isset($inserted_comments[$comment['comment_parent']]))
|
779 |
+
$comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
|
780 |
+
$comment = wp_slash($comment);
|
781 |
+
$comment = wp_filter_comment($comment);
|
782 |
+
$inserted_comments[$key] = wp_insert_comment($comment);
|
783 |
+
do_action('wp_import_insert_comment', $inserted_comments[$key], $comment, $comment_post_ID, $post);
|
784 |
+
|
785 |
+
foreach($comment['commentmeta'] as $meta) {
|
786 |
+
$value = maybe_unserialize($meta['value']);
|
787 |
+
add_comment_meta($inserted_comments[$key], $meta['key'], $value);
|
788 |
+
}
|
789 |
+
|
790 |
+
$num_comments++;
|
791 |
+
}
|
792 |
+
}
|
793 |
+
unset($newcomments, $inserted_comments, $post['comments']);
|
794 |
+
}
|
795 |
+
|
796 |
+
if (!isset($post['postmeta']))
|
797 |
+
$post['postmeta'] = array();
|
798 |
+
|
799 |
+
$post['postmeta'] = apply_filters('wp_import_post_meta', $post['postmeta'], $post_id, $post);
|
800 |
+
|
801 |
+
// add/update post meta
|
802 |
+
if (!empty($post['postmeta'])) {
|
803 |
+
foreach ($post['postmeta'] as $meta) {
|
804 |
+
$key = apply_filters('import_post_meta_key', $meta['key'], $post_id, $post);
|
805 |
+
$value = false;
|
806 |
+
|
807 |
+
if ('_edit_last' == $key) {
|
808 |
+
if (isset($this->processed_authors[intval($meta['value'])]))
|
809 |
+
$value = $this->processed_authors[intval($meta['value'])];
|
810 |
+
else
|
811 |
+
$key = false;
|
812 |
+
}
|
813 |
+
|
814 |
+
if ($key) {
|
815 |
+
// export gets meta straight from the DB so could have a serialized string
|
816 |
+
if (!$value)
|
817 |
+
$value = maybe_unserialize($meta['value']);
|
818 |
+
|
819 |
+
add_post_meta($post_id, $key, $value);
|
820 |
+
do_action('import_post_meta', $post_id, $key, $value);
|
821 |
+
|
822 |
+
// if the post has a featured image, take note of this in case of remap
|
823 |
+
if ('_thumbnail_id' == $key)
|
824 |
+
$this->featured_images[$post_id] = (int) $value;
|
825 |
+
}
|
826 |
+
}
|
827 |
+
}
|
828 |
+
}
|
829 |
+
|
830 |
+
unset($this->posts);
|
831 |
+
}
|
832 |
+
|
833 |
+
/**
|
834 |
+
* Attempt to create a new menu item from import data
|
835 |
+
*
|
836 |
+
* Fails for draft, orphaned menu items and those without an associated nav_menu
|
837 |
+
* or an invalid nav_menu term. If the post type or term object which the menu item
|
838 |
+
* represents doesn't exist then the menu item will not be imported (waits until the
|
839 |
+
* end of the import to retry again before discarding).
|
840 |
+
*
|
841 |
+
* @param array $item Menu item details from WXR file
|
842 |
+
*/
|
843 |
+
public function process_menu_item($item)
|
844 |
+
{
|
845 |
+
// skip draft, orphaned menu items
|
846 |
+
if ('draft' == $item['status'])
|
847 |
+
return;
|
848 |
+
|
849 |
+
$menu_slug = false;
|
850 |
+
if (isset($item['terms'])) {
|
851 |
+
// loop through terms, assume first nav_menu term is correct menu
|
852 |
+
foreach ($item['terms'] as $term) {
|
853 |
+
if ('nav_menu' == $term['domain']) {
|
854 |
+
$menu_slug = $term['slug'];
|
855 |
+
break;
|
856 |
+
}
|
857 |
+
}
|
858 |
+
}
|
859 |
+
|
860 |
+
// no nav_menu term associated with this menu item
|
861 |
+
if (!$menu_slug) {
|
862 |
+
_e('Menu item skipped due to missing menu slug', SG_POPUP_TEXT_DOMAIN);
|
863 |
+
echo '<br />';
|
864 |
+
return;
|
865 |
+
}
|
866 |
+
|
867 |
+
$menu_id = term_exists($menu_slug, 'nav_menu');
|
868 |
+
if (!$menu_id) {
|
869 |
+
printf(__('Menu item skipped due to invalid menu slug: %s', SG_POPUP_TEXT_DOMAIN), esc_html($menu_slug));
|
870 |
+
echo '<br />';
|
871 |
+
return;
|
872 |
+
} else {
|
873 |
+
$menu_id = is_array($menu_id) ? $menu_id['term_id'] : $menu_id;
|
874 |
+
}
|
875 |
+
|
876 |
+
foreach ($item['postmeta'] as $meta) {
|
877 |
+
${$meta['key']} = $meta['value'];
|
878 |
+
}
|
879 |
+
|
880 |
+
if ('taxonomy' == $_menu_item_type && isset($this->processed_terms[intval($_menu_item_object_id)])) {
|
881 |
+
$_menu_item_object_id = $this->processed_terms[intval($_menu_item_object_id)];
|
882 |
+
}
|
883 |
+
else if ('post_type' == $_menu_item_type && isset($this->processed_posts[intval($_menu_item_object_id)])) {
|
884 |
+
$_menu_item_object_id = $this->processed_posts[intval($_menu_item_object_id)];
|
885 |
+
}
|
886 |
+
else if ('custom' != $_menu_item_type) {
|
887 |
+
// associated object is missing or not imported yet, we'll retry later
|
888 |
+
$this->missing_menu_items[] = $item;
|
889 |
+
return;
|
890 |
+
}
|
891 |
+
|
892 |
+
if (isset($this->processed_menu_items[intval($_menu_item_menu_item_parent)])) {
|
893 |
+
$_menu_item_menu_item_parent = $this->processed_menu_items[intval($_menu_item_menu_item_parent)];
|
894 |
+
}
|
895 |
+
else if ($_menu_item_menu_item_parent) {
|
896 |
+
$this->menu_item_orphans[intval($item['post_id'])] = (int) $_menu_item_menu_item_parent;
|
897 |
+
$_menu_item_menu_item_parent = 0;
|
898 |
+
}
|
899 |
+
|
900 |
+
// wp_update_nav_menu_item expects CSS classes as a space separated string
|
901 |
+
$_menu_item_classes = maybe_unserialize($_menu_item_classes);
|
902 |
+
if (is_array($_menu_item_classes)) {
|
903 |
+
$_menu_item_classes = implode(' ', $_menu_item_classes);
|
904 |
+
}
|
905 |
+
|
906 |
+
$args = array(
|
907 |
+
'menu-item-object-id' => $_menu_item_object_id,
|
908 |
+
'menu-item-object' => $_menu_item_object,
|
909 |
+
'menu-item-parent-id' => $_menu_item_menu_item_parent,
|
910 |
+
'menu-item-position' => intval($item['menu_order']),
|
911 |
+
'menu-item-type' => $_menu_item_type,
|
912 |
+
'menu-item-title' => $item['post_title'],
|
913 |
+
'menu-item-url' => $_menu_item_url,
|
914 |
+
'menu-item-description' => $item['post_content'],
|
915 |
+
'menu-item-attr-title' => $item['post_excerpt'],
|
916 |
+
'menu-item-target' => $_menu_item_target,
|
917 |
+
'menu-item-classes' => $_menu_item_classes,
|
918 |
+
'menu-item-xfn' => $_menu_item_xfn,
|
919 |
+
'menu-item-status' => $item['status']
|
920 |
+
);
|
921 |
+
|
922 |
+
$id = wp_update_nav_menu_item($menu_id, 0, $args);
|
923 |
+
if ($id && !is_wp_error($id)) {
|
924 |
+
$this->processed_menu_items[intval($item['post_id'])] = (int) $id;
|
925 |
+
}
|
926 |
+
}
|
927 |
+
|
928 |
+
/**
|
929 |
+
* If fetching attachments is enabled then attempt to create a new attachment
|
930 |
+
*
|
931 |
+
* @param array $post Attachment post details from WXR
|
932 |
+
* @param string $url URL to fetch attachment from
|
933 |
+
* @return int|WP_Error Post ID on success, WP_Error otherwise
|
934 |
+
*/
|
935 |
+
public function process_attachment($post, $url)
|
936 |
+
{
|
937 |
+
if (!$this->fetch_attachments) {
|
938 |
+
return new WP_Error('attachment_processing_error',
|
939 |
+
__('Fetching attachments is not enabled', SG_POPUP_TEXT_DOMAIN));
|
940 |
+
}
|
941 |
+
|
942 |
+
// if the URL is absolute, but does not contain address, then upload it assuming base_site_url
|
943 |
+
if (preg_match('|^/[\w\W]+$|', $url))
|
944 |
+
$url = rtrim($this->base_url, '/') . $url;
|
945 |
+
|
946 |
+
$upload = $this->fetch_remote_file($url, $post);
|
947 |
+
if (is_wp_error($upload)) {
|
948 |
+
return $upload;
|
949 |
+
}
|
950 |
+
|
951 |
+
if ($info = wp_check_filetype($upload['file'])) {
|
952 |
+
$post['post_mime_type'] = $info['type'];
|
953 |
+
}
|
954 |
+
else {
|
955 |
+
return new WP_Error('attachment_processing_error', __('Invalid file type', SG_POPUP_TEXT_DOMAIN));
|
956 |
+
}
|
957 |
+
|
958 |
+
$post['guid'] = $upload['url'];
|
959 |
+
|
960 |
+
// as per wp-admin/includes/upload.php
|
961 |
+
$post_id = wp_insert_attachment($post, $upload['file']);
|
962 |
+
wp_update_attachment_metadata($post_id, wp_generate_attachment_metadata($post_id, $upload['file']));
|
963 |
+
|
964 |
+
// remap resized image URLs, works by stripping the extension and remapping the URL stub.
|
965 |
+
if (preg_match('!^image/!', $info['type'])) {
|
966 |
+
$parts = pathinfo($url);
|
967 |
+
$name = basename($parts['basename'], ".{$parts['extension']}"); // PATHINFO_FILENAME in PHP 5.2
|
968 |
+
|
969 |
+
$parts_new = pathinfo($upload['url']);
|
970 |
+
$name_new = basename($parts_new['basename'], ".{$parts_new['extension']}");
|
971 |
+
|
972 |
+
$this->url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new;
|
973 |
+
}
|
974 |
+
|
975 |
+
return $post_id;
|
976 |
+
}
|
977 |
+
|
978 |
+
/**
|
979 |
+
* Attempt to download a remote file attachment
|
980 |
+
*
|
981 |
+
* @param string $url URL of item to fetch
|
982 |
+
* @param array $post Attachment details
|
983 |
+
* @return array|WP_Error Local file location details on success, WP_Error otherwise
|
984 |
+
*/
|
985 |
+
public function fetch_remote_file($url, $post)
|
986 |
+
{
|
987 |
+
// extract the file name and extension from the url
|
988 |
+
$file_name = basename($url);
|
989 |
+
|
990 |
+
// get placeholder file in the upload dir with a unique, sanitized filename
|
991 |
+
$upload = wp_upload_bits($file_name, 0, '', $post['upload_date']);
|
992 |
+
if ($upload['error']) {
|
993 |
+
return new WP_Error('upload_dir_error', $upload['error']);
|
994 |
+
}
|
995 |
+
|
996 |
+
// fetch the remote url and write it to the placeholder file
|
997 |
+
$remote_response = wp_safe_remote_get($url, array(
|
998 |
+
'timeout' => 300,
|
999 |
+
'stream' => true,
|
1000 |
+
'filename' => $upload['file'],
|
1001 |
+
));
|
1002 |
+
|
1003 |
+
$headers = wp_remote_retrieve_headers($remote_response);
|
1004 |
+
|
1005 |
+
// request failed
|
1006 |
+
if (!$headers) {
|
1007 |
+
@unlink($upload['file']);
|
1008 |
+
return new WP_Error('import_file_error', __('Remote server did not respond', SG_POPUP_TEXT_DOMAIN));
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
$remote_response_code = wp_remote_retrieve_response_code($remote_response);
|
1012 |
+
|
1013 |
+
// make sure the fetch was successful
|
1014 |
+
if ($remote_response_code != '200') {
|
1015 |
+
@unlink($upload['file']);
|
1016 |
+
return new WP_Error('import_file_error', sprintf(__('Remote server returned error response %1$d %2$s', SG_POPUP_TEXT_DOMAIN), esc_html($remote_response_code), get_status_header_desc($remote_response_code)));
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
$filesize = filesize($upload['file']);
|
1020 |
+
|
1021 |
+
if (isset($headers['content-length']) && $filesize != $headers['content-length']) {
|
1022 |
+
@unlink($upload['file']);
|
1023 |
+
return new WP_Error('import_file_error', __('Remote file is incorrect size', SG_POPUP_TEXT_DOMAIN));
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
if (0 == $filesize) {
|
1027 |
+
@unlink($upload['file']);
|
1028 |
+
return new WP_Error('import_file_error', __('Zero size file downloaded', SG_POPUP_TEXT_DOMAIN));
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
$max_size = (int) $this->max_attachment_size();
|
1032 |
+
if (!empty($max_size) && $filesize > $max_size) {
|
1033 |
+
@unlink($upload['file']);
|
1034 |
+
return new WP_Error('import_file_error', sprintf(__('Remote file is too large, limit is %s', SG_POPUP_TEXT_DOMAIN), size_format($max_size)));
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
// keep track of the old and new urls so we can substitute them later
|
1038 |
+
$this->url_remap[$url] = $upload['url'];
|
1039 |
+
$this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed?
|
1040 |
+
// keep track of the destination if the remote url is redirected somewhere else
|
1041 |
+
if (isset($headers['x-final-location']) && $headers['x-final-location'] != $url) {
|
1042 |
+
$this->url_remap[$headers['x-final-location']] = $upload['url'];
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
return $upload;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
/**
|
1049 |
+
* Attempt to associate posts and menu items with previously missing parents
|
1050 |
+
*
|
1051 |
+
* An imported post's parent may not have been imported when it was first created
|
1052 |
+
* so try again. Similarly for child menu items and menu items which were missing
|
1053 |
+
* the object (e.g. post) they represent in the menu
|
1054 |
+
*/
|
1055 |
+
public function backfill_parents()
|
1056 |
+
{
|
1057 |
+
global $wpdb;
|
1058 |
+
|
1059 |
+
// find parents for post orphans
|
1060 |
+
foreach ($this->post_orphans as $child_id => $parent_id) {
|
1061 |
+
$local_child_id = $local_parent_id = false;
|
1062 |
+
if (isset($this->processed_posts[$child_id]))
|
1063 |
+
$local_child_id = $this->processed_posts[$child_id];
|
1064 |
+
if (isset($this->processed_posts[$parent_id]))
|
1065 |
+
$local_parent_id = $this->processed_posts[$parent_id];
|
1066 |
+
|
1067 |
+
if ($local_child_id && $local_parent_id) {
|
1068 |
+
$wpdb->update($wpdb->posts, array('post_parent' => $local_parent_id), array('ID' => $local_child_id), '%d', '%d');
|
1069 |
+
clean_post_cache($local_child_id);
|
1070 |
+
}
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
// all other posts/terms are imported, retry menu items with missing associated object
|
1074 |
+
$missing_menu_items = $this->missing_menu_items;
|
1075 |
+
foreach ($missing_menu_items as $item)
|
1076 |
+
$this->process_menu_item($item);
|
1077 |
+
|
1078 |
+
// find parents for menu item orphans
|
1079 |
+
foreach ($this->menu_item_orphans as $child_id => $parent_id) {
|
1080 |
+
$local_child_id = $local_parent_id = 0;
|
1081 |
+
if (isset($this->processed_menu_items[$child_id])) {
|
1082 |
+
$local_child_id = $this->processed_menu_items[$child_id];
|
1083 |
+
}
|
1084 |
+
if (isset($this->processed_menu_items[$parent_id])) {
|
1085 |
+
$local_parent_id = $this->processed_menu_items[$parent_id];
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
if ($local_child_id && $local_parent_id) {
|
1089 |
+
update_post_meta($local_child_id, '_menu_item_menu_item_parent', (int) $local_parent_id);
|
1090 |
+
}
|
1091 |
+
}
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
/**
|
1095 |
+
* Use stored mapping information to update old attachment URLs
|
1096 |
+
*/
|
1097 |
+
public function backfill_attachment_urls()
|
1098 |
+
{
|
1099 |
+
global $wpdb;
|
1100 |
+
// make sure we do the longest urls first, in case one is a substring of another
|
1101 |
+
uksort($this->url_remap, array(&$this, 'cmpr_strlen'));
|
1102 |
+
|
1103 |
+
foreach ($this->url_remap as $from_url => $to_url) {
|
1104 |
+
// remap urls in post_content
|
1105 |
+
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url));
|
1106 |
+
// remap enclosure urls
|
1107 |
+
$result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url));
|
1108 |
+
}
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
/**
|
1112 |
+
* Update _thumbnail_id meta to new, imported attachment IDs
|
1113 |
+
*/
|
1114 |
+
public function remap_featured_images()
|
1115 |
+
{
|
1116 |
+
// cycle through posts that have a featured image
|
1117 |
+
foreach ($this->featured_images as $post_id => $value) {
|
1118 |
+
if (isset($this->processed_posts[$value])) {
|
1119 |
+
$new_id = $this->processed_posts[$value];
|
1120 |
+
// only update if there's a difference
|
1121 |
+
if ($new_id != $value) {
|
1122 |
+
update_post_meta($post_id, '_thumbnail_id', $new_id);
|
1123 |
+
}
|
1124 |
+
}
|
1125 |
+
}
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
/**
|
1129 |
+
* Parse a WXR file
|
1130 |
+
*
|
1131 |
+
* @param string $file Path to WXR file for parsing
|
1132 |
+
* @return array Information gathered from the WXR file
|
1133 |
+
*/
|
1134 |
+
public function parse($file)
|
1135 |
+
{
|
1136 |
+
$parser = new WXR_Parser();
|
1137 |
+
return $parser->parse($file);
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
// Display import page title
|
1141 |
+
public function header()
|
1142 |
+
{
|
1143 |
+
echo '<div class="wrap">';
|
1144 |
+
echo '<h2>' . __('Import WordPress', SG_POPUP_TEXT_DOMAIN) . '</h2>';
|
1145 |
+
|
1146 |
+
$updates = get_plugin_updates();
|
1147 |
+
$basename = plugin_basename(__FILE__);
|
1148 |
+
if (isset($updates[$basename])) {
|
1149 |
+
$update = $updates[$basename];
|
1150 |
+
echo '<div class="error"><p><strong>';
|
1151 |
+
printf(__('A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', SG_POPUP_TEXT_DOMAIN), $update->update->new_version);
|
1152 |
+
echo '</strong></p></div>';
|
1153 |
+
}
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
// Close div.wrap
|
1157 |
+
public function footer()
|
1158 |
+
{
|
1159 |
+
echo '</div>';
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
/**
|
1163 |
+
* Display introductory text and file upload form
|
1164 |
+
*/
|
1165 |
+
public function greet()
|
1166 |
+
{
|
1167 |
+
echo '<div class="narrow">';
|
1168 |
+
echo '<p>'.__('Howdy!Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this site.', SG_POPUP_TEXT_DOMAIN).'</p>';
|
1169 |
+
echo '<p>'.__('Choose a WXR (.xml) file to upload, then click Upload file and import.', SG_POPUP_TEXT_DOMAIN).'</p>';
|
1170 |
+
wp_import_upload_form('admin.php?import=wordpress&step=1');
|
1171 |
+
echo '</div>';
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
/**
|
1175 |
+
* Decide if the given meta key maps to information we will want to import
|
1176 |
+
*
|
1177 |
+
* @param string $key The meta key to check
|
1178 |
+
* @return string|bool The key if we do want to import, false if not
|
1179 |
+
*/
|
1180 |
+
public function is_valid_meta_key($key)
|
1181 |
+
{
|
1182 |
+
// skip attachment metadata since we'll regenerate it from scratch
|
1183 |
+
// skip _edit_lock as not relevant for import
|
1184 |
+
if (in_array($key, array('_wp_attached_file', '_wp_attachment_metadata', '_edit_lock')))
|
1185 |
+
return false;
|
1186 |
+
return $key;
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
/**
|
1190 |
+
* Decide whether or not the importer is allowed to create users.
|
1191 |
+
* Default is true, can be filtered via import_allow_create_users
|
1192 |
+
*
|
1193 |
+
* @return bool True if creating users is allowed
|
1194 |
+
*/
|
1195 |
+
public function allow_create_users()
|
1196 |
+
{
|
1197 |
+
return apply_filters('import_allow_create_users', true);
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* Decide whether or not the importer should attempt to download attachment files.
|
1202 |
+
* Default is true, can be filtered via import_allow_fetch_attachments. The choice
|
1203 |
+
* made at the import options screen must also be true, false here hides that checkbox.
|
1204 |
+
*
|
1205 |
+
* @return bool True if downloading attachments is allowed
|
1206 |
+
*/
|
1207 |
+
public function allow_fetch_attachments()
|
1208 |
+
{
|
1209 |
+
return apply_filters('import_allow_fetch_attachments', true);
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
/**
|
1213 |
+
* Decide what the maximum file size for downloaded attachments is.
|
1214 |
+
* Default is 0 (unlimited), can be filtered via import_attachment_size_limit
|
1215 |
+
*
|
1216 |
+
* @return int Maximum attachment file size to import
|
1217 |
+
*/
|
1218 |
+
public function max_attachment_size()
|
1219 |
+
{
|
1220 |
+
return apply_filters('import_attachment_size_limit', 0);
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
/**
|
1224 |
+
* Added to http_request_timeout filter to force timeout at 60 seconds during import
|
1225 |
+
* @return int 60
|
1226 |
+
*/
|
1227 |
+
public function bump_request_timeout($val)
|
1228 |
+
{
|
1229 |
+
return 60;
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
// return the difference in length between two strings
|
1233 |
+
public function cmpr_strlen($a, $b)
|
1234 |
+
{
|
1235 |
+
return strlen($b) - strlen($a);
|
1236 |
+
}
|
1237 |
+
}
|
com/libs/parsers.php
ADDED
@@ -0,0 +1,700 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace sgpb;
|
3 |
+
use \DOMDocument;
|
4 |
+
/**
|
5 |
+
* WordPress eXtended RSS file parser implementations
|
6 |
+
*
|
7 |
+
* @package WordPress
|
8 |
+
* @subpackage Importer
|
9 |
+
*/
|
10 |
+
|
11 |
+
/**
|
12 |
+
* WordPress Importer class for managing parsing of WXR files.
|
13 |
+
*/
|
14 |
+
class WXR_Parser {
|
15 |
+
function parse( $file ) {
|
16 |
+
// Attempt to use proper XML parsers first
|
17 |
+
if ( extension_loaded( 'simplexml' ) ) {
|
18 |
+
$parser = new WXR_Parser_SimpleXML;
|
19 |
+
$result = $parser->parse( $file );
|
20 |
+
|
21 |
+
// If SimpleXML succeeds or this is an invalid WXR file then return the results
|
22 |
+
if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() )
|
23 |
+
return $result;
|
24 |
+
} else if ( extension_loaded( 'xml' ) ) {
|
25 |
+
$parser = new WXR_Parser_XML;
|
26 |
+
$result = $parser->parse( $file );
|
27 |
+
|
28 |
+
// If XMLParser succeeds or this is an invalid WXR file then return the results
|
29 |
+
if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() )
|
30 |
+
return $result;
|
31 |
+
}
|
32 |
+
|
33 |
+
// We have a malformed XML file, so display the error and fallthrough to regex
|
34 |
+
if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) {
|
35 |
+
echo '<pre>';
|
36 |
+
if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
|
37 |
+
foreach ( $result->get_error_data() as $error )
|
38 |
+
echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
|
39 |
+
} else if ( 'XML_parse_error' == $result->get_error_code() ) {
|
40 |
+
$error = $result->get_error_data();
|
41 |
+
echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
|
42 |
+
}
|
43 |
+
echo '</pre>';
|
44 |
+
echo '<p><strong>' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '</strong><br />';
|
45 |
+
echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '</p>';
|
46 |
+
}
|
47 |
+
|
48 |
+
// use regular expressions if nothing else available or this is bad XML
|
49 |
+
$parser = new WXR_Parser_Regex;
|
50 |
+
return $parser->parse( $file );
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* WXR Parser that makes use of the SimpleXML PHP extension.
|
56 |
+
*/
|
57 |
+
class WXR_Parser_SimpleXML {
|
58 |
+
function parse( $file ) {
|
59 |
+
$authors = $posts = $categories = $tags = $terms = array();
|
60 |
+
|
61 |
+
$internal_errors = libxml_use_internal_errors(true);
|
62 |
+
|
63 |
+
$dom = new DOMDocument;
|
64 |
+
$old_value = null;
|
65 |
+
if ( function_exists( 'libxml_disable_entity_loader' ) ) {
|
66 |
+
$old_value = libxml_disable_entity_loader( true );
|
67 |
+
}
|
68 |
+
$success = $dom->loadXML( file_get_contents( $file ) );
|
69 |
+
if ( ! is_null( $old_value ) ) {
|
70 |
+
libxml_disable_entity_loader( $old_value );
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( ! $success || isset( $dom->doctype ) ) {
|
74 |
+
return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() );
|
75 |
+
}
|
76 |
+
|
77 |
+
$xml = simplexml_import_dom( $dom );
|
78 |
+
unset( $dom );
|
79 |
+
|
80 |
+
// halt if loading produces an error
|
81 |
+
if ( ! $xml )
|
82 |
+
return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() );
|
83 |
+
|
84 |
+
$wxr_version = $xml->xpath('/rss/channel/wp:wxr_version');
|
85 |
+
if ( ! $wxr_version )
|
86 |
+
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
|
87 |
+
|
88 |
+
$wxr_version = (string) trim( $wxr_version[0] );
|
89 |
+
// confirm that we are dealing with the correct file format
|
90 |
+
if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) )
|
91 |
+
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
|
92 |
+
|
93 |
+
$base_url = $xml->xpath('/rss/channel/wp:base_site_url');
|
94 |
+
$base_url = (string) trim( $base_url[0] );
|
95 |
+
|
96 |
+
$namespaces = $xml->getDocNamespaces();
|
97 |
+
if ( ! isset( $namespaces['wp'] ) )
|
98 |
+
$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
|
99 |
+
if ( ! isset( $namespaces['excerpt'] ) )
|
100 |
+
$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
|
101 |
+
|
102 |
+
// grab authors
|
103 |
+
foreach ( $xml->xpath('/rss/channel/wp:author') as $author_arr ) {
|
104 |
+
$a = $author_arr->children( $namespaces['wp'] );
|
105 |
+
$login = (string) $a->author_login;
|
106 |
+
$authors[$login] = array(
|
107 |
+
'author_id' => (int) $a->author_id,
|
108 |
+
'author_login' => $login,
|
109 |
+
'author_email' => (string) $a->author_email,
|
110 |
+
'author_display_name' => (string) $a->author_display_name,
|
111 |
+
'author_first_name' => (string) $a->author_first_name,
|
112 |
+
'author_last_name' => (string) $a->author_last_name
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
// grab cats, tags and terms
|
117 |
+
foreach ( $xml->xpath('/rss/channel/wp:category') as $term_arr ) {
|
118 |
+
$t = $term_arr->children( $namespaces['wp'] );
|
119 |
+
$category = array(
|
120 |
+
'term_id' => (int) $t->term_id,
|
121 |
+
'category_nicename' => (string) $t->category_nicename,
|
122 |
+
'category_parent' => (string) $t->category_parent,
|
123 |
+
'cat_name' => (string) $t->cat_name,
|
124 |
+
'category_description' => (string) $t->category_description
|
125 |
+
);
|
126 |
+
|
127 |
+
foreach ( $t->termmeta as $meta ) {
|
128 |
+
$category['termmeta'][] = array(
|
129 |
+
'key' => (string) $meta->meta_key,
|
130 |
+
'value' => (string) $meta->meta_value
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
$categories[] = $category;
|
135 |
+
}
|
136 |
+
|
137 |
+
foreach ( $xml->xpath('/rss/channel/wp:tag') as $term_arr ) {
|
138 |
+
$t = $term_arr->children( $namespaces['wp'] );
|
139 |
+
$tag = array(
|
140 |
+
'term_id' => (int) $t->term_id,
|
141 |
+
'tag_slug' => (string) $t->tag_slug,
|
142 |
+
'tag_name' => (string) $t->tag_name,
|
143 |
+
'tag_description' => (string) $t->tag_description
|
144 |
+
);
|
145 |
+
|
146 |
+
foreach ( $t->termmeta as $meta ) {
|
147 |
+
$tag['termmeta'][] = array(
|
148 |
+
'key' => (string) $meta->meta_key,
|
149 |
+
'value' => (string) $meta->meta_value
|
150 |
+
);
|
151 |
+
}
|
152 |
+
|
153 |
+
$tags[] = $tag;
|
154 |
+
}
|
155 |
+
|
156 |
+
foreach ( $xml->xpath('/rss/channel/wp:term') as $term_arr ) {
|
157 |
+
$t = $term_arr->children( $namespaces['wp'] );
|
158 |
+
$term = array(
|
159 |
+
'term_id' => (int) $t->term_id,
|
160 |
+
'term_taxonomy' => (string) $t->term_taxonomy,
|
161 |
+
'slug' => (string) $t->term_slug,
|
162 |
+
'term_parent' => (string) $t->term_parent,
|
163 |
+
'term_name' => (string) $t->term_name,
|
164 |
+
'term_description' => (string) $t->term_description
|
165 |
+
);
|
166 |
+
|
167 |
+
foreach ( $t->termmeta as $meta ) {
|
168 |
+
$term['termmeta'][] = array(
|
169 |
+
'key' => (string) $meta->meta_key,
|
170 |
+
'value' => (string) $meta->meta_value
|
171 |
+
);
|
172 |
+
}
|
173 |
+
|
174 |
+
$terms[] = $term;
|
175 |
+
}
|
176 |
+
|
177 |
+
// grab posts
|
178 |
+
foreach ( $xml->channel->item as $item ) {
|
179 |
+
$post = array(
|
180 |
+
'post_title' => (string) $item->title,
|
181 |
+
'guid' => (string) $item->guid,
|
182 |
+
);
|
183 |
+
|
184 |
+
$dc = $item->children( 'http://purl.org/dc/elements/1.1/' );
|
185 |
+
$post['post_author'] = (string) $dc->creator;
|
186 |
+
|
187 |
+
$content = $item->children( 'http://purl.org/rss/1.0/modules/content/' );
|
188 |
+
$excerpt = $item->children( $namespaces['excerpt'] );
|
189 |
+
$post['post_content'] = (string) $content->encoded;
|
190 |
+
$post['post_excerpt'] = (string) $excerpt->encoded;
|
191 |
+
|
192 |
+
$wp = $item->children( $namespaces['wp'] );
|
193 |
+
$post['post_id'] = (int) $wp->post_id;
|
194 |
+
$post['post_date'] = (string) $wp->post_date;
|
195 |
+
$post['post_date_gmt'] = (string) $wp->post_date_gmt;
|
196 |
+
$post['comment_status'] = (string) $wp->comment_status;
|
197 |
+
$post['ping_status'] = (string) $wp->ping_status;
|
198 |
+
$post['post_name'] = (string) $wp->post_name;
|
199 |
+
$post['status'] = (string) $wp->status;
|
200 |
+
$post['post_parent'] = (int) $wp->post_parent;
|
201 |
+
$post['menu_order'] = (int) $wp->menu_order;
|
202 |
+
$post['post_type'] = (string) $wp->post_type;
|
203 |
+
$post['post_password'] = (string) $wp->post_password;
|
204 |
+
$post['is_sticky'] = (int) $wp->is_sticky;
|
205 |
+
|
206 |
+
if ( isset($wp->attachment_url) )
|
207 |
+
$post['attachment_url'] = (string) $wp->attachment_url;
|
208 |
+
|
209 |
+
foreach ( $item->category as $c ) {
|
210 |
+
$att = $c->attributes();
|
211 |
+
if ( isset( $att['nicename'] ) )
|
212 |
+
$post['terms'][] = array(
|
213 |
+
'name' => (string) $c,
|
214 |
+
'slug' => (string) $att['nicename'],
|
215 |
+
'domain' => (string) $att['domain']
|
216 |
+
);
|
217 |
+
}
|
218 |
+
|
219 |
+
foreach ( $wp->postmeta as $meta ) {
|
220 |
+
$post['postmeta'][] = array(
|
221 |
+
'key' => (string) $meta->meta_key,
|
222 |
+
'value' => (string) $meta->meta_value
|
223 |
+
);
|
224 |
+
}
|
225 |
+
|
226 |
+
foreach ( $wp->comment as $comment ) {
|
227 |
+
$meta = array();
|
228 |
+
if ( isset( $comment->commentmeta ) ) {
|
229 |
+
foreach ( $comment->commentmeta as $m ) {
|
230 |
+
$meta[] = array(
|
231 |
+
'key' => (string) $m->meta_key,
|
232 |
+
'value' => (string) $m->meta_value
|
233 |
+
);
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
$post['comments'][] = array(
|
238 |
+
'comment_id' => (int) $comment->comment_id,
|
239 |
+
'comment_author' => (string) $comment->comment_author,
|
240 |
+
'comment_author_email' => (string) $comment->comment_author_email,
|
241 |
+
'comment_author_IP' => (string) $comment->comment_author_IP,
|
242 |
+
'comment_author_url' => (string) $comment->comment_author_url,
|
243 |
+
'comment_date' => (string) $comment->comment_date,
|
244 |
+
'comment_date_gmt' => (string) $comment->comment_date_gmt,
|
245 |
+
'comment_content' => (string) $comment->comment_content,
|
246 |
+
'comment_approved' => (string) $comment->comment_approved,
|
247 |
+
'comment_type' => (string) $comment->comment_type,
|
248 |
+
'comment_parent' => (string) $comment->comment_parent,
|
249 |
+
'comment_user_id' => (int) $comment->comment_user_id,
|
250 |
+
'commentmeta' => $meta,
|
251 |
+
);
|
252 |
+
}
|
253 |
+
|
254 |
+
$posts[] = $post;
|
255 |
+
}
|
256 |
+
|
257 |
+
return array(
|
258 |
+
'authors' => $authors,
|
259 |
+
'posts' => $posts,
|
260 |
+
'categories' => $categories,
|
261 |
+
'tags' => $tags,
|
262 |
+
'terms' => $terms,
|
263 |
+
'base_url' => $base_url,
|
264 |
+
'version' => $wxr_version
|
265 |
+
);
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* WXR Parser that makes use of the XML Parser PHP extension.
|
271 |
+
*/
|
272 |
+
class WXR_Parser_XML {
|
273 |
+
var $wp_tags = array(
|
274 |
+
'wp:post_id', 'wp:post_date', 'wp:post_date_gmt', 'wp:comment_status', 'wp:ping_status', 'wp:attachment_url',
|
275 |
+
'wp:status', 'wp:post_name', 'wp:post_parent', 'wp:menu_order', 'wp:post_type', 'wp:post_password',
|
276 |
+
'wp:is_sticky', 'wp:term_id', 'wp:category_nicename', 'wp:category_parent', 'wp:cat_name', 'wp:category_description',
|
277 |
+
'wp:tag_slug', 'wp:tag_name', 'wp:tag_description', 'wp:term_taxonomy', 'wp:term_parent',
|
278 |
+
'wp:term_name', 'wp:term_description', 'wp:author_id', 'wp:author_login', 'wp:author_email', 'wp:author_display_name',
|
279 |
+
'wp:author_first_name', 'wp:author_last_name',
|
280 |
+
);
|
281 |
+
var $wp_sub_tags = array(
|
282 |
+
'wp:comment_id', 'wp:comment_author', 'wp:comment_author_email', 'wp:comment_author_url',
|
283 |
+
'wp:comment_author_IP', 'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content',
|
284 |
+
'wp:comment_approved', 'wp:comment_type', 'wp:comment_parent', 'wp:comment_user_id',
|
285 |
+
);
|
286 |
+
|
287 |
+
function parse( $file ) {
|
288 |
+
$this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false;
|
289 |
+
$this->authors = $this->posts = $this->term = $this->category = $this->tag = array();
|
290 |
+
|
291 |
+
$xml = xml_parser_create( 'UTF-8' );
|
292 |
+
xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 );
|
293 |
+
xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 );
|
294 |
+
xml_set_object( $xml, $this );
|
295 |
+
xml_set_character_data_handler( $xml, 'cdata' );
|
296 |
+
xml_set_element_handler( $xml, 'tag_open', 'tag_close' );
|
297 |
+
|
298 |
+
if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) {
|
299 |
+
$current_line = xml_get_current_line_number( $xml );
|
300 |
+
$current_column = xml_get_current_column_number( $xml );
|
301 |
+
$error_code = xml_get_error_code( $xml );
|
302 |
+
$error_string = xml_error_string( $error_code );
|
303 |
+
return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) );
|
304 |
+
}
|
305 |
+
xml_parser_free( $xml );
|
306 |
+
|
307 |
+
if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) )
|
308 |
+
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
|
309 |
+
|
310 |
+
return array(
|
311 |
+
'authors' => $this->authors,
|
312 |
+
'posts' => $this->posts,
|
313 |
+
'categories' => $this->category,
|
314 |
+
'tags' => $this->tag,
|
315 |
+
'terms' => $this->term,
|
316 |
+
'base_url' => $this->base_url,
|
317 |
+
'version' => $this->wxr_version
|
318 |
+
);
|
319 |
+
}
|
320 |
+
|
321 |
+
function tag_open( $parse, $tag, $attr ) {
|
322 |
+
if ( in_array( $tag, $this->wp_tags ) ) {
|
323 |
+
$this->in_tag = substr( $tag, 3 );
|
324 |
+
return;
|
325 |
+
}
|
326 |
+
|
327 |
+
if ( in_array( $tag, $this->wp_sub_tags ) ) {
|
328 |
+
$this->in_sub_tag = substr( $tag, 3 );
|
329 |
+
return;
|
330 |
+
}
|
331 |
+
|
332 |
+
switch ( $tag ) {
|
333 |
+
case 'category':
|
334 |
+
if ( isset($attr['domain'], $attr['nicename']) ) {
|
335 |
+
$this->sub_data['domain'] = $attr['domain'];
|
336 |
+
$this->sub_data['slug'] = $attr['nicename'];
|
337 |
+
}
|
338 |
+
break;
|
339 |
+
case 'item': $this->in_post = true;
|
340 |
+
case 'title': if ( $this->in_post ) $this->in_tag = 'post_title'; break;
|
341 |
+
case 'guid': $this->in_tag = 'guid'; break;
|
342 |
+
case 'dc:creator': $this->in_tag = 'post_author'; break;
|
343 |
+
case 'content:encoded': $this->in_tag = 'post_content'; break;
|
344 |
+
case 'excerpt:encoded': $this->in_tag = 'post_excerpt'; break;
|
345 |
+
|
346 |
+
case 'wp:term_slug': $this->in_tag = 'slug'; break;
|
347 |
+
case 'wp:meta_key': $this->in_sub_tag = 'key'; break;
|
348 |
+
case 'wp:meta_value': $this->in_sub_tag = 'value'; break;
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
function cdata( $parser, $cdata ) {
|
353 |
+
if ( ! trim( $cdata ) )
|
354 |
+
return;
|
355 |
+
|
356 |
+
if ( false !== $this->in_tag || false !== $this->in_sub_tag ) {
|
357 |
+
$this->cdata .= $cdata;
|
358 |
+
} else {
|
359 |
+
$this->cdata .= trim( $cdata );
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
function tag_close( $parser, $tag ) {
|
364 |
+
switch ( $tag ) {
|
365 |
+
case 'wp:comment':
|
366 |
+
unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data
|
367 |
+
if ( ! empty( $this->sub_data ) )
|
368 |
+
$this->data['comments'][] = $this->sub_data;
|
369 |
+
$this->sub_data = false;
|
370 |
+
break;
|
371 |
+
case 'wp:commentmeta':
|
372 |
+
$this->sub_data['commentmeta'][] = array(
|
373 |
+
'key' => $this->sub_data['key'],
|
374 |
+
'value' => $this->sub_data['value']
|
375 |
+
);
|
376 |
+
break;
|
377 |
+
case 'category':
|
378 |
+
if ( ! empty( $this->sub_data ) ) {
|
379 |
+
$this->sub_data['name'] = $this->cdata;
|
380 |
+
$this->data['terms'][] = $this->sub_data;
|
381 |
+
}
|
382 |
+
$this->sub_data = false;
|
383 |
+
break;
|
384 |
+
case 'wp:postmeta':
|
385 |
+
if ( ! empty( $this->sub_data ) )
|
386 |
+
$this->data['postmeta'][] = $this->sub_data;
|
387 |
+
$this->sub_data = false;
|
388 |
+
break;
|
389 |
+
case 'item':
|
390 |
+
$this->posts[] = $this->data;
|
391 |
+
$this->data = false;
|
392 |
+
break;
|
393 |
+
case 'wp:category':
|
394 |
+
case 'wp:tag':
|
395 |
+
case 'wp:term':
|
396 |
+
$n = substr( $tag, 3 );
|
397 |
+
array_push( $this->$n, $this->data );
|
398 |
+
$this->data = false;
|
399 |
+
break;
|
400 |
+
case 'wp:author':
|
401 |
+
if ( ! empty($this->data['author_login']) )
|
402 |
+
$this->authors[$this->data['author_login']] = $this->data;
|
403 |
+
$this->data = false;
|
404 |
+
break;
|
405 |
+
case 'wp:base_site_url':
|
406 |
+
$this->base_url = $this->cdata;
|
407 |
+
break;
|
408 |
+
case 'wp:wxr_version':
|
409 |
+
$this->wxr_version = $this->cdata;
|
410 |
+
break;
|
411 |
+
|
412 |
+
default:
|
413 |
+
if ( $this->in_sub_tag ) {
|
414 |
+
$this->sub_data[$this->in_sub_tag] = ! empty( $this->cdata ) ? $this->cdata : '';
|
415 |
+
$this->in_sub_tag = false;
|
416 |
+
} else if ( $this->in_tag ) {
|
417 |
+
$this->data[$this->in_tag] = ! empty( $this->cdata ) ? $this->cdata : '';
|
418 |
+
$this->in_tag = false;
|
419 |
+
}
|
420 |
+
}
|
421 |
+
|
422 |
+
$this->cdata = false;
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* WXR Parser that uses regular expressions. Fallback for installs without an XML parser.
|
428 |
+
*/
|
429 |
+
class WXR_Parser_Regex {
|
430 |
+
var $authors = array();
|
431 |
+
var $posts = array();
|
432 |
+
var $categories = array();
|
433 |
+
var $tags = array();
|
434 |
+
var $terms = array();
|
435 |
+
var $base_url = '';
|
436 |
+
|
437 |
+
function __construct() {
|
438 |
+
$this->has_gzip = is_callable( 'gzopen' );
|
439 |
+
}
|
440 |
+
|
441 |
+
function parse( $file ) {
|
442 |
+
$wxr_version = $in_multiline = false;
|
443 |
+
|
444 |
+
$multiline_content = '';
|
445 |
+
|
446 |
+
$multiline_tags = array(
|
447 |
+
'item' => array( 'posts', array( $this, 'process_post' ) ),
|
448 |
+
'wp:category' => array( 'categories', array( $this, 'process_category' ) ),
|
449 |
+
'wp:tag' => array( 'tags', array( $this, 'process_tag' ) ),
|
450 |
+
'wp:term' => array( 'terms', array( $this, 'process_term' ) ),
|
451 |
+
);
|
452 |
+
|
453 |
+
$fp = $this->fopen( $file, 'r' );
|
454 |
+
if ( $fp ) {
|
455 |
+
while ( ! $this->feof( $fp ) ) {
|
456 |
+
$importline = rtrim( $this->fgets( $fp ) );
|
457 |
+
|
458 |
+
if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) )
|
459 |
+
$wxr_version = $version[1];
|
460 |
+
|
461 |
+
if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) {
|
462 |
+
preg_match( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url );
|
463 |
+
$this->base_url = $url[1];
|
464 |
+
continue;
|
465 |
+
}
|
466 |
+
|
467 |
+
if ( false !== strpos( $importline, '<wp:author>' ) ) {
|
468 |
+
preg_match( '|<wp:author>(.*?)</wp:author>|is', $importline, $author );
|
469 |
+
$a = $this->process_author( $author[1] );
|
470 |
+
$this->authors[$a['author_login']] = $a;
|
471 |
+
continue;
|
472 |
+
}
|
473 |
+
|
474 |
+
foreach ( $multiline_tags as $tag => $handler ) {
|
475 |
+
// Handle multi-line tags on a singular line
|
476 |
+
if ( preg_match( '|<' . $tag . '>(.*?)</' . $tag . '>|is', $importline, $matches ) ) {
|
477 |
+
$this->{$handler[0]}[] = call_user_func( $handler[1], $matches[1] );
|
478 |
+
|
479 |
+
} elseif ( false !== ( $pos = strpos( $importline, "<$tag>" ) ) ) {
|
480 |
+
// Take note of any content after the opening tag
|
481 |
+
$multiline_content = trim( substr( $importline, $pos + strlen( $tag ) + 2 ) );
|
482 |
+
|
483 |
+
// We don't want to have this line added to `$is_multiline` below.
|
484 |
+
$importline = '';
|
485 |
+
$in_multiline = $tag;
|
486 |
+
|
487 |
+
} elseif ( false !== ( $pos = strpos( $importline, "</$tag>" ) ) ) {
|
488 |
+
$in_multiline = false;
|
489 |
+
$multiline_content .= trim( substr( $importline, 0, $pos ) );
|
490 |
+
|
491 |
+
$this->{$handler[0]}[] = call_user_func( $handler[1], $multiline_content );
|
492 |
+
}
|
493 |
+
}
|
494 |
+
|
495 |
+
if ( $in_multiline && $importline ) {
|
496 |
+
$multiline_content .= $importline . "\n";
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
500 |
+
$this->fclose($fp);
|
501 |
+
}
|
502 |
+
|
503 |
+
if ( ! $wxr_version )
|
504 |
+
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
|
505 |
+
|
506 |
+
return array(
|
507 |
+
'authors' => $this->authors,
|
508 |
+
'posts' => $this->posts,
|
509 |
+
'categories' => $this->categories,
|
510 |
+
'tags' => $this->tags,
|
511 |
+
'terms' => $this->terms,
|
512 |
+
'base_url' => $this->base_url,
|
513 |
+
'version' => $wxr_version
|
514 |
+
);
|
515 |
+
}
|
516 |
+
|
517 |
+
function get_tag( $string, $tag ) {
|
518 |
+
preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return );
|
519 |
+
if ( isset( $return[1] ) ) {
|
520 |
+
if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) {
|
521 |
+
if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) {
|
522 |
+
preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches );
|
523 |
+
$return = '';
|
524 |
+
foreach( $matches[1] as $match )
|
525 |
+
$return .= $match;
|
526 |
+
} else {
|
527 |
+
$return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
|
528 |
+
}
|
529 |
+
} else {
|
530 |
+
$return = $return[1];
|
531 |
+
}
|
532 |
+
} else {
|
533 |
+
$return = '';
|
534 |
+
}
|
535 |
+
return $return;
|
536 |
+
}
|
537 |
+
|
538 |
+
function process_category( $c ) {
|
539 |
+
return array(
|
540 |
+
'term_id' => $this->get_tag( $c, 'wp:term_id' ),
|
541 |
+
'cat_name' => $this->get_tag( $c, 'wp:cat_name' ),
|
542 |
+
'category_nicename' => $this->get_tag( $c, 'wp:category_nicename' ),
|
543 |
+
'category_parent' => $this->get_tag( $c, 'wp:category_parent' ),
|
544 |
+
'category_description' => $this->get_tag( $c, 'wp:category_description' ),
|
545 |
+
);
|
546 |
+
}
|
547 |
+
|
548 |
+
function process_tag( $t ) {
|
549 |
+
return array(
|
550 |
+
'term_id' => $this->get_tag( $t, 'wp:term_id' ),
|
551 |
+
'tag_name' => $this->get_tag( $t, 'wp:tag_name' ),
|
552 |
+
'tag_slug' => $this->get_tag( $t, 'wp:tag_slug' ),
|
553 |
+
'tag_description' => $this->get_tag( $t, 'wp:tag_description' ),
|
554 |
+
);
|
555 |
+
}
|
556 |
+
|
557 |
+
function process_term( $t ) {
|
558 |
+
return array(
|
559 |
+
'term_id' => $this->get_tag( $t, 'wp:term_id' ),
|
560 |
+
'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ),
|
561 |
+
'slug' => $this->get_tag( $t, 'wp:term_slug' ),
|
562 |
+
'term_parent' => $this->get_tag( $t, 'wp:term_parent' ),
|
563 |
+
'term_name' => $this->get_tag( $t, 'wp:term_name' ),
|
564 |
+
'term_description' => $this->get_tag( $t, 'wp:term_description' ),
|
565 |
+
);
|
566 |
+
}
|
567 |
+
|
568 |
+
function process_author( $a ) {
|
569 |
+
return array(
|
570 |
+
'author_id' => $this->get_tag( $a, 'wp:author_id' ),
|
571 |
+
'author_login' => $this->get_tag( $a, 'wp:author_login' ),
|
572 |
+
'author_email' => $this->get_tag( $a, 'wp:author_email' ),
|
573 |
+
'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ),
|
574 |
+
'author_first_name' => $this->get_tag( $a, 'wp:author_first_name' ),
|
575 |
+
'author_last_name' => $this->get_tag( $a, 'wp:author_last_name' ),
|
576 |
+
);
|
577 |
+
}
|
578 |
+
|
579 |
+
function process_post( $post ) {
|
580 |
+
$post_id = $this->get_tag( $post, 'wp:post_id' );
|
581 |
+
$post_title = $this->get_tag( $post, 'title' );
|
582 |
+
$post_date = $this->get_tag( $post, 'wp:post_date' );
|
583 |
+
$post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' );
|
584 |
+
$comment_status = $this->get_tag( $post, 'wp:comment_status' );
|
585 |
+
$ping_status = $this->get_tag( $post, 'wp:ping_status' );
|
586 |
+
$status = $this->get_tag( $post, 'wp:status' );
|
587 |
+
$post_name = $this->get_tag( $post, 'wp:post_name' );
|
588 |
+
$post_parent = $this->get_tag( $post, 'wp:post_parent' );
|
589 |
+
$menu_order = $this->get_tag( $post, 'wp:menu_order' );
|
590 |
+
$post_type = $this->get_tag( $post, 'wp:post_type' );
|
591 |
+
$post_password = $this->get_tag( $post, 'wp:post_password' );
|
592 |
+
$is_sticky = $this->get_tag( $post, 'wp:is_sticky' );
|
593 |
+
$guid = $this->get_tag( $post, 'guid' );
|
594 |
+
$post_author = $this->get_tag( $post, 'dc:creator' );
|
595 |
+
|
596 |
+
$post_excerpt = $this->get_tag( $post, 'excerpt:encoded' );
|
597 |
+
$post_excerpt = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt );
|
598 |
+
$post_excerpt = str_replace( '<br>', '<br />', $post_excerpt );
|
599 |
+
$post_excerpt = str_replace( '<hr>', '<hr />', $post_excerpt );
|
600 |
+
|
601 |
+
$post_content = $this->get_tag( $post, 'content:encoded' );
|
602 |
+
$post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content );
|
603 |
+
$post_content = str_replace( '<br>', '<br />', $post_content );
|
604 |
+
$post_content = str_replace( '<hr>', '<hr />', $post_content );
|
605 |
+
|
606 |
+
$postdata = compact( 'post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt',
|
607 |
+
'post_title', 'status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent',
|
608 |
+
'menu_order', 'post_type', 'post_password', 'is_sticky'
|
609 |
+
);
|
610 |
+
|
611 |
+
$attachment_url = $this->get_tag( $post, 'wp:attachment_url' );
|
612 |
+
if ( $attachment_url )
|
613 |
+
$postdata['attachment_url'] = $attachment_url;
|
614 |
+
|
615 |
+
preg_match_all( '|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER );
|
616 |
+
foreach ( $terms as $t ) {
|
617 |
+
$post_terms[] = array(
|
618 |
+
'slug' => $t[2],
|
619 |
+
'domain' => $t[1],
|
620 |
+
'name' => str_replace( array( '<![CDATA[', ']]>' ), '', $t[3] ),
|
621 |
+
);
|
622 |
+
}
|
623 |
+
if ( ! empty( $post_terms ) ) $postdata['terms'] = $post_terms;
|
624 |
+
|
625 |
+
preg_match_all( '|<wp:comment>(.+?)</wp:comment>|is', $post, $comments );
|
626 |
+
$comments = $comments[1];
|
627 |
+
if ( $comments ) {
|
628 |
+
foreach ( $comments as $comment ) {
|
629 |
+
preg_match_all( '|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta );
|
630 |
+
$commentmeta = $commentmeta[1];
|
631 |
+
$c_meta = array();
|
632 |
+
foreach ( $commentmeta as $m ) {
|
633 |
+
$c_meta[] = array(
|
634 |
+
'key' => $this->get_tag( $m, 'wp:meta_key' ),
|
635 |
+
'value' => $this->get_tag( $m, 'wp:meta_value' ),
|
636 |
+
);
|
637 |
+
}
|
638 |
+
|
639 |
+
$post_comments[] = array(
|
640 |
+
'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ),
|
641 |
+
'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ),
|
642 |
+
'comment_author_email' => $this->get_tag( $comment, 'wp:comment_author_email' ),
|
643 |
+
'comment_author_IP' => $this->get_tag( $comment, 'wp:comment_author_IP' ),
|
644 |
+
'comment_author_url' => $this->get_tag( $comment, 'wp:comment_author_url' ),
|
645 |
+
'comment_date' => $this->get_tag( $comment, 'wp:comment_date' ),
|
646 |
+
'comment_date_gmt' => $this->get_tag( $comment, 'wp:comment_date_gmt' ),
|
647 |
+
'comment_content' => $this->get_tag( $comment, 'wp:comment_content' ),
|
648 |
+
'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ),
|
649 |
+
'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ),
|
650 |
+
'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ),
|
651 |
+
'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ),
|
652 |
+
'commentmeta' => $c_meta,
|
653 |
+
);
|
654 |
+
}
|
655 |
+
}
|
656 |
+
if ( ! empty( $post_comments ) ) $postdata['comments'] = $post_comments;
|
657 |
+
|
658 |
+
preg_match_all( '|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta );
|
659 |
+
$postmeta = $postmeta[1];
|
660 |
+
if ( $postmeta ) {
|
661 |
+
foreach ( $postmeta as $p ) {
|
662 |
+
$post_postmeta[] = array(
|
663 |
+
'key' => $this->get_tag( $p, 'wp:meta_key' ),
|
664 |
+
'value' => $this->get_tag( $p, 'wp:meta_value' ),
|
665 |
+
);
|
666 |
+
}
|
667 |
+
}
|
668 |
+
if ( ! empty( $post_postmeta ) ) $postdata['postmeta'] = $post_postmeta;
|
669 |
+
|
670 |
+
return $postdata;
|
671 |
+
}
|
672 |
+
|
673 |
+
function _normalize_tag( $matches ) {
|
674 |
+
return '<' . strtolower( $matches[1] );
|
675 |
+
}
|
676 |
+
|
677 |
+
function fopen( $filename, $mode = 'r' ) {
|
678 |
+
if ( $this->has_gzip )
|
679 |
+
return gzopen( $filename, $mode );
|
680 |
+
return fopen( $filename, $mode );
|
681 |
+
}
|
682 |
+
|
683 |
+
function feof( $fp ) {
|
684 |
+
if ( $this->has_gzip )
|
685 |
+
return gzeof( $fp );
|
686 |
+
return feof( $fp );
|
687 |
+
}
|
688 |
+
|
689 |
+
function fgets( $fp, $len = 8192 ) {
|
690 |
+
if ( $this->has_gzip )
|
691 |
+
return gzgets( $fp, $len );
|
692 |
+
return fgets( $fp, $len );
|
693 |
+
}
|
694 |
+
|
695 |
+
function fclose( $fp ) {
|
696 |
+
if ( $this->has_gzip )
|
697 |
+
return gzclose( $fp );
|
698 |
+
return fclose( $fp );
|
699 |
+
}
|
700 |
+
}
|
languages/popupBuilder.pot
CHANGED
@@ -825,7 +825,7 @@ msgid "Save"
|
|
825 |
msgstr ""
|
826 |
|
827 |
#: popup-builder-plugin/com/classes/Filters.php:187
|
828 |
-
msgid "
|
829 |
msgstr ""
|
830 |
|
831 |
#: popup-builder-plugin/com/classes/Filters.php:188
|
825 |
msgstr ""
|
826 |
|
827 |
#: popup-builder-plugin/com/classes/Filters.php:187
|
828 |
+
msgid "Views"
|
829 |
msgstr ""
|
830 |
|
831 |
#: popup-builder-plugin/com/classes/Filters.php:188
|
popup-builder.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Popup Builder
|
4 |
* Plugin URI: https://popup-builder.com
|
5 |
* Description: The most complete popup plugin. Html, image, iframe, shortcode, video and many other popup types. Manage popup dimensions, effects, themes and more.
|
6 |
-
* Version: 3.
|
7 |
* Author: Sygnoos
|
8 |
* Author URI: https://sygnoos.com
|
9 |
* License: GPLv2
|
3 |
* Plugin Name: Popup Builder
|
4 |
* Plugin URI: https://popup-builder.com
|
5 |
* Description: The most complete popup plugin. Html, image, iframe, shortcode, video and many other popup types. Manage popup dimensions, effects, themes and more.
|
6 |
+
* Version: 3.1
|
7 |
* Author: Sygnoos
|
8 |
* Author URI: https://sygnoos.com
|
9 |
* License: GPLv2
|
public/css/popupAdminStyles.css
CHANGED
@@ -1849,6 +1849,25 @@ input:checked + .sgpb-slider:before {
|
|
1849 |
margin-right: 20px;
|
1850 |
}
|
1851 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1852 |
.sgpb-upgrade-banner-btn {
|
1853 |
width: 85% !important;
|
1854 |
margin-top: 80px !important;
|
@@ -1906,11 +1925,11 @@ input:checked + .sgpb-slider:before {
|
|
1906 |
.sgpb-dashicons-admin-plugins:before,
|
1907 |
.sgpb-dashicons-editor-help:before,
|
1908 |
.sgpb-dashicons-email-alt:before {
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
}
|
1915 |
|
1916 |
.sgpb-dashicons-heart:before {
|
@@ -2007,3 +2026,12 @@ input:checked + .sgpb-slider:before {
|
|
2007 |
background-color: rgba(235, 95, 70, 0.6) !important;
|
2008 |
border-color: rgba(235, 95, 70, 0.2) !important;
|
2009 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1849 |
margin-right: 20px;
|
1850 |
}
|
1851 |
|
1852 |
+
.sgpb-review-popup-banner-wrapper {
|
1853 |
+
clear: both;
|
1854 |
+
overflow: hidden;
|
1855 |
+
padding-top: 20px;
|
1856 |
+
margin: 10px 20px 10px 0;
|
1857 |
+
background-color: #ffffff;
|
1858 |
+
}
|
1859 |
+
|
1860 |
+
.sgpb-review-popup-banner-wrapper h1,
|
1861 |
+
.sgpb-review-popup-banner-wrapper h2 {
|
1862 |
+
font-size: 22px;
|
1863 |
+
font-weight: normal;
|
1864 |
+
line-height: 1.384;
|
1865 |
+
}
|
1866 |
+
|
1867 |
+
.sgpb-review-popup-banner-wrapper h1 {
|
1868 |
+
margin: 0;
|
1869 |
+
}
|
1870 |
+
|
1871 |
.sgpb-upgrade-banner-btn {
|
1872 |
width: 85% !important;
|
1873 |
margin-top: 80px !important;
|
1925 |
.sgpb-dashicons-admin-plugins:before,
|
1926 |
.sgpb-dashicons-editor-help:before,
|
1927 |
.sgpb-dashicons-email-alt:before {
|
1928 |
+
background-size: 100%;
|
1929 |
+
display: inline-block;
|
1930 |
+
width: 20px;
|
1931 |
+
height: 20px;
|
1932 |
+
content: '';
|
1933 |
}
|
1934 |
|
1935 |
.sgpb-dashicons-heart:before {
|
2026 |
background-color: rgba(235, 95, 70, 0.6) !important;
|
2027 |
border-color: rgba(235, 95, 70, 0.2) !important;
|
2028 |
}
|
2029 |
+
|
2030 |
+
.sgpb-import-wrapper input {
|
2031 |
+
display: inline-block !important;
|
2032 |
+
}
|
2033 |
+
|
2034 |
+
.sgpb-import-wrapper .submit {
|
2035 |
+
float: none !important;
|
2036 |
+
padding: 0 !important;
|
2037 |
+
}
|
public/js/MediaButton.js
CHANGED
@@ -1,11 +1,21 @@
|
|
1 |
function SGPBMediaButton(){}
|
2 |
SGPBMediaButton.prototype.init=function()
|
3 |
-
{this.openMediaButtonPopup();};SGPBMediaButton.prototype.openMediaButtonPopup=function()
|
4 |
{var that=this;var select2Init=1;jQuery('.sgpb-insert-media-button-js, .sgpb-insert-js-variable').bind('click',function(e){e.preventDefault();var hiddenDivId=jQuery(this).attr('data-id');var popupConfigObj=new PopupConfig();popupConfigObj.magicCall('setContentPadding',14);popupConfigObj.magicCall('setContentBorderRadius',4);popupConfigObj.magicCall('setContentBorderRadiusType','px');popupConfigObj.magicCall('setContentBorderWidth',5);popupConfigObj.magicCall('setContentBorderColor','#506274');popupConfigObj.magicCall('setShadowSpread',1);popupConfigObj.magicCall('setContentShadowBlur',4);popupConfigObj.magicCall('setContentShadowColor','#cccccc');popupConfigObj.magicCall('setMinWidth',400);popupConfigObj.magicCall('setSrcElement',hiddenDivId);popupConfigObj.magicCall('setOverlayColor','black');popupConfigObj.magicCall('setOverlayOpacity',40);var config=popupConfigObj.combineConfigObj();var popup=new SGPopup(config);popup.open();jQuery(window).bind('sgpbDidOpen',function(){jQuery('.sgpb-insert-popup').addClass('js-sg-select2');if(mediaButtonParams.currentPostType!=mediaButtonParams.popupBuilderPostType){jQuery('.sgpb-insert-popup-event').addClass('js-sg-select2');if(select2Init==1){that.popupSelect2();}
|
5 |
select2Init++;console.log(jQuery('.select2-container--below').length);jQuery('.select2-container--below').remove();that.popupSelect2();}
|
6 |
else{that.popupSelect2();jQuery('.select2-container--below').remove();}
|
7 |
-
that.closeMediaButtonPopup(popup);});that.insertPopup(popup);});};SGPBMediaButton.prototype.
|
8 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
{var insidePopup=false;if(mediaButtonParams.currentPostType==mediaButtonParams.popupBuilderPostType){insidePopup=true;}
|
10 |
jQuery('.sgpb-insert-popup-js').bind('click',function(){var selectedPopup=jQuery('.sgpb-insert-popup').val();var selectedPopupEvent=jQuery('.sgpb-insert-popup-event').val();if(typeof selectedPopupEvent!='undefined'){selectedPopupEvent=' event="'+selectedPopupEvent+'"';}
|
11 |
else{selectedPopupEvent='';if(insidePopup){selectedPopupEvent=' insidePopup="on"';}}
|
1 |
function SGPBMediaButton(){}
|
2 |
SGPBMediaButton.prototype.init=function()
|
3 |
+
{this.openMediaButtonPopup();this.openAskReviewBannerPopup();};SGPBMediaButton.prototype.openMediaButtonPopup=function()
|
4 |
{var that=this;var select2Init=1;jQuery('.sgpb-insert-media-button-js, .sgpb-insert-js-variable').bind('click',function(e){e.preventDefault();var hiddenDivId=jQuery(this).attr('data-id');var popupConfigObj=new PopupConfig();popupConfigObj.magicCall('setContentPadding',14);popupConfigObj.magicCall('setContentBorderRadius',4);popupConfigObj.magicCall('setContentBorderRadiusType','px');popupConfigObj.magicCall('setContentBorderWidth',5);popupConfigObj.magicCall('setContentBorderColor','#506274');popupConfigObj.magicCall('setShadowSpread',1);popupConfigObj.magicCall('setContentShadowBlur',4);popupConfigObj.magicCall('setContentShadowColor','#cccccc');popupConfigObj.magicCall('setMinWidth',400);popupConfigObj.magicCall('setSrcElement',hiddenDivId);popupConfigObj.magicCall('setOverlayColor','black');popupConfigObj.magicCall('setOverlayOpacity',40);var config=popupConfigObj.combineConfigObj();var popup=new SGPopup(config);popup.open();jQuery(window).bind('sgpbDidOpen',function(){jQuery('.sgpb-insert-popup').addClass('js-sg-select2');if(mediaButtonParams.currentPostType!=mediaButtonParams.popupBuilderPostType){jQuery('.sgpb-insert-popup-event').addClass('js-sg-select2');if(select2Init==1){that.popupSelect2();}
|
5 |
select2Init++;console.log(jQuery('.select2-container--below').length);jQuery('.select2-container--below').remove();that.popupSelect2();}
|
6 |
else{that.popupSelect2();jQuery('.select2-container--below').remove();}
|
7 |
+
that.closeMediaButtonPopup(popup);});that.insertPopup(popup);});};SGPBMediaButton.prototype.openAskReviewBannerPopup=function()
|
8 |
+
{var that=this;var select2Init=1;var popupConfigObj=new PopupConfig();popupConfigObj.magicCall('setContentPadding',14);popupConfigObj.magicCall('setContentBorderRadius',4);popupConfigObj.magicCall('setContentBorderRadiusType','px');popupConfigObj.magicCall('setShadowSpread',14);popupConfigObj.magicCall('setOverlayAddClass','sgpb-theme-1-overlay');popupConfigObj.magicCall('setContentShadowColor','#0009');popupConfigObj.magicCall('setMinWidth',400);popupConfigObj.magicCall('setMaxWidth','700px');popupConfigObj.magicCall('setOverlayShouldClose',false);popupConfigObj.magicCall('setSrcElement','sg-popup-content-wrapper-0');if(jQuery('#sg-popup-content-wrapper-0').length){var config=popupConfigObj.combineConfigObj();var popup=new SGPopup(config);popup.open();}
|
9 |
+
else{that.closingActions();}
|
10 |
+
jQuery(window).bind('sgpbDidOpen',function(){that.closingActions(popup);});};SGPBMediaButton.prototype.closingActions=function(popup)
|
11 |
+
{jQuery('.sg-already-did-review').each(function(){jQuery(this).click(function(){var ajaxData={action:'sgpb_dont_show_review_popup',nonce:SGPB_JS_PARAMS.nonce};jQuery.post(SGPB_JS_PARAMS.url,ajaxData,function(res){if(typeof popup!='undefined'){popup.close();}
|
12 |
+
if(jQuery('.sgpb-review-popup-banner-wrapper').length){jQuery('.sgpb-review-popup-banner-wrapper').remove();}});});});jQuery('.sg-you-worth-it').each(function(){jQuery(this).click(function(){var ajaxData={action:'sgpb_dont_show_review_popup',nonce:SGPB_JS_PARAMS.nonce};jQuery.post(SGPB_JS_PARAMS.url,ajaxData,function(res){if(typeof popup!='undefined'){popup.close();}
|
13 |
+
if(jQuery('.sgpb-review-popup-banner-wrapper').length){jQuery('.sgpb-review-popup-banner-wrapper').remove();}
|
14 |
+
window.location=SGPB_JS_EXTENSIONS_PARAMS.reviewUrl;});});});jQuery('.sg-show-popup-period').click(function(){var messageType=jQuery(this).attr('data-message-type');var ajaxData={action:'sgpb_change_review_popup_show_period',messageType:messageType,nonce:SGPB_JS_PARAMS.nonce};jQuery.post(SGPB_JS_PARAMS.url,ajaxData,function(res){if(typeof popup!='undefined'){popup.close();}
|
15 |
+
if(jQuery('.sgpb-review-popup-banner-wrapper').length){jQuery('.sgpb-review-popup-banner-wrapper').remove();}})});jQuery('.sgpb-dont-show-ask-review-popup').click(function(){var ajaxData={action:'sgpb_hide_ask_review_popup',nonce:SGPB_JS_PARAMS.nonce};jQuery.post(SGPB_JS_PARAMS.url,ajaxData,function(res){if(res){popup.close();}})});}
|
16 |
+
SGPBMediaButton.prototype.closeMediaButtonPopup=function(popup)
|
17 |
+
{jQuery('.sgpb-close-media-popup-js').on('click',function(){popup.close();});};SGPBMediaButton.prototype.closeReviewPopup=function(popup)
|
18 |
+
{jQuery('.sgpb-button-2').on('click',function(){popup.close();});};SGPBMediaButton.prototype.insertPopup=function(popup)
|
19 |
{var insidePopup=false;if(mediaButtonParams.currentPostType==mediaButtonParams.popupBuilderPostType){insidePopup=true;}
|
20 |
jQuery('.sgpb-insert-popup-js').bind('click',function(){var selectedPopup=jQuery('.sgpb-insert-popup').val();var selectedPopupEvent=jQuery('.sgpb-insert-popup-event').val();if(typeof selectedPopupEvent!='undefined'){selectedPopupEvent=' event="'+selectedPopupEvent+'"';}
|
21 |
else{selectedPopupEvent='';if(insidePopup){selectedPopupEvent=' insidePopup="on"';}}
|
public/js/Popup.js
CHANGED
@@ -2,7 +2,7 @@ function SGPopup(config)
|
|
2 |
{var integrations=config.integrations;var popupName=config.popupName;var initialConfig=config;var prefix=config.prefix||'sgpb';var isInited=false;var mainDiv=null;var contentDiv=null;var DIV=null;var opened=false;var resizeTimeout=null;var overlayDiv=null;var defaultZIndex=config.contentBox.zIndex||9999;var defaultWidth="640px";var defaultHeight=config.autoHeight;var closeButtonImage=null;var popupId=config.id;var showOnce=config.showOnce||false;var events=config.events||[];var openDelay=config.openDelay||0;var popupTheme=config.popupTheme;var popupType=config.popupType;var fitBackgroundImg=null;var openAnimation=config.openAnimation||{type:"none",speed:0};var closeAnimation=config.closeAnimation||{type:"none",speed:0};var closeBehavior=config.closeBehavior||{allowed:true,showButton:true,buttonPosition:'topLeft',buttonInside:true,autoclose:false,overlayShouldClose:true,contentShouldClose:false,escShouldClose:true};var closeButton=config.closeButton||{data:sgpbPublicUrl+'img/close.png',width:16,height:16,widthType:'px',heightType:'px',closeButtonType:'IMG',closeButtonText:'Close'};var overlay=config.overlay||{visible:true,color:"#000",opacity:0.7};var contentBox=config.contentBox||{padding:8,showBackground:true,backgroundColor:"#fff",borderStyle:"solid",borderColor:"#ccc",borderRadius:config.contentBox.borderRadius,borderRadiusType:config.contentBox.borderRadiusType,borderWidth:1,shadowColor:"#ccc",shadowSpread:0,shadowBlur:10,scrollingEnabled:true,backgroundPosition:''};var contents=config.contents||"";var inline=config.inline||false;var href=config.href||false;var position=config.position||{left:"center",top:"center"};if((typeof position.left=="undefined"||(isNaN(parseInt(position.left))&&position.left!="center"))&&(typeof position.right=="undefined"||(isNaN(parseInt(position.right))&&position.right!="center"))){position.left="center";}
|
3 |
if((typeof position.top=="undefined"||(isNaN(parseInt(position.top))&&position.top!="center"))&&(typeof position.bottom=="undefined"||(isNaN(parseInt(position.bottom))&&position.bottom!="center"))){position.top="center";}
|
4 |
var sizingRanges=config.sizingRanges||[{screenFrom:{width:-1,height:-1},screenTo:{width:-1,height:-1},width:defaultWidth,height:defaultHeight,maxWidth:-1,maxHeight:-1,minWidth:-1,minHeight:-1}];var shouldOpen=config.shouldOpen||function(){return true;};var willOpen=config.willOpen||function(){};var didOpen=config.didOpen||function(){};var shouldClose=config.shouldClose||function(){return true;};var willClose=config.willClose||function(){};var didClose=config.didClose||function(){};SGPopup.inlinePrevTarget=SGPopup.inlinePrevTarget||{};function resetInlineContent()
|
5 |
-
{if(inline){var htmlElement=document.getElementById(inline);if(SGPopup.inlinePrevTarget.hasPreviousElement){SGPopup.inlinePrevTarget.parentNode.insertBefore(htmlElement,SGPopup.inlinePrevTarget.node.nextSibling);}
|
6 |
else{SGPopup.inlinePrevTarget.node.appendChild(htmlElement);}}}
|
7 |
var OPEN_ANIMATION_POP="@-webkit-keyframes popin{from{-webkit-transform:scale(.8);opacity:0}to{-webkit-transform:scale(1);opacity:1}}@-moz-keyframes popin{from{-moz-transform:scale(.8);opacity:0}to{-moz-transform:scale(1);opacity:1}}@keyframes popin{from{transform:scale(.8);opacity:0}to{transform:scale(1);opacity:1}}";var OPEN_ANIMATION_FADE="@-webkit-keyframes fadein{from{opacity:0}to{opacity:1}}@-moz-keyframes fadein{from{opacity:0}to{opacity:1}}@keyframes fadein{from{opacity:0}to{opacity:1}}";var OPEN_ANIMATION_FLIP="@-webkit-keyframes flipintoright{from{-webkit-transform:rotateY(90deg) scale(.9)}to{-webkit-transform:rotateY(0)}}@-moz-keyframes flipintoright{from{-moz-transform:rotateY(90deg) scale(.9)}to{-moz-transform:rotateY(0)}}@keyframes flipintoright{from{transform:rotateY(90deg) scale(.9)}to{transform:rotateY(0)}}";var OPEN_ANIMATION_SLIDELEFT="@-webkit-keyframes slideinfromright{from{-webkit-transform:translate3d({start},0,0)}to{-webkit-transform:translate3d(0,0,0)}}@-moz-keyframes slideinfromright{from{-moz-transform:translateX({start})}to{-moz-transform:translateX(0)}}@keyframes slideinfromright{from{transform:translateX({start})}to{transform:translateX(0)}}";var OPEN_ANIMATION_SLIDERIGHT="@-webkit-keyframes slideinfromleft{from{-webkit-transform:translate3d({start},0,0)}to{-webkit-transform:translate3d(0,0,0)}}@-moz-keyframes slideinfromleft{from{-moz-transform:translateX({start})}to{-moz-transform:translateX(0)}}@keyframes slideinfromleft{from{transform:translateX({start})}to{transform:translateX(0)}}";var OPEN_ANIMATION_FLOW="@-webkit-keyframes flowinfromright{0%{-webkit-transform:translateX(100%) scale(.7)}30%,40%{-webkit-transform:translateX(0) scale(.7)}100%{-webkit-transform:translateX(0) scale(1)}}@-moz-keyframes flowinfromright{0%{-moz-transform:translateX(100%) scale(.7)}30%,40%{-moz-transform:translateX(0) scale(.7)}100%{-moz-transform:translateX(0) scale(1)}}@keyframes flowinfromright{0%{transform:translateX(100%) scale(.7)}30%,40%{transform:translateX(0) scale(.7)}100%{transform:translateX(0) scale(1)}}";var OPEN_ANIMATION_SLIDEUP="@-webkit-keyframes slideinfrombottom{from{-webkit-transform:translateY({start})}to{-webkit-transform:translateY(0)}}@-moz-keyframes slideinfrombottom{from{-moz-transform:translateY({start})}to{-moz-transform:translateY(0)}}@keyframes slideinfrombottom{from{transform:translateY({start})}to{transform:translateY(0)}}";var OPEN_ANIMATION_SLIDEDOWN="@-webkit-keyframes slideinfromtop{from{-webkit-transform:translateY({start})}to{-webkit-transform:translateY(0)}}@-moz-keyframes slideinfromtop{from{-moz-transform:translateY({start})}to{-moz-transform:translateY(0)}}@keyframes slideinfromtop{from{transform:translateY({start})}to{transform:translateY(0)}}";var CLOSE_ANIMATION_SLIDELEFT="@-webkit-keyframes slideouttoleft{from{-webkit-transform:translate3d(0,0,0)}to{-webkit-transform:translate3d({end},0,0)}}@-moz-keyframes slideouttoleft{from{-moz-transform:translateX(0)}to{-moz-transform:translateX({end})}}@keyframes slideouttoleft{from{transform:translateX(0)}to{transform:translateX({end})}}";var CLOSE_ANIMATION_SLIDERIGHT="@-webkit-keyframes slideouttoright{from{-webkit-transform:translate3d(0,0,0)}to{-webkit-transform:translate3d({end},0,0)}}@-moz-keyframes slideouttoright{from{-moz-transform:translateX(0)}to{-moz-transform:translateX({end})}}@keyframes slideouttoright{from{transform:translateX(0)}to{transform:translateX({end})}}";var CLOSE_ANIMATION_POP="@-webkit-keyframes popout{from{-webkit-transform:scale(1);opacity:1}to{-webkit-transform:scale(.8);opacity:0}}@-moz-keyframes popout{from{-moz-transform:scale(1);opacity:1}to{-moz-transform:scale(.8);opacity:0}}@keyframes popout{from{transform:scale(1);opacity:1}to{transform:scale(.8);opacity:0}}";var CLOSE_ANIMATION_FADE="@-webkit-keyframes fadeout{from{opacity:1}to{opacity:0}}@-moz-keyframes fadeout{from{opacity:1}to{opacity:0}}@keyframes fadeout{from{opacity:1}to{opacity:0}}";var CLOSE_ANIMATION_FLIP="@-webkit-keyframes flipouttoright{from{-webkit-transform:rotateY(0)}to{-webkit-transform:rotateY(90deg) scale(.9)}}@-moz-keyframes flipouttoright{from{-moz-transform:rotateY(0)}to{-moz-transform:rotateY(90deg) scale(.9)}}@keyframes flipouttoright{from{transform:rotateY(0)}to{transform:rotateY(90deg) scale(.9)}}";var CLOSE_ANIMATION_FLOW="@-webkit-keyframes flowouttoright{0%{-webkit-transform:translateX(0) scale(1)}60%,70%{-webkit-transform:translateX(0) scale(.7)}100%{-webkit-transform:translateX(100%) scale(.7)}}@-moz-keyframes flowouttoright{0%{-moz-transform:translateX(0) scale(1)}60%,70%{-moz-transform:translateX(0) scale(.7)}100%{-moz-transform:translateX(100%) scale(.7)}}@keyframes flowouttoright{0%{transform:translateX(0) scale(1)}60%,70%{transform:translateX(0) scale(.7)}100%{transform:translateX(100%) scale(.7)}}";var CLOSE_ANIMATION_SLIDEUP="@-webkit-keyframes slideouttotop{from{-webkit-transform:translateY(0)}to{-webkit-transform:translateY({end})}}@-moz-keyframes slideouttotop{from{-moz-transform:translateY(0)}to{-moz-transform:translateY({end})}}@keyframes slideouttotop{from{transform:translateY(0)}to{transform:translateY({end})}}";var CLOSE_ANIMATION_SLIDEDOWN="@-webkit-keyframes slideouttobottom{from{-webkit-transform:translateY(0)}to{-webkit-transform:translateY({end})}}@-moz-keyframes slideouttobottom{from{-moz-transform:translateY(0)}to{-moz-transform:translateY({end})}}@keyframes slideouttobottom{from{transform:translateY(0)}to{transform:translateY({end})}}";function addAnimationClass(classString)
|
8 |
{var style=document.createElement('style');style.type='text/css';style.innerHTML=classString;style.id=prefix+"-effect-custom-style";document.getElementsByTagName('head')[0].appendChild(style);}
|
2 |
{var integrations=config.integrations;var popupName=config.popupName;var initialConfig=config;var prefix=config.prefix||'sgpb';var isInited=false;var mainDiv=null;var contentDiv=null;var DIV=null;var opened=false;var resizeTimeout=null;var overlayDiv=null;var defaultZIndex=config.contentBox.zIndex||9999;var defaultWidth="640px";var defaultHeight=config.autoHeight;var closeButtonImage=null;var popupId=config.id;var showOnce=config.showOnce||false;var events=config.events||[];var openDelay=config.openDelay||0;var popupTheme=config.popupTheme;var popupType=config.popupType;var fitBackgroundImg=null;var openAnimation=config.openAnimation||{type:"none",speed:0};var closeAnimation=config.closeAnimation||{type:"none",speed:0};var closeBehavior=config.closeBehavior||{allowed:true,showButton:true,buttonPosition:'topLeft',buttonInside:true,autoclose:false,overlayShouldClose:true,contentShouldClose:false,escShouldClose:true};var closeButton=config.closeButton||{data:sgpbPublicUrl+'img/close.png',width:16,height:16,widthType:'px',heightType:'px',closeButtonType:'IMG',closeButtonText:'Close'};var overlay=config.overlay||{visible:true,color:"#000",opacity:0.7};var contentBox=config.contentBox||{padding:8,showBackground:true,backgroundColor:"#fff",borderStyle:"solid",borderColor:"#ccc",borderRadius:config.contentBox.borderRadius,borderRadiusType:config.contentBox.borderRadiusType,borderWidth:1,shadowColor:"#ccc",shadowSpread:0,shadowBlur:10,scrollingEnabled:true,backgroundPosition:''};var contents=config.contents||"";var inline=config.inline||false;var href=config.href||false;var position=config.position||{left:"center",top:"center"};if((typeof position.left=="undefined"||(isNaN(parseInt(position.left))&&position.left!="center"))&&(typeof position.right=="undefined"||(isNaN(parseInt(position.right))&&position.right!="center"))){position.left="center";}
|
3 |
if((typeof position.top=="undefined"||(isNaN(parseInt(position.top))&&position.top!="center"))&&(typeof position.bottom=="undefined"||(isNaN(parseInt(position.bottom))&&position.bottom!="center"))){position.top="center";}
|
4 |
var sizingRanges=config.sizingRanges||[{screenFrom:{width:-1,height:-1},screenTo:{width:-1,height:-1},width:defaultWidth,height:defaultHeight,maxWidth:-1,maxHeight:-1,minWidth:-1,minHeight:-1}];var shouldOpen=config.shouldOpen||function(){return true;};var willOpen=config.willOpen||function(){};var didOpen=config.didOpen||function(){};var shouldClose=config.shouldClose||function(){return true;};var willClose=config.willClose||function(){};var didClose=config.didClose||function(){};SGPopup.inlinePrevTarget=SGPopup.inlinePrevTarget||{};function resetInlineContent()
|
5 |
+
{if(inline){var htmlElement=document.getElementById(inline);if(SGPopup.inlinePrevTarget.hasPreviousElement){if(typeof SGPopup.inlinePrevTarget.parentNode!='undefined'){SGPopup.inlinePrevTarget.parentNode.insertBefore(htmlElement,SGPopup.inlinePrevTarget.node.nextSibling);}}
|
6 |
else{SGPopup.inlinePrevTarget.node.appendChild(htmlElement);}}}
|
7 |
var OPEN_ANIMATION_POP="@-webkit-keyframes popin{from{-webkit-transform:scale(.8);opacity:0}to{-webkit-transform:scale(1);opacity:1}}@-moz-keyframes popin{from{-moz-transform:scale(.8);opacity:0}to{-moz-transform:scale(1);opacity:1}}@keyframes popin{from{transform:scale(.8);opacity:0}to{transform:scale(1);opacity:1}}";var OPEN_ANIMATION_FADE="@-webkit-keyframes fadein{from{opacity:0}to{opacity:1}}@-moz-keyframes fadein{from{opacity:0}to{opacity:1}}@keyframes fadein{from{opacity:0}to{opacity:1}}";var OPEN_ANIMATION_FLIP="@-webkit-keyframes flipintoright{from{-webkit-transform:rotateY(90deg) scale(.9)}to{-webkit-transform:rotateY(0)}}@-moz-keyframes flipintoright{from{-moz-transform:rotateY(90deg) scale(.9)}to{-moz-transform:rotateY(0)}}@keyframes flipintoright{from{transform:rotateY(90deg) scale(.9)}to{transform:rotateY(0)}}";var OPEN_ANIMATION_SLIDELEFT="@-webkit-keyframes slideinfromright{from{-webkit-transform:translate3d({start},0,0)}to{-webkit-transform:translate3d(0,0,0)}}@-moz-keyframes slideinfromright{from{-moz-transform:translateX({start})}to{-moz-transform:translateX(0)}}@keyframes slideinfromright{from{transform:translateX({start})}to{transform:translateX(0)}}";var OPEN_ANIMATION_SLIDERIGHT="@-webkit-keyframes slideinfromleft{from{-webkit-transform:translate3d({start},0,0)}to{-webkit-transform:translate3d(0,0,0)}}@-moz-keyframes slideinfromleft{from{-moz-transform:translateX({start})}to{-moz-transform:translateX(0)}}@keyframes slideinfromleft{from{transform:translateX({start})}to{transform:translateX(0)}}";var OPEN_ANIMATION_FLOW="@-webkit-keyframes flowinfromright{0%{-webkit-transform:translateX(100%) scale(.7)}30%,40%{-webkit-transform:translateX(0) scale(.7)}100%{-webkit-transform:translateX(0) scale(1)}}@-moz-keyframes flowinfromright{0%{-moz-transform:translateX(100%) scale(.7)}30%,40%{-moz-transform:translateX(0) scale(.7)}100%{-moz-transform:translateX(0) scale(1)}}@keyframes flowinfromright{0%{transform:translateX(100%) scale(.7)}30%,40%{transform:translateX(0) scale(.7)}100%{transform:translateX(0) scale(1)}}";var OPEN_ANIMATION_SLIDEUP="@-webkit-keyframes slideinfrombottom{from{-webkit-transform:translateY({start})}to{-webkit-transform:translateY(0)}}@-moz-keyframes slideinfrombottom{from{-moz-transform:translateY({start})}to{-moz-transform:translateY(0)}}@keyframes slideinfrombottom{from{transform:translateY({start})}to{transform:translateY(0)}}";var OPEN_ANIMATION_SLIDEDOWN="@-webkit-keyframes slideinfromtop{from{-webkit-transform:translateY({start})}to{-webkit-transform:translateY(0)}}@-moz-keyframes slideinfromtop{from{-moz-transform:translateY({start})}to{-moz-transform:translateY(0)}}@keyframes slideinfromtop{from{transform:translateY({start})}to{transform:translateY(0)}}";var CLOSE_ANIMATION_SLIDELEFT="@-webkit-keyframes slideouttoleft{from{-webkit-transform:translate3d(0,0,0)}to{-webkit-transform:translate3d({end},0,0)}}@-moz-keyframes slideouttoleft{from{-moz-transform:translateX(0)}to{-moz-transform:translateX({end})}}@keyframes slideouttoleft{from{transform:translateX(0)}to{transform:translateX({end})}}";var CLOSE_ANIMATION_SLIDERIGHT="@-webkit-keyframes slideouttoright{from{-webkit-transform:translate3d(0,0,0)}to{-webkit-transform:translate3d({end},0,0)}}@-moz-keyframes slideouttoright{from{-moz-transform:translateX(0)}to{-moz-transform:translateX({end})}}@keyframes slideouttoright{from{transform:translateX(0)}to{transform:translateX({end})}}";var CLOSE_ANIMATION_POP="@-webkit-keyframes popout{from{-webkit-transform:scale(1);opacity:1}to{-webkit-transform:scale(.8);opacity:0}}@-moz-keyframes popout{from{-moz-transform:scale(1);opacity:1}to{-moz-transform:scale(.8);opacity:0}}@keyframes popout{from{transform:scale(1);opacity:1}to{transform:scale(.8);opacity:0}}";var CLOSE_ANIMATION_FADE="@-webkit-keyframes fadeout{from{opacity:1}to{opacity:0}}@-moz-keyframes fadeout{from{opacity:1}to{opacity:0}}@keyframes fadeout{from{opacity:1}to{opacity:0}}";var CLOSE_ANIMATION_FLIP="@-webkit-keyframes flipouttoright{from{-webkit-transform:rotateY(0)}to{-webkit-transform:rotateY(90deg) scale(.9)}}@-moz-keyframes flipouttoright{from{-moz-transform:rotateY(0)}to{-moz-transform:rotateY(90deg) scale(.9)}}@keyframes flipouttoright{from{transform:rotateY(0)}to{transform:rotateY(90deg) scale(.9)}}";var CLOSE_ANIMATION_FLOW="@-webkit-keyframes flowouttoright{0%{-webkit-transform:translateX(0) scale(1)}60%,70%{-webkit-transform:translateX(0) scale(.7)}100%{-webkit-transform:translateX(100%) scale(.7)}}@-moz-keyframes flowouttoright{0%{-moz-transform:translateX(0) scale(1)}60%,70%{-moz-transform:translateX(0) scale(.7)}100%{-moz-transform:translateX(100%) scale(.7)}}@keyframes flowouttoright{0%{transform:translateX(0) scale(1)}60%,70%{transform:translateX(0) scale(.7)}100%{transform:translateX(100%) scale(.7)}}";var CLOSE_ANIMATION_SLIDEUP="@-webkit-keyframes slideouttotop{from{-webkit-transform:translateY(0)}to{-webkit-transform:translateY({end})}}@-moz-keyframes slideouttotop{from{-moz-transform:translateY(0)}to{-moz-transform:translateY({end})}}@keyframes slideouttotop{from{transform:translateY(0)}to{transform:translateY({end})}}";var CLOSE_ANIMATION_SLIDEDOWN="@-webkit-keyframes slideouttobottom{from{-webkit-transform:translateY(0)}to{-webkit-transform:translateY({end})}}@-moz-keyframes slideouttobottom{from{-moz-transform:translateY(0)}to{-moz-transform:translateY({end})}}@keyframes slideouttobottom{from{transform:translateY(0)}to{transform:translateY({end})}}";function addAnimationClass(classString)
|
8 |
{var style=document.createElement('style');style.type='text/css';style.innerHTML=classString;style.id=prefix+"-effect-custom-style";document.getElementsByTagName('head')[0].appendChild(style);}
|
public/js/PopupBuilder.js
CHANGED
@@ -1773,7 +1773,7 @@ SGPBPopup.setCookie = function(cName, cValue, exDays, cPageLevel)
|
|
1773 |
}
|
1774 |
|
1775 |
expirationDate.setDate(parseInt(expirationDate.getDate() + parseInt(exDays)));
|
1776 |
-
cookieExpirationData = expirationDate.
|
1777 |
var expires = 'expires='+cookieExpirationData;
|
1778 |
|
1779 |
if (exDays == -1) {
|
1773 |
}
|
1774 |
|
1775 |
expirationDate.setDate(parseInt(expirationDate.getDate() + parseInt(exDays)));
|
1776 |
+
cookieExpirationData = expirationDate.toUTCString();
|
1777 |
var expires = 'expires='+cookieExpirationData;
|
1778 |
|
1779 |
if (exDays == -1) {
|
public/views/conditionsView.php
CHANGED
@@ -1,27 +1,18 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
$
|
5 |
-
$popupTargetData = ConditionBuilder::createConditionBuilder($targetData);
|
6 |
-
$conditionsCanBeUsed = PopupBuilderActivePackage::canUseSection('popupConditionsSection');
|
7 |
?>
|
8 |
|
9 |
-
<div class="
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
?>
|
14 |
-
</div>
|
15 |
-
|
16 |
-
|
17 |
-
<?php if (!$conditionsCanBeUsed): ?>
|
18 |
-
<div class="sgpb-other-pro-options">
|
19 |
-
<div class="sgpb-wrapper">
|
20 |
-
<div class="row">
|
21 |
-
<div class="col-md-12">
|
22 |
-
<style type="text/css">.popup-conditions-wrapper.popup-conditions-conditions .select2-container {z-index: 0;}</style>
|
23 |
-
</div>
|
24 |
-
</div>
|
25 |
</div>
|
26 |
</div>
|
27 |
-
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
use sgpb\AdminHelper;
|
3 |
+
$defaultData = ConfigDataHelper::defaultData();
|
4 |
+
$defaultConditions = $defaultData['freeConditions'];
|
|
|
|
|
5 |
?>
|
6 |
|
7 |
+
<div class="sgpb-wrapper">
|
8 |
+
<div class="row">
|
9 |
+
<div class="col-md-4">
|
10 |
+
<label><?php _e('Select conditions', SG_POPUP_TEXT_DOMAIN);?></label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
</div>
|
12 |
</div>
|
13 |
+
<div class="row form-group">
|
14 |
+
<div class="col-md-3">
|
15 |
+
<?php echo AdminHelper::createSelectBox($defaultConditions, '', array('class' => 'js-sg-select2')); ?>
|
16 |
+
</div>
|
17 |
+
</div>
|
18 |
+
</div>
|
public/views/importSettingsView.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
use sgpb\AdminHelper;
|
3 |
+
$defaultData = ConfigDataHelper::defaultData();
|
4 |
+
|
5 |
+
$deleteData = '';
|
6 |
+
if (get_option('sgpb-dont-delete-data')) {
|
7 |
+
$deleteData = 'checked';
|
8 |
+
}
|
9 |
+
|
10 |
+
$userSavedRoles = get_option('sgpb-user-roles');
|
11 |
+
?>
|
12 |
+
<div class="sgpb-wrapper sgpb-settings">
|
13 |
+
<div class="col-md-6">
|
14 |
+
<div id="post-body" class="metabox-holder columns-2">
|
15 |
+
<div id="postbox-container-2" class="postbox-container">
|
16 |
+
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
17 |
+
<div class="postbox popup-builder-special-postbox">
|
18 |
+
<div class="handlediv js-special-title" title="Click to toggle"><br></div>
|
19 |
+
<h3 class="hndle ui-sortable-handle js-special-title">
|
20 |
+
<span><?php _e('Import popups', SG_POPUP_TEXT_DOMAIN); ?></span>
|
21 |
+
</h3>
|
22 |
+
<div class="sgpb-options-content">
|
23 |
+
<div class="sgpb-import-wrapper">
|
24 |
+
<?php
|
25 |
+
wp_import_upload_form('admin.php?import='.SG_POPUP_POST_TYPE.'&step=1');
|
26 |
+
?>
|
27 |
+
</div>
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
</div>
|
public/views/mainActionButtons.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
use sgpb\AdminHelper;
|
3 |
+
?>
|
4 |
+
<div class="sgpb-wrapp">
|
5 |
+
<h1 class="wp-heading-inline"><?php _e('Popups', SG_POPUP_TEXT_DOMAIN)?></h1>
|
6 |
+
<a href="<?php echo AdminHelper::getPopupTypesPageURL(); ?>" class="page-title-action">
|
7 |
+
<?php _e('Add New', SG_POPUP_TEXT_DOMAIN); ?>
|
8 |
+
</a>
|
9 |
+
<a href="<?php echo AdminHelper::getPopupExportURL(); ?>" class="page-title-action">
|
10 |
+
<?php _e('Export', SG_POPUP_TEXT_DOMAIN); ?>
|
11 |
+
</a>
|
12 |
+
<a href="<?php echo AdminHelper::getSettingsURL(array('sgpbImport' => 1)); ?>" class="page-title-action">
|
13 |
+
<?php _e( 'Import', 'easy-digital-downloads' ); ?>
|
14 |
+
</a>
|
15 |
+
</div>
|
16 |
+
<style>
|
17 |
+
#wpbody-content > div.wrap > h1,
|
18 |
+
#wpbody-content > div.wrap > a {
|
19 |
+
display: none !important;
|
20 |
+
}
|
21 |
+
</style>
|
public/views/settings.php
CHANGED
@@ -1,63 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
4 |
|
5 |
-
$deleteData = '';
|
6 |
-
if (get_option('sgpb-dont-delete-data')) {
|
7 |
-
$deleteData = 'checked';
|
8 |
-
}
|
9 |
|
10 |
-
$userSavedRoles = get_option('sgpb-user-roles');
|
11 |
-
?>
|
12 |
-
<div class="sgpb-wrapper sgpb-settings">
|
13 |
-
<div class="col-md-6">
|
14 |
-
<div id="post-body" class="metabox-holder columns-2">
|
15 |
-
<div id="postbox-container-2" class="postbox-container">
|
16 |
-
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
17 |
-
<div class="postbox popup-builder-special-postbox">
|
18 |
-
<div class="handlediv js-special-title" title="Click to toggle"><br></div>
|
19 |
-
<h3 class="hndle ui-sortable-handle js-special-title">
|
20 |
-
<span><?php _e('General Settings', SG_POPUP_TEXT_DOMAIN); ?></span>
|
21 |
-
</h3>
|
22 |
-
<div class="sgpb-options-content">
|
23 |
-
<form method="POST" action="<?php echo admin_url().'admin-post.php?action=sgpbSaveSettings'?>">
|
24 |
-
<div class="row form-group">
|
25 |
-
<div class="col-md-4 sgpb-static-padding-top">
|
26 |
-
<label for="sgpb-dont-delete-data"><?php _e('Delete popup data', SG_POPUP_TEXT_DOMAIN)?></label>
|
27 |
-
</div>
|
28 |
-
<div class="col-md-6">
|
29 |
-
<input type="checkbox" name="sgpb-dont-delete-data" class="sgpb-reset-checkbox-margin-top" id="sgpb-dont-delete-data" <?php echo $deleteData; ?>>
|
30 |
-
<span class="dashicons dashicons-editor-help sgpb-info-icon"></span>
|
31 |
-
<span class="infoSelectRepeat samefontStyle sgpb-info-text">
|
32 |
-
<?php _e('All the popup data will be deleted after removing the plugin if this option is checked', SG_POPUP_TEXT_DOMAIN)?>.
|
33 |
-
</span>
|
34 |
-
</div>
|
35 |
-
</div>
|
36 |
-
<div class="row form-group">
|
37 |
-
<div class="col-md-4 sgpb-label-align-with-select2">
|
38 |
-
<label><?php _e('User role to access the plugin', SG_POPUP_TEXT_DOMAIN)?></label>
|
39 |
-
</div>
|
40 |
-
<div class="col-md-6">
|
41 |
-
<?php echo AdminHelper::createSelectBox($defaultData['userRoles'], $userSavedRoles, array('name'=>'sgpb-user-roles[]', 'class' => 'js-sg-select2 schedule-start-selectbox sg-margin0', 'multiple'=> 'multiple', 'size'=> count($defaultData['userRoles'])));?>
|
42 |
-
</div>
|
43 |
-
<div class="col-md-1">
|
44 |
-
<span class="dashicons dashicons-editor-help sgpb-info-icon sgpb-info-icon-align"></span>
|
45 |
-
<span class="infoSelectRepeat samefontStyle sgpb-info-text">
|
46 |
-
<?php _e('In spite of user roles the administrator always has access to the plugin', SG_POPUP_TEXT_DOMAIN)?>.
|
47 |
-
</span>
|
48 |
-
</div>
|
49 |
-
</div>
|
50 |
-
<div class="row form-group">
|
51 |
-
<div class="col-md-12">
|
52 |
-
<input type="submit" value="<?php _e('Save Changes', SG_POPUP_TEXT_DOMAIN)?>" class="button-primary">
|
53 |
-
</div>
|
54 |
-
</div>
|
55 |
-
</form>
|
56 |
-
</div>
|
57 |
-
</div>
|
58 |
-
</div>
|
59 |
-
</div>
|
60 |
-
</div>
|
61 |
-
</div>
|
62 |
-
<div class="col-md-6"></div>
|
63 |
-
</div>
|
1 |
+
<?php if (!empty($_GET['sgpbImport'])): ?>
|
2 |
+
<?php require_once(SG_POPUP_VIEWS_PATH.'importSettingsView.php'); ?>
|
3 |
+
<?php else: ?>
|
4 |
+
<?php require_once(SG_POPUP_VIEWS_PATH.'settingsOptions.php'); ?>
|
5 |
+
<?php endif;?>
|
6 |
+
|
7 |
|
|
|
|
|
|
|
|
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/views/settingsOptions.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
use sgpb\AdminHelper;
|
3 |
+
$defaultData = ConfigDataHelper::defaultData();
|
4 |
+
|
5 |
+
$deleteData = '';
|
6 |
+
if (get_option('sgpb-dont-delete-data')) {
|
7 |
+
$deleteData = 'checked';
|
8 |
+
}
|
9 |
+
|
10 |
+
$userSavedRoles = get_option('sgpb-user-roles');
|
11 |
+
?>
|
12 |
+
|
13 |
+
<div class="sgpb-wrapper sgpb-settings">
|
14 |
+
<div class="col-md-6">
|
15 |
+
<div id="post-body" class="metabox-holder columns-2">
|
16 |
+
<div id="postbox-container-2" class="postbox-container">
|
17 |
+
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
18 |
+
<div class="postbox popup-builder-special-postbox">
|
19 |
+
<div class="handlediv js-special-title" title="Click to toggle"><br></div>
|
20 |
+
<h3 class="hndle ui-sortable-handle js-special-title">
|
21 |
+
<span><?php _e('General Settings', SG_POPUP_TEXT_DOMAIN); ?></span>
|
22 |
+
</h3>
|
23 |
+
<div class="sgpb-options-content">
|
24 |
+
<form method="POST" action="<?php echo admin_url().'admin-post.php?action=sgpbSaveSettings'?>">
|
25 |
+
<div class="row form-group">
|
26 |
+
<div class="col-md-4 sgpb-static-padding-top">
|
27 |
+
<label for="sgpb-dont-delete-data"><?php _e('Delete popup data', SG_POPUP_TEXT_DOMAIN)?></label>
|
28 |
+
</div>
|
29 |
+
<div class="col-md-6">
|
30 |
+
<input type="checkbox" name="sgpb-dont-delete-data" class="sgpb-reset-checkbox-margin-top" id="sgpb-dont-delete-data" <?php echo $deleteData; ?>>
|
31 |
+
<span class="dashicons dashicons-editor-help sgpb-info-icon"></span>
|
32 |
+
<span class="infoSelectRepeat samefontStyle sgpb-info-text">
|
33 |
+
<?php _e('All the popup data will be deleted after removing the plugin if this option is checked', SG_POPUP_TEXT_DOMAIN)?>.
|
34 |
+
</span>
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
<div class="row form-group">
|
38 |
+
<div class="col-md-4 sgpb-label-align-with-select2">
|
39 |
+
<label><?php _e('User role to access the plugin', SG_POPUP_TEXT_DOMAIN)?></label>
|
40 |
+
</div>
|
41 |
+
<div class="col-md-6">
|
42 |
+
<?php echo AdminHelper::createSelectBox($defaultData['userRoles'], $userSavedRoles, array('name'=>'sgpb-user-roles[]', 'class' => 'js-sg-select2 schedule-start-selectbox sg-margin0', 'multiple'=> 'multiple', 'size'=> count($defaultData['userRoles'])));?>
|
43 |
+
</div>
|
44 |
+
<div class="col-md-1">
|
45 |
+
<span class="dashicons dashicons-editor-help sgpb-info-icon sgpb-info-icon-align"></span>
|
46 |
+
<span class="infoSelectRepeat samefontStyle sgpb-info-text">
|
47 |
+
<?php _e('In spite of user roles the administrator always has access to the plugin', SG_POPUP_TEXT_DOMAIN)?>.
|
48 |
+
</span>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
<div class="row form-group">
|
52 |
+
<div class="col-md-12">
|
53 |
+
<input type="submit" value="<?php _e('Save Changes', SG_POPUP_TEXT_DOMAIN)?>" class="button-primary">
|
54 |
+
</div>
|
55 |
+
</div>
|
56 |
+
</form>
|
57 |
+
</div>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
</div>
|
61 |
+
</div>
|
62 |
+
</div>
|
63 |
+
<div class="col-md-6"></div>
|
64 |
+
</div>
|
65 |
+
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: popup, pop up, wordpress popup, popup maker, exit popup, popup builder, wo
|
|
7 |
Requires at least: 3.8
|
8 |
Tested up to: 5.0
|
9 |
Requires PHP: 5.3.3
|
10 |
-
Stable tag: 3.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -174,6 +174,12 @@ Go to the Popup Builder settings and set your desired options.
|
|
174 |
|
175 |
== Changelog ==
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
= Version 3.0.9.1 =
|
178 |
* Deafult values added for conditions section.
|
179 |
* Media button dublicate localization removed.
|
@@ -869,7 +875,7 @@ Leave us a good review :)
|
|
869 |
|
870 |
== Upgrade Notice ==
|
871 |
|
872 |
-
Current Version of Popup Builder is 3.
|
873 |
|
874 |
== Other Notes ==
|
875 |
|
7 |
Requires at least: 3.8
|
8 |
Tested up to: 5.0
|
9 |
Requires PHP: 5.3.3
|
10 |
+
Stable tag: 3.1
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
174 |
|
175 |
== Changelog ==
|
176 |
|
177 |
+
= Version 3.1 =
|
178 |
+
* Bug fixed related to cookie saving for Safari and Internet Explorer.
|
179 |
+
* Add new option to show categories for WooCommerce product(s).
|
180 |
+
* Bug fixed related to 'unsubscribe' link.
|
181 |
+
* Code improvements and minor bug fixes.
|
182 |
+
|
183 |
= Version 3.0.9.1 =
|
184 |
* Deafult values added for conditions section.
|
185 |
* Media button dublicate localization removed.
|
875 |
|
876 |
== Upgrade Notice ==
|
877 |
|
878 |
+
Current Version of Popup Builder is 3.1
|
879 |
|
880 |
== Other Notes ==
|
881 |
|