من افزونه رو فعال کردم صفحه “وارد کردن داده های نمایشی” کجاست؟

شما میتوانید صفحه درون ریزی را در پیشخوان -> ظاهر -> درون ریزی محتواپیدا کنید.

فایلهای وارداتی نسخه ی نمایشی و فایلهای گزارش در کجا ذخیره می شوند؟

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/2023/03/.

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

چگونه می توان واردات نسخه ی نمایشی را از پیش تعریف کرد؟

این سوال برای نویسندگان موضوع است. برای از پیش تعریف واردات نسخه ی نمایشی ، فقط باید ساختار کد زیر را با مقادیر خود به موضوع خود اضافه کنید (با استفاده از فیلتر ocdi/import_files ):

function ocdi_import_files() {
    return array(
        array(
            'import_file_name'           => 'Demo Import 1',
            'categories'                 => array( 'Category 1', 'Category 2' ),
            'import_file_url'            => 'http://www.your_domain.com/ocdi/demo-content.xml',
            'import_widget_file_url'     => 'http://www.your_domain.com/ocdi/widgets.json',
            'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer.dat',
            'import_redux'               => array(
                array(
                    'file_url'    => 'http://www.your_domain.com/ocdi/redux.json',
                    'option_name' => 'redux_option_name',
                ),
            ),
            'import_preview_image_url'   => 'http://www.your_domain.com/ocdi/preview_import_image1.jpg',
            'import_notice'              => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ),
            'preview_url'                => 'http://www.your_domain.com/my-demo-1',
        ),
        array(
            'import_file_name'           => 'Demo Import 2',
            'categories'                 => array( 'New category', 'Old category' ),
            'import_file_url'            => 'http://www.your_domain.com/ocdi/demo-content2.xml',
            'import_widget_file_url'     => 'http://www.your_domain.com/ocdi/widgets2.json',
            'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer2.dat',
            'import_redux'               => array(
                array(
                    'file_url'    => 'http://www.your_domain.com/ocdi/redux.json',
                    'option_name' => 'redux_option_name',
                ),
                array(
                    'file_url'    => 'http://www.your_domain.com/ocdi/redux2.json',
                    'option_name' => 'redux_option_name_2',
                ),
            ),
            'import_preview_image_url'   => 'http://www.your_domain.com/ocdi/preview_import_image2.jpg',
            'import_notice'              => __( 'A special note for this import.', 'your-textdomain' ),
            'preview_url'                => 'http://www.your_domain.com/my-demo-2',
        ),
    );
}
add_filter( 'ocdi/import_files', 'ocdi_import_files' );

می توانید درون ریزی محتوا ، ابزارک ها ، سفارشی ساز و فایل های درون ریزی چارچوب Redux را تنظیم کنید. همچنین می توانید یک تصویر پیش نمایش تعریف کنید ، که فقط در صورت تعریف چندین درون ریزی نمایشی استفاده می شود ، به طوری که کاربر تفاوت بین درون ریزی را مشاهده می کند. دسته ها را می توان به هر درون ریزی نسخه ی نمایشی اختصاص داد ، به طوری که می توان آنها را به راحتی فیلتر کرد.آدرس اینترنتی پیش نمایش دکمه “‌‌‌‌‌پیشنمایش “‌ را در مورد نسخه ی نمایشی از پیش تعریف شده نمایش می دهد ، که این آدرس اینترنتی را در یک برگه جدید باز می کند و کاربر می تواند نحوه نمای سایت نمایشی را مشاهده کند. شما می توانید درون ریزی محتوا ، ویجت ها ، سفارشی ساز و فایلهای درون ریزی چارچوب Redux را تنظیم کنید به همچنین می توانید یک تصویر پیش نمایش تعریف کنید ، که فقط در صورت تعریف چندین درون ریزی نمایشی استفاده می شود ، به طوری که کاربر تفاوت بین درون ریزی را مشاهده می کند. دسته ها را می توان به هر درون ریزی نسخه ی نمایشی اختصاص داد ، به طوری که می توان آنها را به راحتی فیلتر کرد. آدرس اینترنتی پیش نمایش دکمه “پیش نمایش” را در مورد نسخه ی نمایشی از پیش تعیین شده نمایش می دهد ، که این ادرس اینترنتی را در یک برگه جدید باز می کند و کاربر می تواند ظاهر سایت نمایشی را مشاهده کند.

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

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

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

    set_theme_mod( 'nav_menu_locations', array(
            'main-menu' => $main_menu->term_id, // replace 'main-menu' here with the menu location identifier from register_nav_menu() function
        )
    );

    // 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( 'ocdi/after_import', 'ocdi_after_import_setup' );

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

شما باید از فیلتر مشابه مثال بالا استفاده کنید ، اما با کلیدهای آرایه کمی متفاوت: local_*. مقادیر باید مسیرهای مطلق (و نه نشانی اینترنتی) فایل های واردات شما باشند. برای استفاده از فایل های واردات محلی که در پوشه پوسته شما قرار دارند ، لطفاً از کد زیر استفاده کنید. توجه: مطمئن شوید فایل های وارداتی شما قابل خواندن هستند!

