In WooCommerce product reviews the comment is not automatically marked as approved

Issue:
In WooCommerce product reviews, when an admin replies to a comment, the comment is not automatically marked as approved, unlike regular WordPress posts. The comment remains colored (indicating it is unapproved) even after approval, and the admin has to refresh the page to see the changes.

What I’m looking for:
A solution that automatically marks the parent comment as approved (and removes the “unapproved” color) when an admin replies to it in the WooCommerce product reviews section, without the need for a page refresh

Why does each call to this socket server give a unique list of peers?

I’m trying to create a kind of signalling server. What I’m attempting to do is allow socket connections and respond to 'helo' with a list of already connected peers:

<?php

use SwooleWebSocketServer;

$host = '0.0.0.0';
$port = 9090;

$server = new Server($host, $port, SWOOLE_PROCESS, SWOOLE_SOCK_TCP);

$connectedPeers = [];

function get_request_key($request) {
    return $request->server['remote_addr'] . ':' . (string)$request->server['remote_port'];
}

$server->on('open', function (Server $server, $request) use(&$connectedPeers) {
    echo "New connection: #{$request->fd}n";
    $connectedPeers[] = get_request_key($request);
    echo var_dump($connectedPeers);
});

$server->on('message', function (Server $server, $frame) use(&$connectedPeers) {
    echo "Received from #{$frame->fd}: {$frame->data}n";
   // echo var_dump($frame);
    $msg = $frame->data;

    if($msg === 'helo'){
        /* in this instance, reply with a list of peers */
        $server->push($frame->fd, '{"type":"peers", "peers":' . json_encode($connectedPeers) . '}');
    }
    else
    // Broadcast message to all connected clients
    foreach ($server->connections as $fd) {
        if ($fd !== $frame->fd) {
            $server->push($fd, $msg);
        }
    }
});

$server->on('close', function (Server $server, $fd) {
    echo "Connection #{$fd} closedn";
});

echo "WebSocket Secure Server started on wss://$host:$portn";
$server->start();
?>

The problem is that if I run this with php server.php, and then connect with two different clients, the response to each is a unique list of peers.

I.e. Client A gets a list with just itself. Client B gets a list with just itself. Client A and B never see each other.

I’m sure it has to do with reference/copy of $connectedPeers but I’m very new to PHP and don’t really understand how lifetime works in this instance.

How to Query Facebook Page Posts for an External Partner?

I have already created a Facebook App and selected the Other option during setup. My goal is to fetch posts from a Facebook Page owned by an external partner (not my own page) using the Facebook Graph API.

Could you give me any guidance how to do it?

Since I don’t own the page, how should the external partner authorize my app so I can obtain a valid Page Access Token?

What is the correct process for them to authenticate my app and grant access to their page?

After authentication, how do I correctly retrieve the Page Access Token to query /page_id/posts?

Are there any additional app configurations or API calls required?

Thanks for any help!

WooCommerce: How to Add Content Below Single Product Gallery [duplicate]

I want to add a custom content module below the product gallery on the WooCommerce product detail page. I found a solution on Google from this website:

https://www.businessbloomer.com/woocommerce-add-content-below-the-single-product-page-images/

However, this solution only works for the desktop version. When switching to the mobile version, the display position of the custom content module changes and ends up below the “Add to Cart” button.

How can I fix this issue?

Cross-origin request on PHP APi

I have cross-origin request from client side to the PHP Api. I founded that at the response request part some cookies couldn’t be able set on the client side.
At the PHP Api side i have code:

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
$names    = ClearTextData($_POST['names']);
$to = "some";
$subject = "some";
$message = "some";
$headers = "some";
$emailResult = mail($to, $subject, $message, implode("rn", $headers), " [email protected]");

sometimes mail() PHP function didn’t work. Could bad context of not settings headers influence on the mail() PHP function?

When i’ve changed to same-origin request everything working. mail() function work.
whats wrong with the mail() function on the cross-origin request?

Google Pay Invalid token id error with stripe gateway

I’m integrating Google Pay with Stripe in my webshop. The integration works perfectly in test mode, but when I switch to production, I get Invalid token id from stripe

