HEX
Server: LiteSpeed
System: Linux standart103.isimtescil.net 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: byildiz (11197)
PHP: 8.2.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/byildiz.com.tr/httpdocs/wp-content/themes/lumex/inc/ocdi-setup.php
<?php
/**
 * Functions for implement One Click Demo Import for this theme
 *
 * @package lumex
 */

if ( class_exists( 'LumexPlugin' ) && class_exists( 'OCDI_Plugin' ) && class_exists( 'ACF' ) ) {

function lumex_ocdi_import_files() {
    $extra_dir = lumex_extra_dir();
    if ( $extra_dir == 'normal' ) : return array(); endif;

    return array(
        array(
            'import_file_name'           => esc_attr__( 'default', 'lumex' ),
            'categories'                 => array( esc_attr__( 'Default', 'lumex' ) ),
            'import_file_url'            => LUMEX_EXTRA_PLUGINS_DIRECTORY . $extra_dir . '/ocdi-import/demo/01/content.xml',
            'preview_url'                => 'https://1.envato.market/c/1790164/275988/4415?u=https://preview.themeforest.net/item/lumex-business-consulting-wordpress-theme/full_screen_preview/60508382',
        ),
    );
}
add_filter( 'pt-ocdi/import_files', 'lumex_ocdi_import_files' );

function lumex_ocdi_after_import_setup( $selected_import ) {
    if ( lumex_extra_dir() == 'normal' ) : return; endif;

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

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

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

    update_option( 'show_on_front', 'page' );
    update_option( 'page_on_front', $front_page_id->ID );
    update_option( 'posts_per_page', 6 );

    $acf_options = array();

    if ( $selected_import['import_file_name'] ) {
      $json_file = get_template_directory_uri() . '/inc/acf-options/' . $selected_import['import_file_name']  . '.json';
      $response = wp_remote_get( $json_file, array() );
      $response_body = wp_remote_retrieve_body( $response );

      if ( $response_body ) {
        $response_data = json_decode( $response_body );
        $acf_options = $response_data->data;
      }
    }

    if ( !empty( $acf_options ) ) {
      global $wpdb;
      foreach ( $acf_options as $item ) {
        if ( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->options WHERE option_name = %s", $item->option_name ) ) == 0 ) {
            $wpdb->query( $wpdb->prepare( "INSERT INTO $wpdb->options ( option_name, option_value, autoload ) VALUES (%s, %s, 'no')", $item->option_name, $item->option_value ) );
        } else {
          $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->options SET option_value = %s WHERE option_name = %s", $item->option_value, $item->option_name ) );
        }
      }
    }

}
add_action( 'pt-ocdi/after_import', 'lumex_ocdi_after_import_setup' );

}