Skip to content

Commit 869a40b

Browse files
committed
Initial commit
1 parent 212cbbb commit 869a40b

File tree

11 files changed

+395
-0
lines changed

11 files changed

+395
-0
lines changed

.github/FUNDING.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
custom: https://paypal.me/zgivan
4+
open_collective: vvvebjs

.github/lock.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Configuration for Lock Threads - https://github.com/dessant/lock-threads
2+
3+
# Number of days of inactivity before a closed issue or pull request is locked
4+
daysUntilLock: 365
5+
6+
# Skip issues and pull requests created before a given timestamp. Timestamp must
7+
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
8+
skipCreatedBefore: false
9+
10+
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
11+
exemptLabels:
12+
- no-locking
13+
- help-wanted
14+
15+
# Label to add before locking, such as `outdated`. Set to `false` to disable
16+
lockLabel: outdated
17+
18+
# Comment to post before locking. Set to `false` to disable
19+
lockComment: >
20+
This thread has been automatically locked since there has not been
21+
any recent activity after it was closed. Please open a new issue for
22+
related bugs.
23+
24+
# Assign `resolved` as the reason for locking. Set to `false` to disable
25+
setLockReason: true
26+
27+
# Limit to only `issues` or `pulls`
28+
# only: issues
29+
30+
# Optionally, specify configuration settings just for `issues` or `pulls`
31+
# issues:
32+
# exemptLabels:
33+
# - help-wanted
34+
# lockLabel: outdated
35+
36+
# pulls:
37+
# daysUntilLock: 30
38+
39+
# Repository to extend settings from
40+
# _extends: repo

