From the course: WordPress Ecommerce: WooCommerce Plugins

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Validate settings

Validate settings

From the course: WordPress Ecommerce: WooCommerce Plugins

Start my 1-month free trial

Validate settings

- [Instructor] Now that we've added a 'Settings' page, it's time to update and save these settings. When we're adding settings, we created a function that didn't really do anything. It just called another function. I don't typically write code like that but I did do it in this case, because I knew what was coming next. We need to pass these exact same fields right here into another function and in the exact same format. This 'get settings' function here is actually going to serve two purposes. It's used to display the fields and it's also used to update them. This is called DRY programming. DRY means Do not Repeat Yourself. The idea is that if you ever have to repeat yourself, you're going to make a mistake. If you're going to declare fields in one function and update them in another, you're probably going to, at one point or another, update one and not the other. That's why I created this little function so I only have to update it in one place. In a previous video, we discovered a…

Contents