The Docs

A guide to functions and assets in PHP Site Framework.

Functions
scripts/functions.php

Useful functions that can be used throughout your project.

is_localhost()

Checks to see if the site is being viewed from localhost. Returns true or false.

Example
<?php if ( is_localhost() ): ?> Viewing from localhost <?php endif; ?>

is_page( $arg )

Checks $arg to see if it matches current page. Returns true or false.

Example
<?php if ( is_page('services-design') ): ?> True if url is /services/design. <?php endif; ?>

is_home()

Checks to see if current page is homepage. Returns true or false.

Example
<?php if ( is_home() ): ?> True if current page is homepage. <?php endif; ?>

get_page()

Returns formatted slug for current page.

Example
<?php $page = get_page(); ?>

Would return services-design if the current page is services/design.

this_year( $arg )

Echo's the current year if no argument is given. Can be useful for copyright notice.

Example
<?php this_year(); ?> /* 2015 */

has_expired( $date, $time )

Checks passed date and time against current date and time to see if it has passed. Returns true or false.

Example
<?php has_expired( '01012016' ); ?> /* Date only */
<?php has_expired( '01012016', '1500' ); ?> /* Date and time */

Theme Helper Functions
scripts/functions.php

Useful theme functions. Most useful from within a template file however can be used throughout the project.

assets_dir()

Prints the path of the sites current theme assets directory as set in config.php.

Example
<?php assets_dir() ?> /* prints /theme/default/assets */

template_exists( $arg )

Checks current theme folder to see if passed template file exists. Returns true or false.

Example
<?php if ( template_exists( 'homepage' ) ): ?> /* checks for template file: theme/default/homepage.php */ <?php endif; ?>

part_exists( $arg )

Checks current theme's partials folder to see if passed file exists. Returns true or false.

Example
<?php if ( part_exists( 'header' ) ): ?> /* checks for template file: theme/default/partials/header.php */ <?php endif; ?>

Theme Functions
scripts/Theme/Theme.php

Theme class functions for including the parts that build a template.

$this->get_header()

Includes header.php from the current themes partials folder.

Example
<?php $this->get_header(); ?> /* includes /theme/default/partials/header.php */

$this->get_footer()

Includes footer.php from the current themes partials folder.

Example
<?php $this->get_footer(); ?> /* includes /theme/default/partials/footer.php */

$this->get_sidebar()

Includes sidebar.php from the current themes partials folder.

Example
<?php $this->get_sidebar(); ?> /* includes /theme/default/partials/sidebar.php */

$this->get_partial( $file )

Includes $file from the current themes partials folder.

Example
<?php $this->get_partial( 'analytics' ); ?> /* includes /theme/default/partials/analytics.php */

$this->get_template( $file )

Includes $file from the current theme folder.

Example
<?php $this->get_template( 'contact' ); ?> /* includes /theme/default/contact.php */

Theme Variables
scripts/variables.php

Variables that can be used from within a template file.

Pre-defined variables

Defined from settings declared in config.php along with some useful standard variables.

<?php

$this->name /* Website/Company name */
$this->domain /* Domain name */
$this->phone /* Phone number */
$this->email /* E-mail address */
$this->address /* Physical address */

$this->path /* Current path (e.g. services/design) */
$this->slug /* Current page (e.g. services-design) */

// Page array
$this->page['title'] /* Page title to be used in <title> */
$this->page['description'] /* Description to be used in <meta name="description"> */
$this->page['keywords'] /* Keywords to be used in <meta name="keywords"> */
$this->page['canonical'] /* Canonical URL to be used in <link rel="canonical"> */

?>
Usage
<?php echo $this->name; ?>