44 changes: 22 additions & 22 deletions plugins/cm4all-wp-impex/inc/impex-import-extension-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ function _import_posts(array $options, array $slice, array $author_mapping, arra
// => skip post import
$comment_post_id = $post_exists;
$post_id = $post_exists;
$processed_posts[intval($post[ContentExporter::SLICE_DATA_POSTS_ID])] = intval($post_exists);
$processed_posts[(int)$post[ContentExporter::SLICE_DATA_POSTS_ID]] = (int)$post_exists;
} else {
$post_parent = (int) $post[ContentExporter::SLICE_DATA_POSTS_PARENT];
if ($post_parent) {
if ($post_parent !== 0) {
// if we already know the parent, map it to the new local ID
if (isset($processed_posts[$post_parent])) {
$post_parent = $processed_posts[$post_parent];
// otherwise record the parent for later
} else {
$post_orphans[intval($post['post_id'])] = $post_parent;
$post_orphans[(int)$post['post_id']] = $post_parent;
$featured_images = [];
$post_parent = 0;
}
Expand Down Expand Up @@ -244,7 +244,7 @@ function _import_posts(array $options, array $slice, array $author_mapping, arra
}

// map pre-import ID to local ID
$processed_posts[intval($post[ContentExporter::SLICE_DATA_POSTS_ID])] = (int) $post_id;
$processed_posts[(int)$post[ContentExporter::SLICE_DATA_POSTS_ID]] = (int) $post_id;

$post[ContentExporter::SLICE_DATA_POSTS_TAXONOMY_TERMS] ??= [];

Expand All @@ -270,7 +270,7 @@ function _import_posts(array $options, array $slice, array $author_mapping, arra
);
}
}
$terms_to_set[$taxonomy][] = intval($term_id);
$terms_to_set[$taxonomy][] = (int)$term_id;
}

