PHP code example of k1sul1 / k1kit

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

    

k1sul1 / k1kit example snippets




/**
 * $options is doesn't do anything on subsequent runs
 */
function app($options = []) {
  return \k1\App::init($options);
}

$options = [
  'blocks' => [],
  'templates' => [],
  'languageSlugs' => ['en'],
  'generateOptionsPages' => true,
  'manifests' => [
    'client' => __DIR__ . '/dist/client-manifest.json',
    'admin' => __DIR__ . '/dist/admin-manifest.json'
  ],
]

$app = app();

$app->getOption('key'); // Get value from an ACF options field, using the current language unless other specified
$app->getBlock('Hero'); // Get a custom block instance. Useful if you want to render a block manually.

$app = app();

$app->i18n->getText('Something that should be translated');
$app->i18n->getLanguage();
$app->i18n->getLanguages();

// A different AssetManifest instance if created for each manifest
$app->manifests['client']->enqueue('client.js');
$app->manifests['client']->getAssetFilename('something.svg', false) // Set second parameter to false to return a filesystem path instead of an URL