0

Alright, so.
I am building a form with WordPress, (plugin) and want to loop over it as often as I want. I chose 10 to try it out.

So no inputs have been shown, even after I have the proper arguments. Still, nothing, all it showed me was "Item 10", which is the last time's section title. So the loop seems to work, but it isn't showing anything. And not every single one either!

it also showed me the description of the section. So I went and edited the section callback with the argument. And NOW I got some error message. It says "Notice: Undefined variable: amount in path/to/my-plugin/inc/Pages/Admin.php on line 106"

So, line 106 is where i made the callback for the section. (inside Class Admin)

        "callback" => function() { return $this->callbacks->listSection( $amount ); },

That's the call from this specific line. And this here is what the function does: (inside Class AdminCallbacks)

  public function listSection( $amount ) {
    echo "Check out number: " . $amount;
  }

So it has problems reading the variable.

The variable is set as an argument for the function inside the class Admin, inside this method.

  public function loopSettings( ) {
    for ($i = 1; $i <= 10; $i++) {
      $this->setSettings( $i );
      $this->setSections( $i );
      $this->setFields( $i );
    }
  }

I suspect the loop works since it shows me the number 10. But it doesn't work on everything. I do not know what else to provide for information, as this is a lot I assume.

I will add more if something is missing and is asked.
This is the Admin.php file, as well as my repo to this plugin if anyone wants to take a way deeper look into it.
The main files use for this are: Admin.php, SettingsApi.php, AdminCallbacks.php, SettingsLinks.php and infoWheel.php

https://github.com/Braweria/wp-plugin-learning/blob/main/inc/Pages/Admin.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.