.github/no-response.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Configuration for probot-no-response - https://github.com/probot/no-response
2+
3+
# Number of days of inactivity before an Issue is closed for lack of response
4+
daysUntilClose: 10
5+
# Label requiring a response
6+
responseRequiredLabel: more-information-needed
7+
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
8+
closeComment: >
9+
This issue has been automatically closed because there has been no response
10+
to our request for more information from the original author. With only the
11+
information that is currently in the issue, we don't have enough information
12+
to take action. Please reach out if you have or find the answers we need so
13+
that we can investigate further.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Insert scripts Vvveb plugin
2+
3+
Insert footer and header scripts such as analytics or widgets.
4+
5+
Settings are saved per site for multi site setups.
6+
7+
👉🏻 [Plugin page](https://plugins.vvveb.com/product/insert-scripts) 👉🏻 [Download](https://github.com/Vvveb/insert-scripts/archive/main.zip)
8+
9+
| [![](https://plugins.vvveb.com/media/plugins/insert-scripts/insert-scripts-1.png)](https://plugins.vvveb.com/media/plugins/insert-scripts/insert-scripts-1.png) |
10+
|:---:|
11+
12+
## Install
13+
14+
From your Vvveb dashboard `admin / plugins` page upload plugin zip.
15+
16+
## License
17+
18+
Copyright (c) [Vvveb](https://www.vvveb.com)
19+
20+
Released under the [GPL 3](https://github.com/Vvveb/insert-scripts/blob/main/LICENSE) license.
21+

admin/controller/settings.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/**
4+
* Vvveb
5+
*
6+
* Copyright (C) 2023 Ziadin Givan
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
namespace Vvveb\Plugins\InsertScripts\Controller;
24+
25+
use function Vvveb\__;
26+
use Vvveb\Controller\Base;
27+
use Vvveb\System\Validator;
28+
29+
class Settings extends Base {
30+
function save() {
31+
//$validator = new Validator(['plugins.insert-scripts.settings']);
32+
$settings = $this->request->post['settings'] ?? false;
33+
$errors = [];
34+
35+
if ($settings /*&&
36+
($errors = $validator->validate($settings)) === true*/) {
37+
//$settings = $validator->filter($settings);
38+
$results = \Vvveb\set_settings('insert-scripts', $settings, $this->global['site_id']);
39+
$this->view->success[] = __('Settings saved!');
40+
} else {
41+
$this->view->errors = $errors;
42+
}
43+
44+
return $this->index();
45+
}
46+
47+
function index() {
48+
$this->view->site_id = $this->global['site_id'];
49+
}
50+
}

admin/template/settings.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import(common.tpl)
2+
3+
.settings input[name]|value = <?php
4+
$_setting = '@@__name:\[(.*)\]__@@';
5+
echo $_POST['settings'][$_setting] ?? Vvveb\get_setting('insert-scripts', $_setting, '', $this->site_id);
6+
//name="settings[setting-name] > get only setting-name
7+
?>
8+
9+
.settings textarea = <?php
10+
$_setting = '@@__name:\[(.*)\]__@@';
11+
echo ($_POST['settings'][$_setting] ?? Vvveb\get_setting('insert-scripts', $_setting, '', $this->site_id));
12+
?>

admin/validate/settings.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/**
4+
* Vvveb
5+
*
6+
* Copyright (C) 2023 Ziadin Givan
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
return [
24+
'header' => [
25+
],
26+
'footer' => [
27+
],
28+
];

app/template/common.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
head|append = <?php echo $this->plugins['insert-scripts']['header'] ?? '';?>
2+
body|append = <?php echo $this->plugins['insert-scripts']['footer'] ?? '';?>
3+

plugin.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
/**
4+
* Vvveb
5+
*
6+
* Copyright (C) 2023 Ziadin Givan
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
/*
24+
Name: Insert Footer Header Scripts
25+
Slug: insert-scripts
26+
Category: tools
27+
Url: https://www.vvveb.com
28+
Description: Insert footer and header scripts such as analytics or widgets.
29+
Thumb: insert-scripts.svg
30+
Author: givanz
31+
Version: 0.1
32+
Author url: https://www.vvveb.com
33+
Settings: /admin/?module=plugins/insert-scripts/settings
34+
*/
35+
36+
use function Vvveb\__;
37+
use Vvveb\System\Core\View;
38+
use Vvveb\System\Event;
39+
40+
if (! defined('V_VERSION')) {
41+
die('Invalid request!');
42+
}
43+
44+
class InsertScriptsPlugin {
45+
function admin() {
46+
// add admin menu item
47+
$admin_path = \Vvveb\adminPath();
48+
Event::on('Vvveb\Controller\Base', 'init-menu', __CLASS__, function ($menu) use ($admin_path) {
49+
$menu['plugins']['items']['insert-scripts'] = [
50+
'name' => __('Insert scripts'),
51+
'url' => $admin_path . '?module=plugins/insert-scripts/settings',
52+
'icon-img' => PUBLIC_PATH . 'plugins/insert-scripts/insert-scripts.svg',
53+
];
54+
55+
return [$menu];
56+
}, 20);
57+
}
58+
59+
function app() {
60+
//don't add scripts if the page is open in the editor
61+
if (Vvveb\isEditor()) {
62+
return;
63+
}
64+
$view = View::getInstance();
65+
$template = $view->getTemplateEngineInstance();
66+
$view->plugins = $view->plugins ?? [];
67+
$options = Vvveb\get_setting('insert-scripts', ['header', 'footer']);
68+
$view->plugins['insert-scripts'] = $options ?? [];
69+
$template->loadTemplateFile(__DIR__ . '/app/template/common.tpl');
70+
//$template->addTemplatePath(__DIR__ . '/../app/template/');
71+
}
72+
73+
function __construct() {
74+
if (APP == 'admin') {
75+
$this->admin();
76+
} else {
77+
if (APP == 'app') {
78+
$this->app();
79+
}
80+
}
81+
}
82+
}
83+
84+
$insertScriptsPlugin = new InsertScriptsPlugin();

public/admin/settings.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8+
<meta name="description" content="">
9+
<meta name="author" content="">
10+
<link rel="icon" href="../../favicon.ico">
11+
<base href="">
12+
13+
<title>Vvveb - Insert Scripts Plugin</title>
14+
15+
<link href="css/admin.css" rel="stylesheet">
16+
</head>
17+
18+
19+
<body>
20+
21+
<div id="container">
22+
23+
<div class="sidebar" data-v-copy-from="index.html,.sidebar">
24+
</div>
25+
26+
27+
<div class="main">
28+
29+
<div class="clearfix top-header" data-v-copy-from="index.html,.top-header">
30+
</div>
31+
32+
<form id="settings-form" action="" method="post" class="needs-validation" novalidate data-v-product>
33+
<input type="hidden" name="action" id="action" value="save">
34+
<div class="actions">
35+
<div class="title">
36+
<h4 class="text-muted mt-2">
37+
<i class="la la-file-code la-lg"></i>&ensp;
38+
Insert Scripts Plugin
39+
</h4>
40+
</div>
41+
<div class="btns">
42+
<button type="submit" href="" class="btn btn-primary btn-icon ms-1" title="Save post">
43+
<i class="icon-create-outline"></i> Save settings
44+
</button>
45+
</div>
46+
</div>
47+
<div>
48+
<div id="main-content">
49+
50+
<div class="notifications" data-v-notifications data-v-copy-from="index.html,.notifications"></div>
51+
52+
<div class="content clearfix settings">
53+
54+
<div class="card mb-3">
55+
<div class="card-header">
56+
<label for="input-site-title" class="col-form-label">Header scripts</label>
57+
</div>
58+
<div class="card--body">
59+
<textarea class="form-control border-0" placeholder="Insert scripts here ... example: &lt;script&gt;let script;&lt;/script&gt; or &lt;style&gt;#mystyle{}&lt;/style&gt;" name="settings[header]" rows="9"></textarea>
60+
</div>
61+
</div>
62+
63+
<div class="card mb-3">
64+
<div class="card-header">
65+
<label for="input-site-title" class="col-form-label">Footer scripts</label>
66+
</div>
67+
<div class="card--body">
68+
<textarea class="form-control border-0" placeholder="Insert scripts here ... example: &lt;script&gt;let script;&lt;/script&gt; or &lt;style&gt;#mystyle{}&lt;/style&gt;" name="settings[footer]" rows="9"></textarea>
69+
</div>
70+
</div>
71+
72+
</div>
73+
</div>
74+
</form>
75+
76+
</div>
77+
</div>
78+
79+
80+
<script src="js/jquery.min.js"></script>
81+
<script src="js/popper.min.js"></script>
82+
<script src="js/bootstrap.min.js"></script>
83+
<script id="admin-js" type="module" src="../../js/admin.js"></script>
84+
<script type="module" src="../../js/admin.js"></script>
85+
86+
</body>
87+
</html>

0 commit comments

Comments
 (0)