Plugin nebyl testován na 3 nejnovějších verzích WordPressu. Nemusí už být tedy podporován a u novějších verzí WordPressu může mít problémy s kompatibilitou a může být nestabilní.

Import ukázkového obsahu

Popis

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.

Tento plugin vytvoří stránku v Appearance -> Import Demo Content..

Pokud šablona, kterou používáte, nemá žádné předdefinované soubory pro import, zobrazí se vám tři vstupy pro nahrávání souborů.

První z nich je vyžadován a budete muset nahrát soubor XML s ukázkovým obsahem pro skutečný import ukázky.

Druhý je nepovinný a požádá vás o soubor WIE nebo JSON pro import widgetů. Tento soubor vytvoříte pomocí zásuvného modulu Widget Importer & Exporter.

Třetí je také volitelný a bude importovat nastavení nástroje pro přizpůsobení, vyberte soubor DAT, který můžete vygenerovat z pluginu Customizer Export/Import (nastavení nástroje pro přizpůsobení bude importováno pouze v případě, že byl exportní soubor vytvořen ze stejné šablony).

Tento plugin je založen na pluginu ‚One Click Demo Import‘ od @capuderg a @cyman, https://github.com/proteusthemes/one-click-demo-import.

Stejně jako vylepšený plugin WP Import 2.0 od @humanmade, https://github.com/humanmade/WordPress-Importer.

License

Theme Demo Import používá ‚One Click Demo Import‘ plugin skript
https://github.com/proteusthemes/one-click-demo-import
(C) 2016 ProteusThemes.com
Licencováno pod GNU General Public License v2.0,
http://www.gnu.org/licenses/gpl-2.0.html

Theme Demo Import používá ‚Wordpress Importer‘ plugin skript
https://github.com/humanmade/WordPress-Importer
(C) 2016 @humanmade
Licencováno pod GNU General Public License v2.0,
http://www.gnu.org/licenses/gpl-2.0.html

Autorská práva

Theme Demo Import, Copyright 2016 Ishmael ‚Hans‘ Desjarlais

Theme Demo Import je šířen pod licencí GNU GPL

Tento program je volně šiřitelný software; můžete jej dále šířit a/nebo upravovat.
za podmínek GNU General Public License, jak je zveřejnila společnost
Free Software Foundation; buď verze 2 licence, nebo
(podle vaší volby) jakoukoli pozdější verzi.

Tento program je šířen v naději, že bude užitečný,
ale BEZ JAKÉKOLI ZÁRUKY; dokonce ani bez předpokládané záruky
PRODEJNOSTI nebo VHODNOSTI PRO KONKRÉTNÍ ÚČEL. Viz
GNU General Public License, kde najdete další podrobnosti.

Měli jste obdržet kopii Obecné veřejné licence GNU spolu s dokumentem.
s tímto programem; pokud ne, napište na adresu Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Instalace

Z ovládacího panelu WordPress

  1. Navštivte „Pluginy > Přidat nový“,
  2. Vyhledejte ‚Theme Demo Import‘ a nainstalujte plugin.
  3. Aktivujte ‚Theme Demo Import‘ na stránce Pluginy.

Jakmile je plugin aktivován, najdete aktuální stránku pro import v části Appearance -> Import Demo Content.

Nejčastější dotazy

I have activated the plugin. Where is the „Import Demo Content“ page?

You will find the import page in wp-admin -> Appearance -> Import Demo Content.

Where are the demo import files and the log files saved?

The files used in the demo import will be saved to the default WordPress uploads directory. An example of that directory would be: ../wp-content/uploads/2016/03/.

The log file will also be registered in the wp-admin -> Media section, so you can access it easily.

How to predefine demo imports?

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 theme-demo-import/import_files filter):

