admin_url( 'admin-ajax.php' ), 'admin_url' => admin_url( 'admin.php' ), ); wp_localize_script( 'wcex-csv-importer-js', 'wel_csv_importer_data', $script_data ); } add_action( 'admin_enqueue_scripts', 'wel_csv_importer_enqueue_assets' ); /** * Create the Welcart uploads folder. */ function wel_create_uploads_folder() { // Retrieve WordPress upload directory information. $upload_dir = wp_upload_dir(); $base_dir = $upload_dir['basedir']; // Path for the folder to be created. $welcart_dir = $base_dir . '/welcart-uploads'; // Create the folder if it does not exist. if ( ! file_exists( $welcart_dir ) ) { wp_mkdir_p( $welcart_dir ); } // Path for the .htaccess file. $htaccess_file = $welcart_dir . '/.htaccess'; // If .htaccess does not exist, create it and write "deny from all". if ( ! file_exists( $htaccess_file ) ) { file_put_contents( $htaccess_file, 'deny from all' ); } // Path for index.html. $index_file = $welcart_dir . '/index.html'; // If index.html does not exist, create an empty file. if ( ! file_exists( $index_file ) ) { file_put_contents( $index_file, '' ); } if ( ! defined( 'WELCART_UPLOADS_DIR' ) ) { define( 'WELCART_UPLOADS_DIR', $welcart_dir ); } }