Plugin Directory

Changeset 3366451


Ignore:
Timestamp:
09/23/2025 12:14:53 PM (5 months ago)
Author:
slickplan
Message:

Fixes v.2.5

Location:
slickplan-importer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • slickplan-importer/trunk/readme.txt

    r3251226 r3366451  
    88License: GPL-3.0
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     10
     11The Slickplan import plugin allows you to quickly import your Slickplan projects into your WordPress site.
     12
     13== Description ==
    1014
    1115The Slickplan import plugin allows you to quickly import your Slickplan projects into your WordPress site.
     
    2327== Changelog ==
    2428
     29= 2.5 =
     30* New: Support for new meta fields and featured image import
     31
    2532= 2.4 =
    26 * New: Added per-page mapping
     33* New: Per-page mapping
    2734
    2835= 2.3 =
    29 * New: Added custom posts types mapping
     36* New: Custom post type mapping
    3037
    3138= 2.2 =
    32 * New: Added basic support for Gutenberg
     39* New: Basic support for Gutenberg
    3340* New: Dropped support for PHP 5
    34 * Fix: Non-recognizable files in Content Planner upload blocks with "multiple" option enabled
     41* Fix: Unrecognized files in Content Planner upload blocks with the "multiple" option enabled
    3542
    3643= 2.1.3 =
     
    3845
    3946= 2.1.2 =
    40 * Fix: Non-recognizable XML file when section ID is missing
     47* Fix: Unrecognized XML file when section ID is missing
    4148
    4249= 2.1.1 =
    43 * Fix: Import content blocks in correct order, fixed file download bug
     50* Fix: Import content blocks in the correct order
     51* Fix: File download bug
    4452
    4553= 2.1 =
    46 * New: Added support for internal links when importing content
    47 * New: Added an information about approx total files size to "import files" option
     54* New: Support for internal links when importing content
     55* New: Approximate total file size information added to the "import files" option
    4856* Fix: Don't use AJAX importer when importing content from notes
    49 * Fix: Hide "import files" option when there is no files to import
     57* Fix: Hide the "import files" option when there are no files to import
    5058
    5159= 2.0 =
    52 * New: Import is now a 2 steps process - import options have been moved to Step 2
    53 * New: Added Content Planner support - plugin now can import page content, SEO meta and download files to media library
    54 * Fix: Dropped the PHP's libxml extension requirement, plugin now requires DOMElement which is default PHP5 extension
     60* New: Import is now a 2-step process — import options have been moved to Step 2
     61* New: Content Planner support — plugin can now import page content, SEO meta, and download files to the media library
     62* Fix: Dropped the PHP libxml extension requirement; plugin now requires DOMElement, which is a default PHP 5 extension
    5563
    5664= 1.2 =
    57 * New: Automatically add currect page order attribute
     65* New: Automatically add correct page order attribute
    5866
    5967= 1.1 =
     
    6573= 1.0 =
    6674* New: Options to manipulate page titles prior to import
    67 * Fix: updated styling to suit WordPress 3.8
     75* Fix: Updated styling to match WordPress 3.8
    6876
    6977= 0.4 =
     
    7482
    7583= 0.2 =
    76 * New: Import notes as pages contents
     84* New: Import notes as page content
    7785* New: Import footer section items
    7886
  • slickplan-importer/trunk/slickplan.php

    r3364102 r3366451  
    6666    class Slickplan_Importer extends WP_Importer
    6767    {
    68         public $pages = [];
    69         public $pagesIds = [];
    70 
    71         /**
    72          * Menu order increment.
    73          *
    74          * @var int
    75          */
    76         private $_order = 0;
    77 
    78         /**
    79          * An array of import options.
    80          *
    81          * @var array
    82          */
    83         private $_options = [];
    84 
    85         /**
    86          * An array of imported pages or errors.
    87          *
    88          * @var array
    89          */
    90         private $_summary = [];
    91 
    92         /**
    93          * An array of imported files
    94          *
    95          * @var array
    96          */
    97         private $_files = [];
    98 
    99         /**
    100          * If page has unparsed internal pages
    101          *
    102          * @var bool
    103          */
    104         private $_has_unparsed_internal_links = false;
    105 
    106         /**
    107          * @var WP_oEmbed
    108          */
    109         private $_wp_oembed = null;
    110 
    111         /**
    112          * @var string
    113          */
    114         private $_temp_file = null;
    115 
    116         private $_postTypes = [];
    117         private $_sectionsMap = [];
     68        public array $pages = [];
     69        public array $pagesIds = [];
     70
     71        private int $_order = 0;
     72        private array $_options = [];
     73        private array $_summary = [];
     74        private array $_files = [];
     75        private bool $_has_unparsed_internal_links = false;
     76        private ?WP_oEmbed $_wp_oembed = null;
     77        private ?string $_temp_file = null;
     78        private array $_postTypes = [];
     79        private array $_sectionsMap = [];
    11880
    11981        public function __construct()
     
    13092        }
    13193
    132         /**
    133          * Importer page routing.
    134          */
    13594        public function dispatch()
    13695        {
     
    175134        }
    176135
    177         /**
    178          * Handle file upload and prepare to import pages.
    179          */
    180136        public function handleFileUpload()
    181137        {
     
    200156        }
    201157
    202         /**
    203          * Get HTML of a summary row
    204          *
    205          * @param  array  $page
    206          * @return string
    207          */
    208158        public function getSummaryRow(array $page = [], array $form = []): string
    209159        {
     
    245195        }
    246196
    247         /**
    248          * AJAX import action
    249          *
    250          * @param array $form
    251          * @return array
    252          */
    253197        public function ajaxImport(array $form): array
    254198        {
     
    287231        }
    288232
    289         /**
    290          * Get admin URL.
    291          *
    292          * @param  string|null  $step
    293          * @return string
    294          */
    295         private function _getAdminUrl(string $step = null): string
     233        private function _getAdminUrl(?string $step = null): string
    296234        {
    297235            $url = 'admin.php?import=' . SLICKPLAN_PLUGIN_ID;
     
    514452        }
    515453
    516         /**
    517          * Display AJAX import page.
    518          */
    519454        private function _doImport(array $xml)
    520455        {
     
    543478                'content' => $form['content'] ?? '',
    544479                'content_lang' => $form['content_lang'] ?? '',
    545                 'content_files' => (
    546                     isset($form['content'], $form['content_files'])
    547                     and $form['content'] === 'contents'
    548                     and $form['content_files']
    549                 ),
     480                'content_files' => (($form['content'] ?? '') === 'contents' && ($form['content_files'] ?? '')),
    550481                'create_menu' => (isset($form['create_menu']) and $form['create_menu']),
    551482                'post_type' => $form['page_type'] ?? 'page',
     
    702633                        'menu-item-status' => 'publish',
    703634                        'menu-item-parent-id' => $menu_parent,
    704                     ]
    705                     );
     635                    ]);
    706636                }
    707637
     
    710640                // All In One SEO Pack integration
    711641                $this->_importPageAioSeo($data['contents'], $page['ID']);
     642
     643                if (
     644                    ($featuredImage = $data['contents']['meta_featured_image'] ?? null)
     645                    && filter_var($featuredImage['url'] ?? '', FILTER_VALIDATE_URL)
     646                ) {
     647                    $file = $this->_addMedia($featuredImage['url'], [
     648                        'alt' => $featuredImage['alt'] ?? '',
     649                        'title' => $featuredImage['title'] ?? '',
     650                        'file_name' => $featuredImage['file_name'] ?? '',
     651                    ], true);
     652                    if ($file['id'] ?? null) {
     653                        set_post_thumbnail($page['ID'], $file['id']);
     654                    }
     655                }
    712656
    713657                $page['url'] = get_permalink($page['ID']);
     
    802746        }
    803747
    804         /**
    805          * Replace internal links with correct pages URLs.
    806          *
    807          * @param $content
    808          * @param  bool  $force_parse
    809          * @return bool|string
    810          */
    811748        private function _parseInternalLinks($content, bool $force_parse = false)
    812749        {
     
    835772        }
    836773
    837         /**
    838          * Check if there are any pages with unparsed internal links, if yes - replace links with real URLs
    839          */
    840         private function _checkForInternalLinks()
     774        private function _checkForInternalLinks(): void
    841775        {
    842776            if (isset($this->_options['internal_links']) and is_array($this->_options['internal_links'])) {
     
    856790        }
    857791
    858         /**
    859          * @param array $element
    860          * @return array
    861          */
    862792        private function _getPrependAppend(array $element): array
    863793        {
     
    875805                    }
    876806                    $tag = preg_replace('/[^a-z]+/', '', $tag);
    877                     $prepend = '<'.$tag;
     807                    $prepend = '<' . $tag;
    878808                    if (isset($element['options']['tag_id']) and $element['options']['tag_id']) {
    879                         $prepend .= ' id="'.esc_attr($element['options']['tag_id']).'"';
     809                        $prepend .= ' id="' . esc_attr($element['options']['tag_id']) . '"';
    880810                    }
    881811                    if (isset($element['options']['tag_class']) and $element['options']['tag_class']) {
    882                         $prepend .= ' class="'.esc_attr($element['options']['tag_class']).'"';
     812                        $prepend .= ' class="' . esc_attr($element['options']['tag_class']) . '"';
    883813                    }
    884814                    $prepend .= '>';
    885                     $append = '</'.$tag.'>';
     815                    $append = '</' . $tag . '>';
    886816                }
    887817            }
     
    889819        }
    890820
    891         /**
    892          * Get formatted HTML content.
    893          *
    894          * @param array|string|int $contents
    895          * @return string
    896          */
    897821        private function _getFormattedContent($contents): string
    898822        {
     
    991915        }
    992916
    993         /**
    994          * @param array $element
    995          * @return array
    996          */
    997917        private function _getMediaElementArray(array $element): array
    998918        {
     
    1003923        }
    1004924
    1005         /**
    1006          * @param array $element
    1007          * @return string
    1008          */
    1009925        private function _getGutenbergBlock(array $element): string
    1010926        {
     
    11671083        }
    11681084
    1169         /**
    1170          * Reformat title.
    1171          *
    1172          * @param array $data
    1173          * @return string
    1174          */
    11751085        private function _getFormattedTitle(array $data): string
    11761086        {
     
    11951105        }
    11961106
    1197         /**
    1198          * Add a file to Media Library from URL
    1199          *
    1200          * @param $url
    1201          * @param  array  $attrs
    1202          * @return array|bool|WP_Error
    1203          */
    1204         private function _addMedia($url, array $attrs = [])
    1205         {
    1206             if (!($this->_options['content_files'] ?? null)) {
     1107        private function _addMedia($url, array $attrs = [], bool $forceAdd = false)
     1108        {
     1109            if (!($this->_options['content_files'] ?? null) && !$forceAdd) {
    12071110                return false;
    12081111            }
     
    12541157        }
    12551158
    1256         /**
    1257          * Display importer errors.
    1258          *
    1259          * @param array|string $errors
    1260          */
    12611159        private function _displayError($errors)
    12621160        {
     
    12711169        }
    12721170
    1273         /**
    1274          * Display importer HTML form.
    1275          *
    1276          * @param  bool  $hide_info
    1277          */
    12781171        private function _displayUploadForm(bool $hide_info = false)
    12791172        {
     
    13101203        }
    13111204
    1312         /**
    1313          * Display importer page header HTML.
    1314          */
    13151205        private function _displayHeader()
    13161206        {
     
    13221212        }
    13231213
    1324         /**
    1325          * Display importer page footer HTML.
    1326          */
    13271214        private function _displayFooter()
    13281215        {
     
    13651252        }
    13661253
    1367         /**
    1368          * Display checkbox.
    1369          *
    1370          * @param $name
    1371          * @param  string  $label
    1372          * @param  bool  $checked
    1373          * @param  string|array  $description
    1374          * @param  string|int  $value
    1375          * @param  string  $type
    1376          * @param  string  $class
    1377          * @return string
    1378          */
    13791254        public function displayCheckbox(
    13801255            $name,
     
    14151290        }
    14161291
    1417         /**
    1418          * Display radio element.
    1419          *
    1420          * @param $name
    1421          * @param  string  $label
    1422          * @param  string|int  $value
    1423          * @param  string|array  $description
    1424          * @param  bool  $checked
    1425          * @param  string  $class
    1426          * @return string
    1427          */
    14281292        public function displayRadio(
    14291293            $name,
     
    14371301        }
    14381302
    1439         /**
    1440          * Display dropdown element with users.
    1441          *
    1442          * @param $name
    1443          */
    14441303        public function displayUsersDropdown($name, $selected = '')
    14451304        {
     
    14501309        }
    14511310
    1452         /**
    1453          * Display dropdown element with users.
    1454          */
    14551311        public function displayPageTypesDropdown($name = null, $includeManually = false, $label = 'Import as', $singularName = false, $value = null)
    14561312        {
     
    15071363        }
    15081364
    1509         /**
    1510          * Parse Slickplan's XML file. Converts an XML DOMDocument to an array.
    1511          *
    1512          * @param  string  $input_xml
    1513          * @return WP_Error|array
    1514          */
    15151365        private function _parseSlickplanXml(string $input_xml)
    15161366        {
     
    15771427        }
    15781428
    1579         /**
    1580          * Parse single node XML element.
    1581          *
    1582          * @param DOMElement|DOMNode $node
    1583          * @return array|string
    1584          */
    15851429        private function _parseSlickplanXmlNode($node)
    15861430        {
     
    16361480        }
    16371481
    1638         /**
    1639          * Check if the array is from a correct Slickplan XML file.
    1640          *
    1641          * @param  array  $array
    1642          * @param  bool  $parsed
    1643          * @return bool
    1644          */
    16451482        private function _isCorrectSlickplanXmlFile(array $array, bool $parsed = false): bool
    16461483        {
     
    17161553        }
    17171554
    1718         /**
    1719          * Get multidimensional array, put all child pages as nested array of the parent page.
    1720          *
    1721          * @param array $array
    1722          * @return array
    1723          */
    17241555        private function _getMultidimensionalArrayHelper(array $array): array
    17251556        {
     
    18051636        }
    18061637
    1807         /**
    1808          * @param array $cell
    1809          * @return string
    1810          */
    18111638        private function _getCellLevel(array $cell): string
    18121639        {
     
    18241651        }
    18251652
    1826         /**
    1827          * Put all child pages as nested array of the parent page.
    1828          *
    1829          * @param array $array
    1830          * @param  string  $parent
    1831          * @return array
    1832          */
    18331653        private function _getMultidimensionalArray(array $array, string $parent): array
    18341654        {
     
    18501670        }
    18511671
    1852         /**
    1853          * Sort cells.
    1854          *
    1855          * @param array $a
    1856          * @param array $b
    1857          * @return int
    1858          */
    18591672        private function _sortPages(array $a, array $b): int
    18601673        {
     
    18651678        }
    18661679
    1867         /**
    1868          * Change the WordPress language
    1869          *
    1870          * @param  string  $language
    1871          */
    18721680        private function _changeLanguage(string $language)
    18731681        {
     
    18901698        }
    18911699
    1892 
    1893         /**
    1894          * @param $title
    1895          * @param string $type
    1896          *
    1897          * @return string
    1898          */
    18991700        private function _metaTitle($title, string $type = 'yoast'): string
    19001701        {
     
    19071708        }
    19081709
    1909         /**
    1910          * @param string|int $slug
    1911          * @param string|int $pageName
    1912          *
    1913          * @return string
    1914          */
    19151710        private function _metaSlug($slug, $pageName): string
    19161711        {
     
    19181713            $slug = str_replace('%page_name%', $pageName, $slug);
    19191714            $slug = str_replace('%separator%', '-', $slug);
     1715
    19201716            return $slug ? sanitize_title($slug) : '';
    19211717        }
     
    19451741        }
    19461742
    1947         /**
    1948          * @return bool
    1949          */
    19501743        private function shouldUseGutenberg(): bool
    19511744        {
     
    20191812    }
    20201813
    2021     /**
    2022      * AJAX action
    2023      */
    20241814    function slickplan_importer_ajax_action()
    20251815    {
Note: See TracChangeset for help on using the changeset viewer.