My javascript code: ( I successfully retrieve the Google Pay token and send it to my backend )

let paymentToken = JSON.parse(paymentData.paymentMethodData.tokenizationData.token);
let transactionInfo = await getGoogleTransactionInfo();

let response = await fetch('/stripe/processGooglePayPayment', {
   method: 'POST',
   headers: {
       'Content-Type': 'application/json',
       'Accept': 'application/json',
   },
   body: JSON.stringify({
        token: paymentToken.id,
        totalPrice: transactionInfo.totalPrice,
        currencyCode: transactionInfo.currencyCode,
   })
});

My backend code:

 Stripe::setApiKey(config('shop.stripe_keys.stripe_secret_key'));

 $googlePayToken = $request->input('token');
 $totalPrice = $request->input('totalPrice');
 $currencyCode = $request->input('currencyCode');

 $paymentMethod = PaymentMethod::create([
    'type' => 'card',
    'card' => [
        'token' => "$googlePayToken", // Invalid token id
    ],
 ]);

I ensure that both of Stripe and Google Pay is in production, Google Pay environment variable is set to PRODUCTION, I pass the merchantID too, and I use the live secret key to initialize Stripe.

I searched for the solution in Stripe and Google Pay documentations, but I can’t find anything related to this, anyone who is faced with this error too?

Any help would be appreciate!

Digital Ocean Managed MySql DB can not connet via PHP project hosted on Bigirock Server [duplicate]

I have domain and hosing in bigrock linux shared server.
Digital Ocean Managed MySql DB successfully connect via Navicat for Mysql but when i use these credentials in my php project its not working showing error

Basically i am trying to connect Digital Ocean MySQL DB with php project which is hosted on Bigrock shared linux server.

Code i Have Used

<?php
ini_set('display_errors', 1); 
$servername = "db-mysql-db.ondigitalocean.com"; // CHANGED FOR SEQURITY
$username = "repo_Jyoti"; // CHANGED FOR SEQURITY
$password = "AVNbJQM";  // CHANGED FOR SEQURITY
$dbname = "repo_Jyoti"; // CHANGED FOR SEQURITY
$port = "27850"; // CHANGED FOR SEQURITY
    $options = array(
                  PDO::ATTR_PERSISTENT    => true,
                  PDO::ATTR_ERRMODE       => PDO::ERRMODE_EXCEPTION
              );
   
    $dsn = 'mysql:host=' . $servername . ';port=' . $port. ';dbname=' . $dbname;    // Create a new PDO instanace
    try{
        $dbh = new PDO($dsn, $username, $password, $options);
       
         echo "Connected successfully";
    }
    // Catch any errors
    catch(PDOException $e){
        echo "Connection failed: " . $e->getMessage();
    }    
?>

ERROR : Connection failed: SQLSTATE[HY000] [2002] Connection refused


if you want to see the errors by yourself please visit
https://wapi.rentdekhoo.com/bbsapi/repo_Offline/testconn.php

chart.js stacked bar with dynamic values ​and long data labels with a line below the text [closed]

I need to get the value from the previous page url parameter to calculate and display the value in the dynamic chart. It can make a vertical stacked bar chart like the image below. And I want every bar to have a line and an icon including the dynamic value of the bar extending to the right and press the popup to see more details.
Should I code in chart.js? Does anyone have any suggestions? or plugin wordpress

enter image description here

How to run Laravel queue on the production server?

I have used the queue job in my Laravel project to send emails to multiple users. My code is working perfectly on the local system, but on the production server, when I run the queue:work command, it shows a 504 Gateway Timeout error and the server is crashing.

How to solve this problem on the production server?

video post linkedin api Did my video release succeed or fail?

I am trying to upload videos using LinkedIn API V2 and everything is going smoothly without any errors. According to the LinkedIn API, it returns 201. The postResponse resource returns 1. But there is no update on my platform, I don’t know which step went wrong? Now there’s no clue about troubleshooting at all.Please help.
This is my code

<?php
// Example of LinkedIn API video upload and publishing dynamics

//
$accessToken = '{Token}';
$personURN = 'urn:li:person:{URN}'; // URN