function TDI_import_files() {
    return array(
        array(
            'import_file_name'           => 'Demo Import 1',
            'import_file_url'            => 'http://www.your_domain.com/tdi/demo-content.xml',
            'import_widget_file_url'     => 'http://www.your_domain.com/tdi/widgets.json',
            'import_customizer_file_url' => 'http://www.your_domain.com/tdi/customizer.dat',
            'import_preview_image_url'   => 'http://www.your_domain.com/tdi/preview_import_image1.jpg',
            'import_notice'              => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ),
        ),
        array(
            'import_file_name'           => 'Demo Import 2',
            'import_file_url'            => 'http://www.your_domain.com/tdi/demo-content2.xml',
            'import_widget_file_url'     => 'http://www.your_domain.com/tdi/widgets2.json',
            'import_customizer_file_url' => 'http://www.your_domain.com/tdi/customizer2.dat',
            'import_preview_image_url'   => 'http://www.your_domain.com/tdi/preview_import_image2.jpg',
            'import_notice'              => __( 'A special note for this import.', 'your-textdomain' ),
        ),
    );
}
add_filter( 'theme-demo-import/import_files', 'TDI_import_files' );

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.

How to automatically assign „Front page“, „Posts page“ and menu locations after the importer is done?

You can do that, with the theme-demo-import/after_import action hook. The code would look something like this:

function TDI_after_import_setup() {
    // Assign menus to their locations.
    $main_menu = get_term_by( 'name', 'Top Menu', 'nav_menu' );

    set_theme_mod( 'nav_menu_locations', array(
            'primary-menu' => $main_menu->term_id,
        )
    );

    // Assign front page and posts page (blog page).
    $front_page_id = get_page_by_title( 'Home' );
    $blog_page_id  = get_page_by_title( 'Blog' );

    update_option( 'show_on_front', 'page' );
    update_option( 'page_on_front', $front_page_id->ID );
    update_option( 'page_for_posts', $blog_page_id->ID );

}
add_action( 'theme-demo-import/after_import', 'TDI_after_import_setup' );

What about using local import files (from theme folder)?

You have to use the same filter as in above example, but with a slightly different array keys: local_*. 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!

function TDI_import_files() {
    return array(
        array(
            'import_file_name'             => 'Demo Import 1',
            'local_import_file'            => trailingslashit( get_template_directory() ) . 'tdi/demo-content.xml',
            'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'tdi/widgets.json',
            'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'tdi/customizer.dat',
            'import_preview_image_url'     => 'http://www.your_domain.com/tdi/preview_import_image1.jpg',
            'import_notice'                => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ),
        ),
        array(
            'import_file_name'             => 'Demo Import 2',
            'local_import_file'            => trailingslashit( get_template_directory() ) . 'tdi/demo-content2.xml',
            'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'tdi/widgets2.json',
            'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'tdi/customizer2.dat',
            'import_preview_image_url'     => 'http://www.your_domain.com/tdi/preview_import_image2.jpg',
            'import_notice'                => __( 'A special note for this import.', 'your-textdomain' ),
        ),
    );
}
add_filter( 'theme-demo-import/import_files', 'TDI_import_files' );

How to handle different „after import setups“ depending on which predefined import was selected?

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 theme-demo-import/after_import filter):

function TDI_after_import( $selected_import ) {
    echo "This will be displayed on all after imports!";

    if ( 'Demo Import 1' === $selected_import['import_file_name'] ) {
        echo "This will be displayed only on after import if user selects Demo Import 1";

        // Set logo in customizer
        set_theme_mod( 'logo_img', get_template_directory_uri() . '/assets/images/logo1.png' );
    }
    elseif ( 'Demo Import 2' === $selected_import['import_file_name'] ) {
        echo "This will be displayed only on after import if user selects Demo Import 2";

        // Set logo in customizer
        set_theme_mod( 'logo_img', get_template_directory_uri() . '/assets/images/logo2.png' );
    }
}
add_action( 'theme-demo-import/after_import', 'TDI_after_import' );

Can I add some code before the widgets get imported?

Of course you can, use the theme-demo-import/before_widgets_import action. You can also target different predefined demo imports like in the example above. Here is a simple example code of the theme-demo-import/before_widgets_import action:

