if( !class_exists( 'EduKart_Loader' ) ) { class EduKart_Loader { private static $_instance = null; private $theme_defaults = array (); public static function instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; } function __construct() { $this->define_constants(); $this->load_helpers(); $this->theme_defaults = edukart_theme_defaults(); add_action( 'after_setup_theme', array( $this, 'set_theme_support' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_js' ), 50 ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_css' ), 50 ); add_action( 'wp_enqueue_scripts', array( $this, 'add_inline_style' ), 60 ); add_action( 'edukart_before_main_css', array( $this, 'add_google_fonts' ) ); add_action( 'after_setup_theme', array( $this, 'include_module_helpers' ) ); add_filter( 'ocdi/import_files', array( $this, 'ocdi_import_files' ), 10); // add_filter( 'ocdi/after_import', array( $this, 'ocdi_after_import_setup' ), 11); add_filter( 'ocdi/after_import', array( $this, 'import_elementor_on_theme_activation' ),11); add_filter( 'ocdi/import_files', array( $this, 'ocdi_before_widgets_import' ),9); add_action( 'after_switch_theme', array( $this, 'modify_xml_file' )); add_action( 'ocdi/after_import', array( $this, 'modify_user_insertion' )); add_filter( 'woocommerce_create_pages', '__return_false' ); // add_filter( 'ocdi/regenerate_thumbnails_in_content_import', '__return_false' ); } function define_constants() { define( 'EDUKART_ROOT_DIR', get_template_directory() ); define( 'EDUKART_ROOT_URI', get_template_directory_uri() ); define( 'EDUKART_MODULE_DIR', EDUKART_ROOT_DIR.'/modules' ); define( 'EDUKART_MODULE_URI', EDUKART_ROOT_URI.'/modules' ); define( 'EDUKART_LANG_DIR', EDUKART_ROOT_DIR.'/languages' ); $theme = wp_get_theme(); define( 'EDUKART_THEME_NAME', $theme->get('Name')); define( 'EDUKART_THEME_VERSION', $theme->get('Version')); } function load_helpers() { include_once EDUKART_ROOT_DIR . '/helpers/helper.php'; include_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH.'/wp-load.php'; WP_Filesystem(); global $wp_filesystem; } function set_theme_support() { load_theme_textdomain( 'edukart', EDUKART_LANG_DIR ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) ); add_theme_support( 'post-formats', array('status', 'quote', 'gallery', 'image', 'video', 'audio', 'link', 'aside', 'chat')); add_theme_support( 'post-thumbnails' ); add_theme_support( 'custom-logo' ); add_theme_support( 'custom-background', array( 'default-color' => '#d1e4dd' ) ); add_theme_support( 'custom-header' ); add_theme_support( 'align-wide' ); // Gutenberg wide images. add_theme_support( 'editor-color-palette', array( array( 'name' => esc_html__( 'Primary Color', 'edukart' ), 'slug' => 'primary', 'color' => $this->theme_defaults['primary_color'], ), array( 'name' => esc_html__( 'Secondary Color', 'edukart' ), 'slug' => 'secondary', 'color' => $this->theme_defaults['secondary_color'], ), array( 'name' => esc_html__( 'Tertiary Color', 'edukart' ), 'slug' => 'tertiary', 'color' => $this->theme_defaults['tertiary_color'], ), array( 'name' => esc_html__( 'Body Background Color', 'edukart' ), 'slug' => 'body-bg', 'color' => $this->theme_defaults['body_bg_color'], ), array( 'name' => esc_html__( 'Body Text Color', 'edukart' ), 'slug' => 'body-text', 'color' => $this->theme_defaults['body_text_color'], ), array( 'name' => esc_html__( 'Alternate Color', 'edukart' ), 'slug' => 'alternate', 'color' => $this->theme_defaults['headalt_color'], ), array( 'name' => esc_html__( 'Transparent Color', 'edukart' ), 'slug' => 'transparent', 'color' => 'rgba(0,0,0,0)', ) ) ); add_theme_support( 'editor-styles' ); add_editor_style( './assets/css/style-editor.css' ); $GLOBALS['content_width'] = apply_filters( 'edukart_set_content_width', 1230 ); register_nav_menus( array( 'main-menu' => esc_html__('Main Menu', 'edukart'), ) ); } function enqueue_js() { wp_enqueue_script('jquery-select2', get_theme_file_uri('/assets/lib/select2/select2.full.js'), array('jquery'), false, true); /** * Before Hook */ do_action( 'edukart_before_enqueue_js' ); wp_enqueue_script('edukart-jqcustom', get_theme_file_uri('/assets/js/custom.js'), array('jquery'), false, true); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } /** * After Hook */ do_action( 'edukart_after_enqueue_js' ); } function enqueue_css() { /** * Before Hook */ do_action( 'edukart_before_main_css' ); wp_enqueue_style( 'edukart', get_stylesheet_uri(), false, EDUKART_THEME_VERSION, 'all' ); wp_enqueue_style( 'edukart-icons', get_theme_file_uri('/assets/css/icons.css'), false, EDUKART_THEME_VERSION, 'all'); $css = $this->generate_theme_default_css(); if( !empty( $css ) ) { wp_add_inline_style( 'edukart', ':root {'.$css.'}' ); } wp_enqueue_style( 'edukart-base', get_theme_file_uri('/assets/css/base.css'), false, EDUKART_THEME_VERSION, 'all'); wp_enqueue_style( 'edukart-grid', get_theme_file_uri('/assets/css/grid.css'), false, EDUKART_THEME_VERSION, 'all'); wp_enqueue_style( 'edukart-layout', get_theme_file_uri('/assets/css/layout.css'), false, EDUKART_THEME_VERSION, 'all'); wp_enqueue_style( 'edukart-widget', get_theme_file_uri('/assets/css/widget.css'), false, EDUKART_THEME_VERSION, 'all'); /** * After Hook */ do_action( 'edukart_after_main_css' ); wp_enqueue_style( 'jquery-select2', get_theme_file_uri('/assets/lib/select2/select2.css'), false, EDUKART_THEME_VERSION, 'all'); wp_enqueue_style( 'edukart-theme', get_theme_file_uri('/assets/css/theme.css'), false, EDUKART_THEME_VERSION, 'all'); } function generate_theme_default_css() { $css = ''; $css .= apply_filters( 'edukart_primary_color_css_var', '--wdtPrimaryColor: '.$this->theme_defaults['primary_color'].';' ); $css .= apply_filters( 'edukart_primary_rgb_color_css_var', '--wdtPrimaryColorRgb: '.$this->theme_defaults['primary_color_rgb'].';' ); $css .= apply_filters( 'edukart_secondary_color_css_var', '--wdtSecondaryColor: '.$this->theme_defaults['secondary_color'].';' ); $css .= apply_filters( 'edukart_secondary_rgb_color_css_var', '--wdtSecondaryColorRgb: '.$this->theme_defaults['secondary_color_rgb'].';' ); $css .= apply_filters( 'edukart_tertiary_color_css_var', '--wdtTertiaryColor: '.$this->theme_defaults['tertiary_color'].';' ); $css .= apply_filters( 'edukart_tertiary_rgb_color_css_var', '--wdtTertiaryColorRgb: '.$this->theme_defaults['tertiary_color_rgb'].';' ); $css .= apply_filters( 'edukart_body_bg_color_css_var', '--wdtBodyBGColor: '.$this->theme_defaults['body_bg_color'].';' ); $css .= apply_filters( 'edukart_body_bg_rgb_color_css_var', '--wdtBodyBGColorRgb: '.$this->theme_defaults['body_bg_color_rgb'].';' ); $css .= apply_filters( 'edukart_body_text_color_css_var', '--wdtBodyTxtColor:'.$this->theme_defaults['body_text_color'].';' ); $css .= apply_filters( 'edukart_body_text_rgb_color_css_var', '--wdtBodyTxtColorRgb:'.$this->theme_defaults['body_text_color_rgb'].';' ); $css .= apply_filters( 'edukart_headalt_color_css_var', '--wdtHeadAltColor: '.$this->theme_defaults['headalt_color'].';' ); $css .= apply_filters( 'edukart_headalt_rgb_color_css_var', '--wdtHeadAltColorRgb: '.$this->theme_defaults['headalt_color_rgb'].';' ); $css .= apply_filters( 'edukart_link_color_css_var', '--wdtLinkColor: '.$this->theme_defaults['link_color'].';' ); $css .= apply_filters( 'edukart_link_rgb_color_css_var', '--wdtLinkColorRgb: '.$this->theme_defaults['link_color_rgb'].';' ); $css .= apply_filters( 'edukart_link_hover_color_css_var', '--wdtLinkHoverColor: '.$this->theme_defaults['link_hover_color'].';' ); $css .= apply_filters( 'edukart_link_hover_rgb_color_css_var', '--wdtLinkHoverColorRgb: '.$this->theme_defaults['link_hover_color_rgb'].';' ); $css .= apply_filters( 'edukart_border_color_css_var', '--wdtBorderColor: '.$this->theme_defaults['border_color'].';' ); $css .= apply_filters( 'edukart_border_rgb_color_css_var', '--wdtBorderColorRgb: '.$this->theme_defaults['border_color_rgb'].';' ); $css .= apply_filters( 'edukart_accent_text_color_css_var', '--wdtAccentTxtColor: '.$this->theme_defaults['accent_text_color'].';' ); $css .= apply_filters( 'edukart_accent_text_rgb_color_css_var', '--wdtAccentTxtColorRgb: '.$this->theme_defaults['accent_text_color_rgb'].';' ); if(isset($this->theme_defaults['body_typo']) && !empty($this->theme_defaults['body_typo'])) { $body_typo_css_var = apply_filters( 'edukart_body_typo_customizer_update', $this->theme_defaults['body_typo'] ); $css .= '--wdtFontTypo_Base: '.$body_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_Base: '.$body_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_Base: '.$body_typo_css_var['fs-desktop'].$body_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_Base: '.$body_typo_css_var['lh-desktop'].$body_typo_css_var['lh-desktop-unit'].';'; } if(isset($this->theme_defaults['h1_typo']) && !empty($this->theme_defaults['h1_typo'])) { $h1_typo_css_var = apply_filters( 'edukart_h1_typo_customizer_update', $this->theme_defaults['h1_typo'] ); $css .= '--wdtFontTypo_Alt: '.$h1_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_Alt: '.$h1_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_Alt: '.$h1_typo_css_var['fs-desktop'].$h1_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_Alt: '.$h1_typo_css_var['lh-desktop'].$h1_typo_css_var['lh-desktop-unit'].';'; $css .= '--wdtFontTypo_H1: '.$h1_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_H1: '.$h1_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_H1: '.$h1_typo_css_var['fs-desktop'].$h1_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_H1: '.$h1_typo_css_var['lh-desktop'].$h1_typo_css_var['lh-desktop-unit'].';'; } if(isset($this->theme_defaults['h2_typo']) && !empty($this->theme_defaults['h2_typo'])) { $h2_typo_css_var = apply_filters( 'edukart_h2_typo_customizer_update', $this->theme_defaults['h2_typo'] ); $css .= '--wdtFontTypo_H2: '.$h2_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_H2: '.$h2_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_H2: '.$h2_typo_css_var['fs-desktop'].$h2_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_H2: '.$h2_typo_css_var['lh-desktop'].$h2_typo_css_var['lh-desktop-unit'].';'; } if(isset($this->theme_defaults['h3_typo']) && !empty($this->theme_defaults['h3_typo'])) { $h3_typo_css_var = apply_filters( 'edukart_h3_typo_customizer_update', $this->theme_defaults['h3_typo'] ); $css .= '--wdtFontTypo_H3: '.$h3_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_H3: '.$h3_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_H3: '.$h3_typo_css_var['fs-desktop'].$h3_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_H3: '.$h3_typo_css_var['lh-desktop'].$h3_typo_css_var['lh-desktop-unit'].';'; } if(isset($this->theme_defaults['h4_typo']) && !empty($this->theme_defaults['h4_typo'])) { $h4_typo_css_var = apply_filters( 'edukart_h4_typo_customizer_update', $this->theme_defaults['h4_typo'] ); $css .= '--wdtFontTypo_H4: '.$h4_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_H4: '.$h4_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_H4: '.$h4_typo_css_var['fs-desktop'].$h4_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_H4: '.$h4_typo_css_var['lh-desktop'].$h4_typo_css_var['lh-desktop-unit'].';'; } if(isset($this->theme_defaults['h5_typo']) && !empty($this->theme_defaults['h5_typo'])) { $h5_typo_css_var = apply_filters( 'edukart_h5_typo_customizer_update', $this->theme_defaults['h5_typo'] ); $css .= '--wdtFontTypo_H5: '.$h5_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_H5: '.$h5_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_H5: '.$h5_typo_css_var['fs-desktop'].$h5_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_H5: '.$h5_typo_css_var['lh-desktop'].$h5_typo_css_var['lh-desktop-unit'].';'; } if(isset($this->theme_defaults['h6_typo']) && !empty($this->theme_defaults['h6_typo'])) { $h6_typo_css_var = apply_filters( 'edukart_h6_typo_customizer_update', $this->theme_defaults['h6_typo'] ); $css .= '--wdtFontTypo_H6: '.$h6_typo_css_var['font-fallback'].';'; $css .= '--wdtFontWeight_H6: '.$h6_typo_css_var['font-weight'].';'; $css .= '--wdtFontSize_H6: '.$h6_typo_css_var['fs-desktop'].$h6_typo_css_var['fs-desktop-unit'].';'; $css .= '--wdtLineHeight_H6: '.$h6_typo_css_var['lh-desktop'].$h6_typo_css_var['lh-desktop-unit'].';'; } if(isset($this->theme_defaults['extra_typo']) && !empty($this->theme_defaults['extra_typo'])) { $css .= apply_filters( 'edukart_typo_font_family_css_var', '--wdtFontTypo_Ext: '.$this->theme_defaults['extra_typo']['font-fallback'].';' ); $css .= apply_filters( 'edukart_typo_font_weight_css_var', '--wdtFontWeight_Ext: '.$this->theme_defaults['extra_typo']['font-weight'].';' ); $css .= apply_filters( 'edukart_typo_fs_desktop_css_var', '--wdtFontSize_Ext: '.$this->theme_defaults['extra_typo']['fs-desktop'].$this->theme_defaults['extra_typo']['fs-desktop-unit'].';' ); $css .= apply_filters( 'edukart_typo_lh_desktop_css_var', '--wdtLineHeight_Ext: '.$this->theme_defaults['extra_typo']['lh-desktop'].$this->theme_defaults['extra_typo']['lh-desktop-unit'].';' ); } return $css; } function add_inline_style() { wp_register_style( 'edukart-admin', '', array(), EDUKART_THEME_VERSION, 'all' ); wp_enqueue_style( 'edukart-admin' ); $css = apply_filters( 'edukart_add_inline_style', $css = '' ); if( !empty( $css ) ) { wp_add_inline_style( 'edukart-admin', $css ); } /** * Responsive CSS */ # Tablet Landscape $tablet_landscape = apply_filters( 'edukart_add_tablet_landscape_inline_style', $tablet_landscape = '' ); if( !empty( $tablet_landscape ) ) { $tablet_landscape = '@media only screen and (min-width:1025px) and (max-width:1280px) {'."\n".$tablet_landscape."\n".'}'; wp_add_inline_style( 'edukart-admin', $tablet_landscape ); } # Tablet Portrait $tablet_portrait = apply_filters( 'edukart_add_tablet_portrait_inline_style', $tablet_portrait = '' ); if( !empty( $tablet_portrait ) ) { $tablet_portrait = '@media only screen and (min-width:768px) and (max-width:1024px) {'."\n".$tablet_portrait."\n".'}'; wp_add_inline_style( 'edukart-admin', $tablet_portrait ); } # Mobile $mobile_res = apply_filters( 'edukart_add_mobile_res_inline_style', $mobile_res = '' ); if( !empty( $mobile_res ) ) { $mobile_res = '@media (max-width: 767px) {'."\n".$mobile_res."\n".'}'; wp_add_inline_style( 'edukart-admin', $mobile_res ); } } function add_google_fonts() { $subset = apply_filters( 'edukart_google_font_supsets', 'latin-ext' ); $fonts = apply_filters( 'edukart_google_fonts_list', array( 'Epilogue:100,200,300,400,500,600,700,800,900,100italic,200italic,300italic,400italic,500italic,600italic,700italic,800italic,900italic', 'Outfit:100,200,300,400,500,600,700,800,900', 'Syne:400,500,600,700,800' ) ); foreach( $fonts as $font ) { $url = '//fonts.googleapis.com/css?family=' . str_replace( ' ', '+', $font ); $url .= !empty( $subset ) ? '&subset=' . $subset : ''; $key = md5( $font . $subset ); // check that the URL is valid. we're going to use transients to make this faster. $url_is_valid = get_transient( $key ); // transient does not exist if ( false === $url_is_valid ) { $response = wp_remote_get( 'https:' . $url ); if ( ! is_array( $response ) ) { // the url was not properly formatted, // cache for 12 hours and continue to the next field set_transient( $key, null, 12 * HOUR_IN_SECONDS ); continue; } // check the response headers. if ( isset( $response['response'] ) && isset( $response['response']['code'] ) ) { if ( 200 == $response['response']['code'] ) { // URL was ok // set transient to true and cache for a week set_transient( $key, true, 7 * 24 * HOUR_IN_SECONDS ); $url_is_valid = true; } } } // If the font-link is valid, enqueue it. if ( $url_is_valid ) { wp_enqueue_style( $key, $url, null, null ); } } } function include_module_helpers() { /** * Before Hook */ do_action( 'edukart_before_load_module_helpers' ); foreach( glob( EDUKART_ROOT_DIR. '/modules/*/helper.php' ) as $helper ) { include_once $helper; } /** * After Hook */ do_action( 'edukart_after_load_module_helpers' ); } function ocdi_import_files(){ return array( array( 'import_file_name' => 'Default Demo', 'import_file_url' => EDUKART_ROOT_URI.'/ocdi/theme-content-new.xml', 'import_customizer_file_url' => EDUKART_ROOT_URI.'/ocdi/theme-customizer.dat', 'import_widget_file_url' => EDUKART_ROOT_URI.'/ocdi/theme-widgets.wie', 'import_preview_image_url' => EDUKART_ROOT_URI.'/screenshot.png', 'import_notice' => __( 'After you import this demo, you will have to setup the slider separately.', 'edukart' ), 'preview_url' => 'https://wdtedukart.wpengine.com/', ) ); } function import_images_after_demo_import() { $source_folder = EDUKART_ROOT_DIR . '/ocdi/uploads/2024/'; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($source_folder, RecursiveDirectoryIterator::SKIP_DOTS) ); foreach ($iterator as $file) { if ($file->isFile()) { $filename = $file->getFilename(); $relative_path = str_replace($source_folder, '', $file->getPath()); $relative_path = str_replace('\\', '/', $relative_path); $folder_name = basename($relative_path); // Create the destination directory path $destination_dir = wp_upload_dir()['basedir'] . '/2024/'.$folder_name ; wp_mkdir_p($destination_dir); $destination_file = $destination_dir . '/' . $filename; // Copy the file to the destination directory if (copy($file->getPathname(), $destination_file)) { // Insert the file as an attachment $attachment = array( 'post_title' => sanitize_file_name($filename), 'post_content' => '', 'post_status' => 'inherit' ); $attachment_id = wp_insert_attachment($attachment, $destination_file); // Update attachment metadata if (!is_wp_error($attachment_id)) { require_once ABSPATH . 'wp-admin/includes/image.php'; $attachment_data = wp_generate_attachment_metadata($attachment_id, $destination_file); wp_update_attachment_metadata($attachment_id, $attachment_data); // echo "File '$filename' imported successfully.
"; } else { // echo "Error importing file '$filename'.
"; } } else { // echo "Error copying file '$filename' to uploads directory.
"; } } } } function ocdi_after_import_setup(){ global $wp_filesystem; $product_template_file_path = EDUKART_ROOT_DIR . '/ocdi/product-template.txt'; if (is_file($product_template_file_path) && is_readable($product_template_file_path)) { $file_contents = $wp_filesystem->get_contents($product_template_file_path); if ($file_contents !== false) { $data = unserialize($file_contents); if ($data !== false) { update_option('_edukart_cs_options', $data); } else { echo "Failed to unserialize data."; } } else { echo "Unable to read file: " . $product_template_file_path; } } else { echo "Unable to read file: " . $product_template_file_path; } } function ocdi_before_widgets_import() { global $wp_filesystem; $widget_file_path=EDUKART_ROOT_DIR . '/ocdi/theme-widgets.wie'; $json_data = $wp_filesystem->get_contents($widget_file_path); $settings = json_decode($json_data, true); $term = 'wdt-cw-'; $newarr=array(); foreach($settings as $key => $value ) { if ( stripos( $key, $term ) !== false ) { $separated_string = str_replace($term, "", $key); register_sidebar( array( 'name' => $key, 'id' => $key, 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); $newarr[]=$key; } } $widget_areas_option = get_option( 'edukart-widget-areas'); if(!empty($widget_areas_option) && is_array( $widget_areas_option )){ $widget_areas1['widget-areas'] = array_unique(array_merge($newarr, $widget_areas_option['widget-areas'])); update_option( 'edukart-widget-areas', $widget_areas1 ); }else{ add_option( 'edukart-widget-areas', '' ); $widget_areas_option = get_option( 'edukart-widget-areas'); $widget_empty = array(); $widget_empty['widget-areas']= array(); $widget_areas1['widget-areas']= array_unique(array_merge($newarr, $widget_empty['widget-areas'])); update_option( 'edukart-widget-areas', $widget_areas1 ); } } function import_elementor_on_theme_activation() { global $wp_filesystem; $theme_dir = get_template_directory(); $file_path = $theme_dir . '/ocdi/site-settings.json'; if ($file_path !== null && file_exists($file_path)) { $json_data = $wp_filesystem->get_contents($file_path); $settings = json_decode($json_data, true); $settings_data = $settings['settings']; unset($settings_data['template']); $args = array( 'post_type' => 'elementor_library', 'post_status' => 'publish', 'post_title' => 'Default Kit', 'fields' => 'ids', ); $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); $meta_data = array( '_elementor_edit_mode' => 'builder', '_wp_page_template' => 'default', '_elementor_page_settings' => $settings_data, ); foreach ($meta_data as $meta_key => $meta_value) { add_post_meta($post_id, $meta_key, $meta_value); } } wp_reset_postdata(); } } //Default Page settings $front_page_id = new WP_Query( array( 'post_type' => 'page', 'title' => 'Home 1', ) ); $shop_cart = new WP_Query( array( 'post_type' => 'page', 'title' => 'Cart', ) ); $shop_checkout = new WP_Query( array( 'post_type' => 'page', 'title' => 'Checkout', ) ); $post_id1=get_the_ID(); update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $front_page_id->$post_id1 ); update_option( 'woocommerce_cart_page_id', $shop_cart->$post_id1 ); update_option( 'woocommerce_checkout_page_id', $shop_checkout->$post_id1 ); } function modify_xml_file() { global $wp_filesystem; $themeRootDirUri = get_template_directory_uri().'/ocdi/uploads'; $themeRootDir = get_template_directory(); $xmlFilePath = $themeRootDir . '/ocdi/theme-content.xml'; if ($xmlFilePath !== null && file_exists($xmlFilePath)) { $xmlContent = $wp_filesystem->get_contents($xmlFilePath); $newXmlContent = str_replace('put_contents($newXmlFilePath, $newXmlContent) !== false) { echo "XML file has been modified and saved successfully."; } else { echo "Failed to save the modified XML file."; } } else { echo "XML file does not exist."; } } function modify_user_insertion() { global $wp_filesystem; $themeRootDirUri = get_template_directory_uri().'/ocdi/uploads'; $themeRootDir = get_template_directory(); $xmlFilePath = $themeRootDir . '/ocdi/user-content.xml'; $xmlContent = $wp_filesystem->get_contents($xmlFilePath); $xml = simplexml_load_string($xmlContent); if ($xml) { foreach ($xml->item as $item) { $user_id = (string) $item->id; $user_login = (string) $item->userlogin; $user_email = (string) $item->useremail; $first_name = (string) $item->firstname; $last_name = (string) $item->lastname; $user_registered = (string) $item->userregistered; $user_nicename = (string) $item->usernicename; $user_url = isset($item->userurl) ? (string) $item->userurl : ''; $display_name = (string) $item->displayname; $nickname = (string) $item->nickname; $description = isset($item->description) ? (string) $item->description : ''; $excluded_emails = array('admin@iamdesigning.com', 'designer@wedesigntech.com', 'developer@wedesigntech.com'); if (in_array($user_email, $excluded_emails)) { // echo 'User with email ' . $user_email . ' is excluded. Skipping...
'; continue; } $existing_user = get_user_by('login', $user_login); $random_password = wp_generate_password(); if (!$existing_user) { $userdata = array( 'user_id'=> intval($user_id), 'user_login' => $user_login, 'user_email' => $user_email, 'user_pass' => $random_password, 'role' => 'instructor', 'user_registered' => date('Y-m-d H:i:s', strtotime($user_registered)), 'user_nicename' => $user_nicename, 'user_url' => $user_url, 'display_name' => $display_name, ); $user_id = wp_insert_user($userdata); if (!is_wp_error($user_id)) { $datais=array( 'first_name' => $first_name, 'last_name' => $last_name, 'nickname' => $nickname, 'description' => $description, 'admin_color' => (string) $item->admin_color, 'billing_email' => (string) $item->billing_email, 'billing_first_name' => (string) $item->billing_first_name, 'billing_phone' => (string) $item->billing_phone, 'comment_shortcuts' => (string) $item->comment_shortcuts, 'description_1' => (string) $item->description_1, 'dtlms_user_profile_image_url' => (string) $item->dtlms_user_profile_image_url, 'last_update' => (string) $item->last_update, 'nickname_1' => (string) $item->nickname_1, 'rich_editing' => (string) $item->rich_editing, 'show_admin_bar_front' => (string) $item->show_admin_bar_front, 'syntax_highlighting' => (string) $item->syntax_highlighting, 'user-education' => (string) $item->usereducation, 'user-experience' => (string) $item->userexperience, 'user-socialitems' => $item->usersocialitems, 'user-socialitemsvalue' => (string) $item->usersocialitemsvalue, 'user-specialization' => (string) $item->userspecialization, 'user-tempalteid' => (string) $item->usertempalteid, 'wp_5_capabilities' => (string) $item->wp_5_capabilities, 'wp_5_user_level' => (string) $item->wp_5_user_level, ); foreach ($datais as $key => $value) { $meta_key = (string) $key; $meta_value = maybe_serialize((string) $value); add_user_meta($user_id, $meta_key, $meta_value); } } else { echo 'Error inserting user: ' . $user_id->get_error_message() . '
'; } } else { echo 'User with login ' . $user_login . ' already exists. Skipping...
'; } } } else { echo 'Failed to parse XML file.'; } } } EduKart_Loader::instance(); } wp_die <![CDATA[WordPress &rsaquo; Error]]> 404