TUS-PHP | Upload-Metadata not being passed to backend PHP

I have a vry simple question which i cannot figure out for a while.

I have simple setup of UPPY on front end and TUS-PHP on my backend on AWS EC2 free trier.

The issue is that backend upload.php does not get the custom meta information provided by uppy on upload. Meanwhile in devtools i can see the Upload-Metadata request headers/

This is a part of code how i send a custom data:

uppy.on('file-added', (file) => {
    
uppy.setFileMeta(file.id, {
    relativePath: 'your/relative/path', // Set your custom relative path here
    customField1: 'value1', // Set your custom field value here
    customField2: 'value2'  // Set your custom field value here
  });

........

uppy.setFileMeta(file.id, {
    relativePath: 'your/relative/path', // Set your custom relative path here
    customField1: 'value1', // Set your custom field value here
    customField2: 'value2'  // Set your custom field value here
  });

And this is headers im getting in my php (with getallheaders())

Array
(
    [Host] => 54..***.***.174
    [Connection] => keep-alive
    [Content-Length] => 365387
    [Tus-Resumable] => 1.0.0
    [X-CSRF-TOKEN] => {{ csrf_token() }}
    [Upload-Offset] => 0
    [User-Agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
    [Content-Type] => application/offset+octet-stream
    [Accept] => */*
    [Origin] => http://54.***.***.174
    [Referer] => http://54.***.***.174/
    [Accept-Encoding] => gzip, deflate
    [Accept-Language] => en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7
)

Can you please suggest how can I solve this issue.

Thanks

Custom metadata (Upload-Metadata) is not being passed to TUS-PHP backend php file

ACF & Woocommerce: Automatically Set Product Variations and Attributes Based on ACF Repeater Fields

I’m working on a WooCommerce project where I need to automatically create product variations based on ACF (Advanced Custom Fields) repeater fields. The repeater fields contain two subfields: aantal_kms (distance) and prijs (price). I want each variation to be named with the distance value and to have the correct attributes set.

Here is what I have done so far:

I have set up the ACF repeater fields on the product edit page.
I wrote a function to create the product variations on save, using the data from the ACF repeater fields.

how it looks: Screen

The variations are being created, but the titles of the variations are not set correctly. Each variation should have a title that includes the distance value and should have the corresponding attribute set. This makes the varitions invalid so it doesnt show on the front end.variation name

Here is the code I’m currently using:

function add_variations_from_acf_fields($post_id) {
    // Check if this is a product and we're not in an autosave
    if (get_post_type($post_id) !== 'product' || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
        return;
    }

    // Get the repeater field data
    $acf_repeater = get_field('Deelnameprijzen', $post_id);

    // Check if there is any data in the repeater field
    if ($acf_repeater) {
        // Load the product
        $product = wc_get_product($post_id);
        
        // Delete existing variations
        if ($product->is_type('variable')) {
            $existing_variations = $product->get_children();
            foreach ($existing_variations as $variation_id) {
                wp_delete_post($variation_id, true);
            }
        } else {
            // If the product is not already a variable product, change its type
            wp_set_object_terms($post_id, 'variable', 'product_type');
            $product = wc_get_product($post_id);
        }

        // Prepare attributes
        $distances = array();
        foreach ($acf_repeater as $repeater_item) {
            $distances[] = $repeater_item['aantal_kms'];
        }

        // Ensure distances are unique and filter out any unexpected data
        $distances = array_unique(array_filter($distances));

        // Set the 'Aantal Kms' attribute
        $product_attributes = array();
        $product_attributes['pa_aantal_kms'] = array(
            'name'         => 'Aantal Kms',
            'value'        => implode(' | ', $distances),
            'position'     => 0,
            'is_visible'   => 1,
            'is_variation' => 1,
            'is_taxonomy'  => 0
        );
        update_post_meta($post_id, '_product_attributes', $product_attributes);

        // Create new variations based on the repeater field data
        foreach ($acf_repeater as $repeater_item) {
            $variation = new WC_Product_Variation();
            $variation->set_parent_id($post_id);

            // Set variation attributes
            $variation_attributes = array(
                'pa_aantal_kms' => $repeater_item['aantal_kms']
            );
            $variation->set_attributes($variation_attributes);

            // Set variation price
            $variation->set_regular_price($repeater_item['prijs']);

            // Save the variation
            $variation->save();
        }
    }
}
add_action('save_post', 'add_variations_from_acf_fields', 10, 1);

I ensured the variation title includes the distance value.
The terms are created if they don’t exist.
The attribute values are set for each variation.

I am building a Bulk Messaging App. How to Handle Concurrent Email Sending in a PHP Bulk Messaging System? It sends out but have to queue all in a row [closed]

I am currently developing a bulk messaging system using PHP. My main challenge is handling concurrent email sending efficiently. When multiple users (e.g., 10 or more) initiate the sending process at the same time, the system processes emails sequentially, creating a long queue. This becomes problematic as the number of users grows, leading to significant delays. For instance, with 1000 users, it might take months for all emails to be sent.

Is there a guide out there i can read up to help.
Anyone with experience building bulk messaging system for multiple users.
My app works well, but i did it in a way that sequentially queues all in a DB before sending

Currently, when a user initiates a message, I insert it into a queue table in the database. I have a cron job that runs periodically to process these queued messages. The cron job goes through the messages in the table sequentially and sends them one by one

// Inserting message into queue table
function queueMessage($message) {
    // Database insertion logic here
}

// Cron job processing queued messages
function processQueue() {
    $queuedMessages = getQueuedMessages(); // Retrieve messages from the queue table

    foreach ($queuedMessages as $message) {
        sendEmail($message['email']);
    }
}

curl: (47) Maximum (50) redirects followed when configuring nginx ratelimiting

so I’ve tried adding rate-limit handeling in my nginx configuration which seemd to have broken things.
I’ll share 2 nginx configuration versions, the first one without the ratelimiting part which works fine and the second one with the ratelimit part added.
The Confiug with the ratelimit part added, causes this too many redirects error.

Without Ratelimit (Working)

server {
    listen 80;
    server_name genefit.cc www.genefit.cc;
    root /var/www/html;
    index index.htm index.html index.php;

    charset utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    access_log off;
    error_log /var/log/nginx/error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~* /(phpinfo.php|php_info.php|info.php|_profiler/phpinfo.php|.ht) {
        deny all;
    }
    
    # Allow POST on specific endpoints
    location ~* ^/(velocity/|joinify/|joinify2/|leavify/|checky/|queuebot/)$ {
        if ($request_method !~ ^(POST|GET)$) {
            return 405;
        }
    }

    # Restrict methods other than GET and provide a 405 error for other locations
    location / {
        if ($request_method !~ ^(GET)$) {
            return 405;
        }
    }

    # Error page configuration
    error_page 300 301 302 303 304 305 306 307 308 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error.php?code=$status;

    location ~ /error.php$ {
        include fastcgi_params;
        root /var/www/html/;
        #try_files $uri $uri/ =404;
        fastcgi_pass genefit.cc:9000;
        fastcgi_index error.php;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;

        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param QUERY_STRING $query_string;
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass genefit.cc:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}

With ratelimiting (not working):

server {
    listen 80;
    server_name genefit.cc www.genefit.cc;
    root /var/www/html;
    index index.htm index.html index.php;

    charset utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    access_log off;
    error_log /var/log/nginx/error.log error;

    sendfile off;

    client_max_body_size 100m;

    # Deny access to certain files
    location ~* /(phpinfo.php|php_info.php|info.php|_profiler/phpinfo.php|.ht) {
        deny all;
    }

    # Global rate limiting configuration
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

    # Apply rate limiting globally
    location / {
        limit_req zone=one burst=5;
        limit_req_status 429;

        # Only allow POST on specific endpoints, otherwise allow GET only
        set $allowed_endpoint 0;
        if ($uri ~* ^/(velocity/|joinify/|joinify2/|leavify/|checky/|queuebot/)$) {
            set $allowed_endpoint 1;
        }

        if ($request_method !~ ^(GET)$) {
            if ($allowed_endpoint = 0) {
                return 405;
            }
        }

        try_files $uri $uri/ =404;
    }

    # Error page configuration
    error_page 300 301 302 303 304 305 306 307 308 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error.php?code=$status;

    location ~ /error.php$ {
        include fastcgi_params;
        root /var/www/html/;
        fastcgi_pass genefit.cc:9000;
        fastcgi_index error.php;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;

        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param QUERY_STRING $query_string;
    }

    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass genefit.cc:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}

I have tried quite a bit myself like moving block around so that they correctly apply in order as i’m aware that nginx look for the first match and if it finds a hit, it don’t look future.

The mistake in the php code when I create Templeate for WordPress

Warning: Trying to access array offset on value of type null in /var/www/u2016481/data/www/miostagroup.com/wp-content/themes/miosta/page-articles.php on line 32

but my code is

 if (!defined('ABSPATH')) {
  die();
}

$id = get_the_ID();
$event = get_field('content', $id);
/// print_r($home);
?>
<?php get_header(); ?>
<main class="main" data-page="home" id="smooth-content">
  <!-- header -->
  <?php get_template_part('template-parts/header/header_main'); ?>

  <div class="main__wrap">
    <div class="events__cover">
      <div class="events__cover-content activation">
        <h2 class="cover__content-title title__logo title__logo--57">
      32 line    <?php echo preg_replace("#*{2}(.*?)*{2}#", "<sup>$1</sup>", $event['title']); ?>
        </h2>
        <h1 class="cover__content-title title__logo title__logo--90">
          <?php echo get_the_title($id); ?>
        </h1>
      </div>
      <span class="events__cover-circle activation"></span>
      <span class="events__cover-circle activation events__cover-circle--type2"></span>
    </div>
    <section class="events__content">
      <?php
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $query = new WP_Query(array(
        'post_type' => 'post',
        'posts_per_page' => 6,
        'paged' => $paged
      ));
      if ($query->have_posts()) {
      ?>
        <div class="events__grid activation">

          <?php foreach ($query->posts as $k) {  ?>
            <?php
            $field = get_field('content', $k->ID);
            $year = date('j F Y', strtotime($k->post_date));
            ?>
            <div class="events__card" itemscope itemtype="http://schema.org/Event">
              <div class="events__card-photo">
                <picture>
                  <?php if (isset($field['img_prev']) && $field['img_prev']) { ?>
                 <?php echo avif_convert($field['img_prev']); ?>
                    <img class="events__card-img active" src="<?php echo $field['img_prev']['sizes']['medium']; ?>" alt="<?php echo ($field['img_prev']['alt'] ?? ""); ?>" data-tab="h" itemprop="image">
                  <?php } //end if 
                  ?>
                </picture>
              </div>
              <div class="events__card-content">
                <span class="events__card-date" itemprop="startDate"><?php echo month_translate($year); ?></span>
                <h2 class="events__card-title" itemprop="name"><?php echo ($k->post_title ?? ""); ?></h2>
                <a class="button main__products-link active" href="<?php echo get_permalink($k->ID); ?>" itemprop="url">
                  <span class="button__mask2"><?php pll_e('Подробнее'); ?></span>
                </a>
              </div>
            </div>
          <?php } //end foreach 
          ?>


        </div>



        <div class="events__pagi">

          <?php

          $big = 999999999; // Число, которое гарантированно больше числа всех страниц
          $pagination = paginate_links(array(
            'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
            'show_all' => true,
            'prev_next' => false,
            'format' => '?paged=%#%',
            'current' => max(1, get_query_var('paged')),
            'total' => $query->max_num_pages,
            'type' => 'array',
          ));

          if ($pagination !== null) {

          ?>
            <a class="events__pagi-btn" href="<?php echo get_previous_posts_page_link(); ?>" aria-label="Предыдущая страница">
              <svg width="18" height="7">
                <use xlink:href="#icon-pagi-left">
                </use>
              </svg>
            </a>

            <ul class="events__pagi-list">

              <?php
              foreach ($pagination as $page) {
                $page = str_replace('page-numbers', 'events__pagi-link', $page);

                if (strpos($page, 'current')) {

                  $page = str_replace('current', 'active', $page);

                  echo '<li class="events__pagi-item">' .
                    $page
                    . '</li>';
                } else {

                  echo '<li class="events__pagi-item">' .
                    $page
                    . '</li>';
                }
              }
              ?>


            </ul>

            <a class="events__pagi-btn next" href="<?php echo get_next_posts_page_link(); ?>" aria-label="Следующая страница">
              <svg width="18" height="7">
                <use xlink:href="#icon-pagi-right">
                </use>
              </svg>
            </a>
          <?php } //end if $pagination null 
          ?>

        </div>
      <?php } //end if $query 
      ?>
      <span class="events__grid-circle"></span>
    </section>

  </div>
  <!-- footer -->
  <?php get_template_part('template-parts/footer/footer_main'); ?>
</main>
<?php get_footer(); ?>

What is wrong
It is a cooperated code from other web page with the same meaning is the same as in the other,but I have to do some kind of information
I did not understand what I need to do could you help me please?

Questions regarding Php Laravel scss file [closed]

So i am working on modifying the websites of my company. Issue is that the css that may need to modify is in a scss file. I cant seem to locate this file in my project.

Inspect]1

Now when i want to search for the scss file in studio code. It does not seem to be found, and hence i am unsure how to make modifications on the websites css.

how to remove map values from an array in PHP

I have this array in PHP:

Array ( [0] => Array ( [time_book_start] => 11:30 ) 
        [1] => Array ( [time_book_start] => 9:00 ) 
       )

I just need to output 11:30 and 9:00 in this manner:

['11:30','9:00']

I have used json_encode, sprintf, implode etc without success. Please help me.

downloaded zip with ZipArchive PHP which outputs strange strings

        if (ob_get_length()) {
            ob_end_clean();
        }

        $checkedValues = $img;
        $zipname = 'file.zip';
        $zip = new ZipArchive;
        
        // echo $zip.'<br>';

        if ($zip->open($zipname, ZipArchive::CREATE) === TRUE) {
            echo $zipname.'<br>';
            foreach ($checkedValues as $value) {
                if (file_exists($value)) {
                    echo 'Path: ' . htmlspecialchars($value) . '<br>';
                    echo 'Path: ' . basename($value) . '<br>';
                    // $zip->addFile($value);
                    $zip->addFromString(basename($value),  file_get_contents($value));
                } else {
                    echo 'File not found: ' . htmlspecialchars($value) . '<br>';
                }
            }
            $zip->close();

            // Pastikan output buffering dimatikan sebelum mengirim header
            if (ob_get_length()) {
                ob_end_clean();
            }

            header('Content-Type: application/zip');
            header('Content-disposition: attachment; filename="'.$zipname.'"');
            header('Content-Length: ' . filesize($zipname));
            readfile($zipname);

            // Hapus file ZIP setelah didownload
            unlink($zipname);
        } else {
            echo 'Failed to create zip file.';
        }

can anyone help me explain why when this function is executed it will output a strange string like this:

�w�CB�ti�:���of͝��+���O�o�����ɻ�λ�g��s�'��j��T.���g��*� u�e9���vpz��T��#^oO���#���#��*j�|$D��{۸B���?z�� �9����۶�8ȅ���ܻN%D%t�;����]8o���������.�t���k�oP��[��.��K�.^�t��������|� ��ϯ�׳���N+�66�:�R�O:��MNQ[�w7��302qq����KHJI˼PVQUSi������;8:9C<��}�~��?��}��9�JH���������_PXTQYU�����5����wtvu ����OL�gf����,�lm����S��#��K�)��ø������˗._���.D�G�{��<~z���5���"o��*�f����!��Ig�1H��Sl�k�?B��#����Ud�)��5.<��҅��w�@p:�<��6��y���?�������?�������?�������?�������?��3��VO���?�OWh�����.�Qv��.���������YSY��p�o������S/}y":b���#��.���_�>�mg]��^Ԗ�����2�����;u���^�o����:��"�S�9��f�a�������/���?�K�G����94{�m{��ӀB���@��6��I.��C�W^W��.�� ^O�����c-��6���s�����]��?C�����ߔ*�CYv��?�[���y���T��Sz�*�A��0� b�K��&���|V1�@ =P� �[j�o�s���8�ߎ�i/:�i�f���ŕ�8a� xN=�gp���9�3�A��J��o8U��8�.n與sz�E��q�b�~1rs����j�a�J�Y��$��W:V�����QZ�薭��H�����b?$��f���鐎5��,f�mlN��ϠW�P��l��~�=�'���jkN� rX���d �'8��k�t��S�o�G�ilՎӚ3�D͙ǙT�)�l������Ӡ�w}���^�)K$2J�_?������W�X_ qn�qb�R�n���d�Ir�����8F����]��d�8��#�x��t.��$�ޙ��%�sM��1��qM4k�S�F���R���偨��� 9��}��)���l�g�0�j� ��u�k��sx�뢞ΥG�i5,�5�D��s@z��B���Ư�d���”�9�$|:~�2EӇ�v�j�#ϗ3��?���9� 4}M��=�# {BZ�Q�^iB���s[sҧ�����E.����.�~�>Rc�C9̑���!�1A������4��&Ooq���A���mM����� >�� �4��Lq��^ ��%�4�’�jOMZ}�E군�_}n_����1-�1j{������t��@����� &�”a�p�K�����#Ч�-���謊�����AŜɖ�<���ü�N��F�th��R � #k=�P���X��O6���+,=������J���E.�6zr��0E�j9���BUq.�.��v��w�gfI�FT���G��I�y�/#’�3i��}#� �_tK�V�=8�0�Ř������9Y؇+~������B�����Mҁ�7Y�u����,���eGea�#����g�bK)=����ʷ��T��)�K�᳜�a4HQ��j���P���J³ �Q��ͦ��/���JX#�j��yd&V �����z��{���)�g@�׬m~_J(�5��U[�M�!��;=uۚ!�%�M�$�XO�@���/��˷j�!����հ���x%�Ҥ�B?s8�BM ���uoF�8uE�)�~�;�������(“|�?���T=���@��� ���:;�i�s�7 q�R��.��_�g�8�u(���l�”|���k5����#��{�7�1Z����Y’:I�|&�� QU�+�,�o�;}Ej�iѹ��Ć�eL��a����J>Ӻ��䀆��%�W���Ս��}��Ā����K��!ly� �~du�S�M �~囋�0GgR�i�����<�ӲЮ��S�w��r�’5����gd����Gg~ �����8�y~.��3���S|H��|�M-�|�}vX>mvX��P&Cde5�s.:�3F�2����c��a�½���L��-AgH@@0ٙ|�x’e�p=3 �œP0mǗra��Ηc��w�c�X[ZXL-np?�n�$��|G’��j�Cj�A)��)x��F��ʭ������gv���{:K��>�p!;g��1O-�9J���p����Xm^���k�>�gaP���r~%”WuUD���a�V;a”��u���8��{��p~�6>�A��g�U=���l�y�t���[��������5�rs��+�����&y��1�o��b]a����@���Ķ��O夵ŧQ;g<4��e%ǡ�9�oۄ<Z�0�����ъ� �̳”�����@2���a�k����Yf��Q}5V8p�d7Y,͝���ˣ��ɏ�U��,%Hz�y���-����!��L��nU����@����]�XuX�R�%v>�i���)=���^�s�����������33L��ئ#(t���+���nwB޺�Ǻ��R�p��#��_m��� F1�����r����<,���E�_a .�Н%�9���x�߼�)�������@?X��e<��%����~�7�e?I�VOL8e��tp��&���y�)l��y.��� ~��Z�udl��[i�ϓZ��m����IY��^W��2+�a�9��~�+��L��Qd��rW0[ N c�8 � /��I���~��6�!�fV,�N�(1���)�e�HcC��IY��oi�[����W��E��狺)̛ǣ,�UdUT��lq��7����z�_x�z~�V{g-Rpg�l�F� Y2��c�lDyF�8��߯=�/�oX��͔��[8�CTA��Xm�dDcϼ��t����V������gx��^��z(Y�<���|��GA��g��9���K���D^7>I>ޜR����%�O�X�j#��S��*{՜F��4�Q�~���:�|���Y�y�t8��hu�3�_瀌

Laravel Mail Attachment: Error while sending attachment

I have communication service to handle/send all the communication throughout the application. When I try to send an e-mail with attachment of size more than 100KB gives me below SQS exception. I am not able to understand why I am getting the exception.

I have changed php.ini for both cli/apache

post_max_size = 20M

upload_max_filesize = 20M

Exception Details;

Mail-Exception: [“[object] (AwsSqsExceptionSqsException(code: 0): Error executing “SendMessage” on “https://sqs.ap-south-1.amazonaws.com/**/dev-“; AWS HTTP error: Client error: POST https://sqs.ap-south-1.amazonaws.com/******/dev-**** resulted in a 400 Bad Request response:n<ErrorResponse xmlns=”http://queue.amazonaws.com/doc/2012-11-05/”>SenderI (truncated…)n InvalidParameterValue (client): One or more parameters are invalid. Reason: Message must be shorter than 262144 bytes.

I am getting undefined variable from the ADmin area in WordPress [duplicate]

/home/trave488/cambridgenigeria.com.ng/wp-content/plugins/ijmbcenters/ijmbcenter.php on line 201

Warning: Undefined variable $entry_id in /home/…….php on line 201

Here is my code.

function custom_users_table_column($value, $column_name, $user_id) {
     $user = get_userdata( $user_id );
       if ( 'admission_letter' == $column_name ) {
    if( check_parent_guardian_form_submit($user_id)){
        if(get_user_meta($user_id,'entry_id',true)){
            $entry_id=get_user_meta($user_id,'entry_id',true);
            $status = get_gf_form_fields_value_by_id($entry_id,225);          
        }
    }else{
        $status=get_user_meta($user_id, 'registration_payment_status', true);
    }
    if($status=='Paid'){
        return '<button class="submission_letter" data-user_id='.$user_id.' data-entry_id='.$entry_id.'>Mail Admission Letter</button><button class="view_submission_letter" data-user_id='.$user_id.' data-entry_id='.$entry_id.'>View Admission Letter</button>';
    }else{
        return 'Not Paid';
    }

}

I am using Gravity Form plugins to echo the form for the form to be printed by users.

The issue is error handling if the field is empty, but I don’t know how to go about it, when a field is empty is supposed to be blanked,and not to bring it error.

How to deactivate plugin when WooCommerce plugin is not active and show error to user?

Here is my custom plugin code

custom-plugin.php code

include_once FBPE_PLUGIN_PATH . 'inc/class-free-bulk-price-editor.php';
register_activation_hook(__FILE__, array('Free_Bulk_Price_Editor', 'activate'));
register_deactivation_hook(__FILE__, array('Free_Bulk_Price_Editor', 'deactivate'));

class file code:

class Free_Bulk_Price_Editor {
    public static function is_woocommerce_active() {
        return class_exists('WooCommerce');
    }

    public static function activate() {
        if (!self::is_woocommerce_active()) {
            deactivate_plugins('free-bulk-wp-price-upgrade/free-bulk-wp-price-upgrade.php');
            wp_admin_notice( 'There was an error!', [ 'type' => 'error' ] );
            return;
        }
    }
}

This not work according to my requirements I want my plugin only active when WooCommerce is active.

I want to build custom wordpress plugin and want my plugin is active only when WooCommerce is active other wise show error to user that WooCommerce is required to active this plugin.

PHP / XPath: Selecting namespaced elements

I have the following XML and I would like to select the xt:vars nodes with XPath in PHP.

<xt:locale xmlns:xt="http://www.example.net/xt">
    <xt:vars title="Invitation default" type="email" language="EN">
        <xt:param name="description">Default invitation mail added to event on creation.</xt:param>

    </xt:vars>
    <xt:vars title="Einladung" type="email" language="DE">
        <xt:param name="description">Einladungsemail</xt:param>
    </xt:vars>
</xt:locale>

I am loading the XML file with DOMDocument and would like to select the nodes with DOMXPath.

$template_content = file_get_contents($template_file);
$xml = new DOMDocument("1.0", "UTF8");
$xml->preserveWhiteSpace = false;
if ($xml->loadHTML($template_content)){
    $xpath = new DOMXPath($xml);
    $xpath->registerNamespace('xt', 'http://www.xelos.net/xt');
    $query = "//locale/vars[@language='{$language}']";
    $entries = $xpath->query($query);
    $xmlContent = '';
    foreach($entries as $entry) {
        $xmlContent = $entry->ownerDocument->saveXML($entry);
    }
    if ($xmlContent) {
        $template_content = $xmlContent;
        dump($template_content);
    }
}

I am not sure what the correct XPath selector is to grab the correct xt:vars node.

Bind for 0.0.0.0:3306 failed: port is already allocated

i’m a newbie at this and im trying to set laravel sail to my laptop using ubuntu terminal. there’s no problem in installation but when i use the command sudo ./vendor/bin/sail up
i get this error:

Error response from daemon: driver failed programming external connectivity on endpoint exapp-mysql-1 (8b37fca8d11d52f0456d65180990c572d9d7b39a54944845ee6ba7f1634a2d59): Bind for 0.0.0.0:3306 failed: port is already allocated

i know i need to change the port that it selects and tried to find ways in many blogs but couldnt seem to find a solution that solves my problem yet.

i tried to get rid of zombie process’, tried to stop container and deleting it, i tried restarting docker but they didn’t solve my problem. i’d appreciate any idea and help i could get.

Adding php-imagick extension to Alpine Docker container fails

I try to add the imagick php extension to my Docker container:

FROM php:8.3-fpm-alpine AS base

RUN apk add --update --no-cache --virtual .build-deps $PHPIZE_DEPS imagemagick imagemagick-dev 
    && pecl install imagick 
    && docker-php-ext-enable imagick 
    &&  rm -rf /tmp/pear 
    && apk del .build-deps

The process fails with the following error:

14.37 PHP-Parser-5.0.0/phpstan.neon.dist
14.38 Saved /tmp/pear/temp/imagick/ImagickPixel_arginfo.h
14.38 Parse /tmp/pear/temp/imagick/Imagick.stub.php to generate /tmp/pear/temp/imagick/Imagick_arginfo.h
14.41 In /tmp/pear/temp/imagick/Imagick.stub.php:
14.41 Unterminated preprocessor conditions
14.41 make: *** [Makefile:196: /tmp/pear/temp/imagick/Imagick_arginfo.h] Error 1
14.41 ERROR: `make INSTALL_ROOT="/tmp/pear/temp/pear-build-defaultuserAclDeF/install-imagick-3.7.0" install' failed
------
failed to solve: process "/bin/sh -c apk add --update --no-cache --virtual .build-deps $PHPIZE_DEPS imagemagick imagemagick-dev     && pecl install imagick     && docker-php-ext-enable imagick     &&  rm -rf /tmp/pear     && apk del .build-deps" did not complete successfully: exit code: 1