foreach ($terms_to_set as $tax => $ids) {
Expand Down Expand Up @@ -353,8 +353,8 @@ function _import_posts(array $options, array $slice, array $author_mapping, arra
$value = false;

if ('_edit_last' == $key) {
if (isset($processed_authors[intval(ContentExporter::SLICE_DATA_TERMS_META_VALUE)])) {
$value = $processed_authors[intval(ContentExporter::SLICE_DATA_TERMS_META_VALUE)];
if (isset($processed_authors[(int)ContentExporter::SLICE_DATA_TERMS_META_VALUE])) {
$value = $processed_authors[(int)ContentExporter::SLICE_DATA_TERMS_META_VALUE];
} else {
$key = false;
}
Expand Down Expand Up @@ -439,20 +439,20 @@ function _process_menu_item($item, array $processed_terms, array $processed_post
${$meta[ContentExporter::SLICE_DATA_TERMS_META_KEY]} = $meta[ContentExporter::SLICE_DATA_TERMS_META_VALUE];
}

if ('taxonomy' == $_menu_item_type && isset($processed_terms[intval($_menu_item_object_id)])) {
$_menu_item_object_id = $processed_terms[intval($_menu_item_object_id)];
} elseif ('post_type' == $_menu_item_type && isset($processed_posts[intval($_menu_item_object_id)])) {
$_menu_item_object_id = $processed_posts[intval($_menu_item_object_id)];
if ('taxonomy' == $_menu_item_type && isset($processed_terms[(int)$_menu_item_object_id])) {
$_menu_item_object_id = $processed_terms[(int)$_menu_item_object_id];
} elseif ('post_type' == $_menu_item_type && isset($processed_posts[(int)$_menu_item_object_id])) {
$_menu_item_object_id = $processed_posts[(int)$_menu_item_object_id];
} elseif ('custom' != $_menu_item_type) {
// associated object is missing or not imported yet, we'll retry later
$missing_menu_items[] = $item;
return;
}

if (isset($processed_menu_items[intval($_menu_item_menu_item_parent)])) {
$_menu_item_menu_item_parent = $processed_menu_items[intval($_menu_item_menu_item_parent)];
if (isset($processed_menu_items[(int)$_menu_item_menu_item_parent])) {
$_menu_item_menu_item_parent = $processed_menu_items[(int)$_menu_item_menu_item_parent];
} elseif ($_menu_item_menu_item_parent) {
$menu_item_orphans[intval($item['post_id'])] = (int) $_menu_item_menu_item_parent;
$menu_item_orphans[(int)$item['post_id']] = (int) $_menu_item_menu_item_parent;
$_menu_item_menu_item_parent = 0;
}

Expand All @@ -466,7 +466,7 @@ function _process_menu_item($item, array $processed_terms, array $processed_post
'menu-item-object-id' => $_menu_item_object_id,
'menu-item-object' => $_menu_item_object,
'menu-item-parent-id' => $_menu_item_menu_item_parent,
'menu-item-position' => intval($item[ContentExporter::SLICE_DATA_POSTS_MENU_ORDER]),
'menu-item-position' => (int)$item[ContentExporter::SLICE_DATA_POSTS_MENU_ORDER],
'menu-item-type' => $_menu_item_type,
'menu-item-title' => $item[ContentExporter::SLICE_DATA_POSTS_TITLE],
'menu-item-url' => $_menu_item_url,
Expand All @@ -480,7 +480,7 @@ function _process_menu_item($item, array $processed_terms, array $processed_post

$id = \wp_update_nav_menu_item($menu_id, 0, $args);
if ($id && !is_wp_error($id)) {
$processed_menu_items[intval($item[ContentExporter::SLICE_DATA_POSTS_ID])] = (int) $id;
$processed_menu_items[(int)$item[ContentExporter::SLICE_DATA_POSTS_ID]] = (int) $id;
}

return [$missing_menu_items, $processed_menu_items, $menu_item_orphans];
Expand Down Expand Up @@ -523,7 +523,7 @@ function _import_tags(array $options, array $slice): array
$term_id = $term_id['term_id'];
}
if (isset($tag[ContentExporter::SLICE_DATA_TERMS_ID])) {
$processed_terms[intval($tag[ContentExporter::SLICE_DATA_TERMS_ID])] = (int)$term_id;
$processed_terms[(int)$tag[ContentExporter::SLICE_DATA_TERMS_ID]] = (int)$term_id;
}
continue;
}
Expand All @@ -537,7 +537,7 @@ function _import_tags(array $options, array $slice): array
$term_id = \wp_insert_term(\wp_slash($tag[ContentExporter::SLICE_DATA_TERMS_NAME]), 'post_tag', $args);
if (!is_wp_error($term_id)) {
if (isset($tag[ContentExporter::SLICE_DATA_TERMS_ID])) {
$processed_terms[intval($tag[ContentExporter::SLICE_DATA_TERMS_ID])] = $term_id['term_id'];
$processed_terms[(int)$tag[ContentExporter::SLICE_DATA_TERMS_ID]] = $term_id['term_id'];
}
} else {
throw new ImpexImportRuntimeException("Failed to create term(tag_name==='{$tag[ContentExporter::SLICE_DATA_TERMS_NAME]}') : {$term_id->get_error_message()}");
Expand Down Expand Up @@ -566,7 +566,7 @@ function _import_terms(array $options, array $slice): array
$term_id = $term_id['term_id'];
}
if (isset($term[ContentExporter::SLICE_DATA_TERMS_ID])) {
$processed_terms[intval($term[ContentExporter::SLICE_DATA_TERMS_ID])] = (int) $term_id;
$processed_terms[(int)$term[ContentExporter::SLICE_DATA_TERMS_ID]] = (int) $term_id;
}
continue;
}
Expand All @@ -590,7 +590,7 @@ function _import_terms(array $options, array $slice): array
$term_id = wp_insert_term(wp_slash($term[ContentExporter::SLICE_DATA_TERMS_NAME]), $term[ContentExporter::SLICE_DATA_TERMS_TAXONOMY], $args);
if (!is_wp_error($term_id)) {
if (isset($term[ContentExporter::SLICE_DATA_TERMS_ID])) {
$processed_terms[intval($term[ContentExporter::SLICE_DATA_TERMS_ID])] = $term_id['term_id'];
$processed_terms[(int)$term[ContentExporter::SLICE_DATA_TERMS_ID]] = $term_id['term_id'];
}
} else {
throw new ImpexImportRuntimeException("Failed to create term(term_name==='{$term[ContentExporter::SLICE_DATA_TERMS_NAME]}') : {$term_id->get_error_message()}");
Expand Down Expand Up @@ -620,7 +620,7 @@ function _import_categories(array $options, array $slice): array
$term_id = $term_id['term_id'];
}
if (isset($category[ContentExporter::SLICE_DATA_TERMS_ID])) {
$processed_terms[intval($category[ContentExporter::SLICE_DATA_TERMS_ID])] = (int)$term_id;
$processed_terms[(int)$category[ContentExporter::SLICE_DATA_TERMS_ID]] = (int)$term_id;
}
continue;
}
Expand All @@ -639,7 +639,7 @@ function _import_categories(array $options, array $slice): array

if (!\is_wp_error($category_id) && $category_id > 0) {
if (isset($category[ContentExporter::SLICE_DATA_TERMS_ID])) {
$processed_terms[intval($category[ContentExporter::SLICE_DATA_TERMS_ID])] = $category_id;
$processed_terms[(int)$category[ContentExporter::SLICE_DATA_TERMS_ID]] = $category_id;
}
} else {
throw new ImpexImportRuntimeException("Failed to create category(category_nicename==='{$category['category_nicename']}') : {$category_id->get_error_message()}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function __DbTableImportProviderCallback(array $slice, array $options, ImpexImpo
* @var callable $log
*/
$log = function (string $message, mixed $context = null) use ($options) {
isset($options[Impex::OPTION_LOG]) && call_user_func($options[Impex::OPTION_LOG], $message, $context);
if (isset($options[Impex::OPTION_LOG])) {
call_user_func($options[Impex::OPTION_LOG], $message, $context);
}
};

$slice_meta = $slice[Impex::SLICE_META];
Expand Down Expand Up @@ -127,7 +129,7 @@ function __DbTableImportProviderCallback(array $slice, array $options, ImpexImpo
$rows = $slice[Impex::SLICE_DATA];

// TODO: implement optimized in-db-copy procedure when special option provided
if (count($rows)) {
if (count($rows) > 0) {
$table_column_names = implode('`, `', array_keys((array)$rows[0]));

/*
Expand Down
4 changes: 2 additions & 2 deletions plugins/cm4all-wp-impex/languages/cm4all-wp-impex-en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: cm4all-wp-impex 1.0.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cm4all-wp-impex\n"
"POT-Creation-Date: 2022-01-25T12:37:45+00:00\n"
"POT-Creation-Date: 2022-02-03T11:06:24+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -20,7 +20,7 @@ msgid "cm4all-wp-impex"
msgstr ""

#. Plugin URI of the plugin
msgid "http://dev.intern.cm-ag/trinity/research/cm4all-wp-impex"
msgid "https://github.com/IONOS-WordPress/cm4all-wp-impex"
msgstr ""

#. Description of the plugin
Expand Down
8 changes: 3 additions & 5 deletions plugins/cm4all-wp-impex/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/**
* Plugin Name: cm4all-wp-impex
* Plugin URI: http://dev.intern.cm-ag/trinity/research/cm4all-wp-impex
* Plugin URI: https://github.com/IONOS-WordPress/cm4all-wp-impex
* Description: Impex contributes extendable Import / Export functionality to WordPress
* Version: 1.1.0
* Version: 1.1.1
* Tags: import, export, migration
* Requires PHP: 8.0
* Requires at least: 5.7
Expand Down Expand Up @@ -182,9 +182,7 @@ function ($client_asset_handle, $in_footer) {

\add_action(
'init',
function () {
\load_plugin_textdomain('cm4all-wp-impex', false, basename(__DIR__) . '/languages/');
},
fn () => \load_plugin_textdomain('cm4all-wp-impex', false, basename(__DIR__) . '/languages/'),
);

\add_action(Impex::WP_ACTION_REGISTER_PROFILES, function () {
Expand Down
14 changes: 12 additions & 2 deletions plugins/cm4all-wp-impex/readme.txt.template
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ Impex provides :

* Impex is explicitly designed for use in managed Wordpress instances

* Impex development relies heavily on PHP unit testing its feature sset to be stable and consistent.
* Impex development relies heavily on PHP unit testing its feature set to be stable and consistent.

**Your help is welcome !!**

== Frequently Asked Questions ==

= Where can I find the Impex documentation ? =

Documentation is in a very early stage and is not yet complete.

It's available at the [Impex Plugin GitHub pages](https://ionos-wordpress.github.io/cm4all-wp-impex/)

Please file bugs and feature requests at the [Impex Plugin GitHub issues](https://github.com/IONOS-WordPress/cm4all-wp-impex/issues)

= Why is that Plugin written in PHP 8 ? =

Because PHP 8
Expand All @@ -53,7 +61,9 @@ Because PHP 8

* allows a much cleaner PHP code

=> We will investigate into transpiling the Plugin to PHP 7.4 in the future.
The Plugin version available here (at Wordpress plugin directory) is transpiled down to PHP 7.4

If you prefer to use the PHP 8 version, you can download it from the [GitHub Impex plugin repository](https://github.com/IONOS-WordPress/cm4all-wp-impex)

= Whats the current feature set ? =

Expand Down
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);

// Define what rule sets will be applied
// $containerConfigurator->import(SetList::CODE_QUALITY);
$containerConfigurator->import(DowngradeLevelSetList::DOWN_TO_PHP_80);
$containerConfigurator->import(DowngradeSetList::PHP_80);

Expand Down
2 changes: 2 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module.exports = {
{
prepareCmd:
"sed -i 's/Version:\\(.*\\)/Version: ${nextRelease.version}/' plugins/*/plugin.php && make dist",
publishCmd:
"SVN_TAG='${nextRelease.version}' SVN_USERNAME='${process.env.SVN_USERNAME}' SVN_PASSWORD='${process.env.SVN_PASSWORD}' make deploy-to-wordpress",
},
],
[
Expand Down