function ocdi_import_files() {
    return array(
        array(
            'import_file_name'             => 'Demo Import 1',
            'categories'                   => array( 'Category 1', 'Category 2' ),
            'local_import_file'            => trailingslashit( get_template_directory() ) . 'ocdi/demo-content.xml',
            'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'ocdi/widgets.json',
            'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'ocdi/customizer.dat',
            'local_import_redux'           => array(
                array(
                    'file_path'   => trailingslashit( get_template_directory() ) . 'ocdi/redux.json',
                    'option_name' => 'redux_option_name',
                ),
            ),
            'import_preview_image_url'     => 'http://www.your_domain.com/ocdi/preview_import_image1.jpg',
            'import_notice'                => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ),
            'preview_url'                  => 'http://www.your_domain.com/my-demo-1',
        ),
        array(
            'import_file_name'             => 'Demo Import 2',
            'categories'                   => array( 'New category', 'Old category' ),
            'local_import_file'            => trailingslashit( get_template_directory() ) . 'ocdi/demo-content2.xml',
            'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'ocdi/widgets2.json',
            'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'ocdi/customizer2.dat',
            'local_import_redux'           => array(
                array(
                    'file_path'   => trailingslashit( get_template_directory() ) . 'ocdi/redux.json',
                    'option_name' => 'redux_option_name',
                ),
                array(
                    'file_path'   => trailingslashit( get_template_directory() ) . 'ocdi/redux2.json',
                    'option_name' => 'redux_option_name_2',
                ),
            ),
            'import_preview_image_url'     => 'http://www.your_domain.com/ocdi/preview_import_image2.jpg',
            'import_notice'                => __( 'A special note for this import.', 'your-textdomain' ),
            'preview_url'                  => 'http://www.your_domain.com/my-demo-2',
        ),
    );
}
add_filter( 'ocdi/import_files', 'ocdi_import_files' );

بسته به نوع واردات از پیش تعیین شده ، چگونه “تنظیمات پس از واردات” مختلف را مدیریت کنیم؟

این سوال ممکن است توسط نویسنده پوسته ای که مایل است پیکربندی های متفاوتی را پس از واردات برای چندین واردات نمایشی از پیش تعریف شده پیاده کند ، مطرح شود. بگذارید بگوییم که ما دو واردات نسخه ی نمایشی را با نام های زیر از پیش تعریف کرده ایم: ‘درون ریزی نسخه نمایشی 1’ و ‘درون ریزی نسخه نمایشی2’ ، کد پس از وارد کردن تنظیمات (با استفاده از فیلتر ocdi/after_import ) خواهد بود:

function ocdi_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( 'ocdi/after_import', 'ocdi_after_import' );

Can I add some code before the widgets get imported?

Of course you can, use the ocdi/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 ocdi/before_widgets_import action:

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

چطور میتوانم با وردپرس cli درون ریزی کنم

In the 2.4.0 version of this plugin we added two WP-CLI commands:

  • wp ocdi list-که هرگونه واردات نسخه ی نمایشی از پیش تعریف شده را که پوسته فعلی ممکن است داشته باشد لیست می کند ،
  • wp ocdi import – که دارای چند گزینه است که می توانید از آنها برای وارد کردن موارد مورد نظر خود (محتوا/ابزارک ها/سفارشی ساز/نسخه های نمایشی از پیش تعریف شده) استفاده کنید. اجازه دهید این گزینه های زیر را بررسی کنیم.

    گزینه های در ون ریزی وردپرس ocdi

    wp ocdi import [–content=] [–widgets=] [–customizer=] [–predefined=]

  • --content = & lt؛ file & gt؛ -درون ریزی محتوا را با فایل درون ریزی وردپرس مشخص شده در پارامتر & lt؛ file & gt؛ اجرا می کند ،

  • --widgets = & lt؛ file & gt؛ -واردات ویجت ها را با فایل واردات ابزارک ها مشخص شده در پارامتر & lt؛ file & gt؛ اجرا می کند ،
  • --customizer = & & lt؛ file & gt؛ -واردات تنظیمات شخصی ساز را با فایل وارد کننده شخصی ساز مشخص شده در پارامتر & lt؛ file & gt؛ اجرا می کند ،
  • --predefined = & lt؛ index & gt؛ -موضوع واردات از پیش تعریف شده موضوع را با نمایه واردات از پیش تعریف شده در پارامتر & lt؛ index & gt؛ اجرا می کند (می توانید از دستور wp ocdi list برای بررسی اینکه کدام شاخص برای هر واردات نسخه ی نمایشی از پیش تعیین شده استفاده می شود استفاده کنید)

