Skip to content

Commit

Permalink
feat(shortcodes, NavigationFooter): add global shortcodes and example…
Browse files Browse the repository at this point in the history
…s for dynamic copyright notices (#297)
  • Loading branch information
timohubois authored Sep 21, 2020
1 parent f82743d commit 00f9f6b
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Components/NavigationFooter/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Flynt\Utils\Options;
use Timber\Menu;
use Flynt\Shortcodes;

add_action('init', function () {
register_nav_menus([
Expand Down Expand Up @@ -33,5 +34,44 @@
'media_upload' => 0,
'delay' => 1,
'toolbar' => 'basic',
'default_value' => '© [year] [sitetitle]'
],
[
'label' => __('Content Examples', 'flynt'),
'name' => 'templateTab',
'type' => 'tab',
'placement' => 'top',
'endpoint' => 0,
],
[
'label' => __('Content Examples', 'flynt'),
'name' => 'groupContentExamples',
'instructions' => __('Want some content inspiration? Here they are!', 'flynt'),
'type' => 'group',
'sub_fields' => [
[
'label' => sprintf(__('© %s Website Name', 'flynt'), date_i18n('Y')),
'name' => 'messageShortcodeCopyrightYearWebsiteName',
'type' => 'message',
'message' => '<code>©' . htmlspecialchars('&nbsp;') . '[year] [sitetitle]</code>',
'new_lines' => 'wpautop',
'esc_html' => 0,
'wrapper' => [
'width' => 50
],
],
[
'label' => sprintf(__('© %s Website Name — Subtitle', 'flynt'), date_i18n('Y')),
'name' => 'messageShortcodeCopyrightYearWebsiteNameTagLine',
'type' => 'message',
'message' => '<code>©' . htmlspecialchars('&nbsp;') . '[year] [sitetitle] ' . htmlspecialchars('&mdash;') . ' [tagline]</code>',
'new_lines' => 'wpautop',
'esc_html' => 0,
'wrapper' => [
'width' => 50
]
]
]
],
Shortcodes\getShortcodeReference(),
]);
79 changes: 79 additions & 0 deletions inc/shortcodes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

/**
* Flynt Shortcodes
*/

namespace Flynt\Shortcodes;

/**
* Current year
*/
add_shortcode('year', function () {
$year = date_i18n('Y');
return $year;
});

/**
* Site Title
*/
add_shortcode('sitetitle', function () {
$blogname = get_bloginfo('name');
return $blogname;
});

/**
* Tagline
*/
add_shortcode('tagline', function () {
$tagline = get_bloginfo('description');
return $tagline;
});

/**
* Flynt Shortcode reference
*/
function getShortcodeReference()
{
return [
'label' => __('Shortcode Reference', 'flynt'),
'name' => 'groupShortcodes',
'instructions' => __('A Shortcode can generally be used inside text fields. It’s best practice to switch to text mode before inserting a shortcode inside the visual editor.', 'flynt'),
'type' => 'group',
'sub_fields' => [
[
'label' => __('Site Title (Website Name)', 'flynt'),
'name' => 'messageShortcodeSiteTitle',
'type' => 'message',
'message' => '<code>[sitetitle]</code>',
'new_lines' => 'wpautop',
'esc_html' => 0,
'wrapper' => [
'width' => 50
],
],
[
'label' => __('Tagline (Subtitle)', 'flynt'),
'name' => 'messageShortcodeTagline',
'type' => 'message',
'message' => '<code>[tagline]</code>',
'new_lines' => 'wpautop',
'esc_html' => 0,
'wrapper' => [
'width' => 50
],
],
[
'label' => __('Current Year', 'flynt'),
'name' => 'messageShortcodeCurrentYear',
'type' => 'message',
'message' => '<code>[year]</code>',
'new_lines' => 'wpautop',
'esc_html' => 0,
'wrapper' => [
'width' => 50
],
],
]
];
}

0 comments on commit 00f9f6b

Please sign in to comment.