PHP code example of vincit / wordpress-theme-base

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

    

vincit / wordpress-theme-base example snippets


/* Start the Loop */
while ( have_posts() ) : the_post();

  /*
   * Include the Post-Format-specific template for the content.
   * If you want to override this in a child theme, then e_posts_navigation();

$variable = "string";

get_template_part("variableOutOfScope");

$variable = "string";



namespace Vincit\Template;

// use \Vincit\Media; // Optional use declarations, get image helpers or similar

/**
 * Is actually a link, but looks like a button.
 *
 * @param mixed $data
 */
function Button($data = []) {
  $data = params([
    "text" => null,
    "link" => null,
    "color" => [
      "value" => "white",
    ],
  ], $data);

  if (empty($data["text"]) || empty($data["link"])) {
    // Default is null, but ACF may populate this with empty string
    return false;
  } 

$builder = \Vincit\Pagebuilder::instance();
$button = $builder->block("Button", ["text" => "Click me!", "link" => "#"]);
// Equivalent to calling Button() manually, but with output buffer and error is catchable.

echo get_the_content();
echo $button; // Button is after the content!

$builder = \Vincit\Pagebuilder::instance();

while (have_posts()) { the_post();
  echo $builder->block("SinglePost", [
    "title" => get_the_title(),
    "content" => get_the_content(),
    "image" => get_post_thumbnail_id(),
  ]);

  echo $builder->block("CommentList", [
    "post_id" => get_the_ID(),
  ]);
}

echo $builder->block("PostList", ["template" => "print_r"]);

// Inside another template, under namespace \Vincit\Template

$button = Button(["text" => "Click me!", "link" => "#"]);

echo get_the_content();
echo $button; // Button is actually before the content!