{"id":51776,"date":"2016-10-28T00:53:32","date_gmt":"2016-10-28T00:53:32","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/theme-demo-import\/"},"modified":"2024-07-03T11:04:54","modified_gmt":"2024-07-03T11:04:54","slug":"theme-demo-import","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/theme-demo-import\/","author":14624414,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.1.3","stable_tag":"trunk","tested":"6.5.8","requires":"4.7","requires_php":"5.6","requires_plugins":null,"header_name":"Theme Demo Import","header_author":"Themely","header_description":"","assets_banners_color":"3e92de","last_updated":"2024-07-03 11:04:54","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/wordpress.org\/plugins\/theme-demo-import\/","header_author_uri":"https:\/\/www.themely.com","rating":3,"author_block_rating":0,"active_installs":5000,"downloads":258825,"num_ratings":4,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":2,"2":0,"3":0,"4":0,"5":2},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":1523494,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":1523494,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":1523494,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.png":{"filename":"banner-772x250.png","revision":1523494,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[529,3524,3258,87,241],"plugin_category":[43,59],"plugin_contributors":[125624],"plugin_business_model":[],"class_list":["post-51776","plugin","type-plugin","status-publish","hentry","plugin_tags-content","plugin_tags-data","plugin_tags-demo","plugin_tags-import","plugin_tags-widgets","plugin_category-customization","plugin_category-utilities-and-tools","plugin_contributors-themely","plugin_committers-themely"],"banners":{"banner":"https:\/\/ps.w.org\/theme-demo-import\/assets\/banner-772x250.png?rev=1523494","banner_2x":"https:\/\/ps.w.org\/theme-demo-import\/assets\/banner-1544x500.png?rev=1523494","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/theme-demo-import\/assets\/icon-128x128.png?rev=1523494","icon_2x":"https:\/\/ps.w.org\/theme-demo-import\/assets\/icon-256x256.png?rev=1523494","generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Quickly import demo content, widgets and settings for your new theme. This provides a basic layout to build your website and speed up the development process.<\/p>\n\n<p>This plugin will create a page in <strong>APPEARANCE &gt; Import Demo Content<\/strong>.<\/p>\n\n<p>If the theme you are using does not have any predefined import files, then you will be presented with three file upload inputs.<\/p>\n\n<p>First one is required and you will have to upload a demo content XML file, for the actual demo import.<\/p>\n\n<p>The second one is optional and will ask you for a WIE or JSON file for widgets import. You create that file using the <a href=\"https:\/\/wordpress.org\/plugins\/widget-importer-exporter\/\">Widget Importer &amp; Exporter<\/a> plugin.<\/p>\n\n<p>The third one is also optional and will import the customizer settings, select the DAT file which you can generate from <a href=\"https:\/\/wordpress.org\/plugins\/customizer-export-import\/\">Customizer Export\/Import<\/a> plugin (the customizer settings will be imported only if the export file was created from the same theme).<\/p>\n\n<p>This plugin is based off the 'One Click Demo Import' plugin by @capuderg and @cyman, https:\/\/github.com\/proteusthemes\/one-click-demo-import.<\/p>\n\n<p>As well as the improved WP Import 2.0 plugin by @humanmade, https:\/\/github.com\/humanmade\/WordPress-Importer.<\/p>\n\n<h3>License<\/h3>\n\n<p>Theme Demo Import uses 'One Click Demo Import' plugin script\nhttps:\/\/github.com\/proteusthemes\/one-click-demo-import\n(C) 2016 ProteusThemes.com\nLicensed under the GNU General Public License v2.0,\nhttp:\/\/www.gnu.org\/licenses\/gpl-2.0.html<\/p>\n\n<p>Theme Demo Import uses 'Wordpress Importer' plugin script\nhttps:\/\/github.com\/humanmade\/WordPress-Importer\n(C) 2016 @humanmade\nLicensed under the GNU General Public License v2.0,\nhttp:\/\/www.gnu.org\/licenses\/gpl-2.0.html<\/p>\n\n<h3>Copyright<\/h3>\n\n<p>Theme Demo Import, Copyright 2016 Ishmael 'Hans' Desjarlais<\/p>\n\n<p>Theme Demo Import is distributed under the terms of the GNU GPL<\/p>\n\n<p>This program is free software; you can redistribute it and\/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 2 of the License, or\n(at your option) any later version.<\/p>\n\n<p>This program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.<\/p>\n\n<p>You should have received a copy of the GNU General Public License along\nwith this program; if not, write to the Free Software Foundation, Inc.,\n51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<\/p>\n\n<!--section=installation-->\n<p><strong>From your WordPress dashboard<\/strong><\/p>\n\n<ol>\n<li>Visit 'Plugins &gt; Add New',<\/li>\n<li>Search for 'Theme Demo Import' and install the plugin.<\/li>\n<li>Activate 'Theme Demo Import' from your Plugins page.<\/li>\n<\/ol>\n\n<p>Once the plugin is activated you will find the actual import page in <strong>Appearance -&gt; Import Demo Content.<\/strong><\/p>\n\n<!--section=faq-->\n<dl>\n<dt id='i%20have%20activated%20the%20plugin.%20where%20is%20the%20%22import%20demo%20content%22%20page%3F'><h3>I have activated the plugin. Where is the \"Import Demo Content\" page?<\/h3><\/dt>\n<dd><p>You will find the import page in <em>wp-admin -&gt; Appearance -&gt; Import Demo Content<\/em>.<\/p><\/dd>\n<dt id='where%20are%20the%20demo%20import%20files%20and%20the%20log%20files%20saved%3F'><h3>Where are the demo import files and the log files saved?<\/h3><\/dt>\n<dd><p>The files used in the demo import will be saved to the default WordPress uploads directory. An example of that directory would be: <code>..\/wp-content\/uploads\/2016\/03\/<\/code>.<\/p>\n\n<p>The log file will also be registered in the <em>wp-admin -&gt; Media<\/em> section, so you can access it easily.<\/p><\/dd>\n<dt id='how%20to%20predefine%20demo%20imports%3F'><h3>How to predefine demo imports?<\/h3><\/dt>\n<dd><p>This question is for theme authors. To predefine demo imports, you just have to add the following code structure, with your own values to your theme (using the <code>theme-demo-import\/import_files<\/code> filter):<\/p>\n\n<pre><code>function TDI_import_files() {\n    return array(\n        array(\n            'import_file_name'           =&gt; 'Demo Import 1',\n            'import_file_url'            =&gt; 'http:\/\/www.your_domain.com\/tdi\/demo-content.xml',\n            'import_widget_file_url'     =&gt; 'http:\/\/www.your_domain.com\/tdi\/widgets.json',\n            'import_customizer_file_url' =&gt; 'http:\/\/www.your_domain.com\/tdi\/customizer.dat',\n            'import_preview_image_url'   =&gt; 'http:\/\/www.your_domain.com\/tdi\/preview_import_image1.jpg',\n            'import_notice'              =&gt; __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ),\n        ),\n        array(\n            'import_file_name'           =&gt; 'Demo Import 2',\n            'import_file_url'            =&gt; 'http:\/\/www.your_domain.com\/tdi\/demo-content2.xml',\n            'import_widget_file_url'     =&gt; 'http:\/\/www.your_domain.com\/tdi\/widgets2.json',\n            'import_customizer_file_url' =&gt; 'http:\/\/www.your_domain.com\/tdi\/customizer2.dat',\n            'import_preview_image_url'   =&gt; 'http:\/\/www.your_domain.com\/tdi\/preview_import_image2.jpg',\n            'import_notice'              =&gt; __( 'A special note for this import.', 'your-textdomain' ),\n        ),\n    );\n}\nadd_filter( 'theme-demo-import\/import_files', 'TDI_import_files' );\n<\/code><\/pre>\n\n<p>You can set content import, widgets, and customizer import files. You can also define a preview image, which will be used only when multiple demo imports are defined, so that the user will see the difference between imports.<\/p><\/dd>\n<dt id='how%20to%20automatically%20assign%20%22front%20page%22%2C%20%22posts%20page%22%20and%20menu%20locations%20after%20the%20importer%20is%20done%3F'><h3>How to automatically assign \"Front page\", \"Posts page\" and menu locations after the importer is done?<\/h3><\/dt>\n<dd><p>You can do that, with the <code>theme-demo-import\/after_import<\/code> action hook. The code would look something like this:<\/p>\n\n<pre><code>function TDI_after_import_setup() {\n    \/\/ Assign menus to their locations.\n    $main_menu = get_term_by( 'name', 'Top Menu', 'nav_menu' );\n\n    set_theme_mod( 'nav_menu_locations', array(\n            'primary-menu' =&gt; $main_menu-&gt;term_id,\n        )\n    );\n\n    \/\/ Assign front page and posts page (blog page).\n    $front_page_id = get_page_by_title( 'Home' );\n    $blog_page_id  = get_page_by_title( 'Blog' );\n\n    update_option( 'show_on_front', 'page' );\n    update_option( 'page_on_front', $front_page_id-&gt;ID );\n    update_option( 'page_for_posts', $blog_page_id-&gt;ID );\n\n}\nadd_action( 'theme-demo-import\/after_import', 'TDI_after_import_setup' );\n<\/code><\/pre><\/dd>\n<dt id='what%20about%20using%20local%20import%20files%20%28from%20theme%20folder%29%3F'><h3>What about using local import files (from theme folder)?<\/h3><\/dt>\n<dd><p>You have to use the same filter as in above example, but with a slightly different array keys: <code>local_*<\/code>. The values have to be absolute paths (not URLs) to your import files. To use local import files, that reside in your theme folder, please use the below code. Note: make sure your import files are readable!<\/p>\n\n<pre><code>function TDI_import_files() {\n    return array(\n        array(\n            'import_file_name'             =&gt; 'Demo Import 1',\n            'local_import_file'            =&gt; trailingslashit( get_template_directory() ) . 'tdi\/demo-content.xml',\n            'local_import_widget_file'     =&gt; trailingslashit( get_template_directory() ) . 'tdi\/widgets.json',\n            'local_import_customizer_file' =&gt; trailingslashit( get_template_directory() ) . 'tdi\/customizer.dat',\n            'import_preview_image_url'     =&gt; 'http:\/\/www.your_domain.com\/tdi\/preview_import_image1.jpg',\n            'import_notice'                =&gt; __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ),\n        ),\n        array(\n            'import_file_name'             =&gt; 'Demo Import 2',\n            'local_import_file'            =&gt; trailingslashit( get_template_directory() ) . 'tdi\/demo-content2.xml',\n            'local_import_widget_file'     =&gt; trailingslashit( get_template_directory() ) . 'tdi\/widgets2.json',\n            'local_import_customizer_file' =&gt; trailingslashit( get_template_directory() ) . 'tdi\/customizer2.dat',\n            'import_preview_image_url'     =&gt; 'http:\/\/www.your_domain.com\/tdi\/preview_import_image2.jpg',\n            'import_notice'                =&gt; __( 'A special note for this import.', 'your-textdomain' ),\n        ),\n    );\n}\nadd_filter( 'theme-demo-import\/import_files', 'TDI_import_files' );\n<\/code><\/pre><\/dd>\n<dt id='how%20to%20handle%20different%20%22after%20import%20setups%22%20depending%20on%20which%20predefined%20import%20was%20selected%3F'><h3>How to handle different \"after import setups\" depending on which predefined import was selected?<\/h3><\/dt>\n<dd><p>This question might be asked by a theme author wanting to implement different after import setups for multiple predefined demo imports. Lets say we have predefined two demo imports with the following names: 'Demo Import 1' and 'Demo Import 2', the code for after import setup would be (using the <code>theme-demo-import\/after_import<\/code> filter):<\/p>\n\n<pre><code>function TDI_after_import( $selected_import ) {\n    echo \"This will be displayed on all after imports!\";\n\n    if ( 'Demo Import 1' === $selected_import['import_file_name'] ) {\n        echo \"This will be displayed only on after import if user selects Demo Import 1\";\n\n        \/\/ Set logo in customizer\n        set_theme_mod( 'logo_img', get_template_directory_uri() . '\/assets\/images\/logo1.png' );\n    }\n    elseif ( 'Demo Import 2' === $selected_import['import_file_name'] ) {\n        echo \"This will be displayed only on after import if user selects Demo Import 2\";\n\n        \/\/ Set logo in customizer\n        set_theme_mod( 'logo_img', get_template_directory_uri() . '\/assets\/images\/logo2.png' );\n    }\n}\nadd_action( 'theme-demo-import\/after_import', 'TDI_after_import' );\n<\/code><\/pre><\/dd>\n<dt id='can%20i%20add%20some%20code%20before%20the%20widgets%20get%20imported%3F'><h3>Can I add some code before the widgets get imported?<\/h3><\/dt>\n<dd><p>Of course you can, use the <code>theme-demo-import\/before_widgets_import<\/code> action. You can also target different predefined demo imports like in the example above. Here is a simple example code of the <code>theme-demo-import\/before_widgets_import<\/code> action:<\/p>\n\n<pre><code>function TDI_before_widgets_import( $selected_import ) {\n    echo \"Add your code here that will be executed before the widgets get imported!\";\n}\nadd_action( 'theme-demo-import\/before_widgets_import', 'TDI_before_widgets_import' );\n<\/code><\/pre><\/dd>\n<dt id='i%27m%20a%20theme%20author%20and%20i%20want%20to%20change%20the%20plugin%20intro%20text%2C%20how%20can%20i%20do%20that%3F'><h3>I'm a theme author and I want to change the plugin intro text, how can I do that?<\/h3><\/dt>\n<dd><p>You can change the plugin intro text by using the <code>theme-demo-import\/plugin_intro_text<\/code> filter:<\/p>\n\n<pre><code>function TDI_plugin_intro_text( $default_text ) {\n    $default_text .= '&lt;div class=\"TDI__intro-text\"&gt;This is a custom text added to this plugin intro text.&lt;\/div&gt;';\n\n    return $default_text;\n}\nadd_filter( 'theme-demo-import\/plugin_intro_text', 'TDI_plugin_intro_text' );\n<\/code><\/pre>\n\n<p>To add some text in a separate \"box\", you should wrap your text in a div with a class of 'TDI__intro-text', like in the code example above.<\/p><\/dd>\n<dt id='how%20to%20disable%20generation%20of%20smaller%20images%20%28thumbnails%29%20during%20the%20content%20import'><h3>How to disable generation of smaller images (thumbnails) during the content import<\/h3><\/dt>\n<dd><p>This will greatly improve the time needed to import the content (images), but only the original sized images will be imported. You can disable it with a filter, so just add this code to your theme function.php file:<\/p>\n\n<pre><code>add_filter( 'theme-demo-import\/regenerate_thumbnails_in_content_import', '__return_false' );\n<\/code><\/pre><\/dd>\n<dt id='how%20to%20change%20the%20location%2C%20title%20and%20other%20parameters%20of%20the%20plugin%20page%3F'><h3>How to change the location, title and other parameters of the plugin page?<\/h3><\/dt>\n<dd><p>As a theme author you do not like the location of the \"Import Demo Content\" plugin page in <em>Appearance -&gt; Import Demo Content<\/em>? You can change that with the filter below. Apart from the location, you can also change the title or the page\/menu and some other parameters as well.<\/p>\n\n<pre><code>function TDI_plugin_page_setup( $default_settings ) {\n    $default_settings['parent_slug'] = 'themes.php';\n    $default_settings['page_title']  = esc_html__( 'Theme Demo Import' , 'theme-demo-import' );\n    $default_settings['menu_title']  = esc_html__( 'Import Demo Content' , 'theme-demo-import' );\n    $default_settings['capability']  = 'import';\n    $default_settings['menu_slug']   = 'theme-demo-import';\n\n    return $default_settings;\n}\nadd_filter( 'theme-demo-import\/plugin_page_setup', 'TDI_plugin_page_setup' );\n<\/code><\/pre><\/dd>\n<dt id='i%20can%27t%20activate%20the%20plugin%2C%20because%20of%20a%20fatal%20error%2C%20what%20can%20i%20do%3F'><h3>I can't activate the plugin, because of a fatal error, what can I do?<\/h3><\/dt>\n<dd><p><em>Update: There is now a admin error notice, stating that the minimal PHP version required for this plugin is 5.3.2.<\/em><\/p>\n\n<p>You want to activate the plugin, but this error shows up:<\/p>\n\n<p><em>Plugin could not be activated because it triggered a fatal error<\/em><\/p>\n\n<p>This happens, because your hosting server is using a very old version of PHP. This plugin requires PHP version of at least <strong>5.3.x<\/strong>, but we recommend version <em>5.6.x<\/em>. Please contact your hosting company and ask them to update the PHP version for your site.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<p><strong>1.1.1 - November 2nd, 2022<\/strong><\/p>\n\n<ul>\n<li>SECURITY FIX: Prevent uploading PHP files<\/li>\n<\/ul>\n\n<p><strong>1.0.5 - March 29, 2019<\/strong><\/p>\n\n<ul>\n<li>Removed extra $ on line 72 of class-tdi-helpers.php which was triggering a PHP 7.0+ error<\/li>\n<\/ul>\n\n<p><strong>1.0.2 - 10\/25\/2016<\/strong><\/p>\n\n<ul>\n<li>Removed dependencies on 3rd party plugin<\/li>\n<li>Renamed classes for HM files<\/li>\n<li>Added license and copyright information to readme.txt file<\/li>\n<li>Updated the plugin description<\/li>\n<\/ul>\n\n<p><strong>1.0.1 - 10\/15\/2016<\/strong><\/p>\n\n<ul>\n<li>Updated text strings<\/li>\n<li>Updated styles (UI)<\/li>\n<li>Removed unnecessary code<\/li>\n<\/ul>\n\n<p><strong>1.0.0 - 10\/10\/2016<\/strong><\/p>\n\n<ul>\n<li>INITIAL RELEASE<\/li>\n<\/ul>\n\n<p><strong>1.1.2 - 06\/24\/2024<\/strong><\/p>\n\n<ul>\n<li>Added stricter accept attributes in file upload inputs in \/inc\/class-tdi-main.php (lines 155, 160 and 165)<\/li>\n<li>Added pattern attribute to file upload inputs in \/inc\/class-tdi-main.php (lines 155, 160 and 165)<\/li>\n<\/ul>\n\n<p><strong>1.1.3 - 07\/3\/2024<\/strong>\n- Security: Improved file upload validation for widget imports.\n- Security: Added server-side checks for file types, MIME types, and file sizes.\n- Enhancement: Improved error handling and logging in AJAX file uploads.\n- Enhancement: Added more detailed console logging for easier debugging.\n- Performance: Optimized AJAX handling for smoother file uploads.<\/p>","raw_excerpt":"Quickly import demo content, widgets and settings in one click. Made for theme authors to simplify importing demo content for their users.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/51776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=51776"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/themely"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=51776"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=51776"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=51776"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=51776"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=51776"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=51776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}