Restricting access to a file for everyone except logged in users

The file in question (load-scripts.php) is part of WordPress’s admin interface. It’s generally used to improve the performance of the admin panel by combining multiple JavaScript files into a single request. That being said, access to this file should be restricted to logged-in users only, as it could potentially be misused in a DoS attack … Read more

WordPress wp_set_object_terms does not assign product to custom taxonomy

I can see few potential issues here: wp_insert_post returns post_id or 0 or WP_Error, if you will have WP_Error it will still pass the if ( $porduct_id ). So here you have one potential issue. In description you wrote, that you create fields called “regions”, and in code you have wp_set_object_terms($product_id, $regionId, ‘region’); so here … Read more

How can I update a value of a field depending on outside source?

you can read your file using standard PHP: $value = json_decode( file_get_contents( ‘path/to/your/file.json’ ) ); Then you can use WordPress function to update post meta: update_post_meta( $post_id, $meta_name, $value, $prev_value ); $post_id = ID of the post you want to update $meta_name = name of the meta field you want to update $value = new … Read more

How to use phpspreadsheet reader with $wpdb

I’m assuming you mean this PhpSpreadsheet; if not, please edit your question to clarify. To incorporate any third-party PHP library into your WordPress site, you’ll either need to write a plugin or find one that already does what you need. The PhpSpreadsheet docs explain how you’d incorporate their library into any PHP application, which includes … Read more

Running a long script in PHP

You can add some settings to your script to reduce count of imported products in one run. The simplest way – add fields like “Import from” and “Imported count”. You can run your script several times playing with “Import from” parameter and import 200 products (for example) per one time.