php – Hide first image in product gallery on single WooCommerce product page

I have seen many people give solutions to this problem on this site, but none seem to work for me. I have already installed a lot of products on my site. I want all products to have a product image, but when I open a single product page, product images should only be loaded from the product gallery.

To be clear, each product has a product image and possibly a product gallery. If a product has a product gallery, the single product page for that specific product should not display the product image but only display the first gallery image with thumbnails of the rest of the gallery images. If a product does not have a product gallery, we must leave it as is.

Can anyone help me with this problem? Is there a hook I miss in my functions.php to achieve this?

javascript – Why doesn't my onclick work with a PHP variable?

I have this php code

                $ length = count ($ emotions);
for ($ i = 1; $ i <$ length; $ i ++) {
echo & # 39;

and this javascript (it's on the same page)

function changeValue(value){

What this does is add the value that I send to an entry, the value is that of the array (i) what I don't understand is that it doesn't work if it doesn't give error, if i change the value i send to "$ i" Everything works fine, so i don't understand. Help me please. Thank you

php – Does WordPress disable system functions?

WP itself does not deactivate these functions. This is a security mechanism for one of your plugins or theme that disables them. It is common to hide malicious code by encoding it, then decoding it and executing it when the site loads.

You can deactivate plugins one by one until the function works to determine which one deactivates it. Logically, any security-related plugin would probably be the one that does it, and for good reason, that is, Wordfence, Sucuri, etc.

php – Laravel – list of elements refreshes data with ajax?

I have a project whose backend is laravel (API) and I have a simple front with the blade model engine.

I have a list of cars and the user has a button that can turn them on and off.

Right now, with jquery, I'm making a put call to update the status of this item (car) and to update the information, I'm doing it with jquery.


    var id_site_promocion = $("input(name=id_site_promocion)").val();
    var activo = $("input(name=activo)").val();
    $('.btn-submit').prop('disabled', true);


        url:'/api/coches/' + id_site_promocion ,
        data: {
            activo : activo,

        error:function (data) {


For an element it does not seem "bulky" but if it were more than one element? Would you do it like this or would you make an AJAX call with GET and refresh the table?

I have the same doubt to make a GRID of elements where you can modify "online" an element and save these modifications, create a form for each element and the button of each form which is a submission?

Thank you

Easiest way to call a function from a python script and execute it in PHP

I'm using the Laravel framework and I'm just experimenting with something.
Is there a way to use a function from a python script and use it in a php script?

By the way, my python script contains several functions.
And the function I need requires parameters.
Should I isolate the necessary function in another script?

Help this beginner! Thanks in advance.

php – Get 3 accounts from a table

I'm trying to get 3 results.

Everything, chk = & # 39; Y & # 39 ;, chk = & # 39; N & # 39;

What can I do to improve this code?

$Val = explode(",", urldecode($_POST('Val')));

$addSQL = '';
if (!empty($Val(2))) {
  // parrent.guid
  $addSQL.= " and up_cls='".mysqliChkData($Val(2))."'";

$getSQL = "Select guid From tablee Where 1=1".$addSQL." GROUP BY guid";
$listData = $sql->Select($getSQL);
$arr('allNum') = $listData('num');

$getSQL = "Select guid From tablee Where `chk`='Y'".$addSQL." GROUP BY guid";
$listData = $sql->Select($getSQL);
$arr('openNum') = $listData('num');

$getSQL = "Select guid From tablee Where `chk`='N'".$addSQL." GROUP BY guid";
$listData = $sql->Select($getSQL);
$arr('closeNum') = $listData('num');

Most chk will be "Y", activated.

Same recordings but different languages ​​will have the same guid.

Children's tables have up_cls column and $addSQL.

Few tables don't have chk column because no need to deactivate.

  `lang` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `chk` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date` datetime DEFAULT NULL,
  `guid` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `modify_date` timestamp NOT NULL DEFAULT '1970-12-31 16:00:00' ON UPDATE CURRENT_TIMESTAMP,

Select method

function Select($sql, $act = null) {
  global $mysqli;
  $reData = array();
  $reData('data') = array();

  $rs = mysqli_query($mysqli, $sql);
  if ($rs) {
    $thisNum = $rs->num_rows;
  else {
    $thisNum = 0;
  $reData('num') = $thisNum;
  if ($thisNum != 0) {
    while ($row = $rs->fetch_assoc()) {
      $reData('data')() = $row;

  return $reData;

Dynamically call static methods in php

Hello, I would like to know if in php there is a way to dynamically call the static methods of a class. the only need would be to reduce the amount of line of code.
Currently, I do it this way

php – Limit number of regular expressions

If it is a question of limiting a number, the simplest would be:

if ($numeo > 0 && $numeo <= 1000) {
    //Algo aqui é executado

You don't need a regular expression for something as simple as that, now if the goal is to apply the regular expression to another "group", you need to parse what you really want and what channel you want to match / marry, because I can give a regex answer that will actually break the logic of your existing regex that already exists.

BBC Code Dice Roller in PHP

I don't program PHP too often. I wanted to write a bbc code analyzer for my forums. What do you see that could be improved?

You can see the code live here:


  • Basic Rolls: NdM: Roll N dice with M sides. i.e. 3d20 rolls three twenty sided dice.
  • Add Modifiers: 1d20+1 or 1d20-5: Add (or subtract) the indicated amount from the roll
  • Reroll Low Results: 1d20r3: Roll 1d20, but keep re-rolling if the result is 3 or lower.
  • Keep Highest Rolls: 4d6^3: Roll 4d6, but keep only the 3 highest results, discarding the remainder.
  • Keep Lowest Rolls: 4d6v3: Roll 4d6, but keep only the 3 lowest results, discarding the remainder.
  • Note: You cannot have ^ and v in the same roll -- 3d6^1v1 is invalid.
  • Compound Rolls are OK: 3d6-2d6-5+3: Roll 3d6, subtract 2d6, subtract 5, add 3
  • Whitespace is ignored: 1 d 6 and 1d6 are the same thing. '1 d 2 0' will work too, all white space is completely ignored
  • Syntax Errors Any syntax errors cause the entire roll to be considered invalid.


"; } ?> = 2 && $capture(1)) ? $capture(1) : 0; preg_match('/v(d+)/', $rollToken, $capture); $keepLowCount = (sizeof($capture) >= 2 && $capture(1)) ? $capture(1) : 0; preg_match('/^(d+)/', $rollToken, $capture); $keepHighCount = (sizeof($capture) >= 2 && $capture(1)) ? $capture(1) : 0; $detailText .= (empty($detailText) ? "" : "
") . "" . ($rollSign == -1 ? "-" : "") . "$rollToken Results: "; $subTotal = 0; $rollResults = array(); if ($rerollThreshold >= $diceType) { $detailText = $INVALID_ROLL_ERROR; break; //Future note: This should break out of the big foreach ($rollTokens) loop } for ($k = 0; $k < $numberOfDice; $k++) { array_push ($rollResults, rand($rerollThreshold+1, $diceType)); } if ($keepHighCount > 0 || $keepLowCount > 0) { if ($keepHighCount > 0) { $keepCount = $keepHighCount; $selectorFunction = "max"; } else { $keepCount = $keepLowCount; $selectorFunction = "min"; } if ($keepCount > $numberOfDice) { $detailText = $INVALID_ROLL_ERROR; break; //Future note: This should break out of the big foreach ($rollTokens) loop } $keep = array(); $discard = array(); foreach ($rollResults as $key => $val) { $discard($key) = $val; } for ($k = 0; $k < $keepCount; $k++) { $highest = call_user_func($selectorFunction, $discard); $highestIndex = array_search($highest, $discard); array_push($keep, $highest); unset($discard($highestIndex)); } foreach ($rollResults as $roll) { $keepIndex = array_search($roll, $keep); $discardIndex = array_search($roll, $discard); if ($keepIndex !== False) { $detailText .= "$roll "; $subTotal += $roll; unset($keep($keepIndex)); } else { $detailText .= "$roll "; unset($discard($discardIndex)); } } } else { foreach ($rollResults as $rollResult) { $detailText .= "$rollResult "; $subTotal += $rollResult; } } $subTotal *= $rollSign; $detailText .= " (Total = $subTotal)"; $rollTotal += $subTotal; } } } else { $detailText = $INVALID_ROLL_ERROR; $rollTotal = "0"; } $detailText .= "
Total: " . $rollTotal; $detailText = "Dice Roll: " . $inputClean . "
$detailText"; return array('input'=>$inputText, 'total'=>$rollTotal, 'detailText'=>$detailText); } ?>

object orientation – How to create a recursive association in PHP POO or in Portuguese

Thank you for contributing to Stack Overflow in Portuguese!

  • Make answer the question. Get into the details of your solution and share what you've discovered.

But to avoid

  • Ask for clarification or details on other responses.
  • Make statements based solely on your opinion; occasional references or previous experiences.

For more information, see our tips for writing correct answers.