//
$videoFilePath = $_FILES['file']['tmp_name'];
$videoFileSize = filesize($videoFilePath);
$videoMimeType = mime_content_type($videoFilePath);

// Step 1: Initialize upload
$initUploadUrl = 'https://api.linkedin.com/rest/videos?action=initializeUpload';

$initHeaders = [
    'Authorization: Bearer ' . $accessToken,
    'Content-Type: application/json',
    'X-Restli-Protocol-Version: 2.0.0',
    'LinkedIn-Version: 202405' // 
];

$initData = [
    'initializeUploadRequest' => [
        'owner' => $personURN,
        'fileSizeBytes' => $videoFileSize,
        'uploadCaptions' => false,
        'uploadThumbnail' => false
    ]
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $initUploadUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($initData));
curl_setopt($ch, CURLOPT_HTTPHEADER, $initHeaders);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($httpCode !== 200) {
    die('Initialization upload failed: ' . $response);
}

$initResponse = json_decode($response, true);
$uploadUrl = $initResponse['value']['uploadInstructions'][0]['uploadUrl'];
$videoAsset = $initResponse['value']['video'];

// Step 2: Upload video files
$uploadHeaders = [
    'Authorization: Bearer ' . $accessToken,
    'Content-Type: ' . $videoMimeType,
    'X-Restli-Protocol-Version: 2.0.0'
];

$videoFile = fopen($videoFilePath, 'r');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uploadUrl);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $videoFile);
curl_setopt($ch, CURLOPT_INFILESIZE, $videoFileSize);
curl_setopt($ch, CURLOPT_HTTPHEADER, $uploadHeaders);

$uploadResponse = curl_exec($ch);
$uploadHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

fclose($videoFile);

if ($uploadHttpCode !== 201 && $uploadHttpCode !== 200) {
    die('Video upload failed: ' . $uploadResponse);
}

// Step 3: Create a dynamic that includes a video
$postUrl = 'https://api.linkedin.com/rest/posts';

$postData = [
    'author' => $personURN,
    'commentary' => 'This is the dynamic description text of my video', // describe
    'visibility' => 'PUBLIC', // PUBLIC, CONNECTIONS
    'distribution' => [
        'feedDistribution' => 'MAIN_FEED',
        'targetEntities' => [],
        'thirdPartyDistributionChannels' => []
    ],
    'content' => [
        'media' => [
            'title' => 'My video title',
            'id' => $videoAsset
        ]
    ],
    'lifecycleState' => 'PUBLISHED',
    'isReshareDisabledByAuthor' => false
];

$postHeaders = [
    'Authorization: Bearer ' . $accessToken,
    'Content-Type: application/json',
    'X-Restli-Protocol-Version: 2.0.0',
    'LinkedIn-Version: 202405'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
curl_setopt($ch, CURLOPT_HTTPHEADER, $postHeaders);

$postResponse = curl_exec($ch);
$postHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);
print_r($postHttpCode);
print_r($postResponse);
if ($postHttpCode === 201) {
    echo 'Video dynamic release successful!';
} else {
    echo 'Posting dynamic failed: ' . $postResponse;
}
?>

The information returned by the interface is:2011Video dynamic release successful!
Why is the platform not displaying? Where did my problem lie?How should I adjust?

What is the best way to parse such files & use variables as well as their values? [closed]

//file1.php
<?php $config['english']['login'] = "login here";
$config['english']['logout'] = "logout";

//file2.php
<?php $anotherVar['english']['varone'] = "Some text in var one";
$anotherVar['english']['vartwo'] = "Some text in var two";

Now, consider a whole bunch of files with data like this. The variables can be anyting!

I need to create similar files for other languages.

I can use eval(), parse the file & explode with “=” etc. but the variable values can be in multiple lines, and some lines could be commented out, etc., which is a big headache if i just parse using file_get_contents or with file

What is the best way to achieve what i want?
I want to list all such variables from a given list of files in “english”
And then, for each file, I want to take the value of each variable in the file and then write out to files in other directories, replacing ‘english’ with ‘german’ in the variable name, for example, ( for ‘german’, i will do an api call to google translate & get the german translated text, for example)

