├── .editorconfig
├── .gitattributes
├── .github
├── CONTRIBUTING.md
└── README.md
├── .gitignore
├── .vscode
├── extensions.json
└── settings.json
├── LICENSE
├── SnS.code-workspace
├── bin
├── docker-ready.sh
└── ssl.sh
├── composer.json
├── composer.lock
├── dist
├── .vscode
│ └── settings.json
├── README.txt
├── css
│ ├── meta-box.less
│ └── options-styles.less
├── images
│ ├── arrows.png
│ ├── icon32.png
│ └── menu.png
├── includes
│ ├── admin.php
│ ├── ajax.php
│ ├── bootstrap.php
│ ├── class-list-usage.php
│ ├── form.php
│ ├── global-page.php
│ ├── hoops-page.php
│ ├── main.php
│ ├── meta-box.php
│ ├── rest-page.php
│ ├── rest.php
│ ├── settings-page.php
│ ├── theme-page.php
│ ├── usage-page.php
│ └── utility.php
├── js
│ ├── Root.vue
│ ├── global-page.babel.js
│ ├── hoops-page.babel.js
│ ├── meta-box.babel.js
│ ├── pages
│ │ ├── Global.vue
│ │ ├── Hoops.vue
│ │ ├── Settings.vue
│ │ ├── Theme.vue
│ │ └── Usage.vue
│ ├── rest.babel.js
│ ├── settings-page.babel.js
│ └── theme-page.babel.js
├── languages
│ └── scripts-n-styles.pot
├── legacy
│ ├── autoprefixer.js
│ ├── chosen
│ │ ├── chosen-sprite.png
│ │ ├── chosen-sprite@2x.png
│ │ ├── chosen.jquery.min.js
│ │ └── chosen.min.css
│ ├── cleancss-browser.js
│ ├── coffee-script.js
│ ├── coffeelint.js
│ ├── html5shiv-printshiv.js
│ ├── html5shiv.js
│ ├── jquery.mustache.js
│ ├── jquery.mustache.min.js
│ ├── less.js
│ ├── less.min.js
│ └── uglify.js
├── license.txt
├── scripts-n-styles.php
├── theme
│ └── scripts-n-styles
│ │ ├── .vscode
│ │ └── settings.json
│ │ ├── comments.php
│ │ ├── functions.php
│ │ ├── index.php
│ │ ├── js
│ │ ├── test.coffee
│ │ ├── test.jsx
│ │ ├── test.react.js
│ │ ├── test.ts
│ │ ├── test.tsx
│ │ └── vendor
│ │ │ └── test.js
│ │ ├── less
│ │ ├── content.less
│ │ ├── mixins.less
│ │ ├── theme.less
│ │ └── variables.less
│ │ ├── readme.txt
│ │ ├── screenshot.png
│ │ ├── style.css
│ │ ├── styles
│ │ ├── test.sass
│ │ ├── test.scss
│ │ └── test.styl
│ │ └── test.json
└── uninstall.php
├── docker-compose.yml
├── gulp-build-codemirror.js
├── gulpfile.babel.js
├── initdb
└── data.sql
├── package-lock.json
├── package.json
├── phpcs.xml
├── readme.md
├── ssl
├── 000-default.conf
├── ca-opts.conf
├── localhost.ext
└── ssl.load
├── test-version-override.xml
└── uploads.ini
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | trim_trailing_whitespace = true
8 | indent_style = tab
9 |
10 | [*.{json,yml}]
11 | indent_style = space
12 | indent_size = 2
13 |
14 | [*.md]
15 | trim_trailing_whitespace = false
16 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Just do your best.
4 |
--------------------------------------------------------------------------------
/.github/README.md:
--------------------------------------------------------------------------------
1 | # Scripts n Styles
2 |
3 | This is the Development Repo for Scripts n Styles.
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | _notes/
3 | _notes/dwsync.xml
4 | *.LCK
5 | .DS_Store
6 | vendor
7 | /dist/codemirror
8 | node_modules
9 | /html
10 | /dist/js/**/*.min.js
11 | /dist/css/*.css
12 | .env
13 |
14 | /ssl/localhost.crt
15 | /ssl/localhost.csr
16 | /ssl/localhost.key
17 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "ikappas.phpcs",
4 | "eg2.tslint",
5 | "dbaeumer.vscode-eslint",
6 | "felixfbecker.php-intellisense",
7 | "ikappas.composer",
8 | "ms-azuretools.vscode-docker",
9 | "persoderlind.vscode-phpcbf",
10 | "EditorConfig.editorconfig"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "css.validate": false,
3 | "less.validate": false,
4 | "scss.validate": false
5 | }
--------------------------------------------------------------------------------
/SnS.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": ".",
5 | "name": "Root"
6 | },
7 | {
8 | "path": "dist",
9 | "name": "Plugin"
10 | },
11 | {
12 | "path": "dist/theme/scripts-n-styles",
13 | "name": "Theme"
14 | }
15 | ],
16 | "settings": {
17 | "editor.rulers": [
18 | 85
19 | ],
20 | "search.exclude": {
21 | "**/node_modules": true,
22 | "**/bower_components": true,
23 | "**/svn/*": true
24 | },
25 | "files.exclude": {
26 | "**/.git": true,
27 | "**/.svn": true,
28 | "**/.hg": true,
29 | "**/CVS": true,
30 | "**/.DS_Store": true,
31 | "**/svn/*": true
32 | },
33 | "phpcs.showSources": true
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/bin/docker-ready.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit if any command fails
4 | set -e
5 |
6 | # Launch the WordPress docker
7 | docker-compose up -d
8 |
9 | # Wait until the docker containers are setup properely
10 | echo -n "Waiting for server..."
11 | until [ "$(curl -m 1 -sLI 'http://localhost' | grep 'HTTP')" != "" ]; do echo -n '.'; sleep 1; done
12 | echo " Ready."
13 |
--------------------------------------------------------------------------------
/bin/ssl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit if any command fails
4 | set -e
5 |
6 | echo -e "Setting up Local SSL...\n"
7 |
8 | RED='\033[0;31m'
9 | GREEN='\033[0;32m'
10 | NC='\033[0m' # No Color
11 |
12 | # Check for required files.
13 | echo -e "\nChecking required files...\n"
14 | if [ -f ./ssl/localhost.ext ]
15 | then
16 | echo -e "${GREEN}✓${NC} './ssl/localhost.ext' exists."
17 | else
18 | echo -e "${RED}✗ Missing required file: './ssl/localhost.ext'.${NC}"
19 | exit 1
20 | fi
21 |
22 | if [ -f ./ssl/ca-opts.conf ]
23 | then
24 | echo -e "${GREEN}✓${NC} './ssl/ca-opts.conf' exists."
25 | else
26 | echo -e "${RED}✗ Missing required file: './ssl/ca-opts.conf'.${NC}"
27 | exit 1
28 | fi
29 |
30 | echo -e "\nChecking for local Certificate Authority...\n"
31 | # Create folder if needed.
32 | if [ -d ~/.localssl ]
33 | then
34 | echo -e "${GREEN}✓${NC} '~/.localssl' exists."
35 | else
36 | echo -e "${RED}✗${NC} '~/.localssl' not found..."
37 | echo -e "Creating ~/.localssl ..."
38 | mkdir -p ~/.localssl
39 | echo -e "${GREEN}✓${NC} '~/.localssl' created."
40 | fi
41 |
42 | # Create localhostCA.key if needed.
43 | if [ -f ~/.localssl/localhostCA.key ]
44 | then
45 | echo -e "${GREEN}✓${NC} 'localhostCA.key' exists."
46 | else
47 | echo -e "${RED}✗${NC} 'localhostCA.key' not found..."
48 | echo -e "Creating 'localhostCA.key' ..."
49 | openssl genrsa -des3 -out ~/.localssl/localhostCA.key 2048
50 | echo -e "${GREEN}✓${NC} 'localhostCA.key' created."
51 | fi
52 |
53 | # Create localhostCA.pem if needed.
54 | if [ -f ~/.localssl/localhostCA.pem ]
55 | then
56 | echo -e "${GREEN}✓${NC} 'localhostCA.pem' exists."
57 | else
58 | echo -e "${RED}✗${NC} 'localhostCA.pem' not found..."
59 | echo -e "Creating 'localhostCA.pem' ..."
60 | openssl req -x509 -config ./ssl/ca-opts.conf -new -nodes -key ~/.localssl/localhostCA.key -sha256 -days 825 -out ~/.localssl/localhostCA.pem
61 | echo -e "${GREEN}✓${NC} 'localhostCA.pem' created."
62 | echo -e "Attempting to Trust the CA..."
63 | sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.localssl/localhostCA.pem
64 | echo -e "${GREEN}✓${NC} Trusted the CA!"
65 | fi
66 |
67 | echo -e "\nChecking for local files...\n"
68 |
69 | # Create localhost.key if needed.
70 | if [ -f ./ssl/localhost.key ]
71 | then
72 | echo -e "${GREEN}✓${NC} 'localhost.key' exists."
73 | else
74 | echo -e "${RED}✗${NC} 'localhost.key' not found..."
75 | echo -e "Creating 'localhost.key' ..."
76 | openssl genrsa -out ./ssl/localhost.key 2048
77 | echo -e "${GREEN}✓${NC} 'localhost.key' created."
78 | fi
79 |
80 | # Create localhost.csr if needed.
81 | if [ -f ./ssl/localhost.csr ]
82 | then
83 | echo -e "${GREEN}✓${NC} 'localhost.csr' exists."
84 | else
85 | echo -e "${RED}✗${NC} 'localhost.csr' not found..."
86 | echo -e "Creating 'localhost.csr' ..."
87 | openssl req -new -config ./ssl/ca-opts.conf -key ./ssl/localhost.key -out ./ssl/localhost.csr
88 | echo -e "${GREEN}✓${NC} 'localhost.csr' created."
89 | fi
90 |
91 | # Create localhost.crt if needed.
92 | if [ -f ./ssl/localhost.crt ]
93 | then
94 | echo -e "${GREEN}✓${NC} 'localhost.crt' exists."
95 | else
96 | echo -e "${RED}✗${NC} 'localhost.crt' not found..."
97 | echo -e "Creating 'localhost.crt' ..."
98 | openssl x509 -req -in ./ssl/localhost.csr -CA ~/.localssl/localhostCA.pem -CAkey ~/.localssl/localhostCA.key -CAcreateserial -out ./ssl/localhost.crt -days 825 -sha256 -extfile ./ssl/localhost.ext
99 | echo -e "${GREEN}✓${NC} 'localhost.crt' created."
100 | fi
101 |
102 | echo -e "\nFinished."
103 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "un-focus/scripts-n-styles",
3 | "description": "Scripts n Styles development environment.",
4 | "require-dev": {
5 | "wp-coding-standards/wpcs": "*",
6 | "dealerdirect/phpcodesniffer-composer-installer": "*",
7 | "phpcompatibility/php-compatibility": "*",
8 | "sirbrillig/phpcs-variable-analysis": "*",
9 | "wptrt/wpthemereview": "*"
10 | },
11 | "require": {
12 | "composer/installers": "*",
13 | "wpackagist-plugin/wordpress-seo": "*",
14 | "wpackagist-plugin/classic-editor": "*",
15 | "wpackagist-plugin/debug-bar": "*",
16 | "wpackagist-plugin/gutenberg": "*"
17 | },
18 | "extra": {
19 | "installer-paths": {
20 | "html/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
21 | "html/wp-content/themes/{$name}/": ["type:wordpress-theme"]
22 | }
23 | },
24 | "repositories":[
25 | {
26 | "type":"composer",
27 | "url":"https://wpackagist.org"
28 | }
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/dist/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "phpcs.enable": true,
3 | "phpcs.standard": "../phpcs.xml",
4 | "phpcs.executablePath": "../vendor/bin/phpcs",
5 | "eslint.workingDirectories": [
6 | "../"
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/dist/README.txt:
--------------------------------------------------------------------------------
1 | === Scripts n Styles ===
2 | Contributors: WraithKenny, CaptainN
3 | Tags: admin, CSS, javascript, code, custom, Style
4 | Requires at least: 5.0.0
5 | Tested up to: 5.0.2
6 | Requires PHP: 7.2
7 | Stable tag: 3.4.0
8 | License: GPLv3 or later
9 | License URI: http://www.gnu.org/licenses/gpl-3.0.html
10 |
11 | This plugin allows Admin users to individually add custom CSS, Classes and JavaScript directly to Post, Pages or any other custom post types.
12 |
13 | == Description ==
14 |
15 | This plugin allows Admin users the ability to add custom CSS and JavaScript directly into individual Post, Pages or any other registered custom post types. You can also add classes to the body tag and the post container. There is a Global settings page for which you can write Scripts n Styles for the entire blog.
16 |
17 | Admin's can also add classes to the TinyMCE "Formats" dropdown which users can use to style posts and pages directly. As of Scripts n Styles 3+ styles are reflected in the post editor.
18 |
19 | Because only well trusted users should ever be allowed to insert JavaScript directly into the pages of your site, this plugin restricts usage to admin type users. Admin's have access to even more sensitive areas by definition, so that should be relatively safe ;)
20 |
21 | = Notes about the implementation: =
22 |
23 | * Admin users, or more specifically, *any user with the `manage_options` and `unfiltered_html` capabilities* (which by default is *only* the admin type user) can use this plugin's functionality. Some plugins extend user rolls, and so this plugin would naturally extend include rolls that have the appropriate capability.
24 | * CSS Styles are embeded, not linked, at the bottom of the `head` element with `style` tags by using `wp-head`. If your theme doesn't have this hook, this plugin (as well as most others) won't work.
25 | * JavaScript is embeded, not linked, at the bottom of the `body` (or `head`) element with `script` tags by using `wp-footer` (or `wp-head`). If your theme doesn't have this hook, this plugin (as well as most others) won't work.
26 | * **There is no input validation.** This plugin puts exactly what you type in the meta box directly into the `html` with no error checking. You are an Admin, and we trust you to be carefull. Try not to break anything.
27 | * Do to the licensing of the libraries used, this plugin is released "GPL 3.0 or later" if you care about those things.
28 |
29 | = Contact: =
30 |
31 | You'll have better luck contacting the other if you try me on [Twitter](http://twitter.com/WraithKenny1) and [Github](https://github.com/unFocus/Scripts-n-Styles/issues). If that fails, I have an [open thread](http://wordpress.org/support/topic/contacting-scripts-n-styles-author "Contacting Scripts n Styles' author") on the support forums that will trigger an email.
32 |
33 | == Installation ==
34 |
35 | This plugin does not require any special activation or template tags. Just get it from wordpress.org/extend, install and activate like normal.
36 |
37 | == Frequently Asked Questions ==
38 |
39 | = Will I lose all of my custom Styles and Scripts if I uninstall the plugin? =
40 |
41 | Yes, absolutely. **YOU WLL LOSE ALL CUSTOMIZATIONS.** Be sure that you do not want these customizations before you uninstall.
42 |
43 | = Why would you do that to me? =
44 |
45 | Well, because plugins are supposed to, and should be expected to clean up after themselves. If you disable and uninstall the plugin, as a developer, I am supposed to assume that you no longer want me to store all of that now useless data in your database.
46 |
47 | = Can I get around that somehow? =
48 |
49 | Sure, if you are an Admin, just go to the plugin editor and wipe out the uninstall.php and then WordPress will not delete the meta data on uninstall.
50 |
51 | == Screenshots ==
52 |
53 | 1. Settings Page for Writing Scripts n Styles that apply to the whole blog.
54 | 2. The Scripts panel of the Meta Box.
55 | 3. The Styles panel of the Meta Box.
56 | 4. The Classes panel. Add classes to the Style dropdown!
57 | 5. Enqueue panel. You can enqueue jQuery from here if you need!
58 | 6. Your styles are reflected in the Editor.
59 |
60 | == Changelog ==
61 |
62 | = 3.4 =
63 | * Add option to not delete data on uninstall
64 | * Version 4.0 will drop php support under 5.4
65 | * This version disables updates for installs with php < 5.4
66 | * 4.0 will launch when most have updated to 3.4 :) (and when it's done.)
67 |
68 | = 3.3 =
69 | * See the github repo commits
70 |
71 | = 3.2.1 =
72 | * metabox add shortcode bugfix
73 |
74 | = 3.2 =
75 | * Add AJAX to Shortcode Tab
76 | * Add "Chosen" for selects
77 | * General UI Improvements
78 | * Add CoffeeScript Support
79 | * Add Hoops Widget
80 | * Add Global Hoops Shortcodes
81 | * Add Markdown mode to code editor
82 | * Add (fix) code editor themes
83 | * Theme Support (Beta Feature)
84 |
85 | = 3.1.1 =
86 | * Add (fix) CodeMirror Themes
87 |
88 | = 3.1 =
89 | * Feature: Dynamic Shortcodes.
90 | * Feature: LESS.js support.
91 | * Bug Fix: Proper output escaping.
92 |
93 | = 3.0.3 =
94 | * Bug Fix: wpautop formatting.
95 |
96 | = 3.0.2 =
97 | * Bug Fix: Fatal Error on post save
98 |
99 | = 3.0.1 =
100 | * Option to show Metabox by default
101 | * Check upgrade in more places
102 | * Fix double Settings Message on general-options
103 | * Fix empty post showing on usage
104 | * Cleaned up constants (internal)
105 |
106 | = 3 =
107 | * AJAX Saving of Meta-box
108 | * Dynamically populate the Styles Dropdown for TinyMCE
109 | * Styles preview in Post Editor
110 | * Enqueue dependant scripts if you need (like jQuery)
111 | * Adjustable menu placement
112 | * CodeMirror Themes
113 |
114 | = 2.0.3 =
115 | * fixed some bugs
116 |
117 | = 2.0.1 =
118 | * Better selection of `post_types` to add Scripts-n-Styles
119 | * micro-optimization for storage of class names.
120 | * Adds option page for globally adding Scripts and Styles.
121 | * Defined a later priority for Scripts n Styles to print after other scripts and styles.
122 | * Added a box for Scripts to be included in the `head`.
123 | * Better adherence to coding standards.
124 | * Tabbed interface on metabox
125 | * added CodeMirror
126 | * began contextual help
127 |
128 | = 1.0.2 =
129 | * Added fields for `body_clas`s and `post_class`
130 | * Merged meta boxes
131 | * Cleaned up code
132 | * Improved compatibility
133 | * Added Screenshot
134 |
135 | = 1.0.1 =
136 | * Some small plugin meta data updates.
137 |
138 | = 1.0 =
139 | * Initial Release.
140 |
141 | == Upgrade Notice ==
142 |
143 | = 3.3 =
144 | Bug fixes and lib upgrades
145 |
146 | = 3.2.1 =
147 | Bug fix (add shortcode)
148 |
149 | = 3.2 =
150 | New Major Features
151 |
152 | = 3.1.1 =
153 | Add (fix) CodeMirror Themes
154 |
155 | = 3.1 =
156 | New Features and Bug fixes
157 |
158 | = 3.0.3 =
159 | Bug fix (wpauto issue)
160 |
161 | = 3.0.2 =
162 | Bug fix
163 |
164 | = 3.0.1 =
165 | Bug fixes
166 |
167 | = 3 =
168 | Adds new features.
169 |
170 | = 2 =
171 | Adds new features.
172 |
173 | = 1.0.3 =
174 | Adds a few new features.
175 |
176 | = 1.0.2 =
177 | Minor update. Adds a few new features.
178 |
179 | = 1.0.1 =
180 | Some small plugin meta data updates.
181 |
182 | = 1.0 =
183 | Initial Release, there is nothing to upgrade from.
184 |
--------------------------------------------------------------------------------
/dist/css/meta-box.less:
--------------------------------------------------------------------------------
1 | /* MetaBox.css */
2 | /* stylelint-disable selector-id-pattern */
3 | /* stylelint-disable selector-class-pattern */
4 |
5 | #editorcontainer #content {
6 | font-family: "Courier New", Courier, monospace;
7 | }
8 |
9 | .CodeMirror {
10 | height: 200px;
11 | border: 1px solid #dfdfdf;
12 | }
13 |
14 | .autoheight {
15 |
16 | .CodeMirror {
17 | height: auto;
18 | }
19 |
20 | .autoheight .CodeMirror-scroll {
21 | overflow-x: auto;
22 | overflow-y: hidden;
23 | min-height: 200px;
24 | max-height: calc(~"100vh - 100px");
25 | }
26 | }
27 |
28 | .style,
29 | .script,
30 | .less,
31 | .coffee {
32 | box-sizing: border-box;
33 | background-color: #fff;
34 | margin: 8px 0;
35 | background-clip: padding-box;
36 | font-family: "Courier New", Courier, monospace;
37 |
38 | textarea {
39 | width: 100%;
40 | }
41 |
42 | &::before,
43 | &::after {
44 | border: 1px solid #dfdfdf;
45 | position: relative;
46 | z-index: 3;
47 | display: block;
48 | padding: 0.5em;
49 | background-color: #f5f5f5;
50 | color: #333;
51 | font-family: "Courier New", Courier, monospace;
52 | line-height: 1;
53 | text-shadow: none;
54 | }
55 |
56 | &::before {
57 | border-bottom: 0 none;
58 | border-radius: 5px 5px 0 0;
59 | }
60 |
61 | &::after {
62 | border-top: 0 none;
63 | border-radius: 0 0 5px 5px;
64 | }
65 | }
66 |
67 | .style {
68 |
69 | &::before {
70 | content: '";
75 | }
76 | }
77 |
78 | .script {
79 |
80 | &::before {
81 | content: '";
86 | }
87 | }
88 |
89 | .less {
90 |
91 | &::before {
92 | content: '";
97 | }
98 | }
99 |
100 | .coffee {
101 |
102 | &::before {
103 | content: '";
108 | }
109 | }
110 |
111 | .sns-shortcode p {
112 | margin: 0;
113 | }
114 |
115 | .sns-collapsed-shortcode-btn {
116 | cursor: pointer;
117 | float: left;
118 | height: 1.4em;
119 | width: 1.4em;
120 | background-image: data-uri("../images/arrows.png");
121 | background-attachment: scroll;
122 | background-repeat: no-repeat;
123 | background-position: 1px 1px;
124 | margin-right: 0.5em;
125 | }
126 |
127 |
128 | .sns-ajax-wrap {
129 | height: 23px;
130 | height: auto;
131 | }
132 |
133 | .sns-collapsed-shortcode {
134 | overflow: hidden;
135 |
136 | .sns-collapsed-shortcode-btn {
137 | background-position: 1px -107px;
138 | }
139 |
140 | .CodeMirror,
141 | .sns-ajax-wrap {
142 | visibility: hidden;
143 | position: absolute;
144 | }
145 | }
146 |
147 | #add-mce-dropdown-names label {
148 | width: 50px;
149 | display: inline-block;
150 | }
151 |
152 | .sns-ajax-loading {
153 | display: none;
154 | vertical-align: top;
155 |
156 | .spinner {
157 | float: none;
158 | }
159 | }
160 |
161 | #sns-classes {
162 | overflow: hidden;
163 | width: 100%;
164 | }
165 |
166 | #SnS_classes_mce_wrapper {
167 | margin: 6px 0;
168 | }
169 |
170 | #mce-dropdown-names {
171 | display: none;
172 |
173 | body.js & {
174 | display: block;
175 | }
176 | }
177 |
178 | #delete-mce-dropdown-names .sns-ajax-delete {
179 | cursor: pointer;
180 | display: inline-block;
181 | height: 10px;
182 | overflow: hidden;
183 | text-indent: -9999px;
184 | width: 10px;
185 | background: url(/wp-admin/images/xit.gif) no-repeat scroll 0 0 transparent;
186 |
187 | &:hover {
188 | background: url(/wp-admin/images/xit.gif) no-repeat scroll -10px 0 transparent;
189 | }
190 | }
191 |
192 | #SnS_meta_box {
193 |
194 | > .inside {
195 | height: 300px;
196 | overflow: auto;
197 | padding: 6px 10px 8px;
198 | margin: 0;
199 | position: static;
200 | }
201 |
202 | .wp-tab-panel {
203 | border-style: solid;
204 | border-width: 1px;
205 | overflow: auto;
206 | padding: 0.5em 0.9em;
207 | min-height: 200px;
208 | height: auto;
209 | }
210 |
211 | body.js & {
212 |
213 | .title {
214 | display: none;
215 | }
216 |
217 | > .inside {
218 | height: auto;
219 | padding: 0 10px;
220 | margin: 6px 0 8px;
221 | }
222 |
223 | .wp-tab-panel {
224 | display: none;
225 | margin-bottom: 0;
226 | }
227 |
228 | .wp-tabs-panel-active {
229 | display: block;
230 | }
231 | }
232 |
233 | .wp-tab-bar {
234 | text-align: right;
235 | overflow: auto;
236 | width: 100%;
237 | padding: 0;
238 | margin-top: 3px;
239 | margin-bottom: -1px;
240 |
241 | li {
242 | float: left;
243 | background-color: inherit;
244 | border: 0 none;
245 | margin: 0;
246 | padding: 0;
247 | display: inline;
248 | }
249 |
250 | a {
251 | display: block;
252 | border-radius: 3px 3px 0 0;
253 | border-style: none;
254 | border-width: 1px 1px 0;
255 | padding: 3px 5px 5px;
256 | margin-right: 3px;
257 | text-decoration: none;
258 | }
259 | }
260 |
261 | body.no-js & {
262 |
263 | .wp-tab-bar {
264 | position: absolute;
265 | top: 36px;
266 | }
267 |
268 | .wp-tab-panel {
269 | margin-bottom: 1em;
270 | }
271 | }
272 |
273 | body.no-js #side-sortables & > .inside {
274 | margin-top: 33px;
275 | padding-top: 0;
276 | }
277 |
278 | .wp-tab-active a {
279 | background-color: #fff;
280 | border-color: #dfdfdf;
281 | border-style: solid;
282 | margin-bottom: -1px;
283 | }
284 |
285 | #normal-sortables &,
286 | #advanced-sortables & {
287 |
288 | .wp-tab-bar {
289 | float: left;
290 | margin: 0 -1px 0 5px;
291 | width: 121px;
292 | overflow: visible;
293 |
294 | a {
295 | padding: 8px;
296 | width: 104px;
297 | }
298 | }
299 |
300 | .wp-tab-panel {
301 | margin-left: 125px;
302 | margin-right: 5px;
303 | max-height: none;
304 | }
305 |
306 | .wp-tab-active a {
307 | border-radius: 3px 0 0 3px;
308 | border-style: solid none solid solid;
309 | border-width: 1px 0 1px 1px;
310 | margin-right: -1px;
311 | font-weight: 400;
312 | }
313 | }
314 | }
315 |
316 | @media only screen and (max-width: 1050px) {
317 |
318 | body.no-js #SnS_meta_box > .inside {
319 | margin-top: 33px;
320 | padding-top: 0;
321 | }
322 |
323 | #normal-sortables,
324 | #advanced-sortables {
325 |
326 | #SnS_meta_box {
327 |
328 | .wp-tab-bar {
329 | float: none;
330 | margin: 3px 0 -1px;
331 | width: 100%;
332 | overflow: hidden;
333 | }
334 |
335 | .wp-tab-panel {
336 | margin: 0 0 1em;
337 | }
338 |
339 | .wp-tab-bar a {
340 | padding: 3px 5px 5px;
341 | width: auto;
342 | }
343 |
344 | .wp-tab-active a {
345 | border-radius: 3px 3px 0 0;
346 | border-style: solid solid none;
347 | border-width: 1px 1px 0;
348 | margin-right: 3px;
349 | font-weight: 400;
350 | }
351 | }
352 |
353 | body.js & #SnS_meta_box .wp-tab-panel {
354 | margin: 0;
355 | }
356 | }
357 | }
358 |
--------------------------------------------------------------------------------
/dist/css/options-styles.less:
--------------------------------------------------------------------------------
1 | /* Options.css */
2 |
3 | /* stylelint-disable selector-id-pattern */
4 | /* stylelint-disable selector-class-pattern */
5 |
6 | .CodeMirror {
7 | height: 200px;
8 | border: 1px solid #dfdfdf;
9 | }
10 |
11 | .autoheight {
12 |
13 | .CodeMirror {
14 | height: auto;
15 | }
16 |
17 | .CodeMirror-scroll {
18 | overflow-x: auto;
19 | overflow-y: hidden;
20 | min-height: 200px;
21 | max-height: calc(~"100vh - 100px");
22 | }
23 | }
24 |
25 | .style,
26 | .script,
27 | .less,
28 | .coffee {
29 |
30 | textarea {
31 | width: 100%;
32 | }
33 |
34 | &::before,
35 | &::after {
36 | border: 1px solid #dfdfdf;
37 | position: relative;
38 | z-index: 3;
39 | display: block;
40 | padding: 0.5em;
41 | background-color: #f5f5f5;
42 | color: #333;
43 | font-family: "Courier New", Courier, monospace;
44 | line-height: 1;
45 | text-shadow: none;
46 | }
47 |
48 | &::before {
49 | border-bottom: 0 none;
50 | border-radius: 5px 5px 0 0;
51 | }
52 |
53 | &::after {
54 | border-top: 0 none;
55 | border-radius: 0 0 5px 5px;
56 | }
57 |
58 | > label {
59 | box-sizing: border-box;
60 | display: block;
61 | padding: 3px 6px;
62 | border: 1px solid #dfdfdf;
63 | border-top: 0 none;
64 | }
65 | }
66 |
67 | .style {
68 |
69 | &::before {
70 | content: '";
75 | }
76 | }
77 |
78 | .script {
79 |
80 | &::before {
81 | content: '";
86 | }
87 | }
88 |
89 | .less {
90 |
91 | &::before {
92 | content: '";
97 | }
98 | }
99 |
100 | .coffee {
101 |
102 | &::before {
103 | content: '";
108 | }
109 | } /* end Code Decorations */
110 |
111 |
112 | .scripts-n-styles_page_sns_theme .CodeMirror-scroll {
113 | max-height: none;
114 | }
115 |
116 | .sns-less-ide {
117 |
118 | .disabled {
119 | cursor: default;
120 | }
121 |
122 | .inside {
123 | margin: 6px 0;
124 | padding: 0 10px;
125 | line-height: 1.4;
126 | }
127 | }
128 |
129 | .sns-collapsed-btn {
130 | cursor: pointer;
131 | float: left;
132 | height: 1.4em;
133 | width: 1.4em;
134 | background-image: data-uri("../images/arrows.png");
135 | background-attachment: scroll;
136 | background-repeat: no-repeat;
137 | background-position: 1px 1px;
138 | margin-right: 0.5em;
139 |
140 | + label,
141 | + p {
142 | height: 1.4em;
143 | display: block;
144 | margin: 0;
145 | }
146 | }
147 |
148 | .sns-ajax-wrap {
149 | height: 23px;
150 |
151 | .single-status {
152 | display: inline-block;
153 | vertical-align: middle;
154 |
155 | .settings-error {
156 | margin: 0;
157 | }
158 | }
159 | }
160 |
161 | .sns-collapsed {
162 | overflow: hidden;
163 |
164 | .sns-collapsed-btn {
165 | background-position: 1px -107px;
166 | }
167 |
168 | .CodeMirror,
169 | .code,
170 | .sns-ajax-wrap,
171 | textarea {
172 | visibility: hidden;
173 | position: absolute;
174 | }
175 | }
176 |
177 | .sns-ajax-loading {
178 | display: none;
179 | vertical-align: top;
180 |
181 | .spinner {
182 | float: none;
183 | }
184 | }
185 |
186 | .sns-shortcode {
187 | background-color: #f5f5f5;
188 | background-image: linear-gradient(to bottom, #f9f9f9, #f5f5f5);
189 | border-color: #dfdfdf;
190 | border-radius: 3px;
191 | box-shadow: 0 1px 0 #fff inset;
192 | border-style: solid;
193 | border-width: 1px;
194 | line-height: 1;
195 | margin-bottom: 20px;
196 | padding: 0;
197 |
198 | .inside {
199 | margin: 6px 0 8px;
200 | position: relative;
201 | line-height: 1.4;
202 | padding: 0 10px;
203 | }
204 | }
205 |
--------------------------------------------------------------------------------
/dist/images/arrows.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unFocus/Scripts-n-Styles/07dcf6e0a34d40bab018fe3783392fbe189dee92/dist/images/arrows.png
--------------------------------------------------------------------------------
/dist/images/icon32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unFocus/Scripts-n-Styles/07dcf6e0a34d40bab018fe3783392fbe189dee92/dist/images/icon32.png
--------------------------------------------------------------------------------
/dist/images/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unFocus/Scripts-n-Styles/07dcf6e0a34d40bab018fe3783392fbe189dee92/dist/images/menu.png
--------------------------------------------------------------------------------
/dist/includes/admin.php:
--------------------------------------------------------------------------------
1 | ' . esc_html__( 'Settings', 'scripts-n-styles' ) . '';
48 | return $actions;
49 | } );
50 |
51 |
52 | /**
53 | * A Function for listing core scripts.
54 | */
55 | function get_registered_scripts() {
56 | return [
57 | 'utils',
58 | 'common',
59 | 'sack',
60 | 'quicktags',
61 | 'colorpicker',
62 | 'editor',
63 | 'wp-fullscreen',
64 | 'wp-ajax-response',
65 | 'wp-pointer',
66 | 'autosave',
67 | 'heartbeat',
68 | 'wp-auth-check',
69 | 'wp-lists',
70 | 'prototype',
71 | 'scriptaculous-root',
72 | 'scriptaculous-builder',
73 | 'scriptaculous-dragdrop',
74 | 'scriptaculous-effects',
75 | 'scriptaculous-slider',
76 | 'scriptaculous-sound',
77 | 'scriptaculous-controls',
78 | 'scriptaculous',
79 | 'cropper',
80 | 'jquery',
81 | 'jquery-core',
82 | 'jquery-migrate',
83 | 'jquery-ui-core',
84 | 'jquery-effects-core',
85 | 'jquery-effects-blind',
86 | 'jquery-effects-bounce',
87 | 'jquery-effects-clip',
88 | 'jquery-effects-drop',
89 | 'jquery-effects-explode',
90 | 'jquery-effects-fade',
91 | 'jquery-effects-fold',
92 | 'jquery-effects-highlight',
93 | 'jquery-effects-pulsate',
94 | 'jquery-effects-scale',
95 | 'jquery-effects-shake',
96 | 'jquery-effects-slide',
97 | 'jquery-effects-transfer',
98 | 'jquery-ui-accordion',
99 | 'jquery-ui-autocomplete',
100 | 'jquery-ui-button',
101 | 'jquery-ui-datepicker',
102 | 'jquery-ui-dialog',
103 | 'jquery-ui-draggable',
104 | 'jquery-ui-droppable',
105 | 'jquery-ui-menu',
106 | 'jquery-ui-mouse',
107 | 'jquery-ui-position',
108 | 'jquery-ui-progressbar',
109 | 'jquery-ui-resizable',
110 | 'jquery-ui-selectable',
111 | 'jquery-ui-slider',
112 | 'jquery-ui-sortable',
113 | 'jquery-ui-spinner',
114 | 'jquery-ui-tabs',
115 | 'jquery-ui-tooltip',
116 | 'jquery-ui-widget',
117 | 'jquery-form',
118 | 'jquery-color',
119 | 'suggest',
120 | 'schedule',
121 | 'jquery-query',
122 | 'jquery-serialize-object',
123 | 'jquery-hotkeys',
124 | 'jquery-table-hotkeys',
125 | 'jquery-touch-punch',
126 | 'jquery-masonry',
127 | 'thickbox',
128 | 'jcrop',
129 | 'swfobject',
130 | 'plupload',
131 | 'plupload-html5',
132 | 'plupload-flash',
133 | 'plupload-silverlight',
134 | 'plupload-html4',
135 | 'plupload-all',
136 | 'plupload-handlers',
137 | 'wp-plupload',
138 | 'swfupload',
139 | 'swfupload-swfobject',
140 | 'swfupload-queue',
141 | 'swfupload-speed',
142 | 'swfupload-all',
143 | 'swfupload-handlers',
144 | 'comment-reply',
145 | 'json2',
146 | 'underscore',
147 | 'backbone',
148 | 'wp-util',
149 | 'wp-backbone',
150 | 'revisions',
151 | 'imgareaselect',
152 | 'mediaelement',
153 | 'wp-mediaelement',
154 | 'password-strength-meter',
155 | 'user-profile',
156 | 'user-suggest',
157 | 'admin-bar',
158 | 'wplink',
159 | 'wpdialogs',
160 | 'wpdialogs-popup',
161 | 'word-count',
162 | 'media-upload',
163 | 'hoverIntent',
164 | 'customize-base',
165 | 'customize-loader',
166 | 'customize-preview',
167 | 'customize-controls',
168 | 'accordion',
169 | 'shortcode',
170 | 'media-models',
171 | 'media-views',
172 | 'media-editor',
173 | 'mce-view',
174 | 'less.js',
175 | 'coffeescript',
176 | 'chosen',
177 | 'coffeelint',
178 | 'mustache',
179 | 'html5shiv',
180 | 'html5shiv-printshiv',
181 | 'google-diff-match-patch',
182 | 'codemirror',
183 | ];
184 | }
185 |
186 |
187 | /**
188 | * Settings Page help
189 | */
190 | function help() {
191 | $help = '
' . wp_kses_post( __( 'In default (non MultiSite) WordPress installs, both Administrators and Editors can access Scripts-n-Styles on individual edit screens. Only Administrators can access the Options Pages. In MultiSite WordPress installs, only "Super Admin" users can access either Scripts-n-Styles on individual edit screens or the Options Pages. If other plugins change capabilities (specifically "unfiltered_html"), other users can be granted access.', 'scripts-n-styles' ) ) . '
';
192 | $help .= '' . esc_html__( 'Reference: jQuery Wrappers', 'scripts-n-styles' ) . '
'
193 | . 'jQuery(function($) {' . PHP_EOL
194 | . ' // $() will work as an alias for jQuery() inside of this function' . PHP_EOL
195 | . '}); ';
196 | $help .= '(function($) {' . PHP_EOL
197 | . ' // $() will work as an alias for jQuery() inside of this function' . PHP_EOL
198 | . '})(jQuery); ';
199 |
200 | $sidebar = '' . esc_html__( 'For more information:', 'scripts-n-styles' ) . '
'
201 | . '' . wp_kses_post( __( 'Frequently Asked Questions ', 'scripts-n-styles' ) ) . '
'
202 | . '' . wp_kses_post( __( 'Source on github ', 'scripts-n-styles' ) ) . '
'
203 | . '' . wp_kses_post( __( 'Support Forums ', 'scripts-n-styles' ) ) . '
'
204 | . '' . wp_kses_post( __( 'Ask me on Twitter ', 'scripts-n-styles' ) ) . '
';
205 |
206 | $screen = get_current_screen();
207 | $screen->add_help_tab( [
208 | 'title' => __( 'Scripts n Styles', 'scripts-n-styles' ),
209 | 'id' => 'scripts-n-styles',
210 | 'content' => $help,
211 | ] );
212 | if ( 'post' !== $screen->id ) {
213 | $screen->set_help_sidebar( $sidebar );
214 | }
215 | }
216 |
--------------------------------------------------------------------------------
/dist/includes/ajax.php:
--------------------------------------------------------------------------------
1 | ID, 'current_sns_tab', $active_tab, true );
51 | exit();
52 | } );
53 |
54 | // TinyMCE requests a css file.
55 | add_action( 'wp_ajax_nopriv_sns_tinymce_styles', function () {
56 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended
57 | if ( empty( $_REQUEST['post_id'] ) ) {
58 | exit( 'Bad post ID.' );
59 | }
60 | $post_id = absint( $_REQUEST['post_id'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
61 |
62 | $options = get_option( 'SnS_options' );
63 | $sns = get_post_meta( $post_id, '_SnS', true );
64 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
65 |
66 | header( 'Content-Type: text/css; charset=UTF-8' );
67 |
68 | if ( ! empty( $options['styles'] ) ) {
69 | echo $options['styles']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
70 | }
71 |
72 | if ( ! empty( $styles['styles'] ) ) {
73 | echo $styles['styles']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
74 | }
75 |
76 | exit();
77 | } );
78 | add_action( 'wp_ajax_sns_tinymce_styles', function () {
79 | check_ajax_referer( 'sns_tinymce_styles' );
80 |
81 | if ( empty( $_REQUEST['post_id'] ) ) {
82 | exit( 'Bad post ID.' );
83 | }
84 | $post_id = absint( $_REQUEST['post_id'] );
85 |
86 | $options = get_option( 'SnS_options' );
87 | $sns = get_post_meta( $post_id, '_SnS', true );
88 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
89 |
90 | header( 'Content-Type: text/css; charset=UTF-8' );
91 |
92 | if ( ! empty( $options['styles'] ) ) {
93 | echo $options['styles']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
94 | }
95 |
96 | if ( ! empty( $styles['styles'] ) ) {
97 | echo $styles['styles']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
98 | }
99 |
100 | exit();
101 | } );
102 |
103 | // Ajax Saves.
104 | add_action( 'wp_ajax_sns_classes', function () {
105 | check_ajax_referer( BASENAME );
106 | if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) {
107 | exit( 'Insufficient Privileges.' );
108 | }
109 |
110 | if ( empty( $_REQUEST['post_id'] ) ) {
111 | exit( 'Bad post ID.' );
112 | }
113 | if ( ! isset( $_REQUEST['classes_body'], $_REQUEST['classes_post'] ) ) {
114 | exit( 'Data missing.' );
115 | }
116 |
117 | $post_id = absint( $_REQUEST['post_id'] );
118 | $sns = get_post_meta( $post_id, '_SnS', true );
119 | $sns = is_array( $sns ) ? $sns : []; // Something changed in PHP 7/WP 4.8.
120 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
121 |
122 | $styles = maybe_set( $styles, 'classes_body' );
123 | $styles = maybe_set( $styles, 'classes_post' );
124 |
125 | if ( empty( $styles ) ) {
126 | if ( isset( $sns['styles'] ) ) {
127 | unset( $sns['styles'] );
128 | }
129 | } else {
130 | $sns['styles'] = $styles;
131 | }
132 | maybe_update( $post_id, '_SnS', $sns );
133 |
134 | header( 'Content-Type: application/json; charset=UTF-8' );
135 | echo wp_json_encode( [
136 | 'classes_post' => $_REQUEST['classes_post'],
137 | 'classes_body' => $_REQUEST['classes_body'],
138 | ] );
139 |
140 | exit();
141 | } );
142 |
143 | add_action( 'wp_ajax_sns_scripts', function () {
144 | check_ajax_referer( BASENAME );
145 | if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) {
146 | exit( 'Insufficient Privileges.' );
147 | }
148 |
149 | if ( empty( $_REQUEST['post_id'] ) ) {
150 | exit( 'Bad post ID.' );
151 | }
152 | if ( ! isset( $_REQUEST['scripts'], $_REQUEST['scripts_in_head'] ) ) {
153 | exit( 'Data incorrectly sent.' );
154 | }
155 |
156 | $post_id = absint( $_REQUEST['post_id'] );
157 | $sns = get_post_meta( $post_id, '_SnS', true );
158 | $sns = is_array( $sns ) ? $sns : []; // Something changed in PHP 7/WP 4.8.
159 | $scripts = isset( $sns['scripts'] ) ? $sns['scripts'] : [];
160 |
161 | $scripts = maybe_set( $scripts, 'scripts_in_head' );
162 | $scripts = maybe_set( $scripts, 'scripts' );
163 |
164 | if ( empty( $scripts ) ) {
165 | if ( isset( $sns['scripts'] ) ) {
166 | unset( $sns['scripts'] );
167 | }
168 | } else {
169 | $sns['scripts'] = $scripts;
170 | }
171 | maybe_update( $post_id, '_SnS', $sns );
172 |
173 | header( 'Content-Type: application/json; charset=UTF-8' );
174 | echo wp_json_encode( [
175 | 'scripts' => $_REQUEST['scripts'],
176 | 'scripts_in_head' => $_REQUEST['scripts_in_head'],
177 | ] );
178 |
179 | exit();
180 | } );
181 |
182 | add_action( 'wp_ajax_sns_styles', function () {
183 | check_ajax_referer( BASENAME );
184 | if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) {
185 | exit( 'Insufficient Privileges.' );
186 | }
187 |
188 | if ( empty( $_REQUEST['post_id'] ) ) {
189 | exit( 'Bad post ID.' );
190 | }
191 | if ( ! isset( $_REQUEST['styles'] ) ) {
192 | exit( 'Data incorrectly sent.' );
193 | }
194 |
195 | $post_id = absint( $_REQUEST['post_id'] );
196 | $sns = get_post_meta( $post_id, '_SnS', true );
197 | $sns = is_array( $sns ) ? $sns : []; // Something changed in PHP 7/WP 4.8.
198 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
199 |
200 | $styles = maybe_set( $styles, 'styles' );
201 |
202 | if ( empty( $styles ) ) {
203 | if ( isset( $sns['styles'] ) ) {
204 | unset( $sns['styles'] );
205 | }
206 | } else {
207 | $sns['styles'] = $styles;
208 | }
209 | maybe_update( $post_id, '_SnS', $sns );
210 |
211 | header( 'Content-Type: application/json; charset=UTF-8' );
212 | echo wp_json_encode( [
213 | 'styles' => $_REQUEST['styles'],
214 | ] );
215 |
216 | exit();
217 | } );
218 |
219 | add_action( 'wp_ajax_sns_dropdown', function () {
220 | check_ajax_referer( BASENAME );
221 | if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) {
222 | exit( 'Insufficient Privileges.' );
223 | }
224 |
225 | if ( empty( $_REQUEST['format'] ) ) {
226 | exit( 'Missing Format.' );
227 | }
228 | if ( empty( $_REQUEST['format']['title'] ) ) {
229 | exit( 'Title is required.' );
230 | }
231 | if ( empty( $_REQUEST['format']['classes'] ) ) {
232 | exit( 'Classes is required.' );
233 | }
234 | if (
235 | empty( $_REQUEST['format']['inline'] ) &&
236 | empty( $_REQUEST['format']['block'] ) &&
237 | empty( $_REQUEST['format']['selector'] )
238 | ) {
239 | exit( 'A type is required.' );
240 | }
241 |
242 | if ( empty( $_REQUEST['post_id'] ) ) {
243 | exit( 'Bad post ID.' );
244 | }
245 | $post_id = absint( $_REQUEST['post_id'] );
246 |
247 | $sns = get_post_meta( $post_id, '_SnS', true );
248 | $sns = is_array( $sns ) ? $sns : []; // Something changed in PHP 7/WP 4.8 .
249 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
250 |
251 | if ( ! isset( $styles['classes_mce'] ) ) {
252 | $styles['classes_mce'] = [];
253 | }
254 |
255 | // pass title as key to be able to delete.
256 | $styles['classes_mce'][ $_REQUEST['format']['title'] ] = $_REQUEST['format'];
257 |
258 | $sns['styles'] = $styles;
259 | update_post_meta( $post_id, '_SnS', $sns );
260 |
261 | header( 'Content-Type: application/json; charset=UTF-8' );
262 | echo wp_json_encode( [
263 | 'classes_mce' => array_values( $styles['classes_mce'] ),
264 | ] );
265 |
266 | exit();
267 | } );
268 |
269 | add_action( 'wp_ajax_sns_delete_class', function () {
270 | check_ajax_referer( BASENAME );
271 | if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) {
272 | exit( 'Insufficient Privileges.' );
273 | }
274 |
275 | if ( empty( $_REQUEST['post_id'] ) ) {
276 | exit( 'Bad post ID.' );
277 | }
278 | $post_id = absint( $_REQUEST['post_id'] );
279 | $sns = get_post_meta( $post_id, '_SnS', true );
280 | $sns = is_array( $sns ) ? $sns : []; // Something changed in PHP 7/WP 4.8.
281 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
282 |
283 | $title = $_REQUEST['delete'];
284 |
285 | if ( isset( $styles['classes_mce'][ $title ] ) ) {
286 | unset( $styles['classes_mce'][ $title ] );
287 | } else {
288 | exit( 'No Format of that name.' );
289 | }
290 |
291 | if ( empty( $styles['classes_mce'] ) ) {
292 | unset( $styles['classes_mce'] );
293 | }
294 |
295 | if ( empty( $styles ) ) {
296 | if ( isset( $sns['styles'] ) ) {
297 | unset( $sns['styles'] );
298 | }
299 | } else {
300 | $sns['styles'] = $styles;
301 | }
302 | maybe_update( $post_id, '_SnS', $sns );
303 |
304 | if ( ! isset( $styles['classes_mce'] ) ) {
305 | $styles['classes_mce'] = [ 'Empty' ];
306 | }
307 |
308 | header( 'Content-Type: application/json; charset=UTF-8' );
309 | echo wp_json_encode( [
310 | 'classes_mce' => array_values( $styles['classes_mce'] ),
311 | ] );
312 |
313 | exit();
314 | } );
315 |
316 | add_action( 'wp_ajax_sns_shortcodes', function () {
317 | check_ajax_referer( BASENAME );
318 | if ( ! current_user_can( 'unfiltered_html' ) || ! current_user_can( 'edit_posts' ) ) {
319 | exit( 'Insufficient Privileges.' );
320 | }
321 |
322 | if ( empty( $_REQUEST['post_id'] ) ) {
323 | exit( 'Bad post ID.' );
324 | }
325 | if ( empty( $_REQUEST['subaction'] ) ) {
326 | exit( 'missing directive' );
327 | }
328 |
329 | if ( in_array( $_REQUEST['subaction'], [ 'add', 'update', 'delete' ], true ) ) {
330 | $subaction = $_REQUEST['subaction'];
331 | } else {
332 | exit( 'unknown directive' );
333 | }
334 |
335 | $post_id = absint( $_REQUEST['post_id'] );
336 | $sns = get_post_meta( $post_id, '_SnS', true );
337 | $sns = is_array( $sns ) ? $sns : []; // Something changed in PHP 7/WP 4.8.
338 | $shortcodes = isset( $sns['shortcodes'] ) ? $sns['shortcodes'] : [];
339 | $message = '';
340 | $code = 0;
341 | $key = '';
342 | $value = '';
343 |
344 | if ( isset( $_REQUEST['name'] ) ) {
345 | $key = $_REQUEST['name'];
346 | } else {
347 | exit( 'bad directive.' );
348 | }
349 |
350 | if ( '' === $key ) {
351 | $key = count( $shortcodes );
352 | while ( isset( $shortcodes[ $key ] ) ) {
353 | $key++;
354 | }
355 | }
356 |
357 | switch ( $subaction ) {
358 | case 'add':
359 | if ( empty( $_REQUEST['shortcode'] ) ) {
360 | exit( 'empty value.' );
361 | } else {
362 | $value = $_REQUEST['shortcode'];
363 | }
364 |
365 | if ( isset( $shortcodes[ $key ] ) ) {
366 | $countr = 1;
367 | while ( isset( $shortcodes[ $key . '_' . $countr ] ) ) {
368 | $countr++;
369 | }
370 | $key .= '_' . $countr;
371 | }
372 |
373 | $code = 1;
374 |
375 | $shortcodes[ $key ] = $value;
376 | break;
377 |
378 | case 'update':
379 | if ( empty( $_REQUEST['shortcode'] ) ) {
380 | if ( isset( $shortcodes[ $key ] ) ) {
381 | unset( $shortcodes[ $key ] );
382 | }
383 | $code = 3;
384 | $message = $key;
385 | } else {
386 | $value = $_REQUEST['shortcode'];
387 | if ( isset( $shortcodes[ $key ] ) ) {
388 | $shortcodes[ $key ] = $value;
389 | } else {
390 | exit( 'wrong key.' );
391 | }
392 | $code = 2;
393 | $message = 'updated ' . $key;
394 | }
395 | break;
396 |
397 | case 'delete':
398 | if ( isset( $shortcodes[ $key ] ) ) {
399 | unset( $shortcodes[ $key ] );
400 | } else {
401 | exit( 'bad key.' );
402 | }
403 | $code = 3;
404 | $message = $key;
405 | break;
406 | }
407 |
408 | if ( empty( $shortcodes ) ) {
409 | if ( isset( $sns['shortcodes'] ) ) {
410 | unset( $sns['shortcodes'] );
411 | }
412 | } else {
413 | $sns['shortcodes'] = $shortcodes;
414 | }
415 | maybe_update( $post_id, '_SnS', $sns );
416 |
417 | if ( 1 < $code ) {
418 | header( 'Content-Type: application/json; charset=UTF-8' );
419 | echo wp_json_encode( [
420 | 'message' => $message,
421 | 'code' => $code,
422 | ] );
423 | } else {
424 | header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
425 | ?>
433 | sns_scripts['scripts_in_head'] ) ) {
35 | $return .= '' . esc_html__( 'Scripts (head)', 'scripts-n-styles' ) . '
';
36 | }
37 | if ( isset( $post->sns_scripts['scripts'] ) ) {
38 | $return .= '' . esc_html__( 'Scripts', 'scripts-n-styles' ) . '
';
39 | }
40 | if ( isset( $post->sns_scripts['enqueue_scripts'] ) ) {
41 | $return .= '' . esc_html__( 'Enqueued Scripts', 'scripts-n-styles' ) . '
';
42 | }
43 | return $return;
44 | }
45 | /**
46 | * Build columns.
47 | *
48 | * @param object $post A WordPress $post object.
49 | */
50 | public function column_style_data( $post ) {
51 | $return = '';
52 | if ( isset( $post->sns_styles['classes_mce'] ) ) {
53 | $return .= '' . esc_html__( 'TinyMCE Formats', 'scripts-n-styles' ) . '
';
54 | }
55 | if ( isset( $post->sns_styles['styles'] ) ) {
56 | $return .= '' . esc_html__( 'Styles', 'scripts-n-styles' ) . '
';
57 | }
58 | if ( isset( $post->sns_styles['classes_post'] ) ) {
59 | $return .= '' . esc_html__( 'Post Classes', 'scripts-n-styles' ) . '
';
60 | }
61 | if ( isset( $post->sns_styles['classes_body'] ) ) {
62 | $return .= '' . esc_html__( 'Body Classes', 'scripts-n-styles' ) . '
';
63 | }
64 | return $return;
65 | }
66 | /**
67 | * Build columns.
68 | *
69 | * @param object $post A WordPress $post object.
70 | */
71 | public function column_hoops_data( $post ) {
72 | $hoops = [];
73 | if ( isset( $post->sns_hoops ) ) {
74 | foreach ( $post->sns_hoops as $hoop => $shortcode ) {
75 | $hoops[] = '[hoops name="' . $hoop . '"]';
76 | }
77 | }
78 | return implode( ' ', $hoops );
79 | }
80 |
81 | /**
82 | * Build title column.
83 | *
84 | * @param object $post A WordPress $post object.
85 | */
86 | public function column_title( $post ) {
87 | $edit_link = esc_url( get_edit_post_link( $post->ID ) );
88 | // Translators: Link to edit the post.
89 | $edit_title = esc_attr( sprintf( __( 'Edit “%s”', 'scripts-n-styles' ), $post->post_title ) );
90 |
91 | ?>
92 |
93 | ajax_user_can() && 'trash' !== $post->post_status ) {
95 | ?>
96 |
97 | post_title ); ?>
98 |
99 | post_title );
102 | }
103 | _post_states( $post );
104 | ?>
105 |
106 | (type: post_type ); ?>)
107 | esc_html__( 'Title', 'scripts-n-styles' ),
116 | 'script_data' => esc_html__( 'Script Data', 'scripts-n-styles' ),
117 | 'style_data' => esc_html__( 'Style Data', 'scripts-n-styles' ),
118 | 'hoops_data' => esc_html__( 'Hoops Data', 'scripts-n-styles' ),
119 | ];
120 | }
121 |
122 | /**
123 | * Build query.
124 | */
125 | public function prepare_items() {
126 | $screen_id = get_current_screen()->id;
127 | $per_page = $this->get_items_per_page( "{$screen_id}_per_page", 20 );
128 |
129 | /**
130 | * Get Relavent Posts.
131 | */
132 | $query = new \WP_Query( [
133 | 'posts_per_page' => $per_page,
134 | 'paged' => $this->get_pagenum(),
135 | 'post_type' => 'any',
136 | 'post_status' => 'any',
137 | 'orderby' => 'ID',
138 | 'order' => 'ASC',
139 | 'meta_key' => '_SnS', // WPCS: slow query ok.
140 | ] );
141 |
142 | $this->items = $this->add_meta_data( $query->posts );
143 |
144 | $this->set_pagination_args( [
145 | 'total_items' => $query->found_posts,
146 | 'per_page' => $per_page,
147 | 'total_pages' => $query->max_num_pages,
148 | ] );
149 |
150 | $this->_column_headers = [
151 | $this->get_columns(),
152 | [],
153 | $this->get_sortable_columns(),
154 | ];
155 | }
156 |
157 | /**
158 | * Build metadata onto post objects.
159 | *
160 | * @param array $posts An array of $post objects.
161 | */
162 | private function add_meta_data( $posts ) {
163 | foreach ( $posts as $post ) {
164 | $sns = get_post_meta( $post->ID, '_SnS', true );
165 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
166 | $scripts = isset( $sns['scripts'] ) ? $sns['scripts'] : [];
167 | $hoops = isset( $sns['shortcodes'] ) ? $sns['shortcodes'] : [];
168 | if ( ! empty( $styles ) ) {
169 | $post->sns_styles = $styles;
170 | }
171 | if ( ! empty( $scripts ) ) {
172 | $post->sns_scripts = $scripts;
173 | }
174 | if ( ! empty( $hoops ) ) {
175 | $post->sns_hoops = $hoops;
176 | }
177 | }
178 | return $posts;
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/dist/includes/form.php:
--------------------------------------------------------------------------------
1 | ' . esc_textarea( $value ) . '';
38 | if ( $wrap_class ) {
39 | $textarea = '' . $textarea . '
';
40 | }
41 | $textarea .= $description;
42 | echo wp_kses_post( $textarea );
43 | }
44 |
45 | /**
46 | * Outputs a radio for setting.
47 | *
48 | * @param array $args A set of args.
49 | */
50 | function radio( $args ) {
51 |
52 | $setting = $args['setting'];
53 | $label_for = $args['label_for'];
54 | $options = get_option( $setting );
55 | $default = isset( $args['default'] ) ? $args['default'] : '';
56 | $value = isset( $options[ $label_for ] ) ? $options[ $label_for ] : $default;
57 |
58 | $legend = isset( $args['legend'] ) ? $args['legend'] : '';
59 | $description = isset( $args['description'] ) ? $args['description'] : '';
60 | $layout = isset( $args['layout'] ) && 'horizontal' === $args['layout'];
61 | $choices = isset( $args['choices'] ) ? $args['choices'] : [];
62 | ?>
63 |
64 |
65 |
66 |
67 |
68 |
69 |
71 | value=""
72 | name=""
73 | >
74 | '; ?>
75 |
76 |
77 |
78 |
100 |
103 | size=""
104 | style="">
105 |
106 |
116 | >
117 |
118 |
119 |
122 |
123 |
124 |
125 |
126 |
127 | ' . esc_html__( 'Cheatin’ uh?', 'scripts-n-styles' ) . '' .
140 | '' . esc_html__( 'Sorry, you are not allowed to manage these options.', 'scripts-n-styles' ) . '
',
141 | 403
142 | );
143 | }
144 |
145 | // Handle menu-redirected update message.
146 | if ( ! empty( $_REQUEST['message'] ) ) { // Input var okay.
147 | add_settings_error( $page, 'settings_updated', esc_html__( 'Settings saved.', 'scripts-n-styles' ), 'updated' );
148 | }
149 |
150 | if ( ! isset( $_REQUEST['action'], $_REQUEST['option_page'], $_REQUEST['page'] ) ) { // Input var okay.
151 | return;
152 | }
153 |
154 | wp_reset_vars( [ 'action', 'option_page', 'page' ] );
155 |
156 | check_admin_referer( $option_page . '-options' );
157 |
158 | if ( ! isset( $new_whitelist_options[ $option_page ] ) ) {
159 | return;
160 | }
161 |
162 | $options = $new_whitelist_options[ $option_page ];
163 | foreach ( (array) $options as $option ) {
164 | $old = get_option( $option );
165 | $option = trim( $option );
166 | $new = null;
167 | if ( isset( $_POST[ $option ] ) ) {
168 | $new = wp_unslash( $_POST[ $option ] );
169 | }
170 | if ( ! is_array( $new ) ) {
171 | $new = trim( $new );
172 | }
173 | $new = stripslashes_deep( $new );
174 | $value = array_merge( $old, $new );
175 |
176 | // Allow modification of $value.
177 | $value = apply_filters( 'sns_options_pre_update_option', $value, $page, $action, $new, $old );
178 |
179 | update_option( $option, $value );
180 | }
181 |
182 | if ( ! count( get_settings_errors() ) ) {
183 | add_settings_error( $page, 'settings_updated', __( 'Settings saved.', 'scripts-n-styles' ), 'updated' );
184 | }
185 |
186 | if ( ! empty( $_REQUEST['ajaxsubmit'] ) ) {
187 | ob_start();
188 | settings_errors( $page );
189 | $output = ob_get_contents();
190 | ob_end_clean();
191 | exit( wp_kses_post( $output ) );
192 | }
193 | }
194 |
195 | /**
196 | * Outputs the Admin Page and calls the Settings registered with the Settings API in init_options_page().
197 | */
198 | function page() {
199 | ?>
200 |
201 |
202 |
211 |
212 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 | 'php' ] );
32 | wp_enqueue_script( 'sns-global-page' );
33 | wp_localize_script( 'sns-global-page', '_SnSOptions', [
34 | 'root' => plugins_url( '/', BASENAME ),
35 | ] );
36 | } );
37 |
38 | /**
39 | * Settings Page
40 | * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
41 | */
42 | add_action( "load-$hook_suffix", function() {
43 |
44 | register_setting(
45 | OPTION_GROUP,
46 | 'SnS_options'
47 | );
48 |
49 | add_settings_section(
50 | 'global_styles',
51 | __( 'Blog Wide CSS Styles', 'scripts-n-styles' ),
52 | function() {
53 | ?>
54 |
55 |
every page (and post) of your site, including the homepage and archives. The code will appear before Styles that were registered individually.', 'scripts-n-styles' ); ?>
56 |
57 |
67 |
68 |
every page (and post) of your site, including the homepage and archives. The code will appear before Scripts that were registered individually.', 'scripts-n-styles' ); ?>
69 |
70 | LESS: ', 'scripts-n-styles' ),
78 | function() {
79 | $options = get_option( 'SnS_options' );
80 | $less = isset( $options['less'] ) ? $options['less'] : '';
81 | $compiled = isset( $options['compiled'] ) ? $options['compiled'] : '';
82 | ?>
83 |
92 | 'less' ]
97 | );
98 | add_settings_field(
99 | 'coffee',
100 | __( 'CoffeeScript: ', 'scripts-n-styles' ),
101 | function() {
102 | $options = get_option( 'SnS_options' );
103 | $coffee = isset( $options['coffee'] ) ? $options['coffee'] : '';
104 | $compiled = isset( $options['coffee_compiled'] ) ? $options['coffee_compiled'] : '';
105 | ?>
106 |
107 |
108 |
109 |
110 |
114 |
115 | 'coffee' ]
120 | );
121 | add_settings_field(
122 | 'styles',
123 | __( 'CSS Styles: ', 'scripts-n-styles' ),
124 | __NAMESPACE__ . '\textarea',
125 | ADMIN_MENU_SLUG,
126 | 'global_styles',
127 | [
128 | 'label_for' => 'styles',
129 | 'setting' => 'SnS_options',
130 | 'class' => 'code css autoheight',
131 | 'wrap_class' => 'style',
132 | 'rows' => 10,
133 | 'description' => __( 'The "Styles" will be included verbatim in <style>
tags in the <head>
element of your html. ', 'scripts-n-styles' ),
134 | ]
135 | );
136 | add_settings_field(
137 | 'scripts_in_head',
138 | __( 'Scripts (for the head
element): ', 'scripts-n-styles' ),
139 | __NAMESPACE__ . '\textarea',
140 | ADMIN_MENU_SLUG,
141 | 'global_scripts',
142 | [
143 | 'label_for' => 'scripts_in_head',
144 | 'setting' => 'SnS_options',
145 | 'class' => 'code js autoheight',
146 | 'wrap_class' => 'script',
147 | 'rows' => 10,
148 | 'description' => __( 'The "Scripts (in head)" will be included verbatim in <script>
tags in the <head>
element of your html. ', 'scripts-n-styles' ),
149 | ]
150 | );
151 | add_settings_field(
152 | 'scripts',
153 | wp_kses_post( __( 'Scripts (end of the body
tag):', 'scripts-n-styles' ) ),
154 | __NAMESPACE__ . '\textarea',
155 | ADMIN_MENU_SLUG,
156 | 'global_scripts',
157 | [
158 | 'label_for' => 'scripts',
159 | 'setting' => 'SnS_options',
160 | 'class' => 'code js autoheight',
161 | 'wrap_class' => 'script',
162 | 'rows' => 10,
163 | 'description' => __( 'The "Scripts" will be included verbatim in <script>
tags at the bottom of the <body>
element of your html. ', 'scripts-n-styles' ),
164 | ]
165 | );
166 | add_settings_field(
167 | 'enqueue_scripts',
168 | __( 'Enqueue Scripts : ', 'scripts-n-styles' ),
169 | __NAMESPACE__ . '\select',
170 | ADMIN_MENU_SLUG,
171 | 'global_scripts',
172 | [
173 | 'label_for' => 'enqueue_scripts',
174 | 'setting' => 'SnS_options',
175 | 'choices' => get_registered_scripts(),
176 | 'size' => 5,
177 | 'style' => 'height: auto;',
178 | 'multiple' => true,
179 | 'show_current' => __( 'Currently Enqueued Scripts: ', 'scripts-n-styles' ),
180 | ]
181 | );
182 |
183 | add_filter( 'sns_options_pre_update_option', function( $value, $page, $action, $new, $old ) {
184 | if ( empty( $new['enqueue_scripts'] ) && ! empty( $old['enqueue_scripts'] ) ) {
185 | unset( $value['enqueue_scripts'] );
186 | }
187 | return $value;
188 | }, 10, 5 );
189 |
190 | } );
191 | } );
192 |
--------------------------------------------------------------------------------
/dist/includes/hoops-page.php:
--------------------------------------------------------------------------------
1 | 'html' ] );
32 | wp_enqueue_script( 'sns-hoops-page' );
33 | wp_localize_script( 'sns-hoops-page', '_SnSOptions', [
34 | 'root' => plugins_url( '/', BASENAME ),
35 | ] );
36 | } );
37 |
38 | /**
39 | * Settings Page
40 | * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
41 | */
42 | add_action( "load-$hook_suffix", function() {
43 | // Added here to not effect other pages.
44 | add_filter( 'sns_options_pre_update_option', function( $options ) {
45 | // Get Hoops (Shouldn't be empty).
46 | $hoops = $options['hoops'];
47 |
48 | // Take out new (Also shouldn't be empty).
49 | $new = $hoops['new'];
50 | unset( $hoops['new'] );
51 |
52 | // Get Shortcodes (Could be empty).
53 | $shortcodes = empty( $hoops['shortcodes'] ) ? [] : $hoops['shortcodes'];
54 |
55 | // Prune shortcodes with blank values.
56 | foreach ( $shortcodes as $key => $value ) {
57 | if ( empty( $value ) ) {
58 | unset( $shortcodes[ $key ] );
59 | }
60 | }
61 |
62 | // Add new code (if not empty).
63 | if ( ! empty( $new['code'] ) ) {
64 | $name = empty( $new['name'] ) ? '' : $new['name'];
65 |
66 | if ( '' === $name ) {
67 | // If blank, find next index..
68 | $name = 0;
69 | while ( isset( $shortcodes[ $name ] ) ) {
70 | $name++;
71 | }
72 | } elseif ( isset( $shortcodes[ $name ] ) ) {
73 | // To make sure not to overwrite.
74 | $countr = 1;
75 | while ( isset( $shortcodes[ $name . '_' . $countr ] ) ) {
76 | $countr++;
77 | }
78 | $name .= '_' . $countr;
79 | }
80 |
81 | // Add new to shortcodes.
82 | $shortcodes[ $name ] = $new['code'];
83 | }
84 |
85 | // Put in Shortcodes... if not empty.
86 | if ( empty( $shortcodes ) ) {
87 | if ( isset( $hoops['shortcodes'] ) ) {
88 | unset( $hoops['shortcodes'] );
89 | }
90 | } else {
91 | $hoops['shortcodes'] = $shortcodes;
92 | }
93 |
94 | // Put in Hoops... if not empty.
95 | if ( empty( $hoops ) ) {
96 | if ( isset( $options['hoops'] ) ) {
97 | unset( $options['hoops'] );
98 | }
99 | } else {
100 | $options['hoops'] = $hoops;
101 | }
102 |
103 | return $options; // Finish Filter.
104 | } );
105 |
106 | register_setting(
107 | OPTION_GROUP,
108 | 'SnS_options'
109 | );
110 |
111 | add_settings_section(
112 | 'hoops_section',
113 | __( 'The Hoops Shortcodes', 'scripts-n-styles' ),
114 | function() {
115 | echo '';
116 | echo wp_kses_post( __( '
"Hoops" are shortcodes invented to get around some limitations of vanilla WordPress.
', 'scripts-n-styles' ) )
117 | . wp_kses_post( __(
118 | '
Normally, certain HTML is very problematic to use in the Post Editor, because it either gets jumbled during Switching between HTML and Visual Tabs, stripped out by WPAutoP (rare) or stripped out because the User doesn’t have the proper Permissions.
', 'scripts-n-styles'
119 | ) )
120 | . wp_kses_post( __(
121 | '
With Hoops, an Admin user (who has `unfiltered_html` and `manage_options` capablilities) can write and approve snippets of HTML for other users to use via Shortcodes.
', 'scripts-n-styles'
122 | ) );
123 | echo '
';
124 |
125 | $options = get_option( 'SnS_options' );
126 |
127 | $meta_name = 'SnS_options[hoops]';
128 | $hoops = isset( $options['hoops'] ) ? $options['hoops'] : [];
129 | $shortcodes = isset( $hoops['shortcodes'] ) ? $hoops['shortcodes'] : [];
130 | ?>
131 |
132 |
133 |
140 |
141 |
142 |
143 |
144 |
145 | $value ) { ?>
146 |
147 |
154 |
155 |
156 |
157 |
158 |
159 | add_node( [
21 | 'id' => 'Scripts_n_Styles',
22 | 'title' => $title,
23 | 'href' => admin_url( 'admin.php?page=' . ADMIN_MENU_SLUG ),
24 | 'meta' => [ 'class' => 'Scripts_n_Styles' ],
25 | ] );
26 | }, 11 );
27 |
28 |
29 | /**
30 | * Theme support of Scripts n Styles
31 | * If a theme registers support, replace css with a generated version.
32 | */
33 | add_action( 'wp_print_styles', function() {
34 | if ( ! current_theme_supports( 'scripts-n-styles' ) ) {
35 | return;
36 | }
37 |
38 | $options = get_option( 'SnS_options' );
39 | $slug = get_stylesheet();
40 |
41 | if ( ! empty( $options['themes'][ $slug ]['compiled'] ) ) {
42 | wp_deregister_style( 'theme_style' );
43 | wp_enqueue_style( 'theme_style', add_query_arg( [ 'action' => 'sns_theme_css' ], admin_url( 'admin-ajax.php' ) ), [], time() );
44 | }
45 | } );
46 |
47 | /**
48 | * Gets the generated theme css
49 | */
50 | function theme_css() {
51 | $options = get_option( 'SnS_options' );
52 | $slug = get_stylesheet();
53 | $compiled = $options['themes'][ $slug ]['compiled'];
54 | header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 864000 ) . ' GMT' );
55 | header( 'Cache-Control: public, max-age=864000' );
56 | header( 'Content-Type: text/css; charset=UTF-8' );
57 | echo $compiled; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
58 | die();
59 | }
60 | add_action( 'wp_ajax_sns_theme_css', __NAMESPACE__ . '\theme_css' );
61 | add_action( 'wp_ajax_nopriv_sns_theme_css', __NAMESPACE__ . '\theme_css' );
62 |
63 | /**
64 | * The Hoops shortcode
65 | *
66 | * @param string $atts Stuff.
67 | * @param string $content Stuff.
68 | * @param string $tag Stuff.
69 | */
70 | function hoops_shortcode( $atts, $content = null, $tag ) {
71 | global $post;
72 | $atts = shortcode_atts( [ 'name' => 0 ], $atts );
73 | $output = '';
74 |
75 | $options = get_option( 'SnS_options' );
76 | $hoops = isset( $options['hoops']['shortcodes'] ) ? $options['hoops']['shortcodes'] : [];
77 |
78 | if ( isset( $post->ID ) ) {
79 | $sns = get_post_meta( $post->ID, '_SnS', true );
80 | $shortcodes = isset( $sns['shortcodes'] ) ? $sns['shortcodes'] : [];
81 | }
82 |
83 | if ( isset( $shortcodes[ $atts['name'] ] ) ) {
84 | $output .= $shortcodes[ $atts['name'] ];
85 | } elseif ( isset( $hoops[ $atts['name'] ] ) ) {
86 | $output .= $hoops[ $atts['name'] ];
87 | }
88 |
89 | if ( ! empty( $content ) && empty( $output ) ) {
90 | $output = $content;
91 | }
92 | $output = do_shortcode( $output );
93 |
94 | return $output;
95 | }
96 | add_action( 'plugins_loaded', function() {
97 | add_shortcode( 'sns_shortcode', __NAMESPACE__ . '\hoops_shortcode' );
98 | add_shortcode( 'hoops', __NAMESPACE__ . '\hoops_shortcode' );
99 | } );
100 |
101 | /**
102 | * Register legacy scripts
103 | *
104 | * These where registered and made available to users in the past.
105 | */
106 | function legacy_scripts() {
107 | $dir = plugins_url( '/', BASENAME );
108 | $vendor = $dir . 'legacy/';
109 | wp_register_script( 'clean-css', $vendor . 'cleancss-browser.js', [], '3.4.21-min', false );
110 | wp_register_script( 'less.js', $vendor . 'less.min.js', [], '2.7.1-min', false );
111 | wp_register_script( 'coffeescript', $vendor . 'coffee-script.js', [], '1.12.1-min', false );
112 | wp_register_script( 'chosen', $vendor . 'chosen/chosen.jquery.min.js', [ 'jquery' ], '1.0.0', true );
113 | wp_register_style( 'chosen', $vendor . 'chosen/chosen.min.css', [], '1.0.0', false );
114 | wp_register_script( 'html5shiv', $vendor . 'html5shiv.js', [], '3.7.3', false );
115 | wp_register_script( 'html5shiv-printshiv', $vendor . 'html5shiv-printshiv.js', [], '3.7.3', false );
116 | }
117 | add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\legacy_scripts' );
118 | add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\legacy_scripts' );
119 |
120 |
121 | /**
122 | * Register bundled scripts
123 | */
124 | function register_scripts() {
125 | $dir = plugins_url( '/', BASENAME );
126 |
127 | $js = $dir . 'js/';
128 | wp_register_script( 'sns-settings-page', $js . 'settings-page.min.js', [], VERSION, true );
129 | wp_register_script( 'sns-global-page', $js . 'global-page.min.js', [], VERSION, true );
130 | wp_register_script( 'sns-theme-page', $js . 'theme-page.min.js', [ 'code-editor' ], VERSION, true );
131 | wp_register_script( 'sns-hoops-page', $js . 'hoops-page.min.js', [ 'code-editor' ], VERSION, true );
132 | wp_register_script( 'sns-meta-box', $js . 'meta-box.min.js', [ 'editor', 'jquery-ui-tabs', 'chosen', 'code-editor' ], VERSION, true );
133 | wp_register_script( 'sns-rest', $js . 'rest.min.js', [ 'wp-api', 'code-editor' ], VERSION, true );
134 |
135 | // Use a correctly bundled version of CodeMirror.
136 | wp_deregister_script( 'wp-codemirror' );
137 | wp_register_script( 'wp-codemirror', $dir . 'codemirror/codemirror.min.js', [], '5.56.0', true );
138 |
139 | // Rebundled version of CodeMirror.
140 | wp_deregister_style( 'wp-codemirror' );
141 | wp_register_style( 'wp-codemirror', $dir . 'codemirror/codemirror.min.css', [], '5.56.0' );
142 | }
143 | add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\register_scripts' );
144 | add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\register_scripts' );
145 |
146 | /**
147 | * Theme Action: 'wp_head()'
148 | * Outputs the globally and individually set Styles in the Theme's head element.
149 | */
150 | add_action( 'wp_head', function() {
151 | // Global output.
152 | $options = get_option( 'SnS_options' );
153 | if ( ! empty( $options ) && ! empty( $options['styles'] ) ) {
154 | echo '';
157 | }
158 | if ( ! empty( $options ) && ! empty( $options['compiled'] ) ) {
159 | echo '';
162 | }
163 |
164 | if ( ! is_singular() ) {
165 | return;
166 | }
167 | // Individual.
168 | global $post;
169 | $sns = get_post_meta( $post->ID, '_SnS', true );
170 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
171 | if ( ! empty( $styles ) && ! empty( $styles['styles'] ) ) {
172 | echo '';
175 | }
176 | }, 11 );
177 |
178 | /**
179 | * Theme Action: 'wp_footer()'
180 | * Outputs the globally and individually set Scripts at the end of the Theme's body element.
181 | */
182 | add_action( 'wp_footer', function() {
183 | // Global output.
184 | $options = get_option( 'SnS_options' );
185 | if ( ! empty( $options ) && ! empty( $options['scripts'] ) ) {
186 | echo '';
189 | }
190 | if ( ! empty( $options ) && ! empty( $options['coffee_compiled'] ) ) {
191 | echo '';
194 | }
195 |
196 | if ( ! is_singular() ) {
197 | return;
198 | }
199 | // Individual.
200 | global $post;
201 | $sns = get_post_meta( $post->ID, '_SnS', true );
202 | $scripts = isset( $sns['scripts'] ) ? $sns['scripts'] : [];
203 | if ( ! empty( $scripts ) && ! empty( $scripts['scripts'] ) ) {
204 | echo '';
207 | }
208 | }, 11 );
209 |
210 | /**
211 | * Theme Action: 'wp_head()'
212 | * Outputs the globally and individually set Scripts in the Theme's head element.
213 | */
214 | add_action( 'wp_head', function() {
215 | // Global ouput.
216 | $options = get_option( 'SnS_options' );
217 | if ( ! empty( $options ) && ! empty( $options['scripts_in_head'] ) ) {
218 | echo '';
221 | }
222 |
223 | if ( ! is_singular() ) {
224 | return;
225 | }
226 | // Individual.
227 | global $post;
228 | $sns = get_post_meta( $post->ID, '_SnS', true );
229 | $scripts = isset( $sns['scripts'] ) ? $sns['scripts'] : [];
230 | if ( ! empty( $scripts ) && ! empty( $scripts['scripts_in_head'] ) ) {
231 | echo '';
234 | }
235 | }, 11 );
236 |
237 | /**
238 | * Theme Filter: 'body_class()'
239 | * Adds classes to the Theme's body tag.
240 | */
241 | add_filter( 'body_class', function( $classes ) {
242 | if ( ! is_singular() || is_admin() ) {
243 | return $classes;
244 | }
245 |
246 | global $post;
247 | $sns = get_post_meta( $post->ID, '_SnS', true );
248 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
249 | if ( ! empty( $styles ) && ! empty( $styles['classes_body'] ) ) {
250 | $classes = array_merge( $classes, explode( ' ', $styles['classes_body'] ) );
251 | }
252 |
253 | return $classes;
254 | } );
255 |
256 | /**
257 | * Theme Filter: 'post_class()'
258 | * Adds classes to the Theme's post container.
259 | */
260 | add_filter( 'post_class', function( $classes ) {
261 | if ( ! is_singular() || is_admin() ) {
262 | return $classes;
263 | }
264 |
265 | global $post;
266 | $sns = get_post_meta( $post->ID, '_SnS', true );
267 | $styles = isset( $sns['styles'] ) ? $sns['styles'] : [];
268 |
269 | if ( ! empty( $styles ) && ! empty( $styles['classes_post'] ) ) {
270 | $classes = array_merge( $classes, explode( ' ', $styles['classes_post'] ) );
271 | }
272 |
273 | return $classes;
274 | } );
275 |
276 | /**
277 | * Theme Action: 'wp_enqueue_scripts'
278 | * Enqueues chosen Scripts.
279 | */
280 | add_action( 'wp_enqueue_scripts', function() {
281 | // Global output.
282 | $options = get_option( 'SnS_options' );
283 | if ( ! isset( $options['enqueue_scripts'] ) ) {
284 | $enqueue_scripts = [];
285 | } else {
286 | $enqueue_scripts = $options['enqueue_scripts'];
287 | }
288 |
289 | foreach ( $enqueue_scripts as $handle ) {
290 | wp_enqueue_script( $handle );
291 | }
292 |
293 | if ( ! is_singular() ) {
294 | return;
295 | }
296 | // Individual.
297 | global $post;
298 | $sns = get_post_meta( $post->ID, '_SnS', true );
299 | $scripts = isset( $sns['scripts'] ) ? $sns['scripts'] : [];
300 |
301 | if ( ! empty( $scripts['enqueue_scripts'] ) && is_array( $scripts['enqueue_scripts'] ) ) {
302 | foreach ( $scripts['enqueue_scripts'] as $handle ) {
303 | wp_enqueue_script( $handle );
304 | }
305 | }
306 | }, 11 );
307 |
--------------------------------------------------------------------------------
/dist/includes/rest-page.php:
--------------------------------------------------------------------------------
1 |
23 |
24 | array(
32 | 'saved' => __( 'Settings Saved', 'scripts-n-styles' ),
33 | 'error' => __( 'Error', 'scripts-n-styles' ),
34 | ),
35 | 'api' => array(
36 | 'root' => esc_url_raw( rest_url() ),
37 | 'url' => esc_url_raw( rest_url( 'sns/1.0' ) ),
38 | 'nonce' => wp_create_nonce( 'wp_rest' ),
39 | ),
40 | ) );
41 | } );
42 | } );
43 |
--------------------------------------------------------------------------------
/dist/includes/rest.php:
--------------------------------------------------------------------------------
1 | 'POST',
15 | 'permissions_callback' => function() {
16 | return current_user_can( 'manage_options' ) && current_user_can( 'unfiltered_html' );
17 | },
18 | // 'args' is schema.
19 | 'args' => [],
20 | 'callback' => function( \WP_REST_Request $request ) {
21 | $settings = [
22 | 'item1' => $request->get_param( 'item1' ),
23 | 'item2' => $request->get_param( 'item2' ),
24 | ];
25 | save_settings( $settings );
26 | return rest_ensure_response( get_sns_settings() )->set_status( 201 );
27 | },
28 | ],
29 | [
30 | 'methods' => 'GET',
31 | 'permissions_callback' => function() {
32 | return current_user_can( 'manage_options' ) && current_user_can( 'unfiltered_html' );
33 | },
34 | // 'args' is schema.
35 | 'args' => [],
36 | 'callback' => function() {
37 | return rest_ensure_response( get_sns_settings() );
38 | },
39 | ],
40 | ]);
41 | } );
42 |
43 | /**
44 | * Get defaults.
45 | */
46 | function get_sns_defaults() {
47 | return array();
48 | }
49 |
50 | /**
51 | * Get settings.
52 | */
53 | function get_sns_settings() {
54 | $saved = get_option( '_SnS', array() );
55 |
56 | if ( ! is_array( $saved ) || ! empty( $saved ) ) {
57 | return get_sns_defaults();
58 | }
59 | return wp_parse_args( $saved, get_sns_defaults() );
60 | }
61 |
62 | /**
63 | * Save settings.
64 | *
65 | * @param array $settings The settings.
66 | */
67 | function save_settings( array $settings ) {
68 |
69 | // remove any non-allowed indexes before save.
70 | foreach ( $settings as $i => $setting ) {
71 | if ( ! array_key_exists( $setting, get_sns_defaults() ) ) {
72 | unset( $settings[ $i ] );
73 | }
74 | }
75 | update_option( '_SnS', $settings );
76 | }
77 |
--------------------------------------------------------------------------------
/dist/includes/settings-page.php:
--------------------------------------------------------------------------------
1 | 'php' ] );
33 | wp_enqueue_script( 'sns-settings-page' );
34 | wp_localize_script( 'sns-settings-page', '_SnSOptions', [
35 | 'theme' => $cm_theme,
36 | 'root' => plugins_url( '/', BASENAME ),
37 | ] );
38 | } );
39 |
40 | /**
41 | * Settings Page
42 | * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
43 | */
44 | add_action( "load-$hook_suffix", function() {
45 | register_setting(
46 | OPTION_GROUP,
47 | 'SnS_options'
48 | );
49 |
50 | add_settings_section(
51 | 'settings',
52 | __( 'Scripts n Styles Settings', 'scripts-n-styles' ),
53 | function() {
54 | ?>
55 |
58 | ' . PHP_EOL
72 | . 'The program says = hello("World") ?>.
' . PHP_EOL
73 | . '';
76 | ?>
77 |
78 |
80 |
81 | Theme: ', 'scripts-n-styles' ),
89 | __NAMESPACE__ . '\radio',
90 | ADMIN_MENU_SLUG,
91 | 'demo',
92 | [
93 | 'label_for' => 'cm_theme',
94 | 'setting' => 'SnS_options',
95 | 'choices' => [
96 | 'default',
97 | '3024-day',
98 | '3024-night',
99 | 'abcdef',
100 | 'ambiance',
101 | 'ayu-dark',
102 | 'ayu-mirage',
103 | 'base16-dark',
104 | 'base16-light',
105 | 'bespin',
106 | 'blackboard',
107 | 'cobalt',
108 | 'colorforth',
109 | 'darcula',
110 | 'dracula',
111 | 'duotone-dark',
112 | 'duotone-light',
113 | 'eclipse',
114 | 'elegant',
115 | 'erlang-dark',
116 | 'gruvbox-dark',
117 | 'hopscotch',
118 | 'icecoder',
119 | 'idea',
120 | 'isotope',
121 | 'lesser-dark',
122 | 'liquibyte',
123 | 'lucario',
124 | 'material-darker',
125 | 'material-ocean',
126 | 'material-palenight',
127 | 'material',
128 | 'mbo',
129 | 'mdn-like',
130 | 'midnight',
131 | 'monokai',
132 | 'moxer',
133 | 'neat',
134 | 'neo',
135 | 'night',
136 | 'nord',
137 | 'oceanic-next',
138 | 'panda-syntax',
139 | 'paraiso-dark',
140 | 'paraiso-light',
141 | 'pastel-on-dark',
142 | 'railscasts',
143 | 'rubyblue',
144 | 'seti',
145 | 'shadowfox',
146 | 'solarized',
147 | 'ssms',
148 | 'the-matrix',
149 | 'tomorrow-night-bright',
150 | 'tomorrow-night-eighties',
151 | 'ttcn',
152 | 'twilight',
153 | 'vibrant-ink',
154 | 'xq-dark',
155 | 'xq-light',
156 | 'yeti',
157 | 'yonce',
158 | 'zenburn',
159 | ],
160 | 'default' => 'default',
161 | 'legend' => __( 'Theme', 'scripts-n-styles' ),
162 | 'layout' => 'horizontal',
163 | 'description' => '',
164 | ]
165 | );
166 | add_settings_field(
167 | 'delete_data_uninstall',
168 | __( 'Delete Data When Uninstalling : ', 'scripts-n-styles' ),
169 | __NAMESPACE__ . '\radio',
170 | ADMIN_MENU_SLUG,
171 | 'settings',
172 | [
173 | 'label_for' => 'delete_data_uninstall',
174 | 'setting' => 'SnS_options',
175 | 'choices' => [ 'yes', 'no' ],
176 | 'layout' => 'horizontal',
177 | 'default' => 'no',
178 | 'legend' => __( 'Delete Data When Uninstalling', 'scripts-n-styles' ),
179 | 'description' => __( 'Should the plugin clean up after itself and delete all of its saved data. ', 'scripts-n-styles' ),
180 | ]
181 | );
182 | } );
183 | } );
184 |
--------------------------------------------------------------------------------
/dist/includes/theme-page.php:
--------------------------------------------------------------------------------
1 | 'css' ] );
42 | wp_enqueue_script( 'sns-theme-page' );
43 | wp_localize_script( 'sns-theme-page', '_SnSOptions', [
44 | 'root' => plugins_url( '/', BASENAME ),
45 | ] );
46 | } );
47 |
48 | /**
49 | * Settings Page
50 | * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
51 | */
52 | add_action( "load-$hook_suffix", function() {
53 | // added here to not effect other pages. Theme page requires JavaScript (less.js) or it doesn't make sense to save.
54 | add_filter( 'sns_show_submit_button', '__return_false' );
55 |
56 | register_setting(
57 | OPTION_GROUP,
58 | 'SnS_options'
59 | );
60 |
61 | add_settings_section(
62 | 'theme',
63 | __( 'Scripts n Styles Theme Files', 'scripts-n-styles' ),
64 | 'unFocus\SnS\theme_section',
65 | ADMIN_MENU_SLUG
66 | );
67 | } );
68 | } );
69 |
70 | /**
71 | * Theme Section Markup.
72 | */
73 | function theme_section() {
74 | $files = [];
75 | $support_files = get_theme_support( 'scripts-n-styles' );
76 |
77 | if ( is_child_theme() ) {
78 | $root = get_stylesheet_directory();
79 | } else {
80 | $root = get_template_directory();
81 | }
82 |
83 | foreach ( $support_files[0] as $file ) {
84 | if ( is_file( $root . $file ) ) {
85 | $files[] = $root . $file;
86 | }
87 | }
88 |
89 | $slug = get_stylesheet();
90 | $options = get_option( 'SnS_options' );
91 | // Stores data on a theme by theme basis.
92 | $theme = isset( $options['themes'][ $slug ] ) ? $options['themes'][ $slug ] : [];
93 | $stored = isset( $theme['less'] ) ? $theme['less'] : []; // is an array of stored imported less file data.
94 | $compiled = isset( $theme['compiled'] ) ? $theme['compiled'] : ''; // the complete compiled down css.
95 | $slug = esc_attr( $slug );
96 |
97 | $open_theme_panels = json_decode( get_user_option( 'sns_open_theme_panels', get_current_user_id() ), true );
98 |
99 | ?>
100 |
101 |
144 |
145 |
146 |
147 | Keystokes detected. 1 second delay, then compiling...
148 |
149 |
157 |
158 |
159 | __( 'Per Page', 'scripts-n-styles' ),
41 | 'default' => 20,
42 | ]
43 | );
44 |
45 | add_filter( 'set-screen-option', function( $false, $option, $value ) {
46 | $screen_id = get_current_screen()->id;
47 | $this_option = "{$screen_id}_per_page";
48 | if ( $this_option !== $option ) {
49 | return false;
50 | }
51 |
52 | $value = (int) $value;
53 | if ( $value < 1 || $value > 100 ) {
54 | return false;
55 | }
56 |
57 | return $value;
58 | }, 10, 3 );
59 |
60 | // hack for core limitation: see http://core.trac.wordpress.org/ticket/18954 .
61 | set_screen_options();
62 |
63 | add_settings_section(
64 | 'usage',
65 | __( 'Scripts n Styles Usage', 'scripts-n-styles' ),
66 | function() {
67 | ?>
68 |
71 | prepare_items();
76 | $usage_table->display();
77 | },
78 | ADMIN_MENU_SLUG
79 | );
80 | } );
81 | } );
82 |
--------------------------------------------------------------------------------
/dist/includes/utility.php:
--------------------------------------------------------------------------------
1 | ' ) ) {
18 | upgrade();
19 | }
20 | } );
21 |
22 | /**
23 | * Sets defaults if not previously set. Sets stored 'version' to VERSION.
24 | */
25 | function upgrade() {
26 | $options = get_option( 'SnS_options' );
27 | if ( ! $options ) {
28 | $options = [ 'version' => '0' ];
29 | }
30 |
31 | $version = $options['version'];
32 |
33 | /*
34 | * upgrade proceedure for 4.0 update
35 | */
36 | if ( version_compare( $version, '4.0.0', '<' ) ) :
37 | // Convert Hoops widget to Text.
38 | $sidebars_widgets = get_option( 'sidebars_widgets' );
39 | $widget_sns_hoops = get_option( 'widget_sns_hoops' );
40 | $widget_text = get_option( 'widget_text' );
41 |
42 | foreach ( $sidebars_widgets as $name => $sidebar ) {
43 | if ( ! is_array( $sidebar ) ) {
44 | continue; // ignore metadata in array.
45 | }
46 | foreach ( $sidebar as $key => $widget_name ) {
47 | // widget_name is widget array name ("sns_hoops"), a "-", and it's index in the widget array.
48 | if ( stripos( $widget_name, 'sns_hoops-' ) !== false ) {
49 | $sns_index = substr( $widget_name, strlen( 'sns_hoops-' ) );
50 | $sns_widget = $widget_sns_hoops[ $sns_index ];
51 |
52 | $sns_widget['visual'] = true; // Upgrade.
53 | $sns_widget['filter'] = true; // New version is always filter.
54 |
55 | $widget_text[] = $sns_widget; // Add widget to text widget array.
56 |
57 | $text_index = max( array_keys( $widget_text ) ); // Get text array index.
58 |
59 | $sidebars_widgets[ $name ][ $key ] = 'text-' . $text_index; // update sidebars array with new names.
60 | }
61 | }
62 | }
63 | update_option( 'widget_text', $widget_text );
64 | update_option( 'sidebars_widgets', $sidebars_widgets );
65 | delete_option( 'widget_sns_hoops' );
66 |
67 | $version = '4.0.0';
68 | endif; // 4.0 upgrade
69 |
70 | $options['version'] = VERSION;
71 | update_option( 'SnS_options', $options );
72 | }
73 |
--------------------------------------------------------------------------------
/dist/js/Root.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Scripts n Styles
4 |
5 | Global
6 | Hoops
7 | Theme
8 | Settings
9 | Usage
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dist/js/global-page.babel.js:
--------------------------------------------------------------------------------
1 | // Options JavaScript
2 | import $ from 'jquery';
3 | import less from 'less';
4 | import CoffeeScript from 'coffeescript';
5 | import 'chosen-js';
6 | import 'chosen-js/chosen.css';
7 | import '../css/options-styles.less';
8 |
9 | const { CodeEditor, CodeMirror, apiFetch } = wp;
10 |
11 | if ( CodeMirror ) {
12 | CodeMirror.modeURL = _SnSOptions.root + 'codemirror/mode/%N/%N.js';
13 | }
14 |
15 | $( function() {
16 | $( '#enqueue_scripts' ).chosen({ width: '300px' });
17 |
18 | if ( ! CodeMirror ) {
19 |
20 | // Temp bailout.
21 | return;
22 | }
23 | let compiled,
24 | source,
25 | lessMirror,
26 | lessOutput,
27 | errorLine,
28 | errorText,
29 | errors,
30 | loaded,
31 | coffeeMirror,
32 | coffeeOutput,
33 | coffeeLoaded,
34 | defaultSettings = $.extend({}, wp.codeEditor.defaultSettings ),
35 | lessMirrorConfig = {
36 | gutters: [ 'note-gutter', 'CodeMirror-linenumbers' ],
37 | mode: 'text/x-less',
38 | indentWithTabs: true, viewportMargin: Infinity
39 | },
40 | coffeeMirrorConfig = {
41 | mode: 'text/coffeescript', viewportMargin: Infinity
42 | };
43 |
44 | //CodeMirror.commands.save = saveLessMirror;
45 |
46 | $( 'textarea.js' ).not( '#coffee_compiled' ).each( function() {
47 | wp.codeEditor.initialize( this, $.extend({}, defaultSettings, {
48 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'javascript', viewportMargin: Infinity })
49 | }) );
50 | });
51 |
52 | $( 'textarea.css' ).not( '#compiled' ).each( function() {
53 | wp.codeEditor.initialize( this, $.extend({}, defaultSettings, {
54 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'css', viewportMargin: Infinity })
55 | }) );
56 | });
57 |
58 |
59 | lessOutput = wp.codeEditor.initialize( 'compiled', $.extend({}, defaultSettings, {
60 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'css', readOnly: true, viewportMargin: Infinity })
61 | }) ).codemirror;
62 |
63 | coffeeOutput = wp.codeEditor.initialize( 'coffee_compiled', $.extend({}, defaultSettings, {
64 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'javascript', readOnly: true, viewportMargin: Infinity })
65 | }) ).codemirror;
66 |
67 | $( 'textarea.less' ).each( function() {
68 | lessMirror = wp.codeEditor.initialize( this, $.extend({}, defaultSettings, {
69 | codemirror: $.extend({}, defaultSettings.codemirror, lessMirrorConfig )
70 | }) ).codemirror;
71 | lessMirror.on( 'change', compile );
72 | });
73 | $( 'textarea.coffee' ).each( function() {
74 | coffeeMirror = wp.codeEditor.initialize( this, $.extend({}, defaultSettings, {
75 | codemirror: $.extend({}, defaultSettings.codemirror, coffeeMirrorConfig )
76 | }) ).codemirror;
77 | coffeeMirror.on( 'change', coffeeCompile );
78 | let result = CodeMirror.autoLoadMode( coffeeMirror, 'coffeescript' );
79 | });
80 | $( '#coffee' ).parent().append( '
Double Spaced' );
81 | $( '#coffee_spacing' ).change( coffeeCompile );
82 | compile();
83 | coffeeCompile();
84 | loaded = true;
85 | coffeeLoaded = true;
86 | $( '#less' ).closest( 'form' ).submit( compile );
87 | $( '#coffee' ).closest( 'form' ).submit( coffeeCompile );
88 |
89 | //function saveLessMirror(){
90 | // Ajax Save.
91 | //}
92 |
93 | function compile() {
94 | lessMirror.save();
95 |
96 | less.render( lessMirror.getValue(), {}, function( error, output ) {
97 | if ( error ) {
98 | doError( error );
99 | } else {
100 | try {
101 | $( '#compiled_error' ).hide();
102 | lessOutput.setValue( output.css );
103 | lessOutput.save();
104 | $( '#compiled' ).next( '.CodeMirror' ).show();
105 | lessOutput.refresh();
106 | clearCompileError();
107 | } catch ( error ) {
108 | doError( error );
109 | }
110 | }
111 | });
112 | }
113 | function coffeeCompile() {
114 | coffeeMirror.save();
115 | try {
116 | $( '#coffee_compiled_error' ).hide();
117 | source = $( '#coffee' ).val();
118 | if ( '' == source || ' ' == source ) {
119 | coffeeOutput.setValue( '' );
120 | } else {
121 | compiled = CoffeeScript.compile( source );
122 | let trimmed = $( '#coffee_spacing' ).is( ':checked' ) ? compiled : compiled.replace( /(\n\n)/gm, '\n' );
123 | coffeeOutput.setValue( trimmed );
124 | }
125 | coffeeOutput.save();
126 |
127 | $( '#coffee_compiled' ).next( '.CodeMirror' ).show();
128 | } catch ( err ) {
129 | console.dir( err );
130 | $( '#coffee_compiled' ).next( '.CodeMirror' ).hide();
131 | if ( coffeeLoaded ) {
132 | $( '#coffee_compiled_error' ).removeClass( 'error' ).addClass( 'updated' );
133 | $( '#coffee_compiled_error' ).show().html( '
Warning: ' + err.message + '
' );
134 | } else {
135 | $( '#coffee_compiled_error' ).show().html( '
Error: ' + err.message + '
' );
136 | }
137 | }
138 | }
139 | function doError( err ) {
140 |
141 | //console.dir( err );
142 | $( '#compiled' ).next( '.CodeMirror' ).hide();
143 | if ( loaded ) {
144 | $( '#compiled_error' ).removeClass( 'error' ).addClass( 'updated' );
145 | $( '#compiled_error' ).show().html( '
Warning: ' + err.message + '
' );
146 | } else {
147 | $( '#compiled_error' ).show().html( '
Error: ' + err.message + '
' );
148 | }
149 | clearCompileError();
150 |
151 | errorLine = lessMirror.setGutterMarker( err.line - 1, 'note-gutter', document.createTextNode( '*' ) );
152 |
153 | //lessMirror.setLineClass( errorLine, "cm-error");
154 |
155 | let pos = lessMirror.posFromIndex( err.index + 1 );
156 | let token = lessMirror.getTokenAt( pos );
157 | let start = lessMirror.posFromIndex( err.index );
158 | let end = lessMirror.posFromIndex( err.index + token.string.length );
159 | errorText = lessMirror.markText( start, end, { className: 'cm-error' });
160 |
161 | lessOutput.setValue( '' );
162 | lessOutput.save();
163 | }
164 | function clearCompileError() {
165 | if ( errorLine ) {
166 | lessMirror.clearGutter( 'note-gutter' );
167 |
168 | //lessMirror.setLineClass( errorLine, null );
169 | errorLine = false;
170 | }
171 | if ( errorText ) {
172 | errorText.clear();
173 | }
174 | errorText = false;
175 | }
176 | });
177 |
--------------------------------------------------------------------------------
/dist/js/hoops-page.babel.js:
--------------------------------------------------------------------------------
1 | // Options JavaScript
2 | import $ from 'jquery';
3 | import '../css/options-styles.less';
4 |
5 | let CodeMirror = wp.CodeMirror;
6 |
7 | if ( CodeMirror ) {
8 | CodeMirror.modeURL = _SnSOptions.root + 'codemirror/mode/%N/%N.js';
9 | }
10 |
11 | $( function() {
12 | if ( ! CodeMirror ) {
13 |
14 | // Temp bailout.
15 | return;
16 | }
17 | let collection = [],
18 | context = '#sns-shortcodes',
19 | defaultSettings = $.extend({}, wp.codeEditor.defaultSettings ),
20 | $form,
21 | config;
22 |
23 | config = {
24 | mode: 'text/html',
25 | lineNumbers: true,
26 | tabMode: 'shift',
27 | indentUnit: 4,
28 | indentWithTabs: true,
29 | enterMode: 'keep',
30 | matchBrackets: true
31 | };
32 |
33 | CodeMirror.commands.save = function() {
34 | $form.submit();
35 | };
36 |
37 | // Each "IDE"
38 | $( '.sns-less-ide', context ).each( function() {
39 | var $text = $( '.code', this );
40 | var ide = {
41 | data: $text.val(),
42 | name: $text.data( 'sns-shortcode-key' ),
43 | $text: $text,
44 | cm: wp.codeEditor.initialize( $text.get( 0 ), $.extend({}, defaultSettings, {
45 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'text/html' })
46 | }) ).codemirror
47 | };
48 | if ( $text.parent().hasClass( 'sns-collapsed' ) ) {
49 | ide.cm.toTextArea();
50 | }
51 | collection.push( ide );
52 | });
53 |
54 | // Collapsable
55 | $( context ).on( 'click', '.sns-collapsed-btn, .sns-collapsed-btn + label', function( event ) {
56 | var $this = $( this ),
57 | collapsed,
58 | fileName,
59 | thisIDE;
60 | $this.parent().toggleClass( 'sns-collapsed' );
61 | fileName = $this.siblings( '.code' ).data( 'sns-shortcode-key' );
62 | collapsed = $this.parent().hasClass( 'sns-collapsed' );
63 | $( collection ).each( function( index, element ) {
64 | if ( element.name == fileName ) {
65 | thisIDE = element;
66 | }
67 | });
68 | if ( collapsed ) {
69 | thisIDE.cm.toTextArea();
70 | } else {
71 | thisIDE.cm = wp.codeEditor.initialize( thisIDE.$text.get( 0 ), $.extend({}, defaultSettings, {
72 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'text/html' })
73 | }) ).codemirror;
74 | }
75 | });
76 | $( '.sns-ajax-loading' ).hide();
77 | });
78 |
--------------------------------------------------------------------------------
/dist/js/pages/Global.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Blog Wide CSS Styles
4 |
5 |
Code entered here will be included in every page (and post) of your site , including the homepage and archives. The code will appear before Styles that were registered individually.
6 |
7 |
8 |
Blog Wide JavaScript
9 |
10 |
Code entered here will be included in every page (and post) of your site , including the homepage and archives. The code will appear before Scripts that were registered individually.
11 |
12 |
13 |
14 |
15 |
18 |
19 |
22 |
--------------------------------------------------------------------------------
/dist/js/pages/Hoops.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
The Hoops Shortcodes
4 |
5 |
"Hoops" are shortcodes invented to get around some limitations of vanilla WordPress.
6 |
Normally, certain HTML is very problematic to use in the Post Editor, because it either gets jumbled during Switching between HTML and Visual Tabs, stripped out by WPAutoP (rare) or stripped out because the User doesn’t have the proper Permissions.
7 |
With Hoops, an Admin user (who has `unfiltered_html` and `manage_options` capablilities) can write and approve snippets of HTML for other users to use via Shortcodes.
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/dist/js/pages/Settings.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Scripts n Styles Settings
4 |
5 |
Control how and where Scripts n Styles menus and metaboxes appear. These options are here because sometimes users really care about this stuff. Feel free to adjust to your liking. :-)
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/dist/js/pages/Theme.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Scripts n Styles Theme Files
4 |
5 |
Code entered here will be included in every page (and post) of your site , including the homepage and archives. The code will appear before Styles that were registered individually.
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/dist/js/pages/Usage.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Scripts n Styles Usage
4 |
5 |
The following table shows content that utilizes Scripts n Styles.
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/dist/js/rest.babel.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import VueRouter from 'vue-router';
3 | import Root from './Root.vue';
4 | import Global from './pages/Global.vue';
5 | import Hoops from './pages/Hoops.vue';
6 | import Settings from './pages/Settings.vue';
7 | import Theme from './pages/Theme.vue';
8 | import Usage from './pages/Usage.vue';
9 |
10 | Vue.use( VueRouter );
11 |
12 | const routes = [
13 | { path: '/global', component: Global },
14 | { path: '/hoops', component: Hoops },
15 | { path: '/settings', component: Settings },
16 | { path: '/theme', component: Theme },
17 | { path: '/usage', component: Usage }
18 | ];
19 |
20 | const router = new VueRouter({
21 | routes,
22 | linkActiveClass: 'nav-tab-active'
23 | });
24 |
25 | /* eslint-disable no-new */
26 | new Vue({
27 | router,
28 | el: '#scripts-n-styles',
29 | render() {
30 | return
;
31 | }
32 | });
33 |
34 | $.ajax({
35 | url: snsREST.api.root + 'sns/0.1/global',
36 | method: 'GET',
37 | beforeSend: function( xhr ) {
38 | xhr.setRequestHeader( 'X-WP-Nonce', snsREST.api.nonce );
39 | }
40 | }).always( function( response, textStatus, jqXHR ) {
41 | console.log( 'response', response );
42 | });
43 |
--------------------------------------------------------------------------------
/dist/js/settings-page.babel.js:
--------------------------------------------------------------------------------
1 | import $ from 'jquery';
2 | import '../css/options-styles.less';
3 |
4 | $( function() {
5 | let sns = wp.codeEditor.initialize( $( '#codemirror_demo' ), $.extend({}, wp.codeEditor.defaultSettings ) );
6 |
7 | function createLink( theme ) {
8 | $( '#sns-codemirror-theme-css' ).remove();
9 |
10 | if ( 'default' === theme ) {
11 | sns.codemirror.setOption( 'theme', 'default' );
12 | return;
13 | }
14 |
15 | let href = _SnSOptions.root + 'codemirror/theme/' + theme + '.css';
16 | let link = document.createElement( 'link' );
17 |
18 | link.setAttribute( 'rel', 'stylesheet' );
19 | link.setAttribute( 'type', 'text/css' );
20 | link.setAttribute( 'href', href );
21 |
22 | link.id = 'sns-codemirror-theme-css';
23 |
24 | link.onload = function() {
25 | sns.codemirror.setOption( 'theme', theme );
26 | };
27 |
28 | document.getElementsByTagName( 'head' )[0].appendChild( link );
29 | }
30 |
31 | $( 'input[name="SnS_options[cm_theme]"]' ).change( function() {
32 | let theme = $( this ).val();
33 |
34 | createLink( theme );
35 |
36 | $( this ).focus();
37 | });
38 | });
39 |
--------------------------------------------------------------------------------
/dist/js/theme-page.babel.js:
--------------------------------------------------------------------------------
1 | // Options JavaScript
2 | import $ from 'jquery';
3 | import less from 'less';
4 | import '../css/options-styles.less';
5 | import postcss from 'postcss';
6 | import autoprefixer from 'autoprefixer';
7 |
8 | let CodeMirror = wp.CodeMirror;
9 |
10 | if ( CodeMirror ) {
11 | CodeMirror.modeURL = _SnSOptions.root + 'codemirror/mode/%N/%N.js';
12 | }
13 |
14 | $( function() {
15 |
16 | let collection = [],
17 | context = '#less_area',
18 | defaultSettings = $.extend({}, wp.codeEditor.defaultSettings ),
19 | timeout = _SnSOptions.timeout || 1000,
20 | loaded = false,
21 | preview = false,
22 | compiled,
23 | $error, $status, $form, $css,
24 | onChange,
25 | errorMarker, errorText, errorMirror,
26 | config;
27 |
28 | // Prevent keystoke compile buildup
29 | onChange = function onChange( cm ) {
30 | $status.show();
31 | cm.save();
32 | if ( timeout ) {
33 | clearTimeout( _SnSOptions.themeCompilerTimer );
34 | _SnSOptions.themeCompilerTimer = setTimeout( _SnSOptions.themeCompiler, timeout );
35 | } else {
36 | compile();
37 | }
38 | };
39 | config = {
40 | gutters: [ 'note-gutter', 'CodeMirror-linenumbers' ],
41 | lineNumbers: true,
42 | mode: 'text/x-less',
43 | indentWithTabs: true,
44 | tabSize: 4,
45 | indentUnit: 4
46 | };
47 |
48 | CodeMirror.commands.save = function() {
49 | $form.submit();
50 | };
51 |
52 | // Each "IDE"
53 | $( '.sns-less-ide', context ).each( function() {
54 | var $text = $( '.code', this );
55 | var ide = {
56 | name: $text.data( 'file-name' ),
57 | raw: $text.data( 'raw' ),
58 | data: $text.val(),
59 | $text: $text,
60 | lines: 0,
61 | startLine: 0,
62 | endLine: 0,
63 | startChars: 0,
64 | endChars: 0,
65 | errorLine: null,
66 | errorText: null,
67 | cm: wp.codeEditor.initialize( $text.get( 0 ), $.extend({}, defaultSettings, {
68 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'text/x-less' })
69 | }) ).codemirror
70 | };
71 | ide.cm.on( 'change', onChange );
72 | if ( $text.parent().hasClass( 'sns-collapsed' ) ) {
73 | ide.cm.toTextArea();
74 | }
75 | collection.push( ide );
76 | });
77 |
78 | // Collapsable
79 | $( context ).on( 'click', '.sns-collapsed-btn, .sns-collapsed-btn + label', function( event ) {
80 | var $this = $( this ),
81 | collapsed,
82 | fileName,
83 | thisIDE;
84 | $this.parent().toggleClass( 'sns-collapsed' );
85 | fileName = $this.siblings( '.code' ).data( 'file-name' );
86 | collapsed = $this.parent().hasClass( 'sns-collapsed' );
87 | $( collection ).each( function( index, element ) {
88 | if ( element.name == fileName ) {
89 | thisIDE = element;
90 | }
91 | });
92 | if ( collapsed ) {
93 | thisIDE.cm.toTextArea();
94 | } else {
95 | thisIDE.cm = wp.codeEditor.initialize( thisIDE.$text.get( 0 ), $.extend({}, defaultSettings, {
96 | codemirror: $.extend({}, defaultSettings.codemirror, { mode: 'text/html' })
97 | }) ).codemirror;
98 | thisIDE.cm.on( 'change', onChange );
99 | }
100 | $.post( ajaxurl, {
101 | action: 'sns_open_theme_panels',
102 | _ajax_nonce: $( '#_wpnonce' ).val(), // eslint-disable-line camelcase
103 | 'file-name': fileName,
104 | 'collapsed': collapsed ? 'yes' : 'no'
105 | });
106 | });
107 | $( '#css_area' ).on( 'click', '.sns-collapsed-btn, .sns-collapsed-btn + label', function( event ) {
108 | var $this = $( this ).parent();
109 | $this.toggleClass( 'sns-collapsed' );
110 | preview = ! $this.hasClass( 'sns-collapsed' );
111 | if ( preview ) {
112 | compiled = createCSSEditor();
113 | } else {
114 | compiled.toTextArea();
115 | }
116 | });
117 |
118 | $( '.single-status' ).hide();
119 | $( '.sns-ajax-loading' ).hide();
120 |
121 | // Load
122 | $( context ).on( 'click', '.sns-ajax-load', function( event ) {
123 | event.preventDefault();
124 | $( this ).nextAll( '.sns-ajax-loading' ).show();
125 | let name = $( this ).parent().prevAll( '.code' ).data( 'file-name' );
126 | $( collection ).each( function( index, element ) {
127 | if ( element.name == name ) {
128 | element.cm.setValue( element.raw );
129 | return;
130 | }
131 | });
132 | compile();
133 | $( '.sns-ajax-loading' ).hide();
134 | $( this ).nextAll( '.single-status' )
135 | .show().delay( 3000 ).fadeOut()
136 | .children( '.settings-error' ).text( 'Original Source File Loaded.' );
137 | });
138 |
139 | // Save
140 | $( context ).on( 'click', '.sns-ajax-save', function( event ) {
141 | event.preventDefault();
142 | $( this ).nextAll( '.sns-ajax-loading' ).show();
143 | $form.submit();
144 | });
145 | function saved( data ) {
146 | $( data ).insertAfter( '#icon-sns + h2' ).delay( 3000 ).fadeOut();
147 | $( '.sns-ajax-loading' ).hide();
148 | }
149 |
150 | // The CSS output side.
151 | $css = $( '.css', '#css_area' );
152 | if ( preview ) {
153 | compiled = createCSSEditor();
154 | }
155 |
156 | $error = $( '#compiled_error' );
157 | $status = $( '#compile_status' );
158 |
159 | // Start.
160 | compile();
161 | loaded = true;
162 |
163 | $form = $( '#less_area' ).closest( 'form' );
164 | $form.submit( function( event ) {
165 | event.preventDefault();
166 | compile();
167 | $.ajax({
168 | type: 'POST',
169 | url: window.location,
170 | data: $( this ).serialize() + '&ajaxsubmit=1',
171 | cache: false,
172 | success: saved
173 | });
174 | });
175 | function createCSSEditor() {
176 | return CodeMirror.fromTextArea(
177 | $css.get( 0 ),
178 | { lineNumbers: true, mode: 'css', indentWithTabs: true, tabSize: 4, indentUnit: 4 }
179 | );
180 | }
181 | function compile() {
182 | var lessValue = '';
183 | var totalLines = 0;
184 | var totalChars = 0;
185 | var compiledValue;
186 | $( collection ).each( function() {
187 |
188 | //this.cm.save();
189 | lessValue += '\n' + this.$text.val();
190 |
191 | this.lines = this.cm.lineCount();
192 | this.startLine = totalLines;
193 | totalLines += this.lines;
194 | this.endLine = totalLines;
195 |
196 | this.chars = this.$text.val().length + 1;
197 | this.startChars = totalChars;
198 | totalChars += this.chars;
199 | this.endChars = totalChars;
200 | });
201 |
202 | less.render( lessValue, {}, function( error, output ) {
203 | if ( error ) {
204 | doError( error );
205 | } else {
206 | try {
207 | $error.hide();
208 | if ( preview ) {
209 | $( compiled.getWrapperElement() ).show();
210 | compiledValue = output.css;
211 | compiled.setValue( compiledValue );
212 | compiled.save();
213 | compiled.refresh();
214 | } else {
215 |
216 | // compiledValue = cleanCSS.minify( output.css ).styles;
217 | compiledValue = output.css;
218 | $css.val( compiledValue );
219 | }
220 | clearCompileError();
221 | } catch ( error ) {
222 | doError( error );
223 | }
224 | }
225 | });
226 | clearTimeout( _SnSOptions.themeCompilerTimer );
227 | $status.hide();
228 | }
229 | function doError( err ) {
230 | var pos, token, start, end, errLine, fileName, errMessage, errIndex;
231 | errLine = err.line - 1;
232 |
233 | errorMirror = null;
234 | $( collection ).each( function( i ) {
235 | if ( this.startLine <= errLine && errLine < this.endLine ) {
236 | errorMirror = this.cm;
237 | errLine = errLine - this.startLine - 1;
238 | fileName = this.name;
239 | errIndex = err.index - this.startChars;
240 | return;
241 | }
242 | });
243 | if ( preview ) {
244 | $( compiled.getWrapperElement() ).hide();
245 | }
246 | errMessage = '';
247 |
248 | errMessage = '
LESS ' + err.type + ' Error on line ' + ( errLine + 1 ) + ' of ' + fileName + '.
' + err.message + '';
249 |
250 | if ( loaded ) {
251 | $error
252 | .removeClass( 'error' )
253 | .addClass( 'updated' )
254 | .show()
255 | .html( '
Warning: ' + errMessage + '
' );
256 | } else {
257 | $error
258 | .show()
259 | .html( '
Error: ' + errMessage + '
' );
260 | }
261 |
262 | clearCompileError();
263 |
264 | if ( ! errorMirror ) {
265 | return;
266 | }
267 |
268 | errorMarker = errorMirror.setGutterMarker( errLine, 'note-gutter', $( '
' ).addClass( 'cm-error' ).css( 'marginLeft', '4px' ).text( '✖' ).get( 0 ) );
269 |
270 | //errorMirror.addLineClass( errLine, "wrap", cm-error" );
271 |
272 | pos = errorMirror.posFromIndex( errIndex );
273 | token = errorMirror.getTokenAt( pos );
274 | start = errorMirror.posFromIndex( errIndex - 1 );
275 | end = errorMirror.posFromIndex( errIndex + token.string.length - 1 );
276 | errorText = errorMirror.markText( start, end, { className: 'cm-error' });
277 | if ( preview ) {
278 |
279 | //compiled.setValue( "" );
280 | //compiled.save();
281 | //compiled.refresh();
282 | }
283 | }
284 | function clearCompileError() {
285 | if ( errorMarker ) {
286 | $( collection ).each( function( i ) {
287 | this.cm.clearGutter( 'note-gutter' );
288 | });
289 |
290 | //errorMirror.removeLineClass( errLine, "wrap", "cm-error" );
291 | errorMarker = false;
292 | }
293 | if ( errorText ) {
294 | errorText.clear();
295 | errorText = false;
296 | }
297 | }
298 | _SnSOptions.themeCompiler = compile;
299 | });
300 |
--------------------------------------------------------------------------------
/dist/languages/scripts-n-styles.pot:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2010 Scripts n Styles
2 | # This file is distributed under the same license as the Scripts n Styles package.
3 | msgid ""
4 | msgstr ""
5 | "Project-Id-Version: Scripts n Styles 3.0\n"
6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/scripts-n-styles\n"
7 | "POT-Creation-Date: 2011-12-09 20:46:53+00:00\n"
8 | "MIME-Version: 1.0\n"
9 | "Content-Type: text/plain; charset=UTF-8\n"
10 | "Content-Transfer-Encoding: 8bit\n"
11 | "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12 | "Last-Translator: FULL NAME
\n"
13 | "Language-Team: LANGUAGE \n"
14 |
15 | #. #-#-#-#-# plugin.pot (Scripts n Styles 3.0) #-#-#-#-#
16 | #. Plugin Name of the plugin/theme
17 | #: includes/class.SnS_Admin_Meta_Box.php:97
18 | #: includes/class.SnS_Settings_Page.php:22
19 | #: includes/class.SnS_Usage_Page.php:22 includes/class.SnS_Global_Page.php:18
20 | #: includes/class.SnS_Global_Page.php:20 includes/class.SnS_Admin.php:64
21 | #: includes/class.SnS_Admin.php:67 includes/class.SnS_Admin.php:70
22 | #: includes/class.SnS_Admin.php:106 includes/class.SnS_Admin.php:126
23 | msgid "Scripts n Styles"
24 | msgstr ""
25 |
26 | #: includes/class.SnS_Admin_Meta_Box.php:133
27 | #: includes/class.SnS_List_Usage.php:23
28 | msgid "Scripts"
29 | msgstr ""
30 |
31 | #: includes/class.SnS_Admin_Meta_Box.php:134
32 | #: includes/class.SnS_List_Usage.php:34
33 | msgid "Styles"
34 | msgstr ""
35 |
36 | #: includes/class.SnS_Admin_Meta_Box.php:135
37 | #: includes/class.SnS_Admin_Meta_Box.php:156
38 | msgid "Classes"
39 | msgstr ""
40 |
41 | #: includes/class.SnS_Admin_Meta_Box.php:136
42 | msgid "Include Scripts"
43 | msgstr ""
44 |
45 | #: includes/class.SnS_Admin_Meta_Box.php:140
46 | msgid ""
47 | "This code will be included verbatim in <script>"
48 | "code> tags at the end of your page's (or post's)"
49 | msgstr ""
50 |
51 | #: includes/class.SnS_Admin_Meta_Box.php:141
52 | msgid "Scripts (for the head
element):"
53 | msgstr ""
54 |
55 | #: includes/class.SnS_Admin_Meta_Box.php:143
56 | #: includes/class.SnS_Admin_Meta_Box.php:146
57 | msgid "tag"
58 | msgstr ""
59 |
60 | #: includes/class.SnS_Admin_Meta_Box.php:150
61 | msgid "Styles :"
62 | msgstr ""
63 |
64 | #: includes/class.SnS_Admin_Meta_Box.php:152
65 | msgid ""
66 | "This code will be included verbatim in <style>"
67 | "code> tags in the <head>
tag of your page (or post)."
68 | msgstr ""
69 |
70 | #: includes/class.SnS_Admin_Meta_Box.php:159
71 | msgid "Body Classes :"
72 | msgstr ""
73 |
74 | #: includes/class.SnS_Admin_Meta_Box.php:162
75 | #: includes/class.SnS_Admin_Meta_Box.php:168
76 | msgid "Standard:"
77 | msgstr ""
78 |
79 | #: includes/class.SnS_Admin_Meta_Box.php:170
80 | msgid ""
81 | "These space separated class names will be added to the "
82 | "body_class()
or post_class()
function (provided "
83 | "your theme uses these functions)."
84 | msgstr ""
85 |
86 | #: includes/class.SnS_Admin_Meta_Box.php:179
87 | msgid "The Styles Dropdown"
88 | msgstr ""
89 |
90 | #: includes/class.SnS_Admin_Meta_Box.php:181
91 | msgid "Add (or update) a class for the \"Styles\" drop-down:"
92 | msgstr ""
93 |
94 | #: includes/class.SnS_Admin_Meta_Box.php:183
95 | msgid "Title:"
96 | msgstr ""
97 |
98 | #: includes/class.SnS_Admin_Meta_Box.php:188
99 | msgid "Type:"
100 | msgstr ""
101 |
102 | #: includes/class.SnS_Admin_Meta_Box.php:190
103 | msgctxt "css type"
104 | msgid "Inline"
105 | msgstr ""
106 |
107 | #: includes/class.SnS_Admin_Meta_Box.php:191
108 | msgctxt "css type"
109 | msgid "Block"
110 | msgstr ""
111 |
112 | #: includes/class.SnS_Admin_Meta_Box.php:192
113 | msgctxt "css type"
114 | msgid "Selector:"
115 | msgstr ""
116 |
117 | #: includes/class.SnS_Admin_Meta_Box.php:196
118 | msgid "Element:"
119 | msgstr ""
120 |
121 | #: includes/class.SnS_Admin_Meta_Box.php:201
122 | msgid "Classes:"
123 | msgstr ""
124 |
125 | #: includes/class.SnS_Admin_Meta_Box.php:206
126 | msgid "Wrapper:"
127 | msgstr ""
128 |
129 | #: includes/class.SnS_Admin_Meta_Box.php:212
130 | msgid "Classes currently in the dropdown:"
131 | msgstr ""
132 |
133 | #: includes/class.SnS_Admin_Meta_Box.php:232
134 | msgid "Currently Enqueued Scripts:"
135 | msgstr ""
136 |
137 | #: includes/class.SnS_Admin_Meta_Box.php:236
138 | msgid ""
139 | "The chosen scripts will be enqueued and placed before your codes if your "
140 | "code is dependant on certain scripts (like jQuery)."
141 | msgstr ""
142 |
143 | #: includes/class.SnS_Admin_Meta_Box.php:247
144 | msgid "(plus others once saved.)"
145 | msgstr ""
146 |
147 | #: includes/class.SnS_Settings_Page.php:22 includes/class.SnS_Admin.php:91
148 | #: includes/class.SnS_Admin.php:202
149 | msgid "Settings"
150 | msgstr ""
151 |
152 | #: includes/class.SnS_Settings_Page.php:77
153 | msgid "Scripts n Styles Settings"
154 | msgstr ""
155 |
156 | #: includes/class.SnS_Settings_Page.php:83
157 | msgid "Menu Position : "
158 | msgstr ""
159 |
160 | #: includes/class.SnS_Settings_Page.php:97
161 | msgid "CodeMirror Theme : "
162 | msgstr ""
163 |
164 | #: includes/class.SnS_Settings_Page.php:111
165 | msgid "Hide Metabox by default : "
166 | msgstr ""
167 |
168 | #: includes/class.SnS_Settings_Page.php:120
169 | msgid "Hide Metabox by default"
170 | msgstr ""
171 |
172 | #: includes/class.SnS_Settings_Page.php:121
173 | msgid ""
174 | "This is overridable via Screen Options on each edit screen. "
176 | msgstr ""
177 |
178 | #: includes/class.SnS_Settings_Page.php:126
179 | msgid "Code Mirror Demo"
180 | msgstr ""
181 |
182 | #: includes/class.SnS_Settings_Page.php:138
183 | msgid ""
184 | "Control how and where Scripts n Styles menus and metaboxes appear. These "
185 | "options are here because sometimes users really care about this stuff. Feel "
186 | "free to adjust to your liking. :-)"
187 | msgstr ""
188 |
189 | #: includes/class.SnS_List_Usage.php:20
190 | msgid "Scripts (head)"
191 | msgstr ""
192 |
193 | #: includes/class.SnS_List_Usage.php:26
194 | msgid "Enqueued Scripts"
195 | msgstr ""
196 |
197 | #: includes/class.SnS_List_Usage.php:31
198 | msgid "TinyMCE Formats"
199 | msgstr ""
200 |
201 | #: includes/class.SnS_List_Usage.php:37
202 | msgid "Post Classes"
203 | msgstr ""
204 |
205 | #: includes/class.SnS_List_Usage.php:40
206 | msgid "Body Classes"
207 | msgstr ""
208 |
209 | #: includes/class.SnS_List_Usage.php:50
210 | msgid "Edit “%s”"
211 | msgstr ""
212 |
213 | #: includes/class.SnS_List_Usage.php:53
214 | msgid "Edit"
215 | msgstr ""
216 |
217 | #: includes/class.SnS_List_Usage.php:75
218 | msgid "Title"
219 | msgstr ""
220 |
221 | #: includes/class.SnS_List_Usage.php:76
222 | msgid "ID"
223 | msgstr ""
224 |
225 | #: includes/class.SnS_List_Usage.php:77
226 | msgid "Status"
227 | msgstr ""
228 |
229 | #: includes/class.SnS_List_Usage.php:78
230 | msgid "Post Type"
231 | msgstr ""
232 |
233 | #: includes/class.SnS_List_Usage.php:79
234 | msgid "Script Data"
235 | msgstr ""
236 |
237 | #: includes/class.SnS_List_Usage.php:80
238 | msgid "Style Data"
239 | msgstr ""
240 |
241 | #: includes/class.SnS_List_Usage.php:133
242 | msgid "Password protected"
243 | msgstr ""
244 |
245 | #: includes/class.SnS_List_Usage.php:135
246 | msgid "Private"
247 | msgstr ""
248 |
249 | #: includes/class.SnS_List_Usage.php:137
250 | msgid "Draft"
251 | msgstr ""
252 |
253 | #. translators: post state
254 | #: includes/class.SnS_List_Usage.php:140
255 | msgctxt "post state"
256 | msgid "Pending"
257 | msgstr ""
258 |
259 | #: includes/class.SnS_List_Usage.php:142
260 | msgid "Sticky"
261 | msgstr ""
262 |
263 | #: includes/class.SnS_Usage_Page.php:22 includes/class.SnS_Admin.php:92
264 | msgid "Usage"
265 | msgstr ""
266 |
267 | #: includes/class.SnS_Usage_Page.php:47
268 | msgid "Per Page"
269 | msgstr ""
270 |
271 | #: includes/class.SnS_Usage_Page.php:54
272 | msgid "Scripts n Styles Usage"
273 | msgstr ""
274 |
275 | #: includes/class.SnS_Usage_Page.php:78
276 | msgid "The following table shows content that utilizes Scripts n Styles."
277 | msgstr ""
278 |
279 | #: includes/class.SnS_Global_Page.php:17 includes/class.SnS_Admin.php:90
280 | msgid "Global"
281 | msgstr ""
282 |
283 | #: includes/class.SnS_Global_Page.php:53
284 | msgid "Global Scripts n Styles"
285 | msgstr ""
286 |
287 | #: includes/class.SnS_Global_Page.php:59
288 | msgid "Scripts: "
289 | msgstr ""
290 |
291 | #: includes/class.SnS_Global_Page.php:70
292 | msgid ""
293 | "The \"Scripts\" will be included verbatim in <"
295 | "script>
tags at the bottom of the <body>
element of "
296 | "your html. "
297 | msgstr ""
298 |
299 | #: includes/class.SnS_Global_Page.php:74
300 | msgid "Styles: "
301 | msgstr ""
302 |
303 | #: includes/class.SnS_Global_Page.php:85
304 | msgid ""
305 | "The \"Styles\" will be included verbatim in <"
307 | "style>
tags in the <head>
element of your html. "
308 | msgstr ""
309 |
310 | #: includes/class.SnS_Global_Page.php:89
311 | msgid "Scripts (for the head
element): "
312 | msgstr ""
313 |
314 | #: includes/class.SnS_Global_Page.php:100
315 | msgid ""
316 | "The \"Scripts (in head)\" will be included verbatim in "
318 | "<script>
tags in the <head>
element of your "
319 | "html. "
320 | msgstr ""
321 |
322 | #: includes/class.SnS_Global_Page.php:104
323 | msgid "Enqueue Scripts : "
324 | msgstr ""
325 |
326 | #: includes/class.SnS_Global_Page.php:115
327 | msgid "Currently Enqueued Scripts: "
328 | msgstr ""
329 |
330 | #: includes/class.SnS_Global_Page.php:126
331 | msgid ""
332 | "Code entered here will be included in every page (and post) of your "
333 | "site , including the homepage and archives. The code will appear "
334 | "before Scripts and Styles registered individually."
335 | msgstr ""
336 |
337 | #: includes/class.SnS_Form.php:105
338 | msgid "Cheatin’ uh?"
339 | msgstr ""
340 |
341 | #: includes/class.SnS_Form.php:108 includes/class.SnS_Form.php:135
342 | msgid "Settings saved."
343 | msgstr ""
344 |
345 | #: includes/class.SnS_Admin.php:109 includes/class.SnS_Admin.php:129
346 | msgid ""
347 | "In default (non MultiSite) WordPress installs, both Administrators"
348 | "em> and \r\n"
349 | "\t\t\t\t\t\tEditors can access Scripts-n-Styles on "
350 | "individual edit screens. \r\n"
351 | "\t\t\t\t\t\tOnly Administrators can access this Options Page. In "
352 | "MultiSite WordPress installs, only \r\n"
353 | "\t\t\t\t\t\t\"Super Admin\" users can access either\r\n"
354 | "\t\t\t\t\t\tScripts-n-Styles on individual edit screens or this "
355 | "Options Page. If other plugins change \r\n"
356 | "\t\t\t\t\t\tcapabilities (specifically \"unfiltered_html\"), \r\n"
357 | "\t\t\t\t\t\tother users can be granted access.
"
358 | msgstr ""
359 |
360 | #: includes/class.SnS_Admin.php:119
361 | msgid "For more information:"
362 | msgstr ""
363 |
364 | #: includes/class.SnS_Admin.php:120
365 | msgid ""
366 | "Frequently Asked Questions "
368 | msgstr ""
369 |
370 | #: includes/class.SnS_Admin.php:121
371 | msgid ""
372 | "Source on github "
374 | msgstr ""
375 |
376 | #: includes/class.SnS_Admin.php:122
377 | msgid ""
378 | "Support Forums "
380 | msgstr ""
381 |
382 | #. Plugin URI of the plugin/theme
383 | msgid "http://www.unfocus.com/projects/scripts-n-styles/"
384 | msgstr ""
385 |
386 | #. Description of the plugin/theme
387 | msgid ""
388 | "Allows WordPress admin users the ability to add custom CSS and JavaScript "
389 | "directly to individual Post, Pages or custom post types."
390 | msgstr ""
391 |
392 | #. Author of the plugin/theme
393 | msgid "unFocus Projects"
394 | msgstr ""
395 |
396 | #. Author URI of the plugin/theme
397 | msgid "http://www.unfocus.com/"
398 | msgstr ""
399 |
--------------------------------------------------------------------------------
/dist/legacy/chosen/chosen-sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unFocus/Scripts-n-Styles/07dcf6e0a34d40bab018fe3783392fbe189dee92/dist/legacy/chosen/chosen-sprite.png
--------------------------------------------------------------------------------
/dist/legacy/chosen/chosen-sprite@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unFocus/Scripts-n-Styles/07dcf6e0a34d40bab018fe3783392fbe189dee92/dist/legacy/chosen/chosen-sprite@2x.png
--------------------------------------------------------------------------------
/dist/legacy/chosen/chosen.min.css:
--------------------------------------------------------------------------------
1 | /* Chosen v1.6.2 | (c) 2011-2016 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2 |
3 | .chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chosen-container *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.chosen-container .chosen-drop{position:absolute;top:100%;left:-9999px;z-index:1010;width:100%;border:1px solid #aaa;border-top:0;background:#fff;box-shadow:0 4px 5px rgba(0,0,0,.15)}.chosen-container.chosen-with-drop .chosen-drop{left:0}.chosen-container a{cursor:pointer}.chosen-container .search-choice .group-name,.chosen-container .chosen-single .group-name{margin-right:4px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:400;color:#999}.chosen-container .search-choice .group-name:after,.chosen-container .chosen-single .group-name:after{content:":";padding-left:2px;vertical-align:top}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:25px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),color-stop(100%,#f4f4f4));background:-webkit-linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-moz-linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-o-linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:linear-gradient(#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:#fff url(chosen-sprite.png) no-repeat 100% -20px;background:url(chosen-sprite.png) no-repeat 100% -20px;font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;left:-9999px}.chosen-container .chosen-results{color:#444;position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px;word-wrap:break-word;-webkit-touch-callout:none}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{color:#777;display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;margin:0;padding:0 5px;width:100%;height:auto;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(#eee 1%,#fff 15%);background-image:-moz-linear-gradient(#eee 1%,#fff 15%);background-image:-o-linear-gradient(#eee 1%,#fff 15%);background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:0;height:25px;outline:0;border:0!important;background:transparent!important;box-shadow:none;color:#999;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 5px 3px 0;padding:3px 20px 3px 5px;border:1px solid #aaa;max-width:100%;border-radius:3px;background-color:#eee;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-size:100% 19px;background-repeat:repeat-x;background-clip:padding-box;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice span{word-wrap:break-word}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#eee),color-stop(80%,#fff));background-image:-webkit-linear-gradient(#eee 20%,#fff 80%);background-image:-moz-linear-gradient(#eee 20%,#fff 80%);background-image:-o-linear-gradient(#eee 20%,#fff 80%);background-image:linear-gradient(#eee 20%,#fff 80%);box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:0;background:transparent}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#222!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single-nosearch .chosen-search,.chosen-rtl .chosen-drop{left:9999px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:0}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:#fff url(chosen-sprite.png) no-repeat -30px -20px;background:url(chosen-sprite.png) no-repeat -30px -20px;direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-resolution:144dpi),only screen and (min-resolution:1.5dppx){.chosen-rtl .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-container-single .chosen-search input[type=text],.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span{background-image:url(chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}}
--------------------------------------------------------------------------------
/dist/legacy/html5shiv-printshiv.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
3 | */
4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML=" ",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document);
--------------------------------------------------------------------------------
/dist/legacy/html5shiv.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
3 | */
4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML=" ",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);
--------------------------------------------------------------------------------
/dist/legacy/jquery.mustache.min.js:
--------------------------------------------------------------------------------
1 | // Spec v1.1.2
2 | // Version 0.7.2
3 | /*
4 | The MIT License
5 |
6 | Copyright (c) 2009 Chris Wanstrath (Ruby)
7 | Copyright (c) 2010 Jan Lehnardt (JavaScript)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 | */
15 | (function(a){(function(a,b){if("object"==typeof exports&&exports)b(exports);else{var c={};b(c),"function"==typeof define&&define.amd?define(c):a.Mustache=c}})(this,function(a){function i(a,b){return h.call(a,b)}function j(a){return!i(d,a)}function m(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(a){return(a+"").replace(/[&<>"'\/]/g,function(a){return n[a]})}function p(a){this.string=a,this.tail=a,this.pos=0}function q(a,b){this.view=a||{},this.parent=b,this._cache={}}function r(){this.clearCache()}function s(b,c,d,e){for(var g,h,i,f="",j=0,k=b.length;k>j;++j)switch(g=b[j],h=g[1],g[0]){case"#":if(i=d.lookup(h),"object"==typeof i)if(l(i))for(var m=0,n=i.length;n>m;++m)f+=s(g[4],c,d.push(i[m]),e);else i&&(f+=s(g[4],c,d.push(i),e));else if("function"==typeof i){var o=null==e?null:e.slice(g[3],g[5]);i=i.call(d.view,o,function(a){return c.render(a,d)}),null!=i&&(f+=i)}else i&&(f+=s(g[4],c,d,e));break;case"^":i=d.lookup(h),(!i||l(i)&&0===i.length)&&(f+=s(g[4],c,d,e));break;case">":i=c.getPartial(h),"function"==typeof i&&(f+=i(d));break;case"&":i=d.lookup(h),null!=i&&(f+=i);break;case"name":i=d.lookup(h),null!=i&&(f+=a.escape(i));break;case"text":f+=h}return f}function t(a){for(var e,b=[],c=b,d=[],f=0,g=a.length;g>f;++f)switch(e=a[f],e[0]){case"#":case"^":d.push(e),c.push(e),c=e[4]=[];break;case"/":var h=d.pop();h[5]=e[2],c=d.length>0?d[d.length-1][4]:b;break;default:c.push(e)}return b}function u(a){for(var c,d,b=[],e=0,f=a.length;f>e;++e)c=a[e],c&&("text"===c[0]&&d&&"text"===d[0]?(d[1]+=c[1],d[3]=c[3]):(d=c,b.push(c)));return b}function v(a){return[RegExp(m(a[0])+"\\s*"),RegExp("\\s*"+m(a[1]))]}function w(d,h){function s(){if(q&&!r)for(;o.length;)delete n[o.pop()];else o=[];q=!1,r=!1}if(d=d||"",h=h||a.tags,"string"==typeof h&&(h=h.split(c)),2!==h.length)throw Error("Invalid tags: "+h.join(", "));for(var w,x,y,z,A,i=v(h),k=new p(d),l=[],n=[],o=[],q=!1,r=!1;!k.eos();){if(w=k.pos,y=k.scanUntil(i[0]))for(var B=0,C=y.length;C>B;++B)z=y.charAt(B),j(z)?o.push(n.length):r=!0,n.push(["text",z,w,w+1]),w+=1,"\n"==z&&s();if(!k.scan(i[0]))break;if(q=!0,x=k.scan(g)||"name",k.scan(b),"="===x?(y=k.scanUntil(e),k.scan(e),k.scanUntil(i[1])):"{"===x?(y=k.scanUntil(RegExp("\\s*"+m("}"+h[1]))),k.scan(f),k.scanUntil(i[1]),x="&"):y=k.scanUntil(i[1]),!k.scan(i[1]))throw Error("Unclosed tag at "+k.pos);if(A=[x,y,w,k.pos],n.push(A),"#"===x||"^"===x)l.push(A);else if("/"===x){if(0===l.length)throw Error('Unopened section "'+y+'" at '+w);var D=l.pop();if(D[1]!==y)throw Error('Unclosed section "'+D[1]+'" at '+w)}else if("name"===x||"{"===x||"&"===x)r=!0;else if("="===x){if(h=y.split(c),2!==h.length)throw Error("Invalid tags at "+w+": "+h.join(", "));i=v(h)}}var D=l.pop();if(D)throw Error('Unclosed section "'+D[1]+'" at '+k.pos);return n=u(n),t(n)}var b=/\s*/,c=/\s+/,d=/\S/,e=/\s*=/,f=/\s*\}/,g=/#|\^|\/|>|\{|&|=|!/,h=RegExp.prototype.test,k=Object.prototype.toString,l=Array.isArray||function(a){return"[object Array]"===k.call(a)},n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};p.prototype.eos=function(){return""===this.tail},p.prototype.scan=function(a){var b=this.tail.match(a);return b&&0===b.index?(this.tail=this.tail.substring(b[0].length),this.pos+=b[0].length,b[0]):""},p.prototype.scanUntil=function(a){var b,c=this.tail.search(a);switch(c){case-1:b=this.tail,this.pos+=this.tail.length,this.tail="";break;case 0:b="";break;default:b=this.tail.substring(0,c),this.tail=this.tail.substring(c),this.pos+=c}return b},q.make=function(a){return a instanceof q?a:new q(a)},q.prototype.push=function(a){return new q(a,this)},q.prototype.lookup=function(a){var b=this._cache[a];if(!b){if("."==a)b=this.view;else for(var c=this;c;){if(a.indexOf(".")>0){b=c.view;for(var d=a.split("."),e=0;b&&d.length>e;)b=b[d[e++]]}else b=c.view[a];if(null!=b)break;c=c.parent}this._cache[a]=b}return"function"==typeof b&&(b=b.call(this.view)),b},r.prototype.clearCache=function(){this._cache={},this._partialCache={}},r.prototype.compile=function(b,c){var d=this._cache[b];if(!d){var e=a.parse(b,c);d=this._cache[b]=this.compileTokens(e,b)}return d},r.prototype.compilePartial=function(a,b,c){var d=this.compile(b,c);return this._partialCache[a]=d,d},r.prototype.getPartial=function(a){return a in this._partialCache||!this._loadPartial||this.compilePartial(a,this._loadPartial(a)),this._partialCache[a]},r.prototype.compileTokens=function(a,b){var c=this;return function(d,e){if(e)if("function"==typeof e)c._loadPartial=e;else for(var f in e)c.compilePartial(f,e[f]);return s(a,c,q.make(d),b)}},r.prototype.render=function(a,b,c){return this.compile(a)(b,c)},a.name="mustache.js",a.version="0.7.2",a.tags=["{{","}}"],a.Scanner=p,a.Context=q,a.Writer=r,a.parse=w,a.escape=o;var x=new r;a.clearCache=function(){return x.clearCache()},a.compile=function(a,b){return x.compile(a,b)},a.compilePartial=function(a,b,c){return x.compilePartial(a,b,c)},a.compileTokens=function(a,b){return x.compileTokens(a,b)},a.render=function(a,b,c){return x.render(a,b,c)},a.to_html=function(b,c,d,e){var f=a.render(b,c,d);return"function"!=typeof e?f:(e(f),void 0)}}),a.mustache=function(a,b,c){return Mustache.render(a,b,c)},a.fn.mustache=function(b,c){return a(this).map(function(d,e){var f=a.trim(a(e).html()),g=a.mustache(f,b,c);return a(g).get()})}})(jQuery);
--------------------------------------------------------------------------------
/dist/scripts-n-styles.php:
--------------------------------------------------------------------------------
1 |
7 | * @copyright 2010 - 2020, Kenneth Newman
8 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 | * @link http://www.unfocus.com/projects/scripts-n-styles/ Plugin URI
10 | * @link http://www.unfocus.com/ Author URI
11 | *
12 | * @todo Space to add arbitrary html to wp_head and wp_footer.
13 | * @todo Create ability to add and register scripts and styles for enqueueing (via Options page).
14 | * @todo Create selection on Option page of which to pick registered scripts to make available on edit screens.
15 | * @todo Create shortcode registration on Options page to make those snippets available on edit screens.
16 | * @todo Add Error messaging.
17 | * @todo Clean up tiny_mce_before_init in SnS_Admin_Meta_Box.
18 | *
19 | * @wordpress-plugin
20 | * Plugin Name: Scripts n Styles
21 | * Plugin URI: http://www.unfocus.com/projects/scripts-n-styles/
22 | * Description: Allows WordPress admin users the ability to add custom CSS and JavaScript directly to individual Post, Pages or custom post types.
23 | * Version: 4.0.0-alpha-3
24 | * Requires at least: 5.4
25 | * Requires PHP: 7.2
26 | * Author: unFocus Projects
27 | * Author URI: http://www.unfocus.com/
28 | * License: GPLv3 or later
29 | * License URI: https://www.gnu.org/licenses/gpl-3.0.html
30 | * Text Domain: scripts-n-styles
31 | */
32 |
33 | /*
34 | The Scripts n Styles WordPress Plugin
35 | Copyright (c) 2010-2018 Kenneth Newman
36 | Copyright (c) 2012 Kevin Newman
37 | Copyright (c) 2012-2013 adcSTUDIO LLC
38 |
39 | Scripts n Styles is free software; you can redistribute it and/or
40 | modify it under the terms of the GNU General Public License
41 | as published by the Free Software Foundation; either version 3
42 | of the License, or (at your option) any later version.
43 |
44 | Scripts n Styles is distributed in the hope that it will be useful,
45 | but WITHOUT ANY WARRANTY; without even the implied warranty of
46 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 | GNU General Public License for more details.
48 |
49 | You should have received a copy of the GNU General Public License
50 | along with this program. If not, see .
51 |
52 | This file incorporates work covered by other licenses and permissions.
53 | */
54 |
55 | /**
56 | * Scripts n Styles
57 | *
58 | * Allows WordPress admin users the ability to add custom CSS
59 | * and JavaScript directly to individual Post, Pages or custom
60 | * post types.
61 | *
62 | * NOTE: No user except the "Super Admin" can use this plugin in MultiSite. I'll add
63 | * features for MultiSite later, perhaps the ones below...
64 | * The "Super Admin" user has exclusive 'unfiltered_html' capabilities in MultiSite.
65 | * Also, options.php checks for is_super_admin() so the 'manage_options' capability
66 | * for blog admins is insufficient to pass the check to manage options directly.
67 | *
68 | * The Tentative plan is for Super Admins to create Snippets or Shortcodes approved for use by users with certain capabilities
69 | * ('unfiltered_html' and/or 'manage_options'). The 'unfiltered_html' capability can be granted via another plugin. This plugin will
70 | * not deal with granting any capabilities.
71 | */
72 |
73 | if ( version_compare( PHP_VERSION, '7.2', '>=' ) ) :
74 | /**
75 | * This utility function is location specific.
76 | * Use in places where __FILE__ would otherwise be used.
77 | */
78 | define( 'SNS_FILE', __FILE__ );
79 |
80 | require_once 'includes/bootstrap.php';
81 |
82 | else :
83 | /**
84 | * Disabled message.
85 | */
86 | function sns_disable_message() {
87 | ?>
88 |
91 | 1 && get_option( 'page_comments' ) ) {
12 | previous_comments_link();
13 | next_comments_link();
14 | }
15 | }
16 | comment_form();
17 |
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/functions.php:
--------------------------------------------------------------------------------
1 | %s
', esc_html( $message ) );
21 | } );
22 | } );
23 |
24 | add_action( 'load-customize.php', function() use ( $message ) {
25 | wp_die(
26 | esc_html( $message ),
27 | '',
28 | array(
29 | 'back_link' => true,
30 | )
31 | );
32 | } );
33 |
34 | add_action( 'template_redirect', function() use ( $message ) {
35 | if ( isset( $_GET['preview'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
36 | wp_die( esc_html( $message ) );
37 | }
38 | } );
39 |
40 | return;
41 | }
42 |
43 | add_action( 'after_setup_theme', function() {
44 | // phpcs:disable
45 | add_theme_support( 'admin-bar', [ 'callback' => function() {
46 | ?> 100,
102 | 'width' => 400,
103 | 'flex-height' => true,
104 | 'flex-width' => true,
105 | 'header-text' => [ 'site-title', 'site-description' ],
106 | ] );
107 |
108 | // Add theme support for selective refresh for widgets.
109 | add_theme_support( 'customize-selective-refresh-widgets' );
110 |
111 | /*
112 | * This theme styles the visual editor to resemble the theme style,
113 | * specifically font, colors, and column width.
114 | */
115 | add_editor_style( [ 'css/editor-style.css' ] );
116 |
117 | // Define and register starter content to showcase the theme on new sites.
118 | add_theme_support( 'starter-content', [
119 | 'widgets' => [
120 | // Place three core-defined widgets in the sidebar area.
121 | 'sidebar-1' => [
122 | 'text_business_info',
123 | 'search',
124 | 'text_about',
125 | ],
126 |
127 | // Add the core-defined business info widget to the footer 1 area.
128 | 'sidebar-2' => [
129 | 'text_business_info',
130 | ],
131 |
132 | // Put two core-defined widgets in the footer 2 area.
133 | 'sidebar-3' => [
134 | 'text_about',
135 | 'search',
136 | ],
137 | ],
138 |
139 | // Specify the core-defined pages to create and add custom thumbnails to some of them.
140 | 'posts' => [
141 | 'home',
142 | 'about' => [
143 | 'thumbnail' => '{{image-sandwich}}',
144 | ],
145 | 'contact' => [
146 | 'thumbnail' => '{{image-espresso}}',
147 | ],
148 | 'blog' => [
149 | 'thumbnail' => '{{image-coffee}}',
150 | ],
151 | 'homepage-section' => [
152 | 'thumbnail' => '{{image-espresso}}',
153 | ],
154 | ],
155 |
156 | // Create the custom image attachments used as post thumbnails for pages.
157 | 'attachments' => [
158 | 'image-espresso' => [
159 | 'post_title' => _x( 'Espresso', 'Theme starter content', 'scripts-n-styles' ),
160 | 'file' => 'assets/images/espresso.jpg', // URL relative to the template directory.
161 | ],
162 | 'image-sandwich' => [
163 | 'post_title' => _x( 'Sandwich', 'Theme starter content', 'scripts-n-styles' ),
164 | 'file' => 'assets/images/sandwich.jpg',
165 | ],
166 | 'image-coffee' => [
167 | 'post_title' => _x( 'Coffee', 'Theme starter content', 'scripts-n-styles' ),
168 | 'file' => 'assets/images/coffee.jpg',
169 | ],
170 | ],
171 |
172 | // Default to a static front page and assign the front and posts pages.
173 | 'options' => [
174 | 'show_on_front' => 'page',
175 | 'page_on_front' => '{{home}}',
176 | 'page_for_posts' => '{{blog}}',
177 | ],
178 |
179 | // Set the front page section theme mods to the IDs of the core-registered pages.
180 | 'theme_mods' => [
181 | 'panel_1' => '{{homepage-section}}',
182 | 'panel_2' => '{{about}}',
183 | 'panel_3' => '{{blog}}',
184 | 'panel_4' => '{{contact}}',
185 | ],
186 |
187 | // Set up nav menus for each of the two areas registered in the theme.
188 | 'nav_menus' => [
189 | // Assign a menu to the "top" location.
190 | 'top' => [
191 | 'name' => __( 'Top Menu', 'scripts-n-styles' ),
192 | 'items' => [
193 | 'link_home', // Note that the core "home" page is actually a link in case a static front page is not used.
194 | 'page_about',
195 | 'page_blog',
196 | 'page_contact',
197 | ],
198 | ],
199 |
200 | // Assign a menu to the "social" location.
201 | 'social' => [
202 | 'name' => __( 'Social Links Menu', 'scripts-n-styles' ),
203 | 'items' => [
204 | 'link_yelp',
205 | 'link_facebook',
206 | 'link_twitter',
207 | 'link_instagram',
208 | 'link_email',
209 | ],
210 | ],
211 | ],
212 | ] );
213 | } );
214 |
215 | add_action( 'wp_enqueue_scripts', function() {
216 | if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
217 | wp_enqueue_script( 'comment-reply' );
218 | }
219 | wp_enqueue_style( 'theme_style', get_stylesheet_uri() );
220 | wp_enqueue_style( 'html5shiv-printshiv' );
221 | wp_style_add_data( 'html5shiv-printshiv', 'conditional', 'lt IE 9' );
222 | } );
223 |
224 | add_action( 'widgets_init', function() {
225 | register_sidebar( [
226 | 'name' => __( 'Main Widget Area', 'scripts-n-styles' ),
227 | 'id' => 'sidebar-1',
228 | 'before_widget' => '',
229 | 'after_widget' => ' ',
230 | 'before_title' => '',
232 | ] );
233 | } );
234 |
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/index.php:
--------------------------------------------------------------------------------
1 |
10 | >
11 |
12 |
13 |
14 |
15 |
16 | >
17 |
18 |
19 |
20 |
25 | >
26 |
33 |
38 |
43 |
44 |
48 |
49 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/js/test.coffee:
--------------------------------------------------------------------------------
1 | # Assignment:
2 | number = 42
3 | opposite = true
4 |
5 | # Conditions:
6 | number = -42 if opposite
7 |
8 | # Functions:
9 | square = (x) -> x * x
10 |
11 | # Arrays:
12 | list = [1, 2, 3, 4, 5]
13 |
14 | # Objects:
15 | math =
16 | root: Math.sqrt
17 | square: square
18 | cube: (x) -> x * square x
19 |
20 | # Splats:
21 | race = (winner, runners...) ->
22 | print winner, runners
23 |
24 | # Existence:
25 | alert "I knew it!" if elvis?
26 |
27 | # Array comprehensions:
28 | cubes = (math.cube num for num in list)
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/js/test.jsx:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var HelloWorld = React.createClass({
4 |
5 | render: function() {
6 | return (
7 | Hello World!!!
8 | );
9 | },
10 |
11 | });
12 |
13 | var mainElement = document.querySelector("main");
14 |
15 | ReactDOM.render( , mainElement);
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/js/test.react.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var HelloWorld = React.createClass({
4 |
5 | render: function() {
6 | return (
7 | Hello World!!!
8 | );
9 | },
10 |
11 | });
12 |
13 | var mainElement = document.querySelector("main");
14 |
15 | ReactDOM.render( , mainElement);
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/js/test.ts:
--------------------------------------------------------------------------------
1 | class Greeter {
2 | greeting: string;
3 | constructor (message: string) {
4 | this.greeting = message;
5 | }
6 | greet() {
7 | return "Hello, " + this.greeting;
8 | }
9 | }
10 |
11 | var greeter = new Greeter("world");
12 |
13 | var button = document.createElement('button')
14 | button.innerText = "Say Hello"
15 | button.onclick = function() {
16 | alert(greeter.greet())
17 | }
18 |
19 | document.body.appendChild(button)
20 |
21 |
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/js/test.tsx:
--------------------------------------------------------------------------------
1 | declare namespace JSX {
2 | interface ElementClass {
3 | render: any;
4 | }
5 | }
6 |
7 | class MyComponent {
8 | render() {}
9 | }
10 | function MyFactoryFunction() {
11 | return { render: () => {} }
12 | }
13 |
14 | ; // ok
15 | ; // ok
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/js/vendor/test.js:
--------------------------------------------------------------------------------
1 | test.js
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/less/content.less:
--------------------------------------------------------------------------------
1 | .content {
2 | display: block;
3 | }
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/less/mixins.less:
--------------------------------------------------------------------------------
1 | .mixin-test() {
2 | display: block;
3 | }
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/less/theme.less:
--------------------------------------------------------------------------------
1 | body {
2 | display: block;
3 | }
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/less/variables.less:
--------------------------------------------------------------------------------
1 | @test: #fff;
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/readme.txt:
--------------------------------------------------------------------------------
1 | This theme is part of the Scripts n Styles plugin for WordPress.
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unFocus/Scripts-n-Styles/07dcf6e0a34d40bab018fe3783392fbe189dee92/dist/theme/scripts-n-styles/screenshot.png
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Theme Name: Scripts n Styles
3 | Theme URI: http://www.unfocus.com/projects/scripts-n-styles/
4 | Description: This is a Demo Theme used to enable a beta feature of Scripts n Styles. Please only use for testing. Feedback about the feature would be awesome.
5 | Author: unFocus Projects
6 | Author URI: http://www.unfocus.com/
7 | Version: 4.0.0-alpha
8 | License: GNU General Public License v2 or later
9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html
10 | Tags: grid-layout, one-column, two-columns, three-columns, four-columns, left-sidebar, right-sidebar, flexible-header, footer-widgets, accessibility-ready, buddypress, custom-background, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-image-header, featured-images, front-page-post-form, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready, blog, e-commerce, education, entertainment, food-and-drink, holiday, news, photography, portfolio
11 | Text Domain: scripts-n-styles
12 |
13 | This theme, like WordPress, is licensed under the GPL.
14 | Use it to make something cool, have fun, and share what you've learned with others.
15 | */
16 |
17 | .wp-caption,
18 | .wp-caption-text,
19 | .sticky,
20 | .gallery-caption,
21 | .bypostauthor,
22 | .alignright,
23 | .alignleft,
24 | .aligncenter {}
25 |
26 | .screen-reader-text {}
27 |
28 | .screen-reader-text:focus {}
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/styles/test.sass:
--------------------------------------------------------------------------------
1 | nav
2 | ul
3 | margin: 0
4 | padding: 0
5 | list-style: none
6 |
7 | li
8 | display: inline-block
9 |
10 | a
11 | display: block
12 | padding: 6px 12px
13 | text-decoration: none
14 |
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/styles/test.scss:
--------------------------------------------------------------------------------
1 | nav {
2 | ul {
3 | margin: 0;
4 | padding: 0;
5 | list-style: none;
6 | }
7 |
8 | li { display: inline-block; }
9 |
10 | a {
11 | display: block;
12 | padding: 6px 12px;
13 | text-decoration: none;
14 | }
15 | }
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/styles/test.styl:
--------------------------------------------------------------------------------
1 | /* Stylus mode */
2 |
3 | #id,
4 | .class,
5 | article
6 | font-family Arial, sans-serif
7 |
8 | #id,
9 | .class,
10 | article {
11 | font-family: Arial, sans-serif;
12 | }
13 |
14 | // Variables
15 | font-size-base = 16px
16 | line-height-base = 1.5
17 | font-family-base = "Helvetica Neue", Helvetica, Arial, sans-serif
18 | text-color = lighten(#000, 20%)
19 |
20 | body
21 | font font-size-base/line-height-base font-family-base
22 | color text-color
23 |
24 | body {
25 | font: 400 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
26 | color: #333;
27 | }
28 |
29 | // Variables
30 | link-color = darken(#428bca, 6.5%)
31 | link-hover-color = darken(link-color, 15%)
32 | link-decoration = none
33 | link-hover-decoration = false
34 |
35 | // Mixin
36 | tab-focus()
37 | outline thin dotted
38 | outline 5px auto -webkit-focus-ring-color
39 | outline-offset -2px
40 |
41 | a
42 | color link-color
43 | if link-decoration
44 | text-decoration link-decoration
45 | &:hover
46 | &:focus
47 | color link-hover-color
48 | if link-hover-decoration
49 | text-decoration link-hover-decoration
50 | &:focus
51 | tab-focus()
52 |
53 | a {
54 | color: #3782c4;
55 | text-decoration: none;
56 | }
57 | a:hover,
58 | a:focus {
59 | color: #2f6ea7;
60 | }
61 | a:focus {
62 | outline: thin dotted;
63 | outline: 5px auto -webkit-focus-ring-color;
64 | outline-offset: -2px;
65 | }
66 |
--------------------------------------------------------------------------------
/dist/theme/scripts-n-styles/test.json:
--------------------------------------------------------------------------------
1 | {
2 | "@context": {
3 | "name": "http://schema.org/name",
4 | "description": "http://schema.org/description",
5 | "image": {
6 | "@id": "http://schema.org/image",
7 | "@type": "@id"
8 | },
9 | "geo": "http://schema.org/geo",
10 | "latitude": {
11 | "@id": "http://schema.org/latitude",
12 | "@type": "xsd:float"
13 | },
14 | "longitude": {
15 | "@id": "http://schema.org/longitude",
16 | "@type": "xsd:float"
17 | },
18 | "xsd": "http://www.w3.org/2001/XMLSchema#"
19 | },
20 | "name": "The Empire State Building",
21 | "description": "The Empire State Building is a 102-story landmark in New York City.",
22 | "image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
23 | "geo": {
24 | "latitude": "40.75",
25 | "longitude": "73.98"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/dist/uninstall.php:
--------------------------------------------------------------------------------
1 | -1,
21 | 'post_type' => 'any',
22 | 'post_status' => 'any',
23 | 'orderby' => 'ID',
24 | 'meta_key' => '_SnS', // WPCS: slow query ok.
25 | ] );
26 |
27 | foreach ( $sposts as $spost ) {
28 | delete_post_meta( $spost->ID, '_SnS' );
29 | }
30 | delete_option( 'SnS_options' );
31 |
32 | $users = get_users( 'meta_key=current_sns_tab' ); // WPCS: slow query ok.
33 | foreach ( $users as $user ) {
34 | delete_user_option( $user->ID, 'current_sns_tab', true );
35 | }
36 |
37 | $users = get_users( 'meta_key=scripts_n_styles_page_sns_usage_per_page' ); // WPCS: slow query ok.
38 | foreach ( $users as $user ) {
39 | delete_user_option( $user->ID, 'scripts_n_styles_page_sns_usage_per_page', true );
40 | }
41 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3.7'
2 |
3 | services:
4 |
5 | wordpress:
6 | image: wordpress
7 | depends_on:
8 | - mysql
9 | restart: always
10 | ports:
11 | - "80:80"
12 | - "443:443"
13 | environment:
14 | WORDPRESS_DB_PASSWORD: $DB_PASSWORD
15 | WORDPRESS_DEBUG: 1
16 | WORDPRESS_CONFIG_EXTRA: |
17 | define( 'WP_DEBUG_DISPLAY', false );
18 | define( 'WP_DEBUG_LOG', true );
19 | define( 'SAVEQUERIES', true );
20 | define( 'SCRIPT_DEBUG', true );
21 | define( 'CONCATENATE_SCRIPTS', false );
22 | define( 'JETPACK_DEV_DEBUG', true );
23 | volumes:
24 | - ./html/:/var/www/html/
25 | # - ../svn/trunk/:/var/www/html/wp-content/plugins/scripts-n-styles/
26 | - ./dist/:/var/www/html/wp-content/plugins/scripts-n-styles/
27 | - ./ssl/localhost.crt:/etc/apache2/ssl/localhost.crt
28 | - ./ssl/localhost.key:/etc/apache2/ssl/localhost.key
29 | - ./ssl/000-default.conf:/etc/apache2/sites-enabled/000-default.conf
30 | - ./ssl/ssl.load:/etc/apache2/mods-enabled/ssl.load
31 | - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
32 |
33 | mysql:
34 | image: mariadb
35 | restart: always
36 | ports:
37 | - 3306:3306
38 | volumes:
39 | - ./initdb:/docker-entrypoint-initdb.d
40 | - data:/var/lib/mysql
41 | environment:
42 | MYSQL_ROOT_PASSWORD: $DB_PASSWORD
43 | MYSQL_DATABASE: wordpress
44 |
45 | phpmyadmin:
46 | image: phpmyadmin/phpmyadmin
47 | depends_on:
48 | - mysql
49 | restart: always
50 | ports:
51 | - 8080:80
52 | environment:
53 | PMA_HOST: mysql
54 | MYSQL_ROOT_PASSWORD: $DB_PASSWORD
55 | volumes:
56 | - ./uploads.ini:/usr/local/etc/php/php.ini
57 |
58 | volumes:
59 | data:
60 |
--------------------------------------------------------------------------------
/gulp-build-codemirror.js:
--------------------------------------------------------------------------------
1 | import gulp from 'gulp';
2 | import postcss from 'gulp-postcss';
3 | import header from 'gulp-header';
4 | import footer from 'gulp-footer';
5 | import concat from 'gulp-concat';
6 | import uglify from 'gulp-uglify-es';
7 |
8 | const dir = 'node_modules/codemirror/';
9 |
10 | // A List of each relevant JS file.
11 | // See https://github.com/WordPress/better-code-editing/pull/92/files#diff-d624ea966e142693d2568ef0395f9aeb
12 | let js = [
13 | 'lib/codemirror.js',
14 |
15 | 'keymap/emacs.js',
16 | 'keymap/sublime.js',
17 | 'keymap/vim.js',
18 |
19 | 'addon/hint/show-hint.js',
20 | 'addon/hint/anyword-hint.js',
21 | 'addon/hint/css-hint.js',
22 | 'addon/hint/html-hint.js',
23 | 'addon/hint/javascript-hint.js',
24 | 'addon/hint/sql-hint.js',
25 | 'addon/hint/xml-hint.js',
26 |
27 | 'addon/lint/lint.js',
28 | 'addon/lint/css-lint.js',
29 | 'addon/lint/html-lint.js',
30 | 'addon/lint/javascript-lint.js',
31 | 'addon/lint/json-lint.js',
32 | 'addon/lint/coffeescript-lint.js', // Added.
33 | 'addon/lint/yaml-lint.js', // Added.
34 |
35 | 'addon/comment/comment.js',
36 | 'addon/comment/continuecomment.js',
37 |
38 | 'addon/fold/xml-fold.js',
39 |
40 | 'addon/mode/overlay.js',
41 |
42 | 'addon/edit/closebrackets.js',
43 | 'addon/edit/closetag.js',
44 | 'addon/edit/continuelist.js',
45 | 'addon/edit/matchbrackets.js',
46 | 'addon/edit/matchtags.js',
47 | 'addon/edit/trailingspace.js',
48 |
49 | 'addon/dialog/dialog.js',
50 |
51 | 'addon/display/autorefresh.js',
52 | 'addon/display/fullscreen.js',
53 | 'addon/display/panel.js',
54 | 'addon/display/placeholder.js',
55 | 'addon/display/rulers.js',
56 |
57 | 'addon/fold/brace-fold.js',
58 | 'addon/fold/comment-fold.js',
59 | 'addon/fold/foldcode.js',
60 | 'addon/fold/foldgutter.js',
61 | 'addon/fold/indent-fold.js',
62 | 'addon/fold/markdown-fold.js',
63 |
64 | 'addon/merge/merge.js',
65 |
66 | 'addon/mode/loadmode.js',
67 | 'addon/mode/multiplex.js',
68 | 'addon/mode/simple.js',
69 |
70 | // Should be included separately.
71 | // 'addon/runmode/runmode-standalone.js',
72 | 'addon/runmode/runmode.js',
73 | 'addon/runmode/colorize.js',
74 |
75 | 'addon/scroll/annotatescrollbar.js',
76 | 'addon/scroll/scrollpastend.js',
77 | 'addon/scroll/simplescrollbars.js',
78 |
79 | 'addon/search/search.js',
80 | 'addon/search/jump-to-line.js',
81 | 'addon/search/match-highlighter.js',
82 | 'addon/search/matchesonscrollbar.js',
83 | 'addon/search/searchcursor.js',
84 |
85 | // Shouldn't be included.
86 | // 'addon/tern/worker.js',
87 | // 'addon/tern/tern.js',
88 |
89 | 'addon/wrap/hardwrap.js',
90 |
91 | 'addon/selection/active-line.js',
92 | 'addon/selection/mark-selection.js',
93 | 'addon/selection/selection-pointer.js',
94 |
95 | 'mode/meta.js',
96 | 'mode/clike/clike.js',
97 | 'mode/css/css.js',
98 | 'mode/diff/diff.js',
99 | 'mode/htmlmixed/htmlmixed.js',
100 | 'mode/http/http.js',
101 | 'mode/javascript/javascript.js',
102 | 'mode/jsx/jsx.js',
103 | 'mode/markdown/markdown.js',
104 | 'mode/gfm/gfm.js',
105 | 'mode/nginx/nginx.js',
106 | 'mode/php/php.js',
107 | 'mode/sass/sass.js',
108 | 'mode/shell/shell.js',
109 | 'mode/sql/sql.js',
110 | 'mode/wast/wast.js',
111 | 'mode/xml/xml.js',
112 | 'mode/yaml/yaml.js'
113 | ];
114 |
115 | // Prepend the source dir.
116 | js = js.map( i => dir + i );
117 |
118 | function copyCodeMirrorJS() {
119 | var top = '(function () {',
120 | bottom = [
121 | 'if ( ! window.wp ) {',
122 | 'window.wp = {};',
123 | '}',
124 | 'window.wp.CodeMirror = this.CodeMirror;',
125 | '})();'
126 | ].join( '\n' );
127 |
128 | return gulp.src( js, { base: './node_modules' })
129 | .pipe( concat( 'codemirror.min.js' ) )
130 | .pipe( header( top ) )
131 | .pipe( footer( bottom ) )
132 | .pipe( uglify() )
133 | .pipe( gulp.dest( 'dist/codemirror' ) );
134 | }
135 | function copyCodeMirrorModes() {
136 | return gulp.src([
137 | dir + 'mode/**/*.js'
138 | ], { base: './node_modules' })
139 | .pipe( uglify() )
140 | .pipe( gulp.dest( 'dist' ) );
141 | }
142 | function copyCodeMirrorThemes() {
143 | return gulp.src([
144 | dir + 'theme/**/*.css'
145 | ], { base: './node_modules' })
146 | .pipe( gulp.dest( 'dist' ) );
147 | }
148 | function copyCodeMirrorStandalone() {
149 | return gulp.src([
150 | dir + 'addon/runmode/runmode-standalone.js'
151 | ])
152 | .pipe( uglify() )
153 | .pipe( gulp.dest( 'dist/codemirror' ) );
154 | }
155 | function copyCodeMirrorCSS() {
156 | return gulp.src([
157 | dir + 'lib/codemirror.css',
158 | dir + 'mode/tiddlywiki/tiddlywiki.css',
159 | dir + 'mode/tiki/tiki.css',
160 | dir + 'addon/hint/show-hint.css',
161 | dir + 'addon/lint/lint.css',
162 | dir + 'addon/dialog/dialog.css',
163 | dir + 'addon/display/fullscreen.css',
164 | dir + 'addon/fold/foldgutter.css',
165 | dir + 'addon/merge/merge.css',
166 | dir + 'addon/scroll/simplescrollbars.css',
167 | dir + 'addon/search/matchesonscrollbar.css',
168 | dir + 'addon/tern/tern.css'
169 | ], { base: './node_modules' })
170 | .pipe( concat( 'codemirror.min.css' ) )
171 | .pipe( postcss() )
172 | .pipe( gulp.dest( 'dist/codemirror' ) );
173 | }
174 |
175 | const copyCodeMirror = gulp.series(
176 | copyCodeMirrorModes,
177 | copyCodeMirrorJS,
178 | copyCodeMirrorCSS,
179 | copyCodeMirrorStandalone,
180 | copyCodeMirrorThemes
181 | );
182 |
183 | export {
184 | copyCodeMirror
185 | };
186 | export default copyCodeMirror;
187 |
--------------------------------------------------------------------------------
/gulpfile.babel.js:
--------------------------------------------------------------------------------
1 | import gulp from 'gulp';
2 | import path from 'path';
3 | import webpack from 'webpack';
4 | import BrowserSync from 'browser-sync';
5 | import webpackDevMiddleware from 'webpack-dev-middleware';
6 | import webpackHotMiddleware from 'webpack-hot-middleware';
7 | import VueLoaderPlugin from 'vue-loader/lib/plugin';
8 | import copyCodeMirror from './gulp-build-codemirror';
9 |
10 | // let uglify = uglifyES.default;
11 |
12 | // On 'webpack-hot-middleware/client', `?reload=true` tells client to reload if HMR fails.
13 | const devServer = [ 'webpack/hot/dev-server', 'webpack-hot-middleware/client?reload=true' ];
14 |
15 | let rules = [];
16 |
17 | rules.push({
18 | test: /\.vue$/,
19 | loader: 'vue-loader'
20 | });
21 |
22 | rules.push({
23 | test: /\.babel.js$/,
24 | exclude: /(node_modules|bower_components)/,
25 | use: {
26 | loader: 'babel-loader',
27 | options: {
28 | cacheDirectory: true
29 | }
30 | }
31 | });
32 |
33 | rules.push({
34 | test: /\.css$/,
35 | use: [
36 | 'vue-style-loader',
37 | 'css-loader'
38 | ]
39 | });
40 |
41 | rules.push({
42 | test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)$/,
43 | use: 'base64-inline-loader'
44 | });
45 |
46 | rules.push({
47 | test: /\.less$/,
48 | use: [
49 | 'vue-style-loader',
50 | 'css-loader',
51 | 'less-loader'
52 | ]
53 | });
54 |
55 | rules.push({
56 | test: /\.scss$/,
57 | use: [
58 | 'vue-style-loader',
59 | 'css-loader',
60 | 'sass-loader'
61 | ]
62 | });
63 |
64 | let config = {
65 | entry: {
66 | 'js/settings-page.min': [ './dist/js/settings-page.babel.js' ],
67 | 'js/global-page.min': [ './dist/js/global-page.babel.js' ],
68 | 'js/hoops-page.min': [ './dist/js/hoops-page.babel.js' ],
69 | 'js/meta-box.min': [ './dist/js/meta-box.babel.js' ],
70 | 'js/block.min': [ './dist/js/block.babel.js' ],
71 | 'js/sidebar.min': [ './dist/js/sidebar.babel.js' ],
72 | 'js/theme-page.min': [ './dist/js/theme-page.babel.js' ],
73 | 'js/rest.min': [ './dist/js/rest.babel.js' ]
74 | },
75 | output: {
76 | filename: '[name].js',
77 | path: path.resolve( __dirname, 'dist' ),
78 | publicPath: '/wp-content/plugins/scripts-n-styles'
79 | },
80 | context: path.resolve( __dirname ),
81 | module: {
82 | rules: rules
83 | },
84 | resolve: {
85 | extensions: [ '*', '.js', '.vue', '.json' ]
86 | },
87 | externals: {
88 | wpjquery: 'jQuery'
89 | },
90 | plugins: [
91 | new webpack.ProvidePlugin({
92 | $: 'jquery',
93 | jQuery: 'jquery',
94 | 'window.jQuery': 'wpjquery',
95 | 'window.$': 'wpjquery'
96 | }),
97 | new VueLoaderPlugin()
98 | ],
99 | mode: 'production'
100 | };
101 | let devConfig = {
102 | entry: {
103 | 'js/settings-page.min': [ ...devServer, './dist/js/settings-page.babel.js' ],
104 | 'js/global-page.min': [ ...devServer, './dist/js/global-page.babel.js' ],
105 | 'js/hoops-page.min': [ ...devServer, './dist/js/hoops-page.babel.js' ],
106 | 'js/meta-box.min': [ ...devServer, './dist/js/meta-box.babel.js' ],
107 | 'js/block.min': [ ...devServer, './dist/js/block.babel.js' ],
108 | 'js/sidebar.min': [ ...devServer, './dist/js/sidebar.babel.js' ],
109 | 'js/theme-page.min': [ ...devServer, './dist/js/theme-page.babel.js' ],
110 | 'js/rest.min': [ ...devServer, './dist/js/rest.babel.js' ]
111 | },
112 | output: config.output,
113 | context: config.context,
114 | externals: config.externals,
115 | resolve: config.resolve,
116 | module: config.module,
117 | mode: 'development',
118 | devtool: 'eval',
119 | plugins: [
120 | ...config.plugins,
121 | new webpack.HotModuleReplacementPlugin()
122 | ]
123 | };
124 |
125 | const server = BrowserSync.create();
126 | const compiler = webpack( config );
127 | const devCompiler = webpack( devConfig );
128 |
129 | function reload( done ) {
130 | server.reload();
131 | done();
132 | }
133 |
134 | function compile( done ) {
135 | compiler.run( done );
136 | }
137 |
138 | function serve( done ) {
139 | server.init({
140 |
141 | proxy: 'https://scriptsnstyles.test',
142 | host: 'scriptsnstyles.test',
143 | open: 'external',
144 | https: {
145 | key: './ssl/localhost.key',
146 | cert: './ssl/localhost.crt'
147 | },
148 |
149 | middleware: [
150 | webpackDevMiddleware( devCompiler, {
151 | publicPath: devConfig.output.publicPath,
152 | stats: { colors: true }
153 | }),
154 | webpackHotMiddleware( devCompiler )
155 | ]
156 | }, done );
157 | }
158 |
159 | function watch( done ) {
160 | gulp.watch([ 'dist/**/*.php' ], reload );
161 | done();
162 | }
163 |
164 | const build = gulp.series( compile );
165 | const buildFull = gulp.series( copyCodeMirror, build );
166 | const dev = gulp.series( build, serve, watch );
167 |
168 | export {
169 | watch,
170 | copyCodeMirror,
171 | compile,
172 | serve,
173 | reload,
174 | dev,
175 | build,
176 | buildFull
177 | };
178 | export default dev;
179 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "scripts-n-styles",
3 | "version": "4.0.0-alpha-2",
4 | "description": "Dev for the WP plugin",
5 | "author": "unFocus Projects",
6 | "license": "GPL-3.0",
7 | "homepage": "https://wordpress.org/plugins/scripts-n-styles/",
8 | "scripts": {
9 | "docker-clean": "docker-compose down -v --remove-orphans",
10 | "cleanup": "brew cleanup && brew prune ; npm cache verify ; docker system prune",
11 | "bash": "docker-compose run wordpress /bin/bash",
12 | "savedb": "npm start && docker-compose exec mysql sh -c 'exec mysqldump wordpress -uroot -p\"$MYSQL_ROOT_PASSWORD\"' > ./initdb/data.sql",
13 | "wp": "npm start && docker run -it --rm --volumes-from wordpress --network container:wordpress wordpress:cli",
14 | "update": "brew update && brew upgrade ; npm update -g && npm update ; composer self-update && composer update ; docker-compose pull",
15 | "docker-save-down": "npm run savedb && docker-compose down",
16 | "start": "./bin/docker-ready.sh",
17 | "stop": "docker-compose down",
18 | "gulp": "gulp",
19 | "build": "npm run gulp build",
20 | "dev": "npm start && npm run gulp dev",
21 | "preinstall": "npm run add-localhost && npm run add-ssl",
22 | "postinstall": "npm start && docker-compose down && composer install",
23 | "add-localhost": "URL=scriptsnstyles.test ; grep -qxF \"127.0.0.1\t${URL}\" /etc/hosts && echo 'host record already exists' || ( echo \"127.0.0.1\t$URL\n\" | sudo tee -a /etc/hosts > /dev/null && echo 'host record added' )",
24 | "add-ssl": "./bin/ssl.sh",
25 | "remove-ca": "npm run remove-ca:remove-trust-cert && rm -R ~/.localssl",
26 | "remove-ca:remove-trust-cert": "security find-certificate -c 'Localhost SSL' -a -Z | sudo awk '/SHA-1/{system(\"security delete-certificate -Z \"$NF)}'"
27 | },
28 | "private": true,
29 | "repository": {
30 | "type": "git",
31 | "url": "git+https://github.com/unFocus/Scripts-n-Styles.git"
32 | },
33 | "bugs": {
34 | "url": "https://github.com/unFocus/Scripts-n-Styles/issues"
35 | },
36 | "browserslist": [
37 | "extends @wordpress/browserslist-config"
38 | ],
39 | "babel": {
40 | "presets": [
41 | [
42 | "@babel/preset-env",
43 | {
44 | "useBuiltIns": "usage",
45 | "corejs": 3
46 | }
47 | ]
48 | ],
49 | "plugins": [
50 | "@babel/plugin-transform-runtime",
51 | "transform-vue-jsx"
52 | ]
53 | },
54 | "postcss": {
55 | "plugins": {
56 | "autoprefixer": true,
57 | "cssnano": true
58 | }
59 | },
60 | "eslintConfig": {
61 | "parser": "babel-eslint",
62 | "extends": "wordpress",
63 | "root": true,
64 | "parserOptions": {
65 | "ecmaVersion": 6,
66 | "sourceType": "module",
67 | "ecmaFeatures": {
68 | "jsx": true
69 | }
70 | }
71 | },
72 | "eslintIgnore": [
73 | "**/*.min.js",
74 | "node_modules/*",
75 | "bower_components/*",
76 | "vendor/*",
77 | "dist/codemirror/*",
78 | "dist/legacy/*",
79 | "html/*"
80 | ],
81 | "stylelint": {
82 | "extends": "stylelint-config-wordpress",
83 | "ignoreFiles": [
84 | "dist/css/*.css",
85 | "**/*.md"
86 | ]
87 | },
88 | "dependencies": {
89 | "@babel/polyfill": "^7.10.4",
90 | "@babel/runtime": "^7.10.5",
91 | "chosen-js": "^1.8.7",
92 | "clean-css": "^4.2.3",
93 | "codemirror": "^5.56.0",
94 | "coffeescript": "^2.5.1",
95 | "core-js": "^3.6.5",
96 | "glob": "^7.1.6",
97 | "jquery": "^3.5.1",
98 | "register-service-worker": "^1.7.1",
99 | "vue": "^2.6.11",
100 | "vue-class-component": "^7.2.4",
101 | "vue-property-decorator": "^9.0.0",
102 | "vue-router": "^3.3.4",
103 | "vuex": "^3.5.1"
104 | },
105 | "devDependencies": {
106 | "@babel/core": "^7.10.5",
107 | "@babel/plugin-transform-runtime": "^7.10.5",
108 | "@babel/preset-env": "^7.10.4",
109 | "@babel/register": "^7.10.5",
110 | "@wordpress/browserslist-config": "^2.7.0",
111 | "autoprefixer": "^9.8.5",
112 | "babel-eslint": "^10.1.0",
113 | "babel-helper-vue-jsx-merge-props": "^2.0.3",
114 | "babel-loader": "^8.1.0",
115 | "babel-plugin-syntax-jsx": "^6.18.0",
116 | "babel-plugin-transform-vue-jsx": "^3.7.0",
117 | "babel-preset-env": "^1.7.0",
118 | "base64-inline-loader": "^1.1.1",
119 | "browser-sync": "^2.26.10",
120 | "css-loader": "^3.6.0",
121 | "cssnano": "^4.1.10",
122 | "cssnano-preset-default": "^4.0.7",
123 | "eslint": "^7.5.0",
124 | "eslint-config-wordpress": "^2.0.0",
125 | "file-loader": "^6.0.0",
126 | "gulp": "^4.0.2",
127 | "gulp-concat": "^2.6.1",
128 | "gulp-footer": "^2.0.2",
129 | "gulp-header": "^2.0.9",
130 | "gulp-less": "^4.0.1",
131 | "gulp-postcss": "^8.0.0",
132 | "gulp-sass": "^4.1.0",
133 | "gulp-sourcemaps": "^2.6.5",
134 | "gulp-uglify-es": "^2.0.0",
135 | "imports-loader": "^1.1.0",
136 | "less": "^3.12.2",
137 | "less-loader": "^6.2.0",
138 | "node-sass": "^4.14.1",
139 | "postcss": "^7.0.32",
140 | "postcss-loader": "^3.0.0",
141 | "sass-loader": "^9.0.2",
142 | "script-loader": "^0.7.2",
143 | "style-loader": "^1.2.1",
144 | "stylelint": "^13.6.1",
145 | "stylelint-config-wordpress": "^17.0.0",
146 | "stylelint-csstree-validator": "^1.8.0",
147 | "typescript": "^3.9.7",
148 | "url-loader": "^4.1.0",
149 | "vue-loader": "^15.9.3",
150 | "vue-style-loader": "^4.1.2",
151 | "vue-template-compiler": "^2.6.11",
152 | "webpack": "^4.43.0",
153 | "webpack-dev-middleware": "^3.7.2",
154 | "webpack-hot-middleware": "^2.25.0"
155 | },
156 | "keywords": [
157 | "scripts-n-styles",
158 | "wordpress",
159 | "codemirror"
160 | ]
161 | }
162 |
--------------------------------------------------------------------------------
/phpcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | ./dist
11 | */bin/*
12 | ./html/*
13 | ./initdb/*
14 | */node_modules/*
15 | ./ssl/*
16 | */vendor/*
17 | ./svn/*
18 | */\.git/*
19 |
20 |
21 |
22 |
23 |
24 | */dist/theme/*\.php
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Dev Server commands
2 | The dev server is basically the generic docker images for WordPress, but with things that got in the way ripped out, so that we can tweak wp-config.php constants if we wish. :-/ It should've been easier.
3 |
4 | ## Start
5 | `docker-compose up` or `docker-compose up -d`
6 | Builds and starts your services.
7 |
8 | ## Stop
9 | docker-compose stop
10 | Stops the services without removing them. Leaves it in the current state to continue working later.
11 |
12 | ## Backup
13 | `docker exec sns-db sh -c 'exec mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > ./dbinit/data.sql`
14 | Calls into the `sns-db` container and makes a sql dump into the dbinit folder (for a fresh pre-population on next up).
15 |
16 | You can make a new backup and use it as `mkdir -p foo && docker exec sns-db sh -c 'exec mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > ./foo/data.sql && USEDB=foo`
17 | (Change the .env file variable to make it persistently use it.)
18 |
19 | ## Clean up
20 | `docker-compose down`
21 | Removes most things, but not the data volume (countinue from that data next time).
22 | `docker-compose down -v --remove-orphans`
23 | Removes all (well, most of at least) the things, including the database. (The generic source images remain.) Use this to reset the database to the 'dbinit' backup.
24 |
25 | ## Change PHP versions
26 | `export PHPV=7.1 && docker-compose up --build`
27 | Choices are `5.6`, `7.0`, `7.1`
28 |
29 | ### Bash in the container
30 | `docker-compose run wordpress /bin/bash`
31 |
32 | Use `alias wp='docker-compose exec --user www-data wordpress wp --url=localhost'` to set up a temporary shortcut for using wp-cli in the container.
--------------------------------------------------------------------------------
/ssl/000-default.conf:
--------------------------------------------------------------------------------
1 |
2 | ServerAdmin webmaster@localhost
3 | DocumentRoot /var/www/html
4 | ErrorLog ${APACHE_LOG_DIR}/error.log
5 | CustomLog ${APACHE_LOG_DIR}/access.log combined
6 |
7 |
8 | ServerAdmin webmaster@localhost
9 | DocumentRoot /var/www/html
10 | ErrorLog ${APACHE_LOG_DIR}/error.log
11 | CustomLog ${APACHE_LOG_DIR}/access.log combined
12 | SSLEngine on
13 | SSLCertificateFile /etc/apache2/ssl/localhost.crt
14 | SSLCertificateKeyFile /etc/apache2/ssl/localhost.key
15 |
16 | SSLOptions +StdEnvVars
17 |
18 |
19 | SSLOptions +StdEnvVars
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ssl/ca-opts.conf:
--------------------------------------------------------------------------------
1 | [req]
2 | prompt = no
3 | distinguished_name = req_distinguished_name
4 |
5 | [req_distinguished_name]
6 | C = US
7 | CN = Localhost SSL
8 |
--------------------------------------------------------------------------------
/ssl/localhost.ext:
--------------------------------------------------------------------------------
1 | authorityKeyIdentifier=keyid,issuer
2 | basicConstraints=CA:FALSE
3 | keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
4 | extendedKeyUsage = serverAuth, clientAuth, codeSigning, emailProtection
5 | subjectAltName = @alt_names
6 |
7 | [alt_names]
8 | # Local hosts
9 | DNS.1 = localhost
10 | DNS.2 = 127.0.0.1
11 | DNS.3 = ::1
12 |
13 | # List your domain names here
14 | DNS.4 = scriptsnstyles.test
15 | DNS.5 = *.scriptsnstyles.test
16 |
--------------------------------------------------------------------------------
/ssl/ssl.load:
--------------------------------------------------------------------------------
1 | # Depends: setenvif mime socache_shmcb
2 | LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
3 |
--------------------------------------------------------------------------------
/test-version-override.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/uploads.ini:
--------------------------------------------------------------------------------
1 | ; More Memory
2 | memory_limit = 256M
3 |
4 | ; Must be smaller than memory_limit, larger than upload_max_filesize
5 | post_max_size = 64M
6 |
7 | ; default is 2M
8 | upload_max_filesize = 32M
9 |
10 | ; default is 1000
11 | max_input_vars = 1800
12 |
13 | ; Bigger uploads need more time.
14 |
15 | ; 4 times the default of 30, adjust as needed.
16 | max_execution_time = 120
17 |
18 | ; -1 Falls back to max_execution_time
19 | max_input_time = -1
20 |
--------------------------------------------------------------------------------