From 00f9f6b754a6df41f31b3396ad97884e85f1172d Mon Sep 17 00:00:00 2001
From: Timo Hubois <46505685+pixelsaft@users.noreply.github.com>
Date: Mon, 21 Sep 2020 10:07:57 +0200
Subject: [PATCH] feat(shortcodes, NavigationFooter): add global shortcodes and
examples for dynamic copyright notices (#297)
---
Components/NavigationFooter/functions.php | 40 ++++++++++++
inc/shortcodes.php | 79 +++++++++++++++++++++++
2 files changed, 119 insertions(+)
create mode 100644 inc/shortcodes.php
diff --git a/Components/NavigationFooter/functions.php b/Components/NavigationFooter/functions.php
index 82534ceaf..44b4745d2 100644
--- a/Components/NavigationFooter/functions.php
+++ b/Components/NavigationFooter/functions.php
@@ -4,6 +4,7 @@
use Flynt\Utils\Options;
use Timber\Menu;
+use Flynt\Shortcodes;
add_action('init', function () {
register_nav_menus([
@@ -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' => '©' . htmlspecialchars(' ') . '[year] [sitetitle]
',
+ 'new_lines' => 'wpautop',
+ 'esc_html' => 0,
+ 'wrapper' => [
+ 'width' => 50
+ ],
+ ],
+ [
+ 'label' => sprintf(__('© %s Website Name — Subtitle', 'flynt'), date_i18n('Y')),
+ 'name' => 'messageShortcodeCopyrightYearWebsiteNameTagLine',
+ 'type' => 'message',
+ 'message' => '©' . htmlspecialchars(' ') . '[year] [sitetitle] ' . htmlspecialchars('—') . ' [tagline]
',
+ 'new_lines' => 'wpautop',
+ 'esc_html' => 0,
+ 'wrapper' => [
+ 'width' => 50
+ ]
+ ]
+ ]
+ ],
+ Shortcodes\getShortcodeReference(),
]);
diff --git a/inc/shortcodes.php b/inc/shortcodes.php
new file mode 100644
index 000000000..1abbd4f39
--- /dev/null
+++ b/inc/shortcodes.php
@@ -0,0 +1,79 @@
+ __('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' => '[sitetitle]
',
+ 'new_lines' => 'wpautop',
+ 'esc_html' => 0,
+ 'wrapper' => [
+ 'width' => 50
+ ],
+ ],
+ [
+ 'label' => __('Tagline (Subtitle)', 'flynt'),
+ 'name' => 'messageShortcodeTagline',
+ 'type' => 'message',
+ 'message' => '[tagline]
',
+ 'new_lines' => 'wpautop',
+ 'esc_html' => 0,
+ 'wrapper' => [
+ 'width' => 50
+ ],
+ ],
+ [
+ 'label' => __('Current Year', 'flynt'),
+ 'name' => 'messageShortcodeCurrentYear',
+ 'type' => 'message',
+ 'message' => '[year]
',
+ 'new_lines' => 'wpautop',
+ 'esc_html' => 0,
+ 'wrapper' => [
+ 'width' => 50
+ ],
+ ],
+ ]
+ ];
+}