PHP code example of uwebpro / wordpress

1. Go to this page and download the library: Download uwebpro/wordpress 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/ */

    

uwebpro / wordpress example snippets


(new \UWebPro\WordPress\Duplicator());

// Using Advanced Custom Fields or need to exlude post types?
(new UWebPro\WordPress\Duplicator())->exclude(['acf-field-group']);

$ajax = new \UWebPro\WordPress\WPAjax();

$ajax->setAction('load_more', {callback});

$ajax->setAuthAction('save_forms', {callback});

$ajax->setActionAll('get_availabilities', 'function callback here');

$cron = new WPSchedule();
$cron->schedule({callback})->hourly();

class PostTypes
{
    public const WHATS_ON = 'whats_on';
    public const SEE_AND_DO = 'see_and_do';
    public const STAY_OVER = 'stay_over';

    public const WHATS_ON_CATEGORY = 'event_type';
    public const SEE_AND_DO_CATEGORY = 'attraction_type';
    public const STAY_OVER_CATEGORY = 'establishment_type';

    public function __construct()
    {
        $types = new \UWebPro\WordPress\PostType();

        $types->new()->setTranslations('What\'s On', 'What\'s On')
            ->customIcon('dashicons-calendar-alt')
            ->register(self::WHATS_ON)
            ->registerTaxonimies('Event Type', 'Event Types')
        ->init();

        $types->new()->setTranslations('See and Do', 'See and Do')
            ->customIcon('dashicons-tickets')
            ->register(self::SEE_AND_DO)
            ->registerTaxonimies('Attraction Type', 'Attraction Types')
        ->init();


        $types->new()->setTranslations('Stay Over', 'Stay Over')
            ->customIcon('dashicons-admin-multisite')
            ->register(self::STAY_OVER)
            ->registerTaxonimies('Establishment Type', 'Establishment Types')
        ->init();
    //custom taxonomies
    (new \UWebPro\Wordpress\Taxonomies('post'))->register('Story Type', 'Story Types')->init();


    }
}

$hash = new \UWebPro\WordPress\Hash(SECURE_AUTH_SALT, 8);
$hash->encode($post->ID);
//
$hash->decode($post->ID);

// Want a random string?
$hash->str_rand();