Edited:
What i have tried so far: read file contents with every line into an array, and explode it with ‘=’, and then include the files as well & do an eval() , and get the German text etc. Very ugly way to do it. Am sure that there is a better way.

I have inherited this where for, english, for example, the strings are stored in the examples I have given above. Gettext or storing the strings in a database would have been better, but, sadly, this is what i have!

EDIT2
What I finally want to achieve is to write out to new files like this:

//file1German.php
<?php $config['german']['login'] = "login here (text actually translated to German)";
$config['english']['logout'] = "logout(text actually translated to German)";

//file2German.php
<?php $anotherVar['english']['varone'] = "Some text in var one(text actually translated to German)";
$anotherVar['english']['vartwo'] = "Some text in var two(text actually translated to German)";

PHP Mail Form Not Sending All Fields [duplicate]

I began using a short template to create a PHP Mail Form for a quick way of getting volunteer information. However, each time I attempt to add new fields: Phone, Address and Help (checkboxes) they don’t come through via PHP mail.

Instead they show up blank, but the email does go through.

I’ve swapped out $php_id for $id, as well as eliminated ajax. Neither worked. Additionally, I attempted using “id” vs ‘ajax_id’ and that would not make any difference.

I’m sure this is something stupid that I just don’t understand, but I would appreciate any assistance you could provide so I can get this up and running for a friend.

HTML:

<form action="/" method="post" class="contact_form" id="contact_form">
<div class="returnmessage" data-success="Your message has been received, We will contact you soon."></div>
<div class="empty_notice"><span>Please Fill Required Fields</span></div>
                <div class="first">
                <ul>
                <li>
                <input id="name" type="text" placeholder="Name">
                </li>
                <li>
                <input id="phone" type="tel" placeholder="Phone">
                </li>
                <li>
                <input id="email" type="email" placeholder="Email">
                </li>
                <li>
                <input id="address" type="text" placeholder="Address">
                </li>
                </ul>
                How can you help?<br>
                <p>
                <label>
<input type="checkbox" name="help" value="doors" id="help_0">Knock Doors</label>
                <br>
                <label>
<input type="checkbox" name="help" value="bank" id="help_1">Phone Bank</label>
                <br>
                <label>
<input type="checkbox" name="help" value="sign" id="help_2">Host Yard Sign</label>
                <br>
                <label>
<input type="checkbox" name="help" value="fund" id="help_3">Plan Fundraiser</label>
                <br>
                <label>
<input type="checkbox" name="help" value="meet" id="help_4">Set Up Meet and Greet</label>
                <br>
                </p><br>
                </div>
                <div class="last">
                <textarea id="message" placeholder="Message"></textarea>
                </div>
                <div class="grax_tm_button">
                <a id="send_message" href="#">Send Message</a>
                            </div>
                        </form>


PHP:

<?php

// Put contacting email here
$php_main_email = "[email protected]";

//Fetching Values from URL
$php_name = $_POST['ajax_name'];
$php_phone = $_POST["phone"];
$php_email = $_POST['ajax_email'];
$php_address = $_POST["address"];
$php_help = $_POST["help"];
$php_message = $_POST['ajax_message'];


//Sanitizing email
$php_email = filter_var($php_email, FILTER_SANITIZE_EMAIL);


//After sanitization Validation is performed
if (filter_var($php_email, FILTER_VALIDATE_EMAIL)) {
    
    
        $php_subject = "FORM SUBMITTAL";
        
// To send HTML mail, the Content-type header must be set
        $php_headers = 'MIME-Version: 1.0' . "rn";
        $php_headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
        $php_headers .= 'From:' . $php_email. "rn"; // Sender's Email
        
        $php_template = '<div style="padding:50px;"> ' . 
        '<strong style="color:#012345;">Name:</strong>  ' . $php_name . '<br/>'
        . '<strong style="color:#f00a77;">Phone:</strong>  ' . $php_phone . '<br/>'
        . '<strong style="color:#012345;">Email:</strong>  ' . $php_email . '<br/>'
        . '<strong style="color:#f00a77;">Address:</strong>  ' . $php_address . '<br/>'
        . '<strong style="color:#f00a77;">Help:</strong>  ' . $php_help . '<br/>'
        . '<strong style="color:#012345;">Message:</strong>  ' . $php_message . '<br/><br/>'
        . 'This is a Contact Confirmation mail.'
        . '<br/>'
        . 'We will contact you as soon as possible .</div>';
        $php_sendmessage = "<div style="background-color:#f5f5f5; color:#333;">" . $php_template . "</div>";
        
        // message lines should not exceed 70 characters (PHP rule), so wrap it
        $php_sendmessage = wordwrap($php_sendmessage, 70);
        
        // Send mail by PHP Mail Function
        mail($php_main_email, $php_subject, $php_sendmessage, $php_headers);
        echo "";
    
    
} else {
    echo "<span class='contact_error'>* Invalid email *</span>";
}

