diff --git a/README.md b/README.md index c1deada..2e16a48 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Features - Auto Update - Post Draft - i18n +- Menu builder Requirements ------------ @@ -267,11 +268,6 @@ Paragraph 1 Paragraph 2 etc. ``` -Credit ------- -* [Martin Angelov](http://tutorialzine.com) -* [Xiaoying Riley](http://themes.3rdwavemedia.com) - Contribute ---------- 1. Fork and edit diff --git a/config/config.ini.example b/config/config.ini.example index d96cc2f..ac90b0a 100644 --- a/config/config.ini.example +++ b/config/config.ini.example @@ -49,6 +49,9 @@ google.wmt.id = "" ; Google analytics google.analytics.id = "" +; Google gtag analytics +google.gtag.id = "" + ; Google reCaptcha ; https://www.google.com/recaptcha/admin. Options "false" and "true" diff --git a/system/admin/views/config-custom.html.php b/system/admin/views/config-custom.html.php new file mode 100644 index 0000000..ac78161 --- /dev/null +++ b/system/admin/views/config-custom.html.php @@ -0,0 +1,47 @@ +
hint: Use Ctrl/CMD + F to search for your config key or value.
pro tips: You can creating custom config key and print out your config key value anywhere in your template.
+<?php echo config('your.key'); ?>
hint: Use Ctrl/CMD⌘ + F to search for your config key or value.
pro tips: You can creating custom config key and print out your config key value anywhere in your template.
-<?php echo config('your.key'); ?>
Config
Reading
+ +Widget
+ +Metatags
+ +Performance
+ +Custom
+ +Menus
diff --git a/system/htmly.php b/system/htmly.php index f484613..c303fc0 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -1295,6 +1295,346 @@ post('/admin/config', function () { die; }); +// Show Config page +get('/admin/config/custom', function () { + + $user = $_SESSION[config("site.url")]['user']; + $role = user('role', $user); + + if (login()) { + config('views.root', 'system/admin/views'); + if ($role === 'admin') { + render('config-custom', array( + 'title' => 'Config - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'admin-config', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Config' + )); + } else { + render('denied', array( + 'title' => 'Config page - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'denied', + 'breadcrumb' => '', + )); + } + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Submitted Config page data +post('/admin/config/custom', function () { + + error_reporting(E_ALL); + ini_set("display_errors", 1); + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + if (login() && $proper) { + $newKey = from($_REQUEST, 'newKey'); + $newValue = from($_REQUEST, 'newValue'); + + $new_config = array(); + $new_Keys = array(); + if (!empty($newKey)) { + $new_Keys[$newKey] = $newValue; + } + foreach ($_POST as $name => $value) { + if (substr($name, 0, 8) == "-config-") { + $name = str_replace("_", ".", substr($name, 8)); + $new_config[$name] = $value; + } + } + save_config($new_config, $new_Keys); + $login = site_url() . 'admin/config/custom'; + header("location: $login"); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Show Config page +get('/admin/config/reading', function () { + + $user = $_SESSION[config("site.url")]['user']; + $role = user('role', $user); + + if (login()) { + config('views.root', 'system/admin/views'); + if ($role === 'admin') { + render('config-reading', array( + 'title' => 'Config - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'admin-config', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Config' + )); + } else { + render('denied', array( + 'title' => 'Config page - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'denied', + 'breadcrumb' => '', + )); + } + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Submitted Config page data +post('/admin/config/reading', function () { + + error_reporting(E_ALL); + ini_set("display_errors", 1); + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + if (login() && $proper) { + $newKey = from($_REQUEST, 'newKey'); + $newValue = from($_REQUEST, 'newValue'); + + $new_config = array(); + $new_Keys = array(); + if (!empty($newKey)) { + $new_Keys[$newKey] = $newValue; + } + foreach ($_POST as $name => $value) { + if (substr($name, 0, 8) == "-config-") { + $name = str_replace("_", ".", substr($name, 8)); + $new_config[$name] = $value; + } + } + save_config($new_config, $new_Keys); + $login = site_url() . 'admin/config/reading'; + header("location: $login"); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Show Config page +get('/admin/config/widget', function () { + + $user = $_SESSION[config("site.url")]['user']; + $role = user('role', $user); + + if (login()) { + config('views.root', 'system/admin/views'); + if ($role === 'admin') { + render('config-widget', array( + 'title' => 'Config - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'admin-config', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Config' + )); + } else { + render('denied', array( + 'title' => 'Config page - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'denied', + 'breadcrumb' => '', + )); + } + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Submitted Config page data +post('/admin/config/widget', function () { + + error_reporting(E_ALL); + ini_set("display_errors", 1); + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + if (login() && $proper) { + $newKey = from($_REQUEST, 'newKey'); + $newValue = from($_REQUEST, 'newValue'); + + $new_config = array(); + $new_Keys = array(); + if (!empty($newKey)) { + $new_Keys[$newKey] = $newValue; + } + foreach ($_POST as $name => $value) { + if (substr($name, 0, 8) == "-config-") { + $name = str_replace("_", ".", substr($name, 8)); + $new_config[$name] = $value; + } + } + save_config($new_config, $new_Keys); + $login = site_url() . 'admin/config/widget'; + header("location: $login"); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Show Config page +get('/admin/config/metatags', function () { + + $user = $_SESSION[config("site.url")]['user']; + $role = user('role', $user); + + if (login()) { + config('views.root', 'system/admin/views'); + if ($role === 'admin') { + render('config-metatags', array( + 'title' => 'Config - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'admin-config', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Config' + )); + } else { + render('denied', array( + 'title' => 'Config page - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'denied', + 'breadcrumb' => '', + )); + } + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Submitted Config page data +post('/admin/config/metatags', function () { + + error_reporting(E_ALL); + ini_set("display_errors", 1); + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + if (login() && $proper) { + $newKey = from($_REQUEST, 'newKey'); + $newValue = from($_REQUEST, 'newValue'); + + $new_config = array(); + $new_Keys = array(); + if (!empty($newKey)) { + $new_Keys[$newKey] = $newValue; + } + foreach ($_POST as $name => $value) { + if (substr($name, 0, 8) == "-config-") { + $name = str_replace("_", ".", substr($name, 8)); + $new_config[$name] = $value; + } + } + save_config($new_config, $new_Keys); + $login = site_url() . 'admin/config/metatags'; + header("location: $login"); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Show Config page +get('/admin/config/performance', function () { + + $user = $_SESSION[config("site.url")]['user']; + $role = user('role', $user); + + if (login()) { + config('views.root', 'system/admin/views'); + if ($role === 'admin') { + render('config-performance', array( + 'title' => 'Config - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'admin-config', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Config' + )); + } else { + render('denied', array( + 'title' => 'Config page - ' . blog_title(), + 'description' => strip_tags(blog_description()), + 'canonical' => site_url(), + 'type' => 'is_admin-config', + 'is_admin' => true, + 'bodyclass' => 'denied', + 'breadcrumb' => '', + )); + } + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + +// Submitted Config page data +post('/admin/config/performance', function () { + + error_reporting(E_ALL); + ini_set("display_errors", 1); + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + if (login() && $proper) { + $newKey = from($_REQUEST, 'newKey'); + $newValue = from($_REQUEST, 'newValue'); + + $new_config = array(); + $new_Keys = array(); + if (!empty($newKey)) { + $new_Keys[$newKey] = $newValue; + } + foreach ($_POST as $name => $value) { + if (substr($name, 0, 8) == "-config-") { + $name = str_replace("_", ".", substr($name, 8)); + $new_config[$name] = $value; + } + } + save_config($new_config, $new_Keys); + $login = site_url() . 'admin/config/performance'; + header("location: $login"); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + // Show Backup page get('/admin/backup', function () { if (login()) { @@ -1425,7 +1765,7 @@ post('/admin/menu', function () { if (login()) { $json = from($_REQUEST, 'json'); - file_put_contents('content/data/menu.json', json_encode($json)); + file_put_contents('content/data/menu.json', json_encode($json, JSON_UNESCAPED_UNICODE)); } }); diff --git a/system/includes/functions.php b/system/includes/functions.php index 101717d..491205c 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -1950,27 +1950,36 @@ function publisher() } // Google Analytics -function analytics($analyticsDir = null) +function analytics() { $analytics = config('google.analytics.id'); - if ($analyticsDir === null) { - $analyticsDir = '//www.google-analytics.com/analytics.js'; - } else { - $analyticsDir = site_url() . 'themes/' . $analyticsDir . 'analytics.js'; - } + $gtag = config('google.gtag.id'); $script = <<