PHP code example of parfaitementweb / wordpress-starter-theme

1. Go to this page and download the library: Download parfaitementweb/wordpress-starter-theme library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

parfaitementweb / wordpress-starter-theme example snippets

 wp_nonce_field('contact_form') 


    namespace App;

    class ContactForm
    {
        public function __construct()
        {
            add_action('admin_post_nopriv_contact_form', [$this, 'handle_contact_form']);
            add_action('admin_post_contact_form', [$this, 'handle_contact_form']);
        }

        function handle_contact_form()
        {
            if (wp_verify_nonce($_POST['_wpnonce'], 'contact_form')) {
                $redirect = add_query_arg('form', 'success', site_url('contact'));
                wp_redirect($redirect);
            }
        }
    }

Add this in your `functions.php` under Custom Functions section.

    $contactForm = new \App\ContactForm();

### Validation
Our core had support for [Laravel Validation](https://laravel.com/docs/5.7/validation).

## Helpers
Here is below a list of additional helpers you can use anywhere in your theme.

#### Collections.
We added support for [Laravel Collections](https://laravel.com/docs/5.5/collections).

#### Arrays & Strings
You can use any **Arrays & Objects** and **Strings** Laravel Helper listed here: https://laravel.com/docs/5.7/helpers

#### Dump & Die
We've also add support for the famous `dd()` ("dump and die") helper function. This function dumps the variables using dump() and immediately ends the execution of the script (using exit).

## Custom Theme Functions

All PHP Class files placed under the `/app` folder will be autoloaded and accessible throughout your theme files. Use them for a convienent and testable place to store your custom logic.

    

    namespace App;

    class Custom
    {
        public function get_articles()
        {
            return [
                'article' => 'foo',
                'title' => 'bar'
            ];
        }
    }