?>

Display the current events of a week with custom styling on page in WordPress

My current solution is to use Events Manager as that seemed to be the only free plugin enabling me to:

  1. Add and edit event names, start and end time (also enable lots of non-technical users to do so)
  2. Display multi-day events
  3. Embed the calendar within a page
  4. Style the calendar with custom CSS

But my client wants a week-view for the calendar and it it’s current form it has just gotten too small, with too many events.
Events Manger does not offer a week-view functionality.

I have done extensive research on this subject, installed and uninstalled countless WP calendars just to see how their functionality is not what it is claimed to be on their website.

That is why I am asking here:

Have you been using a free plugin or solution to display a week-view with said functionality?

I don’t have a problem coming up with my own solution, it just seems like overkill to handle a custom ACF type and sort through the data and display the current week etc.

If there is no out-of-the-box solution, how would you go about configuring ACF and displaying the events with PHP, sorted by date and time in a week-view.

I’m not good with PHP.

Laravel 9, Parent child bulk insert while replacing uuid to id

I have following table structure.

Table: movies

id uuid title
1 uuid-m01 movie 1

Table: categories

id uuid title
1 uuid-c01 category 1
2 uuid-c02 category 2

Table: movie_categories

id movie_id category_id uuid
.. …….. ……….. ……..

POST: …/api/movies/create

{
  "title": "movie 2",
  "category_ids": [
    "uuid-c01",
    "uuid-c02"
  ]
}

Models/APIs/v1/Movie.php

class Movie extends Model {
    ...

    public function movieCategories() {
        return $this->hasMany(MovieCategory::class);
    }

    ...
}

Models/APIs/v1/MovieCategory.php

class MovieCategory extends Model {
    ...

    public function movie() {
        return $this->belongsTo(Movie::class);
    }
    public function category() {
        return $this->hasOne(Category::class);
    }
}

Models/APIs/v1/Category.php

class Category extends Model {
    public function movieCategory() {
        return $this->belongsTo(MovieCategory::class);
    }
}

Controllers/APIs/v1/MovieController.php

public function store(MovieRequest $request) {
    try {
        $Post = $request->validated();

        $Movie = Movie::create([
            'uuid'  => Str::uuid(),
            'title' => $Post['title'],
        ]);

        $Movie->movieCategories()->create($Post['category_ids']);

        ...
    } catch (Throwable $th) {
        ...
    }
}

Now, the question is that in the category_ids I am passing the uuids of categories, but in the movie_categories table the column is accepting the id of the categories table.

When I am running the code, I am getting the following error:

{
  ...
  "error": {
    "code": "22003",
    "message": "SQLSTATE[22003]: Numeric value out of range: 1264 Out of 
                range value for column 'category_id' at row 1 (SQL: 
                insert into `movie_categories` 
                (`movie_id`, `category_id`, `uuid`, `updated_at`, `created_at`) 
                values 
                (3, uuid-c01, uuid-string, 2025-04-01 07:36:18, 2025-04-01 07:36:18))"
  }
}

Whereas the output should be:

Table: movie_categories

id movie_id category_id uuid
# 2 1 uuid-mc3
# 2 2 uuid-mc4

I know that there are various other ways to achieve this, such as: Observers, MySQL triggers, Fetching ids before inserting, but I was wondering if there is more appropriate(Laravel based) solution this problem.