Browse Source

Update theme functions

master
Skylar Ittner 1 year ago
parent
commit
a26ad096d6
1 changed files with 67 additions and 32 deletions
  1. 67
    32
      docs/Theme Development.md

+ 67
- 32
docs/Theme Development.md View File

@@ -180,44 +180,61 @@ if (!is_complex_empty("banner-btn-2")) {
<?php } ?>
```

### Social Media URLs

```html
<?php
$social = get_socialmedia_urls();
foreach ($social as $s) {
?>
<li>
<a href="<?php echo $s['url']; ?>" class="icon <?php echo $s['icon']; ?>">
<span class="label"><?php echo $s['name']; ?></span>
</a>
</li>
<?php
}
?>
```

## Theme Functions

### `get_site_name($echo = true)`
### `function get_site_name($echo = true)`

Get the name of the website.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_site_url($echo = true)`
### `function get_site_url($echo = true)`

Get the URL of the website.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_page_title($echo = true)`
### `function get_page_title($echo = true)`

Get the page title.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_page_clean_title($echo = true)`
### `function get_page_clean_title($echo = true)`

Get the page title stripped of any HTML.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_page_slug($echo = true)`
### `function get_page_slug($echo = true)`

Get the page slug for the current page.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_page_clean_url($echo = true, $slug = null)`
### `function get_page_clean_url($echo = true, $slug = null)`

Get a valid minimal URL for a page.

@@ -226,7 +243,7 @@ Get a valid minimal URL for a page.
* `$slug` — `string` — page slug, or null for current
* **Returns:** `string` —

### `get_page_url($echo = true, $slug = null)`
### `function get_page_url($echo = true, $slug = null)`

Get a valid URL for a page.

@@ -235,7 +252,7 @@ Get a valid URL for a page.
* `$slug` — `string` — page slug, or null for current
* **Returns:** `string` —

### `get_component($name, $context = null, $echo = true)`
### `function get_component($name, $context = null, $echo = true, $default = "")`

Echoes or returns the content of a component.

@@ -243,9 +260,10 @@ Echoes or returns the content of a component.
* `$name` — `string` — component name
* `$context` — `string` — page slug, or null for current
* `$echo` — `boolean` — default true
* `$default` — `string` — The content to return if the component is empty
* **Returns:** `string` —

### `is_component_empty($name, $context = null)`
### `function is_component_empty($name, $context = null)`

Check if a component is empty of content.

@@ -254,7 +272,7 @@ Check if a component is empty of content.
* `$context` — `string` — page slug, or null for current
* **Returns:** `boolean` —

### `get_complex_component($name, $context = null, $include = [])`
### `function get_complex_component($name, $context = null, $include = [])`

Return the data for a complex component (icon, link, text, image, etc)

@@ -264,7 +282,7 @@ Return the data for a complex component (icon, link, text, image, etc)
* `$include` — `array` — list of properties to include in the output
* **Returns:** `array` —

### `is_complex_empty($name, $context = null)`
### `function is_complex_empty($name, $context = null)`

Check if the specified complex component is empty.

@@ -273,7 +291,7 @@ Check if the specified complex component is empty.
* `$context` — `string` — page slug
* **Returns:** `boolean` —

### `get_escaped_json($json, $echo = true)`
### `function get_escaped_json($json, $echo = true)`

Convert a variable into encoded JSON for safe inclusion in an element property.

@@ -282,7 +300,7 @@ Convert a variable into encoded JSON for safe inclusion in an element property.
* `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_url_or_slug($str, $echo = true)`
### `function get_url_or_slug($str, $echo = true)`

Detects if a string is a URL or a page slug, and returns something usable for href

@@ -291,21 +309,30 @@ Detects if a string is a URL or a page slug, and returns something usable for hr
* `$echo` — `boolean` —
* **Returns:** `string` —

### `get_page_content($slug = null)`
### `function get_file_url($file, $echo = true)`

Get a valid URL for a given file path. Detects if the file is uploaded via SiteWriter and acts accordingly.

* **Parameters:**
* `$file` — `string` —
* `$echo` — `boolean` —
* **Returns:** `string` —

### `function get_page_content($slug = null)`

Shortcut for get_component("content").

* **Parameters:** `$slug` — `string` — Get the content for the passed page instead of the current.

### `get_header()`
### `function get_header()`

Echoes invisible page header content.

### `get_footer()`
### `function get_footer()`

Echoes invisible page footer content.

### `get_setting($key, $echo = false)`
### `function get_setting($key, $echo = false)`

Return or echo the value of the given site setting key, or an empty string if unset.

@@ -314,39 +341,40 @@ Return or echo the value of the given site setting key, or an empty string if un
* `$echo` — `boolean` — default false
* **Returns:** `string` —

### `get_theme_url($echo = true)`
### `function get_theme_url($echo = true)`

Get the URL path for the theme folder, without trailing slash.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_theme_color_url($echo = true)`
### `function get_theme_color_url($echo = true)`

Get the URL base for the selected theme color asset folder, without trailing slash.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_navigation($currentpage = null, $classPrefix = "", $liclass = "", $currentclass = "current", $linkclass = "", $currentlinkclass = "active")`
### `function get_navigation($currentpage = null, $classPrefix = "", $liclass = "", $currentclass = "current", $linkclass = "", $currentlinkclass = "active")`

Get the page navigation as a string containing a series of `<li><a></a></li>` elements.

**Format:**
Format:
Current page:
```html
<li class="$classPrefix$slug $liclass $currentclass">
<a class="$linkclass $currentlinkclass" href="url">
Link Text
</a>
<a class="$linkclass $currentlinkclass" href="url">
Link Text
</a>
</li>
```
Other pages:

Other pages:
```html
<li class="$classPrefix$slug $liclass">
<a class="$linkclass" href="url">
Link Text
</a>
<a class="$linkclass" href="url">
Link Text
</a>
</li>
```

@@ -358,7 +386,7 @@ Other pages:
* `$linkclass` — `string` —
* `$currentlinkclass` — `string` — default "active"

### `output_conditional($content, $var)`
### `function output_conditional($content, $var)`

Replace "[[VAR]]" with the contents of $var and echo $content, but only if $var isn't empty.

@@ -366,15 +394,22 @@ Replace "[[VAR]]" with the contents of $var and echo $content, but only if $var
* `$content` — `string` —
* `$var` — `string` —

### `get_fontawesome_js($echo = true)`
### `function get_fontawesome_js($echo = true)`

Echos or returns a URL for the FontAwesome 5 JavaScript.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `get_socialmedia_urls()`
### `function get_fontawesome_css($echo = true)`

Echos or returns a URL for the FontAwesome 5 CSS WebFont.

* **Parameters:** `$echo` — `boolean` — default true
* **Returns:** `string` —

### `function get_socialmedia_urls()`

Returns an array of social media URLs, with FontAwesome icon classes and labels.

* **Returns:** `array` — `[["icon", "name", "url"]]`
* **Returns:** `array` — [["icon", "name", "url"]]

Loading…
Cancel
Save