PHP code example of tio27 / avilio

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

    

tio27 / avilio example snippets


// functions.php
add_action('init', 'register_custom_post_type');
function register_custom_post_type() {
    register_post_type('custom', array(
        'labels' => array(
            'name' => __('Custom Post'),
        ),
        'public' => true,
    ));
}

function wpdocs_theme_name_scripts() {
    wp_enqueue_script( 'script1-name', get_template_directory_uri() . '/js/example1.js', array( 'script_one_js' ), '1.0.0', false );
    wp_enqueue_script( 'script2-name', get_template_directory_uri() . '/js/example2.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );

function wpdocs_theme_name_style() {
    wp_enqueue_style( 'style-name', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_style' );


// functions.php
use Avilio\Theme;

$myTheme = new Theme;
$myTheme->addAction('init',function(){
    register_post_type('custom', array(
        'labels' => array(
            'name' => __('Custom Post'),
        ),
        'public' => true,
    ));
})

$myTheme->addScripts([
    [
        'handle'=>'script1-name',
        'src'=>get_template_directory_uri() . '/js/example1.js',
        'deps'=> ['script_one_js'],
    ],
    [
        'handle'=>'script2-name',
        'src'=>get_template_directory_uri() . '/js/example2.js',
    ]
]);

$myTheme->addStyles([
    [
        'handle' => 'style-name',
        'src' => get_stylesheet_uri()

    ]
]);

//other commonly used examples
$myTheme->addImageSizes([
	['name' => 'thumbnail-180', 'width' => 180, 'height' => 227, 'crop' => true],
	['name' => 'thumbnail-240', 'width' => 240, 'height' => 240, 'crop' => true]
]);

$myTheme->addNavMenus([
	'header-menu' => "Header Menu",
	"footer-menu-1" => "Footer Menu",
	'sidebar-menu' => "Sidebar Menu"
]);

// get value from acf field
$display = get_field('field_name');
$display_option = get_field('field_option_name','option');

// repeater field
if( have_rows('parent_repeater') ):
    while( have_rows('parent_repeater') ) : the_row();

        $title = get_sub_field('sub_title');
        $desc = get_sub_field('sub_description');
        $image = get_sub_field('sub_image');
    endwhile;
endif;

use Avilio\ACF;

// get value from acf field
$display = ACF::field('field_name');
$display_option = ACF::option('field_option_name');

//repeater field
$repeater_field = ACF::field('parent_repeater',[
    'title' => 'sub_title',
    'desc' => 'sub_description',
    'image' => 'sub_image'
])
// The output from the repeater field above will be in the form of an array that you can use in your template.

// page.php
 
get_header();

// page.php
 
use Avilio\PageTemplate;
use Avilio\ACF;
get_header();

$template = new PageTemplate();
$data = [
    'section1' => [
        'path' => 'content/section1',
        'title' => ACF::field('section1_title'),
        'subtitle' => ACF::field('subtitle'),
        'image' => ACF::field('image'),
        'desc' => ACF::field('desc'),
    ],
    'section2' => [
        'path' => 'content/section2',
        'title' => ACF::field('section2_title'),
        'subtitle' => ACF::field('section2_subtitle'),
        'lists' => ACF::field('section2_slides',[
            'image' => 'section2_image',
            'caption' => 'section2_caption'
        ]),
    ],
]

 
//template-parts/content/section1.php
<section class="section1">
    <h2> echo $title 

//template-parts/content/section2.php
<section class="section2">
    <h2> echo $title