function TDI_before_widgets_import( $selected_import ) {
    echo "Add your code here that will be executed before the widgets get imported!";
}
add_action( 'theme-demo-import/before_widgets_import', 'TDI_before_widgets_import' );

I’m a theme author and I want to change the plugin intro text, how can I do that?

You can change the plugin intro text by using the theme-demo-import/plugin_intro_text filter:

function TDI_plugin_intro_text( $default_text ) {
    $default_text .= '<div class="TDI__intro-text">This is a custom text added to this plugin intro text.</div>';

    return $default_text;
}
add_filter( 'theme-demo-import/plugin_intro_text', 'TDI_plugin_intro_text' );

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.

How to disable generation of smaller images (thumbnails) during the content import

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:

add_filter( 'theme-demo-import/regenerate_thumbnails_in_content_import', '__return_false' );

How to change the location, title and other parameters of the plugin page?

As a theme author you do not like the location of the „Import Demo Content“ plugin page in Appearance -> Import Demo Content? 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.

function TDI_plugin_page_setup( $default_settings ) {
    $default_settings['parent_slug'] = 'themes.php';
    $default_settings['page_title']  = esc_html__( 'Theme Demo Import' , 'theme-demo-import' );
    $default_settings['menu_title']  = esc_html__( 'Import Demo Content' , 'theme-demo-import' );
    $default_settings['capability']  = 'import';
    $default_settings['menu_slug']   = 'theme-demo-import';

    return $default_settings;
}
add_filter( 'theme-demo-import/plugin_page_setup', 'TDI_plugin_page_setup' );

I can’t activate the plugin, because of a fatal error, what can I do?

Update: There is now a admin error notice, stating that the minimal PHP version required for this plugin is 5.3.2.

You want to activate the plugin, but this error shows up:

Plugin could not be activated because it triggered a fatal error

This happens, because your hosting server is using a very old version of PHP. This plugin requires PHP version of at least 5.3.x, but we recommend version 5.6.x. Please contact your hosting company and ask them to update the PHP version for your site.

Recenze

20. 8. 2023
I installed the plugin, the site crashed immediately. Error message:Warning: The magic method Theme_Demo_Import::__wakeup() must have public visibility in /yyy/zzz/Local Sites/mega/app/public/wp-content/plugins/theme-demo-import/inc/class-tdi-main.php on line 74 Fatal error: Cannot redeclare get_cli_args() (previously declared in /home/jos/Local Sites/mega/app/public/wp-admin/includes/class-wp-importer.php:276) in /yyy/zzz/Local Sites/mega/app/public/wp-admin/includes/class-wp-importer.php on line 326
2. 11. 2016
We've tested this plugin extensively and packaged it with our themes, it works flawlessly.
Přečtěte si všechny 3 recenze

Autoři

Import ukázkového obsahu je otevřený software. Následující lidé přispěli k vývoji tohoto pluginu.

Spolupracovníci

Plugin „Import ukázkového obsahu“ byl přeložen do 1 jazyku. Děkujeme všem překladatelům za jejich pomoc.

Přeložte “Import ukázkového obsahu” do svého jazyka.

Zajímá vás vývoj?

Prohledejte kód, podívejte se do SVN repozitáře, nebo se přihlaste k odběru protokolu vývoje pomocí RSS.

Přehled změn

1.1.1 – 2. listopadu 2022

  • Oprava zabezpečení: Zabránění nahrávání souborů PHP

1.0.5 – 29. března 2019

  • Odstranění extra $ na řádku 72 souboru class-tdi-helpers.php, které způsobovalo chybu PHP 7.0+.

1.0.2 – 25. 10. 2016

  • Odstranění závislostí na tří zásuvných modulu
  • Přejmenování tříd pro HM soubory
  • Přidání informací o licenci a autorských právech do souboru readme.txt
  • Aktualizovat popis pluginu

1.0.1 – 15. 10. 2016

  • Aktualizované textové řádky
  • Aktualizované styly (UI)
  • Odstranění zbytečného kódu

1.0.0 – 10. 10. 2016

  • PRVNÍ VYDÁNÍ