localize_script but data changes dependent on product ID

You should call wp_localize_script() in the wp_enqueue_scripts hook (or a later hook) in which you would get the correct product/post data such as ID, and that conditional tags like is_single() would also work as expected. So you should move all the $product, $product_id, $dataToBePassed and wp_localize_script() parts to inside the wp_enqueue_scripts callback, and then you’d … Read more

Parsing post->ID in included plugin file

First issue- you can’t access any data because your AJAX request is an entirely separate request from the one that loaded the page you’re making the request from. This is not unique to WordPress. You have to pass the data you want to operate on along with your AJAX request. Second issue- calling your plugin … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)