محتوا ، ابزارک ها و گزینه های سفارشی سازی می توانند همزمان مخلوط شده و مورد استفاده قرار گیرند. اگر گزینه از پیش تعریف شده تنظیم شود ، همه گزینه های دیگر را نادیده می گیرد و داده های نمایشی از پیش تعریف شده را وارد می کند

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

با استفاده از فیلتر ocdi/plugin_intro_text می توانید متن معرفی افزونه را تغییر دهید:

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

    return $default_text;
}
add_filter( 'ocdi/plugin_intro_text', 'ocdi_plugin_intro_text' );

To add some text in a separate “box”, you should wrap your text in a div with a class of ‘ocdi__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( 'ocdi/regenerate_thumbnails_in_content_import', '__return_false' );

چگونه می توان مکان ، عنوان و سایر پارامترهای صفحه افزونه را تغییر داد؟

As a theme author you do not like the location of the “Import Demo Data” plugin page in Appearance -> Import Demo Data? 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 ocdi_plugin_page_setup( $default_settings ) {
    $default_settings['parent_slug'] = 'themes.php';
    $default_settings['page_title']  = esc_html__( 'One Click Demo Import' , 'one-click-demo-import' );
    $default_settings['menu_title']  = esc_html__( 'Import Demo Data' , 'one-click-demo-import' );
    $default_settings['capability']  = 'import';
    $default_settings['menu_slug']   = 'one-click-demo-import';

    return $default_settings;
}
add_filter( 'ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' );

چگونه قبل از اجرای درون ریزی محتوا ، کاری انجام دهیم؟

In version 2.0.0 there is a new action hook: ocdi/before_content_import, which will let you hook before the content import starts. An example of the code would look like this:

function ocdi_before_content_import( $selected_import ) {
    if ( 'Demo Import 1' === $selected_import['import_file_name'] ) {
        // Here you can do stuff for the "Demo Import 1" before the content import starts.
        echo "before import 1";
    }
    else {
        // Here you can do stuff for all other imports before the content import starts.
        echo "before import 2";
    }
}
add_action( 'ocdi/before_content_import', 'ocdi_before_content_import' );

How can I enable the `customize_save*` wp action hooks in the customizer import?

آسان است فقط این را به پوسته خود اضافه کنید

add_action( 'ocdi/enable_wp_customize_save_hooks', '__return_true' );

این امر هنگام وارد کردن داده های سفارشی ، قلاب های وردپرس زیر را فعال می کند: customize_save ، customize_save_* ، customize_save_after .

چگونه می توانم نشانی اینترنتی (پیوندهای موقت) آمازون S3 را به عنوان فایل خارجی ارسال کنم؟

اگر می خواهید فایل های محتوای درون ریزی خود را در آمازون S3 میزبانی کنید ، اما می خواهید آنها در دسترس عموم قرار بگیرند ، و نه از طریق API خود به عنوان URL های تعیین شده (که منقضی می شود) می توانید از فیلتر ocdi/pre_download_import_files که می توانید آدرس های اینترنتی خود را ارسال کنید ، به عنوان مثال:

add_filter( 'ocdi/pre_download_import_files', function( $import_file_info ){

    // In this example get_my_custom_urls` is supposedly making a `wp_remote_get` request, getting the urls from an API server where you're creating the presigned urls, [example here](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-url.html).
// This request should return an array containing all the 3 links - `import_file_url`, `import_widget_file_url`, `import_customizer_file_url`
$request = get_my_custom_urls( $import_file_info );

if ( !is_wp_error( $request ) )
{
    if ( isset($request['data']) && is_array($request['data']) )
    {
        if( isset($request['data']['import_file_url']) && $import_file_url = $request['data']['import_file_url'] ){
            $import_file_info['import_file_url'] = $import_file_url;
        }
        if( isset($request['data']['import_widget_file_url']) && $import_widget_file_url = $request['data']['import_widget_file_url'] ){
            $import_file_info['import_widget_file_url'] = $import_widget_file_url;
        }
        if( isset($request['data']['import_customizer_file_url']) && $import_customizer_file_url = $request['data']['import_customizer_file_url'] ){
            $import_file_info['import_customizer_file_url'] = $import_customizer_file_url;
        }
    }
}

return $import_file_info;

} );
`

من نمی توانم افزونه را فعال کنم ، به دلیل خطای مهلک ، چه کاری می توانم انجام دهم؟

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

می خواهید افزونه را فعال کنید ، اما این خطا نشان داده می شود:

Plugin could not be activated because it triggered a fatal error

این اتفاق می افتد ، زیرا سرور میزبانی شما از نسخه بسیار قدیمی PHP استفاده می کند. این افزونه به نسخه PHP حداقل 5.3.x نیاز دارد ، اما ما نسخه 5.6.x یا بهتر از آن 7.x را توصیه می کنیم. لطفاً با شرکت میزبانی خود تماس بگیرید و از آنها بخواهید نسخه PHP سایت شما را به روز کنند.

Issues with the import, that we can’t fix in the plugin

Please visit this docs page, for more answers to issues with importing data.