PHP code example of gebruederheitz / wp-meta-fields

1. Go to this page and download the library: Download gebruederheitz/wp-meta-fields 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/ */

    

gebruederheitz / wp-meta-fields example snippets


use Gebruederheitz\Wordpress\MetaFields\MetaForms;

function render($value) 
{
    // Use the "render{$type}" static methods:
    MetaForms::renderTextInputField('ghwp_favourite_color', $value, 'Favourite color');
    // ...or the more verbose "make{$type}" methods, which support chaining:
    MetaForms::makeTextInputField()
        ->setName('ghwp_favourite_food')
        ->setValue($value)
        ->setLabel('Your favourite food')
        ->render();
}

MetaForms::updateTextDomain('my-textdomain');
// or
MetaForms::getInstance()->setTextDomain('my-textdomain');

class UsesMetaForms
{
    public function __construct() 
    {
        add_action('admin_enqueue_scripts', [$this, 'onAdminEnqueueScripts']);
    }
    
    public function onAdminEnqueueScripts()
    {
        wp_enqueue_media();
    }
}

// Make sure to end with a trailing slash
MetaForms::updateOverridePath('partials/vendor/gebruederheitz/meta-forms/override/')
// or
MetaForms::getInstance()->setOverridePath('partials/vendor/gebruederheitz/meta-forms/override/');