Hello and is it possible to have a callback when pwa is installed?
The idea is to record the number of installations in the database to make stats,
thank you
Category: PHP
Category Added in a WPeMatico Campaign
Divi Theme and woocommerce_product_query not working
I am calling woocommerce_product_query
but is not working in Divi theme
.
I checked and it works with other built-in wordpress themes.
I am using Query Monitor
and I can see that its fired correctly but still I get all products and not the one I hardcoded in post__in
.
Here is my code:
add_action( 'woocommerce_product_query', 'my_pre_get_posts_query', 9999 );
function my_pre_get_posts_query( $query ) {
$meta_query = $query->get( 'meta_query' );
$query->set( 'post__in', ['245374','245372'] );
}
Is there any known interference with Divi? What can possible go wrong? I checked both with parent and child Divi theme.
Laravel Route to other port/application
I have a laravel 8 project running on port 8000 and metabase (an analytic framework) running on port 3000.
metabase itself is password protected. But if possible I would like to make normal users unable to even get to the login screen of metabase. My idea was that metabase exposes port 3000 only to localhost and laravel forwards port 3000 inside a middlewarte protected route.
I was hoping for a solution which would look something like this:
Route::middleware(['auth','isAdmin'])->prefix('metabase')->group(function() {
// forward port 3000 here
});
Sporadic Connection timeout error to RDS from Laravel code
We are using laravel on EC2 and connecting to an RDS instance. Sporadically, once every two days or so there is a timeout issue on the app hosted on EC2 with an error stating
SQLState[HY000][2002] Connection timeout error
There are other posts where this is due to the wrong RDS configuration but this is not the case here. The code works well for the most part. Just fails once every two days or so. Even this is not consistent. There are very few users using the system only 2 to 3 at this point. When this connection error appears the RDS instance seems to be working normally and shows no signs of any errors. We need to reboot the EC2 server for it to work again.
All of our classes extend model and just use basic queries like
Customer::where('type', 'example')->firstOrFail();
The confusing part is that it works perfectly well most of the time but just fails sporadically. We just have 2 users using the laravel app so its not a scaling issue. Wondering if it has something to do with increasing pooling limits or connection timeouts. If nothing works we would have to build a new EC2 instance to see if this occurs there as well. We do query external API’s in some of our calls but that should technically have nothing to do with the RDS timeout.
preg_replace arabic title like مرحبا-اهلاً-بك-هنا
guys i have tried a lot of function but no one of them help me the way that supposed to be.
i have htaccess to replace URL to freindly URL like (test-test-test-test)
in english everything works fine but in arabic not work (مرحبا-مرحبا-مرحبا-مرحبا) not working probably
// English function work fine! replace long title with dashes
// ex: hello-world-how-is-everything
function seoUrl($string) {
$string = strtolower($string);
$string = str_replace('&',' ',$string);
$string = preg_replace("/[^a-z0-9_s-]/", "", $string);
$string = preg_replace("/[s-]+/", " ", $string);
$string = preg_replace("/[s_]/", "-", $string);
return $string;
}
so i want it to be work in arabic language..
thanks
storing positive value in mysql
I’m trying to store something like this in MYSQL table with php : 1+2+3+4
ex: $apple=’1+2+3+4′;
But it only insert the first number “1” in the row apple of my table and drop the rest of the chain
PHP uniqid() – Are there any chances of Duplication
I’m currently using php’s uniqid()
since the requirement is not to exceed 15 chars alphanumeric. But I’m worried if there’s any chances of duplication/collision because of more than thousand entries each day.
I can’t use salt
since it exceeds 15 chars. Is it okay to just use uniqid()
or is there a better solution?
Fetch API giving 403 error in Codeigniter 3
products.push({'<?php echo $this->security->get_csrf_token_name(); ?>':'<?php echo $this->security->get_csrf_hash(); ?>'});
fetch(url + 'createProducts' ,{
method: 'POST',
credentials: 'same-origin',
mode: 'same-origin',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify(products)
}).then(()=>{alert('done'); console.log(response.json());})
.catch(()=>{alert('error AJAX')});
in products, I have an array of products for my project
ad I am pushing my csrf token too.
But still getting 403 error, please help me resolve this.
Thank You