Version Description
- New: Insert Headers and Footers is now WPCode - We make it easy for you to add code snippets in WordPress without having to edit your themes functions.php file.
- New: Full Code Snippets Library - WordPress code snippets library right inside the WPCode plugin.
- New: WordPress code generators to help you quickly generate ready-to-use code using the latest WordPress coding standards and APIs.
- New: Conditional Logic for Code Snippets - Instead of learning the various WordPress conditional logic queries, you can use our beginner-friendly conditional logic user interface.
- New: Auto-insert in various locations of your site or manual code output using shortcodes.
Download this release
Release Info
Developer | gripgrip |
Plugin | Insert Headers and Footers |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 2.0.0
- admin/images/mircea.png +0 -0
- admin/images/spinner.svg +6 -0
- admin/images/syed.png +0 -0
- admin/images/upgrade-welcome-cloud.jpg +0 -0
- admin/images/upgrade-welcome-generator.jpg +0 -0
- admin/images/upgrade-welcome-headers-footers.jpg +0 -0
- admin/images/wpcode-logo.png +0 -0
- assets/js/admin/notice.js +0 -89
- assets/js/admin/notice.min.js +0 -2
- build/admin.asset.php +1 -0
- build/admin.css +4 -0
- build/admin.js +1 -0
- ihaf.php +203 -218
- inc/admin/class-review.php +0 -245
- includes/admin/admin-ajax-handlers.php +185 -0
- includes/admin/admin-menu.php +71 -0
- includes/admin/admin-scripts.php +67 -0
- includes/admin/class-wpcode-docs.php +177 -0
- includes/admin/class-wpcode-importers.php +68 -0
- includes/admin/class-wpcode-notifications.php +496 -0
- includes/admin/class-wpcode-upgrade-welcome.php +314 -0
- includes/admin/importers/class-wpcode-importer-code-snippets.php +188 -0
- includes/admin/importers/class-wpcode-importer-type.php +98 -0
- includes/admin/importers/class-wpcode-importer-woody.php +163 -0
- includes/admin/pages/class-wpcode-admin-page-code-snippets.php +236 -0
- includes/admin/pages/class-wpcode-admin-page-generator.php +223 -0
- includes/admin/pages/class-wpcode-admin-page-headers-footers.php +285 -0
- includes/admin/pages/class-wpcode-admin-page-library.php +137 -0
- includes/admin/pages/class-wpcode-admin-page-settings.php +146 -0
- includes/admin/pages/class-wpcode-admin-page-snippet-manager.php +1067 -0
- includes/admin/pages/class-wpcode-admin-page-tools.php +938 -0
- includes/admin/pages/class-wpcode-admin-page.php +930 -0
- includes/admin/pages/class-wpcode-code-snippets-table.php +730 -0
- includes/auto-insert/class-wpcode-auto-insert-archive.php +139 -0
- includes/auto-insert/class-wpcode-auto-insert-everywhere.php +60 -0
- includes/auto-insert/class-wpcode-auto-insert-single.php +222 -0
- includes/auto-insert/class-wpcode-auto-insert-site-wide.php +73 -0
- includes/auto-insert/class-wpcode-auto-insert-type.php +327 -0
- includes/class-wpcode-auto-insert.php +85 -0
- includes/class-wpcode-capabilities.php +58 -0
- includes/class-wpcode-conditional-logic.php +152 -0
- includes/class-wpcode-error.php +76 -0
- includes/class-wpcode-file-cache.php +140 -0
- includes/class-wpcode-generator.php +143 -0
- includes/class-wpcode-install.php +111 -0
- includes/class-wpcode-library.php +333 -0
- includes/class-wpcode-settings.php +117 -0
- includes/class-wpcode-snippet-cache.php +115 -0
- includes/class-wpcode-snippet-execute.php +397 -0
- includes/class-wpcode-snippet.php +688 -0
- includes/conditional-logic/class-wpcode-conditional-page.php +270 -0
- includes/conditional-logic/class-wpcode-conditional-type.php +219 -0
- includes/conditional-logic/class-wpcode-conditional-user.php +88 -0
- includes/execute/class-wpcode-snippet-execute-html.php +30 -0
- includes/execute/class-wpcode-snippet-execute-js.php +35 -0
- includes/execute/class-wpcode-snippet-execute-php.php +30 -0
- includes/execute/class-wpcode-snippet-execute-text.php +33 -0
- includes/execute/class-wpcode-snippet-execute-type.php +79 -0
- includes/execute/class-wpcode-snippet-execute-universal.php +34 -0
- includes/generator/class-wpcode-generator-admin-bar.php +260 -0
- includes/generator/class-wpcode-generator-contact-methods.php +191 -0
- includes/generator/class-wpcode-generator-cronjob.php +237 -0
- includes/generator/class-wpcode-generator-hooks.php +1426 -0
- includes/generator/class-wpcode-generator-menu.php +192 -0
- includes/generator/class-wpcode-generator-post-status.php +231 -0
- includes/generator/class-wpcode-generator-post-type.php +898 -0
- includes/generator/class-wpcode-generator-query.php +745 -0
- includes/generator/class-wpcode-generator-script.php +298 -0
- includes/generator/class-wpcode-generator-sidebar.php +264 -0
- includes/generator/class-wpcode-generator-style.php +300 -0
- includes/generator/class-wpcode-generator-taxonomy.php +624 -0
- includes/generator/class-wpcode-generator-type.php +781 -0
- includes/generator/class-wpcode-generator-widget.php +572 -0
- includes/global-output.php +74 -0
- includes/helpers.php +27 -0
- includes/icons.php +130 -0
- includes/legacy.php +42 -0
- includes/post-type.php +75 -0
- includes/safe-mode.php +130 -0
- includes/shortcode.php +30 -0
- languages/index.php +4 -0
- languages/insert-headers-and-footers.pot +3551 -0
- readme.txt +243 -49
- uninstall.php +25 -0
- views/dashboard-notices.php +0 -29
- views/settings.php +0 -84
- views/sidebar.php +0 -121
admin/images/mircea.png
ADDED
Binary file
|
admin/images/spinner.svg
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80">
|
2 |
+
<path d="M40 0C17.9 0 0 17.9 0 40s17.9 40 40 40 40-17.9 40-40S62.1 0 40 0zm0 72C22.3 72 8 57.7 8 40S22.3 8 40 8s32 14.3 32 32-14.3 32-32 32z"
|
3 |
+
opacity=".15"/>
|
4 |
+
<path fill="#3568B7"
|
5 |
+
d="M75.8 47.4h-.4c-2.2-.2-3.8-2.2-3.6-4.4.1-1 .1-2 .1-3C72 22.4 57.6 8 40 8c-2.2 0-4-1.8-4-4s1.8-4 4-4c22.1 0 40 17.9 40 40 0 1.3-.1 2.5-.2 3.8-.2 2.1-1.9 3.6-4 3.6z"/>
|
6 |
+
</svg>
|
admin/images/syed.png
ADDED
Binary file
|
admin/images/upgrade-welcome-cloud.jpg
ADDED
Binary file
|
admin/images/upgrade-welcome-generator.jpg
ADDED
Binary file
|
admin/images/upgrade-welcome-headers-footers.jpg
ADDED
Binary file
|
admin/images/wpcode-logo.png
ADDED
Binary file
|
assets/js/admin/notice.js
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
/* global ihaf_admin_notices */
|
2 |
-
|
3 |
-
/**
|
4 |
-
* IHAF Dismissible Notices.
|
5 |
-
*
|
6 |
-
* @since 1.6.1
|
7 |
-
*/
|
8 |
-
|
9 |
-
'use strict';
|
10 |
-
|
11 |
-
var IHAFAdminNotices = window.IHAFAdminNotices || (
|
12 |
-
function ( document, window, $ ) {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Public functions and properties.
|
16 |
-
*
|
17 |
-
* @since 1.6.1
|
18 |
-
*
|
19 |
-
* @type {object}
|
20 |
-
*/
|
21 |
-
var app = {
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Start the engine.
|
25 |
-
*
|
26 |
-
* @since 1.6.1
|
27 |
-
*/
|
28 |
-
init: function () {
|
29 |
-
|
30 |
-
$( app.ready );
|
31 |
-
},
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Document ready.
|
35 |
-
*
|
36 |
-
* @since 1.6.1
|
37 |
-
*/
|
38 |
-
ready: function () {
|
39 |
-
|
40 |
-
app.events();
|
41 |
-
},
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Dismissible notices events.
|
45 |
-
*
|
46 |
-
* @since 1.6.1
|
47 |
-
*/
|
48 |
-
events: function () {
|
49 |
-
|
50 |
-
$( document ).on(
|
51 |
-
'click',
|
52 |
-
'.ihaf-notice .notice-dismiss, .ihaf-notice .ihaf-notice-dismiss',
|
53 |
-
app.dismissNotice
|
54 |
-
);
|
55 |
-
},
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Dismiss notice event handler.
|
59 |
-
*
|
60 |
-
* @since 1.6.1
|
61 |
-
*
|
62 |
-
* @param {object} e Event object.
|
63 |
-
* */
|
64 |
-
dismissNotice: function ( e ) {
|
65 |
-
$.post(
|
66 |
-
ihaf_admin_notices.ajax_url,
|
67 |
-
{
|
68 |
-
action: 'ihaf_notice_dismiss',
|
69 |
-
nonce: ihaf_admin_notices.nonce,
|
70 |
-
}
|
71 |
-
);
|
72 |
-
|
73 |
-
var $el = $( e.target ).closest( '.ihaf-notice' );
|
74 |
-
// Do the same animation as the core one.
|
75 |
-
$el.fadeTo( 100, 0, function() {
|
76 |
-
$el.slideUp( 100, function() {
|
77 |
-
$el.remove();
|
78 |
-
} );
|
79 |
-
} );
|
80 |
-
},
|
81 |
-
};
|
82 |
-
|
83 |
-
return app;
|
84 |
-
|
85 |
-
}( document, window, jQuery )
|
86 |
-
);
|
87 |
-
|
88 |
-
// Initialize.
|
89 |
-
IHAFAdminNotices.init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/js/admin/notice.min.js
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
"use strict";var IHAFAdminNotices=window.IHAFAdminNotices||function(document,window,$){var app={init:function(){$(app.ready)},ready:function(){app.events()},events:function(){$(document).on("click",".ihaf-notice .notice-dismiss, .ihaf-notice .ihaf-notice-dismiss",app.dismissNotice)},dismissNotice:function(e){$.post(ihaf_admin_notices.ajax_url,{action:"ihaf_notice_dismiss",nonce:ihaf_admin_notices.nonce});var $el=$(e.target).closest(".ihaf-notice");$el.fadeTo(100,0,function(){$el.slideUp(100,function(){$el.remove()})})}};return app}(document,window,jQuery);IHAFAdminNotices.init();
|
2 |
-
//# sourceMappingURL=notice.min.js.map
|
|
|
|
build/admin.asset.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php return array('dependencies' => array('jquery'), 'version' => '4f196d35772fea72d2e6ea87bd5491b5');
|
build/admin.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
:root{--wpcode-background-gray:#F8F8F8;--wpcode-background-highlight:#F6FAFF;--wpcode-background-light:#F3F4F5;--wpcode-background-red:#DF2A35;--wpcode-background-white:#fff;--wpcode-border-color:#ddd;--wpcode-button-disabled-bg:#F5F5F5;--wpcode-button-disabled-border:1px solid #DDDDDD;--wpcode-button-disabled-text:#bbb;--wpcode-button-primary-bg:var(--wpcode-color-primary);--wpcode-button-primary-bg-hover:#397EEB;--wpcode-button-primary-text:#fff;--wpcode-button-primary-text-hover:#fff;--wpcode-button-secondary-bg:#F8F8F8;--wpcode-button-secondary-bg-hover:#fff;--wpcode-button-secondary-border:1px solid #DDDDDD;--wpcode-button-secondary-text:#777;--wpcode-button-secondary-text-hover:#454545;--wpcode-color-primary:#3568B7;--wpcode-color-red:#DF2A35;--wpcode-color-red-darker:#AB2028;--wpcode-font-size-l:18px;--wpcode-font-size-m:16px;--wpcode-font-size-s:14px;--wpcode-font-size-xl:22px;--wpcode-font-size-xs:12px;--wpcode-font-size-xxl:24px;--wpcode-input-border:1px solid #DDD;--wpcode-input-border-active:#3568B7;--wpcode-input-text-color:#454545;--wpcode-notice-success-bg:#09A347;--wpcode-notice-success-text:#fff;--wpcode-space-h:36px;--wpcode-space-v:24px;--wpcode-text-color-heading:#454545;--wpcode-text-color-highlight:#3568B7;--wpcode-text-color-light-bg:#848A8A;--wpcode-text-color-paragraph:#777777;--wpcode-text-color-placeholder:#bbb}.wpcode-button{background-color:var(--wpcode-button-primary-bg);border:1px solid var(--wpcode-button-primary-bg);border-radius:4px;color:var(--wpcode-button-primary-text);cursor:pointer;display:inline-block;font-size:var(--wpcode-font-size-s);font-weight:700;line-height:1;padding:10px 16px;text-decoration:none}.wpcode-button.wpcode-button-icon{align-items:center;display:inline-flex;padding-bottom:12px;padding-top:12px}.wpcode-button.wpcode-button-icon svg{margin-right:5px}.wpcode-button.wpcode-button-icon.wpcode-copy-target{padding-bottom:10px;padding-top:10px}.wpcode-button.wpcode-button-wide{padding-left:50px;padding-right:50px}.wpcode-button:hover,.wpcode-button:focus{background-color:var(--wpcode-button-primary-bg-hover);border-color:var(--wpcode-button-primary-bg-hover);color:var(--wpcode-button-primary-text-hover)}.wpcode-button.wpcode-button-secondary{background-color:var(--wpcode-button-secondary-bg);border:var(--wpcode-button-secondary-border);color:var(--wpcode-button-secondary-text)}.wpcode-button.wpcode-button-secondary:hover,.wpcode-button.wpcode-button-secondary:focus{background-color:var(--wpcode-button-secondary-bg-hover);color:var(--wpcode-button-secondary-text-hover)}.wpcode-button.wpcode-button-secondary.wpcode-button-secondary-inactive{background-color:var(--wpcode-button-disabled-bg);border-color:var(--wpcode-button-disabled-bg)}.wpcode-button.wpcode-button-secondary.wpcode-button-secondary-selected{border-color:var(--wpcode-button-primary-bg)}.wpcode-button.wpcode-button-large{align-items:center;display:inline-flex;font-size:var(--wpcode-font-size-m);height:56px;justify-content:center;padding-left:var(--wpcode-space-h);padding-right:var(--wpcode-space-h);text-align:center}.wpcode-button.wpcode-button-large svg{margin-right:7px}.wpcode-button.wpcode-button-small{font-size:var(--wpcode-font-size-xs);padding:9px}.wpcode-button:disabled:hover,.wpcode-button:disabled{background-color:var(--wpcode-button-disabled-bg);border:var(--wpcode-button-disabled-border);color:var(--wpcode-button-disabled-text)}.wpcode-button-toggle{align-items:center;display:flex;justify-content:space-between;min-width:424px}.wpcode-button-toggle .wpcode-button{width:calc(50% - 5px);background:#fff;color:var(--wpcode-input-text-color)}.wpcode-button-toggle .wpcode-button-secondary{border:2px solid var(--wpcode-color-primary)}.wpcode-success-icon{display:none}.wpcode-show-success-icon .wpcode-success-icon{display:inline-block}.wpcode-show-success-icon .wpcode-default-icon{display:none}.wpcode-button-just-icon{background:none;border:none;cursor:pointer;padding:0}.wpcode-button-just-icon .wpcode-icon{display:block}.wpcode-text-button-icon{align-items:center;background:none;border:none;color:var(--wpcode-text-color-paragraph);cursor:pointer;display:inline-flex;font-size:var(--wpcode-font-size-s);font-weight:600;padding:0}.wpcode-text-button-icon:hover{color:var(--wpcode-text-color-heading)}.wpcode-text-button-icon:hover path{fill:var(--wpcode-text-color-heading)}.wpcode-text-button-icon .wpcode-icon{margin-right:5px}.wpcode-just-icon-button{background:none;border:none;cursor:pointer}.wpcode-button-text{background:none;border:none;color:var(--wpcode-text-color-paragraph);cursor:pointer;font-size:var(--wpcode-font-size-xs);padding:0;text-decoration:underline}.wpcode-button-text:hover{text-decoration:none}.wpcode-headers-footers #wpcontent,.wpcode-admin-page #wpcontent{padding-left:0 !important}.wpcode-headers-footers #wpwrap,.wpcode-admin-page #wpwrap{background:var(--wpcode-background-light)}.wpcode-header-top{align-items:center;background:var(--wpcode-background-gray);display:flex;justify-content:space-between;padding:var(--wpcode-space-v) var(--wpcode-space-h)}.wpcode-header-right button{margin-left:18px;vertical-align:middle}.wpcode-header-bottom{align-items:center;background:var(--wpcode-background-white);border-color:var(--wpcode-border-color);border-style:solid;border-width:1px 0;display:flex;justify-content:space-between;min-height:60px;padding:0 var(--wpcode-space-h)}.wpcode-header-bottom h1{color:var(--wpcode-text-color-heading);font-size:var(--wpcode-font-size-xl);margin:0}.wpcode-header-bottom.wpcode-sticky{left:160px;position:fixed;right:0;top:32px;z-index:100}.folded .wpcode-header-bottom.wpcode-sticky{left:36px}.wpcode-column{align-items:center;display:flex;flex-flow:row}.wpcode-column .wpcode-button{margin-left:20px}#wpcode-header-logo{display:block}.wpcode-admin-tabs{font-size:14px;list-style:none;margin:0;overflow:auto;padding:0}.wpcode-admin-tabs li{float:left;margin:0 30px 0 0;padding:0}.wpcode-admin-tabs li a{border-bottom:4px solid #fff;box-shadow:none;color:var(--wpcode-text-color-paragraph);display:block;font-weight:600;padding:20px 0 18px 0;text-decoration:none;transition:border 300ms ease}.wpcode-admin-tabs li a.active{border-color:var(--wpcode-color-primary);color:var(--wpcode-text-color-heading)}.wpcode-admin-tabs li a:focus,.wpcode-admin-tabs li a:hover{border-color:var(--wpcode-text-color-paragraph)}.wpcode-notifications-inbox{position:relative}.wpcode-notifications-inbox[data-count]:after{background:var(--wpcode-color-red);border-radius:50%;bottom:100%;color:#fff;content:attr(data-count);display:block;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12px;font-weight:700;height:16px;left:100%;line-height:18px;min-width:16px;position:absolute;text-align:center;transform:translate(-50%,50%)}.wpcode-content{padding:28px var(--wpcode-space-h)}.wpcode-content *{box-sizing:border-box}.wpcode-content h2{color:var(--wpcode-text-color-heading);font-size:var(--wpcode-font-size-l)}.wpcode-content p{color:var(--wpcode-text-color-paragraph);font-size:var(--wpcode-font-size-s)}.wpcode-add-snippet .wpcode-content{padding-top:20px}.wpcode-content>hr{margin-bottom:36px;margin-top:36px}.wpcode-code-textarea{margin-bottom:var(--wpcode-space-h)}.wpcode-code-textarea h2{margin:12px 0 20px}.wrap{margin:0;padding:0 var(--wpcode-space-h)}.wrap div.error,.wrap div.updated{margin-bottom:0;position:relative}.wrap div:first-child{margin-top:28px}#wpfooter{padding-left:var(--wpcode-space-h);padding-right:var(--wpcode-space-h)}.wpcode-modal-overlay{background:rgba(0,0,0,0.3);bottom:0;display:none;left:0;position:fixed;right:0;top:0;z-index:1000}.admin-bar .wpcode-modal-overlay{top:32px}.wpcode-show-modal .wpcode-modal-overlay{display:block}.wpcode-modal{background:#fff;border:1px solid var(--wpcode-border-color);border-radius:8px;display:none;left:50%;max-width:100%;padding:25px;position:fixed;top:50%;transform:translate(-50%,-50%);width:752px;z-index:1050}.wpcode-show-modal .wpcode-modal{display:block}@media screen and (min-width:783px){.wpcode-modal{margin-left:18px}}@media screen and (min-width:961px){.wpcode-modal{margin-left:80px}.folded .wpcode-modal{margin-left:18px}}.wpcode-content .CodeMirror{border:1px solid var(--wpcode-border-color);border-radius:3px;font-size:var(--wpcode-font-size-s);line-height:25px}.wpcode-content .CodeMirror-linenumber{color:var(--wpcode-text-color-light-bg);font-size:var(--wpcode-font-size-xs)}.wpcode-content .CodeMirror-lines{padding:20px 0}.wpcode-content .CodeMirror-gutters{background-color:var(--wpcode-button-disabled-bg)}.CodeMirror-sizer:before{color:var(--wpcode-text-color-light-bg);position:absolute}[data-code-type="php"] .CodeMirror-sizer:before{content:"<?php"}[data-code-type="js"] .CodeMirror-sizer:before{content:"<script>"}.wpcode-input-title input.wpcode-input-text{font-size:var(--wpcode-font-size-m)}input.wpcode-input-number,input.wpcode-input-text{border:var(--wpcode-input-border);border-radius:4px;color:var(--wpcode-input-text-color);font-size:var(--wpcode-font-size-s);height:40px}input.wpcode-input-number:focus,input.wpcode-input-text:focus{border-color:var(--wpcode-input-border-active)}.wpcode-input-textarea{border:var(--wpcode-input-border);border-radius:4px;color:var(--wpcode-input-text-color);font-size:var(--wpcode-font-size-s);max-width:100%;resize:none;width:424px}.wpcode-input-select{align-items:center;display:flex}.wpcode-input-select label{color:var(--wpcode-text-color-heading);font-size:var(--wpcode-font-size-s);font-weight:600}.wpcode-input-select select{margin-left:13px}.wpcode-metabox-form-row-input{width:100%}.wpcode-metabox-form-row-input select{min-width:424px}.wpcode-inline-select select{min-width:98px}.wpcode-inline-select>span{color:var(--wpcode-text-color-paragraph);display:inline-block;font-size:13px;margin-left:12px}.wpcode-separator{border-color:var(--wpcode-border-color);border-style:solid;border-width:1px 0 0;margin:var(--wpcode-space-v) 0}.wpcode-checkbox-toggle{display:inline-block;height:20px;position:relative;width:36px}.wpcode-checkbox-toggle input{display:none;height:0;opacity:0;width:0}.wpcode-checkbox-toggle input:checked+.wpcode-checkbox-toggle-slider{background-color:var(--wpcode-color-primary)}.wpcode-checkbox-toggle input:checked+.wpcode-checkbox-toggle-slider:before{transform:translateX(16px)}.wpcode-checkbox-toggle input:focus+.wpcode-checkbox-toggle-slider{box-shadow:0 0 1px #2196F3}.wpcode-checkbox-toggle .wpcode-checkbox-toggle-slider{background-color:#ccc;border-radius:20px;bottom:0;cursor:pointer;left:0;position:absolute;right:0;top:0;transition:.4s}.wpcode-checkbox-toggle .wpcode-checkbox-toggle-slider:before{background-color:white;border-radius:50%;bottom:3px;content:"";height:14px;left:3px;position:absolute;transition:.4s;width:14px}.wpcode-input-with-button{display:flex;width:100%}.wpcode-input-with-button .wpcode-input-text{margin-right:10px;width:100%}.wpcode-snippet-manager.wp-core-ui select,.wpcode-tools.wp-core-ui select,.wpcode-generator.wp-core-ui select{background-position-x:calc(100% - 13px);border-color:var(--wpcode-border-color);border-radius:4px;color:var(--wpcode-text-color-heading);line-height:38px;min-height:40px;padding-left:12px;padding-right:32px}.wpcode-metabox .select2-container .select2-search--inline{margin:0}.wpcode-metabox .select2-container .select2-search--inline .select2-search__field{color:var(--wpcode-text-color-heading);font-size:14px;margin:5px 5px 0}.wpcode-metabox .select2-container.select2-container--default .select2-selection--multiple{border-color:var(--wpcode-border-color)}.wpcode-metabox .select2-container.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:var(--wpcode-button-disabled-bg);border:none;border-radius:3px;color:var(--wpcode-text-color-heading);font-size:14px;margin:9px 8px 9px 0;padding:1px 4px}.wpcode-metabox .select2-container.select2-container--default .select2-selection--multiple .select2-selection__rendered{display:block;padding:0 8px}.wpcode-metabox .select2-container.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{margin-right:4px}.wpcode-admin-page .select2-dropdown{border-color:var(--wpcode-border-color);color:var(--wpcode-text-color-heading)}.wpcode-checkboxes-list label{display:block;margin-bottom:16px}.wpcode-checkboxes-list input{margin-right:12px}.wpcode-file-upload .wpcode-file-field{background-color:#fff;border:1px solid #ddd;border-radius:3px;box-shadow:none;color:var(--wpcode-text-color-paragraph);display:inline-block;margin:0 10px 0 0;min-height:40px;overflow:hidden;padding:10px 10px;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;width:400px}.wpcode-file-upload input[type=file]{height:0.1px;opacity:0;overflow:hidden;position:absolute;width:0.1px;z-index:-1}.wpcode-file-upload label{cursor:pointer;display:inline-flex;outline:none;padding:0;text-overflow:ellipsis;white-space:nowrap}.wpcode-checkbox-multiselect-columns{max-width:600px;position:relative}.wpcode-checkbox-multiselect-columns:after{clear:both;content:".";display:block;font-size:0;height:0;line-height:0;min-height:0;visibility:hidden}.wpcode-checkbox-multiselect-columns:before{background-image:url("data:image/svg+xml,%3Csvg width=%2718%27 height=%2714%27 viewBox=%270 0 18 14%27 fill=%27none%27 xmlns=%27http://www.w3.org/2000/svg%27%3E%3Cpath d=%27M3.99 6L0 10L3.99 14V11H11V9H3.99V6ZM18 4L14.01 0V3H7V5H14.01V8L18 4Z%27 fill=%27%23999%27/%3E%3C/svg%3E%0A");color:#999;content:"";display:block;height:14px;left:50%;margin:0 0 0 -10px;position:absolute;top:130px;width:18px}.wpcode-checkbox-multiselect-columns .header{font-size:13px;font-weight:600;margin:0;padding:0 0 5px 0;text-align:center}.wpcode-checkbox-multiselect-columns .first-column,.wpcode-checkbox-multiselect-columns .second-column{float:left;width:45%}.wpcode-checkbox-multiselect-columns .second-column{float:right}.wpcode-checkbox-multiselect-columns .second-column ul li{padding:10px}.wpcode-checkbox-multiselect-columns ul{background-color:#fff;border:1px solid #ddd;border-radius:3px;height:250px;list-style-type:none;margin:0;overflow-y:auto;padding:0;position:relative}.wpcode-checkbox-multiselect-columns ul li{border-bottom:1px #eee solid;color:var(--wpcode-text-color-paragraph);font-size:14px;margin:0}.wpcode-checkbox-multiselect-columns ul li label{display:block;padding:10px 10px 10px 32px;position:relative;vertical-align:baseline}.wpcode-checkbox-multiselect-columns ul li label:hover{background-color:var(--wpcode-color-primary);color:#fff}.wpcode-checkbox-multiselect-columns ul li label:before{color:#ddd;content:"\f0c8";font:normal normal normal 16px/1 Georgia;-webkit-font-smoothing:antialiased;left:10px;-moz-osx-font-smoothing:grayscale;position:absolute;text-rendering:auto;top:12px}.wpcode-checkbox-multiselect-columns ul li label.checked{color:rgba(119,119,119,0.6)}.wpcode-checkbox-multiselect-columns ul li label.checked:before{background-image:url("data:image/svg+xml,%3Csvg width=%2710%27 height=%278%27 viewBox=%270 0 10 8%27 fill=%27none%27 xmlns=%27http://www.w3.org/2000/svg%27%3E%3Cpath d=%27M1.38462 3.03448L0 4.13793L3.23077 8H4.46154L10 0.965517L8.76923 0L3.69231 4.96552L1.38462 3.03448Z%27 fill=%27%234982BF%27/%3E%3C/svg%3E%0A");background-position:3px 3px;background-repeat:no-repeat;background-size:10px 8px}.wpcode-checkbox-multiselect-columns ul li label input{display:none}.wpcode-checkbox-multiselect-columns .all{color:#999;display:inline-block;font-size:13px;margin:10px 0 0}.wpcode-flex{display:flex}.wpcode-code-textarea>.wpcode-flex{justify-content:space-between}.wpcode-input-title{margin-bottom:8px}.wpcode-status-text{color:var(--wpcode-text-color-paragraph);font-size:var(--wpcode-font-size-s);margin-right:8px;min-width:51px}#wp-wpcode_snippet_text-wrap{display:none}.wpcode-show-tinymce .wpcode-code-textarea .CodeMirror{display:none}.wpcode-show-tinymce #wp-wpcode_snippet_text-wrap{display:block}.wpcode-add-snippet-description{padding:var(--wpcode-space-v);background:#fff;border:1px solid var(--wpcode-border-color);border-bottom:0;border-radius:4px 4px 0 0;font-size:var(--wpcode-font-size-s);color:var(--wpcode-text-color-paragraph)}.wpcode-add-snippet-description a:hover{text-decoration:none}.wpcode-add-snippet-description+.wpcode-metabox{border-radius:0 0 4px 4px}.wpcode-metabox{background:var(--wpcode-background-white);border:1px solid var(--wpcode-border-color);border-radius:4px;margin-bottom:var(--wpcode-space-h)}.wpcode-metabox-title{align-items:center;border-bottom:1px solid var(--wpcode-border-color);display:flex;justify-content:space-between}.wpcode-metabox-title-text{color:var(--wpcode-text-color-heading);font-size:var(--wpcode-font-size-m);font-weight:600;padding:0 var(--wpcode-space-v)}.wpcode-metabox-button-toggle{background-color:var(--wpcode-background-white);border:none;cursor:pointer;height:60px;margin:0;text-align:center;width:60px}.wpcode-metabox-collapsed .wpcode-metabox-button-toggle svg{transform:rotate(180deg)}.wpcode-metabox-content{padding:var(--wpcode-space-v);padding-bottom:0}.wpcode-metabox-collapsed .wpcode-metabox-content{display:none}.wpcode-metabox-content p:first-child{margin-top:0}.wpcode-metabox-form{max-width:670px}.wpcode-metabox-form-row{display:flex;margin-bottom:var(--wpcode-space-v)}.wpcode-metabox-form-row-label{flex-shrink:0;width:245px}.wpcode-metabox-form-row-label label{color:var(--wpcode-text-color-heading);font-size:var(--wpcode-font-size-s);font-weight:600}.wp-list-table.wpcode-snippets .column-status{width:65px}@media screen and (min-width:783px){.wp-list-table.wpcode-snippets .column-status{text-align:center}}.wp-list-table.wpcode-snippets .column-name a{color:var(--wpcode-text-color-heading);font-size:14px;text-decoration:none}.wp-list-table.wpcode-snippets .column-name a:hover,.wp-list-table.wpcode-snippets .column-name a:focus{color:var(--wpcode-text-color-paragraph)}.wp-list-table.wpcode-snippets .column-name .delete a,.wp-list-table.wpcode-snippets .column-name .trash a{color:var(--wpcode-background-red)}.wp-list-table.wpcode-snippets .column-name .delete a:hover,.wp-list-table.wpcode-snippets .column-name .delete a:focus,.wp-list-table.wpcode-snippets .column-name .trash a:hover,.wp-list-table.wpcode-snippets .column-name .trash a:focus{color:var(--wpcode-color-red-darker)}.wp-list-table.wpcode-snippets .column-location a,.wp-list-table.wpcode-snippets .column-author a{color:var(--wpcode-text-color-paragraph)}.wp-list-table.wpcode-snippets .column-location a:hover,.wp-list-table.wpcode-snippets .column-location a:focus,.wp-list-table.wpcode-snippets .column-author a:hover,.wp-list-table.wpcode-snippets .column-author a:focus{color:var(--wpcode-text-color-heading)}.wp-list-table.wpcode-snippets th.column-created a{color:var(--wpcode-text-color-heading)}.wp-list-table.wpcode-snippets th.column-created a:hover,.wp-list-table.wpcode-snippets th.column-created a:focus{color:var(--wpcode-text-color-paragraph)}.wp-list-table.wpcode-snippets .column-created{color:var(--wpcode-text-color-paragraph)}.wp-list-table.wpcode-snippets td.column-tags{color:var(--wpcode-color-primary)}.wp-list-table.wpcode-snippets td.column-tags a{color:var(--wpcode-color-primary);text-decoration:underline}.wp-list-table.wpcode-snippets td.column-tags a:hover,.wp-list-table.wpcode-snippets td.column-tags a:focus{text-decoration:none}.wp-list-table.wpcode-snippets .alternate,.wp-list-table.wpcode-snippets.striped>tbody>:nth-child(odd),.wp-list-table.wpcode-snippets ul.striped>:nth-child(odd){background-color:var(--wpcode-background-gray)}.wpcode-admin-page.wpcode .tablenav.top{margin-bottom:16px}.wpcode-admin-page.wpcode .tablenav.bottom{margin-top:11px}.wpcode-admin-page.wpcode .wpcode-content a{}.wpcode-admin-page.wpcode .button{background:var(--wpcode-background-light);border-color:var(--wpcode-color-primary);color:var(--wpcode-color-primary)}.wpcode-cl-group{background:var(--wpcode-button-disabled-bg);border-radius:4px;margin-top:50px;padding:16px;position:relative}.wpcode-cl-group:first-child{margin-top:0}.wpcode-cl-group:first-child .wpcode-cl-group-or{display:none}#wpcode-conditions-holder{margin:16px 0;max-width:685px}.wpcode-cl-group-or{bottom:100%;height:50px;left:0;position:absolute;right:0}.wpcode-cl-group-or .wpcode-cl-group-or-line{background-color:var(--wpcode-button-disabled-bg);height:2px;left:0;position:absolute;right:0;top:50%}.wpcode-cl-group-or .wpcode-cl-group-or-text{background:#F5F5F5;border-radius:10px;color:var(--wpcode-text-color-heading);font-size:12px;font-weight:500;left:50%;padding:2px 9px;position:absolute;top:50%;transform:translate(-50%,-50%)}.wpcode-cl-rules-row{align-items:center;display:flex;justify-content:space-between;margin-bottom:8px}.wpcode-cl-rules-row .wpcode-cl-rules-row-options{align-items:flex-start;display:flex;max-width:653px}.wpcode-metabox-form-row-input .wpcode-cl-rules-row select{margin:0 16px 0 0;min-width:0;width:175px}.wpcode-metabox-form-row-input .wpcode-cl-rules-row select.wpcode-cl-rule-relation{width:130px}.wpcode-cl-rules-row .wpcode-cl-remove-row{flex-shrink:0}.wpcode-items-metabox{display:flex;padding:0}.wpcode-items-sidebar{flex-shrink:0;padding:var(--wpcode-space-v);width:242px}.wpcode-items-list{border-left:1px solid var(--wpcode-border-color);min-height:400px;padding:calc(var(--wpcode-space-v) / 2) 12px;width:100%}.wpcode-items-categories-list{margin:0}.wpcode-items-categories-list li{margin:0}.wpcode-items-categories-list button{background:transparent;border:none;color:var(--wpcode-text-color-paragraph);cursor:pointer;display:block;font-size:var(--wpcode-font-size-m);font-weight:500;padding:12px 8px;position:relative;text-align:left;width:100%}.wpcode-items-categories-list button:focus,.wpcode-items-categories-list button.wpcode-active{background:var(--wpcode-background-highlight);color:var(--wpcode-text-color-highlight)}.wpcode-items-categories-list button:hover{text-decoration:underline}.wpcode-items-categories-list button.wpcode-active{font-weight:700}.wpcode-items-categories-list button.wpcode-active:after{background-image:url("data:image/svg+xml,%3Csvg width=%2716%27 height=%2712%27 viewBox=%270 0 16 12%27 fill=%27none%27 xmlns=%27http://www.w3.org/2000/svg%27%3E%3Cpath d=%27M5.33329 9.25326L1.83329 5.75326L0.666626 6.91992L5.33329 11.5866L15.3333 1.58659L14.1666 0.419922L5.33329 9.25326Z%27 fill=%27%233568B7%27/%3E%3C/svg%3E%0A");content:'';height:12px;position:absolute;right:10px;top:50%;transform:translateY(-50%);width:16px}.wpcode-items-categories-list button.wpcode-active:hover{text-decoration:none}.wpcode-items-list-category{align-content:stretch;display:flex;flex-wrap:wrap;justify-content:flex-start}.wpcode-list-item{border:1px solid var(--wpcode-border-color);border-radius:4px;margin-bottom:24px;margin-right:12px;margin-left:12px;max-width:100%;padding:16px 20px;position:relative;width:100%}@media (min-width:961px){.wpcode-list-item{width:calc(50% - 24px)}}@media (min-width:1440px){.wpcode-list-item{width:calc(100% / 3 - 24px)}}.wpcode-list-item h3{font-size:var(--wpcode-font-size-m);line-height:1.2;margin:0;overflow:hidden;position:relative;text-overflow:ellipsis;white-space:nowrap}.wpcode-list-item p{margin-bottom:0}.wpcode-list-item:hover .wpcode-list-item-description,.wpcode-list-item:focus .wpcode-list-item-description{opacity:0}.wpcode-list-item:hover .wpcode-list-item-buttons,.wpcode-list-item:focus .wpcode-list-item-buttons{opacity:1}@media (hover:none){.wpcode-list-item .wpcode-list-item-description{opacity:0}.wpcode-list-item .wpcode-list-item-buttons{opacity:1}}.wpcode-list-item .wpcode-list-item-pill{position:absolute;top:10px;right:10px;font-size:8px;font-weight:700;text-transform:uppercase;line-height:1;padding:4px 8px;border-radius:40px}.wpcode-list-item .wpcode-list-item-pill.wpcode-list-item-pill-blue{background:var(--wpcode-color-primary);color:#fff}.wpcode-list-item.wpcode-list-item-has-pill h3{max-width:calc(100% - 60px)}.wpcode-list-item-actions{position:relative}.wpcode-list-item-description{min-height:40px}.wpcode-list-item-buttons{display:flex;justify-content:space-between;opacity:0;position:absolute;top:0;width:100%;z-index:10}.wpcode-list-item-buttons .wpcode-button{flex-grow:1;margin-left:10px;text-align:center}.wpcode-list-item-buttons .wpcode-button:first-child{margin-left:0}.wpcode-items-search{margin-bottom:20px;position:relative}.wpcode-items-search input{border-color:var(--wpcode-border-color);font-size:var(--wpcode-font-size-s);height:38px;padding-left:32px;width:100%}.wpcode-items-search input::-moz-placeholder{color:var(--wpcode-text-color-placeholder)}.wpcode-items-search input:-ms-input-placeholder{color:var(--wpcode-text-color-placeholder)}.wpcode-items-search input::placeholder{color:var(--wpcode-text-color-placeholder)}.wpcode-items-search label{left:10px;position:absolute;top:11px}.wpcode-library-preview-header{padding-bottom:25px}.wpcode-library-preview-header h2{margin:0}.wpcode-library-preview-header .wpcode-close-modal{float:right}.wpcode-library-preview-content .CodeMirror{background:var(--wpcode-background-gray)}.wpcode-library-preview-content .CodeMirror-activeline-background{background:transparent !important}.wpcode-library-preview-content .CodeMirror-focused .CodeMirror-activeline-background{background:rgba(100,100,100,0.1) !important}.wpcode-library-preview-buttons{margin-top:25px}.wpcode-generator .wpcode-items-metabox{margin-bottom:0}.wpcode-generator .wpcode-generator-preview .CodeMirror{height:auto}.wpcode-generator-preview{background-color:var(--wpcode-background-highlight);border-color:var(--wpcode-border-color);border-style:solid;border-width:0 1px 1px;padding:15px 28px 24px}.wpcode-generator-preview-header{align-items:center;display:flex;margin-bottom:14px}.wpcode-generator-preview-header h2{margin:0 8px 0 0}.wpcode-generator-preview-header .wpcode-button{margin-left:12px}.wpcode-form-tab:after{clear:both;content:'';display:table}.wpcode-generator-column{float:left;padding:14px 14px;width:calc(100% / 3)}.wpcode-generator-actions{padding:28px 14px 14px;text-align:center}.wpcode-generator-field{margin-bottom:24px}.wpcode-generator-field label{color:var(--wpcode-text-color-heading);display:block;font-size:var(--wpcode-font-size-s);font-weight:600;margin-bottom:8px}.wpcode-generator-field input[type="text"]{width:100%}.wpcode-generator-field select{max-width:100%;width:100%}.wpcode-field-description{margin-top:8px}.wpcode-generator-field-list ul{color:var(--wpcode-text-color-paragraph);font-size:var(--wpcode-font-size-s);list-style:disc;padding-left:18px}.wpcode-loading-spinner{-webkit-animation:wpcode-spinner-rotation 0.8s linear infinite;animation:wpcode-spinner-rotation 0.8s linear infinite;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4MCA4MCI+CiAgICA8cGF0aCBkPSJNNDAgMEMxNy45IDAgMCAxNy45IDAgNDBzMTcuOSA0MCA0MCA0MCA0MC0xNy45IDQwLTQwUzYyLjEgMCA0MCAwem0wIDcyQzIyLjMgNzIgOCA1Ny43IDggNDBTMjIuMyA4IDQwIDhzMzIgMTQuMyAzMiAzMi0xNC4zIDMyLTMyIDMyeiIKICAgICAgICAgIG9wYWNpdHk9Ii4xNSIvPgogICAgPHBhdGggZmlsbD0iIzM1NjhCNyIKICAgICAgICAgIGQ9Ik03NS44IDQ3LjRoLS40Yy0yLjItLjItMy44LTIuMi0zLjYtNC40LjEtMSAuMS0yIC4xLTNDNzIgMjIuNCA1Ny42IDggNDAgOGMtMi4yIDAtNC0xLjgtNC00czEuOC00IDQtNGMyMi4xIDAgNDAgMTcuOSA0MCA0MCAwIDEuMy0uMSAyLjUtLjIgMy44LS4yIDIuMS0xLjkgMy42LTQgMy42eiIvPgo8L3N2Zz4K);background-repeat:no-repeat;background-size:16px 16px;display:none;height:16px;margin:0 10px;position:absolute;width:16px;z-index:40}@-webkit-keyframes wpcode-spinner-rotation{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}@keyframes wpcode-spinner-rotation{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}.wpcode-checkbox-line{margin-bottom:14px}.wpcode-checkbox-line .wpcode-checkbox-toggle{margin-right:8px}.wpcode-checkbox-line label{display:inline-block}.wpcode-repeater-group{border-top:1px solid var(--wpcode-border-color);padding-top:24px}.wpcode-repeater-group .wpcode-remove-row{margin-bottom:24px}#wpcode-importer-process{display:none}#wpcode-importer-process .process-completed{display:none}#wpcode-importer-process .status{background-color:#fff;border:1px solid #ddd;border-radius:3px;display:none;margin:20px 0 30px;max-height:800px;overflow-y:scroll}#wpcode-importer-process .item{border-bottom:1px solid #ddd;padding:20px}#wpcode-importer-process .item:last-of-type{border:none}#wpcode-importer-process .item .name{float:left;font-size:14px}#wpcode-importer-process .item .name svg{display:inline-block;margin:0 10px 0 0}#wpcode-importer-process .item .actions{float:right;font-size:14px}.wpcode-clear:after{clear:both;content:" ";display:table}#wpcode-plugins-importer{margin-bottom:20px;max-width:100%;width:400px}.wpcode-tools .pre-error,.wpcode-tools .info-area{background:#fff;border:1px solid #ddd;box-shadow:none;display:block;font-family:Menlo,Monaco,monospace;font-size:12px;height:450px;max-width:1000px;overflow:auto;padding:20px;white-space:pre;width:100%}.wpcode-admin-page .wpcode-alert{border:1px solid transparent;margin-bottom:18px;padding:16px}.wpcode-admin-page .wpcode-alert h4{color:inherit;margin-top:0}.wpcode-admin-page .wpcode-alert p{margin:0 0 15px 0}.wpcode-admin-page .wpcode-alert p:last-of-type{margin:0}.wpcode-admin-page .wpcode-alert.wpcode-alert-nomargin{margin:0}.wpcode-admin-page .wpcode-alert.wpcode-alert-small{font-size:12px}.wpcode-admin-page .wpcode-alert.wpcode-alert-success{background-color:#dff0d8;border-color:#d6e9c6;color:#3c763d}.wpcode-admin-page .wpcode-alert.wpcode-alert-info{background-color:#d9edf7;border-color:#bce8f1;color:#31708f}.wpcode-admin-page .wpcode-alert.wpcode-alert-warning{background-color:#fcf8e3;border-color:#faebcc;color:#8a6d3b}.wpcode-admin-page .wpcode-alert.wpcode-alert-danger{background-color:#f2dede;border-color:#ebccd1;color:#a94442}.wpcode-docs-overlay{background-color:#ffffff;bottom:0;display:none;left:0;max-height:100vh;opacity:1;overflow-y:auto;position:fixed;right:0;top:46px;z-index:100100}.wpcode-docs-overlay *{box-sizing:border-box}@media screen and (min-width:783px){.wpcode-docs-overlay{left:36px;top:32px}}@media screen and (min-width:961px){.wpcode-docs-overlay{left:160px}.folded .wpcode-docs-overlay{left:36px}}#wpcode-help-logo{left:36px;position:absolute;top:24px}#wpcode-help-close{cursor:pointer;display:inline-block;height:30px;padding:5px;position:absolute;right:37px;top:25px;transition:all 0.05s ease-out;width:30px;z-index:10}.wpcode-docs-content{background-color:#fff;margin:0 auto 50px auto;max-width:100%;padding:0 30px;width:760px}.wpcode-help-docs{margin-bottom:20px;padding:0 18px}.wpcode-help-docs a{color:var(--wpcode-text-color-paragraph);font-size:var(--wpcode-font-size-m);text-decoration:none}.wpcode-help-docs a:hover,.wpcode-help-docs a:focus{color:var(--wpcode-text-color-heading);text-decoration:underline}.wpcode-help-docs .wpcode-icon-file-text{margin-right:14px}.wpcode-help-docs li{margin-bottom:18px}.wpcode-help-categories-toggle{border-bottom:1px solid var(--wpcode-border-color);margin-bottom:40px}.wpcode-help-category{border-top:1px solid var(--wpcode-border-color);margin:0}.wpcode-help-category header{align-items:center;color:var(--wpcode-text-color-heading);cursor:pointer;display:flex;flex-direction:row;font-size:var(--wpcode-font-size-l);font-weight:600;justify-content:flex-start;padding-left:18px;padding-right:25px}.wpcode-help-category header:hover{color:var(--wpcode-color-primary)}.wpcode-help-category .wpcode-icon-folder{margin:23px 11px 23px 0}.wpcode-help-category .wpcode-icon-arrow{margin-left:auto;transform-origin:center;transition:transform 300ms ease}.wpcode-help-category.open .wpcode-icon-arrow{transform:rotate(90deg)}.wpcode-help-category .wpcode-help-docs{display:none}#wpcode-help-search{padding:74px 0 50px 0;position:relative;text-align:center;top:0}#wpcode-help-search .wpcode-icon-search{display:none;left:17px;position:absolute;top:92px}#wpcode-help-search input{background-image:none;background-position:22px center;background-repeat:no-repeat;background-size:20px 20px;border:1px solid var(--wpcode-border-color);border-radius:3px;color:var(--wpcode-text-color-heading);font-size:20px;letter-spacing:0;line-height:20px;min-height:48px;padding:10px 10px 10px 42px;text-align:left;width:100%}#wpcode-help-search #wpcode-help-search-clear{cursor:pointer;left:17px;opacity:.7;position:absolute;top:92px}#wpcode-help-search.wpcode-search-empty #wpcode-help-search-clear{display:none}#wpcode-help-search.wpcode-search-empty .wpcode-icon-search{display:block}#wpcode-help-no-result li span{color:var(--wpcode-text-color-paragraph);font-size:var(--wpcode-font-size-s)}.wpcode-help-footer{align-items:center;display:flex;justify-content:space-between}.wpcode-help-footer .wpcode-help-footer-box{border:1px solid var(--wpcode-border-color);border-radius:8px;padding:40px 38px;text-align:center;width:calc(50% - 18px)}.wpcode-help-footer .wpcode-help-footer-box h3{font-size:var(--wpcode-font-size-l)}.wpcode-help-footer .wpcode-help-footer-box p{color:var(--wpcode-text-color-paragraph);font-size:var(--wpcode-font-size-m)}.wpcode-notifications-drawer{background:#fff;border-left:1px solid var(--wpcode-border-color);bottom:0;position:fixed;right:-375px;top:32px;transition:right 300ms ease 0s,visibility 0s ease 400ms;visibility:hidden;width:375px;z-index:1100}.wpcode-notifications-open .wpcode-notifications-drawer{right:0;transition:right 300ms ease 0s,visibility 0s ease 0ms;visibility:visible}.wpcode-notifications-overlay{background-color:rgba(0,0,0,0.3);bottom:0;display:none;left:0;opacity:.5;position:fixed;right:0;top:46px;transition:.5s;z-index:1052}.folded .wpcode-notifications-overlay{left:36px}.wpcode-notifications-open .wpcode-notifications-overlay{display:block}@media screen and (min-width:783px){.wpcode-notifications-overlay{left:36px}.admin-bar .wpcode-notifications-overlay{top:32px}}@media screen and (min-width:961px){.wpcode-notifications-overlay{left:160px}.folded .wpcode-notifications-overlay{left:36px}}.wpcode-notifications-header{background:var(--wpcode-background-highlight);border-bottom:1px solid var(--wpcode-border-color);padding:18px 40px 18px 20px}.wpcode-notifications-header .wpcode-notifications-close{position:absolute;right:18px;top:22px}.wpcode-notifications-header .wpcode-notifications-close path{fill:var(--wpcode-text-color-heading)}.wpcode-notifications-header h3{color:var(--wpcode-text-color-heading);display:inline-block;font-size:var(--wpcode-font-size-s);font-weight:700;line-height:21px;margin:0 10px 0 0}.wpcode-notifications-list{height:calc(100% - 130px);overflow:auto}.wpcode-notifications-list ul{margin:0}.wpcode-notifications-list li{border-top:1px solid var(--wpcode-border-color);display:flex;margin:0;padding:24px}.wpcode-notifications-list li:first-child{border-top:none}.wpcode-notifications-list li h4{color:var(--wpcode-text-color-heading);font-size:var(--wpcode-font-size-s);font-weight:600;line-height:21px;margin:0}.wpcode-notifications-list p{color:var(--wpcode-text-color-light-bg);font-size:var(--wpcode-font-size-s);margin:8px 0}.wpcode-notifications-list p.wpcode-start{font-size:var(--wpcode-font-size-xs)}.wpcode-notification-actions .wpcode-button{margin-right:10px}.wpcode-notifications-footer{border-top:1px solid var(--wpcode-border-color);padding:24px 27px;text-align:right}#wpcode-dismissed-title,#wpcode-notifications-show-active,.wpcode-notifications-dismissed{display:none}.show-dismissed #wpcode-notifications-show-dismissed,.show-dismissed .wpcode-notifications-active,.show-dismissed #wpcode-active-title{display:none}.show-dismissed #wpcode-notifications-show-active,.show-dismissed #wpcode-dismissed-title{display:inline-block}.show-dismissed .wpcode-notifications-dismissed{display:block}.wpcode-notifications-dismissed .wpcode-notification-dismiss{display:none}.wpcode-notification-icon{margin-right:10px}.wpcode-help-tooltip{cursor:help;display:inline-block;position:relative;vertical-align:middle}.wpcode-help-tooltip .wpcode-help-tooltip-text{background-color:var(--wpcode-color-primary);border-radius:6px;bottom:100%;color:#fff;font-size:var(--wpcode-font-size-s);font-weight:400;left:50%;margin-bottom:12px;margin-left:-90px;padding:12px 12px;position:absolute;text-align:center;visibility:hidden;width:180px;z-index:500}.wpcode-help-tooltip .wpcode-help-tooltip-text:after{border-color:var(--wpcode-color-primary) transparent transparent transparent;border-style:solid;border-width:10px 9px 0 9px;content:'';height:0;left:50%;margin-left:-9px;position:absolute;top:100%;width:0}.wpcode-help-tooltip:hover .wpcode-help-tooltip-text{visibility:visible}.wpcode-help-tooltip .wpcode-icon-help{margin-top:1px}.wpcode-help-tooltip .wpcode-icon-help path{fill:#8A8A8A}.wpcode-upgrade-welcome{background:#f3f4f5}.wpcode-welcome-content{max-width:1168px;margin:24px auto;clear:both}.wpcode-welcome-content *{box-sizing:border-box}.wpcode-welcome-content h2{font-size:22px;font-weight:600;margin-top:0;line-height:1.2}.wpcode-welcome-content h3{font-size:1.5em}.wpcode-welcome-content p{font-size:1.2em}.wpcode-welcome-box{background:#fff;padding:40px;border:1px solid #ddd;border-radius:4px;margin-bottom:30px}@media (max-width:767px){.wpcode-welcome-box{padding:26px}}.wpcode-welcome-logo{margin:4px 0 28px}.wpcode-welcome-text{width:700px;margin:32px auto;max-width:100%}.wpcode-welcome-features{display:flex;justify-content:space-between;flex-wrap:wrap;margin-top:42px}.wpcode-welcome-features .wpcode-welcome-feature{width:calc(33.3% - 16px);text-align:center;margin-bottom:32px;display:flex}@media (max-width:782px){.wpcode-welcome-features .wpcode-welcome-feature{width:100%}}.wpcode-welcome-features .wpcode-welcome-feature p{font-size:16px}.wpcode-welcome-features .wpcode-welcome-feature h3{font-size:18px;margin-top:6px}.wpcode-welcome-features .wpcode-welcome-feature .wpcode-welcome-feature-text{text-align:left;margin-left:16px}.wpcode-welcome-features .wpcode-welcome-feature-icon-icon path{fill:var(--wpcode-color-primary)}.wpcode-welcome-highlight{grid-template-columns:1fr 1fr;display:grid}@media (max-width:767px){.wpcode-welcome-highlight{grid-template-columns:1fr}}.wpcode-welcome-highlight .wpcode-welcome-highlight-column{padding:16px 0;align-self:center;grid-column-start:2}@media (min-width:768px){.wpcode-welcome-highlight .wpcode-welcome-highlight-column{padding:16px 20px}.wpcode-welcome-highlight .wpcode-welcome-highlight-column:nth-of-type(2n+1){grid-column-start:1}.wpcode-welcome-highlight .wpcode-welcome-highlight-column:nth-of-type(2n){grid-column-start:2}}.wpcode-welcome-highlight img{max-width:100%;width:100%;height:auto}.wpcode-buttons-row{text-align:left}.wpcode-welcome-syed-mircea{font-size:1.2em}.wpcode-welcome-syed-mircea .wpcode-welcome-person{display:inline-flex;align-items:center;margin-right:60px;margin-top:32px}.wpcode-welcome-syed-mircea .wpcode-welcome-person-image{margin-right:15px}.wpcode-welcome-syed-mircea .wpcode-welcome-person-text{font-size:13px;color:var(--wpcode-text-color-paragraph)}.wpcode-welcome-syed-mircea h4{color:var(--wpcode-text-color-heading);margin:0 0 4px;font-size:16px;font-weight:600}.wpcode-welcome-syed-mircea img{display:block;margin-bottom:0}.wpcode-welcome-syed-mircea span{align-self:end}.wpcode-upgrade-welcome #wpcontent{padding-right:10px}@media screen and (min-width:783px){.wpcode-upgrade-welcome #wpcontent{padding-right:20px}}
|
2 |
+
|
3 |
+
.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px;padding:1px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:linear-gradient(to bottom,#fff 50%,#eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF',endColorstr='#FFEEEEEE',GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:linear-gradient(to bottom,#eee 50%,#ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE',endColorstr='#FFCCCCCC',GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:linear-gradient(to bottom,#fff 0%,#eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF',endColorstr='#FFEEEEEE',GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:linear-gradient(to bottom,#eee 50%,#fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE',endColorstr='#FFFFFFFF',GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right;margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
|
4 |
+
|
build/admin.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(){var e={233:function(){(window.WPCodeAdminCodeEditor||function(e,t,n){const i={l18n:wpcode,init(){t.WPCodeAdminCodeEditor=i},switch_code_mode(e){const t=i.get_editor();if(void 0===t)return!1;t.setOption("mode",i.get_mime_for_code_type(e)),t.setOption("lint",i.get_lint_for_code_type(e)),jQuery(t.getTextArea()).closest(".wpcode-code-textarea").attr("data-code-type",e)},get_editor:()=>(void 0===i.editor&&void 0!==wpcode_editor&&(i.editor=wpcode_editor.codemirror),i.editor),set_value(e){const t=i.get_editor();if(void 0===t)return!1;t.getDoc().setValue(e)},get_mime_for_code_type:e=>i.l18n.code_type_options[e].mime,get_lint_for_code_type:e=>i.l18n.code_type_options[e].lint,refresh(){i.get_editor().refresh()},get_value:()=>i.get_editor().getValue()};return i}(document,window,jQuery)).init()},560:function(){(window.WPCodeSnippetsTable||function(e,t,n){const i={l10n:wpcode,init:function(){i.should_init()&&i.init_status_toggle()},should_init:function(){return null!==e.getElementById("wpcode-code-snippets-table")},init_status_toggle:function(){n(".wpcode-status-toggle").on("change",(function(){const e=n(this),t=e.is(":checked"),o=e.data("id");i.update_status(t,o).fail((function(){e.prop("checked",!1)})).done((function(n){!1===n.success&&(e.prop("checked",!t),n.data.message&&WPCodeAdminNotices.add_notice(n.data.message,"error"))})).fail((function(e){e.responseText&&WPCodeAdminNotices.add_notice(e.responseText,"error")}))}))},update_status:function(e,t){return n.post(ajaxurl,{_wpnonce:i.l10n.nonce,action:"wpcode_update_snippet_status",snippet_id:t,active:e})}};return i}(document,window,jQuery)).init()},569:function(){(window.WPCodeConditionalLogic||function(e,t,n){const i={l10n:wpcode,init:function(){i.should_init()&&(i.find_elements(),i.add_events(),i.show_relations_for_all_rows())},should_init:function(){return void 0!==wpcode.conditions},find_elements:function(){i.conditions=wpcode.conditions,i.conditions_holder=n(e.getElementById("wpcode-conditions-holder")),i.conditions_input=n(e.getElementById("wpcode-cl-rules")),i.add_group_button=n(e.getElementById("wpcode-cl-add-group")),i.group_template=n(e.getElementById("wpcode-conditions-group-markup")).html(),i.row_template=n(e.getElementById("wpcode-conditions-group-row-markup")).html(),i.show_hide_input=n(e.getElementById("wpcode-cl-show-hide"))},add_events:function(){i.init_add_group(),i.init_add_row(),i.init_remove_row(),i.init_change_type(),i.init_capture_rules(),i.init_change_show_hide(),i.init_select2()},show_relations_for_all_rows(){i.conditions_holder.find(".wpcode-cl-rules-row").each((function(){i.show_hide_relation_options(n(this))}))},init_add_group:function(){i.add_group_button.on("click",(function(){i.add_group()}))},add_group(){const e=i.get_new_group();i.conditions_holder.append(e),i.add_new_row(e.find(".wpcode-cl-group-rules")),i.build_rules_from_inputs()},get_new_group:()=>n(i.group_template),get_new_row:()=>n(i.row_template),init_add_row(){i.conditions_holder.on("click",".wpcode-cl-add-row",(function(){i.add_new_row(n(this).closest(".wpcode-cl-group").find(".wpcode-cl-group-rules"))}))},init_remove_row(){i.conditions_holder.on("click",".wpcode-cl-remove-row",(function(){const e=n(this).closest(".wpcode-cl-group");n(this).closest(".wpcode-cl-rules-row").remove(),i.maybe_remove_group(e),i.build_rules_from_inputs()}))},maybe_remove_group(e){0===e.find(".wpcode-cl-group-rules .wpcode-cl-rules-row").length&&i.remove_group(e)},remove_group(e){e.remove(),i.build_rules_from_inputs()},add_new_row(e){const t=i.get_new_row();t.appendTo(e),i.handle_type_change(t.find(".wpcode-cl-rule-type")),i.build_rules_from_inputs()},init_change_type(){i.conditions_holder.on("change",".wpcode-cl-rule-type",(function(){i.handle_type_change(n(this))}))},init_change_show_hide(){i.show_hide_input.on("change",(function(){i.build_rules_from_inputs()}))},handle_type_change(e){const t=e.find("option:selected"),n=e.val(),o=t.closest("optgroup").data("type"),s=i.conditions[o].options[n],r=e.closest(".wpcode-cl-rules-row");e.parent().find(".wpcode-cl-rule-value").html(i.get_input_markup(s)),i.show_hide_relation_options(r),r.find(".wpcode-cl-rule-relation option").prop("selected",!1),i.init_select2()},get_input_markup(e){let t="";switch(e.type){case"select":t=i.get_input_select(e.options);break;case"text":t=i.get_input_text();break;case"ajax":t=i.get_input_ajax(e.options)}return t},get_input_select(e){const t=n("<select/>");return n.each(e,(function(e,i){t.append(n("<option />",{value:i.value}).text(i.label))})),t},get_input_text:()=>n('<input type="text" class="wpcode-input-text" />'),get_input_ajax:e=>n('<select data-action="'+e+'" class="wpcode-select2" multiple />'),init_capture_rules(){i.conditions_holder.on("change","input,select",(function(){i.build_rules_from_inputs()}))},build_rules_from_inputs(){const e=i.conditions_holder.find(".wpcode-cl-group"),t=[];e.each((function(e){const o=n(this).find(".wpcode-cl-rules-row");t[e]=[],o.each((function(){const o=n(this),s=o.find(".wpcode-cl-rule-type"),r=s.find("option:selected").closest("optgroup").data("type"),a=s.val(),l={},c=i.conditions[r].options[a];l.type=r,l.option=a,l.relation=o.find(".wpcode-cl-rule-relation").val(),l.value=i.get_input_value(c,o),t[e].push(l)}))}));const o={show:i.show_hide_input.val(),groups:t};i.conditions_input.val(JSON.stringify(o))},get_input_value(e,t){let n="";switch(e.type){case"select":case"ajax":n=t.find(".wpcode-cl-rule-value select").val();break;case"text":n=t.find(".wpcode-cl-rule-value input").val()}return n},show_hide_relation_options(e){const t=e.find(".wpcode-cl-rule-type"),o=t.val(),s=t.find("option:selected").closest("optgroup").data("type"),r=e.find(".wpcode-cl-rule-relation option"),a={select:["=","!="],ajax:["=","!="],text:["=","!=","contains","notcontains"]}[i.conditions[s].options[o].type];r.each((function(){a.indexOf(n(this).attr("value"))>-1?n(this).show():n(this).hide()}))},init_select2(){i.conditions_holder.find(".wpcode-select2").select2({ajax:{url:ajaxurl,data:function(e){return{action:n(this).data("action"),term:e.term,_wpnonce:i.l10n.nonce}}}})}};return i}(document,window,jQuery)).init()},786:function(){(window.WPCodeAdminGenerator||function(e,t,n){const i={doing_ajax_call:!1,ajax_snippet_update:!1,init:function(){i.should_init()&&(i.find_elements(),i.init_generator_form(),i.init_code_editor(),i.init_tabs(),i.init_use_snippet(),i.init_copy_editor(),i.init_repeater(),i.do_spacer(),n(e).ready((function(){i.init_autocomplete()})))},should_init:()=>(i.generator_form=n("#wpcode_generator_form"),i.generator_form.length>0),find_elements(){i.tabs_buttons=n(".wpcode-items-tabs"),i.tabs_content=n(".wpcode-items-list .wpcode-form-tab"),i.use_snippet=n("#wpcode-generator-use-snippet"),i.spinner=n("#wpcode-generator-spinner"),i.update_button=n("#wpcode-generator-update-code"),i.repeater_row=n("#wpcode-generator-repeater-row").html()},init_generator_form(){i.generator_form.on("submit",(function(e){e.preventDefault(),i.update_snippet()})),i.generator_form.on("change","input, select",(function(){i.update_snippet()}))},update_snippet(){i.doing_ajax_call||(i.ajax_snippet_update&&i.ajax_snippet_update.abort(),i.show_button_spinner(i.update_button),i.ajax_snippet_update=n.post(ajaxurl,n(i.generator_form).serialize()).done((function(e){i.ajax_snippet_update=!1,WPCodeAdminCodeEditor.set_value(e),i.hide_button_spinner(i.update_button)})))},init_tabs(){i.tabs_buttons.on("click","button",(function(e){e.preventDefault(),i.switch_active_tab(n(this))}))},switch_active_tab(e){i.tabs_buttons.find("button").removeClass("wpcode-active"),e.addClass("wpcode-active");const t=e.data("category");i.tabs_content.hide(),i.tabs_content.filter((function(){return n(this).data("tab")===t})).show(),i.do_spacer(),WPCodeAdminCodeEditor.refresh()},init_use_snippet(){i.use_snippet.on("click",(function(e){if(e.preventDefault(),i.doing_ajax_call)return;i.doing_ajax_call=!0;const o=i.generator_form.serializeArray(),s=n(this);n.each(o,(function(e,t){"action"===t.name&&(o[e].value="wpcode_save_generated_snippet")})),i.show_button_spinner(s),n.post(ajaxurl,n.param(o)).done((function(e){i.doing_ajax_call=!1,i.hide_button_spinner(s),e.success&&e.data.url&&(t.location=e.data.url)}))}))},show_button_spinner(e){e.prop("disabled",!0);const t=e.offset(),o=n("#adminmenuwrap").width(),s=n("#wpadminbar").height();i.spinner.show(),i.spinner.css({left:t.left-o+e.outerWidth(),top:t.top-s+e.outerHeight()/2-i.spinner.height()/2})},hide_button_spinner(e){e.prop("disabled",!1),i.spinner.hide()},init_copy_editor:function(){n(".wpcode-copy-target").on("click",(function(e){e.preventDefault();const t=n(this),i=WPCodeAdminCodeEditor.get_value();i&&(navigator.clipboard.writeText(i),t.addClass("wpcode-show-success-icon"),setTimeout((function(){t.removeClass("wpcode-show-success-icon")}),500))}))},init_repeater(){i.row_id=0,i.tabs_content.on("click",".wpcode-repeater-button",(function(){const e=n(this).data("target"),t=n(n('[data-repeater="'+e+'"]').get().reverse());let o,s,r=0;i.row_id++,t.each((function(){const e=n(this).closest(".wpcode-generator-column");e.is(o)||(r++,o=e,s=n(i.repeater_row),r>1?s.find("button").remove():s.find("button").data("target",i.row_id),s.attr("data-id",i.row_id),e.append(s)),n(this).clone().attr("data-repeater",null).prependTo(s).find("input").val(null)}));let a=0,l=n('.wpcode-repeater-group[data-id="'+i.row_id+'"]');l.each((function(){const e=n(this).height();e>a&&(a=e)})),l.height(a),l.first().find("input").first().focus()})),i.tabs_content.on("click",".wpcode-remove-row",(function(){const e=n(this).data("target");n('.wpcode-repeater-group[data-id="'+e+'"]').remove()}))},do_spacer(){n(".wpcode-generator-field-spacer").each((function(){const e=n(this).closest(".wpcode-generator-column"),t=n(this).closest(".wpcode-generator-column").outerHeight();let i=0;e.siblings(".wpcode-generator-column").each((function(){const e=n(this).height();e>i&&(i=e)})),i>t&&n(this).height(i-t+3)}))},init_autocomplete(){n(".wpcode-generator-field-autocomplete").each((function(){const e=n(this).find('input[type="text"]'),t=n(this).find(".wpcode-field-autocomplete").text();e.autocomplete({source:JSON.parse(t)})}))},init_code_editor(){const e=n(".wpcode-generator-code");if(0===e.length)return;const t=wp.codeEditor.initialize(e);i.CodeMirror=t.codemirror,i.CodeMirror.setOption("readOnly",!1),i.CodeMirror.on("change",(function(e){clearTimeout(i.editor_change_handler),i.editor_change_handler=setTimeout((function(){jQuery(e.getTextArea()).val(e.getValue()).change(),i.update_snippet()}),300)}))}};return i}(document,window,jQuery)).init()},448:function(){(window.WPCodeHeader||function(e,t,n){const i={init(){i.should_init()&&n(e).ready((function(){i.init_sticky_header()}))},should_init:()=>n("#wpcode_snippet_code").length>0||n("#ihaf_insert_header").length>0,init_sticky_header(){const e=n(".wpcode-header-bottom"),i=e.height(),o=e.offset().top,s=e.parent();n(t).scroll((function(){const r=n(t).scrollTop();o<r+32?(e.addClass("wpcode-sticky"),s.css("paddingBottom",i+"px")):(e.removeClass("wpcode-sticky"),s.css("paddingBottom",0))}))}};return i}(document,window,jQuery)).init()},847:function(){(window.WPCodeHelp||function(e,t,n){const i={init:function(){i.should_init()&&(i.find_elements(),i.init_show(),i.init_close_button(),i.init_search(),i.init_accordion())},should_init:()=>(i.$overlay=n("#wpcode-docs-overlay"),i.$overlay.length>0),find_elements(){i.$close_button=n("#wpcode-help-close"),i.$search=n("#wpcode-help-search"),i.$no_result=n("#wpcode-help-no-result"),i.$search_results=n("#wpcode-help-result ul"),i.$categories=n("#wpcode-help-categories")},init_close_button(){i.$close_button.on("click",(function(e){e.preventDefault(),i.$overlay.fadeOut(200)}))},init_show(){n(e).on("click",".wpcode-show-help",(function(e){e.preventDefault(),i.$overlay.fadeIn(200)}))},init_accordion(){i.$categories.on("click",".wpcode-help-category header",(function(){const e=n(this).closest(".wpcode-help-category");i.toggle_category(e)})),i.$categories.on("click",".viewall",(function(e){e.preventDefault(),n(this).closest(".wpcode-help-docs").find("div").slideDown(),n(this).hide()}))},toggle_category(e){e.toggleClass("open"),e.find(".wpcode-help-docs").slideToggle()},init_search(){i.$search.on("keyup","input",i.input_search),i.$search.on("click","#wpcode-help-search-clear",i.clear_search)},input_search(){i.$search_results.html("");const e=n(this).val().toLowerCase(),t=n("#wpcode-help-categories .wpcode-help-docs li").filter((function(){return n(this).text().toLowerCase().indexOf(""+e)>-1}));e.length>2&&t.clone().appendTo(i.$search_results),0===t.length?i.$no_result.show():i.$no_result.hide(),i.$search.toggleClass("wpcode-search-empty",!e)},clear_search(){i.$search.find("input").val("").trigger("keyup")}};return i}(document,window,jQuery)).init()},298:function(){(window.WPCodeInputs||function(e,t,n){const i={init(){n(i.ready)},ready(){i.initFileUploads(),i.initCheckboxMultiselectColumns()},initFileUploads(){n(".wpcode-file-upload").each((function(){const e=n(this).find("input[type=file]"),t=n(this).find("label"),i=t.html();e.on("change",(function(e){let n="";this.files&&this.files.length>1?n=(this.getAttribute("data-multiple-caption")||"").replace("{count}",this.files.length):e.target.value&&(n=e.target.value.split("\\").pop()),n?t.find(".wpcode-file-field").html(n):t.html(i)})),e.on("focus",(function(){e.addClass("has-focus")})).on("blur",(function(){e.removeClass("has-focus")}))}))},initCheckboxMultiselectColumns(){n(e).on("change",".wpcode-checkbox-multiselect-columns input",(function(){var e=n(this),t=e.parent(),i=e.closest(".wpcode-checkbox-multiselect-columns"),o=t.text(),s="check-item-"+e.val(),r=i.find("#"+s);e.prop("checked")?(e.parent().addClass("checked"),r.length||i.find(".second-column ul").append('<li id="'+s+'">'+o+"</li>")):(e.parent().removeClass("checked"),i.find("#"+s).remove())})),n(e).on("click",".wpcode-checkbox-multiselect-columns .all",(function(e){e.preventDefault(),n(this).closest(".wpcode-checkbox-multiselect-columns").find("input[type=checkbox]").prop("checked",!0).trigger("change")}))}};return i}(document,window,jQuery)).init()},900:function(){(window.WPCodeItemsList||function(e,t,n){const i={category:"*",search_term:"",init:function(){i.should_init()&&(i.find_elements(),i.init_category_switch(),i.init_search())},should_init:()=>(i.categories_list=n(".wpcode-items-filters"),i.categories_list.length>0),find_elements(){i.search_input=n("#wpcode-items-search")},init_category_switch(){i.categories_list.on("click","button",(function(){const e=n(this);e.hasClass("wpcode-active")||(i.switch_to_category(e.data("category")),i.switch_category_button(e))}))},switch_category_button(e){i.categories_list.find("button").removeClass("wpcode-active"),e.addClass("wpcode-active")},switch_to_category(e){i.category=e,i.filter_items()},filter_items(){let e;const t=n(".wpcode-list-item"),o=t.filter((function(){return"*"===i.category||n(this).data("categories").indexOf(i.category)>-1}));if(i.search_term.length>2){const o=i.search_term.toLowerCase();e=t.filter((function(){return n(this).text().toLowerCase().indexOf(""+o)>-1}))}else e=o;t.hide(),e.show()},init_search(){i.search_input.on("keyup change search",(function(){const e=n(this).val();e.length<3?i.search_term="":i.search_term=e,i.filter_items()}))}};return i}(document,window,jQuery)).init()},423:function(){(window.WPCodeAdminLibrary||function(e,t,n){const i={l10n:wpcode,init:function(){i.should_init()&&(i.find_elements(),i.init_preview())},should_init:()=>n(".wpcode-library-preview-button").length>0,find_elements(){i.library_list=n(".wpcode-items-list"),i.code_preview_use=n("#wpcode-preview-use-code"),i.code_preview_title=n("#wpcode-preview-title")},init_preview(){i.library_list.on("click",".wpcode-library-preview-button",(function(e){e.preventDefault();const t=n(this).parent().find(".wpcode-item-use-button"),o=n(this).closest(".wpcode-list-item").data("id");i.show_code_preview(o,t.attr("href")),i.code_preview_use.text(t.text())})),n(".wpcode-close-modal, .wpcode-modal-overlay").on("click",(function(){n("body").removeClass("wpcode-show-modal")}))},show_code_preview(e,t){const o=i.l10n.library.snippets.find((t=>t.library_id===e));WPCodeAdminCodeEditor.switch_code_mode(o.code_type),WPCodeAdminCodeEditor.set_value(o.code),i.code_preview_use.attr("href",t),i.code_preview_title.text(o.title),n("body").addClass("wpcode-show-modal"),WPCodeAdminCodeEditor.refresh()}};return i}(document,window,jQuery)).init()},5:function(){const e=window.WPCodeAdminNotices||function(e,t,n){const i={init:function(){t.WPCodeAdminNotices=i,i.notice_holder=n(e.getElementById("wpcode-notice-area")),i.document=n(e)},add_notice(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"updated";const o=n("<div />"),s=n("<p />");s.html(e),o.addClass("fade notice is-dismissible"),o.addClass(t),o.append(s),i.notice_holder.append(o),i.document.trigger("wp-updates-notice-added"),o.find("button").focus()}};return i}(document,window,jQuery);e.init()},770:function(){(window.WPCodeAdminNotifications||function(e,t,n){const i={init(){i.should_init()&&(i.find_elements(),i.init_open(),i.init_close(),i.init_dismiss(),i.init_view_switch(),i.update_count(i.active_count))},should_init:()=>(i.$drawer=n("#wpcode-notifications-drawer"),i.$drawer.length>0),find_elements(){i.$open_button=n("#wpcode-notifications-button"),i.$count=i.$drawer.find("#wpcode-notifications-count"),i.$dismissed_count=i.$drawer.find("#wpcode-notifications-dismissed-count"),i.active_count=i.$open_button.data("count")?i.$open_button.data("count"):0,i.dismissed_count=i.$open_button.data("dismissed"),i.$body=n("body"),i.$dismissed_button=n("#wpcode-notifications-show-dismissed"),i.$active_button=n("#wpcode-notifications-show-active"),i.$active_list=n(".wpcode-notifications-list .wpcode-notifications-active"),i.$dismissed_list=n(".wpcode-notifications-list .wpcode-notifications-dismissed"),i.$dismiss_all=n("#wpcode-dismiss-all")},update_count(e){i.$open_button.data("count",e).attr("data-count",e),0===e&&i.$open_button.removeAttr("data-count"),i.$count.text(e),i.dismissed_count+=Math.abs(e-i.active_count),i.active_count=e,i.$dismissed_count.text(i.dismissed_count),0===i.active_count&&i.$dismiss_all.hide()},init_open(){i.$open_button.on("click",(function(e){e.preventDefault(),i.$body.addClass("wpcode-notifications-open")}))},init_close(){i.$body.on("click",".wpcode-notifications-close, .wpcode-notifications-overlay",(function(e){e.preventDefault(),i.$body.removeClass("wpcode-notifications-open")}))},init_dismiss(){i.$drawer.on("click",".wpcode-notification-dismiss",(function(e){e.preventDefault();const t=n(this).data("id");if(i.dismiss_notification(t),"all"===t)return i.move_to_dismissed(i.$active_list.find("li")),void i.update_count(0);i.move_to_dismissed(n(this).closest("li")),i.update_count(i.active_count-1)}))},move_to_dismissed(e){e.slideUp((function(){n(this).prependTo(i.$dismissed_list).show()}))},dismiss_notification:e=>n.post(ajaxurl,{action:"wpcode_notification_dismiss",nonce:wpcode.nonce,id:e}),init_view_switch(){i.$dismissed_button.on("click",(function(e){e.preventDefault(),i.$drawer.addClass("show-dismissed")})),i.$active_button.on("click",(function(e){e.preventDefault(),i.$drawer.removeClass("show-dismissed")}))}};return i}(document,window,jQuery)).init()},801:function(){(window.WPCodeAdminTools||function(e,t,n){const i={init:function(){i.should_init()&&(i.find_elements(),i.init_importer(),i.init_ssl_verify())},should_init:()=>n("body").hasClass("wpcode-tools"),find_elements(){i.importer_button=n("#wpcode-importer-snippets-submit"),i.$import_progress=n("#wpcode-importer-process"),i.provider=n("#wpcode-importer-provider").val(),i.status_update=n("#wpcode-importer-status-update").html()},init_importer(){i.importer_button.on("click",(function(e){e.preventDefault();const t=n("#wpcode-importer-snippets input:checked");if(t.length){const e=[];t.each((function(){e.push(n(this).val())})),i.import_snippets(e)}}))},import_snippets(e){i.$import_progress.find(".snippet-total").text(e.length),i.$import_progress.find(".snippet-current").text("1"),n("#wpcode-importer-snippets").hide(),i.$import_progress.show(),i.import_queue=e,i.imported=0,i.import_snippet()},import_snippet(){const e=i.import_queue[0];n.post(ajaxurl,{action:"wpcode_import_snippet_"+i.provider,snippet_id:e,_wpnonce:wpcode.nonce}).done((function(e){if(e.success){i.import_queue.shift(),i.imported++;const t=n(i.status_update);t.find(".name span").text(e.data.name),t.find(".actions a").attr("href",e.data.edit),i.$import_progress.find(".status").prepend(t),i.$import_progress.find(".status").show(),0===i.import_queue.length?(i.$import_progress.find(".process-count").hide(),i.$import_progress.find(".snippets-completed").text(i.imported),i.$import_progress.find(".process-completed").show()):(i.$import_progress.find(".snippet-current").text(i.imported+1),i.import_snippet())}}))},init_ssl_verify(){n(e).on("click","#wpcode-ssl-verify",(function(e){e.preventDefault(),i.verify_ssl()}))},verify_ssl(){const e=n("#wpcode-ssl-verify"),t=e.text(),i=e.outerWidth(),o=e.parent(),s={action:"wpcode_verify_ssl",nonce:wpcode.nonce};e.css("width",i).prop("disabled",!0).text(wpcode.testing),n.post(ajaxurl,s,(function(n){console.log(n),o.find(".wpcode-alert, .wpcode-ssl-error").remove(),n.success&&e.before('<div class="wpcode-alert wpcode-alert-success">'+n.data.msg+"</div>"),!n.success&&n.data.msg&&e.before('<div class="wpcode-alert wpcode-alert-danger">'+n.data.msg+"</div>"),!n.success&&n.data.debug&&e.before('<div class="wpcode-ssl-error pre-error">'+n.data.debug+"</div>"),e.css("width",i).prop("disabled",!1).text(t)}))}};return i}(document,window,jQuery)).init()},868:function(){(window.WPCodeAdminWelcome||function(e,t,n){const i={init:function(){i.add_listener()},add_listener(){n("#wpbody-content").on("click",".wpcode-scroll-to",(function(e){e.preventDefault();const t=n(this).attr("href"),i=n(t);n("html, body").animate({scrollTop:i.offset().top},700)}))}};return i}(document,window,jQuery)).init()},686:function(e,t,n){var i,o,s;o=[n(567)],i=function(e){var t=function(){if(e&&e.fn&&e.fn.select2&&e.fn.select2.amd)var t=e.fn.select2.amd;var n,i,o;return t&&t.requirejs||(t?i=t:t={},function(e){var t,s,r,a,l={},c={},d={},u={},p=Object.prototype.hasOwnProperty,h=[].slice,f=/\.js$/;function g(e,t){return p.call(e,t)}function _(e,t){var n,i,o,s,r,a,l,c,u,p,h,g=t&&t.split("/"),_=d.map,m=_&&_["*"]||{};if(e){for(r=(e=e.split("/")).length-1,d.nodeIdCompat&&f.test(e[r])&&(e[r]=e[r].replace(f,"")),"."===e[0].charAt(0)&&g&&(e=g.slice(0,g.length-1).concat(e)),u=0;u<e.length;u++)if("."===(h=e[u]))e.splice(u,1),u-=1;else if(".."===h){if(0===u||1===u&&".."===e[2]||".."===e[u-1])continue;u>0&&(e.splice(u-1,2),u-=2)}e=e.join("/")}if((g||m)&&_){for(u=(n=e.split("/")).length;u>0;u-=1){if(i=n.slice(0,u).join("/"),g)for(p=g.length;p>0;p-=1)if((o=_[g.slice(0,p).join("/")])&&(o=o[i])){s=o,a=u;break}if(s)break;!l&&m&&m[i]&&(l=m[i],c=u)}!s&&l&&(s=l,a=c),s&&(n.splice(0,a,s),e=n.join("/"))}return e}function m(t,n){return function(){var i=h.call(arguments,0);return"string"!=typeof i[0]&&1===i.length&&i.push(null),s.apply(e,i.concat([t,n]))}}function v(e){return function(t){l[e]=t}}function w(n){if(g(c,n)){var i=c[n];delete c[n],u[n]=!0,t.apply(e,i)}if(!g(l,n)&&!g(u,n))throw new Error("No "+n);return l[n]}function y(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function b(e){return e?y(e):[]}function $(e){return function(){return d&&d.config&&d.config[e]||{}}}r=function(e,t){var n,i,o=y(e),s=o[0],r=t[1];return e=o[1],s&&(n=w(s=_(s,r))),s?e=n&&n.normalize?n.normalize(e,(i=r,function(e){return _(e,i)})):_(e,r):(s=(o=y(e=_(e,r)))[0],e=o[1],s&&(n=w(s))),{f:s?s+"!"+e:e,n:e,pr:s,p:n}},a={require:function(e){return m(e)},exports:function(e){var t=l[e];return void 0!==t?t:l[e]={}},module:function(e){return{id:e,uri:"",exports:l[e],config:$(e)}}},t=function(t,n,i,o){var s,d,p,h,f,_,y,$=[],x=typeof i;if(_=b(o=o||t),"undefined"===x||"function"===x){for(n=!n.length&&i.length?["require","exports","module"]:n,f=0;f<n.length;f+=1)if("require"===(d=(h=r(n[f],_)).f))$[f]=a.require(t);else if("exports"===d)$[f]=a.exports(t),y=!0;else if("module"===d)s=$[f]=a.module(t);else if(g(l,d)||g(c,d)||g(u,d))$[f]=w(d);else{if(!h.p)throw new Error(t+" missing "+d);h.p.load(h.n,m(o,!0),v(d),{}),$[f]=l[d]}p=i?i.apply(l[t],$):void 0,t&&(s&&s.exports!==e&&s.exports!==l[t]?l[t]=s.exports:p===e&&y||(l[t]=p))}else t&&(l[t]=i)},n=i=s=function(n,i,o,l,c){if("string"==typeof n)return a[n]?a[n](i):w(r(n,b(i)).f);if(!n.splice){if((d=n).deps&&s(d.deps,d.callback),!i)return;i.splice?(n=i,i=o,o=null):n=e}return i=i||function(){},"function"==typeof o&&(o=l,l=c),l?t(e,n,i,o):setTimeout((function(){t(e,n,i,o)}),4),s},s.config=function(e){return s(e)},n._defined=l,(o=function(e,t,n){if("string"!=typeof e)throw new Error("See almond README: incorrect module build, no module name");t.splice||(n=t,t=[]),g(l,e)||g(c,e)||(c[e]=[e,t,n])}).amd={jQuery:!0}}(),t.requirejs=n,t.require=i,t.define=o),t.define("almond",(function(){})),t.define("jquery",[],(function(){var t=e||$;return null==t&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),t})),t.define("select2/utils",["jquery"],(function(e){var t={};function n(e){var t=e.prototype,n=[];for(var i in t)"function"==typeof t[i]&&"constructor"!==i&&n.push(i);return n}t.Extend=function(e,t){var n={}.hasOwnProperty;function i(){this.constructor=e}for(var o in t)n.call(t,o)&&(e[o]=t[o]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e},t.Decorate=function(e,t){var i=n(t),o=n(e);function s(){var n=Array.prototype.unshift,i=t.prototype.constructor.length,o=e.prototype.constructor;i>0&&(n.call(arguments,e.prototype.constructor),o=t.prototype.constructor),o.apply(this,arguments)}t.displayName=e.displayName,s.prototype=new function(){this.constructor=s};for(var r=0;r<o.length;r++){var a=o[r];s.prototype[a]=e.prototype[a]}for(var l=function(e){var n=function(){};e in s.prototype&&(n=s.prototype[e]);var i=t.prototype[e];return function(){return Array.prototype.unshift.call(arguments,n),i.apply(this,arguments)}},c=0;c<i.length;c++){var d=i[c];s.prototype[d]=l(d)}return s};var i=function(){this.listeners={}};i.prototype.on=function(e,t){this.listeners=this.listeners||{},e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t]},i.prototype.trigger=function(e){var t=Array.prototype.slice,n=t.call(arguments,1);this.listeners=this.listeners||{},null==n&&(n=[]),0===n.length&&n.push({}),n[0]._type=e,e in this.listeners&&this.invoke(this.listeners[e],t.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},i.prototype.invoke=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n].apply(this,t)},t.Observable=i,t.generateChars=function(e){for(var t="",n=0;n<e;n++)t+=Math.floor(36*Math.random()).toString(36);return t},t.bind=function(e,t){return function(){e.apply(t,arguments)}},t._convertData=function(e){for(var t in e){var n=t.split("-"),i=e;if(1!==n.length){for(var o=0;o<n.length;o++){var s=n[o];(s=s.substring(0,1).toLowerCase()+s.substring(1))in i||(i[s]={}),o==n.length-1&&(i[s]=e[t]),i=i[s]}delete e[t]}}return e},t.hasScroll=function(t,n){var i=e(n),o=n.style.overflowX,s=n.style.overflowY;return(o!==s||"hidden"!==s&&"visible"!==s)&&("scroll"===o||"scroll"===s||i.innerHeight()<n.scrollHeight||i.innerWidth()<n.scrollWidth)},t.escapeMarkup=function(e){var t={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,(function(e){return t[e]}))},t.appendMany=function(t,n){if("1.7"===e.fn.jquery.substr(0,3)){var i=e();e.map(n,(function(e){i=i.add(e)})),n=i}t.append(n)},t.__cache={};var o=0;return t.GetUniqueElementId=function(e){var t=e.getAttribute("data-select2-id");return null==t&&(e.id?(t=e.id,e.setAttribute("data-select2-id",t)):(e.setAttribute("data-select2-id",++o),t=o.toString())),t},t.StoreData=function(e,n,i){var o=t.GetUniqueElementId(e);t.__cache[o]||(t.__cache[o]={}),t.__cache[o][n]=i},t.GetData=function(n,i){var o=t.GetUniqueElementId(n);return i?t.__cache[o]&&null!=t.__cache[o][i]?t.__cache[o][i]:e(n).data(i):t.__cache[o]},t.RemoveData=function(e){var n=t.GetUniqueElementId(e);null!=t.__cache[n]&&delete t.__cache[n],e.removeAttribute("data-select2-id")},t})),t.define("select2/results",["jquery","./utils"],(function(e,t){function n(e,t,i){this.$element=e,this.data=i,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,t.Observable),n.prototype.render=function(){var t=e('<ul class="select2-results__options" role="listbox"></ul>');return this.options.get("multiple")&&t.attr("aria-multiselectable","true"),this.$results=t,t},n.prototype.clear=function(){this.$results.empty()},n.prototype.displayMessage=function(t){var n=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var i=e('<li role="alert" aria-live="assertive" class="select2-results__option"></li>'),o=this.options.get("translations").get(t.message);i.append(n(o(t.args))),i[0].className+=" select2-results__message",this.$results.append(i)},n.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},n.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n<e.results.length;n++){var i=e.results[n],o=this.option(i);t.push(o)}this.$results.append(t)}else 0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"})},n.prototype.position=function(e,t){t.find(".select2-results").append(e)},n.prototype.sort=function(e){return this.options.get("sorter")(e)},n.prototype.highlightFirstItem=function(){var e=this.$results.find(".select2-results__option[aria-selected]"),t=e.filter("[aria-selected=true]");t.length>0?t.first().trigger("mouseenter"):e.first().trigger("mouseenter"),this.ensureHighlightVisible()},n.prototype.setClasses=function(){var n=this;this.data.current((function(i){var o=e.map(i,(function(e){return e.id.toString()}));n.$results.find(".select2-results__option[aria-selected]").each((function(){var n=e(this),i=t.GetData(this,"data"),s=""+i.id;null!=i.element&&i.element.selected||null==i.element&&e.inArray(s,o)>-1?n.attr("aria-selected","true"):n.attr("aria-selected","false")}))}))},n.prototype.showLoading=function(e){this.hideLoading();var t={disabled:!0,loading:!0,text:this.options.get("translations").get("searching")(e)},n=this.option(t);n.className+=" loading-results",this.$results.prepend(n)},n.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},n.prototype.option=function(n){var i=document.createElement("li");i.className="select2-results__option";var o={role:"option","aria-selected":"false"},s=window.Element.prototype.matches||window.Element.prototype.msMatchesSelector||window.Element.prototype.webkitMatchesSelector;for(var r in(null!=n.element&&s.call(n.element,":disabled")||null==n.element&&n.disabled)&&(delete o["aria-selected"],o["aria-disabled"]="true"),null==n.id&&delete o["aria-selected"],null!=n._resultId&&(i.id=n._resultId),n.title&&(i.title=n.title),n.children&&(o.role="group",o["aria-label"]=n.text,delete o["aria-selected"]),o){var a=o[r];i.setAttribute(r,a)}if(n.children){var l=e(i),c=document.createElement("strong");c.className="select2-results__group",e(c),this.template(n,c);for(var d=[],u=0;u<n.children.length;u++){var p=n.children[u],h=this.option(p);d.push(h)}var f=e("<ul></ul>",{class:"select2-results__options select2-results__options--nested"});f.append(d),l.append(c),l.append(f)}else this.template(n,i);return t.StoreData(i,"data",n),i},n.prototype.bind=function(n,i){var o=this,s=n.id+"-results";this.$results.attr("id",s),n.on("results:all",(function(e){o.clear(),o.append(e.data),n.isOpen()&&(o.setClasses(),o.highlightFirstItem())})),n.on("results:append",(function(e){o.append(e.data),n.isOpen()&&o.setClasses()})),n.on("query",(function(e){o.hideMessages(),o.showLoading(e)})),n.on("select",(function(){n.isOpen()&&(o.setClasses(),o.options.get("scrollAfterSelect")&&o.highlightFirstItem())})),n.on("unselect",(function(){n.isOpen()&&(o.setClasses(),o.options.get("scrollAfterSelect")&&o.highlightFirstItem())})),n.on("open",(function(){o.$results.attr("aria-expanded","true"),o.$results.attr("aria-hidden","false"),o.setClasses(),o.ensureHighlightVisible()})),n.on("close",(function(){o.$results.attr("aria-expanded","false"),o.$results.attr("aria-hidden","true"),o.$results.removeAttr("aria-activedescendant")})),n.on("results:toggle",(function(){var e=o.getHighlightedResults();0!==e.length&&e.trigger("mouseup")})),n.on("results:select",(function(){var e=o.getHighlightedResults();if(0!==e.length){var n=t.GetData(e[0],"data");"true"==e.attr("aria-selected")?o.trigger("close",{}):o.trigger("select",{data:n})}})),n.on("results:previous",(function(){var e=o.getHighlightedResults(),t=o.$results.find("[aria-selected]"),n=t.index(e);if(!(n<=0)){var i=n-1;0===e.length&&(i=0);var s=t.eq(i);s.trigger("mouseenter");var r=o.$results.offset().top,a=s.offset().top,l=o.$results.scrollTop()+(a-r);0===i?o.$results.scrollTop(0):a-r<0&&o.$results.scrollTop(l)}})),n.on("results:next",(function(){var e=o.getHighlightedResults(),t=o.$results.find("[aria-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var i=t.eq(n);i.trigger("mouseenter");var s=o.$results.offset().top+o.$results.outerHeight(!1),r=i.offset().top+i.outerHeight(!1),a=o.$results.scrollTop()+r-s;0===n?o.$results.scrollTop(0):r>s&&o.$results.scrollTop(a)}})),n.on("results:focus",(function(e){e.element.addClass("select2-results__option--highlighted")})),n.on("results:message",(function(e){o.displayMessage(e)})),e.fn.mousewheel&&this.$results.on("mousewheel",(function(e){var t=o.$results.scrollTop(),n=o.$results.get(0).scrollHeight-t+e.deltaY,i=e.deltaY>0&&t-e.deltaY<=0,s=e.deltaY<0&&n<=o.$results.height();i?(o.$results.scrollTop(0),e.preventDefault(),e.stopPropagation()):s&&(o.$results.scrollTop(o.$results.get(0).scrollHeight-o.$results.height()),e.preventDefault(),e.stopPropagation())})),this.$results.on("mouseup",".select2-results__option[aria-selected]",(function(n){var i=e(this),s=t.GetData(this,"data");"true"!==i.attr("aria-selected")?o.trigger("select",{originalEvent:n,data:s}):o.options.get("multiple")?o.trigger("unselect",{originalEvent:n,data:s}):o.trigger("close",{})})),this.$results.on("mouseenter",".select2-results__option[aria-selected]",(function(n){var i=t.GetData(this,"data");o.getHighlightedResults().removeClass("select2-results__option--highlighted"),o.trigger("results:focus",{data:i,element:e(this)})}))},n.prototype.getHighlightedResults=function(){return this.$results.find(".select2-results__option--highlighted")},n.prototype.destroy=function(){this.$results.remove()},n.prototype.ensureHighlightVisible=function(){var e=this.getHighlightedResults();if(0!==e.length){var t=this.$results.find("[aria-selected]").index(e),n=this.$results.offset().top,i=e.offset().top,o=this.$results.scrollTop()+(i-n),s=i-n;o-=2*e.outerHeight(!1),t<=2?this.$results.scrollTop(0):(s>this.$results.outerHeight()||s<0)&&this.$results.scrollTop(o)}},n.prototype.template=function(t,n){var i=this.options.get("templateResult"),o=this.options.get("escapeMarkup"),s=i(t,n);null==s?n.style.display="none":"string"==typeof s?n.innerHTML=o(s):e(n).append(s)},n})),t.define("select2/keys",[],(function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}})),t.define("select2/selection/base",["jquery","../utils","../keys"],(function(e,t,n){function i(e,t){this.$element=e,this.options=t,i.__super__.constructor.call(this)}return t.Extend(i,t.Observable),i.prototype.render=function(){var n=e('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=t.GetData(this.$element[0],"old-tabindex")?this._tabindex=t.GetData(this.$element[0],"old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),n.attr("title",this.$element.attr("title")),n.attr("tabindex",this._tabindex),n.attr("aria-disabled","false"),this.$selection=n,n},i.prototype.bind=function(e,t){var i=this,o=e.id+"-results";this.container=e,this.$selection.on("focus",(function(e){i.trigger("focus",e)})),this.$selection.on("blur",(function(e){i._handleBlur(e)})),this.$selection.on("keydown",(function(e){i.trigger("keypress",e),e.which===n.SPACE&&e.preventDefault()})),e.on("results:focus",(function(e){i.$selection.attr("aria-activedescendant",e.data._resultId)})),e.on("selection:update",(function(e){i.update(e.data)})),e.on("open",(function(){i.$selection.attr("aria-expanded","true"),i.$selection.attr("aria-owns",o),i._attachCloseHandler(e)})),e.on("close",(function(){i.$selection.attr("aria-expanded","false"),i.$selection.removeAttr("aria-activedescendant"),i.$selection.removeAttr("aria-owns"),i.$selection.trigger("focus"),i._detachCloseHandler(e)})),e.on("enable",(function(){i.$selection.attr("tabindex",i._tabindex),i.$selection.attr("aria-disabled","false")})),e.on("disable",(function(){i.$selection.attr("tabindex","-1"),i.$selection.attr("aria-disabled","true")}))},i.prototype._handleBlur=function(t){var n=this;window.setTimeout((function(){document.activeElement==n.$selection[0]||e.contains(n.$selection[0],document.activeElement)||n.trigger("blur",t)}),1)},i.prototype._attachCloseHandler=function(n){e(document.body).on("mousedown.select2."+n.id,(function(n){var i=e(n.target).closest(".select2");e(".select2.select2-container--open").each((function(){this!=i[0]&&t.GetData(this,"element").select2("close")}))}))},i.prototype._detachCloseHandler=function(t){e(document.body).off("mousedown.select2."+t.id)},i.prototype.position=function(e,t){t.find(".selection").append(e)},i.prototype.destroy=function(){this._detachCloseHandler(this.container)},i.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},i.prototype.isEnabled=function(){return!this.isDisabled()},i.prototype.isDisabled=function(){return this.options.get("disabled")},i})),t.define("select2/selection/single",["jquery","./base","../utils","../keys"],(function(e,t,n,i){function o(){o.__super__.constructor.apply(this,arguments)}return n.Extend(o,t),o.prototype.render=function(){var e=o.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),e},o.prototype.bind=function(e,t){var n=this;o.__super__.bind.apply(this,arguments);var i=e.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",i).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",i),this.$selection.on("mousedown",(function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})})),this.$selection.on("focus",(function(e){})),this.$selection.on("blur",(function(e){})),e.on("focus",(function(t){e.isOpen()||n.$selection.trigger("focus")}))},o.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},o.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},o.prototype.selectionContainer=function(){return e("<span></span>")},o.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2-selection__rendered"),i=this.display(t,n);n.empty().append(i);var o=t.title||t.text;o?n.attr("title",o):n.removeAttr("title")}else this.clear()},o})),t.define("select2/selection/multiple",["jquery","./base","../utils"],(function(e,t,n){function i(e,t){i.__super__.constructor.apply(this,arguments)}return n.Extend(i,t),i.prototype.render=function(){var e=i.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('<ul class="select2-selection__rendered"></ul>'),e},i.prototype.bind=function(t,o){var s=this;i.__super__.bind.apply(this,arguments),this.$selection.on("click",(function(e){s.trigger("toggle",{originalEvent:e})})),this.$selection.on("click",".select2-selection__choice__remove",(function(t){if(!s.isDisabled()){var i=e(this).parent(),o=n.GetData(i[0],"data");s.trigger("unselect",{originalEvent:t,data:o})}}))},i.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},i.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},i.prototype.selectionContainer=function(){return e('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">×</span></li>')},i.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],i=0;i<e.length;i++){var o=e[i],s=this.selectionContainer(),r=this.display(o,s);s.append(r);var a=o.title||o.text;a&&s.attr("title",a),n.StoreData(s[0],"data",o),t.push(s)}var l=this.$selection.find(".select2-selection__rendered");n.appendMany(l,t)}},i})),t.define("select2/selection/placeholder",["../utils"],(function(e){function t(e,t,n){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n)}return t.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},t.prototype.createPlaceholder=function(e,t){var n=this.selectionContainer();return n.html(this.display(t)),n.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),n},t.prototype.update=function(e,t){var n=1==t.length&&t[0].id!=this.placeholder.id;if(t.length>1||n)return e.call(this,t);this.clear();var i=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(i)},t})),t.define("select2/selection/allowClear",["jquery","../keys","../utils"],(function(e,t,n){function i(){}return i.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",(function(e){i._handleClear(e)})),t.on("keypress",(function(e){i._handleKeyboardClear(e,t)}))},i.prototype._handleClear=function(e,t){if(!this.isDisabled()){var i=this.$selection.find(".select2-selection__clear");if(0!==i.length){t.stopPropagation();var o=n.GetData(i[0],"data"),s=this.$element.val();this.$element.val(this.placeholder.id);var r={data:o};if(this.trigger("clear",r),r.prevented)this.$element.val(s);else{for(var a=0;a<o.length;a++)if(r={data:o[a]},this.trigger("unselect",r),r.prevented)return void this.$element.val(s);this.$element.trigger("input").trigger("change"),this.trigger("toggle",{})}}}},i.prototype._handleKeyboardClear=function(e,n,i){i.isOpen()||n.which!=t.DELETE&&n.which!=t.BACKSPACE||this._handleClear(n)},i.prototype.update=function(t,i){if(t.call(this,i),!(this.$selection.find(".select2-selection__placeholder").length>0||0===i.length)){var o=this.options.get("translations").get("removeAllItems"),s=e('<span class="select2-selection__clear" title="'+o()+'">×</span>');n.StoreData(s[0],"data",i),this.$selection.find(".select2-selection__rendered").prepend(s)}},i})),t.define("select2/selection/search",["jquery","../utils","../keys"],(function(e,t,n){function i(e,t,n){e.call(this,t,n)}return i.prototype.render=function(t){var n=e('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" /></li>');this.$searchContainer=n,this.$search=n.find("input");var i=t.call(this);return this._transferTabIndex(),i},i.prototype.bind=function(e,i,o){var s=this,r=i.id+"-results";e.call(this,i,o),i.on("open",(function(){s.$search.attr("aria-controls",r),s.$search.trigger("focus")})),i.on("close",(function(){s.$search.val(""),s.$search.removeAttr("aria-controls"),s.$search.removeAttr("aria-activedescendant"),s.$search.trigger("focus")})),i.on("enable",(function(){s.$search.prop("disabled",!1),s._transferTabIndex()})),i.on("disable",(function(){s.$search.prop("disabled",!0)})),i.on("focus",(function(e){s.$search.trigger("focus")})),i.on("results:focus",(function(e){e.data._resultId?s.$search.attr("aria-activedescendant",e.data._resultId):s.$search.removeAttr("aria-activedescendant")})),this.$selection.on("focusin",".select2-search--inline",(function(e){s.trigger("focus",e)})),this.$selection.on("focusout",".select2-search--inline",(function(e){s._handleBlur(e)})),this.$selection.on("keydown",".select2-search--inline",(function(e){if(e.stopPropagation(),s.trigger("keypress",e),s._keyUpPrevented=e.isDefaultPrevented(),e.which===n.BACKSPACE&&""===s.$search.val()){var i=s.$searchContainer.prev(".select2-selection__choice");if(i.length>0){var o=t.GetData(i[0],"data");s.searchRemoveChoice(o),e.preventDefault()}}})),this.$selection.on("click",".select2-search--inline",(function(e){s.$search.val()&&e.stopPropagation()}));var a=document.documentMode,l=a&&a<=11;this.$selection.on("input.searchcheck",".select2-search--inline",(function(e){l?s.$selection.off("input.search input.searchcheck"):s.$selection.off("keyup.search")})),this.$selection.on("keyup.search input.search",".select2-search--inline",(function(e){if(l&&"input"===e.type)s.$selection.off("input.search input.searchcheck");else{var t=e.which;t!=n.SHIFT&&t!=n.CTRL&&t!=n.ALT&&t!=n.TAB&&s.handleSearch(e)}}))},i.prototype._transferTabIndex=function(e){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},i.prototype.createPlaceholder=function(e,t){this.$search.attr("placeholder",t.text)},i.prototype.update=function(e,t){var n=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),e.call(this,t),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),n&&this.$search.trigger("focus")},i.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var e=this.$search.val();this.trigger("query",{term:e})}this._keyUpPrevented=!1},i.prototype.searchRemoveChoice=function(e,t){this.trigger("unselect",{data:t}),this.$search.val(t.text),this.handleSearch()},i.prototype.resizeSearch=function(){this.$search.css("width","25px");var e;e=""!==this.$search.attr("placeholder")?this.$selection.find(".select2-selection__rendered").width():.75*(this.$search.val().length+1)+"em",this.$search.css("width",e)},i})),t.define("select2/selection/eventRelay",["jquery"],(function(e){function t(){}return t.prototype.bind=function(t,n,i){var o=this,s=["open","opening","close","closing","select","selecting","unselect","unselecting","clear","clearing"],r=["opening","closing","selecting","unselecting","clearing"];t.call(this,n,i),n.on("*",(function(t,n){if(-1!==e.inArray(t,s)){n=n||{};var i=e.Event("select2:"+t,{params:n});o.$element.trigger(i),-1!==e.inArray(t,r)&&(n.prevented=i.isDefaultPrevented())}}))},t})),t.define("select2/translation",["jquery","require"],(function(e,t){function n(e){this.dict=e||{}}return n.prototype.all=function(){return this.dict},n.prototype.get=function(e){return this.dict[e]},n.prototype.extend=function(t){this.dict=e.extend({},t.all(),this.dict)},n._cache={},n.loadPath=function(e){if(!(e in n._cache)){var i=t(e);n._cache[e]=i}return new n(n._cache[e])},n})),t.define("select2/diacritics",[],(function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Œ":"OE","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","œ":"oe","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ώ":"ω","ς":"σ","’":"'"}})),t.define("select2/data/base",["../utils"],(function(e){function t(e,n){t.__super__.constructor.call(this)}return e.Extend(t,e.Observable),t.prototype.current=function(e){throw new Error("The `current` method must be defined in child classes.")},t.prototype.query=function(e,t){throw new Error("The `query` method must be defined in child classes.")},t.prototype.bind=function(e,t){},t.prototype.destroy=function(){},t.prototype.generateResultId=function(t,n){var i=t.id+"-result-";return i+=e.generateChars(4),null!=n.id?i+="-"+n.id.toString():i+="-"+e.generateChars(4),i},t})),t.define("select2/data/select",["./base","../utils","jquery"],(function(e,t,n){function i(e,t){this.$element=e,this.options=t,i.__super__.constructor.call(this)}return t.Extend(i,e),i.prototype.current=function(e){var t=[],i=this;this.$element.find(":selected").each((function(){var e=n(this),o=i.item(e);t.push(o)})),e(t)},i.prototype.select=function(e){var t=this;if(e.selected=!0,n(e.element).is("option"))return e.element.selected=!0,void this.$element.trigger("input").trigger("change");if(this.$element.prop("multiple"))this.current((function(i){var o=[];(e=[e]).push.apply(e,i);for(var s=0;s<e.length;s++){var r=e[s].id;-1===n.inArray(r,o)&&o.push(r)}t.$element.val(o),t.$element.trigger("input").trigger("change")}));else{var i=e.id;this.$element.val(i),this.$element.trigger("input").trigger("change")}},i.prototype.unselect=function(e){var t=this;if(this.$element.prop("multiple")){if(e.selected=!1,n(e.element).is("option"))return e.element.selected=!1,void this.$element.trigger("input").trigger("change");this.current((function(i){for(var o=[],s=0;s<i.length;s++){var r=i[s].id;r!==e.id&&-1===n.inArray(r,o)&&o.push(r)}t.$element.val(o),t.$element.trigger("input").trigger("change")}))}},i.prototype.bind=function(e,t){var n=this;this.container=e,e.on("select",(function(e){n.select(e.data)})),e.on("unselect",(function(e){n.unselect(e.data)}))},i.prototype.destroy=function(){this.$element.find("*").each((function(){t.RemoveData(this)}))},i.prototype.query=function(e,t){var i=[],o=this;this.$element.children().each((function(){var t=n(this);if(t.is("option")||t.is("optgroup")){var s=o.item(t),r=o.matches(e,s);null!==r&&i.push(r)}})),t({results:i})},i.prototype.addOptions=function(e){t.appendMany(this.$element,e)},i.prototype.option=function(e){var i;e.children?(i=document.createElement("optgroup")).label=e.text:void 0!==(i=document.createElement("option")).textContent?i.textContent=e.text:i.innerText=e.text,void 0!==e.id&&(i.value=e.id),e.disabled&&(i.disabled=!0),e.selected&&(i.selected=!0),e.title&&(i.title=e.title);var o=n(i),s=this._normalizeItem(e);return s.element=i,t.StoreData(i,"data",s),o},i.prototype.item=function(e){var i={};if(null!=(i=t.GetData(e[0],"data")))return i;if(e.is("option"))i={id:e.val(),text:e.text(),disabled:e.prop("disabled"),selected:e.prop("selected"),title:e.prop("title")};else if(e.is("optgroup")){i={text:e.prop("label"),children:[],title:e.prop("title")};for(var o=e.children("option"),s=[],r=0;r<o.length;r++){var a=n(o[r]),l=this.item(a);s.push(l)}i.children=s}return(i=this._normalizeItem(i)).element=e[0],t.StoreData(e[0],"data",i),i},i.prototype._normalizeItem=function(e){e!==Object(e)&&(e={id:e,text:e});return null!=(e=n.extend({},{text:""},e)).id&&(e.id=e.id.toString()),null!=e.text&&(e.text=e.text.toString()),null==e._resultId&&e.id&&null!=this.container&&(e._resultId=this.generateResultId(this.container,e)),n.extend({},{selected:!1,disabled:!1},e)},i.prototype.matches=function(e,t){return this.options.get("matcher")(e,t)},i})),t.define("select2/data/array",["./select","../utils","jquery"],(function(e,t,n){function i(e,t){this._dataToConvert=t.get("data")||[],i.__super__.constructor.call(this,e,t)}return t.Extend(i,e),i.prototype.bind=function(e,t){i.__super__.bind.call(this,e,t),this.addOptions(this.convertToOptions(this._dataToConvert))},i.prototype.select=function(e){var t=this.$element.find("option").filter((function(t,n){return n.value==e.id.toString()}));0===t.length&&(t=this.option(e),this.addOptions(t)),i.__super__.select.call(this,e)},i.prototype.convertToOptions=function(e){var i=this,o=this.$element.find("option"),s=o.map((function(){return i.item(n(this)).id})).get(),r=[];function a(e){return function(){return n(this).val()==e.id}}for(var l=0;l<e.length;l++){var c=this._normalizeItem(e[l]);if(n.inArray(c.id,s)>=0){var d=o.filter(a(c)),u=this.item(d),p=n.extend(!0,{},c,u),h=this.option(p);d.replaceWith(h)}else{var f=this.option(c);if(c.children){var g=this.convertToOptions(c.children);t.appendMany(f,g)}r.push(f)}}return r},i})),t.define("select2/data/ajax",["./array","../utils","jquery"],(function(e,t,n){function i(e,t){this.ajaxOptions=this._applyDefaults(t.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),i.__super__.constructor.call(this,e,t)}return t.Extend(i,e),i.prototype._applyDefaults=function(e){var t={data:function(e){return n.extend({},e,{q:e.term})},transport:function(e,t,i){var o=n.ajax(e);return o.then(t),o.fail(i),o}};return n.extend({},t,e,!0)},i.prototype.processResults=function(e){return e},i.prototype.query=function(e,t){var i=this;null!=this._request&&(n.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var o=n.extend({type:"GET"},this.ajaxOptions);function s(){var s=o.transport(o,(function(o){var s=i.processResults(o,e);i.options.get("debug")&&window.console&&console.error&&(s&&s.results&&n.isArray(s.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),t(s)}),(function(){(!("status"in s)||0!==s.status&&"0"!==s.status)&&i.trigger("results:message",{message:"errorLoading"})}));i._request=s}"function"==typeof o.url&&(o.url=o.url.call(this.$element,e)),"function"==typeof o.data&&(o.data=o.data.call(this.$element,e)),this.ajaxOptions.delay&&null!=e.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(s,this.ajaxOptions.delay)):s()},i})),t.define("select2/data/tags",["jquery"],(function(e){function t(t,n,i){var o=i.get("tags"),s=i.get("createTag");void 0!==s&&(this.createTag=s);var r=i.get("insertTag");if(void 0!==r&&(this.insertTag=r),t.call(this,n,i),e.isArray(o))for(var a=0;a<o.length;a++){var l=o[a],c=this._normalizeItem(l),d=this.option(c);this.$element.append(d)}}return t.prototype.query=function(e,t,n){var i=this;this._removeOldTags(),null!=t.term&&null==t.page?e.call(this,t,(function e(o,s){for(var r=o.results,a=0;a<r.length;a++){var l=r[a],c=null!=l.children&&!e({results:l.children},!0);if((l.text||"").toUpperCase()===(t.term||"").toUpperCase()||c)return!s&&(o.data=r,void n(o))}if(s)return!0;var d=i.createTag(t);if(null!=d){var u=i.option(d);u.attr("data-select2-tag",!0),i.addOptions([u]),i.insertTag(r,d)}o.results=r,n(o)})):e.call(this,t,n)},t.prototype.createTag=function(t,n){var i=e.trim(n.term);return""===i?null:{id:i,text:i}},t.prototype.insertTag=function(e,t,n){t.unshift(n)},t.prototype._removeOldTags=function(t){this.$element.find("option[data-select2-tag]").each((function(){this.selected||e(this).remove()}))},t})),t.define("select2/data/tokenizer",["jquery"],(function(e){function t(e,t,n){var i=n.get("tokenizer");void 0!==i&&(this.tokenizer=i),e.call(this,t,n)}return t.prototype.bind=function(e,t,n){e.call(this,t,n),this.$search=t.dropdown.$search||t.selection.$search||n.find(".select2-search__field")},t.prototype.query=function(t,n,i){var o=this;n.term=n.term||"";var s=this.tokenizer(n,this.options,(function(t){var n=o._normalizeItem(t);if(!o.$element.find("option").filter((function(){return e(this).val()===n.id})).length){var i=o.option(n);i.attr("data-select2-tag",!0),o._removeOldTags(),o.addOptions([i])}!function(e){o.trigger("select",{data:e})}(n)}));s.term!==n.term&&(this.$search.length&&(this.$search.val(s.term),this.$search.trigger("focus")),n.term=s.term),t.call(this,n,i)},t.prototype.tokenizer=function(t,n,i,o){for(var s=i.get("tokenSeparators")||[],r=n.term,a=0,l=this.createTag||function(e){return{id:e.term,text:e.term}};a<r.length;){var c=r[a];if(-1!==e.inArray(c,s)){var d=r.substr(0,a),u=l(e.extend({},n,{term:d}));null!=u?(o(u),r=r.substr(a+1)||"",a=0):a++}else a++}return{term:r}},t})),t.define("select2/data/minimumInputLength",[],(function(){function e(e,t,n){this.minimumInputLength=n.get("minimumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",t.term.length<this.minimumInputLength?this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e})),t.define("select2/data/maximumInputLength",[],(function(){function e(e,t,n){this.maximumInputLength=n.get("maximumInputLength"),e.call(this,t,n)}return e.prototype.query=function(e,t,n){t.term=t.term||"",this.maximumInputLength>0&&t.term.length>this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e})),t.define("select2/data/maximumSelectionLength",[],(function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("select",(function(){i._checkIfMaximumSelected()}))},e.prototype.query=function(e,t,n){var i=this;this._checkIfMaximumSelected((function(){e.call(i,t,n)}))},e.prototype._checkIfMaximumSelected=function(e,t){var n=this;this.current((function(e){var i=null!=e?e.length:0;n.maximumSelectionLength>0&&i>=n.maximumSelectionLength?n.trigger("results:message",{message:"maximumSelected",args:{maximum:n.maximumSelectionLength}}):t&&t()}))},e})),t.define("select2/dropdown",["jquery","./utils"],(function(e,t){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return t.Extend(n,t.Observable),n.prototype.render=function(){var t=e('<span class="select2-dropdown"><span class="select2-results"></span></span>');return t.attr("dir",this.options.get("dir")),this.$dropdown=t,t},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n})),t.define("select2/dropdown/search",["jquery","../utils"],(function(e,t){function n(){}return n.prototype.render=function(t){var n=t.call(this),i=e('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" /></span>');return this.$searchContainer=i,this.$search=i.find("input"),n.prepend(i),n},n.prototype.bind=function(t,n,i){var o=this,s=n.id+"-results";t.call(this,n,i),this.$search.on("keydown",(function(e){o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented()})),this.$search.on("input",(function(t){e(this).off("keyup")})),this.$search.on("keyup input",(function(e){o.handleSearch(e)})),n.on("open",(function(){o.$search.attr("tabindex",0),o.$search.attr("aria-controls",s),o.$search.trigger("focus"),window.setTimeout((function(){o.$search.trigger("focus")}),0)})),n.on("close",(function(){o.$search.attr("tabindex",-1),o.$search.removeAttr("aria-controls"),o.$search.removeAttr("aria-activedescendant"),o.$search.val(""),o.$search.trigger("blur")})),n.on("focus",(function(){n.isOpen()||o.$search.trigger("focus")})),n.on("results:all",(function(e){null!=e.query.term&&""!==e.query.term||(o.showSearch(e)?o.$searchContainer.removeClass("select2-search--hide"):o.$searchContainer.addClass("select2-search--hide"))})),n.on("results:focus",(function(e){e.data._resultId?o.$search.attr("aria-activedescendant",e.data._resultId):o.$search.removeAttr("aria-activedescendant")}))},n.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},n.prototype.showSearch=function(e,t){return!0},n})),t.define("select2/dropdown/hidePlaceholder",[],(function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;i>=0;i--){var o=t[i];this.placeholder.id===o.id&&n.splice(i,1)}return n},e})),t.define("select2/dropdown/infiniteScroll",["jquery"],(function(e){function t(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return t.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&(this.$results.append(this.$loadingMore),this.loadMoreIfNeeded())},t.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",(function(e){i.lastParams=e,i.loading=!0})),t.on("query:append",(function(e){i.lastParams=e,i.loading=!0})),this.$results.on("scroll",this.loadMoreIfNeeded.bind(this))},t.prototype.loadMoreIfNeeded=function(){var t=e.contains(document.documentElement,this.$loadingMore[0]);!this.loading&&t&&this.$results.offset().top+this.$results.outerHeight(!1)+50>=this.$loadingMore.offset().top+this.$loadingMore.outerHeight(!1)&&this.loadMore()},t.prototype.loadMore=function(){this.loading=!0;var t=e.extend({},{page:1},this.lastParams);t.page++,this.trigger("query:append",t)},t.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},t.prototype.createLoadingMore=function(){var t=e('<li class="select2-results__option select2-results__option--load-more"role="option" aria-disabled="true"></li>'),n=this.options.get("translations").get("loadingMore");return t.html(n(this.lastParams)),t},t})),t.define("select2/dropdown/attachBody",["jquery","../utils"],(function(e,t){function n(t,n,i){this.$dropdownParent=e(i.get("dropdownParent")||document.body),t.call(this,n,i)}return n.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("open",(function(){i._showDropdown(),i._attachPositioningHandler(t),i._bindContainerResultHandlers(t)})),t.on("close",(function(){i._hideDropdown(),i._detachPositioningHandler(t)})),this.$dropdownContainer.on("mousedown",(function(e){e.stopPropagation()}))},n.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},n.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},n.prototype.render=function(t){var n=e("<span></span>"),i=t.call(this);return n.append(i),this.$dropdownContainer=n,n},n.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},n.prototype._bindContainerResultHandlers=function(e,t){if(!this._containerResultsHandlersBound){var n=this;t.on("results:all",(function(){n._positionDropdown(),n._resizeDropdown()})),t.on("results:append",(function(){n._positionDropdown(),n._resizeDropdown()})),t.on("results:message",(function(){n._positionDropdown(),n._resizeDropdown()})),t.on("select",(function(){n._positionDropdown(),n._resizeDropdown()})),t.on("unselect",(function(){n._positionDropdown(),n._resizeDropdown()})),this._containerResultsHandlersBound=!0}},n.prototype._attachPositioningHandler=function(n,i){var o=this,s="scroll.select2."+i.id,r="resize.select2."+i.id,a="orientationchange.select2."+i.id,l=this.$container.parents().filter(t.hasScroll);l.each((function(){t.StoreData(this,"select2-scroll-position",{x:e(this).scrollLeft(),y:e(this).scrollTop()})})),l.on(s,(function(n){var i=t.GetData(this,"select2-scroll-position");e(this).scrollTop(i.y)})),e(window).on(s+" "+r+" "+a,(function(e){o._positionDropdown(),o._resizeDropdown()}))},n.prototype._detachPositioningHandler=function(n,i){var o="scroll.select2."+i.id,s="resize.select2."+i.id,r="orientationchange.select2."+i.id;this.$container.parents().filter(t.hasScroll).off(o),e(window).off(o+" "+s+" "+r)},n.prototype._positionDropdown=function(){var t=e(window),n=this.$dropdown.hasClass("select2-dropdown--above"),i=this.$dropdown.hasClass("select2-dropdown--below"),o=null,s=this.$container.offset();s.bottom=s.top+this.$container.outerHeight(!1);var r={height:this.$container.outerHeight(!1)};r.top=s.top,r.bottom=s.top+r.height;var a=this.$dropdown.outerHeight(!1),l=t.scrollTop(),c=t.scrollTop()+t.height(),d=l<s.top-a,u=c>s.bottom+a,p={left:s.left,top:r.bottom},h=this.$dropdownParent;"static"===h.css("position")&&(h=h.offsetParent());var f={top:0,left:0};(e.contains(document.body,h[0])||h[0].isConnected)&&(f=h.offset()),p.top-=f.top,p.left-=f.left,n||i||(o="below"),u||!d||n?!d&&u&&n&&(o="below"):o="above",("above"==o||n&&"below"!==o)&&(p.top=r.top-f.top-a),null!=o&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+o),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+o)),this.$dropdownContainer.css(p)},n.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},n.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},n})),t.define("select2/dropdown/minimumResultsForSearch",[],(function(){function e(t){for(var n=0,i=0;i<t.length;i++){var o=t[i];o.children?n+=e(o.children):n++}return n}function t(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,i)}return t.prototype.showSearch=function(t,n){return!(e(n.data.results)<this.minimumResultsForSearch)&&t.call(this,n)},t})),t.define("select2/dropdown/selectOnClose",["../utils"],(function(e){function t(){}return t.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("close",(function(e){i._handleSelectOnClose(e)}))},t.prototype._handleSelectOnClose=function(t,n){if(n&&null!=n.originalSelect2Event){var i=n.originalSelect2Event;if("select"===i._type||"unselect"===i._type)return}var o=this.getHighlightedResults();if(!(o.length<1)){var s=e.GetData(o[0],"data");null!=s.element&&s.element.selected||null==s.element&&s.selected||this.trigger("select",{data:s})}},t})),t.define("select2/dropdown/closeOnSelect",[],(function(){function e(){}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("select",(function(e){i._selectTriggered(e)})),t.on("unselect",(function(e){i._selectTriggered(e)}))},e.prototype._selectTriggered=function(e,t){var n=t.originalEvent;n&&(n.ctrlKey||n.metaKey)||this.trigger("close",{originalEvent:n,originalSelect2Event:t})},e})),t.define("select2/i18n/en",[],(function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Please delete "+t+" character";return 1!=t&&(n+="s"),n},inputTooShort:function(e){return"Please enter "+(e.minimum-e.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(e){var t="You can only select "+e.maximum+" item";return 1!=e.maximum&&(t+="s"),t},noResults:function(){return"No results found"},searching:function(){return"Searching…"},removeAllItems:function(){return"Remove all items"}}})),t.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],(function(e,t,n,i,o,s,r,a,l,c,d,u,p,h,f,g,_,m,v,w,y,b,$,x,C,A,D,E,S){function k(){this.reset()}return k.prototype.apply=function(d){if(null==(d=e.extend(!0,{},this.defaults,d)).dataAdapter){if(null!=d.ajax?d.dataAdapter=f:null!=d.data?d.dataAdapter=h:d.dataAdapter=p,d.minimumInputLength>0&&(d.dataAdapter=c.Decorate(d.dataAdapter,m)),d.maximumInputLength>0&&(d.dataAdapter=c.Decorate(d.dataAdapter,v)),d.maximumSelectionLength>0&&(d.dataAdapter=c.Decorate(d.dataAdapter,w)),d.tags&&(d.dataAdapter=c.Decorate(d.dataAdapter,g)),null==d.tokenSeparators&&null==d.tokenizer||(d.dataAdapter=c.Decorate(d.dataAdapter,_)),null!=d.query){var u=t(d.amdBase+"compat/query");d.dataAdapter=c.Decorate(d.dataAdapter,u)}if(null!=d.initSelection){var S=t(d.amdBase+"compat/initSelection");d.dataAdapter=c.Decorate(d.dataAdapter,S)}}if(null==d.resultsAdapter&&(d.resultsAdapter=n,null!=d.ajax&&(d.resultsAdapter=c.Decorate(d.resultsAdapter,x)),null!=d.placeholder&&(d.resultsAdapter=c.Decorate(d.resultsAdapter,$)),d.selectOnClose&&(d.resultsAdapter=c.Decorate(d.resultsAdapter,D))),null==d.dropdownAdapter){if(d.multiple)d.dropdownAdapter=y;else{var k=c.Decorate(y,b);d.dropdownAdapter=k}if(0!==d.minimumResultsForSearch&&(d.dropdownAdapter=c.Decorate(d.dropdownAdapter,A)),d.closeOnSelect&&(d.dropdownAdapter=c.Decorate(d.dropdownAdapter,E)),null!=d.dropdownCssClass||null!=d.dropdownCss||null!=d.adaptDropdownCssClass){var O=t(d.amdBase+"compat/dropdownCss");d.dropdownAdapter=c.Decorate(d.dropdownAdapter,O)}d.dropdownAdapter=c.Decorate(d.dropdownAdapter,C)}if(null==d.selectionAdapter){if(d.multiple?d.selectionAdapter=o:d.selectionAdapter=i,null!=d.placeholder&&(d.selectionAdapter=c.Decorate(d.selectionAdapter,s)),d.allowClear&&(d.selectionAdapter=c.Decorate(d.selectionAdapter,r)),d.multiple&&(d.selectionAdapter=c.Decorate(d.selectionAdapter,a)),null!=d.containerCssClass||null!=d.containerCss||null!=d.adaptContainerCssClass){var T=t(d.amdBase+"compat/containerCss");d.selectionAdapter=c.Decorate(d.selectionAdapter,T)}d.selectionAdapter=c.Decorate(d.selectionAdapter,l)}d.language=this._resolveLanguage(d.language),d.language.push("en");for(var j=[],P=0;P<d.language.length;P++){var q=d.language[P];-1===j.indexOf(q)&&j.push(q)}return d.language=j,d.translations=this._processTranslations(d.language,d.debug),d},k.prototype.reset=function(){function t(e){return e.replace(/[^\u0000-\u007E]/g,(function(e){return u[e]||e}))}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:c.escapeMarkup,language:{},matcher:function n(i,o){if(""===e.trim(i.term))return o;if(o.children&&o.children.length>0){for(var s=e.extend(!0,{},o),r=o.children.length-1;r>=0;r--)null==n(i,o.children[r])&&s.children.splice(r,1);return s.children.length>0?s:n(i,s)}var a=t(o.text).toUpperCase(),l=t(i.term).toUpperCase();return a.indexOf(l)>-1?o:null},minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,scrollAfterSelect:!1,sorter:function(e){return e},templateResult:function(e){return e.text},templateSelection:function(e){return e.text},theme:"default",width:"resolve"}},k.prototype.applyFromElement=function(e,t){var n=e.language,i=this.defaults.language,o=t.prop("lang"),s=t.closest("[lang]").prop("lang"),r=Array.prototype.concat.call(this._resolveLanguage(o),this._resolveLanguage(n),this._resolveLanguage(i),this._resolveLanguage(s));return e.language=r,e},k.prototype._resolveLanguage=function(t){if(!t)return[];if(e.isEmptyObject(t))return[];if(e.isPlainObject(t))return[t];var n;n=e.isArray(t)?t:[t];for(var i=[],o=0;o<n.length;o++)if(i.push(n[o]),"string"==typeof n[o]&&n[o].indexOf("-")>0){var s=n[o].split("-")[0];i.push(s)}return i},k.prototype._processTranslations=function(t,n){for(var i=new d,o=0;o<t.length;o++){var s=new d,r=t[o];if("string"==typeof r)try{s=d.loadPath(r)}catch(e){try{r=this.defaults.amdLanguageBase+r,s=d.loadPath(r)}catch(e){n&&window.console&&console.warn&&console.warn('Select2: The language file for "'+r+'" could not be automatically loaded. A fallback will be used instead.')}}else s=e.isPlainObject(r)?new d(r):r;i.extend(s)}return i},k.prototype.set=function(t,n){var i={};i[e.camelCase(t)]=n;var o=c._convertData(i);e.extend(!0,this.defaults,o)},new k})),t.define("select2/options",["require","jquery","./defaults","./utils"],(function(e,t,n,i){function o(t,o){if(this.options=t,null!=o&&this.fromElement(o),null!=o&&(this.options=n.applyFromElement(this.options,o)),this.options=n.apply(this.options),o&&o.is("input")){var s=e(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=i.Decorate(this.options.dataAdapter,s)}}return o.prototype.fromElement=function(e){var n=["select2"];null==this.options.multiple&&(this.options.multiple=e.prop("multiple")),null==this.options.disabled&&(this.options.disabled=e.prop("disabled")),null==this.options.dir&&(e.prop("dir")?this.options.dir=e.prop("dir"):e.closest("[dir]").prop("dir")?this.options.dir=e.closest("[dir]").prop("dir"):this.options.dir="ltr"),e.prop("disabled",this.options.disabled),e.prop("multiple",this.options.multiple),i.GetData(e[0],"select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),i.StoreData(e[0],"data",i.GetData(e[0],"select2Tags")),i.StoreData(e[0],"tags",!0)),i.GetData(e[0],"ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),e.attr("ajax--url",i.GetData(e[0],"ajaxUrl")),i.StoreData(e[0],"ajax-Url",i.GetData(e[0],"ajaxUrl")));var o={};function s(e,t){return t.toUpperCase()}for(var r=0;r<e[0].attributes.length;r++){var a=e[0].attributes[r].name,l="data-";if(a.substr(0,l.length)==l){var c=a.substring(l.length),d=i.GetData(e[0],c);o[c.replace(/-([a-z])/g,s)]=d}}t.fn.jquery&&"1."==t.fn.jquery.substr(0,2)&&e[0].dataset&&(o=t.extend(!0,{},e[0].dataset,o));var u=t.extend(!0,{},i.GetData(e[0]),o);for(var p in u=i._convertData(u))t.inArray(p,n)>-1||(t.isPlainObject(this.options[p])?t.extend(this.options[p],u[p]):this.options[p]=u[p]);return this},o.prototype.get=function(e){return this.options[e]},o.prototype.set=function(e,t){this.options[e]=t},o})),t.define("select2/core",["jquery","./options","./utils","./keys"],(function(e,t,n,i){var o=function(e,i){null!=n.GetData(e[0],"select2")&&n.GetData(e[0],"select2").destroy(),this.$element=e,this.id=this._generateId(e),i=i||{},this.options=new t(i,e),o.__super__.constructor.call(this);var s=e.attr("tabindex")||0;n.StoreData(e[0],"old-tabindex",s),e.attr("tabindex","-1");var r=this.options.get("dataAdapter");this.dataAdapter=new r(e,this.options);var a=this.render();this._placeContainer(a);var l=this.options.get("selectionAdapter");this.selection=new l(e,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,a);var c=this.options.get("dropdownAdapter");this.dropdown=new c(e,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,a);var d=this.options.get("resultsAdapter");this.results=new d(e,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var u=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current((function(e){u.trigger("selection:update",{data:e})})),e.addClass("select2-hidden-accessible"),e.attr("aria-hidden","true"),this._syncAttributes(),n.StoreData(e[0],"select2",this),e.data("select2",this)};return n.Extend(o,n.Observable),o.prototype._generateId=function(e){return"select2-"+(null!=e.attr("id")?e.attr("id"):null!=e.attr("name")?e.attr("name")+"-"+n.generateChars(2):n.generateChars(4)).replace(/(:|\.|\[|\]|,)/g,"")},o.prototype._placeContainer=function(e){e.insertAfter(this.$element);var t=this._resolveWidth(this.$element,this.options.get("width"));null!=t&&e.css("width",t)},o.prototype._resolveWidth=function(e,t){var n=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==t){var i=this._resolveWidth(e,"style");return null!=i?i:this._resolveWidth(e,"element")}if("element"==t){var o=e.outerWidth(!1);return o<=0?"auto":o+"px"}if("style"==t){var s=e.attr("style");if("string"!=typeof s)return null;for(var r=s.split(";"),a=0,l=r.length;a<l;a+=1){var c=r[a].replace(/\s/g,"").match(n);if(null!==c&&c.length>=1)return c[1]}return null}return"computedstyle"==t?window.getComputedStyle(e[0]).width:t},o.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},o.prototype._registerDomEvents=function(){var e=this;this.$element.on("change.select2",(function(){e.dataAdapter.current((function(t){e.trigger("selection:update",{data:t})}))})),this.$element.on("focus.select2",(function(t){e.trigger("focus",t)})),this._syncA=n.bind(this._syncAttributes,this),this._syncS=n.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var t=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=t?(this._observer=new t((function(t){e._syncA(),e._syncS(null,t)})),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",e._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",e._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",e._syncS,!1))},o.prototype._registerDataEvents=function(){var e=this;this.dataAdapter.on("*",(function(t,n){e.trigger(t,n)}))},o.prototype._registerSelectionEvents=function(){var t=this,n=["toggle","focus"];this.selection.on("toggle",(function(){t.toggleDropdown()})),this.selection.on("focus",(function(e){t.focus(e)})),this.selection.on("*",(function(i,o){-1===e.inArray(i,n)&&t.trigger(i,o)}))},o.prototype._registerDropdownEvents=function(){var e=this;this.dropdown.on("*",(function(t,n){e.trigger(t,n)}))},o.prototype._registerResultsEvents=function(){var e=this;this.results.on("*",(function(t,n){e.trigger(t,n)}))},o.prototype._registerEvents=function(){var e=this;this.on("open",(function(){e.$container.addClass("select2-container--open")})),this.on("close",(function(){e.$container.removeClass("select2-container--open")})),this.on("enable",(function(){e.$container.removeClass("select2-container--disabled")})),this.on("disable",(function(){e.$container.addClass("select2-container--disabled")})),this.on("blur",(function(){e.$container.removeClass("select2-container--focus")})),this.on("query",(function(t){e.isOpen()||e.trigger("open",{}),this.dataAdapter.query(t,(function(n){e.trigger("results:all",{data:n,query:t})}))})),this.on("query:append",(function(t){this.dataAdapter.query(t,(function(n){e.trigger("results:append",{data:n,query:t})}))})),this.on("keypress",(function(t){var n=t.which;e.isOpen()?n===i.ESC||n===i.TAB||n===i.UP&&t.altKey?(e.close(t),t.preventDefault()):n===i.ENTER?(e.trigger("results:select",{}),t.preventDefault()):n===i.SPACE&&t.ctrlKey?(e.trigger("results:toggle",{}),t.preventDefault()):n===i.UP?(e.trigger("results:previous",{}),t.preventDefault()):n===i.DOWN&&(e.trigger("results:next",{}),t.preventDefault()):(n===i.ENTER||n===i.SPACE||n===i.DOWN&&t.altKey)&&(e.open(),t.preventDefault())}))},o.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.isDisabled()?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},o.prototype._isChangeMutation=function(t,n){var i=!1,o=this;if(!t||!t.target||"OPTION"===t.target.nodeName||"OPTGROUP"===t.target.nodeName){if(n)if(n.addedNodes&&n.addedNodes.length>0)for(var s=0;s<n.addedNodes.length;s++)n.addedNodes[s].selected&&(i=!0);else n.removedNodes&&n.removedNodes.length>0?i=!0:e.isArray(n)&&e.each(n,(function(e,t){if(o._isChangeMutation(e,t))return i=!0,!1}));else i=!0;return i}},o.prototype._syncSubtree=function(e,t){var n=this._isChangeMutation(e,t),i=this;n&&this.dataAdapter.current((function(e){i.trigger("selection:update",{data:e})}))},o.prototype.trigger=function(e,t){var n=o.__super__.trigger,i={open:"opening",close:"closing",select:"selecting",unselect:"unselecting",clear:"clearing"};if(void 0===t&&(t={}),e in i){var s=i[e],r={prevented:!1,name:e,args:t};if(n.call(this,s,r),r.prevented)return void(t.prevented=!0)}n.call(this,e,t)},o.prototype.toggleDropdown=function(){this.isDisabled()||(this.isOpen()?this.close():this.open())},o.prototype.open=function(){this.isOpen()||this.isDisabled()||this.trigger("query",{})},o.prototype.close=function(e){this.isOpen()&&this.trigger("close",{originalEvent:e})},o.prototype.isEnabled=function(){return!this.isDisabled()},o.prototype.isDisabled=function(){return this.options.get("disabled")},o.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},o.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},o.prototype.focus=function(e){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},o.prototype.enable=function(e){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),null!=e&&0!==e.length||(e=[!0]);var t=!e[0];this.$element.prop("disabled",t)},o.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var e=[];return this.dataAdapter.current((function(t){e=t})),e},o.prototype.val=function(t){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==t||0===t.length)return this.$element.val();var n=t[0];e.isArray(n)&&(n=e.map(n,(function(e){return e.toString()}))),this.$element.val(n).trigger("input").trigger("change")},o.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",n.GetData(this.$element[0],"old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),n.RemoveData(this.$element[0]),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},o.prototype.render=function(){var t=e('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return t.attr("dir",this.options.get("dir")),this.$container=t,this.$container.addClass("select2-container--"+this.options.get("theme")),n.StoreData(t[0],"element",this.$element),t},o})),t.define("jquery-mousewheel",["jquery"],(function(e){return e})),t.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults","./select2/utils"],(function(e,t,n,i,o){if(null==e.fn.select2){var s=["open","close","destroy"];e.fn.select2=function(t){if("object"==typeof(t=t||{}))return this.each((function(){var i=e.extend(!0,{},t);new n(e(this),i)})),this;if("string"==typeof t){var i,r=Array.prototype.slice.call(arguments,1);return this.each((function(){var e=o.GetData(this,"select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),i=e[t].apply(e,r)})),e.inArray(t,s)>-1?this:i}throw new Error("Invalid arguments for Select2: "+t)}}return null==e.fn.select2.defaults&&(e.fn.select2.defaults=i),n})),{define:t.define,require:t.require}}(),n=t.require("jquery.select2");return e.fn.select2.amd=t,n},void 0===(s=i.apply(t,o))||(e.exports=s)},567:function(e){"use strict";e.exports=window.jQuery}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}!function(){"use strict";n(233),n(686);const e=window.WPCodeSnippetManager||function(e,t,n){const i={editor_id:"wpcode_snippet_code",unload_set:!1,init:function(){i.should_init()&&(i.find_elements(),i.init_snippet_type_switcher(),i.init_auto_insert_toggle(),i.init_dynamic_hide(),i.init_copy_target(),i.init_tags_picker(),i.init_metabox_toggler(),i.init_select2(),i.init_tinymce_listener(),i.unload_change_listener())},should_init:function(){return void 0!==t.wpcode_editor&&null!==e.getElementById(i.editor_id)},find_elements(){i.location_dropdown=n("#wpcode_auto_insert_location"),i.switcher=n(e.getElementById("wpcode_snippet_type")),i.$body=n("body"),i.$text_editor=tinymce.get("wpcode_snippet_text")},init_snippet_type_switcher:function(){i.switcher.on("change",(function(){i.set_before_unload(),t.WPCodeAdminCodeEditor.switch_code_mode(n(this).val(),n(this).find(":selected").data("mode"),n(this).find(":selected").data("lint")),"text"===i.switcher.val()?(i.$body.addClass("wpcode-show-tinymce"),i.$text_editor.setContent(t.WPCodeAdminCodeEditor.get_value())):(i.$body.removeClass("wpcode-show-tinymce"),t.WPCodeAdminCodeEditor.refresh()),i.update_available_locations(i.switcher.val())}))},update_available_locations(e){const t=i.location_dropdown.find("optgroup");t.find("option").prop("disabled",!1).prop("selected",!1);const o=t.filter((function(){const t=n(this).data("code-type");return"all"!==t&&e!==t}));o.length>0&&o.find("option").prop("disabled",!0).prop("selected",!1)},init_auto_insert_toggle:function(){const t={toggles:"",init:function(){t.toggles=n(e.querySelectorAll(".wpcode-button-toggle")),t.listen_to_switch()},listen_to_switch:function(){t.toggles.each((function(){const e=n(this).find(".wpcode-button-toggle-input");n(this).on("click",".wpcode-button",(function(o){o.preventDefault(),i.set_before_unload(),e.val(n(this).val()).change(),t.make_button_active(n(this))}))}))},make_button_active:function(e){e.closest(".wpcode-button-toggle").find(".wpcode-button").each((function(){e.is(n(this))?n(this).removeClass("wpcode-button-secondary-inactive"):n(this).addClass("wpcode-button-secondary-inactive")}))}};t.init()},init_dynamic_hide:function(){const e={init:function(){e.elements=n("[data-show-if-id]"),e.add_listeners()},add_listeners:function(){e.elements.each((function(){const t=n(this),i=t.data("show-if-id");if(""===i)return;const o=String(t.data("show-if-value")).split(","),s=n(i);s.on("change",(function(){e.maybe_hide(s,t,o)})),e.maybe_hide(s,t,o)}))},maybe_hide:function(e,t,n){let i=String(e.val());"checkbox"===e.attr("type")&&(i=e.prop("checked")?"1":"0"),n.indexOf(i)<0?t.hide():t.show()}};e.init()},init_copy_target:function(){n(".wpcode-copy-target").on("click",(function(e){e.preventDefault();const t=n(this),i=t.data("target"),o=n(i).val();o&&(navigator.clipboard.writeText(o),t.addClass("wpcode-show-success-icon"),setTimeout((function(){t.removeClass("wpcode-show-success-icon")}),500))}))},init_select2:function(){n(".wpcode-select2").select2()},init_tags_picker:function(){const e=n(".wpcode-tags-picker");e.select2({tags:!0,ajax:{url:ajaxurl,data:function(e){return{action:"ajax-tag-search",tax:"wpcode_tags",q:e.term?e.term:""}},processResults:function(e){const t=e.split(","),n=[];return t.forEach((function(e){""!==e&&n.push({id:e,text:e})})),{results:n}}}}),e.on("change",(function(){i.set_before_unload();const e=n(this).data("target");n(e).val(n(this).val().join(","))}))},init_metabox_toggler:function(){n(".wpcode-metabox-title").on("click",(function(){n(this).parent().toggleClass("wpcode-metabox-collapsed")}))},init_tinymce_listener(){i.$text_editor.on("Paste Change input Undo Redo",(function(){i.set_before_unload(),clearTimeout(i.editor_change_handler),i.editor_change_handler=setTimeout((function(){t.WPCodeAdminCodeEditor.set_value(i.$text_editor.getContent())}),100)}))},set_before_unload(){i.unload_set||(i.unload_set=!0,n(t).on("beforeunload",(function(){return""})))},unload_change_listener(){t.WPCodeAdminCodeEditor.get_editor().on("change",(function(){i.set_before_unload()}));const e=n("#wpcode-snippet-manager-form");e.on("change","input, select",(function(){i.set_before_unload()})),e.on("submit",(function(){n(t).off("beforeunload")}))}};return i}(document,window,jQuery);jQuery((function(){e.init()})),n(560),n(569),n(5),n(900),n(423),n(786),n(298),n(801),n(847),n(770),n(868),n(448)}()}();
|
ihaf.php
CHANGED
@@ -1,18 +1,24 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Plugin Name: Insert Headers and
|
4 |
-
* Plugin URI:
|
5 |
-
* Version:
|
6 |
* Requires at least: 4.6
|
7 |
-
* Requires PHP: 5.
|
8 |
-
* Tested up to:
|
9 |
-
* Author:
|
10 |
-
* Author URI:
|
11 |
-
* Description:
|
12 |
* License: GPLv2 or later
|
|
|
|
|
|
|
|
|
|
|
13 |
*/
|
14 |
|
15 |
-
/*
|
|
|
16 |
|
17 |
This program is free software; you can redistribute it and/or modify
|
18 |
it under the terms of the GNU General Public License, version 2, as
|
@@ -28,276 +34,255 @@
|
|
28 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
29 |
*/
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
/**
|
32 |
-
*
|
33 |
*/
|
34 |
-
class
|
35 |
-
|
36 |
-
static $instance;
|
37 |
|
38 |
-
public static function get_instance() {
|
39 |
-
if ( ! isset( self::$instance ) ) {
|
40 |
-
self::$instance = new InsertHeadersAndFooters();
|
41 |
-
}
|
42 |
-
return self::$instance;
|
43 |
-
}
|
44 |
/**
|
45 |
-
*
|
|
|
|
|
|
|
|
|
46 |
*/
|
47 |
-
|
48 |
-
$file_data = get_file_data( __FILE__, array( 'Version' => 'Version' ) );
|
49 |
-
|
50 |
-
// Plugin Details
|
51 |
-
$this->plugin = new stdClass;
|
52 |
-
$this->plugin->name = 'insert-headers-and-footers'; // Plugin Folder
|
53 |
-
$this->plugin->displayName = 'Insert Headers and Footers'; // Plugin Name
|
54 |
-
$this->plugin->version = $file_data['Version'];
|
55 |
-
$this->plugin->folder = plugin_dir_path( __FILE__ );
|
56 |
-
$this->plugin->url = plugin_dir_url( __FILE__ );
|
57 |
-
$this->plugin->db_welcome_dismissed_key = $this->plugin->name . '_welcome_dismissed_key';
|
58 |
-
$this->body_open_supported = function_exists( 'wp_body_open' ) && version_compare( get_bloginfo( 'version' ), '5.2', '>=' );
|
59 |
-
|
60 |
-
// Hooks
|
61 |
-
add_action( 'plugins_loaded', array( $this, 'requireAdmin' ) );
|
62 |
-
add_action( 'admin_init', array( &$this, 'registerSettings' ) );
|
63 |
-
add_action( 'admin_enqueue_scripts', array( &$this, 'initCodeMirror' ) );
|
64 |
-
add_action( 'admin_menu', array( &$this, 'adminPanelsAndMetaBoxes' ) );
|
65 |
-
add_action( 'admin_notices', array( &$this, 'dashboardNotices' ) );
|
66 |
-
add_action( 'wp_ajax_' . $this->plugin->name . '_dismiss_dashboard_notices', array( &$this, 'dismissDashboardNotices' ) );
|
67 |
-
|
68 |
-
// Frontend Hooks
|
69 |
-
add_action( 'wp_head', array( &$this, 'frontendHeader' ) );
|
70 |
-
add_action( 'wp_footer', array( &$this, 'frontendFooter' ) );
|
71 |
-
if ( $this->body_open_supported ) {
|
72 |
-
add_action( 'wp_body_open', array( &$this, 'frontendBody' ), 1 );
|
73 |
-
}
|
74 |
-
}
|
75 |
|
76 |
/**
|
77 |
-
*
|
78 |
*
|
79 |
-
* @
|
|
|
|
|
80 |
*/
|
81 |
-
public
|
82 |
-
if ( ! is_admin() ) {
|
83 |
-
// Only load in admin section.
|
84 |
-
return;
|
85 |
-
}
|
86 |
-
require_once $this->plugin->folder . 'inc/admin/class-review.php';
|
87 |
-
}
|
88 |
|
89 |
/**
|
90 |
-
*
|
|
|
|
|
91 |
*/
|
92 |
-
|
93 |
-
global $pagenow;
|
94 |
-
|
95 |
-
if (
|
96 |
-
! get_option( $this->plugin->db_welcome_dismissed_key )
|
97 |
-
&& current_user_can( 'manage_options' )
|
98 |
-
) {
|
99 |
-
if ( ! ( 'options-general.php' === $pagenow && isset( $_GET['page'] ) && 'insert-headers-and-footers' === $_GET['page'] ) ) {
|
100 |
-
$setting_page = admin_url( 'options-general.php?page=' . $this->plugin->name );
|
101 |
-
// load the notices view
|
102 |
-
include_once( $this->plugin->folder . '/views/dashboard-notices.php' );
|
103 |
-
}
|
104 |
-
}
|
105 |
-
}
|
106 |
|
107 |
/**
|
108 |
-
*
|
|
|
|
|
109 |
*/
|
110 |
-
|
111 |
-
check_ajax_referer( $this->plugin->name . '-nonce', 'nonce' );
|
112 |
-
// user has dismissed the welcome notice
|
113 |
-
update_option( $this->plugin->db_welcome_dismissed_key, 1 );
|
114 |
-
exit;
|
115 |
-
}
|
116 |
|
117 |
/**
|
118 |
-
*
|
|
|
|
|
119 |
*/
|
120 |
-
|
121 |
-
register_setting( $this->plugin->name, 'ihaf_insert_header', 'trim' );
|
122 |
-
register_setting( $this->plugin->name, 'ihaf_insert_footer', 'trim' );
|
123 |
-
register_setting( $this->plugin->name, 'ihaf_insert_body', 'trim' );
|
124 |
-
}
|
125 |
|
126 |
/**
|
127 |
-
*
|
|
|
|
|
128 |
*/
|
129 |
-
|
130 |
-
add_submenu_page( 'options-general.php', $this->plugin->displayName, $this->plugin->displayName, 'manage_options', $this->plugin->name, array( &$this, 'adminPanel' ) );
|
131 |
-
}
|
132 |
|
133 |
/**
|
134 |
-
*
|
135 |
-
*
|
|
|
136 |
*/
|
137 |
-
|
138 |
-
/*
|
139 |
-
* Only users with manage_options can access this page.
|
140 |
-
*
|
141 |
-
* The capability included in add_settings_page() means WP should deal
|
142 |
-
* with this automatically but it never hurts to double check.
|
143 |
-
*/
|
144 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
145 |
-
wp_die( __( 'Sorry, you are not allowed to access this page.', 'insert-headers-and-footers' ) );
|
146 |
-
}
|
147 |
-
|
148 |
-
// only users with `unfiltered_html` can edit scripts.
|
149 |
-
if ( ! current_user_can( 'unfiltered_html' ) ) {
|
150 |
-
$this->errorMessage = '<p>' . __( 'Sorry, only have read-only access to this page. Ask your administrator for assistance editing.', 'insert-headers-and-footers' ) . '</p>';
|
151 |
-
}
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
} elseif ( ! isset( $_REQUEST[ $this->plugin->name . '_nonce' ] ) ) {
|
160 |
-
// Missing nonce
|
161 |
-
$this->errorMessage = __( 'nonce field is missing. Settings NOT saved.', 'insert-headers-and-footers' );
|
162 |
-
} elseif ( ! wp_verify_nonce( $_REQUEST[ $this->plugin->name . '_nonce' ], $this->plugin->name ) ) {
|
163 |
-
// Invalid nonce
|
164 |
-
$this->errorMessage = __( 'Invalid nonce specified. Settings NOT saved.', 'insert-headers-and-footers' );
|
165 |
-
} else {
|
166 |
-
// Save
|
167 |
-
// $_REQUEST has already been slashed by wp_magic_quotes in wp-settings
|
168 |
-
// so do nothing before saving
|
169 |
-
update_option( 'ihaf_insert_header', $_REQUEST['ihaf_insert_header'] );
|
170 |
-
update_option( 'ihaf_insert_footer', $_REQUEST['ihaf_insert_footer'] );
|
171 |
-
update_option( 'ihaf_insert_body', isset( $_REQUEST['ihaf_insert_body'] ) ? $_REQUEST['ihaf_insert_body'] : '' );
|
172 |
-
update_option( $this->plugin->db_welcome_dismissed_key, 1 );
|
173 |
-
$this->message = __( 'Settings Saved.', 'insert-headers-and-footers' );
|
174 |
-
}
|
175 |
-
}
|
176 |
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
187 |
|
188 |
/**
|
189 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
*/
|
191 |
-
|
192 |
-
// Make sure that we don't fatal error on WP versions before 4.9.
|
193 |
-
if ( ! function_exists( 'wp_enqueue_code_editor' ) ) {
|
194 |
-
return;
|
195 |
-
}
|
196 |
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
-
|
|
|
204 |
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
|
|
208 |
|
209 |
-
|
210 |
-
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
216 |
|
217 |
-
|
218 |
-
$styles = '.CodeMirror{ border: 1px solid #ccd0d4; }';
|
219 |
|
220 |
-
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
|
227 |
-
|
228 |
-
* Outputs script / CSS to the frontend header
|
229 |
-
*/
|
230 |
-
function frontendHeader() {
|
231 |
-
$this->output( 'ihaf_insert_header' );
|
232 |
}
|
233 |
|
234 |
/**
|
235 |
-
*
|
|
|
|
|
236 |
*/
|
237 |
-
function
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
|
241 |
/**
|
242 |
-
*
|
|
|
|
|
243 |
*/
|
244 |
-
function
|
245 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
-
*
|
250 |
*
|
251 |
-
* @
|
252 |
-
* @return output
|
253 |
*/
|
254 |
-
function
|
255 |
-
|
256 |
-
|
257 |
-
return;
|
258 |
-
}
|
259 |
-
|
260 |
-
// provide the opportunity to Ignore IHAF - both headers and footers via filters
|
261 |
-
if ( apply_filters( 'disable_ihaf', false ) ) {
|
262 |
-
return;
|
263 |
-
}
|
264 |
-
|
265 |
-
// provide the opportunity to Ignore IHAF - footer only via filters
|
266 |
-
if ( 'ihaf_insert_footer' === $setting && apply_filters( 'disable_ihaf_footer', false ) ) {
|
267 |
-
return;
|
268 |
-
}
|
269 |
-
|
270 |
-
// provide the opportunity to Ignore IHAF - header only via filters
|
271 |
-
if ( 'ihaf_insert_header' === $setting && apply_filters( 'disable_ihaf_header', false ) ) {
|
272 |
-
return;
|
273 |
-
}
|
274 |
-
|
275 |
-
// provide the opportunity to Ignore IHAF - below opening body only via filters
|
276 |
-
if ( 'ihaf_insert_body' === $setting && apply_filters( 'disable_ihaf_body', false ) ) {
|
277 |
-
return;
|
278 |
-
}
|
279 |
-
|
280 |
-
// Get meta
|
281 |
-
$meta = get_option( $setting );
|
282 |
-
if ( empty( $meta ) ) {
|
283 |
-
return;
|
284 |
-
}
|
285 |
-
if ( trim( $meta ) === '' ) {
|
286 |
-
return;
|
287 |
}
|
288 |
|
289 |
-
|
290 |
-
echo wp_unslash( $meta );
|
291 |
}
|
292 |
}
|
293 |
|
294 |
/**
|
295 |
-
*
|
296 |
*
|
297 |
-
* @
|
298 |
*/
|
299 |
-
function
|
300 |
-
return
|
301 |
}
|
302 |
|
303 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: WPCode - Insert Headers, Footers, and Code Snippets
|
4 |
+
* Plugin URI: https://www.wpcode.com/
|
5 |
+
* Version: 2.0.0
|
6 |
* Requires at least: 4.6
|
7 |
+
* Requires PHP: 5.5
|
8 |
+
* Tested up to: 6.0
|
9 |
+
* Author: WPCode
|
10 |
+
* Author URI: https://www.wpcode.com/
|
11 |
+
* Description: Easily add code snippets in WordPress. Insert scripts to the header and footer, add PHP code snippets with conditional logic, insert ads pixel, custom content, and more.
|
12 |
* License: GPLv2 or later
|
13 |
+
*
|
14 |
+
* Text Domain: insert-headers-and-footers
|
15 |
+
* Domain Path: /languages
|
16 |
+
*
|
17 |
+
* @package WPCode
|
18 |
*/
|
19 |
|
20 |
+
/*
|
21 |
+
Copyright 2019 WPBeginner
|
22 |
|
23 |
This program is free software; you can redistribute it and/or modify
|
24 |
it under the terms of the GNU General Public License, version 2, as
|
34 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
35 |
*/
|
36 |
|
37 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
38 |
+
exit;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
/**
|
43 |
+
* Main WPCode Class
|
44 |
*/
|
45 |
+
class WPCode {
|
|
|
|
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
+
* Holds the instance of the plugin.
|
49 |
+
*
|
50 |
+
* @since 2.0.0
|
51 |
+
*
|
52 |
+
* @var WPCode The one true WPCode
|
53 |
*/
|
54 |
+
private static $instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
/**
|
57 |
+
* Plugin version.
|
58 |
*
|
59 |
+
* @since 2.0.0
|
60 |
+
*
|
61 |
+
* @var string
|
62 |
*/
|
63 |
+
public $version = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
/**
|
66 |
+
* The auto-insert instance.
|
67 |
+
*
|
68 |
+
* @var WPCode_Auto_Insert
|
69 |
*/
|
70 |
+
public $auto_insert;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
/**
|
73 |
+
* The snippet execution instance.
|
74 |
+
*
|
75 |
+
* @var WPCode_Snippet_Execute
|
76 |
*/
|
77 |
+
public $execute;
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
/**
|
80 |
+
* The error handling instance.
|
81 |
+
*
|
82 |
+
* @var WPCode_Error
|
83 |
*/
|
84 |
+
public $error;
|
|
|
|
|
|
|
|
|
85 |
|
86 |
/**
|
87 |
+
* The conditional logic instance.
|
88 |
+
*
|
89 |
+
* @var WPCode_Conditional_Logic
|
90 |
*/
|
91 |
+
public $conditional_logic;
|
|
|
|
|
92 |
|
93 |
/**
|
94 |
+
* The conditional logic instance.
|
95 |
+
*
|
96 |
+
* @var WPCode_Snippet_Cache
|
97 |
*/
|
98 |
+
public $cache;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
+
/**
|
101 |
+
* The snippet library.
|
102 |
+
*
|
103 |
+
* @var WPCode_Library
|
104 |
+
*/
|
105 |
+
public $library;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
+
/**
|
108 |
+
* The Snippet Generator.
|
109 |
+
*
|
110 |
+
* @var WPCode_Generator
|
111 |
+
*/
|
112 |
+
public $generator;
|
113 |
|
114 |
+
/**
|
115 |
+
* The plugin settings.
|
116 |
+
*
|
117 |
+
* @var WPCode_Settings
|
118 |
+
*/
|
119 |
+
public $settings;
|
120 |
|
121 |
/**
|
122 |
+
* The plugin importers.
|
123 |
+
*
|
124 |
+
* @var WPCode_Importers
|
125 |
+
*/
|
126 |
+
public $importers;
|
127 |
+
/**
|
128 |
+
* The file cache class.
|
129 |
+
*
|
130 |
+
* @var WPCode_File_Cache
|
131 |
*/
|
132 |
+
public $file_cache;
|
|
|
|
|
|
|
|
|
133 |
|
134 |
+
/**
|
135 |
+
* The notifications instance (admin-only).
|
136 |
+
*
|
137 |
+
* @var WPCode_Notifications
|
138 |
+
*/
|
139 |
+
public $notifications;
|
140 |
|
141 |
+
/**
|
142 |
+
* Main instance of WPCode.
|
143 |
+
*
|
144 |
+
* @return WPCode
|
145 |
+
* @since 2.0.0
|
146 |
+
*/
|
147 |
+
public static function instance() {
|
148 |
+
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPCode ) ) {
|
149 |
+
self::$instance = new WPCode();
|
150 |
}
|
151 |
|
152 |
+
return self::$instance;
|
153 |
+
}
|
154 |
|
155 |
+
/**
|
156 |
+
* Constructor.
|
157 |
+
*/
|
158 |
+
private function __construct() {
|
159 |
+
$this->setup_constants();
|
160 |
+
$this->includes();
|
161 |
+
$this->load_components();
|
162 |
|
163 |
+
add_action( 'init', array( $this, 'load_plugin_textdomain' ), 15 );
|
164 |
+
}
|
165 |
|
166 |
+
/**
|
167 |
+
* Set up global constants.
|
168 |
+
*
|
169 |
+
* @return void
|
170 |
+
*/
|
171 |
+
private function setup_constants() {
|
172 |
|
173 |
+
define( 'WPCODE_FILE', __FILE__ );
|
|
|
174 |
|
175 |
+
$plugin_headers = get_file_data( WPCODE_FILE, array( 'version' => 'Version' ) );
|
176 |
|
177 |
+
define( 'WPCODE_VERSION', $plugin_headers['version'] );
|
178 |
+
define( 'WPCODE_PLUGIN_BASENAME', plugin_basename( WPCODE_FILE ) );
|
179 |
+
define( 'WPCODE_PLUGIN_URL', plugin_dir_url( WPCODE_FILE ) );
|
180 |
+
define( 'WPCODE_PLUGIN_PATH', plugin_dir_path( WPCODE_FILE ) );
|
181 |
|
182 |
+
$this->version = WPCODE_VERSION;
|
|
|
|
|
|
|
|
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
+
* Require the files needed for the plugin.
|
187 |
+
*
|
188 |
+
* @return void
|
189 |
*/
|
190 |
+
private function includes() {
|
191 |
+
// Load the safe mode logic first.
|
192 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/safe-mode.php';
|
193 |
+
// Functions for global headers & footers output.
|
194 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/global-output.php';
|
195 |
+
// Use the old class name for backwards compatibility.
|
196 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/legacy.php';
|
197 |
+
// Register code snippets post type.
|
198 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/post-type.php';
|
199 |
+
// The snippet class.
|
200 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet.php';
|
201 |
+
// Auto-insert options.
|
202 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-auto-insert.php';
|
203 |
+
// Execute snippets.
|
204 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet-execute.php';
|
205 |
+
// Handle PHP errors.
|
206 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-error.php';
|
207 |
+
// [wpcode] shortcode.
|
208 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/shortcode.php';
|
209 |
+
// Conditional logic.
|
210 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-conditional-logic.php';
|
211 |
+
// Snippet Cache.
|
212 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet-cache.php';
|
213 |
+
// Settings class.
|
214 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-settings.php';
|
215 |
+
// Custom capabilities.
|
216 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-capabilities.php';
|
217 |
+
// Install routines.
|
218 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-install.php';
|
219 |
+
|
220 |
+
if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
|
221 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/icons.php'; // This is not needed in the frontend atm.
|
222 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/helpers.php'; // This is not needed in the frontend atm.
|
223 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/admin-menu.php';
|
224 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/admin-scripts.php';
|
225 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/admin-ajax-handlers.php';
|
226 |
+
// Always used just in the backend.
|
227 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-generator.php';
|
228 |
+
// Snippet Library.
|
229 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-library.php';
|
230 |
+
// Importers.
|
231 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-importers.php';
|
232 |
+
// File cache.
|
233 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-file-cache.php';
|
234 |
+
// The docs.
|
235 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-docs.php';
|
236 |
+
// Notifications class.
|
237 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-notifications.php';
|
238 |
+
// Upgrade page.
|
239 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-upgrade-welcome.php';
|
240 |
+
}
|
241 |
}
|
242 |
|
243 |
/**
|
244 |
+
* Load components in the main plugin instance.
|
245 |
+
*
|
246 |
+
* @return void
|
247 |
*/
|
248 |
+
public function load_components() {
|
249 |
+
$this->auto_insert = new WPCode_Auto_Insert();
|
250 |
+
$this->execute = new WPCode_Snippet_Execute();
|
251 |
+
$this->error = new WPCode_Error();
|
252 |
+
$this->conditional_logic = new WPCode_Conditional_Logic();
|
253 |
+
$this->cache = new WPCode_Snippet_Cache();
|
254 |
+
$this->settings = new WPCode_Settings();
|
255 |
+
|
256 |
+
if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
|
257 |
+
$this->file_cache = new WPCode_File_Cache();
|
258 |
+
$this->library = new WPCode_Library();
|
259 |
+
$this->generator = new WPCode_Generator();
|
260 |
+
$this->importers = new WPCode_Importers();
|
261 |
+
$this->notifications = new WPCode_Notifications();
|
262 |
+
}
|
263 |
}
|
264 |
|
265 |
/**
|
266 |
+
* Load the plugin translations.
|
267 |
*
|
268 |
+
* @return void
|
|
|
269 |
*/
|
270 |
+
public function load_plugin_textdomain() {
|
271 |
+
if ( is_user_logged_in() ) {
|
272 |
+
unload_textdomain( 'insert-headers-and-footers' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
}
|
274 |
|
275 |
+
load_plugin_textdomain( 'insert-headers-and-footers', false, dirname( plugin_basename( WPCODE_FILE ) ) . '/languages/' );
|
|
|
276 |
}
|
277 |
}
|
278 |
|
279 |
/**
|
280 |
+
* Get the main instance of WPCode.
|
281 |
*
|
282 |
+
* @return WPCode
|
283 |
*/
|
284 |
+
function WPCode() {// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
|
285 |
+
return WPCode::instance();
|
286 |
}
|
287 |
|
288 |
+
WPCode();
|
inc/admin/class-review.php
DELETED
@@ -1,245 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Review class.
|
5 |
-
*
|
6 |
-
* @since 1.6.1
|
7 |
-
*/
|
8 |
-
class IHAF_Review {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* The HTML code for the review notice.
|
12 |
-
* Used to display the review notice at the proper time.
|
13 |
-
*
|
14 |
-
* @var string
|
15 |
-
*/
|
16 |
-
private $notice = '';
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Primary class constructor.
|
20 |
-
*
|
21 |
-
* @since 1.6.1
|
22 |
-
*/
|
23 |
-
public function __construct() {
|
24 |
-
|
25 |
-
// Admin notice requesting review.
|
26 |
-
add_action( 'admin_init', array( $this, 'review_request' ) );
|
27 |
-
add_action( 'wp_ajax_ihaf_notice_dismiss', array( $this, 'review_dismiss' ) );
|
28 |
-
add_action( 'admin_notices', array( $this, 'maybe_show_admin_notices' ) );
|
29 |
-
|
30 |
-
// Admin footer text.
|
31 |
-
add_filter( 'admin_footer_text', array( $this, 'admin_footer' ), 1, 2 );
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Add admin notices as needed for reviews.
|
36 |
-
*
|
37 |
-
* @since 1.6.1
|
38 |
-
*/
|
39 |
-
public function review_request() {
|
40 |
-
|
41 |
-
// Only consider showing the review request to admin users.
|
42 |
-
if ( ! is_super_admin() ) {
|
43 |
-
return;
|
44 |
-
}
|
45 |
-
|
46 |
-
// Verify that we can do a check for reviews.
|
47 |
-
$notices = get_option( 'ihaf_admin_notices', array() );
|
48 |
-
$time = time();
|
49 |
-
$load = false;
|
50 |
-
|
51 |
-
if ( empty( $notices['review_request'] ) ) {
|
52 |
-
$notices['review_request'] = array(
|
53 |
-
'time' => $time,
|
54 |
-
'dismissed' => false,
|
55 |
-
);
|
56 |
-
|
57 |
-
update_option( 'ihaf_admin_notices', $notices );
|
58 |
-
|
59 |
-
return;
|
60 |
-
}
|
61 |
-
|
62 |
-
// Check if it has been dismissed or not.
|
63 |
-
if ( ( isset( $notices['review_request']['dismissed'] ) && ! $notices['review_request']['dismissed'] ) ) {
|
64 |
-
$load = true;
|
65 |
-
}
|
66 |
-
|
67 |
-
// If we cannot load, return early.
|
68 |
-
if ( ! $load ) {
|
69 |
-
return;
|
70 |
-
}
|
71 |
-
|
72 |
-
// Show the notice.
|
73 |
-
$this->review_lite();
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Maybe show Lite review request.
|
78 |
-
*
|
79 |
-
* @since 1.6.1
|
80 |
-
*/
|
81 |
-
public function review_lite() {
|
82 |
-
|
83 |
-
// Fetch when plugin was initially installed.
|
84 |
-
$activated = get_option( 'ihaf_activated', array() );
|
85 |
-
|
86 |
-
if ( ! empty( $activated['lite'] ) ) {
|
87 |
-
// Only continue if plugin has been installed for at least 7 days.
|
88 |
-
if ( ( $activated['lite'] + ( DAY_IN_SECONDS * 7 ) ) > time() ) {
|
89 |
-
return;
|
90 |
-
}
|
91 |
-
} else {
|
92 |
-
$activated['lite'] = time();
|
93 |
-
|
94 |
-
update_option( 'ihaf_activated', $activated );
|
95 |
-
|
96 |
-
return;
|
97 |
-
}
|
98 |
-
|
99 |
-
// Only proceed with displaying if the user added a script using IHAF.
|
100 |
-
if ( ! $this->has_updated_settings() ) {
|
101 |
-
return;
|
102 |
-
}
|
103 |
-
|
104 |
-
ob_start();
|
105 |
-
|
106 |
-
// We have a candidate! Output a review message.
|
107 |
-
?>
|
108 |
-
<p><?php esc_html_e( 'Hey, I noticed you have been using Insert Headers and Footers for some time - that’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'insert-headers-and-footers' ); ?></p>
|
109 |
-
<p>
|
110 |
-
<strong><?php echo wp_kses( __( '~ Syed Balkhi<br>Founder of WPBeginner', 'insert-headers-and-footers' ), array( 'br' => array() ) ); ?></strong>
|
111 |
-
</p>
|
112 |
-
<p>
|
113 |
-
<a href="https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/?filter=5#new-post" class="ihaf-notice-dismiss ihaf-review-out" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Ok, you deserve it', 'insert-headers-and-footers' ); ?></a><br>
|
114 |
-
<a href="#" class="ihaf-notice-dismiss" rel="noopener noreferrer"><?php esc_html_e( 'Nope, maybe later', 'insert-headers-and-footers' ); ?></a><br>
|
115 |
-
<a href="#" class="ihaf-notice-dismiss" rel="noopener noreferrer"><?php esc_html_e( 'I already did', 'insert-headers-and-footers' ); ?></a>
|
116 |
-
</p>
|
117 |
-
<?php
|
118 |
-
|
119 |
-
$this->notice = ob_get_clean();
|
120 |
-
// If we got this far, let's make sure we also load the needed js.
|
121 |
-
$this->add_enqueue_scripts_hook();
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* If the notice is available, show it.
|
126 |
-
*
|
127 |
-
* @return void
|
128 |
-
*/
|
129 |
-
public function maybe_show_admin_notices() {
|
130 |
-
if ( empty( $this->notice ) ) {
|
131 |
-
// If no notice to show, bail early.
|
132 |
-
return;
|
133 |
-
}
|
134 |
-
echo '<div class="ihaf-notice notice notice-info is-dismissible" id="ihaf-notice-review_request">';
|
135 |
-
echo '<p>' . $this->notice . '</p>';// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
136 |
-
echo '</div>';
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Dismiss the review admin notice.
|
141 |
-
*
|
142 |
-
* @since 1.6.1
|
143 |
-
*/
|
144 |
-
public function review_dismiss() {
|
145 |
-
|
146 |
-
check_ajax_referer( 'ihaf_admin_notice', 'nonce' );
|
147 |
-
|
148 |
-
$notices = get_option( 'ihaf_admin_notices', array() );
|
149 |
-
|
150 |
-
$notices['review_request'] = array(
|
151 |
-
'time' => time(),
|
152 |
-
'dismissed' => true,
|
153 |
-
);
|
154 |
-
update_option( 'ihaf_admin_notices', $notices );
|
155 |
-
|
156 |
-
wp_send_json_success();
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* When user is on a IHAF related admin page, display footer text
|
161 |
-
* that graciously asks them to rate us.
|
162 |
-
*
|
163 |
-
* @param string $text Footer text.
|
164 |
-
*
|
165 |
-
* @return string
|
166 |
-
* @since 1.6.1
|
167 |
-
*
|
168 |
-
*/
|
169 |
-
public function admin_footer( $text ) {
|
170 |
-
|
171 |
-
global $current_screen;
|
172 |
-
|
173 |
-
if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'insert-headers-and-footers' ) !== false ) {
|
174 |
-
$url = 'https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/?filter=5#new-post';
|
175 |
-
$text = sprintf(
|
176 |
-
wp_kses( /* translators: $1$s - IHAF plugin name; $2$s - WP.org review link; $3$s - WP.org review link. */
|
177 |
-
__( 'Please rate %1$s <a href="%2$s" target="_blank" rel="noopener noreferrer">★★★★★</a> on <a href="%3$s" target="_blank" rel="noopener">WordPress.org</a> to help us spread the word. Thank you from the WPBeginner team!', 'insert-headers-and-footers' ),
|
178 |
-
array(
|
179 |
-
'a' => array(
|
180 |
-
'href' => array(),
|
181 |
-
'target' => array(),
|
182 |
-
'rel' => array(),
|
183 |
-
),
|
184 |
-
)
|
185 |
-
),
|
186 |
-
'<strong>Insert Headers and Footers</strong>',
|
187 |
-
$url,
|
188 |
-
$url
|
189 |
-
);
|
190 |
-
}
|
191 |
-
|
192 |
-
return $text;
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Checks if the uses the plugin to load any scripts.
|
197 |
-
*
|
198 |
-
* @return bool
|
199 |
-
*/
|
200 |
-
public function has_updated_settings() {
|
201 |
-
$header_option = get_option( 'ihaf_insert_header' );
|
202 |
-
if ( ! empty( $header_option ) ) {
|
203 |
-
return true;
|
204 |
-
}
|
205 |
-
$body_option = get_option( 'ihaf_insert_body' );
|
206 |
-
if ( ! empty( $body_option ) ) {
|
207 |
-
return true;
|
208 |
-
}
|
209 |
-
$footer_option = get_option( 'ihaf_insert_footer' );
|
210 |
-
if ( ! empty( $footer_option ) ) {
|
211 |
-
return true;
|
212 |
-
}
|
213 |
-
|
214 |
-
return false;
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Just adds an action to admin_enqueue_scripts.
|
219 |
-
*
|
220 |
-
* @return void
|
221 |
-
*/
|
222 |
-
public function add_enqueue_scripts_hook() {
|
223 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Enqueue scripts needed to dismiss the admin notice.
|
228 |
-
*
|
229 |
-
* @return void
|
230 |
-
*/
|
231 |
-
public function enqueue_scripts() {
|
232 |
-
wp_enqueue_script( 'ihaf-admin-notice', insert_headers_and_footers()->plugin->url . 'assets/js/admin/notice.min.js', array( 'jquery' ), insert_headers_and_footers()->plugin->version, true );
|
233 |
-
wp_localize_script(
|
234 |
-
'ihaf-admin-notice',
|
235 |
-
'ihaf_admin_notices',
|
236 |
-
array(
|
237 |
-
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
238 |
-
'nonce' => wp_create_nonce( 'ihaf_admin_notice' ),
|
239 |
-
)
|
240 |
-
);
|
241 |
-
}
|
242 |
-
|
243 |
-
}
|
244 |
-
|
245 |
-
new IHAF_Review();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/admin/admin-ajax-handlers.php
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ajax handlers for the admin.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
add_action( 'wp_ajax_wpcode_update_snippet_status', 'wpcode_update_snippet_status' );
|
9 |
+
add_action( 'wp_ajax_wpcode_search_terms', 'wpcode_search_terms' );
|
10 |
+
add_action( 'wp_ajax_wpcode_generate_snippet', 'wpcode_generate_snippet' );
|
11 |
+
add_action( 'wp_ajax_wpcode_save_generated_snippet', 'wpcode_save_generated_snippet' );
|
12 |
+
add_action( 'wp_ajax_wpcode_verify_ssl', 'wpcode_verify_ssl' );
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Handles toggling a snippet status from the admin.
|
16 |
+
*
|
17 |
+
* @return void
|
18 |
+
*/
|
19 |
+
function wpcode_update_snippet_status() {
|
20 |
+
check_ajax_referer( 'wpcode_admin' );
|
21 |
+
|
22 |
+
if ( empty( $_POST['snippet_id'] ) ) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
$snippet_id = absint( $_POST['snippet_id'] );
|
26 |
+
$active = isset( $_POST['active'] ) && 'true' === $_POST['active'];
|
27 |
+
|
28 |
+
$snippet = new WPCode_Snippet( $snippet_id );
|
29 |
+
if ( $active ) {
|
30 |
+
$snippet->activate();
|
31 |
+
} else {
|
32 |
+
$snippet->deactivate();
|
33 |
+
}
|
34 |
+
|
35 |
+
if ( ! isset( $snippet->active ) || $active !== $snippet->active ) {
|
36 |
+
$error_message = sprintf(
|
37 |
+
// Translators: formatted error code.
|
38 |
+
__( 'Snippet not %2$s, the following error was encountered: %1$s', 'insert-headers-and-footers' ),
|
39 |
+
'<code>' . wpcode()->error->get_last_error_message() . '</code>',
|
40 |
+
$active ? _x( 'activated', 'Snippet status change', 'insert-headers-and-footers' ) : _x( 'deactivated', 'Snippet status change', 'insert-headers-and-footers' )
|
41 |
+
);
|
42 |
+
// We failed to activate it, so it's an error.
|
43 |
+
wp_send_json_error(
|
44 |
+
array(
|
45 |
+
'message' => $error_message,
|
46 |
+
)
|
47 |
+
);
|
48 |
+
}
|
49 |
+
exit;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Ajax handler to search for terms through all the public taxonomies.
|
54 |
+
*
|
55 |
+
* @return void
|
56 |
+
*/
|
57 |
+
function wpcode_search_terms() {
|
58 |
+
check_ajax_referer( 'wpcode_admin' );
|
59 |
+
|
60 |
+
$term = isset( $_GET['term'] ) ? sanitize_text_field( wp_unslash( $_GET['term'] ) ) : '';
|
61 |
+
|
62 |
+
$public_taxonomies = get_taxonomies(
|
63 |
+
array(
|
64 |
+
'public' => true,
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
$terms = get_terms(
|
69 |
+
array(
|
70 |
+
'search' => $term,
|
71 |
+
'taxonomy' => $public_taxonomies,
|
72 |
+
'hide_empty' => false,
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
$results = array();
|
77 |
+
|
78 |
+
foreach ( $terms as $term ) {
|
79 |
+
$results[] = array(
|
80 |
+
'id' => $term->term_id,
|
81 |
+
'text' => $term->name,
|
82 |
+
);
|
83 |
+
}
|
84 |
+
|
85 |
+
wp_send_json(
|
86 |
+
array(
|
87 |
+
'results' => $results,
|
88 |
+
)
|
89 |
+
);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Ajax handler for the generator.
|
94 |
+
*
|
95 |
+
* @return void
|
96 |
+
*/
|
97 |
+
function wpcode_generate_snippet() {
|
98 |
+
|
99 |
+
check_ajax_referer( 'wpcode_generate', 'nonce' );
|
100 |
+
|
101 |
+
$generator_type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
|
102 |
+
|
103 |
+
$generator = wpcode()->generator->get_type( $generator_type );
|
104 |
+
|
105 |
+
if ( ! $generator ) {
|
106 |
+
wp_send_json_error();
|
107 |
+
}
|
108 |
+
|
109 |
+
$snippet_code = $generator->process_form_data( $_POST );
|
110 |
+
|
111 |
+
wp_send_json( $snippet_code );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Take the values from a generated snippet and save as a new snippet.
|
116 |
+
*
|
117 |
+
* @return void
|
118 |
+
*/
|
119 |
+
function wpcode_save_generated_snippet() {
|
120 |
+
|
121 |
+
check_ajax_referer( 'wpcode_generate', 'nonce' );
|
122 |
+
|
123 |
+
$generator_type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
|
124 |
+
$generator = wpcode()->generator->get_type( $generator_type );
|
125 |
+
|
126 |
+
if ( ! $generator ) {
|
127 |
+
wp_send_json_error();
|
128 |
+
}
|
129 |
+
|
130 |
+
$snippet_code = $generator->process_form_data( $_POST );
|
131 |
+
|
132 |
+
$new_snippet = new WPCode_Snippet(
|
133 |
+
array(
|
134 |
+
// Translators: this an auto-generated title for when a snippet is saved from the generator.
|
135 |
+
'title' => sprintf( __( 'Generated Snippet %s', 'insert-headers-and-footers' ), $generator->get_title() ),
|
136 |
+
'code' => $snippet_code,
|
137 |
+
'code_type' => $generator->get_code_type(),
|
138 |
+
'tags' => $generator->get_tags(),
|
139 |
+
'location' => $generator->get_location(),
|
140 |
+
'generator' => $generator->get_name(),
|
141 |
+
'generator_data' => $generator->get_generator_data(),
|
142 |
+
'auto_insert' => $generator->get_auto_insert(),
|
143 |
+
)
|
144 |
+
);
|
145 |
+
|
146 |
+
$new_snippet_id = $new_snippet->save();
|
147 |
+
|
148 |
+
wp_send_json_success(
|
149 |
+
array(
|
150 |
+
'url' => add_query_arg(
|
151 |
+
array(
|
152 |
+
'page' => 'wpcode-snippet-manager',
|
153 |
+
'snippet_id' => $new_snippet_id,
|
154 |
+
),
|
155 |
+
admin_url( 'admin.php' )
|
156 |
+
),
|
157 |
+
)
|
158 |
+
);
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Ajax handler to verify that the current web host can successfully
|
164 |
+
* make outbound SSL connections.
|
165 |
+
*
|
166 |
+
* @return void
|
167 |
+
*/
|
168 |
+
function wpcode_verify_ssl() {
|
169 |
+
$response = wp_remote_post( 'https://wpcode.com' );
|
170 |
+
|
171 |
+
if ( 200 === wp_remote_retrieve_response_code( $response ) ) {
|
172 |
+
wp_send_json_success(
|
173 |
+
array(
|
174 |
+
'msg' => esc_html__( 'Success! Your server can make SSL connections.', 'insert-headers-and-footers' ),
|
175 |
+
)
|
176 |
+
);
|
177 |
+
}
|
178 |
+
|
179 |
+
wp_send_json_error(
|
180 |
+
array(
|
181 |
+
'msg' => esc_html__( 'There was an error and the connection failed. Please contact your web host with the technical details below.', 'insert-headers-and-footers' ),
|
182 |
+
'debug' => '<pre>' . print_r( map_deep( $response, 'wp_strip_all_tags' ), true ) . '</pre>',
|
183 |
+
)
|
184 |
+
);
|
185 |
+
}
|
includes/admin/admin-menu.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add WPCode admin menus.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
add_action( 'admin_menu', 'wpcode_register_admin_menu', 9 );
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Register the admin menu items.
|
16 |
+
*
|
17 |
+
* @return void
|
18 |
+
*/
|
19 |
+
function wpcode_register_admin_menu() {
|
20 |
+
if ( wpcode()->settings->get_option( 'headers_footers_mode' ) ) {
|
21 |
+
wpcode_load_admin_pages();
|
22 |
+
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
$svg = get_wpcode_icon( 'logo', 36, 34, '-10 -6 80 80' );
|
26 |
+
$wpcode_icon = 'data:image/svg+xml;base64,' . base64_encode( $svg ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
|
27 |
+
|
28 |
+
add_menu_page( __( 'Code Snippets', 'insert-headers-and-footers' ), __( 'Code Snippets', 'insert-headers-and-footers' ), 'wpcode_edit_snippets', 'wpcode', 'wpcode_admin_menu_page', $wpcode_icon, '81.4568' );
|
29 |
+
|
30 |
+
wpcode_load_admin_pages();
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Generic handler for the admin menu page.
|
35 |
+
*
|
36 |
+
* @return void
|
37 |
+
*/
|
38 |
+
function wpcode_admin_menu_page() {
|
39 |
+
do_action( 'wpcode_admin_page' );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Load the admin pages.
|
44 |
+
*
|
45 |
+
* @return void
|
46 |
+
*/
|
47 |
+
function wpcode_load_admin_pages() {
|
48 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page.php';
|
49 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page-headers-footers.php';
|
50 |
+
|
51 |
+
if ( wpcode()->settings->get_option( 'headers_footers_mode' ) ) {
|
52 |
+
new WPCode_Admin_Page_Headers_Footers( true );
|
53 |
+
|
54 |
+
return;
|
55 |
+
}
|
56 |
+
|
57 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page-code-snippets.php';
|
58 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page-snippet-manager.php';
|
59 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page-library.php';
|
60 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page-generator.php';
|
61 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page-tools.php';
|
62 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-admin-page-settings.php';
|
63 |
+
|
64 |
+
new WPCode_Admin_Page_Code_Snippets();
|
65 |
+
new WPCode_Admin_Page_Snippet_Manager();
|
66 |
+
new WPCode_Admin_Page_Headers_Footers();
|
67 |
+
new WPCode_Admin_Page_Library();
|
68 |
+
new WPCode_Admin_Page_Generator();
|
69 |
+
new WPCode_Admin_Page_Tools();
|
70 |
+
new WPCode_Admin_Page_Settings();
|
71 |
+
}
|
includes/admin/admin-scripts.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Load scripts for the admin area.
|
4 |
+
*/
|
5 |
+
|
6 |
+
add_action( 'admin_enqueue_scripts', 'wpcode_admin_scripts' );
|
7 |
+
add_filter( 'admin_body_class', 'wpcode_admin_body_class' );
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Load admin scripts here.
|
11 |
+
*
|
12 |
+
* @return void
|
13 |
+
*/
|
14 |
+
function wpcode_admin_scripts() {
|
15 |
+
|
16 |
+
$current_screen = get_current_screen();
|
17 |
+
|
18 |
+
if ( ! isset( $current_screen->id ) || false === strpos( $current_screen->id, 'wpcode' ) ) {
|
19 |
+
return;
|
20 |
+
}
|
21 |
+
|
22 |
+
$admin_asset_file = WPCODE_PLUGIN_PATH . 'build/admin.asset.php';
|
23 |
+
|
24 |
+
if ( ! file_exists( $admin_asset_file ) ) {
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$asset = include_once $admin_asset_file;
|
29 |
+
|
30 |
+
wp_enqueue_style( 'wpcode-admin-css', WPCODE_PLUGIN_URL . 'build/admin.css', null, $asset['version'] );
|
31 |
+
|
32 |
+
wp_enqueue_script( 'wpcode-admin-js', WPCODE_PLUGIN_URL . 'build/admin.js', $asset['dependencies'], $asset['version'], true );
|
33 |
+
|
34 |
+
wp_localize_script(
|
35 |
+
'wpcode-admin-js',
|
36 |
+
'wpcode',
|
37 |
+
apply_filters(
|
38 |
+
'wpcode_admin_js_data',
|
39 |
+
array(
|
40 |
+
'nonce' => wp_create_nonce( 'wpcode_admin' ),
|
41 |
+
'code_type_options' => wpcode()->execute->get_code_type_options(),
|
42 |
+
)
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
// Dequeue debug bar console styles on WPCode pages.
|
47 |
+
wp_dequeue_style( 'debug-bar-codemirror' );
|
48 |
+
wp_dequeue_style( 'debug-bar-console' );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Add stable body class that doesn't change with the translation.
|
53 |
+
*
|
54 |
+
* @param string $classes The body classes.
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
function wpcode_admin_body_class( $classes ) {
|
59 |
+
|
60 |
+
$page_parent = get_admin_page_parent();
|
61 |
+
|
62 |
+
if ( 'wpcode' === $page_parent ) {
|
63 |
+
$classes .= ' wpcode-admin-page';
|
64 |
+
}
|
65 |
+
|
66 |
+
return $classes;
|
67 |
+
}
|
includes/admin/class-wpcode-docs.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Load docs data from the server and store it
|
4 |
+
* in local file cache in the uplaods folder.
|
5 |
+
*
|
6 |
+
* @package WPCode
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* The class to load docs data from the server.
|
11 |
+
*/
|
12 |
+
class WPCode_Docs {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The URL from which to grab docs.
|
16 |
+
*
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
public $url = 'https://cdn.wpcode.com/wp-content/docs.json';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* The categories.
|
23 |
+
*
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
private $categories;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* The docs data.
|
30 |
+
*
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
private $docs;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Load docs data from cache or from the server.
|
37 |
+
*
|
38 |
+
* @return void
|
39 |
+
*/
|
40 |
+
public function load_docs_data() {
|
41 |
+
$docs_data = wpcode()->file_cache->get( 'docs', DAY_IN_SECONDS );
|
42 |
+
if ( false === $docs_data ) {
|
43 |
+
$docs_data = $this->load_from_server();
|
44 |
+
wpcode()->file_cache->set( 'docs', $docs_data );
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->categories = isset( $docs_data['categories'] ) ? $docs_data['categories'] : array();
|
48 |
+
$this->docs = isset( $docs_data['docs'] ) ? $docs_data['docs'] : array();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Get the docs.
|
53 |
+
*
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
public function get_docs() {
|
57 |
+
if ( ! isset( $this->docs ) ) {
|
58 |
+
$this->load_docs_data();
|
59 |
+
}
|
60 |
+
|
61 |
+
return $this->docs;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Get the docs categories.
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
public function get_categories() {
|
70 |
+
if ( ! isset( $this->categories ) ) {
|
71 |
+
$this->load_docs_data();
|
72 |
+
}
|
73 |
+
|
74 |
+
return $this->categories;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Load the docs data from the server.
|
79 |
+
*
|
80 |
+
* @return array
|
81 |
+
*/
|
82 |
+
public function load_from_server() {
|
83 |
+
$request = wp_remote_get( $this->url );
|
84 |
+
|
85 |
+
if ( wp_remote_retrieve_response_code( $request ) > 299 ) {
|
86 |
+
return array();
|
87 |
+
}
|
88 |
+
|
89 |
+
return json_decode( wp_remote_retrieve_body( $request ), true );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Go through all the docs and retrieve just those for this category.
|
94 |
+
*
|
95 |
+
* @param string $slug The category slug.
|
96 |
+
*
|
97 |
+
* @return array
|
98 |
+
*/
|
99 |
+
public function get_docs_for_category( $slug ) {
|
100 |
+
$docs = $this->get_docs();
|
101 |
+
|
102 |
+
ksort( $docs );
|
103 |
+
$category_docs = array();
|
104 |
+
// Until we drop PHP 5.2 support to use closure.
|
105 |
+
foreach ( $docs as $doc ) {
|
106 |
+
if ( ! in_array( $slug, $doc['categories'], true ) ) {
|
107 |
+
continue;
|
108 |
+
}
|
109 |
+
$category_docs[] = $doc;
|
110 |
+
}
|
111 |
+
|
112 |
+
return $category_docs;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Output the docs categories markup.
|
117 |
+
*
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
public function get_categories_accordion() {
|
121 |
+
?>
|
122 |
+
<div id="wpcode-help-categories" style="transition: opacity 300ms ease-in 0s; opacity: 1;">
|
123 |
+
<ul class="wpcode-help-categories-toggle">
|
124 |
+
<?php
|
125 |
+
$ci = 0;
|
126 |
+
$categories = $this->get_categories();
|
127 |
+
foreach ( $categories as $slug => $category_title ) {
|
128 |
+
$style = 0 === $ci ? 'display:block' : '';
|
129 |
+
$class = 0 === $ci ? 'wpcode-help-category open' : 'wpcode-help-category';
|
130 |
+
$ci ++;
|
131 |
+
$docs = $this->get_docs_for_category( $slug );
|
132 |
+
$i = 0;
|
133 |
+
?>
|
134 |
+
<li class="<?php echo esc_attr( $class ); ?>">
|
135 |
+
<header>
|
136 |
+
<?php wpcode_icon( 'folder', 28, 22 ); ?>
|
137 |
+
<span><?php echo esc_html( $category_title ); ?></span>
|
138 |
+
<?php wpcode_icon( 'arrow', 10, 16 ); ?>
|
139 |
+
</header>
|
140 |
+
<ul class="wpcode-help-docs" style="<?php echo esc_attr( $style ); ?>">
|
141 |
+
<?php
|
142 |
+
foreach ( $docs as $doc ) {
|
143 |
+
$i ++;
|
144 |
+
?>
|
145 |
+
<li>
|
146 |
+
<?php wpcode_icon( 'file-text', 16, 16 ); ?>
|
147 |
+
<a href="<?php echo esc_url( wpcode_utm_url( $doc['url'], 'docs', 'overlay' ) ); ?>" rel="noopener noreferrer" target="_blank">
|
148 |
+
<?php echo esc_html( $doc['title'] ); ?>
|
149 |
+
</a>
|
150 |
+
</li>
|
151 |
+
<?php
|
152 |
+
if ( 5 === $i && count( $docs ) > 5 ) {
|
153 |
+
echo '<div style="display: none;">';
|
154 |
+
}
|
155 |
+
}
|
156 |
+
if ( count( $docs ) > 5 ) {
|
157 |
+
echo '</div>' // Hidden div for the rest of the elements.
|
158 |
+
?>
|
159 |
+
|
160 |
+
<button class="wpcode-button wpcode-button-secondary viewall" type="button">
|
161 |
+
<?php
|
162 |
+
printf(
|
163 |
+
// Translators: Placeholder for the category name.
|
164 |
+
esc_html__( 'View All %s Docs', 'insert-headers-and-footers' ),
|
165 |
+
esc_html( $category_title )
|
166 |
+
);
|
167 |
+
?>
|
168 |
+
</button>
|
169 |
+
<?php } ?>
|
170 |
+
</ul>
|
171 |
+
</li>
|
172 |
+
<?php } ?>
|
173 |
+
</ul>
|
174 |
+
</div>
|
175 |
+
<?php
|
176 |
+
}
|
177 |
+
}
|
includes/admin/class-wpcode-importers.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Load classes used for importing data from other plugins.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Importers class.
|
10 |
+
*/
|
11 |
+
class WPCode_Importers {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Available importers.
|
15 |
+
*
|
16 |
+
* @var WPCode_Importer_Type[]
|
17 |
+
*/
|
18 |
+
public $importers = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Constructor.
|
22 |
+
*/
|
23 |
+
public function __construct() {
|
24 |
+
$this->require_files();
|
25 |
+
$this->load_importers();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Require the importer classes.
|
30 |
+
*
|
31 |
+
* @return void
|
32 |
+
*/
|
33 |
+
private function require_files() {
|
34 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/importers/class-wpcode-importer-type.php';
|
35 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/importers/class-wpcode-importer-code-snippets.php';
|
36 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/importers/class-wpcode-importer-woody.php';
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the available importers instances.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
private function load_importers() {
|
45 |
+
if ( empty( $this->importers ) ) {
|
46 |
+
$this->importers = array(
|
47 |
+
'code-snippets' => new WPCode_Importer_Code_Snippets(),
|
48 |
+
'woody' => new WPCode_Importer_Woody(),
|
49 |
+
);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get the importers with registered data.
|
55 |
+
*
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
public function get_importers() {
|
59 |
+
|
60 |
+
$importers = array();
|
61 |
+
|
62 |
+
foreach ( $this->importers as $importer ) {
|
63 |
+
$importers = $importer->register( $importers );
|
64 |
+
}
|
65 |
+
|
66 |
+
return $importers;
|
67 |
+
}
|
68 |
+
}
|
includes/admin/class-wpcode-notifications.php
ADDED
@@ -0,0 +1,496 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Notifications from remote source.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Notifications.
|
10 |
+
*/
|
11 |
+
class WPCode_Notifications {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Source of notifications content.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
const SOURCE_URL = 'https://plugin.wpcode.com/wp-content/notifications.json';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Option value.
|
22 |
+
*
|
23 |
+
* @var bool|array
|
24 |
+
*/
|
25 |
+
public $option = false;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The name of the option used to store the data.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
public static $option_name = 'wpcode_notifications';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* WPCode_Notifications constructor.
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
+
$this->init();
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Initialize class.
|
43 |
+
*/
|
44 |
+
public function init() {
|
45 |
+
|
46 |
+
$this->hooks();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Register hooks.
|
51 |
+
*/
|
52 |
+
public function hooks() {
|
53 |
+
add_action( 'wp_ajax_wpcode_notification_dismiss', array( $this, 'dismiss' ) );
|
54 |
+
|
55 |
+
add_action( 'wpcode_admin_notifications_update', array( $this, 'update' ) );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Check if user has access and is enabled.
|
60 |
+
*
|
61 |
+
* @return bool
|
62 |
+
*/
|
63 |
+
public function has_access() {
|
64 |
+
return apply_filters( 'wpcode_admin_notifications_has_access', ! wpcode()->settings->get_option( 'hide_am_notices', false ) );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get option value.
|
69 |
+
*
|
70 |
+
* @param bool $cache Reference property cache if available.
|
71 |
+
*
|
72 |
+
* @return array
|
73 |
+
*/
|
74 |
+
public function get_option( $cache = true ) {
|
75 |
+
|
76 |
+
if ( $this->option && $cache ) {
|
77 |
+
return $this->option;
|
78 |
+
}
|
79 |
+
|
80 |
+
$option = get_option( self::$option_name, array() );
|
81 |
+
|
82 |
+
$this->option = array(
|
83 |
+
'update' => ! empty( $option['update'] ) ? $option['update'] : 0,
|
84 |
+
'events' => ! empty( $option['events'] ) ? $option['events'] : array(),
|
85 |
+
'feed' => ! empty( $option['feed'] ) ? $option['feed'] : array(),
|
86 |
+
'dismissed' => ! empty( $option['dismissed'] ) ? $option['dismissed'] : array(),
|
87 |
+
);
|
88 |
+
|
89 |
+
return $this->option;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Fetch notifications from feed.
|
94 |
+
*
|
95 |
+
* @return array
|
96 |
+
*/
|
97 |
+
public function fetch_feed() {
|
98 |
+
|
99 |
+
$res = wp_remote_get( self::SOURCE_URL );
|
100 |
+
|
101 |
+
if ( is_wp_error( $res ) ) {
|
102 |
+
return array();
|
103 |
+
}
|
104 |
+
|
105 |
+
$body = wp_remote_retrieve_body( $res );
|
106 |
+
|
107 |
+
if ( empty( $body ) ) {
|
108 |
+
return array();
|
109 |
+
}
|
110 |
+
|
111 |
+
return $this->verify( json_decode( $body, true ) );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Verify notification data before it is saved.
|
116 |
+
*
|
117 |
+
* @param array $notifications Array of notifications items to verify.
|
118 |
+
*
|
119 |
+
* @return array
|
120 |
+
* @since {VERSION}
|
121 |
+
*/
|
122 |
+
public function verify( $notifications ) {
|
123 |
+
|
124 |
+
$data = array();
|
125 |
+
|
126 |
+
if ( ! is_array( $notifications ) || empty( $notifications ) ) {
|
127 |
+
return $data;
|
128 |
+
}
|
129 |
+
|
130 |
+
$option = $this->get_option();
|
131 |
+
|
132 |
+
foreach ( $notifications as $notification ) {
|
133 |
+
|
134 |
+
// The message and license should never be empty, if they are, ignore.
|
135 |
+
if ( empty( $notification['content'] ) || empty( $notification['type'] ) ) {
|
136 |
+
continue;
|
137 |
+
}
|
138 |
+
|
139 |
+
// Ignore if notification is not ready to display(based on start time).
|
140 |
+
if ( ! empty( $notification['start'] ) && time() < strtotime( $notification['start'] ) ) {
|
141 |
+
continue;
|
142 |
+
}
|
143 |
+
|
144 |
+
// Ignore if expired.
|
145 |
+
if ( ! empty( $notification['end'] ) && time() > strtotime( $notification['end'] ) ) {
|
146 |
+
continue;
|
147 |
+
}
|
148 |
+
|
149 |
+
// Ignore if notification has already been dismissed.
|
150 |
+
$notification_already_dismissed = false;
|
151 |
+
if ( is_array( $option['dismissed'] ) && ! empty( $option['dismissed'] ) ) {
|
152 |
+
foreach ( $option['dismissed'] as $dismiss_notification ) {
|
153 |
+
if ( $notification['id'] === $dismiss_notification['id'] ) {
|
154 |
+
$notification_already_dismissed = true;
|
155 |
+
break;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
if ( true === $notification_already_dismissed ) {
|
161 |
+
continue;
|
162 |
+
}
|
163 |
+
|
164 |
+
// Ignore if notification existed before installing WPCode.
|
165 |
+
// Prevents bombarding the user with notifications after activation.
|
166 |
+
$activated = get_option( 'ihaf_activated', array() );
|
167 |
+
|
168 |
+
if (
|
169 |
+
! empty( $activated['wpcode'] ) &&
|
170 |
+
! empty( $notification['start'] ) &&
|
171 |
+
$activated['wpcode'] > strtotime( $notification['start'] )
|
172 |
+
) {
|
173 |
+
continue;
|
174 |
+
}
|
175 |
+
|
176 |
+
$data[] = $notification;
|
177 |
+
}
|
178 |
+
|
179 |
+
return $data;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Verify saved notification data for active notifications.
|
184 |
+
*
|
185 |
+
* @param array $notifications Array of notifications items to verify.
|
186 |
+
*
|
187 |
+
* @return array
|
188 |
+
*/
|
189 |
+
public function verify_active( $notifications ) {
|
190 |
+
|
191 |
+
if ( ! is_array( $notifications ) || empty( $notifications ) ) {
|
192 |
+
return array();
|
193 |
+
}
|
194 |
+
|
195 |
+
// Remove notifications that are not active, or if the license type not exists.
|
196 |
+
foreach ( $notifications as $key => $notification ) {
|
197 |
+
if (
|
198 |
+
( ! empty( $notification['start'] ) && time() < strtotime( $notification['start'] ) ) ||
|
199 |
+
( ! empty( $notification['end'] ) && time() > strtotime( $notification['end'] ) )
|
200 |
+
) {
|
201 |
+
unset( $notifications[ $key ] );
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
return $notifications;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Get notification data.
|
210 |
+
*
|
211 |
+
* @return array
|
212 |
+
*/
|
213 |
+
public function get() {
|
214 |
+
|
215 |
+
if ( ! $this->has_access() ) {
|
216 |
+
return array();
|
217 |
+
}
|
218 |
+
|
219 |
+
$option = $this->get_option();
|
220 |
+
|
221 |
+
// Update notifications using async task.
|
222 |
+
if ( empty( $option['update'] ) || time() > $option['update'] + DAY_IN_SECONDS ) {
|
223 |
+
if ( false === wp_next_scheduled( 'wpcode_admin_notifications_update' ) ) {
|
224 |
+
wp_schedule_single_event( time(), 'wpcode_admin_notifications_update' );
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
$events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : array();
|
229 |
+
$feed = ! empty( $option['feed'] ) ? $this->verify_active( $option['feed'] ) : array();
|
230 |
+
|
231 |
+
$notifications = array();
|
232 |
+
$notifications['active'] = array_merge( $events, $feed );
|
233 |
+
$notifications['active'] = $this->get_notifications_with_human_readeable_start_time( $notifications['active'] );
|
234 |
+
$notifications['active'] = $this->get_notifications_with_formatted_content( $notifications['active'] );
|
235 |
+
$notifications['dismissed'] = ! empty( $option['dismissed'] ) ? $option['dismissed'] : array();
|
236 |
+
$notifications['dismissed'] = $this->get_notifications_with_human_readeable_start_time( $notifications['dismissed'] );
|
237 |
+
$notifications['dismissed'] = $this->get_notifications_with_formatted_content( $notifications['dismissed'] );
|
238 |
+
|
239 |
+
return $notifications;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Improve format of the content of notifications before display. By default, it just runs wpautop.
|
244 |
+
*
|
245 |
+
* @param array $notifications The notifications to be parsed.
|
246 |
+
*
|
247 |
+
* @return array
|
248 |
+
*/
|
249 |
+
public function get_notifications_with_formatted_content( $notifications ) {
|
250 |
+
if ( ! is_array( $notifications ) || empty( $notifications ) ) {
|
251 |
+
return $notifications;
|
252 |
+
}
|
253 |
+
|
254 |
+
foreach ( $notifications as $key => $notification ) {
|
255 |
+
if ( ! empty( $notification['content'] ) ) {
|
256 |
+
$notifications[ $key ]['content'] = wpautop( $notification['content'] );
|
257 |
+
$notifications[ $key ]['content'] = apply_filters( 'wpcode_notification_content_display', $notifications[ $key ]['content'] );
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
return $notifications;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Get notifications start time with human time difference
|
266 |
+
*
|
267 |
+
* @param array $notifications The array of notifications to convert.
|
268 |
+
*
|
269 |
+
* @return array
|
270 |
+
*/
|
271 |
+
public function get_notifications_with_human_readeable_start_time( $notifications ) {
|
272 |
+
if ( ! is_array( $notifications ) || empty( $notifications ) ) {
|
273 |
+
return array();
|
274 |
+
}
|
275 |
+
|
276 |
+
foreach ( $notifications as $key => $notification ) {
|
277 |
+
if ( empty( $notification['start'] ) ) {
|
278 |
+
continue;
|
279 |
+
}
|
280 |
+
|
281 |
+
// Translators: Human-Readable time to display.
|
282 |
+
$modified_start_time = sprintf( __( '%1$s ago', 'insert-headers-and-footers' ), human_time_diff( strtotime( $notification['start'] ), time() ) );
|
283 |
+
$notifications[ $key ]['start'] = $modified_start_time;
|
284 |
+
}
|
285 |
+
|
286 |
+
return $notifications;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Get active notifications.
|
291 |
+
*
|
292 |
+
* @return array $notifications['active'] active notifications
|
293 |
+
*/
|
294 |
+
public function get_active_notifications() {
|
295 |
+
$notifications = $this->get();
|
296 |
+
|
297 |
+
// Show only 5 active notifications plus any that has a priority of 1.
|
298 |
+
$all_active = isset( $notifications['active'] ) ? $notifications['active'] : array();
|
299 |
+
$displayed = array();
|
300 |
+
|
301 |
+
foreach ( $all_active as $notification ) {
|
302 |
+
if ( ( isset( $notification['priority'] ) && 1 === $notification['priority'] ) || count( $displayed ) < 5 ) {
|
303 |
+
$displayed[] = $notification;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
return $displayed;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Get dismissed notifications.
|
312 |
+
*
|
313 |
+
* @return array $notifications['dismissed'] dismissed notifications
|
314 |
+
*/
|
315 |
+
public function get_dismissed_notifications() {
|
316 |
+
$notifications = $this->get();
|
317 |
+
|
318 |
+
return isset( $notifications['dismissed'] ) ? $notifications['dismissed'] : array();
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Get notification count.
|
323 |
+
*
|
324 |
+
* @return int
|
325 |
+
*/
|
326 |
+
public function get_count() {
|
327 |
+
return count( $this->get_active_notifications() );
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Get the dismissed notifications count.
|
332 |
+
*
|
333 |
+
* @return int
|
334 |
+
*/
|
335 |
+
public function get_dismissed_count() {
|
336 |
+
return count( $this->get_dismissed_notifications() );
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Check if a notification has been dismissed before
|
341 |
+
*
|
342 |
+
* @param array $notification The notification to check if is dismissed.
|
343 |
+
*
|
344 |
+
* @return bool
|
345 |
+
*/
|
346 |
+
public function is_dismissed( $notification ) {
|
347 |
+
if ( empty( $notification['id'] ) ) {
|
348 |
+
return true;
|
349 |
+
}
|
350 |
+
|
351 |
+
$option = $this->get_option();
|
352 |
+
|
353 |
+
foreach ( $option['dismissed'] as $item ) {
|
354 |
+
if ( $item['id'] === $notification['id'] ) {
|
355 |
+
return true;
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
return false;
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Add a manual notification event.
|
364 |
+
*
|
365 |
+
* @param array $notification Notification data.
|
366 |
+
*/
|
367 |
+
public function add( $notification ) {
|
368 |
+
|
369 |
+
if ( empty( $notification['id'] ) || $this->is_dismissed( $notification ) ) {
|
370 |
+
return false;
|
371 |
+
}
|
372 |
+
|
373 |
+
$option = $this->get_option();
|
374 |
+
|
375 |
+
$current_notifications = $option['events'];
|
376 |
+
|
377 |
+
foreach ( $current_notifications as $item ) {
|
378 |
+
if ( $item['id'] === $notification['id'] ) {
|
379 |
+
return false;
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
$notification = $this->verify( array( $notification ) );
|
384 |
+
|
385 |
+
$notifications = array_merge( $notification, $current_notifications );
|
386 |
+
|
387 |
+
// Sort notifications by priority.
|
388 |
+
usort(
|
389 |
+
$notifications,
|
390 |
+
function ( $a, $b ) {
|
391 |
+
if ( ! isset( $a['priority'] ) || ! isset( $b['priority'] ) ) {
|
392 |
+
return 0;
|
393 |
+
}
|
394 |
+
|
395 |
+
if ( $a['priority'] === $b['priority'] ) {
|
396 |
+
return 0;
|
397 |
+
}
|
398 |
+
|
399 |
+
return $a['priority'] < $b['priority'] ? - 1 : 1;
|
400 |
+
}
|
401 |
+
);
|
402 |
+
|
403 |
+
update_option(
|
404 |
+
self::$option_name,
|
405 |
+
array(
|
406 |
+
'update' => $option['update'],
|
407 |
+
'feed' => $option['feed'],
|
408 |
+
'events' => $notifications,
|
409 |
+
'dismissed' => $option['dismissed'],
|
410 |
+
),
|
411 |
+
false
|
412 |
+
);
|
413 |
+
|
414 |
+
return true;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Update notification data from feed.
|
419 |
+
*
|
420 |
+
* @since {VERSION}
|
421 |
+
*/
|
422 |
+
public function update() {
|
423 |
+
|
424 |
+
$feed = $this->fetch_feed();
|
425 |
+
$option = $this->get_option();
|
426 |
+
|
427 |
+
update_option(
|
428 |
+
self::$option_name,
|
429 |
+
array(
|
430 |
+
'update' => time(),
|
431 |
+
'feed' => $feed,
|
432 |
+
'events' => $option['events'],
|
433 |
+
'dismissed' => array_slice( $option['dismissed'], 0, 30 ), // Limit dismissed notifications to last 30.
|
434 |
+
),
|
435 |
+
false
|
436 |
+
);
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Dismiss notification via AJAX.
|
441 |
+
*/
|
442 |
+
public function dismiss() {
|
443 |
+
// Run a security check.
|
444 |
+
check_ajax_referer( 'wpcode_admin', 'nonce' );
|
445 |
+
|
446 |
+
// Check for access and required param.
|
447 |
+
if ( ! $this->has_access() || empty( $_POST['id'] ) ) {
|
448 |
+
wp_send_json_error();
|
449 |
+
}
|
450 |
+
|
451 |
+
$id = sanitize_text_field( wp_unslash( $_POST['id'] ) );
|
452 |
+
$option = $this->get_option();
|
453 |
+
|
454 |
+
// Dismiss all notifications and add them to dissmiss array.
|
455 |
+
if ( 'all' === $id ) {
|
456 |
+
if ( is_array( $option['feed'] ) && ! empty( $option['feed'] ) ) {
|
457 |
+
foreach ( $option['feed'] as $key => $notification ) {
|
458 |
+
array_unshift( $option['dismissed'], $notification );
|
459 |
+
unset( $option['feed'][ $key ] );
|
460 |
+
}
|
461 |
+
}
|
462 |
+
if ( is_array( $option['events'] ) && ! empty( $option['events'] ) ) {
|
463 |
+
foreach ( $option['events'] as $key => $notification ) {
|
464 |
+
array_unshift( $option['dismissed'], $notification );
|
465 |
+
unset( $option['events'][ $key ] );
|
466 |
+
}
|
467 |
+
}
|
468 |
+
}
|
469 |
+
|
470 |
+
$type = is_numeric( $id ) ? 'feed' : 'events';
|
471 |
+
|
472 |
+
// Remove notification and add in dismissed array.
|
473 |
+
if ( is_array( $option[ $type ] ) && ! empty( $option[ $type ] ) ) {
|
474 |
+
foreach ( $option[ $type ] as $key => $notification ) {
|
475 |
+
if ( $notification['id'] == $id ) { // phpcs:ignore WordPress.PHP.StrictComparisons
|
476 |
+
// Add notification to dismissed array.
|
477 |
+
array_unshift( $option['dismissed'], $notification );
|
478 |
+
// Remove notification from feed or events.
|
479 |
+
unset( $option[ $type ][ $key ] );
|
480 |
+
break;
|
481 |
+
}
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
update_option( self::$option_name, $option, false );
|
486 |
+
|
487 |
+
wp_send_json_success();
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Delete the notification options.
|
492 |
+
*/
|
493 |
+
public static function delete_notifications_data() {
|
494 |
+
delete_option( self::$option_name );
|
495 |
+
}
|
496 |
+
}
|
includes/admin/class-wpcode-upgrade-welcome.php
ADDED
@@ -0,0 +1,314 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Upgrade Welcome screen.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* This page is shown when the plugin is updated from IHAF to WPCode.
|
10 |
+
*/
|
11 |
+
class WPCode_Upgrade_Welcome {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Hidden welcome page slug.
|
15 |
+
*/
|
16 |
+
const SLUG = 'wpcode-upgrade-welcome';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Primary class constructor.
|
20 |
+
*/
|
21 |
+
public function __construct() {
|
22 |
+
add_action( 'init', array( $this, 'hooks' ) );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Register the pages to be used for the Welcome screen.
|
27 |
+
*/
|
28 |
+
public function register() {
|
29 |
+
add_dashboard_page(
|
30 |
+
esc_html__( 'Welcome to WPCode', 'insert-headers-and-footers' ),
|
31 |
+
esc_html__( 'Welcome to WPCode', 'insert-headers-and-footers' ),
|
32 |
+
'wpcode_edit_snippets',
|
33 |
+
self::SLUG,
|
34 |
+
array( $this, 'output' )
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Register all WP hooks.
|
40 |
+
*/
|
41 |
+
public function hooks() {
|
42 |
+
|
43 |
+
// If user is in admin ajax or doing cron, return.
|
44 |
+
if ( wp_doing_ajax() || wp_doing_cron() ) {
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
|
48 |
+
// If user did not update (or can't update) the plugin don't show the screen.
|
49 |
+
if ( ! current_user_can( 'update_plugins' ) ) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
|
53 |
+
add_action( 'admin_menu', array( $this, 'register' ) );
|
54 |
+
add_action( 'admin_head', array( $this, 'hide_menu' ) );
|
55 |
+
add_action( 'admin_init', array( $this, 'redirect' ), 9999 );
|
56 |
+
add_action( 'admin_body_class', array( $this, 'body_class' ) );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Remove the dashboard page from the admin menu.
|
61 |
+
*/
|
62 |
+
public function hide_menu() {
|
63 |
+
|
64 |
+
remove_submenu_page( 'index.php', self::SLUG );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Welcome screen redirect. Only redirect if the user was previously using IHAF 1.6.x.
|
69 |
+
*/
|
70 |
+
public function redirect() {
|
71 |
+
|
72 |
+
$redirect = get_transient( 'wpcode_upgrade_redirect' );
|
73 |
+
|
74 |
+
if ( false === $redirect ) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
// Only redirect once.
|
79 |
+
delete_transient( 'wpcode_upgrade_redirect' );
|
80 |
+
|
81 |
+
wp_safe_redirect( admin_url( 'index.php?page=' . self::SLUG ) );
|
82 |
+
exit;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add a body class for this page only.
|
87 |
+
*
|
88 |
+
* @param string $body_class The body class.
|
89 |
+
*
|
90 |
+
* @return string
|
91 |
+
*/
|
92 |
+
public function body_class( $body_class ) {
|
93 |
+
$screen = get_current_screen();
|
94 |
+
|
95 |
+
if ( ! empty( $screen->id ) && false !== strpos( $screen->id, self::SLUG ) ) {
|
96 |
+
$body_class .= ' ' . self::SLUG;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $body_class;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Output of the upgrade screen.
|
104 |
+
*/
|
105 |
+
public function output() {
|
106 |
+
$settings_link = add_query_arg(
|
107 |
+
array(
|
108 |
+
'page' => 'wpcode-settings',
|
109 |
+
),
|
110 |
+
admin_url( 'admin.php' )
|
111 |
+
);
|
112 |
+
$snippets_page = add_query_arg(
|
113 |
+
array(
|
114 |
+
'page' => 'wpcode',
|
115 |
+
),
|
116 |
+
admin_url( 'admin.php' )
|
117 |
+
);
|
118 |
+
$image_generator = WPCODE_PLUGIN_URL . 'admin/images/upgrade-welcome-generator.jpg';
|
119 |
+
$image_settings = WPCODE_PLUGIN_URL . 'admin/images/upgrade-welcome-headers-footers.jpg';
|
120 |
+
$image_cloud = WPCODE_PLUGIN_URL . 'admin/images/upgrade-welcome-cloud.jpg';
|
121 |
+
$features = array(
|
122 |
+
array(
|
123 |
+
'icon' => 'code',
|
124 |
+
'title' => __( 'Header & Footer Scripts', 'insert-headers-and-footers' ),
|
125 |
+
'desc' => __( 'Effortlessly manage global headers & footers in a familiar interface.', 'insert-headers-and-footers' ),
|
126 |
+
),
|
127 |
+
array(
|
128 |
+
'icon' => 'filter',
|
129 |
+
'title' => __( 'Conversion Pixels', 'insert-headers-and-footers' ),
|
130 |
+
'desc' => __( 'Easily target specific pages to track conversions reliably.', 'insert-headers-and-footers' ),
|
131 |
+
),
|
132 |
+
array(
|
133 |
+
'icon' => 'php',
|
134 |
+
'title' => __( 'PHP Snippets', 'insert-headers-and-footers' ),
|
135 |
+
'desc' => __( 'Add or remove features with full confidence that your site will not break.', 'insert-headers-and-footers' ),
|
136 |
+
),
|
137 |
+
array(
|
138 |
+
'icon' => 'split',
|
139 |
+
'title' => __( 'Conditional Logic', 'insert-headers-and-footers' ),
|
140 |
+
'desc' => __( 'Create advanced conditional logic rules in an easy-to-use interface.', 'insert-headers-and-footers' ),
|
141 |
+
),
|
142 |
+
array(
|
143 |
+
'icon' => 'error_badge',
|
144 |
+
'title' => __( 'Error Handling', 'insert-headers-and-footers' ),
|
145 |
+
'desc' => __( 'Unique error handling capabilities ensure you will not get locked out of your site.', 'insert-headers-and-footers' ),
|
146 |
+
),
|
147 |
+
array(
|
148 |
+
'icon' => 'terminal',
|
149 |
+
'title' => __( 'Snippets Library', 'insert-headers-and-footers' ),
|
150 |
+
'desc' => __( 'One-click install from our extensive library of commonly-used snippets.', 'insert-headers-and-footers' ),
|
151 |
+
),
|
152 |
+
);
|
153 |
+
$logo_src = WPCODE_PLUGIN_URL . 'admin/images/wpcode-logo.png';
|
154 |
+
// Translators: This simply adds the plugin name before the logo text.
|
155 |
+
$logo_alt = sprintf( __( '%s logo', 'insert-headers-and-footers' ), 'WPCode' );
|
156 |
+
$syed_photo = WPCODE_PLUGIN_URL . 'admin/images/syed.png';
|
157 |
+
$mircea_photo = WPCODE_PLUGIN_URL . 'admin/images/mircea.png';
|
158 |
+
?>
|
159 |
+
<div class="wpcode-welcome-content">
|
160 |
+
<div class="wpcode-welcome-logo">
|
161 |
+
<img src="<?php echo esc_url( $logo_src ); ?>" width="132" alt="<?php echo esc_attr( $logo_alt ); ?>"/>
|
162 |
+
</div>
|
163 |
+
<div class="wpcode-welcome-box">
|
164 |
+
<h2><?php esc_html_e( 'Insert Headers and Footers is now WPCode', 'insert-headers-and-footers' ); ?></h2>
|
165 |
+
<p><?php esc_html_e( 'When we first built Insert Headers and Footers over a decade ago, it was meant to do one very simple thing: add header and footer scripts to your site without editing theme files.', 'insert-headers-and-footers' ); ?></p>
|
166 |
+
<p><?php esc_html_e( 'Since then, the plugin has grown to over 1 million active installs with an amazing user base. We have continued to receive feature requests to add more options like controlling which pages the scripts get loaded, allowing more types of code snippets, etc.', 'insert-headers-and-footers' ); ?></p>
|
167 |
+
<p><?php esc_html_e( 'We listened to your feedback, and we are excited to present WPCode, the next generation of Insert Headers and Footers. We chose a new name because it was only fair considering the plugin is now 10x more powerful. Aside from adding global headers and footer snippets, you can also add multiple other types of code snippets, have granular control of where the snippets are output with conditional logic, and a whole lot more.', 'insert-headers-and-footers' ); ?></p>
|
168 |
+
<p>
|
169 |
+
<?php
|
170 |
+
printf(
|
171 |
+
// Translators: Placeholders 1 & 2 add a link to scroll down the page and 3 & 4 add a link to the suggestions form.
|
172 |
+
esc_html__(
|
173 |
+
'Please see the full list of features %1$sbelow%2$s and let us know what you\'d like us to add next by %3$ssharing your feedback%4$s.',
|
174 |
+
'insert-headers-and-footers'
|
175 |
+
),
|
176 |
+
'<a href="#features" class="wpcode-scroll-to">',
|
177 |
+
'</a>',
|
178 |
+
'<a href="' . esc_url( wpcode_utm_url( 'https://wpcode.com/suggestions/', 'welcome', 'intro' ) ) . '" target="_blank">',
|
179 |
+
'</a>'
|
180 |
+
);
|
181 |
+
?>
|
182 |
+
</p>
|
183 |
+
<p>
|
184 |
+
<?php
|
185 |
+
printf(
|
186 |
+
// Translators: Placeholders add link to the details about settings.
|
187 |
+
esc_html__(
|
188 |
+
'For those of you who want to limit the functionality and switch back to the old interface, you can do so with one click. %1$sSee details here%2$s.',
|
189 |
+
'insert-headers-and-footers'
|
190 |
+
),
|
191 |
+
'<a href="#old_interface" class="wpcode-scroll-to">',
|
192 |
+
'</a>'
|
193 |
+
);
|
194 |
+
?>
|
195 |
+
</p>
|
196 |
+
<p><?php esc_html_e( 'We have an exciting roadmap ahead of us since you have shared tons of great ideas with us over the last several years. We truly appreciate your continued support and thank you for being an awesome user.', 'insert-headers-and-footers' ); ?></p>
|
197 |
+
<p><?php esc_html_e( 'We truly appreciate your continued support and thank you for using WPCode.', 'insert-headers-and-footers' ); ?></p>
|
198 |
+
<div class="wpcode-welcome-syed-mircea">
|
199 |
+
<div class="wpcode-welcome-person">
|
200 |
+
<div class="wpcode-welcome-person-image">
|
201 |
+
<img src="<?php echo esc_attr( $syed_photo ); ?>" alt="Syed" width="48"/>
|
202 |
+
</div>
|
203 |
+
<div class="wpcode-welcome-person-text">
|
204 |
+
<h4>Syed Balkhi</h4>
|
205 |
+
<?php
|
206 |
+
printf(
|
207 |
+
// Translators: Placeholder for "WPBeginner".
|
208 |
+
esc_html__( 'Founder of %s', 'insert-headers-and-footers' ),
|
209 |
+
'WPBeginner'
|
210 |
+
);
|
211 |
+
?>
|
212 |
+
</div>
|
213 |
+
</div>
|
214 |
+
<div class="wpcode-welcome-person">
|
215 |
+
<div class="wpcode-welcome-person-image">
|
216 |
+
<img src="<?php echo esc_attr( $mircea_photo ); ?>" alt="Mircea" width="48"/>
|
217 |
+
</div>
|
218 |
+
<div class="wpcode-welcome-person-text">
|
219 |
+
<h4>Mircea Sandu</h4>
|
220 |
+
<?php esc_html_e( 'Lead Developer', 'insert-headers-and-footers' ); ?>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
+
</div>
|
224 |
+
</div>
|
225 |
+
<div class="wpcode-welcome-box" id="features">
|
226 |
+
<h2><?php esc_html_e( 'What’s New in WPCode (Features & Highlights)', 'insert-headers-and-footers' ); ?></h2>
|
227 |
+
<div class="wpcode-welcome-features">
|
228 |
+
<?php foreach ( $features as $feature ) { ?>
|
229 |
+
<div class="wpcode-welcome-feature">
|
230 |
+
<div class="wpcode-welcome-feature-icon">
|
231 |
+
<div class="wpcode-welcome-feature-icon-icon">
|
232 |
+
<?php wpcode_icon( $feature['icon'], 30, 30, '0 0 48 48' ); ?>
|
233 |
+
</div>
|
234 |
+
</div>
|
235 |
+
<div class="wpcode-welcome-feature-text">
|
236 |
+
<h3><?php echo esc_html( $feature['title'] ); ?></h3>
|
237 |
+
<p><?php echo esc_html( $feature['desc'] ); ?></p>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
+
<?php } ?>
|
241 |
+
</div>
|
242 |
+
</div>
|
243 |
+
<div class="wpcode-welcome-box">
|
244 |
+
<div class="wpcode-welcome-highlight">
|
245 |
+
<div class="wpcode-welcome-highlight-column">
|
246 |
+
<img src="<?php echo esc_url( $image_generator ); ?>" alt="<?php esc_attr_e( 'WPCode Generator Screen capture', 'insert-headers-and-footers' ); ?>"/>
|
247 |
+
</div>
|
248 |
+
<div class="wpcode-welcome-highlight-column">
|
249 |
+
<h3><?php esc_html_e( 'Snippet Generator', 'insert-headers-and-footers' ); ?></h3>
|
250 |
+
<p><?php esc_html_e( 'WPCode now includes a snippet generator directly in the plugin.', 'insert-headers-and-footers' ); ?></p>
|
251 |
+
<p><?php esc_html_e( 'Using the built-in generators, you can quickly add custom post types, custom post statuses, widgets, menus, build complex WP Queries and much more.', 'insert-headers-and-footers' ); ?></p>
|
252 |
+
<p><?php esc_html_e( 'Simply fill in the fields in our guided wizard to generate a custom ready-to-use snippet for your website with 1 click. Try WordPress Snippet Generator.', 'insert-headers-and-footers' ); ?></p>
|
253 |
+
</div>
|
254 |
+
</div>
|
255 |
+
</div>
|
256 |
+
<div class="wpcode-welcome-box">
|
257 |
+
<div class="wpcode-welcome-highlight">
|
258 |
+
<div class="wpcode-welcome-highlight-column">
|
259 |
+
<h3><?php esc_html_e( 'Store Snippets in Cloud (Coming Soon)', 'insert-headers-and-footers' ); ?></h3>
|
260 |
+
<p><?php esc_html_e( 'A lot of you requested the ability to save and re-use snippets on multiple websites.', 'insert-headers-and-footers' ); ?></p>
|
261 |
+
<p><?php esc_html_e( 'We\'re working on this feature to help you save time when managing multiple projects.', 'insert-headers-and-footers' ); ?></p>
|
262 |
+
<p>
|
263 |
+
<?php
|
264 |
+
printf(
|
265 |
+
// Translators: Placeholders add a link to the suggestions page.
|
266 |
+
esc_html__(
|
267 |
+
'If you have specific ideas or feature requests, please let us know by %1$sfilling out this form%2$s.',
|
268 |
+
'insert-headers-and-footers'
|
269 |
+
),
|
270 |
+
'<a href="' . esc_url( wpcode_utm_url( 'https://wpcode.com/suggestions/', 'welcome', 'cloud' ) ) . '" target="_blank">',
|
271 |
+
'</a>'
|
272 |
+
);
|
273 |
+
?>
|
274 |
+
</p>
|
275 |
+
</div>
|
276 |
+
<div class="wpcode-welcome-highlight-column">
|
277 |
+
<img src="<?php echo esc_url( $image_cloud ); ?>" alt="<?php esc_attr_e( 'WPCode Cloud Screen capture', 'insert-headers-and-footers' ); ?>"/>
|
278 |
+
</div>
|
279 |
+
</div>
|
280 |
+
</div>
|
281 |
+
<div class="wpcode-welcome-box">
|
282 |
+
<div class="wpcode-welcome-highlight" id="old_interface">
|
283 |
+
<div class="wpcode-welcome-highlight-column">
|
284 |
+
<img src="<?php echo esc_url( $image_settings ); ?>" alt="<?php esc_attr_e( 'WPCode Generator Screen capture', 'insert-headers-and-footers' ); ?>"/>
|
285 |
+
</div>
|
286 |
+
<div class="wpcode-welcome-highlight-column">
|
287 |
+
<h3><?php esc_html_e( 'Not ready for the new interface?', 'insert-headers-and-footers' ); ?></h3>
|
288 |
+
<p><?php esc_html_e( 'If you are not ready to switch to the new interface, or you simply want to use the plugin just for inserting headers and footers we\'ve got you covered.', 'insert-headers-and-footers' ); ?></p>
|
289 |
+
<p>
|
290 |
+
<?php
|
291 |
+
printf(
|
292 |
+
// Translators: Placeholders add a link to the settings page.
|
293 |
+
esc_html__(
|
294 |
+
'You can switch to the simple Headers & Footers interface at any time from the %1$ssettings page%2$s.',
|
295 |
+
'insert-headers-and-footers'
|
296 |
+
),
|
297 |
+
'<a href="' . esc_url( $settings_link ) . '">',
|
298 |
+
'</a>'
|
299 |
+
);
|
300 |
+
?>
|
301 |
+
</p>
|
302 |
+
<p><?php esc_html_e( 'And if you change your mind later and want to give the full plugin a shot, you can always switch back with just 2 clicks using the option at the top of the page.', 'insert-headers-and-footers' ); ?></p>
|
303 |
+
</div>
|
304 |
+
</div>
|
305 |
+
</div>
|
306 |
+
<div class="wpcode-buttons-row">
|
307 |
+
<a href="<?php echo esc_url( $snippets_page ); ?>" class="wpcode-button wpcode-button-large"><?php esc_html_e( 'Add Your First Snippet', 'insert-headers-and-footers' ); ?></a>
|
308 |
+
</div>
|
309 |
+
</div>
|
310 |
+
<?php
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
new WPCode_Upgrade_Welcome();
|
includes/admin/importers/class-wpcode-importer-code-snippets.php
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Importer for Code Snippets.
|
4 |
+
*
|
5 |
+
* @package WPCode.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Importer_Code_Snippets.
|
10 |
+
*/
|
11 |
+
class WPCode_Importer_Code_Snippets extends WPCode_Importer_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The plugin name.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'Code Snippets';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Importer slug.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
public $slug = 'code-snippets';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Plugin path.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
public $path = 'code-snippets/code-snippets.php';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get an array of snippets for this plugin.
|
36 |
+
*
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function get_snippets() {
|
40 |
+
|
41 |
+
$snippets = array();
|
42 |
+
|
43 |
+
if ( ! $this->is_active() ) {
|
44 |
+
return $snippets;
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( ! function_exists( '\Code_Snippets\get_snippets' ) ) {
|
48 |
+
return $snippets;
|
49 |
+
}
|
50 |
+
|
51 |
+
$code_snippets = \Code_Snippets\get_snippets();
|
52 |
+
|
53 |
+
foreach ( $code_snippets as $code_snippet ) {
|
54 |
+
/**
|
55 |
+
* The Code Snippets Snippet object.
|
56 |
+
*
|
57 |
+
* @var \Code_Snippets\Snippet $code_snippet
|
58 |
+
*/
|
59 |
+
$snippets[ $code_snippet->id ] = $code_snippet->name;
|
60 |
+
}
|
61 |
+
|
62 |
+
return $snippets;
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Import the snippet data.
|
68 |
+
*
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
public function import_snippet() {
|
72 |
+
// Run a security check.
|
73 |
+
check_ajax_referer( 'wpcode_admin' );
|
74 |
+
|
75 |
+
if ( ! current_user_can( 'wpcode_edit_snippets' ) ) {
|
76 |
+
wp_send_json_error();
|
77 |
+
}
|
78 |
+
|
79 |
+
if ( ! function_exists( '\Code_Snippets\get_snippets' ) ) {
|
80 |
+
wp_send_json_error();
|
81 |
+
}
|
82 |
+
|
83 |
+
$id = isset( $_POST['snippet_id'] ) ? absint( $_POST['snippet_id'] ) : 0;
|
84 |
+
|
85 |
+
// Grab a snippet from Code Snippets.
|
86 |
+
$snippets = \Code_Snippets\get_snippets( array( $id ) );
|
87 |
+
|
88 |
+
if ( empty( $snippets ) || empty( $snippets[0] ) ) {
|
89 |
+
wp_send_json_error(
|
90 |
+
array(
|
91 |
+
'error' => true,
|
92 |
+
'name' => esc_html__( 'Unknown Snippet', 'insert-headers-and-footers' ),
|
93 |
+
'msg' => esc_html__( 'The snippet you are trying to import does not exist.', 'insert-headers-and-footers' ),
|
94 |
+
)
|
95 |
+
);
|
96 |
+
}
|
97 |
+
|
98 |
+
// If we got so far we have a snippet to process.
|
99 |
+
$snippet = $snippets[0];
|
100 |
+
|
101 |
+
// Create a new snippet from the snippet data array.
|
102 |
+
$new_snippet = new WPCode_Snippet( $this->get_snippet_data( $snippet ) );
|
103 |
+
|
104 |
+
$new_snippet->save();
|
105 |
+
|
106 |
+
if ( ! empty( $new_snippet->get_id() ) ) {
|
107 |
+
wp_send_json_success(
|
108 |
+
array(
|
109 |
+
'name' => $new_snippet->get_title(),
|
110 |
+
'edit' => esc_url_raw(
|
111 |
+
add_query_arg(
|
112 |
+
array(
|
113 |
+
'page' => 'wpcode-snippet-manager',
|
114 |
+
'snippet_id' => $new_snippet->get_id(),
|
115 |
+
),
|
116 |
+
admin_url( 'admin.php' )
|
117 |
+
)
|
118 |
+
),
|
119 |
+
)
|
120 |
+
);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Convert a "Code Snippets" snippet to the format for a WPCode snippet.
|
126 |
+
*
|
127 |
+
* @param \Code_Snippets\Snippet $snippet The snippet object.
|
128 |
+
*
|
129 |
+
* @return array
|
130 |
+
*/
|
131 |
+
public function get_snippet_data( $snippet ) {
|
132 |
+
|
133 |
+
$code_type = $this->get_snippet_type( $snippet );
|
134 |
+
$auto_insert = 1;
|
135 |
+
switch ( $snippet->scope ) {
|
136 |
+
case 'admin':
|
137 |
+
$location = 'admin_only';
|
138 |
+
break;
|
139 |
+
case 'front-end':
|
140 |
+
$location = 'frontend_only';
|
141 |
+
break;
|
142 |
+
default:
|
143 |
+
$location = 'everywhere';
|
144 |
+
}
|
145 |
+
if ( 'php' !== $code_type ) {
|
146 |
+
$location = '';
|
147 |
+
$auto_insert = 0;
|
148 |
+
}
|
149 |
+
|
150 |
+
return array(
|
151 |
+
'code' => $snippet->code,
|
152 |
+
'note' => $snippet->desc,
|
153 |
+
'title' => $snippet->name,
|
154 |
+
'tags' => $snippet->tags,
|
155 |
+
'code_type' => $code_type,
|
156 |
+
'priority' => $snippet->priority,
|
157 |
+
'location' => $location,
|
158 |
+
'auto_insert' => $auto_insert,
|
159 |
+
);
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Get the snippet type from the scope as the method in \Code_Snippets\Snippet is private.
|
164 |
+
*
|
165 |
+
* @param \Code_Snippets\Snippet $snippet The snippet to check the scope for.
|
166 |
+
*
|
167 |
+
* @return string
|
168 |
+
*/
|
169 |
+
public function get_snippet_type( $snippet ) {
|
170 |
+
if ( ! isset( $snippet->scope ) ) {
|
171 |
+
return 'php';
|
172 |
+
}
|
173 |
+
|
174 |
+
if ( '-css' === substr( $snippet->scope, - 4 ) ) {
|
175 |
+
return 'html';
|
176 |
+
}
|
177 |
+
|
178 |
+
if ( '-js' === substr( $snippet->scope, - 3 ) ) {
|
179 |
+
return 'js';
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( 'content' === substr( $snippet->scope, - 7 ) ) {
|
183 |
+
return 'universal';
|
184 |
+
}
|
185 |
+
|
186 |
+
return 'php';
|
187 |
+
}
|
188 |
+
}
|
includes/admin/importers/class-wpcode-importer-type.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Abstract class for importing data from other plugins.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Abstract class WPCode_Importer_Type.
|
10 |
+
*/
|
11 |
+
abstract class WPCode_Importer_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The plugin name.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = '';
|
19 |
+
/**
|
20 |
+
* The plugin slug.
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
public $slug = '';
|
25 |
+
/**
|
26 |
+
* The plugin path.
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $path = '';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Constructor.
|
34 |
+
*/
|
35 |
+
public function __construct() {
|
36 |
+
add_action( "wp_ajax_wpcode_import_snippet_{$this->slug}", array( $this, 'import_snippet' ) );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Add to list of registered importers.
|
41 |
+
*
|
42 |
+
* @param array $importers List of supported importers.
|
43 |
+
*
|
44 |
+
* @return array
|
45 |
+
*/
|
46 |
+
public function register( $importers = array() ) {
|
47 |
+
|
48 |
+
$importers[ $this->slug ] = array(
|
49 |
+
'name' => $this->name,
|
50 |
+
'slug' => $this->slug,
|
51 |
+
'path' => $this->path,
|
52 |
+
'installed' => file_exists( trailingslashit( WP_PLUGIN_DIR ) . $this->path ),
|
53 |
+
'active' => $this->is_active(),
|
54 |
+
);
|
55 |
+
|
56 |
+
return $importers;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Get all the snippets for this plugin.
|
61 |
+
*
|
62 |
+
* @return array
|
63 |
+
*/
|
64 |
+
abstract public function get_snippets();
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Check if the plugin is active.
|
68 |
+
*
|
69 |
+
* @return bool
|
70 |
+
*/
|
71 |
+
public function is_active() {
|
72 |
+
return is_plugin_active( $this->path );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* After a snippet has been successfully imported we track it, so that in the
|
77 |
+
* future we can alert users if they try to import a snippet that has already
|
78 |
+
* been imported.
|
79 |
+
*
|
80 |
+
* @param int $source_id Imported plugin snippet ID.
|
81 |
+
* @param int $wpcode_id WPCode snippet ID.
|
82 |
+
*/
|
83 |
+
public function track_import( $source_id, $wpcode_id ) {
|
84 |
+
|
85 |
+
$imported = get_option( 'wpcode_imported', array() );
|
86 |
+
|
87 |
+
$imported[ $this->slug ][ $wpcode_id ] = $source_id;
|
88 |
+
|
89 |
+
update_option( 'wpcode_imported', $imported, false );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Import a single snippet using AJAX.
|
94 |
+
*
|
95 |
+
* @return void
|
96 |
+
*/
|
97 |
+
abstract public function import_snippet();
|
98 |
+
}
|
includes/admin/importers/class-wpcode-importer-woody.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Importer for Woody.
|
4 |
+
*
|
5 |
+
* @package WPCode.
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Importer_Woody.
|
10 |
+
*/
|
11 |
+
class WPCode_Importer_Woody extends WPCode_Importer_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The plugin name.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'Woody Code Snippets';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Importer slug.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
public $slug = 'woody';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Plugin path.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
public $path = 'insert-php/insert_php.php';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get an array of snippets for this plugin.
|
36 |
+
*
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function get_snippets() {
|
40 |
+
|
41 |
+
$snippets = array();
|
42 |
+
|
43 |
+
if ( ! $this->is_active() ) {
|
44 |
+
return $snippets;
|
45 |
+
}
|
46 |
+
|
47 |
+
$snippets_posts = get_posts(
|
48 |
+
array(
|
49 |
+
'post_type' => 'wbcr-snippets',
|
50 |
+
'posts_per_page' => - 1,
|
51 |
+
'post_status' => 'any',
|
52 |
+
)
|
53 |
+
);
|
54 |
+
|
55 |
+
foreach ( $snippets_posts as $post ) {
|
56 |
+
$snippets[ $post->ID ] = $post->post_title;
|
57 |
+
}
|
58 |
+
|
59 |
+
return $snippets;
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Import the snippet data.
|
65 |
+
*
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
public function import_snippet() {
|
69 |
+
// Run a security check.
|
70 |
+
check_ajax_referer( 'wpcode_admin' );
|
71 |
+
|
72 |
+
if ( ! current_user_can( 'wpcode_edit_snippets' ) ) {
|
73 |
+
wp_send_json_error();
|
74 |
+
}
|
75 |
+
|
76 |
+
if ( ! class_exists( 'WINP_Helper' ) ) {
|
77 |
+
wp_send_json_error();
|
78 |
+
}
|
79 |
+
|
80 |
+
$id = isset( $_POST['snippet_id'] ) ? absint( $_POST['snippet_id'] ) : 0;
|
81 |
+
|
82 |
+
// Grab a snippet from Code Snippets.
|
83 |
+
$snippet = get_post( $id );
|
84 |
+
|
85 |
+
if ( null === $snippet ) {
|
86 |
+
wp_send_json_error(
|
87 |
+
array(
|
88 |
+
'error' => true,
|
89 |
+
'name' => esc_html__( 'Unknown Snippet', 'insert-headers-and-footers' ),
|
90 |
+
'msg' => esc_html__( 'The snippet you are trying to import does not exist.', 'insert-headers-and-footers' ),
|
91 |
+
)
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
// If we got so far we have a snippet to process.
|
96 |
+
|
97 |
+
// Create a new snippet from the snippet data array.
|
98 |
+
$new_snippet = new WPCode_Snippet( $this->get_snippet_data( $snippet ) );
|
99 |
+
|
100 |
+
$new_snippet->save();
|
101 |
+
|
102 |
+
if ( ! empty( $new_snippet->get_id() ) ) {
|
103 |
+
wp_send_json_success(
|
104 |
+
array(
|
105 |
+
'name' => $new_snippet->get_title(),
|
106 |
+
'edit' => esc_url_raw(
|
107 |
+
add_query_arg(
|
108 |
+
array(
|
109 |
+
'page' => 'wpcode-snippet-manager',
|
110 |
+
'snippet_id' => $new_snippet->get_id(),
|
111 |
+
),
|
112 |
+
admin_url( 'admin.php' )
|
113 |
+
)
|
114 |
+
),
|
115 |
+
)
|
116 |
+
);
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Convert a "Woody" snippet to the format for a WPCode snippet.
|
123 |
+
*
|
124 |
+
* @param WP_Post $snippet The snippet post.
|
125 |
+
*
|
126 |
+
* @return array
|
127 |
+
*/
|
128 |
+
public function get_snippet_data( $snippet ) {
|
129 |
+
|
130 |
+
$snippet_location = WINP_Helper::getMetaOption( $snippet->ID, 'snippet_location', '' );
|
131 |
+
$scope = WINP_Helper::getMetaOption( $snippet->ID, 'snippet_scope', '' );
|
132 |
+
$auto_insert = in_array(
|
133 |
+
$scope,
|
134 |
+
array(
|
135 |
+
'auto',
|
136 |
+
'evrywhere',
|
137 |
+
),
|
138 |
+
true
|
139 |
+
) ? 1 : 0;
|
140 |
+
|
141 |
+
switch ( $snippet_location ) {
|
142 |
+
case 'header':
|
143 |
+
$location = 'site_wide_header';
|
144 |
+
break;
|
145 |
+
case 'footer':
|
146 |
+
$location = 'site_wide_footer';
|
147 |
+
break;
|
148 |
+
default:
|
149 |
+
$location = $snippet_location;
|
150 |
+
}
|
151 |
+
|
152 |
+
return array(
|
153 |
+
'code' => WINP_Helper::get_snippet_code( $snippet ),
|
154 |
+
'note' => WINP_Helper::getMetaOption( $snippet->ID, 'snippet_description', '' ),
|
155 |
+
'title' => $snippet->post_title,
|
156 |
+
'tags' => wp_get_post_terms( $snippet->ID, WINP_SNIPPETS_TAXONOMY, array( 'fields' => 'slugs' ) ),
|
157 |
+
'code_type' => WINP_Helper::get_snippet_type( $snippet->ID ),
|
158 |
+
'priority' => intval( WINP_Helper::getMetaOption( $snippet->ID, 'snippet_priority', '' ) ),
|
159 |
+
'location' => $location,
|
160 |
+
'auto_insert' => $auto_insert,
|
161 |
+
);
|
162 |
+
}
|
163 |
+
}
|
includes/admin/pages/class-wpcode-admin-page-code-snippets.php
ADDED
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Code snippets admin main list page.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class for the code snippets page.
|
10 |
+
*/
|
11 |
+
class WPCode_Admin_Page_Code_Snippets extends WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug to be used when adding the submenu.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = 'wpcode';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Instance of the code snippets table.
|
22 |
+
*
|
23 |
+
* @see WP_List_Table
|
24 |
+
* @var WPCode_Code_Snippets_Table
|
25 |
+
*/
|
26 |
+
private $snippets_table;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Call this just to set the page title translatable.
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
$this->page_title = __( 'Code Snippets', 'insert-headers-and-footers' );
|
33 |
+
parent::__construct();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Page-specific hooks, init the custom WP_List_Table.
|
38 |
+
*
|
39 |
+
* @return void
|
40 |
+
*/
|
41 |
+
public function page_hooks() {
|
42 |
+
$this->process_message();
|
43 |
+
add_action( 'current_screen', array( $this, 'init_table' ) );
|
44 |
+
add_action( 'admin_init', array( $this, 'maybe_capture_filter' ) );
|
45 |
+
add_action( 'load-toplevel_page_wpcode', array( $this, 'maybe_process_bulk_action' ) );
|
46 |
+
add_filter( 'screen_options_show_screen', '__return_false' );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* If the referer is set, remove and redirect.
|
51 |
+
*
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
public function maybe_capture_filter() {
|
55 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) && isset( $_SERVER['REQUEST_URI'] ) && isset( $_REQUEST['filter_action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
56 |
+
wp_safe_redirect(
|
57 |
+
remove_query_arg(
|
58 |
+
array(
|
59 |
+
'_wp_http_referer',
|
60 |
+
'_wpnonce',
|
61 |
+
),
|
62 |
+
wp_unslash( $_SERVER['REQUEST_URI'] ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
63 |
+
)
|
64 |
+
);
|
65 |
+
exit;
|
66 |
+
}
|
67 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) && isset( $_SERVER['REQUEST_URI'] ) && isset( $_REQUEST['filter_clear'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
68 |
+
wp_safe_redirect(
|
69 |
+
add_query_arg(
|
70 |
+
'page',
|
71 |
+
'wpcode',
|
72 |
+
admin_url( 'admin.php' )
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
exit;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Listener for bulk actions.
|
82 |
+
*
|
83 |
+
* @return void
|
84 |
+
*/
|
85 |
+
public function maybe_process_bulk_action() {
|
86 |
+
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
87 |
+
$ids = isset( $_GET['snippet_id'] ) ? array_map( 'absint', (array) $_GET['snippet_id'] ) : array();
|
88 |
+
$action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : false;
|
89 |
+
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
90 |
+
if ( empty( $ids ) || empty( $action ) ) {
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
if ( empty( $_GET['_wpnonce'] ) ) {
|
94 |
+
return;
|
95 |
+
}
|
96 |
+
|
97 |
+
if (
|
98 |
+
! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'bulk-wpcode-snippets' ) &&
|
99 |
+
! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'wpcode_' . $action . '_nonce' )
|
100 |
+
) {
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
$update_status_actions = array( 'trash', 'untrash' );
|
105 |
+
|
106 |
+
if ( in_array( $action, $update_status_actions, true ) ) {
|
107 |
+
$newstatus = 'trash' === $action ? 'trash' : 'draft';
|
108 |
+
foreach ( $ids as $id ) {
|
109 |
+
wp_update_post(
|
110 |
+
array(
|
111 |
+
'ID' => $id,
|
112 |
+
'post_status' => $newstatus,
|
113 |
+
)
|
114 |
+
);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
if ( 'delete' === $action ) {
|
118 |
+
foreach ( $ids as $id ) {
|
119 |
+
wp_delete_post( $id );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
$message = array(
|
123 |
+
rtrim( $action, 'e' ) . 'ed' => count( $ids ),
|
124 |
+
);
|
125 |
+
|
126 |
+
wpcode()->cache->cache_all_loaded_snippets();
|
127 |
+
|
128 |
+
// Clear used library snippets.
|
129 |
+
delete_transient( 'wpcode_used_library_snippets' );
|
130 |
+
|
131 |
+
wp_safe_redirect(
|
132 |
+
add_query_arg(
|
133 |
+
$message,
|
134 |
+
remove_query_arg(
|
135 |
+
array(
|
136 |
+
'action',
|
137 |
+
'action2',
|
138 |
+
'_wpnonce',
|
139 |
+
'snippet_id',
|
140 |
+
'paged',
|
141 |
+
'_wp_http_referer',
|
142 |
+
)
|
143 |
+
)
|
144 |
+
)
|
145 |
+
);
|
146 |
+
exit;
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Init the custom table for the snippets list.
|
152 |
+
*
|
153 |
+
* @return void
|
154 |
+
*/
|
155 |
+
public function init_table() {
|
156 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/admin/pages/class-wpcode-code-snippets-table.php';
|
157 |
+
|
158 |
+
$this->snippets_table = new WPCode_Code_Snippets_Table();
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Output the custom table and page content.
|
163 |
+
*
|
164 |
+
* @return void
|
165 |
+
*/
|
166 |
+
public function output_content() {
|
167 |
+
$this->snippets_table->prepare_items();
|
168 |
+
|
169 |
+
?>
|
170 |
+
<form id="wpcode-code-snippets-table" method="get" action="<?php echo esc_url( admin_url( 'admin.php?page=wpcode' ) ); ?>">
|
171 |
+
<input type="hidden" name="page" value="wpcode"/>
|
172 |
+
<?php
|
173 |
+
$this->snippets_table->search_box( esc_html__( 'Search Snippets', 'insert-headers-and-footers' ), 'wpcode_snippet_search' );
|
174 |
+
$this->snippets_table->views();
|
175 |
+
$this->snippets_table->display();
|
176 |
+
?>
|
177 |
+
|
178 |
+
</form>
|
179 |
+
<?php
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Content of the bottom row of the header.
|
184 |
+
*
|
185 |
+
* @return void
|
186 |
+
*/
|
187 |
+
public function output_header_bottom() {
|
188 |
+
$add_new_url = admin_url( 'admin.php?page=wpcode-snippet-manager' );
|
189 |
+
?>
|
190 |
+
<div class="wpcode-column wpcode-title-button">
|
191 |
+
<h1><?php esc_html_e( 'All Snippets', 'insert-headers-and-footers' ); ?></h1>
|
192 |
+
<a class="wpcode-button" href="<?php echo esc_url( $add_new_url ); ?>">
|
193 |
+
<?php esc_html_e( 'Add New', 'insert-headers-and-footers' ); ?>
|
194 |
+
</a>
|
195 |
+
</div>
|
196 |
+
<?php
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Capture screen-specific messages and add notices.
|
201 |
+
*
|
202 |
+
* @return void
|
203 |
+
*/
|
204 |
+
public function process_message() {
|
205 |
+
|
206 |
+
// phpcs:disable WordPress.Security.NonceVerification
|
207 |
+
if ( ! empty( $_GET['trashed'] ) ) {
|
208 |
+
$count = absint( $_GET['trashed'] );
|
209 |
+
$notice = sprintf( /* Translators: %d - Trashed snippets count. */
|
210 |
+
_n( '%d snippet was successfully moved to Trash.', '%d snippets were successfully moved to Trash.', $count, 'insert-headers-and-footers' ),
|
211 |
+
$count
|
212 |
+
);
|
213 |
+
}
|
214 |
+
|
215 |
+
if ( ! empty( $_GET['untrashed'] ) ) {
|
216 |
+
$count = absint( $_GET['untrashed'] );
|
217 |
+
$notice = sprintf( /* translators: %d - Restored from trash snippets count. */
|
218 |
+
_n( '%d snippet was successfully restored.', '%d snippet were successfully restored.', $count, 'insert-headers-and-footers' ),
|
219 |
+
$count
|
220 |
+
);
|
221 |
+
}
|
222 |
+
|
223 |
+
if ( ! empty( $_GET['deleted'] ) ) {
|
224 |
+
$count = absint( $_GET['deleted'] );
|
225 |
+
$notice = sprintf( /* translators: %d - Deleted snippets count. */
|
226 |
+
_n( '%d snippet was successfully permanently deleted.', '%d snippets were successfully permanently deleted.', $count, 'insert-headers-and-footers' ),
|
227 |
+
$count
|
228 |
+
);
|
229 |
+
}
|
230 |
+
// phpcs:enable WordPress.Security.NonceVerification
|
231 |
+
|
232 |
+
if ( isset( $notice ) ) {
|
233 |
+
$this->set_success_message( $notice );
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
includes/admin/pages/class-wpcode-admin-page-generator.php
ADDED
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The admin page for the snippet generator.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Admin_Page_Generator.
|
10 |
+
*/
|
11 |
+
class WPCode_Admin_Page_Generator extends WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = 'wpcode-generator';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Generator to show, if any.
|
22 |
+
*
|
23 |
+
* @var bool|string
|
24 |
+
*/
|
25 |
+
public $generator = false;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Available generators.
|
29 |
+
*
|
30 |
+
* @var WPCode_Generator_Type[]
|
31 |
+
*/
|
32 |
+
public $generators;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Set the code type for the editor on this page.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $code_type = 'php';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Set the header title based on what is displayed.
|
43 |
+
*
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $header_title;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Call this just to set the page title translatable.
|
50 |
+
*/
|
51 |
+
public function __construct() {
|
52 |
+
$this->page_title = __( 'Generator', 'insert-headers-and-footers' );
|
53 |
+
$this->header_title = $this->page_title;
|
54 |
+
parent::__construct();
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Page-specific hooks & logic.
|
59 |
+
*
|
60 |
+
* @return void
|
61 |
+
*/
|
62 |
+
public function page_hooks() {
|
63 |
+
$this->generators = wpcode()->generator->get_all_generators();
|
64 |
+
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
65 |
+
// Let's see if we should display a generator.
|
66 |
+
if ( isset( $_GET['generator'] ) ) {
|
67 |
+
$generator = sanitize_text_field( wp_unslash( $_GET['generator'] ) );
|
68 |
+
if ( array_key_exists( $generator, $this->generators ) ) {
|
69 |
+
$this->generator = $generator;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
73 |
+
if ( $this->generator ) {
|
74 |
+
// Translators: gets replace with the generator name.
|
75 |
+
$this->header_title = sprintf( __( '%s Generator', 'insert-headers-and-footers' ), $this->generators[ $this->generator ]->get_title() );
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Output the content of the page.
|
81 |
+
*
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function output_content() {
|
85 |
+
if ( $this->generator ) {
|
86 |
+
$this->show_generator();
|
87 |
+
} else {
|
88 |
+
$this->show_generators_list();
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Show the list of generators with categories.
|
94 |
+
*
|
95 |
+
* @return void
|
96 |
+
*/
|
97 |
+
public function show_generators_list() {
|
98 |
+
$categories = wpcode()->generator->get_categories();
|
99 |
+
?>
|
100 |
+
<div class="wpcode-items-metabox wpcode-metabox">
|
101 |
+
<?php $this->get_items_list_sidebar( $categories, __( 'All Generators', 'insert-headers-and-footers' ), __( 'Search Generators' ) ); ?>
|
102 |
+
<div class="wpcode-items-list">
|
103 |
+
<ul class="wpcode-items-list-category">
|
104 |
+
<?php
|
105 |
+
foreach ( $this->generators as $generator ) {
|
106 |
+
$url = add_query_arg(
|
107 |
+
array(
|
108 |
+
'page' => $this->page_slug,
|
109 |
+
'generator' => $generator->get_name(),
|
110 |
+
),
|
111 |
+
admin_url( 'admin.php' )
|
112 |
+
);
|
113 |
+
$this->get_list_item( $generator->get_name(), $generator->get_title(), $generator->get_description(), $url, __( 'Generate', 'insert-headers-and-footers' ), $generator->get_categories() );
|
114 |
+
}
|
115 |
+
?>
|
116 |
+
</ul>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
<?php
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Show the generator based on the param.
|
124 |
+
*
|
125 |
+
* @return void
|
126 |
+
*/
|
127 |
+
public function show_generator() {
|
128 |
+
$generator = $this->generators[ $this->generator ];
|
129 |
+
$tabs = $generator->get_tabs();
|
130 |
+
?>
|
131 |
+
<form id="wpcode_generator_form">
|
132 |
+
<div class="wpcode-items-metabox wpcode-metabox">
|
133 |
+
<div class="wpcode-items-sidebar">
|
134 |
+
<ul class="wpcode-items-categories-list wpcode-items-tabs">
|
135 |
+
<?php
|
136 |
+
$selected = key( $tabs );
|
137 |
+
foreach ( $tabs as $tab_id => $tab ) {
|
138 |
+
$class = $tab_id === $selected ? 'wpcode-active' : '';
|
139 |
+
?>
|
140 |
+
<li>
|
141 |
+
<button type="button" class="<?php echo esc_attr( $class ); ?>" data-category="<?php echo esc_attr( $tab_id ); ?>"><?php echo esc_html( $tab['label'] ); ?></button>
|
142 |
+
</li>
|
143 |
+
<?php } ?>
|
144 |
+
</ul>
|
145 |
+
</div>
|
146 |
+
<div class="wpcode-items-list">
|
147 |
+
<?php
|
148 |
+
foreach ( $tabs as $tab_id => $tab ) {
|
149 |
+
$style = $selected === $tab_id ? '' : 'display:none;';
|
150 |
+
?>
|
151 |
+
<div class="wpcode-form-tab" data-tab="<?php echo esc_attr( $tab_id ); ?>" style="<?php echo esc_attr( $style ); ?>">
|
152 |
+
<?php $generator->render_tab( $tab_id ); ?>
|
153 |
+
</div>
|
154 |
+
<?php } ?>
|
155 |
+
<div class="wpcode-generator-actions">
|
156 |
+
<?php wp_nonce_field( 'wpcode_generate', 'nonce', false ); ?>
|
157 |
+
<input type="hidden" name="type" value="<?php echo esc_attr( $this->generator ); ?>"/>
|
158 |
+
<input type="hidden" name="action" value="wpcode_generate_snippet"/>
|
159 |
+
<button type="submit" class="wpcode-button wpcode-button-secondary" id="wpcode-generator-update-code"><?php esc_html_e( 'Update code', 'insert-headers-and-footers' ); ?></button>
|
160 |
+
</div>
|
161 |
+
</div>
|
162 |
+
</div>
|
163 |
+
</form>
|
164 |
+
<div class="wpcode-generator-preview">
|
165 |
+
<div class="wpcode-generator-preview-header">
|
166 |
+
<h2><?php esc_html_e( 'Code Preview', 'insert-headers-and-footers' ); ?></h2>
|
167 |
+
<button type="button" class="wpcode-button" id="wpcode-generator-use-snippet"><?php esc_html_e( 'Use Snippet', 'insert-headers-and-footers' ); ?></button>
|
168 |
+
<button class="wpcode-button wpcode-button-icon wpcode-button-secondary wpcode-copy-target" data-target="#wpcode_generator_code_preview" type="button">
|
169 |
+
<span class="wpcode-default-icon"><?php wpcode_icon( 'copy', 16, 16 ); ?></span><span class="wpcode-success-icon"><?php wpcode_icon( 'check', 16, 13 ); ?></span> <?php echo esc_html_x( 'Copy Code', 'Copy to clipboard', 'insert-headers-and-footers' ); ?>
|
170 |
+
</button>
|
171 |
+
</div>
|
172 |
+
<textarea id="wpcode_generator_code_preview"><?php echo $generator->get_snippet_code(); ?></textarea>
|
173 |
+
</div>
|
174 |
+
<span class="wpcode-loading-spinner" id="wpcode-generator-spinner"></span>
|
175 |
+
<script type="text/template" id="wpcode-generator-repeater-row">
|
176 |
+
<?php $this->repeater_group_template(); ?>
|
177 |
+
</script>
|
178 |
+
<?php
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* The bottom part of the header.
|
183 |
+
*
|
184 |
+
* @return void
|
185 |
+
*/
|
186 |
+
public function output_header_bottom() {
|
187 |
+
?>
|
188 |
+
<div class="wpcode-column">
|
189 |
+
<h1><?php echo esc_html( $this->header_title ); ?></h1>
|
190 |
+
</div>
|
191 |
+
<?php
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* The template for the repeater row.
|
196 |
+
*
|
197 |
+
* @return void
|
198 |
+
*/
|
199 |
+
public function repeater_group_template() {
|
200 |
+
?>
|
201 |
+
<div class="wpcode-repeater-group">
|
202 |
+
<button type="button" class="wpcode-button wpcode-button-secondary wpcode-remove-row"><?php esc_html_e( 'Remove Row', 'insert-headers-and-footers' ); ?></button>
|
203 |
+
</div>
|
204 |
+
<?php
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Add page-specific scripts.
|
209 |
+
*
|
210 |
+
* @return void
|
211 |
+
*/
|
212 |
+
public function page_scripts() {
|
213 |
+
if ( ! $this->generator ) {
|
214 |
+
return;
|
215 |
+
}
|
216 |
+
$settings = $this->load_code_mirror();
|
217 |
+
|
218 |
+
$settings['codemirror']['readOnly'] = 'nocursor';
|
219 |
+
wp_add_inline_script( 'code-editor', sprintf( 'jQuery( function() { window.wpcode_editor = wp.codeEditor.initialize( "wpcode_generator_code_preview", %s ); } );', wp_json_encode( $settings ) ) );
|
220 |
+
|
221 |
+
wp_enqueue_script( 'jquery-ui-autocomplete' );
|
222 |
+
}
|
223 |
+
}
|
includes/admin/pages/class-wpcode-admin-page-headers-footers.php
ADDED
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Headers & Footers admin page.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class for the headers & footers admin page.
|
10 |
+
*/
|
11 |
+
class WPCode_Admin_Page_Headers_Footers extends WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug to be used when adding the submenu.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = 'wpcode-headers-footers';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The action used for the nonce.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $action = 'insert-headers-and-footers';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* If the page should be a submenu of Settings instead of wpcode.
|
29 |
+
*
|
30 |
+
* @var bool
|
31 |
+
*/
|
32 |
+
private $settings_submenu = false;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The nonce name field.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
private $nonce_name = 'insert-headers-and-footers_nonce';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Call this just to set the page title translatable.
|
43 |
+
*
|
44 |
+
* @param bool $settings_submenu If true, the page will be added as a submenu of the Settings page.
|
45 |
+
*/
|
46 |
+
public function __construct( $settings_submenu = false ) {
|
47 |
+
if ( $settings_submenu ) {
|
48 |
+
$this->settings_submenu = true;
|
49 |
+
}
|
50 |
+
$this->page_title = __( 'Header & Footer', 'insert-headers-and-footers' );
|
51 |
+
parent::__construct();
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Add the submenu page.
|
56 |
+
*
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
public function add_page() {
|
60 |
+
if ( $this->settings_submenu ) {
|
61 |
+
add_options_page( $this->menu_title, $this->page_title, 'wpcode_edit_snippets', $this->page_slug, 'wpcode_admin_menu_page' );
|
62 |
+
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
parent::add_page();
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Register hook on admin init just for this page.
|
70 |
+
*
|
71 |
+
* @return void
|
72 |
+
*/
|
73 |
+
public function page_hooks() {
|
74 |
+
$this->can_edit = current_user_can( 'unfiltered_html' );
|
75 |
+
add_action( 'admin_init', array( $this, 'submit_listener' ) );
|
76 |
+
$this->process_message();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Process messages specific to this page.
|
81 |
+
*
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function process_message() {
|
85 |
+
// phpcs:disable WordPress.Security.NonceVerification
|
86 |
+
if ( ! isset( $_GET['message'] ) ) {
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
$messages = array(
|
91 |
+
1 => __( 'Headers & Footers mode activated. Use the toggle next to the Save Changes button to disable it at any time.', 'insert-headers-and-footers' ),
|
92 |
+
2 => __( 'Headers & Footers mode deactivated, if you wish to switch back please use the option on the settings page.', 'insert-headers-and-footers' ),
|
93 |
+
);
|
94 |
+
$message = absint( $_GET['message'] );
|
95 |
+
// phpcs:enable WordPress.Security.NonceVerification
|
96 |
+
|
97 |
+
if ( ! isset( $messages[ $message ] ) ) {
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
$this->set_success_message( $messages[ $message ] );
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Wrap this page in a form tag.
|
105 |
+
*
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
public function output() {
|
109 |
+
if ( ! $this->can_edit ) {
|
110 |
+
$this->set_error_message( __( 'Sorry, only have read-only access to this page. Ask your administrator for assistance editing.', 'insert-headers-and-footers' ) );
|
111 |
+
// If the user can't edit the values just don't load form at all.
|
112 |
+
parent::output();
|
113 |
+
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
?>
|
117 |
+
<form action="<?php echo esc_url( $this->get_page_action_url() ); ?>" method="post">
|
118 |
+
<?php parent::output(); ?>
|
119 |
+
</form>
|
120 |
+
<?php
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* The headers & footers page output.
|
125 |
+
*
|
126 |
+
* @return void
|
127 |
+
*/
|
128 |
+
public function output_content() {
|
129 |
+
$body_supported = function_exists( 'wp_body_open' ) && version_compare( get_bloginfo( 'version' ), '5.2', '>=' );
|
130 |
+
$header_desc = sprintf(
|
131 |
+
/* translators: %s: The `<head>` tag */
|
132 |
+
esc_html__( 'These scripts will be printed in the %s section.', 'insert-headers-and-footers' ),
|
133 |
+
'<code><head></code>'
|
134 |
+
);
|
135 |
+
$body_desc = sprintf(
|
136 |
+
/* translators: %s: The `<head>` tag */
|
137 |
+
esc_html__( 'These scripts will be printed just below the opening %s tag.', 'insert-headers-and-footers' ),
|
138 |
+
'<code><body></code>'
|
139 |
+
);
|
140 |
+
$footer_desc = sprintf(
|
141 |
+
/* translators: %s: The `</body>` tag */
|
142 |
+
esc_html__( 'These scripts will be printed above the closing %s tag.', 'insert-headers-and-footers' ),
|
143 |
+
'<code></body></code>'
|
144 |
+
);
|
145 |
+
$this->textarea_field( 'ihaf_insert_header', __( 'Header', 'insert-headers-and-footers' ), $header_desc );
|
146 |
+
if ( $body_supported ) {
|
147 |
+
$this->textarea_field( 'ihaf_insert_body', __( 'Body', 'insert-headers-and-footers' ), $body_desc );
|
148 |
+
}
|
149 |
+
$this->textarea_field( 'ihaf_insert_footer', __( 'Footer', 'insert-headers-and-footers' ), $footer_desc );
|
150 |
+
wp_nonce_field( $this->action, $this->nonce_name );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Standard output for a code input field.
|
155 |
+
*
|
156 |
+
* @param string $option The option name as stored in the DB.
|
157 |
+
* @param string $title The title of the input (also used as label).
|
158 |
+
* @param string $desc The description that shows up under the field.
|
159 |
+
*
|
160 |
+
* @return void
|
161 |
+
*/
|
162 |
+
public function textarea_field( $option, $title, $desc ) {
|
163 |
+
$value = esc_html( wp_unslash( get_option( $option ) ) );
|
164 |
+
?>
|
165 |
+
<div class="wpcode-code-textarea">
|
166 |
+
<h2><label for="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( $title ); ?></label></h2>
|
167 |
+
<textarea name="<?php echo esc_attr( $option ); ?>" id="<?php echo esc_attr( $option ); ?>" class="widefat" rows="8" <?php disabled( ! current_user_can( 'unfiltered_html' ) ); ?>><?php echo $value; ?></textarea>
|
168 |
+
<p>
|
169 |
+
<?php echo wp_kses( $desc, array( 'code' => array() ) ); ?>
|
170 |
+
</p>
|
171 |
+
</div>
|
172 |
+
<?php
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* For this page we output a title and the save button.
|
177 |
+
*
|
178 |
+
* @return void
|
179 |
+
*/
|
180 |
+
public function output_header_bottom() {
|
181 |
+
$button_disabled = ! $this->can_edit ? 'disabled' : '';
|
182 |
+
?>
|
183 |
+
<div class="wpcode-column">
|
184 |
+
<h1><?php esc_html_e( 'Global Header and Footer', 'insert-headers-and-footers' ); ?></h1>
|
185 |
+
</div>
|
186 |
+
<div class="wpcode-column">
|
187 |
+
<?php $this->get_submenu_toggle(); ?>
|
188 |
+
<button class="wpcode-button" type="submit" <?php echo esc_attr( $button_disabled ); ?>>
|
189 |
+
<?php esc_html_e( 'Save Changes', 'insert-headers-and-footers' ); ?>
|
190 |
+
</button>
|
191 |
+
</div>
|
192 |
+
<?php
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Get the toggle to disable submenu mode.
|
197 |
+
*
|
198 |
+
* @return void
|
199 |
+
*/
|
200 |
+
public function get_submenu_toggle() {
|
201 |
+
if ( ! $this->settings_submenu ) {
|
202 |
+
return;
|
203 |
+
}
|
204 |
+
|
205 |
+
?>
|
206 |
+
<div>
|
207 |
+
<label for="headers_footers_mode" class="wpcode-status-text"><?php esc_html_e( 'Simple mode', 'insert-headers-and-footers' ); ?></label>
|
208 |
+
<?php echo $this->get_checkbox_toggle( true, 'headers_footers_mode' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
209 |
+
</div>
|
210 |
+
<?php
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Page specific scripts. Hooked to 'admin_enqueue_scripts'.
|
215 |
+
*
|
216 |
+
* @return void
|
217 |
+
*/
|
218 |
+
public function page_scripts() {
|
219 |
+
$settings = $this->load_code_mirror();
|
220 |
+
if ( false === $settings ) {
|
221 |
+
return;
|
222 |
+
}
|
223 |
+
|
224 |
+
wp_add_inline_script( 'code-editor', sprintf( 'jQuery( function() { wp.codeEditor.initialize( "ihaf_insert_header", %s ); } );', wp_json_encode( $settings ) ) );
|
225 |
+
wp_add_inline_script( 'code-editor', sprintf( 'jQuery( function() { wp.codeEditor.initialize( "ihaf_insert_body", %s ); } );', wp_json_encode( $settings ) ) );
|
226 |
+
wp_add_inline_script( 'code-editor', sprintf( 'jQuery( function() { wp.codeEditor.initialize( "ihaf_insert_footer", %s ); } );', wp_json_encode( $settings ) ) );
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* If the form is submitted attempt to save the values.
|
231 |
+
*
|
232 |
+
* @return void
|
233 |
+
*/
|
234 |
+
public function submit_listener() {
|
235 |
+
if ( ! isset( $_REQUEST[ $this->nonce_name ] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST[ $this->nonce_name ] ), $this->action ) ) {
|
236 |
+
// Nonce is missing, so we're not even going to try.
|
237 |
+
return;
|
238 |
+
}
|
239 |
+
|
240 |
+
if ( ! $this->can_edit ) {
|
241 |
+
// They are not allowed to edit the page so they shouldn't be able to submit the form in the first place.
|
242 |
+
return;
|
243 |
+
}
|
244 |
+
|
245 |
+
if ( ! isset( $_REQUEST['ihaf_insert_header'] ) || ! isset( $_REQUEST['ihaf_insert_footer'] ) ) {
|
246 |
+
// If the values are not set, just don't try.
|
247 |
+
return;
|
248 |
+
}
|
249 |
+
|
250 |
+
update_option( 'ihaf_insert_header', $_REQUEST['ihaf_insert_header'] );
|
251 |
+
update_option( 'ihaf_insert_footer', $_REQUEST['ihaf_insert_footer'] );
|
252 |
+
update_option( 'ihaf_insert_body', isset( $_REQUEST['ihaf_insert_body'] ) ? $_REQUEST['ihaf_insert_body'] : '' );
|
253 |
+
|
254 |
+
if ( wpcode()->settings->get_option( 'headers_footers_mode' ) && ! isset( $_REQUEST['headers_footers_mode'] ) ) {
|
255 |
+
wpcode()->settings->update_option( 'headers_footers_mode', false );
|
256 |
+
wp_safe_redirect(
|
257 |
+
add_query_arg(
|
258 |
+
array(
|
259 |
+
'page' => $this->page_slug,
|
260 |
+
'message' => 2,
|
261 |
+
),
|
262 |
+
admin_url( 'admin.php' )
|
263 |
+
)
|
264 |
+
);
|
265 |
+
exit;
|
266 |
+
}
|
267 |
+
|
268 |
+
$this->set_success_message( __( 'Settings Saved.', 'insert-headers-and-footers' ) );
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Use a different base url when the headers_footers_mode is enabled.
|
273 |
+
*
|
274 |
+
* @return string
|
275 |
+
*/
|
276 |
+
public function get_page_action_url() {
|
277 |
+
$url = parent::get_page_action_url();
|
278 |
+
|
279 |
+
if ( ! wpcode()->settings->get_option( 'headers_footers_mode' ) ) {
|
280 |
+
return $url;
|
281 |
+
}
|
282 |
+
|
283 |
+
return str_replace( 'admin.php', 'options-general.php', $url );
|
284 |
+
}
|
285 |
+
}
|
includes/admin/pages/class-wpcode-admin-page-library.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin page for the snippets library.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Admin_Page_Library class.
|
10 |
+
*/
|
11 |
+
class WPCode_Admin_Page_Library extends WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = 'wpcode-library';
|
19 |
+
/**
|
20 |
+
* We always show the library on this page.
|
21 |
+
*
|
22 |
+
* @var bool
|
23 |
+
*/
|
24 |
+
protected $show_library = true;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Call this just to set the page title translatable.
|
28 |
+
*/
|
29 |
+
public function __construct() {
|
30 |
+
$this->page_title = __( 'Library', 'insert-headers-and-footers' );
|
31 |
+
parent::__construct();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add page-specific hooks.
|
36 |
+
*
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function page_hooks() {
|
40 |
+
$this->process_message();
|
41 |
+
add_action( 'admin_init', array( $this, 'maybe_add_from_library' ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Handle grabbing snippets from the library.
|
46 |
+
*
|
47 |
+
* @return void
|
48 |
+
*/
|
49 |
+
public function maybe_add_from_library() {
|
50 |
+
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'wpcode_add_from_library' ) ) {
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
$library_id = isset( $_GET['snippet_library_id'] ) ? absint( $_GET['snippet_library_id'] ) : 0;
|
54 |
+
|
55 |
+
if ( empty( $library_id ) ) {
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
$snippet = wpcode()->library->create_new_snippet( $library_id );
|
60 |
+
|
61 |
+
if ( $snippet ) {
|
62 |
+
$url = add_query_arg(
|
63 |
+
array(
|
64 |
+
'page' => 'wpcode-snippet-manager',
|
65 |
+
'snippet_id' => $snippet->get_id(),
|
66 |
+
),
|
67 |
+
admin_url( 'admin.php' )
|
68 |
+
);
|
69 |
+
} else {
|
70 |
+
$url = add_query_arg(
|
71 |
+
array(
|
72 |
+
'message' => 1,
|
73 |
+
),
|
74 |
+
remove_query_arg(
|
75 |
+
array(
|
76 |
+
'_wpnonce',
|
77 |
+
'snippet_library_id',
|
78 |
+
)
|
79 |
+
)
|
80 |
+
);
|
81 |
+
}
|
82 |
+
|
83 |
+
wp_safe_redirect( $url );
|
84 |
+
exit;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Markup for the Library page content.
|
89 |
+
*
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
public function output_content() {
|
93 |
+
$library_data = wpcode()->library->get_data();
|
94 |
+
$categories = $library_data['categories'];
|
95 |
+
$snippets = $library_data['snippets'];
|
96 |
+
|
97 |
+
$this->get_library_markup( $categories, $snippets );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* For this page we output just a title now.
|
102 |
+
*
|
103 |
+
* @return void
|
104 |
+
*/
|
105 |
+
public function output_header_bottom() {
|
106 |
+
?>
|
107 |
+
<div class="wpcode-column">
|
108 |
+
<h1><?php esc_html_e( 'Snippet Library', 'insert-headers-and-footers' ); ?></h1>
|
109 |
+
</div>
|
110 |
+
<?php
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Process messages specific to this page.
|
115 |
+
*
|
116 |
+
* @return void
|
117 |
+
*/
|
118 |
+
public function process_message() {
|
119 |
+
// phpcs:disable WordPress.Security.NonceVerification
|
120 |
+
if ( ! isset( $_GET['message'] ) ) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
$messages = array(
|
125 |
+
1 => __( 'We encountered an error while trying to load the snippet data. Please try again.', 'insert-headers-and-footers' ),
|
126 |
+
);
|
127 |
+
$message = absint( $_GET['message'] );
|
128 |
+
// phpcs:enable WordPress.Security.NonceVerification
|
129 |
+
|
130 |
+
if ( ! isset( $messages[ $message ] ) ) {
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
|
134 |
+
$this->set_error_message( $messages[ $message ] );
|
135 |
+
|
136 |
+
}
|
137 |
+
}
|
includes/admin/pages/class-wpcode-admin-page-settings.php
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Settings admin page.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class for the Settings admin page.
|
10 |
+
*/
|
11 |
+
class WPCode_Admin_Page_Settings extends WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug to be used when adding the submenu.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = 'wpcode-settings';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The action used for the nonce.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $action = 'wpcode-settings';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The nonce name field.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
private $nonce_name = 'wpcode-settings_nonce';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Call this just to set the page title translatable.
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
+
$this->page_title = __( 'Settings', 'insert-headers-and-footers' );
|
39 |
+
parent::__construct();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Register hook on admin init just for this page.
|
44 |
+
*
|
45 |
+
* @return void
|
46 |
+
*/
|
47 |
+
public function page_hooks() {
|
48 |
+
add_action( 'admin_init', array( $this, 'submit_listener' ) );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Wrap this page in a form tag.
|
53 |
+
*
|
54 |
+
* @return void
|
55 |
+
*/
|
56 |
+
public function output() {
|
57 |
+
?>
|
58 |
+
<form action="<?php echo esc_url( $this->get_page_action_url() ); ?>" method="post">
|
59 |
+
<?php parent::output(); ?>
|
60 |
+
</form>
|
61 |
+
<?php
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* The Settings page output.
|
66 |
+
*
|
67 |
+
* @return void
|
68 |
+
*/
|
69 |
+
public function output_content() {
|
70 |
+
$header_and_footers = wpcode()->settings->get_option( 'headers_footers_mode' );
|
71 |
+
|
72 |
+
$description = __( 'This allows you to disable all Code Snippets functionality and have a single "Headers & Footers" item under the settings menu.', 'insert-headers-and-footers' );
|
73 |
+
|
74 |
+
$description .= '<br />';
|
75 |
+
$description .= sprintf(
|
76 |
+
// Translators: Placeholders make the text bold.
|
77 |
+
__( '%1$sNOTE:%2$s Please use this setting with caution. It will disable all custom snippets that you add using the new snippet management interface.', 'insert-headers-and-footers' ),
|
78 |
+
'<strong>',
|
79 |
+
'</strong>'
|
80 |
+
);
|
81 |
+
|
82 |
+
$this->metabox_row(
|
83 |
+
__( 'Headers & Footers mode', 'insert-headers-and-footers' ),
|
84 |
+
$this->get_checkbox_toggle(
|
85 |
+
$header_and_footers,
|
86 |
+
'headers_footers_mode',
|
87 |
+
$description
|
88 |
+
),
|
89 |
+
'headers_footers_mode'
|
90 |
+
);
|
91 |
+
|
92 |
+
wp_nonce_field( $this->action, $this->nonce_name );
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* For this page we output a title and the save button.
|
98 |
+
*
|
99 |
+
* @return void
|
100 |
+
*/
|
101 |
+
public function output_header_bottom() {
|
102 |
+
?>
|
103 |
+
<div class="wpcode-column">
|
104 |
+
<h1><?php esc_html_e( 'Settings', 'insert-headers-and-footers' ); ?></h1>
|
105 |
+
</div>
|
106 |
+
<div class="wpcode-column">
|
107 |
+
<button class="wpcode-button" type="submit">
|
108 |
+
<?php esc_html_e( 'Save Changes', 'insert-headers-and-footers' ); ?>
|
109 |
+
</button>
|
110 |
+
</div>
|
111 |
+
<?php
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* If the form is submitted attempt to save the values.
|
116 |
+
*
|
117 |
+
* @return void
|
118 |
+
*/
|
119 |
+
public function submit_listener() {
|
120 |
+
if ( ! isset( $_REQUEST[ $this->nonce_name ] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST[ $this->nonce_name ] ), $this->action ) ) {
|
121 |
+
// Nonce is missing, so we're not even going to try.
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
|
125 |
+
$settings = array(
|
126 |
+
'headers_footers_mode' => isset( $_POST['headers_footers_mode'] ),
|
127 |
+
);
|
128 |
+
|
129 |
+
wpcode()->settings->bulk_update_options( $settings );
|
130 |
+
|
131 |
+
if ( true === $settings['headers_footers_mode'] ) {
|
132 |
+
wp_safe_redirect(
|
133 |
+
add_query_arg(
|
134 |
+
array(
|
135 |
+
'page' => 'wpcode-headers-footers',
|
136 |
+
'message' => 1,
|
137 |
+
),
|
138 |
+
admin_url( 'options-general.php' )
|
139 |
+
)
|
140 |
+
);
|
141 |
+
exit;
|
142 |
+
}
|
143 |
+
|
144 |
+
$this->set_success_message( __( 'Settings Saved.', 'insert-headers-and-footers' ) );
|
145 |
+
}
|
146 |
+
}
|
includes/admin/pages/class-wpcode-admin-page-snippet-manager.php
ADDED
@@ -0,0 +1,1067 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Snippet manager page - add/edit snippets.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Admin_Page_Snippet_Manager class.
|
10 |
+
*/
|
11 |
+
class WPCode_Admin_Page_Snippet_Manager extends WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug to be used when adding the submenu.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = 'wpcode-snippet-manager';
|
19 |
+
/**
|
20 |
+
* The publish button text depending on the status.
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
public $publish_button_text;
|
25 |
+
/**
|
26 |
+
* The header title text depending on the status.
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $header_title;
|
31 |
+
/**
|
32 |
+
* The default code type for this page is HTML.
|
33 |
+
*
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
public $code_type = 'html';
|
37 |
+
/**
|
38 |
+
* The action for the nonce when the current page is submitted.
|
39 |
+
*
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
private $action = 'wpcode-save-snippet';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* The name of the nonce used for saving.
|
46 |
+
*
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
private $nonce_name = 'wpcode-save-snippet-nonce';
|
50 |
+
/**
|
51 |
+
* The snippet id.
|
52 |
+
*
|
53 |
+
* @var int
|
54 |
+
*/
|
55 |
+
private $snippet_id;
|
56 |
+
/**
|
57 |
+
* The snippet instance.
|
58 |
+
*
|
59 |
+
* @var WPCode_Snippet
|
60 |
+
*/
|
61 |
+
private $snippet;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Constructor.
|
65 |
+
*/
|
66 |
+
public function __construct() {
|
67 |
+
// Translators: This adds the name of the plugin "WPCode".
|
68 |
+
$this->page_title = sprintf( __( 'Add %s Snippet', 'insert-headers-and-footers' ), 'WPCode' );
|
69 |
+
$this->menu_title = sprintf( '+ %s', __( 'Add Snippet', 'insert-headers-and-footers' ) );
|
70 |
+
parent::__construct();
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Page-specific hooks.
|
75 |
+
*
|
76 |
+
* @return void
|
77 |
+
*/
|
78 |
+
public function page_hooks() {
|
79 |
+
$this->can_edit = current_user_can( 'wpcode_edit_snippets' ) && current_user_can( 'unfiltered_html' );
|
80 |
+
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
81 |
+
if ( isset( $_GET['snippet_id'] ) ) {
|
82 |
+
$snippet_post = get_post( absint( $_GET['snippet_id'] ) );
|
83 |
+
if ( ! is_null( $snippet_post ) && 'wpcode' === $snippet_post->post_type ) {
|
84 |
+
$this->snippet_id = $snippet_post->ID;
|
85 |
+
$this->snippet = new WPCode_Snippet( $snippet_post );
|
86 |
+
}
|
87 |
+
// If the post type does not match the page will act as an add new snippet page, the id will be ignored.
|
88 |
+
} elseif ( ! isset( $_GET['custom'] ) ) {
|
89 |
+
$this->show_library = apply_filters( 'wpcode_add_snippet_show_library', true );
|
90 |
+
}
|
91 |
+
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
92 |
+
$this->publish_button_text = __( 'Save Snippet', 'insert-headers-and-footers' );
|
93 |
+
$this->header_title = __( 'Create Custom Snippet', 'insert-headers-and-footers' );
|
94 |
+
if ( isset( $this->snippet ) ) {
|
95 |
+
$this->header_title = __( 'Edit Snippet', 'insert-headers-and-footers' );
|
96 |
+
$this->publish_button_text = __( 'Update', 'insert-headers-and-footers' );
|
97 |
+
}
|
98 |
+
if ( $this->show_library ) {
|
99 |
+
$this->header_title = __( 'Add Snippet', 'insert-headers-and-footers' );
|
100 |
+
}
|
101 |
+
$this->process_message();
|
102 |
+
add_action( 'admin_init', array( $this, 'check_status' ) );
|
103 |
+
add_filter( 'submenu_file', array( $this, 'change_current_menu' ) );
|
104 |
+
add_filter( 'admin_title', array( $this, 'change_page_title' ), 15, 2 );
|
105 |
+
add_action( 'admin_init', array( $this, 'submit_listener' ) );
|
106 |
+
add_action( 'admin_init', array( $this, 'set_code_type' ) );
|
107 |
+
add_filter( 'wpcode_admin_js_data', array( $this, 'add_conditional_rules_to_script' ) );
|
108 |
+
add_filter( 'admin_body_class', array( $this, 'maybe_show_tinymce' ) );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Make sure we can't edit a trashed snippet.
|
113 |
+
*
|
114 |
+
* @return void
|
115 |
+
*/
|
116 |
+
public function check_status() {
|
117 |
+
if ( ! isset( $this->snippet ) ) {
|
118 |
+
return;
|
119 |
+
}
|
120 |
+
$post_data = $this->snippet->get_post_data();
|
121 |
+
if ( 'trash' === $post_data->post_status ) {
|
122 |
+
wp_die( esc_html__( 'You cannot edit this snippet because it is in the Trash. Please restore it and try again.', 'insert-headers-and-footers' ) );
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Process messages specific to this page.
|
128 |
+
*
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
public function process_message() {
|
132 |
+
// phpcs:disable WordPress.Security.NonceVerification
|
133 |
+
if ( ! isset( $_GET['message'] ) ) {
|
134 |
+
return;
|
135 |
+
}
|
136 |
+
|
137 |
+
$messages = array(
|
138 |
+
1 => __( 'Snippet updated.', 'insert-headers-and-footers' ),
|
139 |
+
2 => __( 'Snippet created & Saved.', 'insert-headers-and-footers' ),
|
140 |
+
3 => __( 'We encountered an error activating your snippet, please check the syntax and try again.', 'insert-headers-and-footers' ),
|
141 |
+
4 => __( 'Sorry, you are not allowed to change the status of the snippet.', 'insert-headers-and-footers' ),
|
142 |
+
);
|
143 |
+
$message = absint( $_GET['message'] );
|
144 |
+
// phpcs:enable WordPress.Security.NonceVerification
|
145 |
+
|
146 |
+
if ( ! isset( $messages[ $message ] ) ) {
|
147 |
+
return;
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( $message > 2 ) {
|
151 |
+
$this->set_error_message( $messages[ $message ] );
|
152 |
+
} else {
|
153 |
+
$this->set_success_message( $messages[ $message ] );
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* If we're editing a snippet, change the active submenu like WP does.
|
160 |
+
*
|
161 |
+
* @param null|string $submenu_file The submenu file.
|
162 |
+
*
|
163 |
+
* @return null|string
|
164 |
+
*/
|
165 |
+
public function change_current_menu( $submenu_file ) {
|
166 |
+
if ( ! isset( $this->snippet_id ) ) {
|
167 |
+
// Only change this for when editing a snippet.
|
168 |
+
return $submenu_file;
|
169 |
+
}
|
170 |
+
|
171 |
+
return 'wpcode';
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Change the admin page title when editing a snippet.
|
176 |
+
*
|
177 |
+
* @param string $title The admin page title to be displayed.
|
178 |
+
* @param string $original_title The page title before adding the WP suffix.
|
179 |
+
*
|
180 |
+
* @return string
|
181 |
+
*/
|
182 |
+
public function change_page_title( $title, $original_title ) {
|
183 |
+
if ( isset( $this->snippet ) ) {
|
184 |
+
// If the snippet post is loaded (so we're editing) replace the original page title with our edit snippet one.
|
185 |
+
// Translators: this changes the edit page title to show the snippet title.
|
186 |
+
return str_replace( $original_title, sprintf( __( 'Edit snippet "%s"', 'insert-headers-and-footers' ), $this->snippet->get_title() ), $title );
|
187 |
+
}
|
188 |
+
|
189 |
+
return $title;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* The main page content.
|
194 |
+
*
|
195 |
+
* @return void
|
196 |
+
*/
|
197 |
+
public function output_content() {
|
198 |
+
if ( $this->show_library ) {
|
199 |
+
$this->show_snippet_library();
|
200 |
+
} else {
|
201 |
+
$this->show_snippet_editor();
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Show the snippet editor markup.
|
207 |
+
*
|
208 |
+
* @return void
|
209 |
+
*/
|
210 |
+
public function show_snippet_editor() {
|
211 |
+
$this->field_title();
|
212 |
+
$this->field_code_editor();
|
213 |
+
$this->field_insert_options();
|
214 |
+
$this->field_basic_info();
|
215 |
+
$this->field_conditional_logic();
|
216 |
+
$this->hidden_fields();
|
217 |
+
wp_nonce_field( $this->action, $this->nonce_name );
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Show the snippet library markup.
|
222 |
+
*
|
223 |
+
* @return void
|
224 |
+
*/
|
225 |
+
public function show_snippet_library() {
|
226 |
+
$library_data = wpcode()->library->get_data();
|
227 |
+
$categories = $library_data['categories'];
|
228 |
+
$snippets = $library_data['snippets'];
|
229 |
+
$default_category = isset( $categories[0]['slug'] ) ? $categories[0]['slug'] : '';
|
230 |
+
|
231 |
+
// Add a new item to allow adding a custom snippet.
|
232 |
+
array_unshift(
|
233 |
+
$snippets,
|
234 |
+
array(
|
235 |
+
'library_id' => 0,
|
236 |
+
'title' => __( 'Add Your Custom Code (New Snippet)', 'insert-headers-and-footers' ),
|
237 |
+
'note' => __( 'Choose this blank snippet to start from scratch and paste any custom code or simply write your own.', 'insert-headers-and-footers' ),
|
238 |
+
'categories' => array(
|
239 |
+
$default_category,
|
240 |
+
),
|
241 |
+
)
|
242 |
+
);
|
243 |
+
|
244 |
+
?>
|
245 |
+
<div class="wpcode-add-snippet-description">
|
246 |
+
<?php
|
247 |
+
$custom_url = add_query_arg(
|
248 |
+
array(
|
249 |
+
'page' => 'wpcode-snippet-manager',
|
250 |
+
'custom' => 1,
|
251 |
+
),
|
252 |
+
admin_url( 'admin.php' )
|
253 |
+
);
|
254 |
+
printf(
|
255 |
+
// Translators: The placeholders add links to create a new custom snippet or the suggest-a-snippet form.
|
256 |
+
esc_html__( 'To speed up the process you can select from one of our pre-made library, or you can start with a %1$sblank snippet%2$s and %1$screate your own%2$s. Have a suggestion for new snippet? %3$sWe’d love to hear it!%4$s', 'insert-headers-and-footers' ),
|
257 |
+
'<a href="' . esc_url( $custom_url ) . '">',
|
258 |
+
'</a>',
|
259 |
+
'<a href="' . esc_url( wpcode_utm_url( 'https://wpcode.com/suggestions/?wpf78_8=Snippet Request', 'add-new', 'library' ) ) . '" target="_blank">',
|
260 |
+
'</a>'
|
261 |
+
);
|
262 |
+
?>
|
263 |
+
</div>
|
264 |
+
<?php
|
265 |
+
$this->get_library_markup( $categories, $snippets );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Output the snippet title field.
|
270 |
+
*
|
271 |
+
* @return void
|
272 |
+
*/
|
273 |
+
public function field_title() {
|
274 |
+
$value = isset( $this->snippet ) ? $this->snippet->get_title() : '';
|
275 |
+
?>
|
276 |
+
<div class="wpcode-input-title">
|
277 |
+
<input type="text" class="widefat wpcode-input-text" value="<?php echo esc_attr( $value ); ?>" name="wpcode_snippet_title" placeholder="<?php esc_attr_e( 'Add title for snippet', 'insert-headers-and-footers' ); ?>"/>
|
278 |
+
</div>
|
279 |
+
<?php
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* The main code editor field.
|
284 |
+
*
|
285 |
+
* @return void
|
286 |
+
*/
|
287 |
+
public function field_code_editor() {
|
288 |
+
$value = isset( $this->snippet ) ? $this->snippet->get_code() : '';
|
289 |
+
?>
|
290 |
+
<div class="wpcode-code-textarea" data-code-type="<?php echo esc_attr( $this->code_type ); ?>">
|
291 |
+
<div class="wpcode-flex">
|
292 |
+
<div class="wpcode-column">
|
293 |
+
<h2>
|
294 |
+
<label for="wpcode_snippet_code"><?php esc_html_e( 'Code Preview', 'insert-headers-and-footers' ); ?></label>
|
295 |
+
</h2>
|
296 |
+
</div>
|
297 |
+
<div class="wpcode-column">
|
298 |
+
<?php $this->field_code_type(); ?>
|
299 |
+
</div>
|
300 |
+
</div>
|
301 |
+
<textarea name="wpcode_snippet_code" id="wpcode_snippet_code" class="widefat" rows="8" <?php disabled( ! current_user_can( 'unfiltered_html' ) ); ?>><?php echo esc_html( wp_unslash( $value ) ); ?></textarea>
|
302 |
+
<?php
|
303 |
+
wp_editor(
|
304 |
+
$value,
|
305 |
+
'wpcode_snippet_text',
|
306 |
+
array(
|
307 |
+
'wpautop' => false,
|
308 |
+
'default_editor' => 'tinymce',
|
309 |
+
'tinymce' => array(
|
310 |
+
'height' => 330,
|
311 |
+
),
|
312 |
+
)
|
313 |
+
);
|
314 |
+
?>
|
315 |
+
</div>
|
316 |
+
<?php
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Snippet type field.
|
321 |
+
*
|
322 |
+
* @return void
|
323 |
+
*/
|
324 |
+
public function field_code_type() {
|
325 |
+
$snippet_types = wpcode()->execute->get_options();
|
326 |
+
?>
|
327 |
+
<div class="wpcode-input-select">
|
328 |
+
<label for="wpcode_snippet_type"><?php esc_html_e( 'Code Type', 'insert-headers-and-footers' ); ?></label>
|
329 |
+
<select name="wpcode_snippet_type" id="wpcode_snippet_type">
|
330 |
+
<?php foreach ( $snippet_types as $key => $label ) { ?>
|
331 |
+
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $this->code_type, $key ); ?>>
|
332 |
+
<?php echo esc_html( $label ); ?>
|
333 |
+
</option>
|
334 |
+
<?php } ?>
|
335 |
+
</select>
|
336 |
+
</div>
|
337 |
+
<?php
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* The insert options - using a metabox-style layout to output the options.
|
342 |
+
*
|
343 |
+
* @return void
|
344 |
+
*/
|
345 |
+
public function field_insert_options() {
|
346 |
+
$title = __( 'Insertion', 'insert-headers-and-footers' );
|
347 |
+
$insert_toggle = $this->get_input_insert_toggle();
|
348 |
+
$auto_insert_options = $this->get_input_auto_insert_options();
|
349 |
+
$shortcode_field = $this->get_input_shortcode();
|
350 |
+
// Build the field markup here.
|
351 |
+
ob_start();
|
352 |
+
?>
|
353 |
+
<p><?php esc_html_e( 'Choose "Auto Insert" if you want the snippet to be automatically executed in one of the locations available. In "Shortcode" mode, the snippet will only be executed where the shortcode is inserted.', 'insert-headers-and-footers' ); ?></p>
|
354 |
+
<div class="wpcode-separator"></div>
|
355 |
+
<div class="wpcode-metabox-form">
|
356 |
+
<?php $this->metabox_row( __( 'Insert Method', 'insert-headers-and-footers' ), $insert_toggle ); ?>
|
357 |
+
<div class="wpcode-auto-insert-form-fields" data-show-if-id="#wpcode_auto_insert" data-show-if-value="1">
|
358 |
+
<?php
|
359 |
+
$this->metabox_row( __( 'Location', 'insert-headers-and-footers' ), $auto_insert_options, 'wpcode_auto_insert_location' );
|
360 |
+
$this->metabox_row(
|
361 |
+
__( 'Insert Number', 'insert-headers-and-footers' ),
|
362 |
+
$this->get_input_number(
|
363 |
+
'wpcode_auto_insert_number',
|
364 |
+
$this->get_auto_insert_number_value(),
|
365 |
+
'',
|
366 |
+
1
|
367 |
+
) . $this->get_insert_number_descriptions(),
|
368 |
+
'wpcode_auto_insert_number',
|
369 |
+
'#wpcode_auto_insert_location',
|
370 |
+
implode(
|
371 |
+
',',
|
372 |
+
array(
|
373 |
+
'before_paragraph',
|
374 |
+
'after_paragraph',
|
375 |
+
'archive_before_post',
|
376 |
+
'archive_after_post',
|
377 |
+
)
|
378 |
+
)
|
379 |
+
);
|
380 |
+
?>
|
381 |
+
</div>
|
382 |
+
<div class="wpcode-shortcode-form-fields" data-show-if-id="#wpcode_auto_insert" data-show-if-value="0">
|
383 |
+
<?php
|
384 |
+
$this->metabox_row( __( 'Shortcode', 'insert-headers-and-footers' ), $shortcode_field, 'wpcode_shortcode' );
|
385 |
+
?>
|
386 |
+
</div>
|
387 |
+
</div>
|
388 |
+
<?php
|
389 |
+
$content = ob_get_clean();
|
390 |
+
|
391 |
+
$this->metabox(
|
392 |
+
$title,
|
393 |
+
$content,
|
394 |
+
__( 'Your snippet can be either automatically executed or only used as a shortcode. When using the "Auto Insert" option you can choose the location where your snippet will be placed automatically.', 'insert-headers-and-footers' )
|
395 |
+
);
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Get all the descriptions for the insert number input with conditional rules.
|
400 |
+
*
|
401 |
+
* @return string
|
402 |
+
*/
|
403 |
+
public function get_insert_number_descriptions() {
|
404 |
+
$descriptions = array(
|
405 |
+
'before_paragraph' => __( 'Number of paragraphs before which to insert the snippet.', 'insert-headers-and-footers' ),
|
406 |
+
'after_paragraph' => __( 'Number of paragraphs after which to insert the snippet.', 'insert-headers-and-footers' ),
|
407 |
+
'archive_before_post' => __( 'Number of posts before which to insert the snippet.', 'insert-headers-and-footers' ),
|
408 |
+
'archive_after_post' => __( 'Number of posts after which to insert the snippet.', 'insert-headers-and-footers' ),
|
409 |
+
);
|
410 |
+
$markup = '';
|
411 |
+
foreach ( $descriptions as $value => $description ) {
|
412 |
+
$markup .= sprintf( '<p data-show-if-id="#wpcode_auto_insert_location" data-show-if-value="%1$s" style="display:none;">%2$s</p>', $value, esc_html( $description ) );
|
413 |
+
}
|
414 |
+
|
415 |
+
return $markup;
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Get the input insert toggle markup.
|
420 |
+
*
|
421 |
+
* @return string
|
422 |
+
*/
|
423 |
+
public function get_input_insert_toggle() {
|
424 |
+
ob_start();
|
425 |
+
?>
|
426 |
+
<div class="wpcode-button-toggle">
|
427 |
+
<button class="wpcode-button wpcode-button-large wpcode-button-secondary <?php echo esc_attr( $this->get_active_toggle_class( 1 ) ); ?>" type="button" value="1">
|
428 |
+
<?php wpcode_icon( 'auto', 18, 23 ); ?>
|
429 |
+
<span><?php esc_html_e( 'Auto Insert', 'insert-headers-and-footers' ); ?></span>
|
430 |
+
</button>
|
431 |
+
<button class="wpcode-button wpcode-button-large wpcode-button-secondary <?php echo esc_attr( $this->get_active_toggle_class( 0 ) ); ?>" type="button" value="0">
|
432 |
+
<?php wpcode_icon( 'shortcode', 24, 17 ); ?>
|
433 |
+
<span><?php esc_html_e( 'Shortcode', 'insert-headers-and-footers' ); ?></span>
|
434 |
+
</button>
|
435 |
+
<input type="hidden" name="wpcode_auto_insert" class="wpcode-button-toggle-input" id="wpcode_auto_insert" value="<?php echo absint( $this->get_auto_insert_value() ); ?>"/>
|
436 |
+
</div>
|
437 |
+
<?php
|
438 |
+
return ob_get_clean();
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* Get the active toggle class based on the auto-insert value.
|
443 |
+
*
|
444 |
+
* @param string|int $value The value of the button.
|
445 |
+
*
|
446 |
+
* @return string
|
447 |
+
*/
|
448 |
+
private function get_active_toggle_class( $value ) {
|
449 |
+
$current_value = $this->get_auto_insert_value();
|
450 |
+
if ( absint( $value ) !== $current_value ) {
|
451 |
+
return 'wpcode-button-secondary-inactive';
|
452 |
+
}
|
453 |
+
|
454 |
+
return '';
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Get the auto-insert value consistently.
|
459 |
+
*
|
460 |
+
* @return int
|
461 |
+
*/
|
462 |
+
private function get_auto_insert_value() {
|
463 |
+
return isset( $this->snippet ) ? $this->snippet->get_auto_insert() : 0;
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* Renders the dropdown with the auto-insert options.
|
468 |
+
* This uses the auto-insert class that loads all the available types.
|
469 |
+
* Each type has some specific options.
|
470 |
+
*
|
471 |
+
* @return string
|
472 |
+
* @see WPCode_Auto_Insert
|
473 |
+
*/
|
474 |
+
public function get_input_auto_insert_options() {
|
475 |
+
$available_types = wpcode()->auto_insert->get_types();
|
476 |
+
$location = '';
|
477 |
+
$location_terms = wp_get_post_terms(
|
478 |
+
$this->snippet_id,
|
479 |
+
'wpcode_location',
|
480 |
+
array(
|
481 |
+
'fields' => 'slugs',
|
482 |
+
'number' => 1, // A snippet can only have 1 type.
|
483 |
+
)
|
484 |
+
);
|
485 |
+
if ( ! empty( $location_terms ) ) {
|
486 |
+
$location = $location_terms[0];
|
487 |
+
}
|
488 |
+
ob_start();
|
489 |
+
?>
|
490 |
+
<select name="wpcode_auto_insert_location" id="wpcode_auto_insert_location">
|
491 |
+
<?php
|
492 |
+
foreach ( $available_types as $type ) {
|
493 |
+
$options = $type->get_locations();
|
494 |
+
if ( empty( $options ) ) {
|
495 |
+
continue;
|
496 |
+
}
|
497 |
+
?>
|
498 |
+
<optgroup label="<?php echo esc_attr( $type->get_label() ); ?>" data-code-type="<?php echo esc_attr( $type->code_type ); ?>">
|
499 |
+
<?php
|
500 |
+
foreach ( $options as $key => $label ) {
|
501 |
+
$disabled = false;
|
502 |
+
if ( 'all' !== $type->code_type && $type->code_type !== $this->code_type ) {
|
503 |
+
$disabled = true;
|
504 |
+
}
|
505 |
+
?>
|
506 |
+
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $location, $key ); ?> <?php disabled( $disabled ); ?>>
|
507 |
+
<?php echo esc_html( $label ); ?>
|
508 |
+
</option>
|
509 |
+
<?php } ?>
|
510 |
+
</optgroup>
|
511 |
+
<?php
|
512 |
+
}
|
513 |
+
?>
|
514 |
+
</select>
|
515 |
+
<?php
|
516 |
+
return ob_get_clean();
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Get the shortcode field.
|
521 |
+
*
|
522 |
+
* @return string
|
523 |
+
*/
|
524 |
+
public function get_input_shortcode() {
|
525 |
+
$shortcode = __( 'Please save the snippet first', 'insert-headers-and-footers' );
|
526 |
+
if ( isset( $this->snippet_id ) ) {
|
527 |
+
$shortcode = sprintf( '[wpcode id="%d"]', $this->snippet_id );
|
528 |
+
}
|
529 |
+
$input = sprintf(
|
530 |
+
'<input type="text" value=\'%1$s\' id="wpcode-shortcode" class="wpcode-input-text" readonly />',
|
531 |
+
$shortcode
|
532 |
+
);
|
533 |
+
$button = sprintf(
|
534 |
+
'<button class="wpcode-button wpcode-button-icon wpcode-button-secondary wpcode-copy-target" data-target="#wpcode-shortcode" type="button"><span class="wpcode-default-icon">%1$s</span><span class="wpcode-success-icon">%2$s</span> %3$s</button>',
|
535 |
+
get_wpcode_icon( 'copy', 16, 16 ),
|
536 |
+
get_wpcode_icon( 'check', 16, 13 ),
|
537 |
+
_x( 'Copy', 'Copy to clipboard', 'insert-headers-and-footers' )
|
538 |
+
);
|
539 |
+
|
540 |
+
return sprintf( '<div class="wpcode-input-with-button">%1$s %2$s</div>', $input, $button );
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Generic input number function.
|
545 |
+
*
|
546 |
+
* @param string $id The id of the input field.
|
547 |
+
* @param string|int $value The value of the input.
|
548 |
+
* @param string $description The description to display under the field.
|
549 |
+
* @param int $min The minimum value.
|
550 |
+
*
|
551 |
+
* @return string
|
552 |
+
*/
|
553 |
+
public function get_input_number( $id, $value = '', $description = '', $min = 0 ) {
|
554 |
+
$input = '<input type="number" class="wpcode-input-number" id="' . esc_attr( $id ) . '" name="' . esc_attr( $id ) . '" value="' . esc_attr( $value ) . '" min="' . absint( $min ) . '" />';
|
555 |
+
if ( ! empty( $description ) ) {
|
556 |
+
$input .= '<p>' . $description . '</p>';
|
557 |
+
}
|
558 |
+
|
559 |
+
return $input;
|
560 |
+
}
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Get a simple textarea field.
|
564 |
+
*
|
565 |
+
* @param string $id The id of the input field.
|
566 |
+
* @param string $value The value of the input.
|
567 |
+
* @param string $description The description to display under the field.
|
568 |
+
*
|
569 |
+
* @return string
|
570 |
+
*/
|
571 |
+
public function get_input_textarea( $id, $value = '', $description = '' ) {
|
572 |
+
$input = '<textarea class="wpcode-input-textarea" id="' . esc_attr( $id ) . '" name="' . esc_attr( $id ) . '" rows="3">' . esc_html( $value ) . '</textarea>';
|
573 |
+
if ( ! empty( $description ) ) {
|
574 |
+
$input .= '<p>' . $description . '</p>';
|
575 |
+
}
|
576 |
+
|
577 |
+
return $input;
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Get the auto-insert value consistently.
|
582 |
+
*
|
583 |
+
* @return int
|
584 |
+
*/
|
585 |
+
private function get_auto_insert_number_value() {
|
586 |
+
return isset( $this->snippet ) ? $this->snippet->get_auto_insert_number() : 1;
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Markup for the basic info metabox.
|
591 |
+
*
|
592 |
+
* @return void
|
593 |
+
*/
|
594 |
+
public function field_basic_info() {
|
595 |
+
$priority = isset( $this->snippet ) ? $this->snippet->get_priority() : 10;
|
596 |
+
$note = isset( $this->snippet ) ? $this->snippet->get_note() : '';
|
597 |
+
|
598 |
+
ob_start();
|
599 |
+
$this->metabox_row( __( 'Tag', 'insert-headers-and-footers' ), $this->get_input_tag_picker() );
|
600 |
+
$this->metabox_row( __( 'Priority', 'insert-headers-and-footers' ), $this->get_input_number( 'wpcode_priority', $priority ), 'wpcode_priority' );
|
601 |
+
$this->metabox_row( __( 'Note', 'insert-headers-and-footers' ), $this->get_input_textarea( 'wpcode_note', $note ), 'wpcode_note' );
|
602 |
+
|
603 |
+
$this->metabox(
|
604 |
+
__( 'Basic info', 'insert-headers-and-footers' ),
|
605 |
+
ob_get_clean(),
|
606 |
+
__( 'Tags: Use tags to make it easier to group similar snippets together. <br />Priority: A lower priority will result in the snippet being executed before others with a higher priority. <br />Note: Add a private note related to this snippet.', 'insert-headers-and-footers' )
|
607 |
+
);
|
608 |
+
}
|
609 |
+
|
610 |
+
/**
|
611 |
+
* The conditional logic field.
|
612 |
+
*
|
613 |
+
* @return void
|
614 |
+
*/
|
615 |
+
public function field_conditional_logic() {
|
616 |
+
$enable_logic = isset( $this->snippet ) && $this->snippet->conditional_rules_enabled();
|
617 |
+
|
618 |
+
$content = '<p>' . __( 'Using conditional logic you can limit the pages where you want the snippet to be auto-inserted.', 'insert-headers-and-footers' ) . '</p>';
|
619 |
+
|
620 |
+
$content .= '<div class="wpcode-separator"></div>';
|
621 |
+
ob_start();
|
622 |
+
$this->metabox_row( __( 'Enable Logic', 'insert-headers-and-footers' ), $this->get_checkbox_toggle( $enable_logic, 'wpcode_conditional_logic_enable' ) );
|
623 |
+
$this->metabox_row( __( 'Conditions', 'insert-headers-and-footers' ), $this->get_conditional_logic_input(), 'wpcode_contional_logic_conditions', '#wpcode_conditional_logic_enable', '1' );
|
624 |
+
|
625 |
+
$content .= ob_get_clean();
|
626 |
+
|
627 |
+
$this->metabox(
|
628 |
+
__( 'Smart Conditional Logic', 'insert-headers-and-footers' ),
|
629 |
+
$content,
|
630 |
+
__( 'Enable logic to add rules and limit where your snippets are inserted automatically. Use multiple groups for different sets of rules.', 'insert-headers-and-footers' )
|
631 |
+
);
|
632 |
+
}
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Get the tag picker markup.
|
636 |
+
*
|
637 |
+
* @return string
|
638 |
+
*/
|
639 |
+
public function get_input_tag_picker() {
|
640 |
+
$tags = isset( $this->snippet ) ? $this->snippet->get_tags() : array();
|
641 |
+
$tags_string = isset( $this->snippet ) ? implode( ',', $this->snippet->get_tags() ) : '';
|
642 |
+
$markup = '<select multiple="multiple" class="wpcode-tags-picker" data-target="#wpcode-tags">';
|
643 |
+
foreach ( $tags as $tag ) {
|
644 |
+
$markup .= '<option value="' . esc_attr( $tag ) . '" selected="selected">' . esc_html( $tag ) . '</option>';
|
645 |
+
}
|
646 |
+
$markup .= '</select>';
|
647 |
+
$markup .= '<input type="hidden" name="wpcode_tags" id="wpcode-tags" value="' . esc_attr( $tags_string ) . '" />';
|
648 |
+
|
649 |
+
return $markup;
|
650 |
+
}
|
651 |
+
|
652 |
+
/**
|
653 |
+
* The hidden fields needed to identify the form submission.
|
654 |
+
*
|
655 |
+
* @return void
|
656 |
+
*/
|
657 |
+
public function hidden_fields() {
|
658 |
+
if ( ! isset( $this->snippet_id ) ) {
|
659 |
+
return;
|
660 |
+
}
|
661 |
+
?>
|
662 |
+
<input type="hidden" name="id" value="<?php echo esc_attr( $this->snippet_id ); ?>"/>
|
663 |
+
<?php
|
664 |
+
}
|
665 |
+
|
666 |
+
/**
|
667 |
+
* Output of the page wrapped in a form.
|
668 |
+
*
|
669 |
+
* @return void
|
670 |
+
*/
|
671 |
+
public function output() {
|
672 |
+
if ( $this->show_library ) {
|
673 |
+
// Don't wrap with form when showing library.
|
674 |
+
parent::output();
|
675 |
+
|
676 |
+
return;
|
677 |
+
}
|
678 |
+
?>
|
679 |
+
<form action="<?php echo esc_url( $this->get_page_action_url() ); ?>" method="post" id="wpcode-snippet-manager-form">
|
680 |
+
<?php parent::output(); ?>
|
681 |
+
</form>
|
682 |
+
<?php
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
* The bottom of the header part.
|
687 |
+
*
|
688 |
+
* @return void
|
689 |
+
*/
|
690 |
+
public function output_header_bottom() {
|
691 |
+
$active = isset( $this->snippet ) && $this->snippet->is_active();
|
692 |
+
?>
|
693 |
+
<div class="wpcode-column">
|
694 |
+
<h1><?php echo esc_html( $this->header_title ); ?></h1>
|
695 |
+
</div>
|
696 |
+
<?php if ( $this->show_library ) {
|
697 |
+
return;
|
698 |
+
} ?>
|
699 |
+
<div class="wpcode-column">
|
700 |
+
<div class="wpcode-status-text">
|
701 |
+
<span data-show-if-id="#wpcode_active" data-show-if-value="1" style="display: none">
|
702 |
+
<?php esc_html_e( 'Active', 'insert-headers-and-footers' ); ?>
|
703 |
+
</span>
|
704 |
+
<span data-show-if-id="#wpcode_active" data-show-if-value="0" style="display:none;">
|
705 |
+
<?php esc_html_e( 'Inactive', 'insert-headers-and-footers' ); ?>
|
706 |
+
</span>
|
707 |
+
</div>
|
708 |
+
<?php echo $this->get_checkbox_toggle( $active, 'wpcode_active' ); ?>
|
709 |
+
<button class="wpcode-button" type="submit" value="publish" name="button"><?php echo esc_html( $this->publish_button_text ); ?></button>
|
710 |
+
</div>
|
711 |
+
<?php
|
712 |
+
}
|
713 |
+
|
714 |
+
/**
|
715 |
+
* Handle a form submit here.
|
716 |
+
*
|
717 |
+
* @return void
|
718 |
+
*/
|
719 |
+
public function submit_listener() {
|
720 |
+
if ( ! isset( $_REQUEST[ $this->nonce_name ] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST[ $this->nonce_name ] ), $this->action ) ) {
|
721 |
+
// Nonce is missing, so we're not even going to try.
|
722 |
+
return;
|
723 |
+
}
|
724 |
+
if ( ! $this->can_edit ) {
|
725 |
+
return;
|
726 |
+
}
|
727 |
+
|
728 |
+
$code_type = isset( $_POST['wpcode_snippet_type'] ) ? sanitize_text_field( wp_unslash( $_POST['wpcode_snippet_type'] ) ) : 'html';
|
729 |
+
$snippet_code = isset( $_POST['wpcode_snippet_code'] ) ? wp_unslash( $_POST['wpcode_snippet_code'] ) : '';
|
730 |
+
if ( 'text' === $code_type ) {
|
731 |
+
$snippet_code = wpautop( $snippet_code );
|
732 |
+
}
|
733 |
+
|
734 |
+
$snippet = new WPCode_Snippet(
|
735 |
+
array(
|
736 |
+
'id' => empty( $_REQUEST['id'] ) ? 0 : absint( $_REQUEST['id'] ),
|
737 |
+
'title' => isset( $_POST['wpcode_snippet_title'] ) ? sanitize_text_field( wp_unslash( $_POST['wpcode_snippet_title'] ) ) : '',
|
738 |
+
'code' => $snippet_code,
|
739 |
+
'active' => isset( $_REQUEST['wpcode_active'] ),
|
740 |
+
'code_type' => $code_type,
|
741 |
+
'location' => isset( $_POST['wpcode_auto_insert_location'] ) ? sanitize_text_field( wp_unslash( $_POST['wpcode_auto_insert_location'] ) ) : '',
|
742 |
+
'insert_number' => isset( $_POST['wpcode_auto_insert_number'] ) ? absint( $_POST['wpcode_auto_insert_number'] ) : 0,
|
743 |
+
'auto_insert' => isset( $_POST['wpcode_auto_insert'] ) ? absint( $_POST['wpcode_auto_insert'] ) : 0,
|
744 |
+
'tags' => isset( $_POST['wpcode_tags'] ) ? explode( ',', sanitize_text_field( wp_unslash( $_POST['wpcode_tags'] ) ) ) : array(),
|
745 |
+
'use_rules' => isset( $_POST['wpcode_conditional_logic_enable'] ),
|
746 |
+
'rules' => isset( $_POST['wpcode_cl_rules'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['wpcode_cl_rules'] ) ), true ) : array(),
|
747 |
+
'priority' => isset( $_POST['wpcode_priority'] ) ? intval( $_POST['wpcode_priority'] ) : 10,
|
748 |
+
'note' => isset( $_POST['wpcode_note'] ) ? sanitize_textarea_field( wp_unslash( $_POST['wpcode_note'] ) ) : '',
|
749 |
+
)
|
750 |
+
);
|
751 |
+
|
752 |
+
if ( empty( $snippet->title ) ) {
|
753 |
+
$snippet->title = $snippet->get_untitled_title();
|
754 |
+
}
|
755 |
+
|
756 |
+
$message_number = 1;
|
757 |
+
$active_wanted = $snippet->active;
|
758 |
+
|
759 |
+
if ( 0 === $snippet->id ) {
|
760 |
+
// If it's a new snippet display a different message.
|
761 |
+
$message_number = 2;
|
762 |
+
}
|
763 |
+
|
764 |
+
$id = $snippet->save();
|
765 |
+
|
766 |
+
if ( $active_wanted !== $snippet->is_active() ) {
|
767 |
+
// If the snippet failed to change status display an error message.
|
768 |
+
$message_number = 3;
|
769 |
+
// If the current user is not allowed to change snippet status, display a different message.
|
770 |
+
if ( ! current_user_can( 'wpcode_activate_snippets' ) ) {
|
771 |
+
$message_number = 4;
|
772 |
+
}
|
773 |
+
}
|
774 |
+
|
775 |
+
if ( $id ) {
|
776 |
+
wp_safe_redirect(
|
777 |
+
add_query_arg(
|
778 |
+
array(
|
779 |
+
'snippet_id' => $id,
|
780 |
+
'message' => $message_number,
|
781 |
+
),
|
782 |
+
$this->get_page_action_url()
|
783 |
+
)
|
784 |
+
);
|
785 |
+
exit;
|
786 |
+
}
|
787 |
+
}
|
788 |
+
|
789 |
+
/**
|
790 |
+
* Load page-specific scripts.
|
791 |
+
*
|
792 |
+
* @return void
|
793 |
+
*/
|
794 |
+
public function page_scripts() {
|
795 |
+
if ( $this->show_library ) {
|
796 |
+
return;
|
797 |
+
}
|
798 |
+
$settings = $this->load_code_mirror();
|
799 |
+
|
800 |
+
wp_enqueue_script( 'htmlhint' );
|
801 |
+
wp_enqueue_script( 'csslint' );
|
802 |
+
wp_enqueue_script( 'jshint' );
|
803 |
+
|
804 |
+
if ( isset( $settings['codemirror'] ) ) {
|
805 |
+
// Update settings to improve style when switching code types.
|
806 |
+
$settings['codemirror'] = array_merge(
|
807 |
+
array(
|
808 |
+
'autoCloseTags' => true,
|
809 |
+
'matchTags' => array(
|
810 |
+
'bothTags' => true,
|
811 |
+
),
|
812 |
+
),
|
813 |
+
$settings['codemirror']
|
814 |
+
);
|
815 |
+
}
|
816 |
+
|
817 |
+
wp_add_inline_script( 'code-editor', sprintf( 'jQuery( function() { window.wpcode_editor = wp.codeEditor.initialize( "wpcode_snippet_code", %s ); } );', wp_json_encode( $settings ) ) );
|
818 |
+
}
|
819 |
+
|
820 |
+
/**
|
821 |
+
* Get the snippet type based on the context.
|
822 |
+
*
|
823 |
+
* @return void
|
824 |
+
*/
|
825 |
+
public function set_code_type() {
|
826 |
+
if ( isset( $this->snippet ) ) {
|
827 |
+
$this->code_type = $this->snippet->get_code_type();
|
828 |
+
}
|
829 |
+
}
|
830 |
+
|
831 |
+
/**
|
832 |
+
* Get the conditional logic options input markup.
|
833 |
+
*
|
834 |
+
* @return string
|
835 |
+
*/
|
836 |
+
public function get_conditional_logic_input() {
|
837 |
+
|
838 |
+
$conditional_rules = isset( $this->snippet ) ? wp_json_encode( $this->snippet->get_conditional_rules() ) : '';
|
839 |
+
|
840 |
+
$markup = $this->get_conditional_select_show_hide();
|
841 |
+
|
842 |
+
$markup .= sprintf( '<div id="wpcode-conditions-holder">%s</div>', $this->build_conditional_rules_form() );
|
843 |
+
$markup .= sprintf( '<button type="button" class="wpcode-button" id="wpcode-cl-add-group">%s</button>', __( '+ Add new group', 'insert-headers-and-footers' ) );
|
844 |
+
$markup .= sprintf( '<script type="text/template" id="wpcode-conditions-group-markup">%s</script>', $this->get_conditions_group_markup() );
|
845 |
+
$markup .= sprintf( '<script type="text/template" id="wpcode-conditions-group-row-markup">%s</script>', $this->get_conditions_group_row_markup() );
|
846 |
+
$markup .= sprintf( '<input type="hidden" name="wpcode_cl_rules" id="wpcode-cl-rules" value="%s" />', esc_attr( $conditional_rules ) );
|
847 |
+
|
848 |
+
return $markup;
|
849 |
+
}
|
850 |
+
|
851 |
+
/**
|
852 |
+
* Markup for the show/hide select input.
|
853 |
+
*
|
854 |
+
* @return string
|
855 |
+
*/
|
856 |
+
public function get_conditional_select_show_hide() {
|
857 |
+
$rules = isset( $this->snippet ) ? $this->snippet->get_conditional_rules() : array();
|
858 |
+
$selected = empty( $rules ) ? 'show' : $rules['show'];
|
859 |
+
$options = array(
|
860 |
+
'show' => __( 'Show', 'insert-headers-and-footers' ),
|
861 |
+
'hide' => __( 'Hide', 'insert-headers-and-footers' ),
|
862 |
+
);
|
863 |
+
|
864 |
+
$markup = '<div class="wpcode-inline-select">';
|
865 |
+
|
866 |
+
$markup .= '<select id="wpcode-cl-show-hide">';
|
867 |
+
foreach ( $options as $value => $label ) {
|
868 |
+
$markup .= sprintf(
|
869 |
+
'<option value="%1$s" %2$s>%3$s</option>',
|
870 |
+
esc_attr( $value ),
|
871 |
+
selected( $value, $selected, false ),
|
872 |
+
esc_html( $label )
|
873 |
+
);
|
874 |
+
}
|
875 |
+
$markup .= '</select>';
|
876 |
+
$markup .= sprintf( '<span>%s</span>', __( 'This code snippet if', 'insert-headers-and-footers' ) );
|
877 |
+
$markup .= '</div>';
|
878 |
+
|
879 |
+
return $markup;
|
880 |
+
}
|
881 |
+
|
882 |
+
/**
|
883 |
+
* Build back the form markup from the stored conditions.
|
884 |
+
*
|
885 |
+
* @return string|void
|
886 |
+
*/
|
887 |
+
public function build_conditional_rules_form() {
|
888 |
+
if ( ! isset( $this->snippet ) ) {
|
889 |
+
return;
|
890 |
+
}
|
891 |
+
$options = wpcode()->conditional_logic->get_all_admin_options();
|
892 |
+
$rules = $this->snippet->get_conditional_rules();
|
893 |
+
if ( empty( $rules ) || empty( $rules['groups'] ) ) {
|
894 |
+
return;
|
895 |
+
}
|
896 |
+
$form_groups = array();
|
897 |
+
foreach ( $rules['groups'] as $group_rows ) {
|
898 |
+
$rows = array();
|
899 |
+
foreach ( $group_rows as $row ) {
|
900 |
+
$type_options = $options[ $row['type'] ];
|
901 |
+
$value_option = $type_options['options'][ $row['option'] ];
|
902 |
+
|
903 |
+
$rows[] = $this->get_conditions_group_row_markup( $row['option'], $row['relation'], $this->get_input_markup_by_type( $value_option, $row['value'] ) );
|
904 |
+
}
|
905 |
+
|
906 |
+
$form_groups[] = $this->get_conditions_group_markup( implode( '', $rows ) );
|
907 |
+
}
|
908 |
+
|
909 |
+
return implode( $form_groups );
|
910 |
+
|
911 |
+
}
|
912 |
+
|
913 |
+
/**
|
914 |
+
* Process the type options and return the input markup.
|
915 |
+
*
|
916 |
+
* @param array $data The data with the settings/options.
|
917 |
+
* @param string $value The value currently selected.
|
918 |
+
*
|
919 |
+
* @return string
|
920 |
+
*/
|
921 |
+
private function get_input_markup_by_type( $data, $value ) {
|
922 |
+
$markup = '';
|
923 |
+
switch ( $data['type'] ) {
|
924 |
+
case 'select':
|
925 |
+
$markup = '<select>';
|
926 |
+
foreach ( $data['options'] as $option ) {
|
927 |
+
$markup .= '<option value="' . esc_attr( $option['value'] ) . '" ' . selected( $value, $option['value'], false ) . '>' . esc_html( $option['label'] ) . '</option>';
|
928 |
+
}
|
929 |
+
$markup .= '</select>';
|
930 |
+
break;
|
931 |
+
case 'text':
|
932 |
+
$markup = sprintf( '<input type="text" class="wpcode-input-text" value="%s" />', esc_attr( $value ) );
|
933 |
+
break;
|
934 |
+
case 'ajax':
|
935 |
+
$options = isset( $data['labels_callback'] ) ? $data['labels_callback']( $value ) : array();
|
936 |
+
$markup = '<select class="wpcode-select2" data-action="' . esc_attr( $data['options'] ) . '" multiple>';
|
937 |
+
foreach ( $options as $option ) {
|
938 |
+
$markup .= '<option value="' . esc_attr( $option['value'] ) . '" ' . selected( true, true, false ) . '>' . esc_html( $option['label'] ) . '</option>';
|
939 |
+
}
|
940 |
+
$markup .= '</select>';
|
941 |
+
break;
|
942 |
+
}
|
943 |
+
|
944 |
+
return $markup;
|
945 |
+
}
|
946 |
+
|
947 |
+
/**
|
948 |
+
* Build the markup for an empty conditional logic group.
|
949 |
+
*
|
950 |
+
* @param string $rows Optional, already-built rows markup.
|
951 |
+
*
|
952 |
+
* @return string
|
953 |
+
*/
|
954 |
+
private function get_conditions_group_markup( $rows = '' ) {
|
955 |
+
$markup = '<div class="wpcode-cl-group">';
|
956 |
+
|
957 |
+
$markup .= $this->get_conditions_group_or_markup();
|
958 |
+
$markup .= '<div class="wpcode-cl-group-rules">' . $rows . '</div>';
|
959 |
+
$markup .= sprintf( '<button class="wpcode-button wpcode-cl-add-row" type="button">%s</button>', _x( 'AND', 'Conditional logic add another "and" rules row.', 'insert-headers-and-footers' ) );
|
960 |
+
$markup .= '</div>';
|
961 |
+
|
962 |
+
return $markup;
|
963 |
+
}
|
964 |
+
|
965 |
+
/**
|
966 |
+
* Build the markup for a conditional logic row. All parameters are optional and if
|
967 |
+
* left empty it will return the template to be used in JS.
|
968 |
+
*
|
969 |
+
* @param string $type The value for the type input.
|
970 |
+
* @param string $relation The value for the relation field.
|
971 |
+
* @param string $value The value selected for this row.
|
972 |
+
*
|
973 |
+
* @return string
|
974 |
+
*/
|
975 |
+
private function get_conditions_group_row_markup( $type = '', $relation = '', $value = '' ) {
|
976 |
+
$options = wpcode()->conditional_logic->get_all_admin_options();
|
977 |
+
|
978 |
+
$markup = '<div class="wpcode-cl-rules-row">';
|
979 |
+
|
980 |
+
$markup .= '<div class="wpcode-cl-rules-row-options">';
|
981 |
+
$markup .= '<select class="wpcode-cl-rule-type">';
|
982 |
+
foreach ( $options as $opt_group ) {
|
983 |
+
$markup .= '<optgroup label="' . esc_attr( $opt_group['label'] ) . '" data-type="' . esc_attr( $opt_group['name'] ) . '">';
|
984 |
+
foreach ( $opt_group['options'] as $key => $option ) {
|
985 |
+
$markup .= '<option value="' . esc_attr( $key ) . '" ' . selected( $type, $key, false ) . '>' . esc_html( $option['label'] ) . '</option>';
|
986 |
+
}
|
987 |
+
$markup .= '</optgroup>';
|
988 |
+
}
|
989 |
+
$markup .= '</select>';
|
990 |
+
$markup .= $this->get_conditions_relation_select( $relation );
|
991 |
+
$markup .= '<div class="wpcode-cl-rule-value">' . $value . '</div>';// This should be automatically populated based on the selected type.
|
992 |
+
$markup .= '</div>'; // rules-row-options.
|
993 |
+
$markup .= '<button class="wpcode-button-just-icon wpcode-cl-remove-row" type="button">' . get_wpcode_icon( 'remove' ) . '</button>'; // rules-row-options.
|
994 |
+
$markup .= '</div>'; // rules-row.
|
995 |
+
|
996 |
+
return $markup;
|
997 |
+
}
|
998 |
+
|
999 |
+
/**
|
1000 |
+
* Get the markup for the relation field.
|
1001 |
+
*
|
1002 |
+
* @param string $relation Optional selected relation.
|
1003 |
+
*
|
1004 |
+
* @return string
|
1005 |
+
*/
|
1006 |
+
private function get_conditions_relation_select( $relation = '' ) {
|
1007 |
+
$options = array(
|
1008 |
+
'=' => __( 'Is', 'insert-headers-and-footers' ),
|
1009 |
+
'!=' => __( 'Is not', 'insert-headers-and-footers' ),
|
1010 |
+
'contains' => __( 'Contains', 'insert-headers-and-footers' ),
|
1011 |
+
'notcontains' => __( 'Doesn\'t Contain', 'insert-headers-and-footers' ),
|
1012 |
+
);
|
1013 |
+
$markup = '<select class="wpcode-cl-rule-relation">';
|
1014 |
+
foreach ( $options as $value => $label ) {
|
1015 |
+
$markup .= '<option value="' . esc_attr( $value ) . '" ' . selected( $relation, $value, false ) . '>' . esc_html( $label ) . '</option>';
|
1016 |
+
}
|
1017 |
+
$markup .= '</select>';
|
1018 |
+
|
1019 |
+
return $markup;
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
/**
|
1023 |
+
* The markup for the "or" displayed between groups.
|
1024 |
+
*
|
1025 |
+
* @return string
|
1026 |
+
*/
|
1027 |
+
private function get_conditions_group_or_markup() {
|
1028 |
+
$markup = '<div class="wpcode-cl-group-or">';
|
1029 |
+
|
1030 |
+
$markup .= '<div class="wpcode-cl-group-or-line"></div>';
|
1031 |
+
$markup .= '<div class="wpcode-cl-group-or-text">' . _x( 'OR', 'Conditional logic "or" another rule', 'insert-headers-and-footers' ) . '</div>';
|
1032 |
+
$markup .= '</div>';
|
1033 |
+
|
1034 |
+
return $markup;
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
/**
|
1038 |
+
* Add conditions to the admin script when on this page.
|
1039 |
+
*
|
1040 |
+
* @param array $data The localized data used in wp_localize_script.
|
1041 |
+
*
|
1042 |
+
* @return array
|
1043 |
+
* @see wpcode_admin_scripts
|
1044 |
+
*/
|
1045 |
+
public function add_conditional_rules_to_script( $data ) {
|
1046 |
+
if ( ! isset( $data['conditions'] ) ) {
|
1047 |
+
$data['conditions'] = wpcode()->conditional_logic->get_all_admin_options();
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
return $data;
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
/**
|
1054 |
+
* If we're showing a "text" code type let's display TinyMCE by default.
|
1055 |
+
*
|
1056 |
+
* @param string $body_class The body class.
|
1057 |
+
*
|
1058 |
+
* @return string
|
1059 |
+
*/
|
1060 |
+
public function maybe_show_tinymce( $body_class ) {
|
1061 |
+
if ( 'text' === $this->code_type ) {
|
1062 |
+
$body_class .= ' wpcode-show-tinymce';
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
return $body_class;
|
1066 |
+
}
|
1067 |
+
}
|
includes/admin/pages/class-wpcode-admin-page-tools.php
ADDED
@@ -0,0 +1,938 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Tools admin page.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class for the Tools admin page.
|
10 |
+
*/
|
11 |
+
class WPCode_Admin_Page_Tools extends WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug to be used when adding the submenu.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = 'wpcode-tools';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The action used for the nonce.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $action = 'wpcode-tools';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Default view.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
public $view = 'import';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The nonce name field.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
private $nonce_name = 'wpcode-tools_nonce';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Available importers.
|
43 |
+
*
|
44 |
+
* @var WPCode_Importer_Type[]
|
45 |
+
*/
|
46 |
+
private $importers = array();
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Call this just to set the page title translatable.
|
50 |
+
*/
|
51 |
+
public function __construct() {
|
52 |
+
$this->page_title = __( 'Tools', 'insert-headers-and-footers' );
|
53 |
+
parent::__construct();
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Register hook on admin init just for this page.
|
58 |
+
*
|
59 |
+
* @return void
|
60 |
+
*/
|
61 |
+
public function page_hooks() {
|
62 |
+
$this->process_message();
|
63 |
+
add_action( 'admin_init', array( $this, 'submit_listener' ) );
|
64 |
+
add_action( 'admin_print_scripts', array( $this, 'importer_templates' ) );
|
65 |
+
add_filter( 'wpcode_admin_js_data', array( $this, 'add_tools_data' ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Process messages specific to this page.
|
71 |
+
*
|
72 |
+
* @return void
|
73 |
+
*/
|
74 |
+
public function process_message() {
|
75 |
+
// phpcs:disable WordPress.Security.NonceVerification
|
76 |
+
if ( ! isset( $_GET['message'] ) ) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
$messages = array(
|
81 |
+
1 => sprintf(
|
82 |
+
// Translators: Adds a link to the snippets list in the admin.
|
83 |
+
__( 'Import was successfully finished. You can go and check %1$syour snippets%2$s.', 'insert-headers-and-footers' ),
|
84 |
+
'<a href="' . esc_url( admin_url( 'admin.php?page=wpcode' ) ) . '">',
|
85 |
+
'</a>'
|
86 |
+
),
|
87 |
+
);
|
88 |
+
$message = absint( $_GET['message'] );
|
89 |
+
// phpcs:enable WordPress.Security.NonceVerification
|
90 |
+
|
91 |
+
if ( ! isset( $messages[ $message ] ) ) {
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
|
95 |
+
$this->set_success_message( $messages[ $message ] );
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @return WPCode_Importer_Type[]
|
101 |
+
*/
|
102 |
+
public function get_importers() {
|
103 |
+
if ( empty( $this->importers ) ) {
|
104 |
+
$this->importers = wpcode()->importers->get_importers();
|
105 |
+
}
|
106 |
+
|
107 |
+
return $this->importers;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* The Tools page output.
|
112 |
+
*
|
113 |
+
* @return void
|
114 |
+
*/
|
115 |
+
public function output_content() {
|
116 |
+
if ( method_exists( $this, 'output_view_' . $this->view ) ) {
|
117 |
+
call_user_func( array( $this, 'output_view_' . $this->view ) );
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* The Import view.
|
123 |
+
*
|
124 |
+
* @return void
|
125 |
+
*/
|
126 |
+
public function output_view_import() {
|
127 |
+
?>
|
128 |
+
<div class="wpcode-setting-row wpcode-tools">
|
129 |
+
<h3><?php esc_html_e( 'WPCode Snippet Import', 'insert-headers-and-footers' ); ?></h3>
|
130 |
+
<p><?php esc_html_e( 'Select a WPCode export file', 'insert-headers-and-footers' ); ?></p>
|
131 |
+
|
132 |
+
<form method="post" enctype="multipart/form-data" action="<?php echo esc_url( $this->get_page_action_url() ); ?>">
|
133 |
+
<div class="wpcode-file-upload">
|
134 |
+
<input type="file" name="file" id="wpcode-tools-snippets-import" class="inputfile" data-multiple-caption="{count} files selected" accept=".json">
|
135 |
+
<label for="wpcode-tools-snippets-import">
|
136 |
+
<span class="wpcode-file-field"><span class="placeholder"><?php esc_html_e( 'No file chosen', 'insert-headers-and-footers' ); ?></span></span>
|
137 |
+
<strong class="wpcode-button wpcode-button-secondary wpcode-button-icon">
|
138 |
+
<?php
|
139 |
+
wpcode_icon( 'upload', 12, 12 );
|
140 |
+
esc_html_e( 'Choose a file…', 'insert-headers-and-footers' );
|
141 |
+
?>
|
142 |
+
</strong>
|
143 |
+
</label>
|
144 |
+
</div>
|
145 |
+
<br>
|
146 |
+
<input type="hidden" name="action" value="import_snippets">
|
147 |
+
<?php wp_nonce_field( $this->action, $this->nonce_name ); ?>
|
148 |
+
<button name="submit-import" class="wpcode-button">
|
149 |
+
<?php esc_html_e( 'Import', 'insert-headers-and-footers' ); ?>
|
150 |
+
</button>
|
151 |
+
</form>
|
152 |
+
</div>
|
153 |
+
<hr/>
|
154 |
+
<div class="wpcode-setting-row wpcode-tools">
|
155 |
+
<h3><?php esc_html_e( 'Import from Other Code Plugins', 'insert-headers-and-footers' ); ?></h3>
|
156 |
+
<p><?php esc_html_e( 'WPCode makes it easy for you to switch by allowing you import your third-party snippet plugins with a single click.', 'insert-headers-and-footers' ); ?></p>
|
157 |
+
<form action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>">
|
158 |
+
<select name="provider" id="wpcode-plugins-importer" required>
|
159 |
+
<option value=""><?php esc_html_e( 'Select previous Code plugin', 'insert-headers-and-footers' ); ?></option>
|
160 |
+
<?php
|
161 |
+
foreach ( $this->get_importers() as $importer ) {
|
162 |
+
$status = '';
|
163 |
+
|
164 |
+
if ( empty( $importer['installed'] ) ) {
|
165 |
+
$status = esc_html__( 'Not Installed', 'insert-headers-and-footers' );
|
166 |
+
} elseif ( empty( $importer['active'] ) ) {
|
167 |
+
$status = esc_html__( 'Not Active', 'insert-headers-and-footers' );
|
168 |
+
}
|
169 |
+
printf(
|
170 |
+
'<option value="%s" %s>%s %s</option>',
|
171 |
+
esc_attr( $importer['slug'] ),
|
172 |
+
! empty( $status ) ? 'disabled' : '',
|
173 |
+
esc_html( $importer['name'] ),
|
174 |
+
! empty( $status ) ? '(' . esc_html( $status ) . ')' : '' //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
175 |
+
);
|
176 |
+
}
|
177 |
+
?>
|
178 |
+
</select>
|
179 |
+
<input type="hidden" name="view" value="importer"/>
|
180 |
+
<input type="hidden" name="page" value="<?php echo esc_attr( $this->page_slug ); ?>"/>
|
181 |
+
<br/>
|
182 |
+
<button class="wpcode-button"><?php esc_html_e( 'Import', 'insert-headers-and-footers' ); ?></button>
|
183 |
+
</form>
|
184 |
+
</div>
|
185 |
+
<hr/>
|
186 |
+
<?php
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* The export view.
|
191 |
+
*
|
192 |
+
* @return void
|
193 |
+
*/
|
194 |
+
public function output_view_export() {
|
195 |
+
?>
|
196 |
+
<div class="wpcode-setting-row wpcode-tools">
|
197 |
+
<h3><?php esc_html_e( 'Export Code Snippets', 'insert-headers-and-footers' ); ?></h3>
|
198 |
+
<form action="<?php echo esc_url( $this->get_page_action_url() ); ?>" method="post">
|
199 |
+
<?php
|
200 |
+
$this->metabox_row(
|
201 |
+
__( 'Status', 'insert-headers-and-footers' ),
|
202 |
+
$this->get_status_dropdown(),
|
203 |
+
'wpcode_export_status'
|
204 |
+
);
|
205 |
+
$this->metabox_row(
|
206 |
+
__( 'Code type', 'insert-headers-and-footers' ),
|
207 |
+
$this->get_code_type_checkboxes(),
|
208 |
+
'wpcode_export_code_type'
|
209 |
+
);
|
210 |
+
$this->metabox_row(
|
211 |
+
__( 'Tags', 'insert-headers-and-footers' ),
|
212 |
+
$this->get_tags_checkboxes(),
|
213 |
+
'wpcode_export_tags'
|
214 |
+
);
|
215 |
+
|
216 |
+
wp_nonce_field( $this->action, $this->nonce_name );
|
217 |
+
?>
|
218 |
+
<button type="submit" name="wpcode-export-snippets" class="wpcode-button"><?php esc_html_e( 'Export Snippets', 'insert-headers-and-footers' ); ?></button>
|
219 |
+
</form>
|
220 |
+
</div>
|
221 |
+
<?php
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* The System Info view.
|
226 |
+
*
|
227 |
+
* @return void
|
228 |
+
*/
|
229 |
+
public function output_view_info() {
|
230 |
+
?>
|
231 |
+
<div class="wpcode-setting-row">
|
232 |
+
<h3><?php esc_html_e( 'System Information', 'insert-headers-and-footers' ); ?></h3>
|
233 |
+
<textarea class="info-area" readonly><?php echo esc_textarea( $this->get_system_info() ); ?></textarea>
|
234 |
+
</div>
|
235 |
+
<hr/>
|
236 |
+
<div class="wpcode-setting-row">
|
237 |
+
<h3 id="ssl-verify"><?php esc_html_e( 'Test SSL Connections', 'insert-headers-and-footers' ); ?></h3>
|
238 |
+
<p><?php esc_html_e( 'Click the button below to verify your web server can perform SSL connections successfully.', 'insert-headers-and-footers' ); ?></p>
|
239 |
+
<button type="button" id="wpcode-ssl-verify" class="wpcode-button">
|
240 |
+
<?php esc_html_e( 'Test Connection', 'insert-headers-and-footers' ); ?>
|
241 |
+
</button>
|
242 |
+
</div>
|
243 |
+
<?php
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Importer view (from other plugins).
|
248 |
+
*
|
249 |
+
* @return void
|
250 |
+
*/
|
251 |
+
public function output_view_importer() {
|
252 |
+
$provider = ! empty( $_GET['provider'] ) ? sanitize_text_field( wp_unslash( $_GET['provider'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
253 |
+
|
254 |
+
$importers = wpcode()->importers->importers;
|
255 |
+
$snippets = array();
|
256 |
+
$provider_name = '';
|
257 |
+
if ( isset( $importers[ $provider ] ) ) {
|
258 |
+
$snippets = $importers[ $provider ]->get_snippets();
|
259 |
+
$provider_name = $importers[ $provider ]->name;
|
260 |
+
}
|
261 |
+
|
262 |
+
?>
|
263 |
+
<h2><?php esc_html_e( 'Snippets import', 'insert-headers-and-footers' ); ?></h2>
|
264 |
+
<hr/>
|
265 |
+
<div id="wpcode-importer-snippets">
|
266 |
+
<div class="wpcode-setting-row wpcode-tools">
|
267 |
+
<p><?php esc_html_e( 'Select the Snippets you would like to import.', 'insert-headers-and-footers' ); ?></p>
|
268 |
+
|
269 |
+
<div class="wpcode-checkbox-multiselect-columns">
|
270 |
+
<div class="first-column">
|
271 |
+
<h5 class="header"><?php esc_html_e( 'Available Snippets', 'insert-headers-and-footers' ); ?></h5>
|
272 |
+
|
273 |
+
<ul>
|
274 |
+
<?php
|
275 |
+
if ( empty( $snippets ) ) {
|
276 |
+
echo '<li>' . esc_html__( 'No snippets found.', 'insert-headers-and-footers' ) . '</li>';
|
277 |
+
} else {
|
278 |
+
foreach ( $snippets as $id => $snippet ) {
|
279 |
+
printf(
|
280 |
+
'<li><label><input type="checkbox" name="snippets[]" value="%s">%s</label></li>',
|
281 |
+
esc_attr( $id ),
|
282 |
+
esc_attr( sanitize_text_field( $snippet ) )
|
283 |
+
);
|
284 |
+
}
|
285 |
+
}
|
286 |
+
?>
|
287 |
+
</ul>
|
288 |
+
|
289 |
+
<?php if ( ! empty( $snippets ) ) : ?>
|
290 |
+
<a href="#" class="all"><?php esc_html_e( 'Select All', 'insert-headers-and-footers' ); ?></a>
|
291 |
+
<?php endif; ?>
|
292 |
+
|
293 |
+
</div>
|
294 |
+
<div class="second-column">
|
295 |
+
<h5 class="header"><?php esc_html_e( 'Snippets to Import', 'insert-headers-and-footers' ); ?></h5>
|
296 |
+
<ul></ul>
|
297 |
+
</div>
|
298 |
+
</div>
|
299 |
+
</div>
|
300 |
+
|
301 |
+
<?php if ( ! empty( $snippets ) ) : ?>
|
302 |
+
<p class="submit">
|
303 |
+
<input type="hidden" value="<?php echo esc_attr( $provider ); ?>" id="wpcode-importer-provider"/>
|
304 |
+
<button class="wpcode-button" id="wpcode-importer-snippets-submit"><?php esc_html_e( 'Import', 'insert-headers-and-footers' ); ?></button>
|
305 |
+
</p>
|
306 |
+
<?php endif; ?>
|
307 |
+
</div>
|
308 |
+
<div id="wpcode-importer-process">
|
309 |
+
|
310 |
+
<p class="process-count">
|
311 |
+
<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>
|
312 |
+
<?php
|
313 |
+
printf(
|
314 |
+
wp_kses(
|
315 |
+
// Translators: These add markup to display which snippet out of the total from the provider name.
|
316 |
+
__( 'Importing %1$s of %2$s snippets from %3$s.', 'insert-headers-and-footers' ),
|
317 |
+
array(
|
318 |
+
'span' => array(
|
319 |
+
'class' => array(),
|
320 |
+
),
|
321 |
+
)
|
322 |
+
),
|
323 |
+
'<span class="snippet-current">1</span>',
|
324 |
+
'<span class="snippet-total">0</span>',
|
325 |
+
esc_html( $provider_name )
|
326 |
+
);
|
327 |
+
?>
|
328 |
+
</p>
|
329 |
+
<p class="process-completed">
|
330 |
+
<?php
|
331 |
+
printf(
|
332 |
+
wp_kses(
|
333 |
+
// Translators: this adds the total snippets count that have been completed.
|
334 |
+
__( 'Congrats, the import process has finished! We have successfully imported %s snippets. You can review the results below.', 'insert-headers-and-footers' ),
|
335 |
+
array(
|
336 |
+
'span' => array(
|
337 |
+
'class' => array(),
|
338 |
+
),
|
339 |
+
)
|
340 |
+
),
|
341 |
+
'<span class="snippets-completed"></span>'
|
342 |
+
);
|
343 |
+
?>
|
344 |
+
</p>
|
345 |
+
<div class="status"></div>
|
346 |
+
</div>
|
347 |
+
<?php
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Get a dropdown with the status options.
|
352 |
+
*
|
353 |
+
* @return string
|
354 |
+
*/
|
355 |
+
public function get_status_dropdown() {
|
356 |
+
$options = array(
|
357 |
+
'all' => __( 'All', 'insert-headers-and-footers' ),
|
358 |
+
'publish' => __( 'Active', 'insert-headers-and-footers' ),
|
359 |
+
'draft' => __( 'Inactive', 'insert-headers-and-footers' ),
|
360 |
+
);
|
361 |
+
|
362 |
+
$select = '<select name="wpcode_export_status" id="wpcode_export_status">';
|
363 |
+
foreach ( $options as $value => $label ) {
|
364 |
+
$select .= sprintf(
|
365 |
+
'<option value="%1$s">%2$s</option>',
|
366 |
+
esc_attr( $value ),
|
367 |
+
esc_html( $label )
|
368 |
+
);
|
369 |
+
}
|
370 |
+
$select .= '</select>';
|
371 |
+
|
372 |
+
return $select;
|
373 |
+
}
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Get all the tags in a checkbox list.
|
377 |
+
*
|
378 |
+
* @return string
|
379 |
+
*/
|
380 |
+
public function get_code_type_checkboxes() {
|
381 |
+
$labels = wpcode()->execute->get_options();
|
382 |
+
$tags = get_terms(
|
383 |
+
array(
|
384 |
+
'taxonomy' => 'wpcode_type',
|
385 |
+
'count' => true,
|
386 |
+
)
|
387 |
+
);
|
388 |
+
$options = array();
|
389 |
+
|
390 |
+
if ( empty( $tags ) ) {
|
391 |
+
return __( 'No snippets available to export.', 'insert-headers-and-footers' );
|
392 |
+
}
|
393 |
+
|
394 |
+
foreach ( $tags as $tag ) {
|
395 |
+
$label = isset( $labels[ $tag->slug ] ) ? $labels[ $tag->slug ] : $tag->name;
|
396 |
+
$options[ $tag->term_id ] = $label . ' (' . $tag->count . ')';
|
397 |
+
}
|
398 |
+
|
399 |
+
return $this->get_checkboxes_list( $options, 'wpcode_export_code_type' );
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Get all the tags in a checkbox list.
|
404 |
+
*
|
405 |
+
* @return string
|
406 |
+
*/
|
407 |
+
public function get_tags_checkboxes() {
|
408 |
+
$tags = get_terms(
|
409 |
+
array(
|
410 |
+
'taxonomy' => 'wpcode_tags',
|
411 |
+
'count' => true,
|
412 |
+
)
|
413 |
+
);
|
414 |
+
|
415 |
+
if ( empty( $tags ) ) {
|
416 |
+
return __( 'No tags available.', 'insert-headers-and-footers' );
|
417 |
+
}
|
418 |
+
|
419 |
+
$options = array();
|
420 |
+
foreach ( $tags as $tag ) {
|
421 |
+
$options[ $tag->term_id ] = $tag->name . ' (' . $tag->count . ')';
|
422 |
+
}
|
423 |
+
|
424 |
+
return $this->get_checkboxes_list( $options, 'wpcode_export_tags' );
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Get a list of checkboxes from a key=>value array.
|
429 |
+
*
|
430 |
+
* @param array $options The options to display as checkboxes.
|
431 |
+
* @param string $name The name used for the input name attribute.
|
432 |
+
*
|
433 |
+
* @return string
|
434 |
+
*/
|
435 |
+
public function get_checkboxes_list( $options, $name ) {
|
436 |
+
$checkboxes = '<div class="wpcode-checkboxes-list">';
|
437 |
+
foreach ( $options as $value => $label ) {
|
438 |
+
$checkboxes .= sprintf(
|
439 |
+
'<label><input type="checkbox" name="%1$s[]" value="%2$s" />%3$s</label>',
|
440 |
+
$name,
|
441 |
+
$value,
|
442 |
+
$label
|
443 |
+
);
|
444 |
+
}
|
445 |
+
$checkboxes .= '</div>';
|
446 |
+
|
447 |
+
return $checkboxes;
|
448 |
+
}
|
449 |
+
|
450 |
+
/**
|
451 |
+
* For this page we output a menu.
|
452 |
+
*
|
453 |
+
* @return void
|
454 |
+
*/
|
455 |
+
public function output_header_bottom() {
|
456 |
+
?>
|
457 |
+
<ul class="wpcode-admin-tabs">
|
458 |
+
<?php
|
459 |
+
foreach ( $this->views as $slug => $label ) {
|
460 |
+
if ( 'importer' === $slug ) {
|
461 |
+
continue;
|
462 |
+
}
|
463 |
+
$class = $this->view === $slug ? 'active' : '';
|
464 |
+
?>
|
465 |
+
<li>
|
466 |
+
<a href="<?php echo esc_url( $this->get_view_link( $slug ) ); ?>" class="<?php echo esc_attr( $class ); ?>"><?php echo esc_html( $label ); ?></a>
|
467 |
+
</li>
|
468 |
+
<?php } ?>
|
469 |
+
</ul>
|
470 |
+
<?php
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Setup page-specific views.
|
475 |
+
*
|
476 |
+
* @return void
|
477 |
+
*/
|
478 |
+
protected function setup_views() {
|
479 |
+
$this->views = array(
|
480 |
+
'import' => __( 'Import', 'insert-headers-and-footers' ),
|
481 |
+
'export' => __( 'Export', 'insert-headers-and-footers' ),
|
482 |
+
'info' => __( 'System Info', 'insert-headers-and-footers' ),
|
483 |
+
'importer' => __( 'Importer', 'insert-headers-and-footers' ),
|
484 |
+
);
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* If the form is submitted attempt to save the values.
|
489 |
+
*
|
490 |
+
* @return void
|
491 |
+
*/
|
492 |
+
public function submit_listener() {
|
493 |
+
if ( ! isset( $_REQUEST[ $this->nonce_name ] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST[ $this->nonce_name ] ), $this->action ) ) {
|
494 |
+
// Nonce is missing, so we're not even going to try.
|
495 |
+
return;
|
496 |
+
}
|
497 |
+
|
498 |
+
if ( isset( $_REQUEST['wpcode-export-snippets'] ) ) {
|
499 |
+
$this->handle_export();
|
500 |
+
}
|
501 |
+
|
502 |
+
if ( ! isset( $_REQUEST['action'] ) ) {
|
503 |
+
return;
|
504 |
+
}
|
505 |
+
|
506 |
+
$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
|
507 |
+
if ( 'import_snippets' === $action ) {
|
508 |
+
$this->handle_import_file();
|
509 |
+
}
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Process export form and download a JSON file.
|
514 |
+
*
|
515 |
+
* @return void
|
516 |
+
*/
|
517 |
+
public function handle_export() {
|
518 |
+
// Already verified nonce in parent method @see submit_listener.
|
519 |
+
// phpcs:disable WordPress.Security.NonceVerification
|
520 |
+
$status = isset( $_POST['wpcode_export_status'] ) ? sanitize_text_field( wp_unslash( $_POST['wpcode_export_status'] ) ) : 'all';
|
521 |
+
$code_types = isset( $_POST['wpcode_export_code_type'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['wpcode_export_code_type'] ) ) : array();
|
522 |
+
$tags = isset( $_POST['wpcode_export_tags'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['wpcode_export_tags'] ) ) : array();
|
523 |
+
if ( 'all' === $status ) {
|
524 |
+
$status = array(
|
525 |
+
'publish',
|
526 |
+
'draft',
|
527 |
+
);
|
528 |
+
}
|
529 |
+
$tax_query = array();
|
530 |
+
|
531 |
+
if ( ! empty( $code_types ) ) {
|
532 |
+
$tax_query[] = array(
|
533 |
+
'taxonomy' => 'wpcode_type',
|
534 |
+
'terms' => $code_types,
|
535 |
+
);
|
536 |
+
}
|
537 |
+
if ( ! empty( $tags ) ) {
|
538 |
+
$tax_query[] = array(
|
539 |
+
'taxonomy' => 'wpcode_tags',
|
540 |
+
'terms' => $tags,
|
541 |
+
);
|
542 |
+
}
|
543 |
+
|
544 |
+
$query_args = array(
|
545 |
+
'post_type' => 'wpcode',
|
546 |
+
'post_status' => $status,
|
547 |
+
'nopaging' => true,
|
548 |
+
);
|
549 |
+
if ( ! empty( $tax_query ) ) {
|
550 |
+
$query_args['tax_query'] = $tax_query; // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
|
551 |
+
}
|
552 |
+
$export = array();
|
553 |
+
$snippets = get_posts( $query_args );
|
554 |
+
|
555 |
+
foreach ( $snippets as $snippet ) {
|
556 |
+
$snippet = new WPCode_Snippet( $snippet );
|
557 |
+
$snippet_data = $snippet->get_data_for_caching();
|
558 |
+
$snippet_data['tags'] = $snippet->get_tags();
|
559 |
+
$snippet_data['note'] = $snippet->get_note();
|
560 |
+
$export[] = $snippet_data;
|
561 |
+
}
|
562 |
+
|
563 |
+
ignore_user_abort( true );
|
564 |
+
|
565 |
+
nocache_headers();
|
566 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
567 |
+
header( 'Content-Disposition: attachment; filename=wpcode-snippets-export-' . current_time( 'Y-m-d' ) . '.json' );
|
568 |
+
header( 'Expires: 0' );
|
569 |
+
|
570 |
+
echo wp_json_encode( $export );
|
571 |
+
exit;
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Process import file.
|
576 |
+
*
|
577 |
+
* @return void
|
578 |
+
*/
|
579 |
+
public function handle_import_file() {
|
580 |
+
|
581 |
+
$ext = '';
|
582 |
+
|
583 |
+
if ( isset( $_FILES['file']['name'] ) ) {
|
584 |
+
$ext = strtolower( pathinfo( sanitize_text_field( wp_unslash( $_FILES['file']['name'] ) ), PATHINFO_EXTENSION ) );
|
585 |
+
}
|
586 |
+
|
587 |
+
if ( 'json' !== $ext ) {
|
588 |
+
wp_die(
|
589 |
+
esc_html__( 'Please upload a valid .json snippets export file.', 'insert-headers-and-footers' ),
|
590 |
+
esc_html__( 'Error', 'insert-headers-and-footers' ),
|
591 |
+
array(
|
592 |
+
'response' => 400,
|
593 |
+
)
|
594 |
+
);
|
595 |
+
}
|
596 |
+
|
597 |
+
$tmp_name = isset( $_FILES['file']['tmp_name'] ) ? sanitize_text_field( $_FILES['file']['tmp_name'] ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- wp_unslash() breaks upload on Windows.
|
598 |
+
$snippets = json_decode( $this->remove_utf8_bom( file_get_contents( $tmp_name ) ), true ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
|
599 |
+
|
600 |
+
if ( empty( $snippets ) || ! is_array( $snippets ) ) {
|
601 |
+
wp_die(
|
602 |
+
esc_html__( 'Snippets data cannot be imported.', 'insert-headers-and-footers' ),
|
603 |
+
esc_html__( 'Error', 'insert-headers-and-footers' ),
|
604 |
+
array(
|
605 |
+
'response' => 400,
|
606 |
+
)
|
607 |
+
);
|
608 |
+
}
|
609 |
+
|
610 |
+
foreach ( $snippets as $snippet ) {
|
611 |
+
if ( empty( $snippet['code_type'] ) ) {
|
612 |
+
// Just a minimal check that we have some required fields.
|
613 |
+
continue;
|
614 |
+
}
|
615 |
+
if ( isset( $snippet['id'] ) ) {
|
616 |
+
// We don't want to update existing snippets/posts.
|
617 |
+
unset( $snippet['id'] );
|
618 |
+
}
|
619 |
+
$new_snippet = new WPCode_Snippet( $snippet );
|
620 |
+
$new_snippet->save();
|
621 |
+
}
|
622 |
+
|
623 |
+
wp_safe_redirect(
|
624 |
+
add_query_arg( 'message', 1 )
|
625 |
+
);
|
626 |
+
exit;
|
627 |
+
}
|
628 |
+
|
629 |
+
/**
|
630 |
+
* Remove UTF-8 BOM signature if it is present.
|
631 |
+
*
|
632 |
+
* @param string $string String to process.
|
633 |
+
*
|
634 |
+
* @return string
|
635 |
+
*/
|
636 |
+
public function remove_utf8_bom( $string ) {
|
637 |
+
if ( strpos( bin2hex( $string ), 'efbbbf' ) === 0 ) {
|
638 |
+
$string = substr( $string, 3 );
|
639 |
+
}
|
640 |
+
|
641 |
+
return $string;
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* Templates used by the importer in JS.
|
646 |
+
*
|
647 |
+
* @return void
|
648 |
+
*/
|
649 |
+
public function importer_templates() {
|
650 |
+
?>
|
651 |
+
<script type="text/template" id="wpcode-importer-status-update">
|
652 |
+
<div class="item">
|
653 |
+
<div class="wpcode-clear">
|
654 |
+
<span class="name">
|
655 |
+
<?php wpcode_icon( 'check', 16, 13 ); ?>
|
656 |
+
<span></span>
|
657 |
+
</span>
|
658 |
+
<span class="actions">
|
659 |
+
<a href="" target="_blank"><?php esc_html_e( 'Edit', 'insert-headers-and-footers' ); ?></a>
|
660 |
+
</span>
|
661 |
+
</div>
|
662 |
+
</div>
|
663 |
+
</script>
|
664 |
+
<?php
|
665 |
+
}
|
666 |
+
|
667 |
+
/**
|
668 |
+
* Add tools-specific localization data.
|
669 |
+
*
|
670 |
+
* @param array $data Localization data.
|
671 |
+
*
|
672 |
+
* @return array
|
673 |
+
*/
|
674 |
+
public function add_tools_data( $data ) {
|
675 |
+
$data['testing'] = esc_html__( 'Testing', 'insert-headers-and-footers' );
|
676 |
+
|
677 |
+
return $data;
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Get system information.
|
682 |
+
*
|
683 |
+
* Based on a function from Easy Digital Downloads by Pippin Williamson.
|
684 |
+
*
|
685 |
+
* @link https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/admin/tools.php#L470
|
686 |
+
*
|
687 |
+
* @return string
|
688 |
+
*/
|
689 |
+
public function get_system_info() {
|
690 |
+
|
691 |
+
$data = '### Begin System Info ###' . "\n\n";
|
692 |
+
|
693 |
+
$data .= $this->site_info();
|
694 |
+
$data .= $this->wp_info();
|
695 |
+
$data .= $this->uploads_info();
|
696 |
+
$data .= $this->plugins_info();
|
697 |
+
$data .= $this->server_info();
|
698 |
+
|
699 |
+
$data .= "\n" . '### End System Info ###';
|
700 |
+
|
701 |
+
return $data;
|
702 |
+
}
|
703 |
+
|
704 |
+
/**
|
705 |
+
* Get Site info.
|
706 |
+
*
|
707 |
+
* @return string
|
708 |
+
*/
|
709 |
+
private function site_info() {
|
710 |
+
|
711 |
+
$data = "\n" . '-- Site Info' . "\n\n";
|
712 |
+
$data .= 'Site URL: ' . site_url() . "\n";
|
713 |
+
$data .= 'Home URL: ' . home_url() . "\n";
|
714 |
+
$data .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
|
715 |
+
|
716 |
+
return $data;
|
717 |
+
}
|
718 |
+
|
719 |
+
/**
|
720 |
+
* Get WordPress Configuration info.
|
721 |
+
*
|
722 |
+
* @return string
|
723 |
+
*/
|
724 |
+
private function wp_info() {
|
725 |
+
|
726 |
+
global $wpdb;
|
727 |
+
|
728 |
+
$theme_data = wp_get_theme();
|
729 |
+
$theme = $theme_data->name . ' ' . $theme_data->version;
|
730 |
+
|
731 |
+
$data = "\n" . '-- WordPress Configuration' . "\n\n";
|
732 |
+
$data .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
|
733 |
+
$data .= 'Language: ' . get_locale() . "\n";
|
734 |
+
$data .= 'User Language: ' . get_user_locale() . "\n";
|
735 |
+
$data .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
|
736 |
+
$data .= 'Active Theme: ' . $theme . "\n";
|
737 |
+
$data .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
|
738 |
+
|
739 |
+
// Only show page specs if front page is set to 'page'.
|
740 |
+
if ( get_option( 'show_on_front' ) === 'page' ) {
|
741 |
+
$front_page_id = get_option( 'page_on_front' );
|
742 |
+
$blog_page_id = get_option( 'page_for_posts' );
|
743 |
+
|
744 |
+
$data .= 'Page On Front: ' . ( $front_page_id ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
|
745 |
+
$data .= 'Page For Posts: ' . ( $blog_page_id ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
|
746 |
+
}
|
747 |
+
$data .= 'ABSPATH: ' . ABSPATH . "\n";
|
748 |
+
$data .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n"; //phpcs:ignore
|
749 |
+
$data .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
|
750 |
+
$data .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
|
751 |
+
$data .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
|
752 |
+
$data .= 'Revisions: ' . ( WP_POST_REVISIONS ? WP_POST_REVISIONS > 1 ? 'Limited to ' . WP_POST_REVISIONS : 'Enabled' : 'Disabled' ) . "\n";
|
753 |
+
|
754 |
+
return $data;
|
755 |
+
}
|
756 |
+
|
757 |
+
/**
|
758 |
+
* Get Uploads/Constants info.
|
759 |
+
*
|
760 |
+
* @return string
|
761 |
+
*/
|
762 |
+
private function uploads_info() {
|
763 |
+
|
764 |
+
$data = "\n" . '-- WordPress Uploads/Constants' . "\n\n";
|
765 |
+
$data .= 'WP_CONTENT_DIR: ' . ( defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR ? WP_CONTENT_DIR : 'Disabled' : 'Not set' ) . "\n";
|
766 |
+
$data .= 'WP_CONTENT_URL: ' . ( defined( 'WP_CONTENT_URL' ) ? WP_CONTENT_URL ? WP_CONTENT_URL : 'Disabled' : 'Not set' ) . "\n";
|
767 |
+
$data .= 'UPLOADS: ' . ( defined( 'UPLOADS' ) ? UPLOADS ? UPLOADS : 'Disabled' : 'Not set' ) . "\n";
|
768 |
+
|
769 |
+
$uploads_dir = wp_upload_dir();
|
770 |
+
|
771 |
+
$data .= 'wp_uploads_dir() path: ' . $uploads_dir['path'] . "\n";
|
772 |
+
$data .= 'wp_uploads_dir() url: ' . $uploads_dir['url'] . "\n";
|
773 |
+
$data .= 'wp_uploads_dir() basedir: ' . $uploads_dir['basedir'] . "\n";
|
774 |
+
$data .= 'wp_uploads_dir() baseurl: ' . $uploads_dir['baseurl'] . "\n";
|
775 |
+
|
776 |
+
return $data;
|
777 |
+
}
|
778 |
+
|
779 |
+
/**
|
780 |
+
* Get Plugins info.
|
781 |
+
*
|
782 |
+
* @return string
|
783 |
+
*/
|
784 |
+
private function plugins_info() {
|
785 |
+
|
786 |
+
// Get plugins that have an update.
|
787 |
+
$data = $this->mu_plugins();
|
788 |
+
|
789 |
+
$data .= $this->installed_plugins();
|
790 |
+
$data .= $this->multisite_plugins();
|
791 |
+
|
792 |
+
return $data;
|
793 |
+
}
|
794 |
+
|
795 |
+
/**
|
796 |
+
* Get MU Plugins info.
|
797 |
+
*
|
798 |
+
* @return string
|
799 |
+
*/
|
800 |
+
private function mu_plugins() {
|
801 |
+
|
802 |
+
$data = '';
|
803 |
+
|
804 |
+
// Must-use plugins.
|
805 |
+
// NOTE: MU plugins can't show updates!
|
806 |
+
$muplugins = get_mu_plugins();
|
807 |
+
|
808 |
+
if ( ! empty( $muplugins ) && count( $muplugins ) > 0 ) {
|
809 |
+
$data = "\n" . '-- Must-Use Plugins' . "\n\n";
|
810 |
+
|
811 |
+
foreach ( $muplugins as $plugin => $plugin_data ) {
|
812 |
+
$data .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
|
813 |
+
}
|
814 |
+
}
|
815 |
+
|
816 |
+
return $data;
|
817 |
+
}
|
818 |
+
|
819 |
+
/**
|
820 |
+
* Get Installed Plugins info.
|
821 |
+
*
|
822 |
+
* @return string
|
823 |
+
*/
|
824 |
+
private function installed_plugins() {
|
825 |
+
|
826 |
+
$updates = get_plugin_updates();
|
827 |
+
|
828 |
+
// WordPress active plugins.
|
829 |
+
$data = "\n" . '-- WordPress Active Plugins' . "\n\n";
|
830 |
+
|
831 |
+
$plugins = get_plugins();
|
832 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
833 |
+
|
834 |
+
foreach ( $plugins as $plugin_path => $plugin ) {
|
835 |
+
if ( ! in_array( $plugin_path, $active_plugins, true ) ) {
|
836 |
+
continue;
|
837 |
+
}
|
838 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
|
839 |
+
$data .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
840 |
+
}
|
841 |
+
|
842 |
+
// WordPress inactive plugins.
|
843 |
+
$data .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
|
844 |
+
|
845 |
+
foreach ( $plugins as $plugin_path => $plugin ) {
|
846 |
+
if ( in_array( $plugin_path, $active_plugins, true ) ) {
|
847 |
+
continue;
|
848 |
+
}
|
849 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
|
850 |
+
$data .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
851 |
+
}
|
852 |
+
|
853 |
+
return $data;
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Get Multisite Plugins info.
|
858 |
+
*
|
859 |
+
* @return string
|
860 |
+
*/
|
861 |
+
private function multisite_plugins() {
|
862 |
+
|
863 |
+
$data = '';
|
864 |
+
|
865 |
+
if ( ! is_multisite() ) {
|
866 |
+
return $data;
|
867 |
+
}
|
868 |
+
|
869 |
+
$updates = get_plugin_updates();
|
870 |
+
|
871 |
+
// WordPress Multisite active plugins.
|
872 |
+
$data = "\n" . '-- Network Active Plugins' . "\n\n";
|
873 |
+
|
874 |
+
$plugins = wp_get_active_network_plugins();
|
875 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
876 |
+
|
877 |
+
foreach ( $plugins as $plugin_path ) {
|
878 |
+
$plugin_base = plugin_basename( $plugin_path );
|
879 |
+
|
880 |
+
if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
|
881 |
+
continue;
|
882 |
+
}
|
883 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
|
884 |
+
$plugin = get_plugin_data( $plugin_path );
|
885 |
+
$data .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
886 |
+
}
|
887 |
+
|
888 |
+
return $data;
|
889 |
+
}
|
890 |
+
|
891 |
+
/**
|
892 |
+
* Get Server info.
|
893 |
+
*
|
894 |
+
* @return string
|
895 |
+
*/
|
896 |
+
private function server_info() {
|
897 |
+
|
898 |
+
global $wpdb;
|
899 |
+
|
900 |
+
// Server configuration (really just versions).
|
901 |
+
$data = "\n" . '-- Webserver Configuration' . "\n\n";
|
902 |
+
$data .= 'PHP Version: ' . PHP_VERSION . "\n";
|
903 |
+
$data .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
|
904 |
+
$data .= 'Webserver Info: ' . ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '' ) . "\n";
|
905 |
+
|
906 |
+
// PHP configs... now we're getting to the important stuff.
|
907 |
+
$data .= "\n" . '-- PHP Configuration' . "\n\n";
|
908 |
+
$data .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
|
909 |
+
$data .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
910 |
+
$data .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
|
911 |
+
$data .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
912 |
+
$data .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
|
913 |
+
$data .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
|
914 |
+
$data .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
|
915 |
+
|
916 |
+
// PHP extensions and such.
|
917 |
+
$data .= "\n" . '-- PHP Extensions' . "\n\n";
|
918 |
+
$data .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
919 |
+
$data .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
920 |
+
$data .= 'SOAP Client: ' . ( class_exists( 'SoapClient', false ) ? 'Installed' : 'Not Installed' ) . "\n";
|
921 |
+
$data .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
922 |
+
|
923 |
+
// Session stuff.
|
924 |
+
$data .= "\n" . '-- Session Configuration' . "\n\n";
|
925 |
+
$data .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n";
|
926 |
+
|
927 |
+
// The rest of this is only relevant if session is enabled.
|
928 |
+
if ( isset( $_SESSION ) ) {
|
929 |
+
$data .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n";
|
930 |
+
$data .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
|
931 |
+
$data .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
|
932 |
+
$data .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
|
933 |
+
$data .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
|
934 |
+
}
|
935 |
+
|
936 |
+
return $data;
|
937 |
+
}
|
938 |
+
}
|
includes/admin/pages/class-wpcode-admin-page.php
ADDED
@@ -0,0 +1,930 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin pages abstract class.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Admin_Page
|
10 |
+
*/
|
11 |
+
abstract class WPCode_Admin_Page {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The page slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $page_slug = '';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The page title.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
public $page_title = '';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The menu title, defaults to the page title.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
public $menu_title;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* If there's an error message, let's store it here.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
public $message_error;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* If there's a success message, store it here.
|
43 |
+
*
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $message_success;
|
47 |
+
/**
|
48 |
+
* The code type to be used by CodeMirror.
|
49 |
+
*
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
public $code_type = 'html';
|
53 |
+
/**
|
54 |
+
* Whether the current user can edit the code on the current page.
|
55 |
+
*
|
56 |
+
* @var bool
|
57 |
+
*/
|
58 |
+
protected $can_edit = false;
|
59 |
+
/**
|
60 |
+
* If true, the snippet library is shown, otherwise, we display
|
61 |
+
* the snippet editor.
|
62 |
+
*
|
63 |
+
* @var bool
|
64 |
+
*/
|
65 |
+
protected $show_library = false;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* The current view.
|
69 |
+
*
|
70 |
+
* @var string
|
71 |
+
*/
|
72 |
+
public $view = '';
|
73 |
+
|
74 |
+
/**
|
75 |
+
* The available views for this page.
|
76 |
+
*
|
77 |
+
* @var array
|
78 |
+
*/
|
79 |
+
public $views = array();
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Constructor.
|
83 |
+
*/
|
84 |
+
public function __construct() {
|
85 |
+
if ( ! isset( $this->menu_title ) ) {
|
86 |
+
$this->menu_title = $this->page_title;
|
87 |
+
}
|
88 |
+
|
89 |
+
$this->hooks();
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Add hooks to register the page and output content.
|
94 |
+
*
|
95 |
+
* @return void
|
96 |
+
*/
|
97 |
+
public function hooks() {
|
98 |
+
add_action( 'admin_menu', array( $this, 'add_page' ) );
|
99 |
+
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
100 |
+
// Only load if we are actually on the desired page.
|
101 |
+
if ( $this->page_slug !== $page ) {
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
add_action( 'wpcode_admin_page', array( $this, 'output' ) );
|
105 |
+
add_action( 'wpcode_admin_page', array( $this, 'output_footer' ) );
|
106 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'page_scripts' ) );
|
107 |
+
add_filter( 'admin_body_class', array( $this, 'page_specific_body_class' ) );
|
108 |
+
add_filter( 'wpcode_admin_js_data', array( $this, 'maybe_add_library_data' ) );
|
109 |
+
|
110 |
+
$this->setup_views();
|
111 |
+
$this->set_current_view();
|
112 |
+
$this->page_hooks();
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Override in child class to define page-specific hooks that will run only
|
117 |
+
* after checks have been passed.
|
118 |
+
*
|
119 |
+
* @return void
|
120 |
+
*/
|
121 |
+
public function page_hooks() {
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Add the submenu page.
|
127 |
+
*
|
128 |
+
* @return void
|
129 |
+
*/
|
130 |
+
public function add_page() {
|
131 |
+
add_submenu_page( 'wpcode', $this->page_title, $this->menu_title, 'wpcode_edit_snippets', $this->page_slug, 'wpcode_admin_menu_page' );
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* If the page has views, this is where you should assign them to $this->views.
|
136 |
+
*
|
137 |
+
* @return void
|
138 |
+
*/
|
139 |
+
protected function setup_views() {
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Set the current view from the query param also checking it's a registered view for this page.
|
145 |
+
*
|
146 |
+
* @return void
|
147 |
+
*/
|
148 |
+
protected function set_current_view() {
|
149 |
+
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
150 |
+
if ( ! isset( $_GET['view'] ) ) {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
$view = sanitize_text_field( wp_unslash( $_GET['view'] ) );
|
154 |
+
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
155 |
+
if ( array_key_exists( $view, $this->views ) ) {
|
156 |
+
$this->view = $view;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Output the page content.
|
162 |
+
*
|
163 |
+
* @return void
|
164 |
+
*/
|
165 |
+
public function output() {
|
166 |
+
$this->output_header();
|
167 |
+
?>
|
168 |
+
<div class="wpcode-content">
|
169 |
+
<?php
|
170 |
+
$this->output_content();
|
171 |
+
do_action( "wpcode_admin_page_content_{$this->page_slug}", $this );
|
172 |
+
?>
|
173 |
+
</div>
|
174 |
+
<?php
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Output of the header markup for admin pages.
|
179 |
+
*
|
180 |
+
* @return void
|
181 |
+
*/
|
182 |
+
public function output_header() {
|
183 |
+
?>
|
184 |
+
<div class="wpcode-header">
|
185 |
+
<div class="wpcode-header-top">
|
186 |
+
<div class="wpcode-header-left">
|
187 |
+
<?php $this->output_header_left(); ?>
|
188 |
+
</div>
|
189 |
+
<div class="wpcode-header-right">
|
190 |
+
<?php $this->output_header_right(); ?>
|
191 |
+
</div>
|
192 |
+
</div>
|
193 |
+
<div class="wpcode-header-bottom">
|
194 |
+
<?php $this->output_header_bottom(); ?>
|
195 |
+
</div>
|
196 |
+
</div>
|
197 |
+
<?php $this->maybe_output_message(); ?>
|
198 |
+
<?php
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Output footer markup, mostly used for overlays that are fixed.
|
203 |
+
*
|
204 |
+
* @return void
|
205 |
+
*/
|
206 |
+
public function output_footer() {
|
207 |
+
?>
|
208 |
+
<div class="wpcode-modal-overlay"></div>
|
209 |
+
<div class="wpcode-notifications-overlay"></div>
|
210 |
+
<div class="wpcode-docs-overlay" id="wpcode-docs-overlay">
|
211 |
+
<?php $this->logo_image( 'wpcode-help-logo' ); ?>
|
212 |
+
<button id="wpcode-help-close" class="wpcode-button-just-icon" type="button">
|
213 |
+
<?php wpcode_icon( 'close', 19, 19 ); ?>
|
214 |
+
</button>
|
215 |
+
<div class="wpcode-docs-content">
|
216 |
+
<div id="wpcode-help-search" class="wpcode-search-empty">
|
217 |
+
<label>
|
218 |
+
<span class="screen-reader-text"><?php esc_html_e( 'Search docs', 'insert-headers-and-footers' ); ?></span>
|
219 |
+
<?php wpcode_icon( 'search' ); ?>
|
220 |
+
<input type="text" class="wpcode-input-text"/>
|
221 |
+
</label>
|
222 |
+
<div id="wpcode-help-search-clear" title="<?php esc_attr_e( 'Clear', 'insert-headers-and-footers' ); ?>">
|
223 |
+
<?php wpcode_icon( 'close', 14, 14 ); ?>
|
224 |
+
</div>
|
225 |
+
</div>
|
226 |
+
<div id="wpcode-help-no-result" style="display: none;">
|
227 |
+
<ul class="wpcode-help-docs">
|
228 |
+
<li>
|
229 |
+
<span><?php esc_html_e( 'No docs found', 'insert-headers-and-footers' ); ?></span>
|
230 |
+
</li>
|
231 |
+
</ul>
|
232 |
+
</div>
|
233 |
+
<div id="wpcode-help-result">
|
234 |
+
<ul class="wpcode-help-docs"></ul>
|
235 |
+
</div>
|
236 |
+
<?php
|
237 |
+
$docs = new WPCode_Docs();
|
238 |
+
$docs->get_categories_accordion();
|
239 |
+
?>
|
240 |
+
<div class="wpcode-help-footer">
|
241 |
+
<div class="wpcode-help-footer-box">
|
242 |
+
<?php wpcode_icon( 'file', 48, 48 ); ?>
|
243 |
+
<h3><?php esc_html_e( 'View Documentation', 'insert-headers-and-footers' ); ?></h3>
|
244 |
+
<p><?php esc_html_e( 'Browse documentation, reference material, and tutorials for WPCode.', 'insert-headers-and-footers' ); ?></p>
|
245 |
+
<a class="wpcode-button wpcode-button-secondary" href="<?php echo esc_url( wpcode_utm_url( 'https://wpcode.com/docs', 'docs', 'footer' ) ); ?>" target="_blank"><?php esc_html_e( 'View All Documentation', 'insert-headers-and-footers' ); ?></a>
|
246 |
+
</div>
|
247 |
+
<div class="wpcode-help-footer-box">
|
248 |
+
<?php wpcode_icon( 'support', 48, 48 ); ?>
|
249 |
+
<h3><?php esc_html_e( 'Get Support', 'insert-headers-and-footers' ); ?></h3>
|
250 |
+
<p><?php esc_html_e( 'Submit a ticket and our world class support team will be in touch soon.', 'insert-headers-and-footers' ); ?></p>
|
251 |
+
<a class="wpcode-button wpcode-button-secondary" href="https://wordpress.org/support/plugin/insert-headers-and-footers/" target="_blank"><?php esc_html_e( 'Submit a Support Ticket', 'insert-headers-and-footers' ); ?></a>
|
252 |
+
</div>
|
253 |
+
</div>
|
254 |
+
</div>
|
255 |
+
</div>
|
256 |
+
<div class="wpcode-notifications-drawer" id="wpcode-notifications-drawer">
|
257 |
+
<div class="wpcode-notifications-header">
|
258 |
+
<h3 id="wpcode-active-title">
|
259 |
+
<?php
|
260 |
+
printf(
|
261 |
+
wp_kses_post(
|
262 |
+
// Translators: Placeholder for the number of active notifications.
|
263 |
+
__( 'New Notifications (%s)', 'insert-headers-and-footers' )
|
264 |
+
),
|
265 |
+
'<span id="wpcode-notifications-count">' . absint( wpcode()->notifications->get_count() ) . '</span>'
|
266 |
+
);
|
267 |
+
?>
|
268 |
+
</h3>
|
269 |
+
<h3 id="wpcode-dismissed-title">
|
270 |
+
<?php
|
271 |
+
printf(
|
272 |
+
wp_kses_post(
|
273 |
+
// Translators: Placeholder for the number of dismissed notifications.
|
274 |
+
__( 'Notifications (%s)', 'insert-headers-and-footers' )
|
275 |
+
),
|
276 |
+
'<span id="wpcode-notifications-dismissed-count">' . absint( wpcode()->notifications->get_dismissed_count() ) . '</span>'
|
277 |
+
);
|
278 |
+
?>
|
279 |
+
</h3>
|
280 |
+
<button type="button" class="wpcode-button-text" id="wpcode-notifications-show-dismissed">
|
281 |
+
<?php esc_html_e( 'Dismissed Notifications', 'insert-headers-and-footers' ); ?>
|
282 |
+
</button>
|
283 |
+
<button type="button" class="wpcode-button-text" id="wpcode-notifications-show-active">
|
284 |
+
<?php esc_html_e( 'Active Notifications', 'insert-headers-and-footers' ); ?>
|
285 |
+
</button>
|
286 |
+
<button type="button" class="wpcode-just-icon-button wpcode-notifications-close"><?php wpcode_icon( 'close', 12, 12, '0 0 16 16' ); ?></button>
|
287 |
+
</div>
|
288 |
+
<div class="wpcode-notifications-list">
|
289 |
+
<ul class="wpcode-notifications-active">
|
290 |
+
<?php
|
291 |
+
$notifications = wpcode()->notifications->get_active_notifications();
|
292 |
+
foreach ( $notifications as $notification ) {
|
293 |
+
$this->get_notification_markup( $notification );
|
294 |
+
}
|
295 |
+
?>
|
296 |
+
</ul>
|
297 |
+
<ul class="wpcode-notifications-dismissed">
|
298 |
+
<?php
|
299 |
+
$notifications = wpcode()->notifications->get_dismissed_notifications();
|
300 |
+
foreach ( $notifications as $notification ) {
|
301 |
+
$this->get_notification_markup( $notification );
|
302 |
+
}
|
303 |
+
?>
|
304 |
+
</ul>
|
305 |
+
</div>
|
306 |
+
<div class="wpcode-notifications-footer">
|
307 |
+
<button type="button" class="wpcode-button-text wpcode-notification-dismiss" id="wpcode-dismiss-all" data-id="all"><?php esc_html_e( 'Dismiss all', 'insert-headers-and-footers' ); ?></button>
|
308 |
+
</div>
|
309 |
+
</div>
|
310 |
+
<?php
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Get the notification HTML markup for displaying in a list.
|
315 |
+
*
|
316 |
+
* @param array $notification The notification array.
|
317 |
+
*
|
318 |
+
* @return void
|
319 |
+
*/
|
320 |
+
public function get_notification_markup( $notification ) {
|
321 |
+
$type = ! empty( $notification['icon'] ) ? $notification['icon'] : 'info';
|
322 |
+
?>
|
323 |
+
<li>
|
324 |
+
<div class="wpcode-notification-icon"><?php wpcode_icon( $type, 18, 18 ); ?></div>
|
325 |
+
<div class="wpcode-notification-content">
|
326 |
+
<h4><?php echo esc_html( $notification['title'] ); ?></h4>
|
327 |
+
<p><?php echo wp_kses_post( $notification['content'] ); ?></p>
|
328 |
+
<p class="wpcode-start"><?php echo esc_html( $notification['start'] ); ?></p>
|
329 |
+
<div class="wpcode-notification-actions">
|
330 |
+
<?php
|
331 |
+
$main_button = ! empty( $notification['btns']['main'] ) ? $notification['btns']['main'] : false;
|
332 |
+
$alt_button = ! empty( $notification['btns']['alt'] ) ? $notification['btns']['alt'] : false;
|
333 |
+
if ( $main_button ) {
|
334 |
+
?>
|
335 |
+
<a href="<?php echo esc_url( $main_button['url'] ); ?>" class="wpcode-button wpcode-button-small" target="_blank">
|
336 |
+
<?php echo esc_html( $main_button['text'] ); ?>
|
337 |
+
</a>
|
338 |
+
<?php
|
339 |
+
}
|
340 |
+
if ( $alt_button ) {
|
341 |
+
?>
|
342 |
+
<a href="<?php echo esc_url( $alt_button['url'] ); ?>" class="wpcode-button wpcode-button-secondary wpcode-button-small" target="_blank">
|
343 |
+
<?php echo esc_html( $alt_button['text'] ); ?>
|
344 |
+
</a>
|
345 |
+
<?php
|
346 |
+
}
|
347 |
+
?>
|
348 |
+
<button type="button" class="wpcode-button-text wpcode-notification-dismiss" data-id="<?php echo esc_attr( $notification['id'] ); ?>"><?php esc_html_e( 'Dismiss', 'insert-headers-and-footers' ); ?></button>
|
349 |
+
</div>
|
350 |
+
</div>
|
351 |
+
</li>
|
352 |
+
<?php
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Left side of the header, usually just the logo in this area.
|
357 |
+
*
|
358 |
+
* @return void
|
359 |
+
*/
|
360 |
+
public function output_header_left() {
|
361 |
+
$this->logo_image();
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Logo image.
|
366 |
+
*
|
367 |
+
* @param string $id Id of the image.
|
368 |
+
*
|
369 |
+
* @return void
|
370 |
+
*/
|
371 |
+
public function logo_image( $id = 'wpcode-header-logo' ) {
|
372 |
+
$logo_src = WPCODE_PLUGIN_URL . 'admin/images/wpcode-logo.png';
|
373 |
+
// Translators: This simply adds the plugin name before the logo text.
|
374 |
+
$alt = sprintf( __( '%s logo', 'insert-headers-and-footers' ), 'WPCode' )
|
375 |
+
?>
|
376 |
+
<img src="<?php echo esc_url( $logo_src ); ?>" width="132" alt="<?php echo esc_attr( $alt ); ?>" id="<?php echo esc_attr( $id ); ?>"/>
|
377 |
+
<?php
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Top right area of the header, by default the notifications and help icons.
|
382 |
+
*
|
383 |
+
* @return void
|
384 |
+
*/
|
385 |
+
public function output_header_right() {
|
386 |
+
$notifications_count = wpcode()->notifications->get_count();
|
387 |
+
$dismissed_count = wpcode()->notifications->get_dismissed_count();
|
388 |
+
$data_count = '';
|
389 |
+
if ( $notifications_count > 0 ) {
|
390 |
+
$data_count = sprintf(
|
391 |
+
'data-count="%d"',
|
392 |
+
absint( $notifications_count )
|
393 |
+
);
|
394 |
+
}
|
395 |
+
?>
|
396 |
+
<button
|
397 |
+
type="button"
|
398 |
+
id="wpcode-notifications-button"
|
399 |
+
class="wpcode-button-just-icon wpcode-notifications-inbox wpcode-open-notifications"
|
400 |
+
data-dismissed="<?php echo esc_attr( $dismissed_count ); ?>"
|
401 |
+
<?php echo $data_count; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
|
402 |
+
<?php wpcode_icon( 'inbox', 15, 16 ); ?>
|
403 |
+
</button>
|
404 |
+
<button class="wpcode-text-button-icon wpcode-show-help" type="button">
|
405 |
+
<?php wpcode_icon( 'help', 21 ); ?>
|
406 |
+
<?php esc_html_e( 'Help', 'insert-headers-and-footers' ); ?>
|
407 |
+
</button>
|
408 |
+
<?php
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* This is the menu area but on some pages it's just at title.
|
413 |
+
* Tabs could also be used here.
|
414 |
+
*
|
415 |
+
* @return void
|
416 |
+
*/
|
417 |
+
public function output_header_bottom() {
|
418 |
+
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Checks if an error or success message is available and outputs using the specific format.
|
423 |
+
*
|
424 |
+
* @return void
|
425 |
+
*/
|
426 |
+
public function maybe_output_message() {
|
427 |
+
$error_message = $this->get_error_message();
|
428 |
+
$success_message = $this->get_success_message();
|
429 |
+
|
430 |
+
?>
|
431 |
+
<div class="wrap" id="wpcode-notice-area">
|
432 |
+
<?php
|
433 |
+
if ( $error_message ) {
|
434 |
+
?>
|
435 |
+
<div class="error fade notice is-dismissible">
|
436 |
+
<p><?php echo wp_kses_post( $error_message ); ?></p>
|
437 |
+
</div>
|
438 |
+
<?php
|
439 |
+
}
|
440 |
+
if ( $success_message ) {
|
441 |
+
?>
|
442 |
+
<div class="updated fade notice is-dismissible">
|
443 |
+
<p><?php echo wp_kses_post( $success_message ); ?></p>
|
444 |
+
</div>
|
445 |
+
<?php
|
446 |
+
}
|
447 |
+
?>
|
448 |
+
</div>
|
449 |
+
<?php
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* If no message is set return false otherwise return the message string.
|
454 |
+
*
|
455 |
+
* @return false|string
|
456 |
+
*/
|
457 |
+
public function get_error_message() {
|
458 |
+
return ! empty( $this->message_error ) ? $this->message_error : false;
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* If no message is set return false otherwise return the message string.
|
463 |
+
*
|
464 |
+
* @return false|string
|
465 |
+
*/
|
466 |
+
public function get_success_message() {
|
467 |
+
return ! empty( $this->message_success ) ? $this->message_success : false;
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* This is the main page content and you can't get away without it.
|
472 |
+
*
|
473 |
+
* @return void
|
474 |
+
*/
|
475 |
+
abstract public function output_content();
|
476 |
+
|
477 |
+
/**
|
478 |
+
* If you need to page-specific scripts override this function.
|
479 |
+
* Hooked to 'admin_enqueue_scripts'.
|
480 |
+
*
|
481 |
+
* @return void
|
482 |
+
*/
|
483 |
+
public function page_scripts() {
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Set a success message to display it in the appropriate place.
|
488 |
+
* Let's use a function so if we decide to display multiple messages in the
|
489 |
+
* same instance it's easy to change the variable to an array.
|
490 |
+
*
|
491 |
+
* @param string $message The message to store as success message.
|
492 |
+
*
|
493 |
+
* @return void
|
494 |
+
*/
|
495 |
+
public function set_success_message( $message ) {
|
496 |
+
$this->message_success = $message;
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Set an error message to display it in the appropriate place.
|
501 |
+
* Let's use a function so if we decide to display multiple messages in the
|
502 |
+
* same instance it's easy to change the variable to an array.
|
503 |
+
*
|
504 |
+
* @param string $message The message to store as error message.
|
505 |
+
*
|
506 |
+
* @return void
|
507 |
+
*/
|
508 |
+
public function set_error_message( $message ) {
|
509 |
+
$this->message_error = $message;
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Add a page-specific body class using the page slug variable..
|
514 |
+
*
|
515 |
+
* @param string $body_class The body class to append.
|
516 |
+
*
|
517 |
+
* @return string
|
518 |
+
*/
|
519 |
+
public function page_specific_body_class( $body_class ) {
|
520 |
+
|
521 |
+
$body_class .= ' ' . $this->page_slug;
|
522 |
+
|
523 |
+
return $body_class;
|
524 |
+
}
|
525 |
+
|
526 |
+
/**
|
527 |
+
* Get the page url to be used in a form action.
|
528 |
+
*
|
529 |
+
* @return string
|
530 |
+
*/
|
531 |
+
public function get_page_action_url() {
|
532 |
+
$args = array(
|
533 |
+
'page' => $this->page_slug,
|
534 |
+
);
|
535 |
+
if ( ! empty( $this->view ) ) {
|
536 |
+
$args['view'] = $this->view;
|
537 |
+
}
|
538 |
+
|
539 |
+
return add_query_arg( $args, admin_url( 'admin.php' ) );
|
540 |
+
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* If called, this loads CodeMirror on the current admin page with checks.
|
544 |
+
*
|
545 |
+
* @return array|false
|
546 |
+
*/
|
547 |
+
public function load_code_mirror() {
|
548 |
+
if ( ! function_exists( 'wp_enqueue_code_editor' ) ) {
|
549 |
+
return false;
|
550 |
+
}
|
551 |
+
$editor_args = array( 'type' => $this->get_mime_from_code_type() );
|
552 |
+
if ( ! $this->can_edit || ! current_user_can( 'wpcode_edit_snippets' ) ) {
|
553 |
+
$editor_args['codemirror']['readOnly'] = true;
|
554 |
+
}
|
555 |
+
|
556 |
+
// Enqueue code editor and settings for manipulating HTML.
|
557 |
+
return wp_enqueue_code_editor( $editor_args );
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Convert generic code type to MIME used by CodeMirror.
|
562 |
+
*
|
563 |
+
* @param string $code_type Optional parameter, if not passed it returns the mime for the currently set $code_type.
|
564 |
+
*
|
565 |
+
* @return string
|
566 |
+
* @see $code_type
|
567 |
+
*/
|
568 |
+
protected function get_mime_from_code_type( $code_type = '' ) {
|
569 |
+
if ( empty( $code_type ) ) {
|
570 |
+
$code_type = isset( $this->code_type ) ? $this->code_type : '';
|
571 |
+
}
|
572 |
+
|
573 |
+
return wpcode()->execute->get_mime_for_code_type( $code_type );
|
574 |
+
}
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Metabox-style layout for admin pages.
|
578 |
+
*
|
579 |
+
* @param string $title The metabox title.
|
580 |
+
* @param string $content The metabox content.
|
581 |
+
* @param string $help The helper text (optional) - if set, a help icon will show up next to the title.
|
582 |
+
*
|
583 |
+
* @return void
|
584 |
+
*/
|
585 |
+
public function metabox( $title, $content, $help = '' ) {
|
586 |
+
?>
|
587 |
+
<div class="wpcode-metabox">
|
588 |
+
<div class="wpcode-metabox-title">
|
589 |
+
<div class="wpcode-metabox-title-text">
|
590 |
+
<?php echo esc_html( $title ); ?>
|
591 |
+
<?php $this->help_icon( $help ); ?>
|
592 |
+
</div>
|
593 |
+
<div class="wpcode-metabox-title-toggle">
|
594 |
+
<button class="wpcode-metabox-button-toggle" type="button">
|
595 |
+
<svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
596 |
+
<path d="M1.41 7.70508L6 3.12508L10.59 7.70508L12 6.29508L6 0.295079L-1.23266e-07 6.29508L1.41 7.70508Z" fill="#454545"/>
|
597 |
+
</svg>
|
598 |
+
</button>
|
599 |
+
</div>
|
600 |
+
</div>
|
601 |
+
<div class="wpcode-metabox-content">
|
602 |
+
<?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
603 |
+
</div>
|
604 |
+
</div>
|
605 |
+
<?php
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Output a help icon with the text passed to it.
|
610 |
+
*
|
611 |
+
* @param string $text The tooltip text.
|
612 |
+
*
|
613 |
+
* @return void
|
614 |
+
*/
|
615 |
+
public function help_icon( $text = '' ) {
|
616 |
+
if ( empty( $text ) ) {
|
617 |
+
return;
|
618 |
+
}
|
619 |
+
?>
|
620 |
+
<span class="wpcode-help-tooltip">
|
621 |
+
<?php wpcode_icon( 'help', 16, 16, '0 0 20 20' ); ?>
|
622 |
+
<span class="wpcode-help-tooltip-text"><?php echo wp_kses_post( $text ); ?></span>
|
623 |
+
</span>
|
624 |
+
<?php
|
625 |
+
}
|
626 |
+
|
627 |
+
/**
|
628 |
+
* Get a WPCode metabox row.
|
629 |
+
*
|
630 |
+
* @param string $label The label of the field.
|
631 |
+
* @param string $input The field input (html).
|
632 |
+
* @param string $id The id for the row.
|
633 |
+
* @param string $show_if_id Conditional logic id, automatically hide if the value of the field with this id doesn't match show if value.
|
634 |
+
* @param string $show_if_value Value(s) to match against, can be comma-separated string for multiple values.
|
635 |
+
*
|
636 |
+
* @return void
|
637 |
+
*/
|
638 |
+
public function metabox_row( $label, $input, $id = '', $show_if_id = '', $show_if_value = '' ) {
|
639 |
+
$show_if_rules = '';
|
640 |
+
if ( ! empty( $show_if_id ) ) {
|
641 |
+
$show_if_rules = sprintf( 'data-show-if-id="%1$s" data-show-if-value="%2$s"', $show_if_id, $show_if_value );
|
642 |
+
}
|
643 |
+
?>
|
644 |
+
<div class="wpcode-metabox-form-row" <?php echo $show_if_rules; ?>>
|
645 |
+
<div class="wpcode-metabox-form-row-label">
|
646 |
+
<label for="<?php echo esc_attr( $id ); ?>">
|
647 |
+
<?php echo esc_html( $label ); ?>
|
648 |
+
</label>
|
649 |
+
</div>
|
650 |
+
<div class="wpcode-metabox-form-row-input">
|
651 |
+
<?php echo $input; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
652 |
+
</div>
|
653 |
+
</div>
|
654 |
+
<?php
|
655 |
+
}
|
656 |
+
|
657 |
+
/**
|
658 |
+
* Get a checkbox wrapped with markup to be displayed as a toggle.
|
659 |
+
*
|
660 |
+
* @param bool $checked Is it checked or not.
|
661 |
+
* @param string $name The name for the input.
|
662 |
+
* @param string $description Field description (optional).
|
663 |
+
*
|
664 |
+
* @return string
|
665 |
+
*/
|
666 |
+
public function get_checkbox_toggle( $checked, $name, $description = '' ) {
|
667 |
+
$markup = '<label class="wpcode-checkbox-toggle">';
|
668 |
+
|
669 |
+
$markup .= '<input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $name ) . '" id="' . esc_attr( $name ) . '" />';
|
670 |
+
$markup .= '<span class="wpcode-checkbox-toggle-slider"></span>';
|
671 |
+
$markup .= '</label>';
|
672 |
+
|
673 |
+
if ( ! empty( $description ) ) {
|
674 |
+
$markup .= '<p class="description">' . wp_kses_post( $description ) . '</p>';
|
675 |
+
}
|
676 |
+
|
677 |
+
return $markup;
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Build the markup for the snippet item. Also used as a template for the js.
|
682 |
+
*
|
683 |
+
* @param array $snippet The snippet object.
|
684 |
+
* @param string $category The active category to display by default.
|
685 |
+
*
|
686 |
+
* @return void
|
687 |
+
*/
|
688 |
+
public function get_library_snippet_item( $snippet = array(), $category = '*' ) {
|
689 |
+
$title = '';
|
690 |
+
$url = '';
|
691 |
+
$description = '';
|
692 |
+
$used_library_snippets = wpcode()->library->get_used_library_snippets();
|
693 |
+
$button_text = __( 'Use snippet', 'insert-headers-and-footers' );
|
694 |
+
$pill_text = '';
|
695 |
+
if ( ! empty( $snippet ) ) {
|
696 |
+
$url = add_query_arg(
|
697 |
+
array(
|
698 |
+
'page' => 'wpcode-snippet-manager',
|
699 |
+
'custom' => true,
|
700 |
+
),
|
701 |
+
admin_url( 'admin.php' )
|
702 |
+
);
|
703 |
+
if ( 0 !== $snippet['library_id'] ) {
|
704 |
+
if ( ! empty( $used_library_snippets[ $snippet['library_id'] ] ) ) {
|
705 |
+
$url = add_query_arg(
|
706 |
+
array(
|
707 |
+
'page' => 'wpcode-snippet-manager',
|
708 |
+
'snippet_id' => absint( $used_library_snippets[ $snippet['library_id'] ] ),
|
709 |
+
),
|
710 |
+
admin_url( 'admin.php' )
|
711 |
+
);
|
712 |
+
$button_text = __( 'Edit snippet', 'insert-headers-and-footers' );
|
713 |
+
$pill_text = __( 'Used', 'insert-headers-and-footers' );
|
714 |
+
} else {
|
715 |
+
$url = wp_nonce_url(
|
716 |
+
add_query_arg(
|
717 |
+
array(
|
718 |
+
'snippet_library_id' => absint( $snippet['library_id'] ),
|
719 |
+
'page' => 'wpcode-library',
|
720 |
+
),
|
721 |
+
admin_url( 'admin.php' )
|
722 |
+
),
|
723 |
+
'wpcode_add_from_library'
|
724 |
+
);
|
725 |
+
}
|
726 |
+
}
|
727 |
+
$title = $snippet['title'];
|
728 |
+
$description = $snippet['note'];
|
729 |
+
}
|
730 |
+
$id = $snippet['library_id'];
|
731 |
+
$button_2_text = '';
|
732 |
+
if ( ! empty( $snippet['code'] ) ) {
|
733 |
+
$button_2_text = __( 'Preview', 'insert-headers-and-footers' );
|
734 |
+
}
|
735 |
+
$categories = isset( $snippet['categories'] ) ? $snippet['categories'] : array();
|
736 |
+
|
737 |
+
$this->get_list_item( $id, $title, $description, $url, $button_text, $categories, $button_2_text, 'wpcode-library-preview-button', $pill_text, 'blue', $category );
|
738 |
+
}
|
739 |
+
|
740 |
+
/**
|
741 |
+
* Get a list item markup, used for library & generators.
|
742 |
+
*
|
743 |
+
* @param string $id The id used for the data-id param (used for filtering).
|
744 |
+
* @param string $title The title of the item.
|
745 |
+
* @param string $description The item description.
|
746 |
+
* @param string $url The URL for the action button.
|
747 |
+
* @param string $button_text The action button text.
|
748 |
+
* @param array $categories The categories of this object (for filtering).
|
749 |
+
* @param string $button_2_text (optional) 2nd button text. If left empty, the 2nd button will not be shown.
|
750 |
+
* @param string $button_2_class (optional) 2nd button class.
|
751 |
+
* @param string $pill_text (optional) Display a "pill" with some text in the top right corner.
|
752 |
+
* @param string $pill_class (optional) Custom CSS class for the pill.
|
753 |
+
* @param string $selected_category (optional) Slug of the category selected by default.
|
754 |
+
*
|
755 |
+
* @return void
|
756 |
+
*/
|
757 |
+
public function get_list_item( $id, $title, $description, $url, $button_text, $categories = array(), $button_2_text = '', $button_2_class = '', $pill_text = '', $pill_class = 'blue', $selected_category = '*' ) {
|
758 |
+
$item_class = array(
|
759 |
+
'wpcode-list-item',
|
760 |
+
);
|
761 |
+
if ( ! empty( $pill_text ) ) {
|
762 |
+
$item_class[] = 'wpcode-list-item-has-pill';
|
763 |
+
}
|
764 |
+
$style = '';
|
765 |
+
if ( '*' !== $selected_category && ! in_array( $selected_category, $categories, true ) ) {
|
766 |
+
$style = 'display:none;';
|
767 |
+
}
|
768 |
+
?>
|
769 |
+
<li class="<?php echo esc_attr( implode( ' ', $item_class ) ); ?>" data-id="<?php echo esc_attr( $id ); ?>" data-categories='<?php echo wp_json_encode( $categories ); ?>' style="<?php echo esc_attr( $style ); ?>">
|
770 |
+
<h3 title="<?php echo esc_attr( $title ); ?>"><?php echo esc_html( $title ); ?></h3>
|
771 |
+
<?php if ( ! empty( $pill_text ) ) { ?>
|
772 |
+
<span class="wpcode-list-item-pill wpcode-list-item-pill-<?php echo esc_attr( $pill_class ); ?>"><?php echo esc_html( $pill_text ); ?></span>
|
773 |
+
<?php } ?>
|
774 |
+
<div class="wpcode-list-item-actions">
|
775 |
+
<div class="wpcode-list-item-description">
|
776 |
+
<p><?php echo esc_html( $description ); ?></p>
|
777 |
+
</div>
|
778 |
+
<div class="wpcode-list-item-buttons">
|
779 |
+
<a href="<?php echo esc_url( $url ); ?>" class="wpcode-button wpcode-item-use-button">
|
780 |
+
<?php echo esc_html( $button_text ); ?>
|
781 |
+
</a>
|
782 |
+
<?php if ( ! empty( $button_2_text ) ) { ?>
|
783 |
+
<button class="wpcode-button wpcode-button-secondary <?php echo esc_attr( $button_2_class ); ?>" type="button">
|
784 |
+
<?php echo esc_html( $button_2_text ); ?>
|
785 |
+
</button>
|
786 |
+
<?php } ?>
|
787 |
+
</div>
|
788 |
+
</div>
|
789 |
+
</li>
|
790 |
+
<?php
|
791 |
+
}
|
792 |
+
|
793 |
+
/**
|
794 |
+
* Output the library markup from an array of categories and an array of snippets.
|
795 |
+
*
|
796 |
+
* @param array $categories The snippet categories to show.
|
797 |
+
* @param array $snippets The snippets to show.
|
798 |
+
*
|
799 |
+
* @return void
|
800 |
+
*/
|
801 |
+
public function get_library_markup( $categories, $snippets ) {
|
802 |
+
$selected_category = isset( $categories[0]['slug'] ) ? $categories[0]['slug'] : '*';
|
803 |
+
?>
|
804 |
+
<div class="wpcode-items-metabox wpcode-metabox">
|
805 |
+
<?php $this->get_items_list_sidebar( $categories, __( 'All Snippets', 'insert-headers-and-footers' ), __( 'Search Snippets', 'insert-headers-and-footers' ), $selected_category ); ?>
|
806 |
+
<div class="wpcode-items-list">
|
807 |
+
<?php
|
808 |
+
if ( empty( $snippets ) ) {
|
809 |
+
?>
|
810 |
+
<div class="wpcode-alert wpcode-alert-warning">
|
811 |
+
<?php printf( '<h4>%s</h4>', esc_html__( 'We encountered a problem loading the Snippet Library items, please try again later.', 'insert-headers-and-footers' ) ); ?>
|
812 |
+
</div>
|
813 |
+
<?php
|
814 |
+
}
|
815 |
+
?>
|
816 |
+
<ul class="wpcode-items-list-category">
|
817 |
+
<?php
|
818 |
+
foreach ( $snippets as $snippet ) {
|
819 |
+
$this->get_library_snippet_item( $snippet, $selected_category );
|
820 |
+
}
|
821 |
+
?>
|
822 |
+
</ul>
|
823 |
+
</div>
|
824 |
+
</div>
|
825 |
+
<?php
|
826 |
+
$this->library_preview_modal_content();
|
827 |
+
}
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Get the items list sidebar with optional search form.
|
831 |
+
*
|
832 |
+
* @param array $categories The array of categories to display as filters - each item needs to have the "slug" and "name" keys.
|
833 |
+
* @param string $all_text Text to display on the all items button in the categories list.
|
834 |
+
* @param string $search_label The search label, if left empty the search form is hidden.
|
835 |
+
* @param string $selected_category Slug of the category selected by default.
|
836 |
+
*
|
837 |
+
* @return void
|
838 |
+
*/
|
839 |
+
public function get_items_list_sidebar( $categories, $all_text = '', $search_label = '', $selected_category = '' ) {
|
840 |
+
?>
|
841 |
+
<div class="wpcode-items-sidebar">
|
842 |
+
<?php if ( ! empty( $search_label ) ) { ?>
|
843 |
+
<div class="wpcode-items-search">
|
844 |
+
<label for="wpcode-items-search">
|
845 |
+
<span class="screen-reader-text"><?php echo esc_html( $search_label ); ?></span>
|
846 |
+
<?php wpcode_icon( 'search', 16, 16 ); ?>
|
847 |
+
</label>
|
848 |
+
<input type="search" id="wpcode-items-search" placeholder="<?php echo esc_html( $search_label ); ?>"/>
|
849 |
+
</div>
|
850 |
+
<?php } ?>
|
851 |
+
<ul class="wpcode-items-categories-list wpcode-items-filters">
|
852 |
+
<li>
|
853 |
+
<button type="button" data-category="*" class="<?php echo empty( $selected_category ) ? 'wpcode-active' : ''; ?>"><?php echo esc_html( $all_text ); ?></button>
|
854 |
+
</li>
|
855 |
+
<?php
|
856 |
+
foreach ( $categories as $category ) {
|
857 |
+
// Mark the first category as active.
|
858 |
+
$class = $category['slug'] === $selected_category ? 'wpcode-active' : '';
|
859 |
+
?>
|
860 |
+
<li>
|
861 |
+
<button type="button" class="<?php echo esc_attr( $class ); ?>" data-category="<?php echo esc_attr( $category['slug'] ); ?>"><?php echo esc_html( $category['name'] ); ?></button>
|
862 |
+
</li>
|
863 |
+
<?php } ?>
|
864 |
+
</ul>
|
865 |
+
</div>
|
866 |
+
<?php
|
867 |
+
}
|
868 |
+
|
869 |
+
/**
|
870 |
+
* Get the preview modal markup.
|
871 |
+
*
|
872 |
+
* @return void
|
873 |
+
*/
|
874 |
+
public function library_preview_modal_content() {
|
875 |
+
?>
|
876 |
+
<div class="wpcode-library-preview wpcode-modal" id="wpcode-library-preview">
|
877 |
+
<div class="wpcode-library-preview-header">
|
878 |
+
<button type="button" class="wpcode-just-icon-button wpcode-close-modal"><?php wpcode_icon( 'close', 15, 14 ); ?></button>
|
879 |
+
<h2><?php esc_html_e( 'Preview Snippet', 'insert-headers-and-footers' ); ?></h2>
|
880 |
+
</div>
|
881 |
+
<div class="wpcode-library-preview-content">
|
882 |
+
<h3>
|
883 |
+
<label for="wpcode-code-preview" id="wpcode-preview-title"><?php esc_html_e( 'Code Preview', 'insert-headers-and-footers' ); ?></label>
|
884 |
+
</h3>
|
885 |
+
<textarea id="wpcode-code-preview"></textarea>
|
886 |
+
</div>
|
887 |
+
<div class="wpcode-library-preview-buttons">
|
888 |
+
<a class="wpcode-button wpcode-button-wide" id="wpcode-preview-use-code"><?php esc_html_e( 'Use Snippet', 'insert-headers-and-footers' ); ?></a>
|
889 |
+
</div>
|
890 |
+
</div>
|
891 |
+
<?php
|
892 |
+
$this->code_type = 'text';
|
893 |
+
$settings = $this->load_code_mirror();
|
894 |
+
|
895 |
+
$settings['codemirror']['readOnly'] = 'nocursor';
|
896 |
+
wp_add_inline_script( 'code-editor', sprintf( 'jQuery( function() { window.wpcode_editor = wp.codeEditor.initialize( "wpcode-code-preview", %s ); } );', wp_json_encode( $settings ) ) );
|
897 |
+
}
|
898 |
+
|
899 |
+
/**
|
900 |
+
* Load library data in JS.
|
901 |
+
*
|
902 |
+
* @param array $data The library data.
|
903 |
+
*
|
904 |
+
* @return array
|
905 |
+
*/
|
906 |
+
public function maybe_add_library_data( $data ) {
|
907 |
+
if ( $this->show_library ) {
|
908 |
+
$data['library'] = wpcode()->library->get_data();
|
909 |
+
}
|
910 |
+
|
911 |
+
return $data;
|
912 |
+
}
|
913 |
+
|
914 |
+
/**
|
915 |
+
* Get the full URL for a view of an admin page.
|
916 |
+
*
|
917 |
+
* @param string $view The view slug.
|
918 |
+
*
|
919 |
+
* @return string
|
920 |
+
*/
|
921 |
+
public function get_view_link( $view ) {
|
922 |
+
return add_query_arg(
|
923 |
+
array(
|
924 |
+
'page' => $this->page_slug,
|
925 |
+
'view' => $view,
|
926 |
+
),
|
927 |
+
admin_url( 'admin.php' )
|
928 |
+
);
|
929 |
+
}
|
930 |
+
}
|
includes/admin/pages/class-wpcode-code-snippets-table.php
ADDED
@@ -0,0 +1,730 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Table of snippets for the admin list.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Generate the table for the list of code snippets.
|
10 |
+
*/
|
11 |
+
class WPCode_Code_Snippets_Table extends WP_List_Table {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Number of snippets to show per page.
|
15 |
+
*
|
16 |
+
* @var int
|
17 |
+
*/
|
18 |
+
public $per_page;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Number of snippets in different views.
|
22 |
+
*
|
23 |
+
* @var array
|
24 |
+
*/
|
25 |
+
private $count;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Current view.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
private $view;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Primary class constructor.
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
+
|
39 |
+
// Utilize the parent constructor to build the main class properties.
|
40 |
+
parent::__construct(
|
41 |
+
array(
|
42 |
+
'singular' => 'wpcode-snippet',
|
43 |
+
'plural' => 'wpcode-snippets',
|
44 |
+
'ajax' => false,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
// Default number of snippets to show per page.
|
49 |
+
$this->per_page = (int) apply_filters( 'wpcode_code_snippets_per_page', 20 );
|
50 |
+
$this->view = $this->get_current_view();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Load the current view from the get param.
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
private function get_current_view() {
|
59 |
+
return isset( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : 'all'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Render the checkbox column.
|
64 |
+
*
|
65 |
+
* @param WP_Post $item Snippet.
|
66 |
+
*
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
public function column_cb( $item ) {
|
70 |
+
return '<input type="checkbox" name="snippet_id[]" value="' . absint( $item->ID ) . '" />';
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Render the columns.
|
75 |
+
*
|
76 |
+
* @param WP_Post $item CPT object as a snippet representation.
|
77 |
+
* @param string $column_name Column Name.
|
78 |
+
*
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function column_default( $item, $column_name ) {
|
82 |
+
$snippet = new WPCode_Snippet( $item );
|
83 |
+
|
84 |
+
switch ( $column_name ) {
|
85 |
+
case 'id':
|
86 |
+
$value = $snippet->get_id();
|
87 |
+
break;
|
88 |
+
|
89 |
+
case 'location':
|
90 |
+
$location = $snippet->get_location();
|
91 |
+
$value = '';
|
92 |
+
if ( ! empty( $location ) ) {
|
93 |
+
$label = wpcode()->auto_insert->get_location_label( $location );
|
94 |
+
if ( 'trash' === $this->view ) {
|
95 |
+
$value = $label;
|
96 |
+
} else {
|
97 |
+
$url = add_query_arg( 'location', $snippet->get_location_term()->term_id );
|
98 |
+
$value = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $url ), esc_html( $label ) );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
break;
|
102 |
+
|
103 |
+
case 'created':
|
104 |
+
$value = sprintf(
|
105 |
+
// Translators: This is the format for displaying the date in the admin list, [date] at [time].
|
106 |
+
__( '%1$s at %2$s', 'insert-headers-and-footers' ),
|
107 |
+
get_the_time( get_option( 'date_format' ), $snippet->get_post_data() ),
|
108 |
+
get_the_time( get_option( 'time_format' ), $snippet->get_post_data() )
|
109 |
+
);
|
110 |
+
break;
|
111 |
+
|
112 |
+
case 'author':
|
113 |
+
$value = '';
|
114 |
+
$author = get_userdata( $snippet->get_snippet_author() );
|
115 |
+
|
116 |
+
if ( ! $author ) {
|
117 |
+
break;
|
118 |
+
}
|
119 |
+
|
120 |
+
$value = $author->display_name;
|
121 |
+
$user_edit_url = get_edit_user_link( $author->ID );
|
122 |
+
|
123 |
+
if ( ! empty( $user_edit_url ) ) {
|
124 |
+
$value = '<a href="' . esc_url( $user_edit_url ) . '">' . esc_html( $value ) . '</a>';
|
125 |
+
}
|
126 |
+
break;
|
127 |
+
|
128 |
+
case 'tags':
|
129 |
+
$tags = $snippet->get_tags();
|
130 |
+
$tags_links = array();
|
131 |
+
if ( 'trash' !== $this->view ) {
|
132 |
+
foreach ( $tags as $tag ) {
|
133 |
+
$tags_links[] = sprintf(
|
134 |
+
'<a href="%1$s" title="%2$s">%3$s</a>',
|
135 |
+
add_query_arg( 'tag', $tag ),
|
136 |
+
// Translators: The tag by which to filter the list of snippets in the admin.
|
137 |
+
sprintf( __( 'Filter snippets by tag: %s', 'insert-headers-and-footers' ), $tag ),
|
138 |
+
$tag
|
139 |
+
);
|
140 |
+
}
|
141 |
+
} else {
|
142 |
+
$tags_links = $tags;
|
143 |
+
}
|
144 |
+
$value = implode( ', ', $tags_links );
|
145 |
+
break;
|
146 |
+
|
147 |
+
case 'status':
|
148 |
+
$value = $this->get_status_toggle( $snippet->is_active(), $snippet->get_id() );
|
149 |
+
break;
|
150 |
+
|
151 |
+
default:
|
152 |
+
$value = '';
|
153 |
+
}
|
154 |
+
|
155 |
+
return apply_filters( 'wpcode_code_snippets_table_column_value', $value, $snippet, $column_name );
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Get the markup for the status toggle.
|
160 |
+
*
|
161 |
+
* @param bool $active If the snippet is active or not.
|
162 |
+
* @param int $snippet_id The id of the snippet.
|
163 |
+
*
|
164 |
+
* @return string
|
165 |
+
*/
|
166 |
+
public function get_status_toggle( $active, $snippet_id ) {
|
167 |
+
$markup = '<label class="wpcode-checkbox-toggle">';
|
168 |
+
$markup .= '<input data-id=' . absint( $snippet_id ) . ' type="checkbox" ' . checked( $active, true, false ) . ' class="wpcode-status-toggle" />';
|
169 |
+
$markup .= '<span class="wpcode-checkbox-toggle-slider"></span>';
|
170 |
+
$markup .= '</label>';
|
171 |
+
|
172 |
+
return $markup;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Render the snippet name column with action links.
|
177 |
+
*
|
178 |
+
* @param WP_Post $snippet Snippet.
|
179 |
+
*
|
180 |
+
* @return string
|
181 |
+
*/
|
182 |
+
public function column_name( $snippet ) {
|
183 |
+
// Build the row action links and return the value.
|
184 |
+
return $this->get_column_name_title( $snippet ) . $this->get_column_name_row_actions( $snippet );
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Get the snippet name HTML for the snippet name column.
|
189 |
+
*
|
190 |
+
* @param WP_Post $snippet Snippet post object.
|
191 |
+
*
|
192 |
+
* @return string
|
193 |
+
*/
|
194 |
+
protected function get_column_name_title( $snippet ) {
|
195 |
+
|
196 |
+
$title = ! empty( $snippet->post_title ) ? $snippet->post_title : $snippet->post_name;
|
197 |
+
$name = sprintf(
|
198 |
+
'<span><strong>%s</strong></span>',
|
199 |
+
esc_html( $title )
|
200 |
+
);
|
201 |
+
|
202 |
+
if ( 'trash' === $this->view ) {
|
203 |
+
return $name;
|
204 |
+
}
|
205 |
+
|
206 |
+
if ( current_user_can( 'edit_post', $snippet->ID ) ) {
|
207 |
+
$name = sprintf(
|
208 |
+
'<a href="%s" title="%s"><strong>%s</strong></a>',
|
209 |
+
esc_url(
|
210 |
+
add_query_arg(
|
211 |
+
'snippet_id',
|
212 |
+
$snippet->ID,
|
213 |
+
admin_url( 'admin.php?page=wpcode-snippet-manager' )
|
214 |
+
)
|
215 |
+
),
|
216 |
+
esc_attr__( 'Edit This Snippet', 'insert-headers-and-footers' ),
|
217 |
+
esc_html( $title )
|
218 |
+
);
|
219 |
+
}
|
220 |
+
|
221 |
+
return $name;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get the row actions HTML for the snippet name column.
|
226 |
+
*
|
227 |
+
* @param WP_Post $snippet Snippet object.
|
228 |
+
*
|
229 |
+
* @return string
|
230 |
+
*/
|
231 |
+
protected function get_column_name_row_actions( $snippet ) {
|
232 |
+
/**
|
233 |
+
* Filters row action links on the 'Code Snippets' admin page.
|
234 |
+
*
|
235 |
+
* @param array $row_actions An array of action links for a given snippet.
|
236 |
+
* @param WP_Post $snippet Snippet object.
|
237 |
+
*/
|
238 |
+
$actions = array();
|
239 |
+
|
240 |
+
if ( 'trash' === $this->view ) {
|
241 |
+
if ( current_user_can( 'edit_post', $snippet->ID ) ) {
|
242 |
+
$actions['untrash'] = sprintf(
|
243 |
+
'<a href="%s" title="%s">%s</a>',
|
244 |
+
esc_url(
|
245 |
+
wp_nonce_url(
|
246 |
+
add_query_arg(
|
247 |
+
array(
|
248 |
+
'action' => 'untrash',
|
249 |
+
'snippet_id' => $snippet->ID,
|
250 |
+
),
|
251 |
+
admin_url( 'admin.php?page=wpcode' )
|
252 |
+
),
|
253 |
+
'wpcode_untrash_nonce'
|
254 |
+
)
|
255 |
+
),
|
256 |
+
esc_attr__( 'Restore this snippet', 'insert-headers-and-footers' ),
|
257 |
+
esc_html__( 'Restore', 'insert-headers-and-footers' )
|
258 |
+
);
|
259 |
+
$actions['delete'] = sprintf(
|
260 |
+
'<a href="%s" title="%s">%s</a>',
|
261 |
+
esc_url(
|
262 |
+
wp_nonce_url(
|
263 |
+
add_query_arg(
|
264 |
+
array(
|
265 |
+
'action' => 'delete',
|
266 |
+
'snippet_id' => $snippet->ID,
|
267 |
+
),
|
268 |
+
admin_url( 'admin.php?page=wpcode' )
|
269 |
+
),
|
270 |
+
'wpcode_delete_nonce'
|
271 |
+
)
|
272 |
+
),
|
273 |
+
esc_attr__( 'Delete this snippet permanently', 'insert-headers-and-footers' ),
|
274 |
+
esc_html__( 'Delete Permanently', 'insert-headers-and-footers' )
|
275 |
+
);
|
276 |
+
}
|
277 |
+
} else {
|
278 |
+
|
279 |
+
if ( current_user_can( 'edit_post', $snippet->ID ) ) {
|
280 |
+
$actions['edit'] = sprintf(
|
281 |
+
'<a href="%s" title="%s">%s</a>',
|
282 |
+
esc_url( add_query_arg( 'snippet_id', $snippet->ID, admin_url( 'admin.php?page=wpcode-snippet-manager' ) ) ),
|
283 |
+
esc_attr__( 'Edit This Snippet', 'insert-headers-and-footers' ),
|
284 |
+
esc_html__( 'Edit', 'insert-headers-and-footers' )
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
if ( current_user_can( 'edit_post', $snippet->ID ) ) {
|
289 |
+
$actions['trash'] = sprintf(
|
290 |
+
'<a href="%s" title="%s">%s</a>',
|
291 |
+
esc_url(
|
292 |
+
wp_nonce_url(
|
293 |
+
add_query_arg(
|
294 |
+
array(
|
295 |
+
'action' => 'trash',
|
296 |
+
'snippet_id' => $snippet->ID,
|
297 |
+
),
|
298 |
+
admin_url( 'admin.php?page=wpcode' )
|
299 |
+
),
|
300 |
+
'wpcode_trash_nonce'
|
301 |
+
)
|
302 |
+
),
|
303 |
+
esc_attr__( 'Move this snippet to trash', 'insert-headers-and-footers' ),
|
304 |
+
esc_html__( 'Trash', 'insert-headers-and-footers' )
|
305 |
+
);
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
return $this->row_actions( apply_filters( 'wpcode_code_snippets_row_actions', $actions, $snippet, $this->view ) );
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Define bulk actions available for our table listing.
|
314 |
+
*
|
315 |
+
* @return array
|
316 |
+
*/
|
317 |
+
public function get_bulk_actions() {
|
318 |
+
if ( 'trash' === $this->view ) {
|
319 |
+
return array(
|
320 |
+
'untrash' => esc_html__( 'Restore', 'insert-headers-and-footers' ),
|
321 |
+
'delete' => esc_html__( 'Delete Permanently', 'insert-headers-and-footers' ),
|
322 |
+
);
|
323 |
+
}
|
324 |
+
|
325 |
+
return array(
|
326 |
+
'trash' => __( 'Trash', 'insert-headers-and-footers' ),
|
327 |
+
);
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Message to be displayed when there are no snippets.
|
332 |
+
*
|
333 |
+
* @since 2.0.0
|
334 |
+
*/
|
335 |
+
public function no_items() {
|
336 |
+
|
337 |
+
esc_html_e( 'No snippets found.', 'insert-headers-and-footers' );
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Fetch and set up the final data for the table.
|
342 |
+
*
|
343 |
+
* @since 2.0.0
|
344 |
+
*/
|
345 |
+
public function prepare_items() {
|
346 |
+
|
347 |
+
// Set up the columns.
|
348 |
+
$columns = $this->get_columns();
|
349 |
+
|
350 |
+
// Hidden columns (none).
|
351 |
+
$hidden = get_hidden_columns( $this->screen );
|
352 |
+
|
353 |
+
$sortable = array(
|
354 |
+
'name' => array( 'title', false ),
|
355 |
+
'created' => array( 'date', false ),
|
356 |
+
);
|
357 |
+
|
358 |
+
// Set column headers.
|
359 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
360 |
+
|
361 |
+
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
362 |
+
$page = $this->get_pagenum();
|
363 |
+
$order = isset( $_GET['order'] ) && 'asc' === $_GET['order'] ? 'ASC' : 'DESC';
|
364 |
+
$orderby = isset( $_GET['orderby'] ) ? sanitize_key( $_GET['orderby'] ) : 'ID';
|
365 |
+
$per_page = $this->get_items_per_page( 'wpcode_snippets_per_page', $this->per_page );
|
366 |
+
$is_filtered = false;
|
367 |
+
|
368 |
+
$args = array(
|
369 |
+
'orderby' => $orderby,
|
370 |
+
'order' => $order,
|
371 |
+
'nopaging' => false,
|
372 |
+
'posts_per_page' => $per_page,
|
373 |
+
'paged' => $page,
|
374 |
+
'no_found_rows' => false,
|
375 |
+
'post_status' => array( 'publish', 'draft' ),
|
376 |
+
'post_type' => 'wpcode',
|
377 |
+
'suppress_filters' => true,
|
378 |
+
);
|
379 |
+
|
380 |
+
if ( ! empty( $_GET['location'] ) ) {
|
381 |
+
$is_filtered = true;
|
382 |
+
$args['tax_query'] = array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
|
383 |
+
array(
|
384 |
+
'taxonomy' => 'wpcode_location',
|
385 |
+
'terms' => array( absint( $_GET['location'] ) ),
|
386 |
+
),
|
387 |
+
);
|
388 |
+
}
|
389 |
+
|
390 |
+
if ( ! empty( $_GET['type'] ) ) {
|
391 |
+
$is_filtered = true;
|
392 |
+
if ( ! isset( $args['tax_query'] ) ) {
|
393 |
+
$args['tax_query'] = array(); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
|
394 |
+
}
|
395 |
+
$args['tax_query'][] = array(
|
396 |
+
'taxonomy' => 'wpcode_type',
|
397 |
+
'terms' => array( sanitize_text_field( wp_unslash( $_GET['type'] ) ) ),
|
398 |
+
'field' => 'slug',
|
399 |
+
);
|
400 |
+
}
|
401 |
+
|
402 |
+
if ( ! empty( $_GET['tag'] ) ) {
|
403 |
+
$is_filtered = true;
|
404 |
+
if ( ! isset( $args['tax_query'] ) ) {
|
405 |
+
$args['tax_query'] = array(); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
|
406 |
+
}
|
407 |
+
$args['tax_query'][] = array(
|
408 |
+
'taxonomy' => 'wpcode_tags',
|
409 |
+
'terms' => array( sanitize_text_field( wp_unslash( $_GET['tag'] ) ) ),
|
410 |
+
'field' => 'slug',
|
411 |
+
);
|
412 |
+
}
|
413 |
+
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
414 |
+
|
415 |
+
if ( 'all' !== $this->view ) {
|
416 |
+
$args['post_status'] = $this->get_post_status_from_view();
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Filters the `get_posts()` arguments while preparing items for the code snippets table.
|
421 |
+
*
|
422 |
+
* @param array $args Arguments array.
|
423 |
+
*/
|
424 |
+
$args = (array) apply_filters( 'wpcode_code_snippets_table_prepare_items_args', $args );
|
425 |
+
|
426 |
+
$items_query = new WP_Query( $args );
|
427 |
+
$this->items = $items_query->get_posts();
|
428 |
+
|
429 |
+
$per_page = isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : $this->get_items_per_page( 'wpcode_snippets_per_page', $this->per_page );
|
430 |
+
|
431 |
+
$this->update_count( $args );
|
432 |
+
|
433 |
+
$count_current_view = empty( $this->count[ $this->view ] ) ? 0 : $this->count[ $this->view ];
|
434 |
+
if ( $is_filtered ) {
|
435 |
+
$count_current_view = $items_query->found_posts;
|
436 |
+
}
|
437 |
+
|
438 |
+
// Finalize pagination.
|
439 |
+
$this->set_pagination_args(
|
440 |
+
array(
|
441 |
+
'total_items' => $count_current_view,
|
442 |
+
'per_page' => $per_page,
|
443 |
+
'total_pages' => ceil( $count_current_view / $per_page ),
|
444 |
+
)
|
445 |
+
);
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Retrieve the table columns.
|
450 |
+
*
|
451 |
+
* @return array $columns Array of all the list table columns.
|
452 |
+
*/
|
453 |
+
public function get_columns() {
|
454 |
+
|
455 |
+
$columns = array(
|
456 |
+
'cb' => '<input type="checkbox" />',
|
457 |
+
'name' => esc_html__( 'Name', 'insert-headers-and-footers' ),
|
458 |
+
'author' => esc_html__( 'Author', 'insert-headers-and-footers' ),
|
459 |
+
'location' => esc_html__( 'Location', 'insert-headers-and-footers' ),
|
460 |
+
'created' => esc_html__( 'Created', 'insert-headers-and-footers' ),
|
461 |
+
'tags' => esc_html__( 'Tags', 'insert-headers-and-footers' ),
|
462 |
+
);
|
463 |
+
if ( 'trash' !== $this->view ) {
|
464 |
+
$columns['status'] = esc_html__( 'Status', 'insert-headers-and-footers' );
|
465 |
+
}
|
466 |
+
|
467 |
+
return apply_filters( 'wpcode_code_snippets_table_columns', $columns );
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Convert custom view names to actual post statuses.
|
472 |
+
*
|
473 |
+
* @return string
|
474 |
+
*/
|
475 |
+
private function get_post_status_from_view() {
|
476 |
+
switch ( $this->view ) {
|
477 |
+
case 'active':
|
478 |
+
$post_status = 'publish';
|
479 |
+
break;
|
480 |
+
case 'inactive':
|
481 |
+
$post_status = 'draft';
|
482 |
+
break;
|
483 |
+
case 'trash':
|
484 |
+
$post_status = 'trash';
|
485 |
+
break;
|
486 |
+
default:
|
487 |
+
$post_status = 'all';
|
488 |
+
break;
|
489 |
+
}
|
490 |
+
|
491 |
+
return $post_status;
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Calculate and update snippets counts.
|
496 |
+
*
|
497 |
+
* @param array $args Get snippets arguments.
|
498 |
+
*/
|
499 |
+
private function update_count( $args ) {
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Allow counting snippets filtered by a given search criteria.
|
503 |
+
*
|
504 |
+
* If result will not contain `all` key, count All Snippets without filtering will be performed.
|
505 |
+
*
|
506 |
+
* @param array $count Contains counts of snippets in different views.
|
507 |
+
* @param array $args Arguments of the `get_posts`.
|
508 |
+
*
|
509 |
+
* @since 2.0.0
|
510 |
+
*/
|
511 |
+
$this->count = (array) apply_filters( 'wpcode_code_snippets_table_update_count', array(), $args );
|
512 |
+
|
513 |
+
// We do not need to perform all snippets count if we have the result already.
|
514 |
+
if ( isset( $this->count['all'] ) ) {
|
515 |
+
return;
|
516 |
+
}
|
517 |
+
|
518 |
+
// Count all snippets.
|
519 |
+
$counts = wp_count_posts( 'wpcode' );
|
520 |
+
$this->count['all'] = array_sum( array( $counts->publish, $counts->draft ) );
|
521 |
+
$this->count['active'] = $counts->publish;
|
522 |
+
$this->count['inactive'] = $counts->draft;
|
523 |
+
$this->count['trash'] = $counts->trash;
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Filters snippets count data after counting all snippets.
|
527 |
+
*
|
528 |
+
* This filter executes only if the result of `wpcode_code_snippets_table_update_count` filter
|
529 |
+
* doesn't contain `all` key.
|
530 |
+
*
|
531 |
+
* @param array $count Contains counts of snippets in different views.
|
532 |
+
* @param array $args Arguments of the `get_posts`.
|
533 |
+
*/
|
534 |
+
$this->count = (array) apply_filters( 'wpcode_code_snippets_table_update_count_all', $this->count, $args );
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* Extending the `display_rows()` method in order to add hooks.
|
539 |
+
*
|
540 |
+
* @since 1.5.6
|
541 |
+
*/
|
542 |
+
public function display_rows() {
|
543 |
+
|
544 |
+
do_action( 'wpcode_code_snippets_table_before_rows', $this );
|
545 |
+
|
546 |
+
parent::display_rows();
|
547 |
+
|
548 |
+
do_action( 'wpcode_code_snippets_table_after_rows', $this );
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* Snippets search markup.
|
553 |
+
*
|
554 |
+
* @param string $text The 'submit' button label.
|
555 |
+
* @param string $input_id ID attribute value for the search input field.
|
556 |
+
*/
|
557 |
+
public function search_box( $text, $input_id ) {
|
558 |
+
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* Display the pagination.
|
563 |
+
*
|
564 |
+
* @param string $which The location of the table pagination: 'top' or 'bottom'.
|
565 |
+
*/
|
566 |
+
protected function pagination( $which ) {
|
567 |
+
|
568 |
+
if ( $this->has_items() ) {
|
569 |
+
parent::pagination( $which );
|
570 |
+
|
571 |
+
return;
|
572 |
+
}
|
573 |
+
|
574 |
+
printf(
|
575 |
+
'<div class="tablenav-pages one-page">
|
576 |
+
<span class="displaying-num">%s</span>
|
577 |
+
</div>',
|
578 |
+
esc_html__( '0 items', 'insert-headers-and-footers' )
|
579 |
+
);
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Extra controls to be displayed between bulk actions and pagination.
|
584 |
+
*
|
585 |
+
* @param string $which The location of the table navigation: 'top' or 'bottom'.
|
586 |
+
*
|
587 |
+
* @return void
|
588 |
+
*/
|
589 |
+
protected function extra_tablenav( $which ) {
|
590 |
+
if ( 'top' === $which && 'trash' !== $this->view ) {
|
591 |
+
$this->type_dropdown( 'wpcode' );
|
592 |
+
$this->location_dropdown( 'wpcode' );
|
593 |
+
|
594 |
+
submit_button( __( 'Filter', 'insert-headers-and-footers' ), '', 'filter_action', false, array( 'id' => 'wpcode-filter-submit' ) );
|
595 |
+
|
596 |
+
if ( isset( $_GET['filter_action'] ) || isset( $_GET['tag'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
597 |
+
echo ' ';
|
598 |
+
submit_button( __( 'Clear', 'insert-headers-and-footers' ), '', 'filter_clear', false, array( 'id' => 'wpcode-filter-clear' ) );
|
599 |
+
}
|
600 |
+
}
|
601 |
+
}
|
602 |
+
|
603 |
+
/**
|
604 |
+
* The dropdown to filter by the code type.
|
605 |
+
*
|
606 |
+
* @param string $post_type The post type.
|
607 |
+
*
|
608 |
+
* @return void
|
609 |
+
*/
|
610 |
+
protected function type_dropdown( $post_type ) {
|
611 |
+
if ( ! is_object_in_taxonomy( $post_type, 'wpcode_type' ) ) {
|
612 |
+
return;
|
613 |
+
}
|
614 |
+
|
615 |
+
$used_types = get_terms(
|
616 |
+
array(
|
617 |
+
'taxonomy' => 'wpcode_type',
|
618 |
+
'hide_empty' => false,
|
619 |
+
)
|
620 |
+
);
|
621 |
+
|
622 |
+
if ( ! $used_types ) {
|
623 |
+
return;
|
624 |
+
}
|
625 |
+
|
626 |
+
$displayed_type = isset( $_GET['type'] ) ? sanitize_text_field( wp_unslash( $_GET['type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
627 |
+
?>
|
628 |
+
<label for="filter-by-type" class="screen-reader-text"><?php esc_html_e( 'Filter by code type', 'insert-headers-and-footers' ); ?></label>
|
629 |
+
<select name="type" id="filter-by-type">
|
630 |
+
<option<?php selected( $displayed_type, '' ); ?> value=""><?php esc_html_e( 'All types', 'insert-headers-and-footers' ); ?></option>
|
631 |
+
<?php
|
632 |
+
foreach ( $used_types as $used_type ) {
|
633 |
+
|
634 |
+
$pretty_name = wpcode()->execute->get_type_label( $used_type->slug );
|
635 |
+
?>
|
636 |
+
<option<?php selected( $displayed_type, $used_type->slug ); ?> value="<?php echo esc_attr( $used_type->slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option>
|
637 |
+
<?php
|
638 |
+
}
|
639 |
+
?>
|
640 |
+
</select>
|
641 |
+
<?php
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* The dropdown to filter by location.
|
646 |
+
*
|
647 |
+
* @param string $post_type The post type.
|
648 |
+
*
|
649 |
+
* @return void
|
650 |
+
*/
|
651 |
+
protected function location_dropdown( $post_type ) {
|
652 |
+
if ( ! is_object_in_taxonomy( $post_type, 'wpcode_location' ) ) {
|
653 |
+
return;
|
654 |
+
}
|
655 |
+
|
656 |
+
$used_locations = get_terms(
|
657 |
+
array(
|
658 |
+
'taxonomy' => 'wpcode_location',
|
659 |
+
'hide_empty' => false,
|
660 |
+
)
|
661 |
+
);
|
662 |
+
|
663 |
+
// Return if there are no posts using locations.
|
664 |
+
if ( ! $used_locations ) {
|
665 |
+
return;
|
666 |
+
}
|
667 |
+
|
668 |
+
$displayed_location = isset( $_GET['location'] ) ? absint( $_GET['location'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
669 |
+
?>
|
670 |
+
<label for="filter-by-location" class="screen-reader-text"><?php esc_html_e( 'Filter by location', 'insert-headers-and-footers' ); ?></label>
|
671 |
+
<select name="location" id="filter-by-location">
|
672 |
+
<option<?php selected( $displayed_location, '' ); ?> value=""><?php esc_html_e( 'All locations', 'insert-headers-and-footers' ); ?></option>
|
673 |
+
<?php
|
674 |
+
foreach ( $used_locations as $used_location ) {
|
675 |
+
$pretty_name = wpcode()->auto_insert->get_location_label( $used_location->slug );
|
676 |
+
?>
|
677 |
+
<option<?php selected( $displayed_location, $used_location->term_id ); ?> value="<?php echo esc_attr( $used_location->term_id ); ?>"><?php echo esc_html( $pretty_name ); ?></option>
|
678 |
+
<?php
|
679 |
+
}
|
680 |
+
?>
|
681 |
+
</select>
|
682 |
+
<?php
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
* Get the list of views available on the overview table.
|
687 |
+
*
|
688 |
+
* @return array
|
689 |
+
*/
|
690 |
+
protected function get_views() {
|
691 |
+
$views = array(
|
692 |
+
'all' => $this->view_markup( 'all', __( 'All', 'insert-headers-and-footers' ) ),
|
693 |
+
);
|
694 |
+
if ( $this->count['active'] ) {
|
695 |
+
$views['active'] = $this->view_markup( 'active', __( 'Active', 'insert-headers-and-footers' ) );
|
696 |
+
}
|
697 |
+
if ( $this->count['inactive'] ) {
|
698 |
+
$views['inactive'] = $this->view_markup( 'inactive', __( 'Inactive', 'insert-headers-and-footers' ) );
|
699 |
+
}
|
700 |
+
if ( $this->count['trash'] ) {
|
701 |
+
$views['trash'] = $this->view_markup( 'trash', __( 'Trash', 'insert-headers-and-footers' ) );
|
702 |
+
}
|
703 |
+
|
704 |
+
return $views;
|
705 |
+
}
|
706 |
+
|
707 |
+
/**
|
708 |
+
* Get view link markup for the nav above the table.
|
709 |
+
*
|
710 |
+
* @param string $slug The slug of the view.
|
711 |
+
* @param string $label The label for the view.
|
712 |
+
*
|
713 |
+
* @return string
|
714 |
+
*/
|
715 |
+
private function view_markup( $slug, $label ) {
|
716 |
+
$base_url = remove_query_arg(
|
717 |
+
array(
|
718 |
+
'view',
|
719 |
+
'trashed',
|
720 |
+
'untrashed',
|
721 |
+
'deleted',
|
722 |
+
)
|
723 |
+
);
|
724 |
+
$url = 'all' === $slug ? remove_query_arg( 'view', $base_url ) : add_query_arg( 'view', $slug, $base_url );
|
725 |
+
$class = $this->view === $slug ? ' class="current"' : '';
|
726 |
+
$count = isset( $this->count[ $slug ] ) ? $this->count[ $slug ] : 0;
|
727 |
+
|
728 |
+
return sprintf( '<a href="%1$s"%2$s>%3$s <span class="count">(%4$d)</span></a>', esc_url( $url ), $class, $label, $count );
|
729 |
+
}
|
730 |
+
}
|
includes/auto-insert/class-wpcode-auto-insert-archive.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class to auto-insert snippets on archive pages, taxonomies, etc.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Auto_Insert_Archive.
|
10 |
+
*/
|
11 |
+
class WPCode_Auto_Insert_Archive extends WPCode_Auto_Insert_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Load the available options and labels.
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
public function init() {
|
19 |
+
$this->label = __( 'Categories, Archives, Tags, Taxonomies', 'insert-headers-and-footers' );
|
20 |
+
$this->locations = array(
|
21 |
+
'before_excerpt' => __( 'Insert Before Excerpt', 'insert-headers-and-footers' ),
|
22 |
+
'after_excerpt' => __( 'Insert After Excerpt', 'insert-headers-and-footers' ),
|
23 |
+
'between_posts' => __( 'Between Posts', 'insert-headers-and-footers' ),
|
24 |
+
'archive_before_post' => __( 'Before Post', 'insert-headers-and-footers' ),
|
25 |
+
'archive_after_post' => __( 'After Post', 'insert-headers-and-footers' ),
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Checks if we are on an archive page and we should be executing hooks.
|
31 |
+
*
|
32 |
+
* @return bool
|
33 |
+
*/
|
34 |
+
public function conditions() {
|
35 |
+
return is_archive();
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Add hooks specific to single posts.
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function hooks() {
|
44 |
+
add_filter( 'the_excerpt', array( $this, 'insert_before_excerpt' ) );
|
45 |
+
add_filter( 'the_excerpt', array( $this, 'insert_after_excerpt' ) );
|
46 |
+
add_action( 'the_post', array( $this, 'insert_between_posts' ), 10, 2 );
|
47 |
+
add_action( 'the_post', array( $this, 'insert_before_after_post' ), 10, 2 );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Output snippet before excerpt on archive pages.
|
52 |
+
*
|
53 |
+
* @param string $excerpt The excerpt text.
|
54 |
+
*
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function insert_before_excerpt( $excerpt ) {
|
58 |
+
$snippets = $this->get_snippets_for_location( 'before_excerpt' );
|
59 |
+
|
60 |
+
foreach ( $snippets as $snippet ) {
|
61 |
+
$excerpt = wpcode()->execute->get_snippet_output( $snippet ) . $excerpt;
|
62 |
+
}
|
63 |
+
|
64 |
+
return $excerpt;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Output snippet after excerpt on archive pages.
|
69 |
+
*
|
70 |
+
* @param string $excerpt The excerpt text.
|
71 |
+
*
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function insert_after_excerpt( $excerpt ) {
|
75 |
+
$snippets = $this->get_snippets_for_location( 'after_excerpt' );
|
76 |
+
|
77 |
+
foreach ( $snippets as $snippet ) {
|
78 |
+
$excerpt .= wpcode()->execute->get_snippet_output( $snippet );
|
79 |
+
}
|
80 |
+
|
81 |
+
return $excerpt;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Output snippets between posts in a list of posts.
|
86 |
+
*
|
87 |
+
* @param WP_Post $post_data The post.
|
88 |
+
* @param WP_Query $query The query.
|
89 |
+
*
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
public function insert_between_posts( $post_data, $query ) {
|
93 |
+
// If the query has at least two posts to display snippets between.
|
94 |
+
if ( $query->post_count < 2 ) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
// If the current post is not the first one in the list.
|
98 |
+
if ( $query->current_post < 1 ) {
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
// If the current post is not the last one in the list.
|
102 |
+
if ( $query->post_count <= $query->current_post ) {
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
$snippets = $this->get_snippets_for_location( 'between_posts' );
|
106 |
+
|
107 |
+
foreach ( $snippets as $snippet ) {
|
108 |
+
echo wpcode()->execute->get_snippet_output( $snippet );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Output snippets before or after posts.
|
114 |
+
*
|
115 |
+
* @param WP_Post $post_data The post.
|
116 |
+
* @param WP_Query $query The query.
|
117 |
+
*
|
118 |
+
* @return void
|
119 |
+
*/
|
120 |
+
public function insert_before_after_post( $post_data, $query ) {
|
121 |
+
$snippets = $this->get_snippets_for_location( 'archive_before_post' );
|
122 |
+
|
123 |
+
foreach ( $snippets as $snippet ) {
|
124 |
+
$insert_number = $snippet->get_auto_insert_number();
|
125 |
+
if ( $query->current_post === $insert_number - 1 ) {
|
126 |
+
echo wpcode()->execute->get_snippet_output( $snippet );
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
$snippets = $this->get_snippets_for_location( 'archive_after_post' );
|
131 |
+
|
132 |
+
foreach ( $snippets as $snippet ) {
|
133 |
+
$insert_number = $snippet->get_auto_insert_number();
|
134 |
+
if ( $query->current_post === $insert_number ) {
|
135 |
+
echo wpcode()->execute->get_snippet_output( $snippet );
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
includes/auto-insert/class-wpcode-auto-insert-everywhere.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class to auto-insert snippets site-wide.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Auto_Insert_Single.
|
10 |
+
*/
|
11 |
+
class WPCode_Auto_Insert_Everywhere extends WPCode_Auto_Insert_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* This should is only available for PHP scripts.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $code_type = 'php';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Load the available options and labels.
|
22 |
+
*
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
public function init() {
|
26 |
+
$this->label = __( 'PHP Snippets Only', 'insert-headers-and-footers' );
|
27 |
+
$this->locations = array(
|
28 |
+
'everywhere' => __( 'Run Everywhere', 'insert-headers-and-footers' ),
|
29 |
+
'frontend_only' => __( 'Frontend Only', 'insert-headers-and-footers' ),
|
30 |
+
'admin_only' => __( 'Admin Only', 'insert-headers-and-footers' ),
|
31 |
+
);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Execute snippets.
|
36 |
+
*
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function run_snippets() {
|
40 |
+
$snippets = $this->get_snippets_for_location( 'everywhere' );
|
41 |
+
foreach ( $snippets as $snippet ) {
|
42 |
+
wpcode()->execute->get_snippet_output( $snippet );
|
43 |
+
}
|
44 |
+
$location = is_admin() ? 'admin_only' : 'frontend_only';
|
45 |
+
$snippets = $this->get_snippets_for_location( $location );
|
46 |
+
foreach ( $snippets as $snippet ) {
|
47 |
+
wpcode()->execute->get_snippet_output( $snippet );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Override the default hook and short-circuit any other conditions
|
53 |
+
* checks as these snippets will run everywhere.
|
54 |
+
*
|
55 |
+
* @return void
|
56 |
+
*/
|
57 |
+
protected function add_start_hook() {
|
58 |
+
add_action( 'init', array( $this, 'run_snippets' ), - 1 );
|
59 |
+
}
|
60 |
+
}
|
includes/auto-insert/class-wpcode-auto-insert-single.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class to auto-insert snippets on single posts.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Auto_Insert_Single.
|
10 |
+
*/
|
11 |
+
class WPCode_Auto_Insert_Single extends WPCode_Auto_Insert_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Used to make sure we only output the before post code once.
|
15 |
+
*
|
16 |
+
* @var bool
|
17 |
+
*/
|
18 |
+
private $did_before_post_output = false;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Load the available options and labels.
|
22 |
+
*
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
public function init() {
|
26 |
+
$this->label = __( 'Page, Post, Custom Post Type', 'insert-headers-and-footers' );
|
27 |
+
$this->locations = array(
|
28 |
+
'before_post' => __( 'Insert Before Post', 'insert-headers-and-footers' ),
|
29 |
+
'after_post' => __( 'Insert After Post', 'insert-headers-and-footers' ),
|
30 |
+
'before_content' => __( 'Insert Before Content', 'insert-headers-and-footers' ),
|
31 |
+
'after_content' => __( 'Insert After Content', 'insert-headers-and-footers' ),
|
32 |
+
'before_paragraph' => __( 'Insert Before Paragraph', 'insert-headers-and-footers' ),
|
33 |
+
'after_paragraph' => __( 'Insert After Paragraph', 'insert-headers-and-footers' ),
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Checks if we are on a singular page and we should be executing hooks.
|
39 |
+
*
|
40 |
+
* @return bool
|
41 |
+
*/
|
42 |
+
public function conditions() {
|
43 |
+
return is_singular();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Add hooks specific to single posts.
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function hooks() {
|
52 |
+
add_action( 'the_post', array( $this, 'insert_before_post' ) );
|
53 |
+
add_filter( 'render_block_core/template-part', array( $this, 'insert_before_post_fse' ), 15, 2 );
|
54 |
+
add_action( 'the_content', array( $this, 'insert_after_post' ) );
|
55 |
+
add_filter( 'the_content', array( $this, 'insert_before_content' ) );
|
56 |
+
add_filter( 'the_content', array( $this, 'insert_after_content' ) );
|
57 |
+
add_filter( 'the_content', array( $this, 'insert_after_before_paragraph' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Insert snippet before the post.
|
62 |
+
*
|
63 |
+
* @param WP_Post $post_object The post object being loaded.
|
64 |
+
*
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
public function insert_before_post( $post_object ) {
|
68 |
+
if ( ! did_action( 'get_header' ) || get_the_ID() !== $post_object->ID || $this->did_before_post_output ) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
$snippets = $this->get_snippets_for_location( 'before_post' );
|
72 |
+
foreach ( $snippets as $snippet ) {
|
73 |
+
echo wpcode()->execute->get_snippet_output( $snippet );
|
74 |
+
}
|
75 |
+
$this->did_before_post_output = true;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* In FSE themes there's no "get_header" action to check for, so we hook after the core template-part header block.
|
80 |
+
*
|
81 |
+
* @param string $block_content The normal block HTML that would be sent to the screen.
|
82 |
+
* @param array $block An array of data about the block, and the way the user configured it.
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function insert_before_post_fse( $block_content, $block ) {
|
87 |
+
// If the get_header action ran we use the classic output method above.
|
88 |
+
if ( did_action( 'get_header' ) ) {
|
89 |
+
return $block_content;
|
90 |
+
}
|
91 |
+
if ( ! isset( $block['attrs']['slug'] ) || 'header' !== $block['attrs']['slug'] ) {
|
92 |
+
return $block_content;
|
93 |
+
}
|
94 |
+
$before_post = '';
|
95 |
+
$snippets = $this->get_snippets_for_location( 'before_post' );
|
96 |
+
foreach ( $snippets as $snippet ) {
|
97 |
+
$before_post .= wpcode()->execute->get_snippet_output( $snippet );
|
98 |
+
}
|
99 |
+
|
100 |
+
return $block_content . $before_post;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Insert snippet output after the content.
|
105 |
+
*
|
106 |
+
* @param string $content The content of the post.
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
+
public function insert_after_content( $content ) {
|
111 |
+
$snippets = $this->get_snippets_for_location( 'after_content' );
|
112 |
+
foreach ( $snippets as $snippet ) {
|
113 |
+
$content .= wpcode()->execute->get_snippet_output( $snippet );
|
114 |
+
}
|
115 |
+
|
116 |
+
return $content;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Insert snippet after the post
|
121 |
+
*
|
122 |
+
* @param string $content The post content.
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
+
public function insert_after_post( $content ) {
|
127 |
+
$snippets = $this->get_snippets_for_location( 'after_post' );
|
128 |
+
foreach ( $snippets as $snippet ) {
|
129 |
+
$content .= wpcode()->execute->get_snippet_output( $snippet );
|
130 |
+
}
|
131 |
+
|
132 |
+
return $content;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Insert snippets before the content.
|
137 |
+
*
|
138 |
+
* @param string $content The post content.
|
139 |
+
*
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
public function insert_before_content( $content ) {
|
143 |
+
$snippets = $this->get_snippets_for_location( 'before_content' );
|
144 |
+
$snippets_output = '';
|
145 |
+
foreach ( $snippets as $snippet ) {
|
146 |
+
$snippets_output .= wpcode()->execute->get_snippet_output( $snippet );
|
147 |
+
}
|
148 |
+
|
149 |
+
return $snippets_output . $content;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Insert content before or after paragraphs based on settings.
|
154 |
+
*
|
155 |
+
* @param string $content The post content.
|
156 |
+
*
|
157 |
+
* @return string
|
158 |
+
*/
|
159 |
+
public function insert_after_before_paragraph( $content ) {
|
160 |
+
|
161 |
+
$snippets = $this->get_snippets_for_location( 'before_paragraph' );
|
162 |
+
foreach ( $snippets as $snippet ) {
|
163 |
+
$auto_insert_number = $snippet->get_auto_insert_number();
|
164 |
+
$auto_insert_number = empty( $auto_insert_number ) ? 1 : absint( $auto_insert_number );
|
165 |
+
$snippet_output = wpcode()->execute->get_snippet_output( $snippet );
|
166 |
+
$content = $this->insert_between_paragraphs( $snippet_output, $auto_insert_number, $content, 'before' );
|
167 |
+
}
|
168 |
+
|
169 |
+
$snippets = $this->get_snippets_for_location( 'after_paragraph' );
|
170 |
+
foreach ( $snippets as $snippet ) {
|
171 |
+
$auto_insert_number = $snippet->get_auto_insert_number();
|
172 |
+
$auto_insert_number = empty( $auto_insert_number ) ? 1 : absint( $auto_insert_number );
|
173 |
+
$snippet_output = wpcode()->execute->get_snippet_output( $snippet );
|
174 |
+
$content = $this->insert_between_paragraphs( $snippet_output, $auto_insert_number, $content, 'after' );
|
175 |
+
}
|
176 |
+
|
177 |
+
return $content;
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Insert snippet code before or after paragraphs in a post.
|
183 |
+
*
|
184 |
+
* @param string $content_to_insert The content to insert (snippet code output).
|
185 |
+
* @param int $p_number The paragraph number.
|
186 |
+
* @param string $content_to_add_to The content in which the content should be added.
|
187 |
+
* @param string $before_or_after Add it before or after the paragraph.
|
188 |
+
*
|
189 |
+
* @return string
|
190 |
+
*/
|
191 |
+
public function insert_between_paragraphs( $content_to_insert, $p_number, $content_to_add_to, $before_or_after = 'after' ) {
|
192 |
+
if ( 'before' === $before_or_after ) {
|
193 |
+
preg_match_all( '/<p(.*?)>/', $content_to_add_to, $matches );
|
194 |
+
} else {
|
195 |
+
preg_match_all( '/<\/p>/', $content_to_add_to, $matches );
|
196 |
+
}
|
197 |
+
$paragraphs = $matches[0];
|
198 |
+
|
199 |
+
// We don't have enough paragraphs to add the snippet.
|
200 |
+
if ( count( $paragraphs ) < $p_number ) {
|
201 |
+
return $content_to_add_to;
|
202 |
+
}
|
203 |
+
|
204 |
+
$p_number = -- $p_number;
|
205 |
+
$offset = 0;
|
206 |
+
foreach ( $paragraphs as $p_index => $p ) {
|
207 |
+
$position = strpos( $content_to_add_to, $p, $offset );
|
208 |
+
if ( $p_index === $p_number ) {
|
209 |
+
if ( 'before' === $before_or_after ) {
|
210 |
+
$content_to_add_to = substr( $content_to_add_to, 0, $position ) . $content_to_insert . substr( $content_to_add_to, $position );
|
211 |
+
} else {
|
212 |
+
$content_to_add_to = substr( $content_to_add_to, 0, $position + 4 ) . $content_to_insert . substr( $content_to_add_to, $position + 4 );
|
213 |
+
}
|
214 |
+
break;
|
215 |
+
} else {
|
216 |
+
$offset = $position + 1;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
return $content_to_add_to;
|
221 |
+
}
|
222 |
+
}
|
includes/auto-insert/class-wpcode-auto-insert-site-wide.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class to auto-insert snippets site-wide.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Auto_Insert_Single.
|
10 |
+
*/
|
11 |
+
class WPCode_Auto_Insert_Site_Wide extends WPCode_Auto_Insert_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Load the available options and labels.
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
public function init() {
|
19 |
+
$this->label = __( 'Site wide', 'insert-headers-and-footers' );
|
20 |
+
$this->locations = array(
|
21 |
+
'site_wide_header' => __( 'Site Wide Header', 'insert-headers-and-footers' ),
|
22 |
+
'site_wide_body' => __( 'Site Wide Body', 'insert-headers-and-footers' ),
|
23 |
+
'site_wide_footer' => __( 'Site Wide Footer', 'insert-headers-and-footers' ),
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Add hooks specific to this type.
|
29 |
+
*
|
30 |
+
* @return void
|
31 |
+
*/
|
32 |
+
public function hooks() {
|
33 |
+
add_action( 'wp_head', array( $this, 'insert_header' ) );
|
34 |
+
add_action( 'wp_footer', array( $this, 'insert_footer' ) );
|
35 |
+
add_action( 'wp_body_open', array( $this, 'insert_body' ) );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Insert snippets in the header.
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
public function insert_header() {
|
44 |
+
$snippets = $this->get_snippets_for_location( 'site_wide_header' );
|
45 |
+
foreach ( $snippets as $snippet ) {
|
46 |
+
echo wpcode()->execute->get_snippet_output( $snippet );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Insert snippets in the footer.
|
52 |
+
*
|
53 |
+
* @return void
|
54 |
+
*/
|
55 |
+
public function insert_footer() {
|
56 |
+
$snippets = $this->get_snippets_for_location( 'site_wide_footer' );
|
57 |
+
foreach ( $snippets as $snippet ) {
|
58 |
+
echo wpcode()->execute->get_snippet_output( $snippet );
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Insert snippets after the opening body tag.
|
64 |
+
*
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
public function insert_body() {
|
68 |
+
$snippets = $this->get_snippets_for_location( 'site_wide_body' );
|
69 |
+
foreach ( $snippets as $snippet ) {
|
70 |
+
echo wpcode()->execute->get_snippet_output( $snippet );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
includes/auto-insert/class-wpcode-auto-insert-type.php
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Base class for of auto-insert options.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Abstract class WPCode_Auto_Insert_Type.
|
10 |
+
*/
|
11 |
+
abstract class WPCode_Auto_Insert_Type {
|
12 |
+
/**
|
13 |
+
* The auto-insert label.
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
public $label;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* An array of locations.
|
21 |
+
* This is an array of unique locations where snippets can be executed in the form
|
22 |
+
* of key => label where the keys should be unique for all the options across
|
23 |
+
* all child classes as those will be used as taxonomy terms to store the
|
24 |
+
* relationship between snippets and their location.
|
25 |
+
*
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
public $locations;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Terms of the locations for this type.
|
32 |
+
*
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
public $locations_terms;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* All the snippets for this location.
|
39 |
+
*
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
public $snippets;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* For which code type this insert is available.
|
46 |
+
* By default, all.
|
47 |
+
*
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
public $code_type = 'all';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* If we should skip the cache set this to false.
|
54 |
+
*
|
55 |
+
* @var bool
|
56 |
+
*/
|
57 |
+
protected $use_cache = true;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Start the auto insertion.
|
61 |
+
*/
|
62 |
+
public function __construct() {
|
63 |
+
$this->init();
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Constant to enable safe mode.
|
67 |
+
* Filter to allow disabling auto insert.
|
68 |
+
*/
|
69 |
+
if ( defined( 'WPCODE_SAFE_MODE' ) && WPCODE_SAFE_MODE ) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
if ( ! apply_filters( 'wpcode_do_auto_insert', true ) ) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->add_start_hook();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Init function that is specific to each auto-insert type.
|
81 |
+
*
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
abstract public function init();
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Give child classes a chance to load on a different hook.
|
88 |
+
*
|
89 |
+
* @return void
|
90 |
+
*/
|
91 |
+
protected function add_start_hook() {
|
92 |
+
add_action( 'wp', array( $this, 'maybe_run_hooks' ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Check if conditions are met before calling the hooks.
|
97 |
+
*
|
98 |
+
* @return void
|
99 |
+
*/
|
100 |
+
public function maybe_run_hooks() {
|
101 |
+
if ( ! $this->conditions() ) {
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
// Go through relevant hooks and output based on settings.
|
105 |
+
$this->hooks();
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Conditions that have to be met for the class to do its thing.
|
110 |
+
* For example, in the single post class we'll check if is_single
|
111 |
+
* and only then will we change the_content.
|
112 |
+
*
|
113 |
+
* @return bool
|
114 |
+
*/
|
115 |
+
public function conditions() {
|
116 |
+
// Most types only run on the frontend.
|
117 |
+
return ! is_admin();
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Hooks specific to this type of auto-insertion.
|
122 |
+
*
|
123 |
+
* @return void
|
124 |
+
*/
|
125 |
+
public function hooks() {
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get an array of options for the admin.
|
130 |
+
* Check if the insert type is compatible with the code type.
|
131 |
+
*
|
132 |
+
* @return array
|
133 |
+
*/
|
134 |
+
public function get_locations() {
|
135 |
+
return isset( $this->locations ) ? $this->locations : array();
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Query snippets by location.
|
140 |
+
*
|
141 |
+
* @param string $location The location slug.
|
142 |
+
*
|
143 |
+
* @return WPCode_Snippet[]
|
144 |
+
*/
|
145 |
+
public function get_snippets_for_location( $location ) {
|
146 |
+
$snippets = $this->get_snippets();
|
147 |
+
|
148 |
+
$snippets_for_location = isset( $snippets[ $location ] ) ? $snippets[ $location ] : array();
|
149 |
+
|
150 |
+
return wpcode()->conditional_logic->check_snippets_conditions( $snippets_for_location );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Get the snippets for this type and query on demand.
|
155 |
+
*
|
156 |
+
* @return array
|
157 |
+
*/
|
158 |
+
public function get_snippets() {
|
159 |
+
if ( ! isset( $this->snippets ) ) {
|
160 |
+
$this->load_all_snippets_for_type();
|
161 |
+
}
|
162 |
+
|
163 |
+
return $this->snippets;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Load all the snippets for this type and group them by location.
|
168 |
+
* This can be further improved by separating the snippet loading and loading
|
169 |
+
* all the relevant snippets for a screen at once (regardless of type) or just loading all the
|
170 |
+
* active snippets in 1 query.
|
171 |
+
*
|
172 |
+
* @return void
|
173 |
+
*/
|
174 |
+
public function load_all_snippets_for_type() {
|
175 |
+
|
176 |
+
if ( $this->use_cache() ) {
|
177 |
+
$this->snippets = $this->get_snippets_from_cache();
|
178 |
+
|
179 |
+
return;
|
180 |
+
}
|
181 |
+
|
182 |
+
$terms = $this->get_locations_ids();
|
183 |
+
if ( empty( $terms ) ) {
|
184 |
+
// If no terms are yet set we don't have to load anything as
|
185 |
+
// no snippet has been added to the current type.
|
186 |
+
$this->snippets = array();
|
187 |
+
|
188 |
+
return;
|
189 |
+
}
|
190 |
+
$args = array(
|
191 |
+
'post_type' => 'wpcode',
|
192 |
+
'posts_per_page' => - 1,
|
193 |
+
'tax_query' => array( //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
|
194 |
+
array(
|
195 |
+
'taxonomy' => 'wpcode_location',
|
196 |
+
'terms' => $terms,
|
197 |
+
),
|
198 |
+
),
|
199 |
+
'post_status' => 'publish',
|
200 |
+
);
|
201 |
+
add_filter( 'posts_clauses', array( $this, 'include_term_in_post' ) );
|
202 |
+
$snippets_query = new WP_Query( $args );
|
203 |
+
remove_filter( 'posts_clauses', array( $this, 'include_term_in_post' ) );
|
204 |
+
$snippets = $snippets_query->posts;
|
205 |
+
|
206 |
+
// Get the terms that are defined and then assign found snippets to their respective taxonomies
|
207 |
+
// so that they can be picked up by id later without having to query again.
|
208 |
+
$location_terms = $this->get_location_terms();
|
209 |
+
foreach ( $location_terms as $location_key => $location_term ) {
|
210 |
+
$term_id = $location_term->term_id;
|
211 |
+
$this->snippets[ $location_key ] = array();
|
212 |
+
// Until we update to PHP 5.3 this is the easiest way to do this.
|
213 |
+
foreach ( $snippets as $snippet ) {
|
214 |
+
if ( isset( $snippet->term_taxonomy_id ) && absint( $snippet->term_taxonomy_id ) === $term_id ) {
|
215 |
+
$this->snippets[ $location_key ][] = new WPCode_Snippet( $snippet );
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Get snippets from cache split by relevant locations for this type.
|
223 |
+
*
|
224 |
+
* @return array
|
225 |
+
*/
|
226 |
+
public function get_snippets_from_cache() {
|
227 |
+
$cached_snippets = wpcode()->cache->get_cached_snippets();
|
228 |
+
$type_snippets = array();
|
229 |
+
foreach ( $this->locations as $location => $label ) {
|
230 |
+
if ( array_key_exists( $location, $cached_snippets ) ) {
|
231 |
+
$type_snippets[ $location ] = $cached_snippets[ $location ];
|
232 |
+
} else {
|
233 |
+
$type_snippets[ $location ] = array();
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
return $type_snippets;
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Get the ids of the loaded location terms.
|
242 |
+
*
|
243 |
+
* @return int[]
|
244 |
+
*/
|
245 |
+
public function get_locations_ids() {
|
246 |
+
$terms = $this->get_location_terms();
|
247 |
+
$ids = array();
|
248 |
+
foreach ( $terms as $term ) {
|
249 |
+
$ids[] = $term->term_id;
|
250 |
+
}
|
251 |
+
|
252 |
+
return $ids;
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Get the location terms.
|
257 |
+
*
|
258 |
+
* @return WP_Term[]
|
259 |
+
*/
|
260 |
+
public function get_location_terms() {
|
261 |
+
if ( ! isset( $this->locations_terms ) ) {
|
262 |
+
$this->load_locations_terms();
|
263 |
+
}
|
264 |
+
|
265 |
+
return $this->locations_terms;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Query the location terms using get_terms and store them in the instance.
|
270 |
+
*
|
271 |
+
* @return void
|
272 |
+
*/
|
273 |
+
public function load_locations_terms() {
|
274 |
+
$terms = get_terms(
|
275 |
+
array(
|
276 |
+
'taxonomy' => 'wpcode_location',
|
277 |
+
'slug' => array_keys( $this->locations ),
|
278 |
+
)
|
279 |
+
);
|
280 |
+
|
281 |
+
$this->locations_terms = array();
|
282 |
+
|
283 |
+
if ( is_wp_error( $terms ) ) {
|
284 |
+
// If the terms don't exist, bail early.
|
285 |
+
return;
|
286 |
+
}
|
287 |
+
|
288 |
+
foreach ( $terms as $term ) {
|
289 |
+
$this->locations_terms[ $term->slug ] = $term;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Change the clauses for our specific query to include the term id in the resulting
|
295 |
+
* WP_Post object so that we can group the results by the type locations.
|
296 |
+
*
|
297 |
+
* @param array $clauses Array of clauses for the SQL query.
|
298 |
+
*
|
299 |
+
* @return mixed
|
300 |
+
*/
|
301 |
+
public function include_term_in_post( $clauses ) {
|
302 |
+
global $wpdb;
|
303 |
+
|
304 |
+
$clauses['fields'] .= ", {$wpdb->term_relationships}.term_taxonomy_id";
|
305 |
+
$clauses['groupby'] = '';
|
306 |
+
|
307 |
+
return $clauses;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Return the type label.
|
312 |
+
*
|
313 |
+
* @return string
|
314 |
+
*/
|
315 |
+
public function get_label() {
|
316 |
+
return $this->label;
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Grab the use cache value allowing filtering.
|
321 |
+
*
|
322 |
+
* @return bool
|
323 |
+
*/
|
324 |
+
public function use_cache() {
|
325 |
+
return boolval( apply_filters( 'wpcode_use_auto_insert_cache', $this->use_cache ) );
|
326 |
+
}
|
327 |
+
}
|
includes/class-wpcode-auto-insert.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Central handler of auto-inserting snippets.
|
4 |
+
* Loads the different types and processes them.
|
5 |
+
*
|
6 |
+
* @package WPCode
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class WPCode_Auto_Insert.
|
11 |
+
*/
|
12 |
+
class WPCode_Auto_Insert {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The auto-insert types.
|
16 |
+
*
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
public $types = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructor.
|
23 |
+
*/
|
24 |
+
public function __construct() {
|
25 |
+
$this->hooks();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Add hooks.
|
30 |
+
*
|
31 |
+
* @return void
|
32 |
+
*/
|
33 |
+
private function hooks() {
|
34 |
+
add_action( 'plugins_loaded', array( $this, 'load_types' ), 1 );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Load and initialize the different types of auto-insert types.
|
39 |
+
*
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function load_types() {
|
43 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/auto-insert/class-wpcode-auto-insert-type.php';
|
44 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/auto-insert/class-wpcode-auto-insert-everywhere.php';
|
45 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/auto-insert/class-wpcode-auto-insert-site-wide.php';
|
46 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/auto-insert/class-wpcode-auto-insert-single.php';
|
47 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/auto-insert/class-wpcode-auto-insert-archive.php';
|
48 |
+
|
49 |
+
$this->types[] = new WPCode_Auto_Insert_Everywhere();
|
50 |
+
$this->types[] = new WPCode_Auto_Insert_Site_Wide();
|
51 |
+
$this->types[] = new WPCode_Auto_Insert_Single();
|
52 |
+
$this->types[] = new WPCode_Auto_Insert_Archive();
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Get the types of auto-insert options.
|
57 |
+
*
|
58 |
+
* @return WPCode_Auto_Insert_Type[]
|
59 |
+
*/
|
60 |
+
public function get_types() {
|
61 |
+
return $this->types;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Get a location label from the class not the term.
|
66 |
+
*
|
67 |
+
* @param string $location The location slug/name.
|
68 |
+
*
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function get_location_label( $location ) {
|
72 |
+
foreach ( $this->types as $type ) {
|
73 |
+
/**
|
74 |
+
* Added for convenience.
|
75 |
+
*
|
76 |
+
* @var WPCode_Auto_Insert_Type $type
|
77 |
+
*/
|
78 |
+
if ( isset( $type->locations[ $location ] ) ) {
|
79 |
+
return $type->locations[ $location ];
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
return '';
|
84 |
+
}
|
85 |
+
}
|
includes/class-wpcode-capabilities.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Manage custom capabilities for WPCode.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The WPCode_Capabilities class.
|
10 |
+
*/
|
11 |
+
class WPCode_Capabilities {
|
12 |
+
/**
|
13 |
+
* Function to call on plugin activation.
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
public static function add_capabilities() {
|
18 |
+
|
19 |
+
foreach ( self::get_roles() as $role ) {
|
20 |
+
if ( $role->has_cap( 'manage_options' ) ) {
|
21 |
+
$role->add_cap( 'wpcode_edit_snippets' );
|
22 |
+
$role->add_cap( 'wpcode_activate_snippets' );
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get roles as WP_Role objects.
|
30 |
+
*
|
31 |
+
* @return WP_Role[]
|
32 |
+
*/
|
33 |
+
public static function get_roles() {
|
34 |
+
$roles = get_editable_roles();
|
35 |
+
$role_array = array();
|
36 |
+
foreach ( array_keys( $roles ) as $role_key ) {
|
37 |
+
$role_array[] = get_role( $role_key );
|
38 |
+
}
|
39 |
+
|
40 |
+
return $role_array;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Remove custom capabilities.
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
public static function uninstall() {
|
49 |
+
foreach ( self::get_roles() as $role ) {
|
50 |
+
if ( $role->has_cap( 'wpcode_edit_snippets' ) ) {
|
51 |
+
$role->remove_cap( 'wpcode_edit_snippets' );
|
52 |
+
}
|
53 |
+
if ( $role->has_cap( 'wpcode_activate_snippets' ) ) {
|
54 |
+
$role->remove_cap( 'wpcode_activate_snippets' );
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
includes/class-wpcode-conditional-logic.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handle logic for the conditional loading of snippets.
|
4 |
+
* You'll find here the available logic options and how they apply to snippets.
|
5 |
+
*
|
6 |
+
* @package WPCode
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* The main conditional logic class that loads all the types.
|
11 |
+
*/
|
12 |
+
class WPCode_Conditional_Logic {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Types of conditional logic.
|
16 |
+
*
|
17 |
+
* @var WPCode_Conditional_Type[]
|
18 |
+
*/
|
19 |
+
private $types = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructor.
|
23 |
+
*/
|
24 |
+
public function __construct() {
|
25 |
+
add_action( 'plugins_loaded', array( $this, 'load_types' ), 0 );
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Load the different conditional logic types.
|
30 |
+
*
|
31 |
+
* @return void
|
32 |
+
*/
|
33 |
+
public function load_types() {
|
34 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/conditional-logic/class-wpcode-conditional-type.php';
|
35 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/conditional-logic/class-wpcode-conditional-user.php';
|
36 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/conditional-logic/class-wpcode-conditional-page.php';
|
37 |
+
|
38 |
+
$this->types['user'] = new WPCode_Conditional_User();
|
39 |
+
$this->types['page'] = new WPCode_Conditional_Page();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Get all the admin options for the conditional logic form.
|
44 |
+
*
|
45 |
+
* @return array
|
46 |
+
*/
|
47 |
+
public function get_all_admin_options() {
|
48 |
+
$options = array();
|
49 |
+
foreach ( $this->types as $type ) {
|
50 |
+
$options[ $type->get_name() ] = array(
|
51 |
+
'label' => $type->get_label(),
|
52 |
+
'name' => $type->get_name(),
|
53 |
+
'options' => $type->get_type_options(),
|
54 |
+
);
|
55 |
+
}
|
56 |
+
|
57 |
+
return $options;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Goes through a list of snippets and filters out the ones
|
62 |
+
* that don't match the conditional logic rules.
|
63 |
+
*
|
64 |
+
* @param WPCode_Snippet[] $snippets An array of snippets.
|
65 |
+
*
|
66 |
+
* @return WPCode_Snippet[]
|
67 |
+
*/
|
68 |
+
public function check_snippets_conditions( $snippets ) {
|
69 |
+
// If there's nothing to evaluate just return an empty array.
|
70 |
+
if ( empty( $snippets ) ) {
|
71 |
+
return array();
|
72 |
+
}
|
73 |
+
|
74 |
+
$filtered_snippets = array();
|
75 |
+
foreach ( $snippets as $snippet ) {
|
76 |
+
if ( ! $snippet->conditional_rules_enabled() ) {
|
77 |
+
// If rules are disabled, ignore.
|
78 |
+
$filtered_snippets[] = $snippet;
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
$rules = $snippet->get_conditional_rules();
|
82 |
+
if ( ! isset( $rules['show'] ) ) {
|
83 |
+
continue;
|
84 |
+
}
|
85 |
+
$show = 'show' === $rules['show'];
|
86 |
+
$rules_are_met = $this->are_snippet_rules_met( $snippet );
|
87 |
+
if ( $show && ! $rules_are_met ) {
|
88 |
+
// If we should show based on conditions, and conditions
|
89 |
+
// are not met, skip.
|
90 |
+
continue;
|
91 |
+
}
|
92 |
+
if ( ! $show && $rules_are_met ) {
|
93 |
+
// If we should hide based on conditions, and conditions
|
94 |
+
// are met, skip.
|
95 |
+
continue;
|
96 |
+
}
|
97 |
+
|
98 |
+
$filtered_snippets[] = $snippet;
|
99 |
+
}
|
100 |
+
|
101 |
+
return $filtered_snippets;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Takes a snippet and evaluates if conditional logic rules
|
106 |
+
* are met.
|
107 |
+
*
|
108 |
+
* @param WPCode_Snippet $snippet The snippet instance.
|
109 |
+
*
|
110 |
+
* @return bool
|
111 |
+
*/
|
112 |
+
public function are_snippet_rules_met( $snippet ) {
|
113 |
+
$rules = $snippet->get_conditional_rules();
|
114 |
+
if ( empty( $rules ) || ! is_array( $rules ) || empty( $rules['groups'] ) ) {
|
115 |
+
return true;
|
116 |
+
}
|
117 |
+
|
118 |
+
// Go through all rule groups.
|
119 |
+
foreach ( $rules['groups'] as $rule_group ) {
|
120 |
+
// If any of the groups are met return true.
|
121 |
+
if ( $this->are_group_rules_met( $rule_group ) ) {
|
122 |
+
return true;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
// If no group rules satisfy the conditions, return false.
|
127 |
+
return false;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Evaluate all the rows of rules in a group.
|
132 |
+
*
|
133 |
+
* @param array $rule_group An array of rows.
|
134 |
+
*
|
135 |
+
* @return bool
|
136 |
+
*/
|
137 |
+
public function are_group_rules_met( $rule_group ) {
|
138 |
+
foreach ( $rule_group as $rule_row ) {
|
139 |
+
if ( ! isset( $rule_row['type'] ) ) {
|
140 |
+
continue;
|
141 |
+
}
|
142 |
+
$rule_type = $this->types[ $rule_row['type'] ];
|
143 |
+
if ( ! $rule_type->evaluate_rule_row( $rule_row ) ) {
|
144 |
+
// If this row doesn't match, the whole group fails.
|
145 |
+
return false;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
// If none of the rows failed the group matches.
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
}
|
includes/class-wpcode-error.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This class handles PHP errors, keeping tabs of errors thrown
|
4 |
+
* and the messages displayed back to the user.
|
5 |
+
*
|
6 |
+
* @package wpcode
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* WPCode_Error class.
|
11 |
+
*/
|
12 |
+
class WPCode_Error {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* An array of errors already caught.
|
16 |
+
*
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
private $errors = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* The error object caught when running the code.
|
23 |
+
*
|
24 |
+
* @param ParseError|Exception|Error|array $error The caught error.
|
25 |
+
*
|
26 |
+
* @return void
|
27 |
+
*/
|
28 |
+
public function add_error( $error ) {
|
29 |
+
$this->errors[] = $error;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Check if an error has been recorded.
|
34 |
+
*
|
35 |
+
* @return bool
|
36 |
+
*/
|
37 |
+
public function has_error() {
|
38 |
+
return ! empty( $this->errors );
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Empty the errors record, useful if you want to
|
43 |
+
* make sure the last error was thrown by your code.
|
44 |
+
*
|
45 |
+
* @return void
|
46 |
+
*/
|
47 |
+
public function clear_errors() {
|
48 |
+
$this->errors = array();
|
49 |
+
}
|
50 |
+
|
51 |
+
private function store_error() {
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Get the last error message.
|
57 |
+
*
|
58 |
+
* @return string
|
59 |
+
*/
|
60 |
+
public function get_last_error_message() {
|
61 |
+
if ( empty( $this->errors ) ) {
|
62 |
+
return '';
|
63 |
+
}
|
64 |
+
$last_error = end( $this->errors );
|
65 |
+
|
66 |
+
if ( method_exists( $last_error, 'getMessage' ) ) {
|
67 |
+
return $last_error->getMessage();
|
68 |
+
}
|
69 |
+
|
70 |
+
if ( is_array( $last_error ) && isset( $last_error['message'] ) ) {
|
71 |
+
return $last_error['message'];
|
72 |
+
}
|
73 |
+
|
74 |
+
return '';
|
75 |
+
}
|
76 |
+
}
|
includes/class-wpcode-file-cache.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File cache class. Store files in the uploads folder.
|
4 |
+
* Use the expiration in the get function to control how often a file should be refreshed.
|
5 |
+
*
|
6 |
+
* @package WPCode
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* WPCode_File_Cache class.
|
11 |
+
*/
|
12 |
+
class WPCode_File_Cache {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Name of the folder in the Uploads folder.
|
16 |
+
*
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
private $dirname = 'wpcode/cache';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Full upload path, created form the WP uploads folder.
|
23 |
+
*
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
private $upload_path;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Write a file to the server with an expiration date.
|
30 |
+
*
|
31 |
+
* @param string $name The key by which to retrieve the data.
|
32 |
+
* @param mixed $data The data to save - if it's a JSON it should be decoded first as it gets encoded here.
|
33 |
+
*
|
34 |
+
* @return void
|
35 |
+
*/
|
36 |
+
public function set( $name, $data ) {
|
37 |
+
$this->write_file( $this->get_cache_filename_by_key( $name ), wp_json_encode( $data ) );
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get some data by its name. Checks if the data is expired and if so
|
42 |
+
* returns false so you can update it.
|
43 |
+
*
|
44 |
+
* @param string $name The key of the data to save.
|
45 |
+
* @param int $ttl For how long since creation should this file be used.
|
46 |
+
*
|
47 |
+
* @return array|false
|
48 |
+
*/
|
49 |
+
public function get( $name, $ttl = 0 ) {
|
50 |
+
$file = $this->get_directory_path( $this->get_cache_filename_by_key( $name ) );
|
51 |
+
|
52 |
+
// If the file doesn't exist there's not much to do.
|
53 |
+
if ( ! file_exists( $file ) ) {
|
54 |
+
return false;
|
55 |
+
}
|
56 |
+
|
57 |
+
// If TTL is 0, always return the file.
|
58 |
+
if ( $ttl > 0 && (int) filemtime( $file ) + $ttl < time() ) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
return json_decode( file_get_contents( $file ), true ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Basically just adds JSON to the end of the key but we should use this
|
67 |
+
* to also make sure it's a proper filename.
|
68 |
+
*
|
69 |
+
* @param string $name The key.
|
70 |
+
*
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
private function get_cache_filename_by_key( $name ) {
|
74 |
+
return $name . '.json';
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Write a file to the cache folder. Data should already be processed when using this.
|
79 |
+
*
|
80 |
+
* @param string $name The name of the file.
|
81 |
+
* @param string $data The data to write to the file.
|
82 |
+
*
|
83 |
+
* @return void
|
84 |
+
*/
|
85 |
+
private function write_file( $name, $data ) {
|
86 |
+
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_file_put_contents
|
87 |
+
file_put_contents( $this->get_directory_path( $name ), $data );
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get a reliable path to write files to, it also creates the folders needed if they don't exist.
|
92 |
+
*
|
93 |
+
* @param string $filename The file path.
|
94 |
+
*
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
private function get_directory_path( $filename ) {
|
98 |
+
if ( ! isset( $this->upload_path ) ) {
|
99 |
+
$uploads = wp_upload_dir();
|
100 |
+
$this->upload_path = trailingslashit( $uploads['basedir'] ) . $this->dirname;
|
101 |
+
|
102 |
+
if ( ! file_exists( $this->upload_path ) || ! wp_is_writable( $this->upload_path ) ) {
|
103 |
+
wp_mkdir_p( $this->upload_path );
|
104 |
+
$this->create_index_html_file( $this->upload_path );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
$filepath = trailingslashit( $this->upload_path ) . $filename;
|
109 |
+
$directory = dirname( $filepath );
|
110 |
+
if ( $directory !== $this->upload_path && ! file_exists( $directory ) ) {
|
111 |
+
wp_mkdir_p( $directory );
|
112 |
+
$this->create_index_html_file( $directory );
|
113 |
+
}
|
114 |
+
|
115 |
+
return $filepath;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Create index.html file in the specified directory if it doesn't exist.
|
120 |
+
*
|
121 |
+
* @param string $path The path to the directory.
|
122 |
+
*
|
123 |
+
* @return false|int
|
124 |
+
*/
|
125 |
+
public static function create_index_html_file( $path ) {
|
126 |
+
if ( ! is_dir( $path ) || is_link( $path ) ) {
|
127 |
+
return false;
|
128 |
+
}
|
129 |
+
|
130 |
+
$index_file = wp_normalize_path( trailingslashit( $path ) . 'index.html' );
|
131 |
+
|
132 |
+
// Do nothing if index.html exists in the directory.
|
133 |
+
if ( file_exists( $index_file ) ) {
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
|
137 |
+
// Create empty index.html.
|
138 |
+
return file_put_contents( $index_file, '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions
|
139 |
+
}
|
140 |
+
}
|
includes/class-wpcode-generator.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Load all generator types and expose them to the admin.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The WPCode_Generator class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The type of generators available.
|
15 |
+
*
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
public $types = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The available categories.
|
22 |
+
*
|
23 |
+
* @var array
|
24 |
+
*/
|
25 |
+
public $categories;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Constructor.
|
29 |
+
*/
|
30 |
+
public function __construct() {
|
31 |
+
$this->load_types();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Require and load all the generators.
|
36 |
+
*
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function load_types() {
|
40 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-type.php';
|
41 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-post-status.php';
|
42 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-post-type.php';
|
43 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-admin-bar.php';
|
44 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-contact-methods.php';
|
45 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-taxonomy.php';
|
46 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-script.php';
|
47 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-style.php';
|
48 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-hooks.php';
|
49 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-cronjob.php';
|
50 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-menu.php';
|
51 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-sidebar.php';
|
52 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-query.php';
|
53 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/generator/class-wpcode-generator-widget.php';
|
54 |
+
|
55 |
+
$generators = array(
|
56 |
+
'WPCode_Generator_Admin_Bar',
|
57 |
+
'WPCode_Generator_Contact_Methods',
|
58 |
+
'WPCode_Generator_Cronjob',
|
59 |
+
'WPCode_Generator_Hooks',
|
60 |
+
'WPCode_Generator_Menu',
|
61 |
+
'WPCode_Generator_Post_Status',
|
62 |
+
'WPCode_Generator_Post_Type',
|
63 |
+
'WPCode_Generator_Script',
|
64 |
+
'WPCode_Generator_Sidebar',
|
65 |
+
'WPCode_Generator_Style',
|
66 |
+
'WPCode_Generator_Taxonomy',
|
67 |
+
'WPCode_Generator_Widget',
|
68 |
+
'WPCode_Generator_Query',
|
69 |
+
);
|
70 |
+
foreach ( $generators as $generator_class ) {
|
71 |
+
if ( ! class_exists( $generator_class ) ) {
|
72 |
+
continue;
|
73 |
+
}
|
74 |
+
$instance = new $generator_class();
|
75 |
+
|
76 |
+
$this->types[ $instance->name ] = $instance;
|
77 |
+
}
|
78 |
+
// Sort by displayed title.
|
79 |
+
uasort(
|
80 |
+
$this->types,
|
81 |
+
function( $a, $b ) {
|
82 |
+
return strcmp( $a->title, $b->title );
|
83 |
+
}
|
84 |
+
);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Load all the categories with their labels.
|
89 |
+
*
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
private function load_categories() {
|
93 |
+
$categories = array(
|
94 |
+
'admin' => __( 'Admin', 'insert-headers-and-footers' ),
|
95 |
+
'content' => __( 'Content', 'insert-headers-and-footers' ),
|
96 |
+
'core' => __( 'Core', 'insert-headers-and-footers' ),
|
97 |
+
'design' => __( 'Design', 'insert-headers-and-footers' ),
|
98 |
+
'query' => __( 'Query', 'insert-headers-and-footers' ),
|
99 |
+
);
|
100 |
+
$this->categories = array();
|
101 |
+
foreach ( $categories as $slug => $name ) {
|
102 |
+
$this->categories[] = array(
|
103 |
+
'slug' => $slug,
|
104 |
+
'name' => $name,
|
105 |
+
);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Get categories.
|
111 |
+
*
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
public function get_categories() {
|
115 |
+
if ( ! isset( $this->categories ) ) {
|
116 |
+
$this->load_categories();
|
117 |
+
}
|
118 |
+
|
119 |
+
return $this->categories;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get all the generator instances.
|
124 |
+
*
|
125 |
+
* @return WPCode_Generator_Type[]
|
126 |
+
*/
|
127 |
+
public function get_all_generators() {
|
128 |
+
return $this->types;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get a generator by its name. If not found it returns false.
|
133 |
+
*
|
134 |
+
* @param string $name The name of the generator.
|
135 |
+
*
|
136 |
+
* @return WPCode_Generator_Type|false
|
137 |
+
*/
|
138 |
+
public function get_type( $name ) {
|
139 |
+
$types = $this->get_all_generators();
|
140 |
+
|
141 |
+
return isset( $types[ $name ] ) ? $types[ $name ] : false;
|
142 |
+
}
|
143 |
+
}
|
includes/class-wpcode-install.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Logic to run on plugin install.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Install.
|
10 |
+
*/
|
11 |
+
class WPCode_Install {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* WPCode_Install constructor.
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
register_activation_hook( WPCODE_FILE, array( $this, 'activate' ) );
|
18 |
+
add_action( 'admin_init', array( $this, 'maybe_run_install' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Activation hook.
|
23 |
+
*
|
24 |
+
* @return void
|
25 |
+
*/
|
26 |
+
public function activate() {
|
27 |
+
// Add capabilities on activation as deleting the plugin removes them
|
28 |
+
// but the option used in the `maybe_run_install` method below is not
|
29 |
+
// removed so the capabilities are not added back.
|
30 |
+
WPCode_Capabilities::add_capabilities();
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Install routine to run on plugin activation.
|
35 |
+
* Runs on admin_init so that we also handle updates.
|
36 |
+
* The ihaf_activated option was used by IHAF 1.6 and the key "lite" is for the activation date
|
37 |
+
* of that version of the plugin. In the WPCode plugin we use the "wpcode" key, so we have the update date
|
38 |
+
* and install the demo data.
|
39 |
+
*
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function maybe_run_install() {
|
43 |
+
$activated = get_option( 'ihaf_activated', array() );
|
44 |
+
|
45 |
+
if ( empty( $activated['wpcode'] ) ) {
|
46 |
+
$activated['wpcode'] = time();
|
47 |
+
|
48 |
+
update_option( 'ihaf_activated', $activated );
|
49 |
+
|
50 |
+
// Add custom capabilities.
|
51 |
+
WPCode_Capabilities::add_capabilities();
|
52 |
+
|
53 |
+
// The option was empty so let's add the demo data.
|
54 |
+
$this->add_demo_data();
|
55 |
+
|
56 |
+
if ( ! empty( $activated['lite'] ) ) {
|
57 |
+
// If IHAF 1.6 has been running on the site, redirect to upgrade screen.
|
58 |
+
set_transient( 'wpcode_upgrade_redirect', true, 30 );
|
59 |
+
}
|
60 |
+
|
61 |
+
do_action( 'wpcode_install' );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add some example snippets in a new installation.
|
67 |
+
*
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
public function add_demo_data() {
|
71 |
+
$snippets = array(
|
72 |
+
array(
|
73 |
+
'title' => __( 'Display a message after the 1st paragraph of posts', 'insert-headers-and-footers' ),
|
74 |
+
'code' => 'Thank you for reading this post, don\'t forget to subscribe!',
|
75 |
+
'code_type' => 'text',
|
76 |
+
'auto_insert' => 1,
|
77 |
+
'location' => 'after_paragraph',
|
78 |
+
'insert_number' => 1,
|
79 |
+
'tags' => array(
|
80 |
+
'sample',
|
81 |
+
'message',
|
82 |
+
),
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'title' => __( 'Completely Disable Comments', 'insert-headers-and-footers' ),
|
86 |
+
'code' => "add_action('admin_init', function () {\r\n \/\/ Redirect any user trying to access comments page\r\n global \$pagenow;\r\n \r\n if (\$pagenow === 'edit-comments.php') {\r\n wp_safe_redirect(admin_url());\r\n exit;\r\n }\r\n\r\n \/\/ Remove comments metabox from dashboard\r\n remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');\r\n\r\n \/\/ Disable support for comments and trackbacks in post types\r\n foreach (get_post_types() as \$post_type) {\r\n if (post_type_supports(\$post_type, 'comments')) {\r\n remove_post_type_support(\$post_type, 'comments');\r\n remove_post_type_support(\$post_type, 'trackbacks');\r\n }\r\n }\r\n});\r\n\r\n\/\/ Close comments on the front-end\r\nadd_filter('comments_open', '__return_false', 20, 2);\r\nadd_filter('pings_open', '__return_false', 20, 2);\r\n\r\n\/\/ Hide existing comments\r\nadd_filter('comments_array', '__return_empty_array', 10, 2);\r\n\r\n\/\/ Remove comments page in menu\r\nadd_action('admin_menu', function () {\r\n remove_menu_page('edit-comments.php');\r\n});\r\n\r\n\/\/ Remove comments links from admin bar\r\nadd_action('init', function () {\r\n if (is_admin_bar_showing()) {\r\n remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);\r\n }\r\n});",
|
87 |
+
'code_type' => 'php',
|
88 |
+
'auto_insert' => 1,
|
89 |
+
'location' => 'everywhere',
|
90 |
+
'tags' => array(
|
91 |
+
'sample',
|
92 |
+
'disable',
|
93 |
+
'comments',
|
94 |
+
),
|
95 |
+
'library_id' => 12,
|
96 |
+
),
|
97 |
+
);
|
98 |
+
|
99 |
+
// The activation hook runs after `init` so our plugin's custom
|
100 |
+
// post type and custom taxonomies didn't have a chance to be registered.
|
101 |
+
wpcode_register_post_type();
|
102 |
+
wpcode_register_taxonomies();
|
103 |
+
|
104 |
+
foreach ( $snippets as $snippet ) {
|
105 |
+
$new_snippet = new WPCode_Snippet( $snippet );
|
106 |
+
$new_snippet->save();
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
new WPCode_Install();
|
includes/class-wpcode-library.php
ADDED
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Load snippets from the wpcode.com snippet library.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Library.
|
10 |
+
*/
|
11 |
+
class WPCode_Library {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The endpoint where everything starts.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $library_url = 'https://cdn.wpcode.com/library/api/get';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Key for storing snippets in the db.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $cache_key = 'snippets';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The key for storing individual snippets.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
private $snippet_key = 'snippets/snippet';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The base cache folder for this class.
|
36 |
+
*
|
37 |
+
* @var string
|
38 |
+
*/
|
39 |
+
private $cache_folder = 'library';
|
40 |
+
|
41 |
+
/**
|
42 |
+
* The data.
|
43 |
+
*
|
44 |
+
* @var array
|
45 |
+
*/
|
46 |
+
private $data;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* The default time to live for libary items that are cached.
|
50 |
+
*
|
51 |
+
* @var int
|
52 |
+
*/
|
53 |
+
private $ttl = DAY_IN_SECONDS;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Array of snippet ids that were already loaded from the library.
|
57 |
+
*
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
private $library_snippets;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Grab all the available categories from the library.
|
64 |
+
*
|
65 |
+
* @return array
|
66 |
+
*/
|
67 |
+
public function get_data() {
|
68 |
+
if ( ! isset( $this->data ) ) {
|
69 |
+
$this->data = $this->load_data();
|
70 |
+
}
|
71 |
+
|
72 |
+
return $this->data;
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Grab data from the cache.
|
78 |
+
*
|
79 |
+
* @param string $key The key used to grab from cache.
|
80 |
+
* @param int $ttl The time to live for cached data, defaults to class ttl.
|
81 |
+
*
|
82 |
+
* @return array|false
|
83 |
+
*/
|
84 |
+
public function get_from_cache( $key, $ttl = 0 ) {
|
85 |
+
if ( empty( $ttl ) ) {
|
86 |
+
$ttl = $this->ttl;
|
87 |
+
}
|
88 |
+
|
89 |
+
$data = wpcode()->file_cache->get( $this->cache_folder . '/' . $key, $ttl );
|
90 |
+
|
91 |
+
if ( isset( $data['error'] ) && isset( $data['time'] ) ) {
|
92 |
+
if ( $data['time'] + 10 * MINUTE_IN_SECONDS < time() ) {
|
93 |
+
return false;
|
94 |
+
} else {
|
95 |
+
return $this->get_empty_array();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
return $data;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Load the library data either from the server or from cache.
|
104 |
+
*
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
public function load_data() {
|
108 |
+
$this->data = $this->get_from_cache( $this->cache_key );
|
109 |
+
|
110 |
+
if ( false === $this->data ) {
|
111 |
+
$this->data = $this->get_from_server();
|
112 |
+
}
|
113 |
+
|
114 |
+
return $this->data;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get data from the server.
|
120 |
+
*
|
121 |
+
* @return array
|
122 |
+
*/
|
123 |
+
private function get_from_server() {
|
124 |
+
$url = $this->library_url;
|
125 |
+
|
126 |
+
if ( empty( $url ) ) {
|
127 |
+
// Didn't know what to grab.
|
128 |
+
return $this->get_empty_array();
|
129 |
+
}
|
130 |
+
|
131 |
+
$request = wp_remote_get( $url );
|
132 |
+
|
133 |
+
if ( is_wp_error( $request ) ) {
|
134 |
+
return $this->save_temporary_response_fail( $this->cache_key );
|
135 |
+
}
|
136 |
+
|
137 |
+
$response_code = wp_remote_retrieve_response_code( $request );
|
138 |
+
|
139 |
+
$data = wp_remote_retrieve_body( $request );
|
140 |
+
if ( $response_code > 299 ) {
|
141 |
+
// Temporary error so cache for just 10 minutes and then try again.
|
142 |
+
$data = '';
|
143 |
+
}
|
144 |
+
|
145 |
+
$data = $this->process_response( $data );
|
146 |
+
|
147 |
+
if ( empty( $data['snippets'] ) ) {
|
148 |
+
return $this->save_temporary_response_fail( $this->cache_key );
|
149 |
+
}
|
150 |
+
|
151 |
+
$this->save_to_cache( $this->cache_key, $data );
|
152 |
+
|
153 |
+
return $data;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* When we can't fetch from the server we save a temporary error => true file to avoid
|
158 |
+
* subsequent requests for a while. Returns a properly formatted array for frontend output.
|
159 |
+
*
|
160 |
+
* @param string $key The key used for storing the data in the cache.
|
161 |
+
*
|
162 |
+
* @return array
|
163 |
+
*/
|
164 |
+
public function save_temporary_response_fail( $key ) {
|
165 |
+
$data = array(
|
166 |
+
'error' => true,
|
167 |
+
'time' => time(),
|
168 |
+
);
|
169 |
+
$this->save_to_cache( $key, $data );
|
170 |
+
|
171 |
+
return $this->get_empty_array();
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Get an empty array for a consistent response.
|
176 |
+
*
|
177 |
+
* @return array[]
|
178 |
+
*/
|
179 |
+
public function get_empty_array() {
|
180 |
+
return array(
|
181 |
+
'categories' => array(),
|
182 |
+
'snippets' => array(),
|
183 |
+
);
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Save to cache.
|
188 |
+
*
|
189 |
+
* @param string $key The key used to store the data in the cache.
|
190 |
+
* @param array|mixed $data The data that will be stored.
|
191 |
+
*
|
192 |
+
* @return void
|
193 |
+
*/
|
194 |
+
public function save_to_cache( $key, $data ) {
|
195 |
+
wpcode()->file_cache->set( $this->cache_folder . '/' . $key, $data );
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Generic handler for grabbing data by slug. Either all categories or the category slug.
|
200 |
+
*
|
201 |
+
* @param string $data Response body from server.
|
202 |
+
*
|
203 |
+
* @return array
|
204 |
+
*/
|
205 |
+
private function process_response( $data ) {
|
206 |
+
$response = json_decode( $data, true );
|
207 |
+
if ( ! isset( $response['status'] ) || 'success' !== $response['status'] ) {
|
208 |
+
return $this->get_empty_array();
|
209 |
+
}
|
210 |
+
|
211 |
+
return $response['data'];
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Get a cache key for a specific snippet id.
|
216 |
+
*
|
217 |
+
* @param int $id The snippet id.
|
218 |
+
*
|
219 |
+
* @return string
|
220 |
+
*/
|
221 |
+
public function get_snippet_cache_key( $id ) {
|
222 |
+
return $this->snippet_key . '_' . $id;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Create a new snippet by the library id.
|
227 |
+
* This grabs the snippet by its id from the snippet library site and creates
|
228 |
+
* a new snippet on the current site using the response.
|
229 |
+
*
|
230 |
+
* @param int $library_id The id of the snippet on the library site.
|
231 |
+
*
|
232 |
+
* @return false|WPCode_Snippet
|
233 |
+
*/
|
234 |
+
public function create_new_snippet( $library_id ) {
|
235 |
+
|
236 |
+
$snippet_data = $this->grab_snippet_from_api( $library_id );
|
237 |
+
|
238 |
+
if ( ! $snippet_data ) {
|
239 |
+
return false;
|
240 |
+
}
|
241 |
+
|
242 |
+
$snippet = new WPCode_Snippet( $snippet_data );
|
243 |
+
|
244 |
+
$snippet->save();
|
245 |
+
|
246 |
+
delete_transient( 'wpcode_used_library_snippets' );
|
247 |
+
|
248 |
+
return $snippet;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Grab a snippet data from the API.
|
253 |
+
*
|
254 |
+
* @param int $library_id The id of the snippet in the Library api.
|
255 |
+
*
|
256 |
+
* @return array|array[]|false
|
257 |
+
*/
|
258 |
+
public function grab_snippet_from_api( $library_id ) {
|
259 |
+
$data = $this->get_data();
|
260 |
+
|
261 |
+
if ( empty( $data['links']['snippet'] ) ) {
|
262 |
+
return false;
|
263 |
+
}
|
264 |
+
|
265 |
+
$url = add_query_arg(
|
266 |
+
array(
|
267 |
+
'site' => rawurlencode( site_url() ),
|
268 |
+
),
|
269 |
+
trailingslashit( esc_url( $data['links']['snippet'] ) ) . $library_id
|
270 |
+
);
|
271 |
+
|
272 |
+
$snippet_request = wp_remote_get( $url );
|
273 |
+
|
274 |
+
$response_code = wp_remote_retrieve_response_code( $snippet_request );
|
275 |
+
|
276 |
+
if ( $response_code > 299 ) {
|
277 |
+
return false;
|
278 |
+
}
|
279 |
+
|
280 |
+
$snippet_data = $this->process_response( wp_remote_retrieve_body( $snippet_request ) );
|
281 |
+
|
282 |
+
if ( empty( $snippet_data ) ) {
|
283 |
+
return false;
|
284 |
+
}
|
285 |
+
|
286 |
+
return $snippet_data;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Get all the snippets that were created from the library, by library ID.
|
291 |
+
* Results are cached in a transient.
|
292 |
+
*
|
293 |
+
* @return array
|
294 |
+
*/
|
295 |
+
public function get_used_library_snippets() {
|
296 |
+
|
297 |
+
if ( isset( $this->library_snippets ) ) {
|
298 |
+
return $this->library_snippets;
|
299 |
+
}
|
300 |
+
|
301 |
+
$snippets_from_library = get_transient( 'wpcode_used_library_snippets' );
|
302 |
+
|
303 |
+
if ( false === $snippets_from_library ) {
|
304 |
+
$snippets_from_library = array();
|
305 |
+
|
306 |
+
$args = array(
|
307 |
+
'post_type' => 'wpcode',
|
308 |
+
'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
|
309 |
+
array(
|
310 |
+
'key' => '_wpcode_library_id',
|
311 |
+
'compare' => 'EXISTS',
|
312 |
+
),
|
313 |
+
),
|
314 |
+
'fields' => 'ids',
|
315 |
+
'post_status' => 'any',
|
316 |
+
'nopaging' => true,
|
317 |
+
);
|
318 |
+
$snippets = get_posts( $args );
|
319 |
+
|
320 |
+
foreach ( $snippets as $snippet_id ) {
|
321 |
+
$library_id = absint( get_post_meta( $snippet_id, '_wpcode_library_id', true ) );
|
322 |
+
$snippets_from_library[ $library_id ] = $snippet_id;
|
323 |
+
}
|
324 |
+
|
325 |
+
set_transient( 'wpcode_used_library_snippets', $snippets_from_library );
|
326 |
+
}
|
327 |
+
|
328 |
+
$this->library_snippets = $snippets_from_library;
|
329 |
+
|
330 |
+
return $this->library_snippets;
|
331 |
+
|
332 |
+
}
|
333 |
+
}
|
includes/class-wpcode-settings.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handles all the WPCode settings.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Settings.
|
10 |
+
*/
|
11 |
+
class WPCode_Settings {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The key used for storing settings in the db.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
private $settings_key = 'wpcode_settings';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Options as they are loaded from the db.
|
22 |
+
*
|
23 |
+
* @var array
|
24 |
+
* @see WPCode_Settings::get_options
|
25 |
+
*/
|
26 |
+
private $options;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get an option by name with an optional default value.
|
30 |
+
*
|
31 |
+
* @param string $option The option name.
|
32 |
+
* @param mixed $default The default value (optional).
|
33 |
+
*
|
34 |
+
* @return mixed
|
35 |
+
* @see get_option
|
36 |
+
*/
|
37 |
+
public function get_option( $option, $default = false ) {
|
38 |
+
$options = $this->get_options();
|
39 |
+
if ( isset( $options[ $option ] ) ) {
|
40 |
+
return $options[ $option ];
|
41 |
+
}
|
42 |
+
|
43 |
+
return $default;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get all the options as they are stored in the db.
|
48 |
+
*
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
public function get_options() {
|
52 |
+
if ( ! isset( $this->options ) ) {
|
53 |
+
$this->options = get_option( $this->settings_key, array() );
|
54 |
+
}
|
55 |
+
|
56 |
+
return $this->options;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Update an option in the settings object.
|
61 |
+
*
|
62 |
+
* @param string $option The option name.
|
63 |
+
* @param mixed $value The new value.
|
64 |
+
*
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
public function update_option( $option, $value ) {
|
68 |
+
if ( empty( $value ) ) {
|
69 |
+
$this->delete_option( $option );
|
70 |
+
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
if ( isset( $this->options[ $option ] ) && $this->options[ $option ] === $value ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
$this->options[ $option ] = $value;
|
77 |
+
|
78 |
+
$this->save_options();
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Delete an option by its name.
|
83 |
+
*
|
84 |
+
* @param string $option The option name.
|
85 |
+
*
|
86 |
+
* @return void
|
87 |
+
*/
|
88 |
+
public function delete_option( $option ) {
|
89 |
+
// If there's nothing to delete, do nothing.
|
90 |
+
if ( isset( $this->options[ $option ] ) ) {
|
91 |
+
unset( $this->options[ $option ] );
|
92 |
+
$this->save_options();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Save the current options object to the db.
|
98 |
+
*
|
99 |
+
* @return void
|
100 |
+
*/
|
101 |
+
private function save_options() {
|
102 |
+
update_option( $this->settings_key, (array) $this->options );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Use an array to update multiple settings at once.
|
107 |
+
*
|
108 |
+
* @param array $options The new options array.
|
109 |
+
*
|
110 |
+
* @return void
|
111 |
+
*/
|
112 |
+
public function bulk_update_options( $options ) {
|
113 |
+
$this->options = array_merge( $this->get_options(), $options );
|
114 |
+
|
115 |
+
$this->save_options();
|
116 |
+
}
|
117 |
+
}
|
includes/class-wpcode-snippet-cache.php
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cache active snippets in a single query.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class WPCode_Snippet_Cache.
|
10 |
+
*/
|
11 |
+
class WPCode_Snippet_Cache {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The option name used for storing data in the db.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
private $option_name = 'wpcode_snippets';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The snippets stored in the db.
|
22 |
+
*
|
23 |
+
* @var array
|
24 |
+
*/
|
25 |
+
private $snippets;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get the snippets data from the cache.
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function get_cached_snippets() {
|
33 |
+
if ( ! isset( $this->snippets ) ) {
|
34 |
+
$all_snippets = get_option( $this->option_name, array() );
|
35 |
+
foreach ( $all_snippets as $location => $snippets ) {
|
36 |
+
// Load minimal snippet data from array.
|
37 |
+
foreach ( $snippets as $key => $snippet ) {
|
38 |
+
$all_snippets[ $location ][ $key ] = new WPCode_Snippet( $snippet );
|
39 |
+
}
|
40 |
+
|
41 |
+
usort( $all_snippets[ $location ], array( $this, 'priority_order' ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
$this->snippets = $all_snippets;
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->snippets;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Used for sorting by priority.
|
53 |
+
*
|
54 |
+
* @param WPCode_Snippet $snippet_a The first snippet.
|
55 |
+
* @param WPCode_Snippet $snippet_b The second snippet.
|
56 |
+
*
|
57 |
+
* @return int
|
58 |
+
*/
|
59 |
+
public function priority_order( $snippet_a, $snippet_b ) {
|
60 |
+
return $snippet_a->get_priority() - $snippet_b->get_priority();
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Delete the cache option completely.
|
65 |
+
*
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
public function delete_cache() {
|
69 |
+
update_option( $this->option_name, array() );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Save all the loaded snippets in a single option.
|
74 |
+
*
|
75 |
+
* @return void
|
76 |
+
*/
|
77 |
+
public function cache_all_loaded_snippets() {
|
78 |
+
if ( ! apply_filters( 'wpcode_cache_active_snippets', true ) ) {
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
$auto_inserts = wpcode()->auto_insert->get_types();
|
82 |
+
$snippets_by_location = array();
|
83 |
+
foreach ( $auto_inserts as $auto_insert ) {
|
84 |
+
// We don't want to use cached data when gathering stuff for cache.
|
85 |
+
add_filter( 'wpcode_use_auto_insert_cache', '__return_false' );
|
86 |
+
// Make sure snippets were not already loaded by earlier hooks.
|
87 |
+
unset( $auto_insert->snippets );
|
88 |
+
$snippets_by_location = array_merge( $auto_insert->get_snippets(), $snippets_by_location );
|
89 |
+
}
|
90 |
+
|
91 |
+
$data_for_cache = array();
|
92 |
+
foreach ( $snippets_by_location as $location => $snippets ) {
|
93 |
+
$data_for_cache[ $location ] = $this->prepare_snippets_for_caching( $snippets );
|
94 |
+
}
|
95 |
+
|
96 |
+
update_option( $this->option_name, $data_for_cache );
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Go through an array of snippets and extract just the minimal data
|
101 |
+
* needed for running the snippets.
|
102 |
+
*
|
103 |
+
* @param WPCode_Snippet[] $snippets The snippets array.
|
104 |
+
*
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
private function prepare_snippets_for_caching( $snippets ) {
|
108 |
+
$prepared_snippets = array();
|
109 |
+
foreach ( $snippets as $snippet ) {
|
110 |
+
$prepared_snippets[] = $snippet->get_data_for_caching();
|
111 |
+
}
|
112 |
+
|
113 |
+
return $prepared_snippets;
|
114 |
+
}
|
115 |
+
}
|
includes/class-wpcode-snippet-execute.php
ADDED
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Global class used to execute code across the plugin.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Snippet_Execute class.
|
10 |
+
*/
|
11 |
+
class WPCode_Snippet_Execute {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Simply mark this as true when activating a snippet
|
15 |
+
* to display the proper custom error message.
|
16 |
+
*
|
17 |
+
* @var bool
|
18 |
+
*/
|
19 |
+
private $doing_activation = false;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* The type of executors.
|
23 |
+
*
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
public $types;
|
27 |
+
/**
|
28 |
+
* The snippet executed right now, for error handling.
|
29 |
+
*
|
30 |
+
* @var WPCode_Snippet
|
31 |
+
*/
|
32 |
+
public $snippet_executed;
|
33 |
+
/**
|
34 |
+
* Store snippet types by id for already looked-up snippets
|
35 |
+
* to reduce the number of queries.
|
36 |
+
*
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
private $snippet_types = array();
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor.
|
43 |
+
*/
|
44 |
+
public function __construct() {
|
45 |
+
$this->add_error_handling();
|
46 |
+
$this->load_types();
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Register custom error handling functions.
|
51 |
+
*
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
public function add_error_handling() {
|
55 |
+
// Register our custom error catcher.
|
56 |
+
register_shutdown_function( array( $this, 'maybe_disable_snippet' ) );
|
57 |
+
// Customize WP error message.
|
58 |
+
add_filter( 'wp_php_error_message', array( $this, 'custom_error_message' ), 15, 2 );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Load the classes and options available for executing code.
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
public function load_types() {
|
67 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/execute/class-wpcode-snippet-execute-type.php';
|
68 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/execute/class-wpcode-snippet-execute-html.php';
|
69 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/execute/class-wpcode-snippet-execute-text.php';
|
70 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/execute/class-wpcode-snippet-execute-js.php';
|
71 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/execute/class-wpcode-snippet-execute-php.php';
|
72 |
+
require_once WPCODE_PLUGIN_PATH . 'includes/execute/class-wpcode-snippet-execute-universal.php';
|
73 |
+
|
74 |
+
$this->types = array(
|
75 |
+
'html' => array(
|
76 |
+
'class' => 'WPCode_Snippet_Execute_HTML',
|
77 |
+
'label' => __( 'HTML Snippet', 'insert-headers-and-footers' ),
|
78 |
+
// Don't want to instantiate the class until it's needed and we need this to be translatable.
|
79 |
+
),
|
80 |
+
'text' => array(
|
81 |
+
'class' => 'WPCode_Snippet_Execute_Text',
|
82 |
+
'label' => __( 'Text Snippet', 'insert-headers-and-footers' ),
|
83 |
+
),
|
84 |
+
'js' => array(
|
85 |
+
'class' => 'WPCode_Snippet_Execute_JS',
|
86 |
+
'label' => __( 'JavaScript Snippet', 'insert-headers-and-footers' ),
|
87 |
+
),
|
88 |
+
'php' => array(
|
89 |
+
'class' => 'WPCode_Snippet_Execute_PHP',
|
90 |
+
'label' => __( 'PHP Snippet', 'insert-headers-and-footers' ),
|
91 |
+
),
|
92 |
+
'universal' => array(
|
93 |
+
'class' => 'WPCode_Snippet_Execute_Universal',
|
94 |
+
'label' => __( 'Universal Snippet', 'insert-headers-and-footers' ),
|
95 |
+
),
|
96 |
+
);
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Gets passed a snippet WP_Post or id and returns the processed output.
|
101 |
+
*
|
102 |
+
* @param int|WP_Post|WPCode_Snippet $snippet The snippet id or post object.
|
103 |
+
*
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function get_snippet_output( $snippet ) {
|
107 |
+
// If we're in headers & footers mode prevent execution of any type of snippet.
|
108 |
+
if ( WPCode()->settings->get_option( 'headers_footers_mode' ) ) {
|
109 |
+
return '';
|
110 |
+
}
|
111 |
+
if ( ! $snippet instanceof WPCode_Snippet ) {
|
112 |
+
$snippet = new WPCode_Snippet( $snippet );
|
113 |
+
}
|
114 |
+
$type = $snippet->get_code_type();
|
115 |
+
$class = $this->get_type_execute_class( $type );
|
116 |
+
|
117 |
+
if ( $class && class_exists( $class ) ) {
|
118 |
+
$execute_instance = new $class( $snippet );
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Adding comment for convenience.
|
122 |
+
*
|
123 |
+
* @var WPCode_Snippet_Execute_Type $execute_instance
|
124 |
+
*/
|
125 |
+
return $execute_instance->get_output();
|
126 |
+
}
|
127 |
+
|
128 |
+
// If we can't find the type class for some reason just return empty.
|
129 |
+
return '';
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Find the execution type class and returns its name.
|
134 |
+
*
|
135 |
+
* @param string $type The type of code to get the executor for.
|
136 |
+
*
|
137 |
+
* @return string|false
|
138 |
+
*/
|
139 |
+
public function get_type_execute_class( $type ) {
|
140 |
+
if ( isset( $this->types[ $type ] ) ) {
|
141 |
+
return $this->types[ $type ]['class'];
|
142 |
+
}
|
143 |
+
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Get a label from the term slug.
|
149 |
+
*
|
150 |
+
* @param string $type The code type slug.
|
151 |
+
*
|
152 |
+
* @return string
|
153 |
+
*/
|
154 |
+
public function get_type_label( $type ) {
|
155 |
+
$options = $this->get_options();
|
156 |
+
|
157 |
+
return isset( $options[ $type ] ) ? $options[ $type ] : '';
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Grab the options with labels, for display in admin.
|
162 |
+
*
|
163 |
+
* @return array
|
164 |
+
*/
|
165 |
+
public function get_options() {
|
166 |
+
$options = array();
|
167 |
+
foreach ( $this->types as $type_key => $type_values ) {
|
168 |
+
$options[ $type_key ] = $type_values['label'];
|
169 |
+
}
|
170 |
+
|
171 |
+
return $options;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Get editor options for all code types.
|
176 |
+
*
|
177 |
+
* @return array
|
178 |
+
*/
|
179 |
+
public function get_code_type_options() {
|
180 |
+
$types = $this->get_options();
|
181 |
+
$options = array();
|
182 |
+
foreach ( $types as $type => $label ) {
|
183 |
+
$options[ $type ] = array(
|
184 |
+
'mime' => $this->get_mime_for_code_type( $type ),
|
185 |
+
'lint' => $this->code_type_has_lint( $type ),
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
return $options;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Convert generic code type to MIME used by CodeMirror.
|
194 |
+
*
|
195 |
+
* @param string $code_type The code type (php,js,html,etc).
|
196 |
+
*
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
public function get_mime_for_code_type( $code_type ) {
|
200 |
+
$mime = 'text/html';
|
201 |
+
if ( ! empty( $code_type ) ) {
|
202 |
+
switch ( $code_type ) {
|
203 |
+
case 'php':
|
204 |
+
$mime = 'text/x-php';
|
205 |
+
break;
|
206 |
+
case 'universal':
|
207 |
+
$mime = 'application/x-httpd-php';
|
208 |
+
break;
|
209 |
+
case 'js':
|
210 |
+
$mime = 'text/javascript';
|
211 |
+
break;
|
212 |
+
case 'text':
|
213 |
+
$mime = 'text/x-markdown';
|
214 |
+
break;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return $mime;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Check if the code type supports linting in CodeMirror.
|
223 |
+
*
|
224 |
+
* @param string $code_type The code type slug.
|
225 |
+
*
|
226 |
+
* @return bool
|
227 |
+
*/
|
228 |
+
public function code_type_has_lint( $code_type = '' ) {
|
229 |
+
if ( empty( $code_type ) ) {
|
230 |
+
$code_type = isset( $this->code_type ) ? $this->code_type : '';
|
231 |
+
}
|
232 |
+
$types_with_lint = array(
|
233 |
+
'html',
|
234 |
+
'js',
|
235 |
+
);
|
236 |
+
|
237 |
+
return in_array( $code_type, $types_with_lint, true );
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Execute the PHP code in a single place.
|
242 |
+
*
|
243 |
+
* @param string $code The code to execute.
|
244 |
+
* @param WPCode_Snippet $snippet The snippet object (optional) so we deactivate it to prevent the same error.
|
245 |
+
*
|
246 |
+
* @return false|string
|
247 |
+
*/
|
248 |
+
public function safe_execute_php( $code, $snippet = null ) {
|
249 |
+
|
250 |
+
if ( isset( $snippet ) ) {
|
251 |
+
$this->snippet_executed = $snippet;
|
252 |
+
}
|
253 |
+
|
254 |
+
// Catch any output from running the code.
|
255 |
+
ob_start();
|
256 |
+
|
257 |
+
$error = false;
|
258 |
+
|
259 |
+
try {
|
260 |
+
eval( $code ); // phpcs:ignore Squiz.PHP.Eval.Discouraged
|
261 |
+
} catch ( Error $e ) {
|
262 |
+
wpcode()->error->add_error( $e );
|
263 |
+
$error = true;
|
264 |
+
}
|
265 |
+
|
266 |
+
if ( $error ) {
|
267 |
+
$this->deactivate_last_snippet();
|
268 |
+
}
|
269 |
+
|
270 |
+
return ob_get_clean();
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Deactivate the last snippet that was executed as it threw an error.
|
275 |
+
*
|
276 |
+
* @return void
|
277 |
+
*/
|
278 |
+
public function deactivate_last_snippet() {
|
279 |
+
$locations_to_auto_disable = array(
|
280 |
+
'everywhere',
|
281 |
+
'admin_only',
|
282 |
+
);
|
283 |
+
if ( isset( $this->snippet_executed ) && in_array( $this->snippet_executed->get_location(), $locations_to_auto_disable, true ) ) {
|
284 |
+
$this->snippet_executed->deactivate();
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Callback for register_shutdown_function that checks if the error was thrown by this class
|
290 |
+
* and if so, it disables the last snippet that was executed so that the site continues to run
|
291 |
+
* correctly.
|
292 |
+
*
|
293 |
+
* @return void
|
294 |
+
*/
|
295 |
+
public function maybe_disable_snippet() {
|
296 |
+
$error = error_get_last();
|
297 |
+
|
298 |
+
if ( $this->is_error_from_wpcode( $error ) ) {
|
299 |
+
// Deactivate the last ran snippet.
|
300 |
+
wpcode()->error->add_error( $error );
|
301 |
+
$this->deactivate_last_snippet();
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Get an error object (from error_get_last) and check if it originated in the WPCode eval function.
|
307 |
+
*
|
308 |
+
* @param array $error The error array.
|
309 |
+
*
|
310 |
+
* @return bool
|
311 |
+
* @see error_get_last()
|
312 |
+
*/
|
313 |
+
public function is_error_from_wpcode( $error ) {
|
314 |
+
if ( isset( $error['type'] ) && E_NOTICE === $error['type'] ) {
|
315 |
+
// If it's a notice let's let it be.
|
316 |
+
return false;
|
317 |
+
}
|
318 |
+
if ( $error && isset( $error['message'] ) ) {
|
319 |
+
// Let's see if the error originated in the code executed from a snippet.
|
320 |
+
$pattern = '/\bwpcode-snippet-execute\.php\b(.*)\beval\b/m';
|
321 |
+
if ( preg_match( $pattern, $error['message'] ) || preg_match( $pattern, $error['file'] ) ) {
|
322 |
+
return true;
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Display a custom error message (not the WP default one) for fatal errors thrown
|
331 |
+
* when trying to activate snippets via AJAX. Only if the error is thrown in the eval code from WPCode.
|
332 |
+
*
|
333 |
+
* @param string $message The error message to be displayed (HTML).
|
334 |
+
* @param array $error The error object from error_get_last.
|
335 |
+
*
|
336 |
+
* @return string
|
337 |
+
*/
|
338 |
+
public function custom_error_message( $message, $error ) {
|
339 |
+
// If the error is not related to our plugin don't do anything.
|
340 |
+
if ( ! $this->is_error_from_wpcode( $error ) ) {
|
341 |
+
return $message;
|
342 |
+
}
|
343 |
+
// If we're not in the admin or the current user can't update snippets just let WP handle the error message.
|
344 |
+
if ( ! is_admin() || ! current_user_can( 'wpcode_edit_snippets' ) ) {
|
345 |
+
return $message;
|
346 |
+
}
|
347 |
+
|
348 |
+
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
|
349 |
+
|
350 |
+
if ( $this->is_doing_activation() ) {
|
351 |
+
$message = sprintf( '<p>%s</p>', __( 'Snippet has not been activated due to an error.', 'insert-headers-and-footers' ) );
|
352 |
+
|
353 |
+
if ( ! $doing_ajax ) {
|
354 |
+
// Not doing ajax let's ask them to go back.
|
355 |
+
$message .= '<p>' . __( 'Please click the back button in the browser to update the snippet.', 'insert-headers-and-footers' ) . '</p>';
|
356 |
+
}
|
357 |
+
} else {
|
358 |
+
$message = sprintf( '<p>%s</p>', __( 'WPCode has detected an error in one of the snippets which has now been automatically deactivated.', 'insert-headers-and-footers' ) );
|
359 |
+
}
|
360 |
+
|
361 |
+
if ( ! $doing_ajax && ! empty( $this->snippet_executed ) ) {
|
362 |
+
$snippet_edit_link = add_query_arg(
|
363 |
+
array(
|
364 |
+
'page' => 'wpcode-snippet-manager',
|
365 |
+
'snippet_id' => $this->snippet_executed->get_id(),
|
366 |
+
),
|
367 |
+
admin_url( 'admin.php' )
|
368 |
+
);
|
369 |
+
// Translators: the placeholders add a link to edit the snippet that threw the error.
|
370 |
+
$message .= '<p>' . sprintf( __( '%1$sClick here%2$s to update the snippet that threw the error.', 'insert-headers-and-footers' ), '<a href="' . esc_url( $snippet_edit_link ) . '">', '</a>' ) . '</p>';
|
371 |
+
}
|
372 |
+
|
373 |
+
$message .= sprintf( '<p>%s</p>', __( 'Error message:', 'insert-headers-and-footers' ) );
|
374 |
+
$message .= sprintf( '<p>%s</p>', $error['message'] );
|
375 |
+
|
376 |
+
return $message;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Mark as doing activation.
|
381 |
+
*
|
382 |
+
* @return void
|
383 |
+
*/
|
384 |
+
public function doing_activation() {
|
385 |
+
$this->doing_activation = true;
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Check if we are in the middle of activating a snippet.
|
390 |
+
* Used for choosing the type of custom error message to display.
|
391 |
+
*
|
392 |
+
* @return bool
|
393 |
+
*/
|
394 |
+
public function is_doing_activation() {
|
395 |
+
return $this->doing_activation;
|
396 |
+
}
|
397 |
+
}
|
includes/class-wpcode-snippet.php
ADDED
@@ -0,0 +1,688 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The main class to work with single WPCode snippets.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Snippet class.
|
10 |
+
*/
|
11 |
+
class WPCode_Snippet {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The snippet id.
|
15 |
+
*
|
16 |
+
* @var int
|
17 |
+
*/
|
18 |
+
public $id;
|
19 |
+
/**
|
20 |
+
* The WP_Post object for the snippet.
|
21 |
+
*
|
22 |
+
* @var WP_Post
|
23 |
+
*/
|
24 |
+
public $post_data;
|
25 |
+
/**
|
26 |
+
* The snippet title.
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
public $title;
|
31 |
+
/**
|
32 |
+
* The actual snippet code.
|
33 |
+
*
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
public $code;
|
37 |
+
/**
|
38 |
+
* The code language/type.
|
39 |
+
*
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
public $code_type;
|
43 |
+
/**
|
44 |
+
* The location where the snippet is added.
|
45 |
+
*
|
46 |
+
* @var string
|
47 |
+
*/
|
48 |
+
public $location;
|
49 |
+
/**
|
50 |
+
* Auto-insert or use shortcode?
|
51 |
+
*
|
52 |
+
* @var int
|
53 |
+
*/
|
54 |
+
public $auto_insert;
|
55 |
+
/**
|
56 |
+
* The insert number for paragraphs or posts in an archive.
|
57 |
+
*
|
58 |
+
* @var int
|
59 |
+
*/
|
60 |
+
public $insert_number;
|
61 |
+
/**
|
62 |
+
* If the snippet is active or not, for now this is handled by the post status draft vs published.
|
63 |
+
*
|
64 |
+
* @var bool
|
65 |
+
*/
|
66 |
+
public $active;
|
67 |
+
/**
|
68 |
+
* An array of tags.
|
69 |
+
*
|
70 |
+
* @var string[]
|
71 |
+
*/
|
72 |
+
public $tags;
|
73 |
+
/**
|
74 |
+
* When we load the location from the terms let's store the object here.
|
75 |
+
*
|
76 |
+
* @var WP_Term
|
77 |
+
*/
|
78 |
+
private $location_term;
|
79 |
+
/**
|
80 |
+
* When we load the code type from the terms let's store the object here.
|
81 |
+
*
|
82 |
+
* @var WP_Term
|
83 |
+
*/
|
84 |
+
private $code_type_term;
|
85 |
+
/**
|
86 |
+
* The tag terms.
|
87 |
+
*
|
88 |
+
* @var WP_Term[]
|
89 |
+
*/
|
90 |
+
private $tags_terms;
|
91 |
+
/**
|
92 |
+
* Whether the conditional rules are enabled or disabled.
|
93 |
+
*
|
94 |
+
* @var bool
|
95 |
+
*/
|
96 |
+
private $use_rules;
|
97 |
+
/**
|
98 |
+
* The conditional logic rules.
|
99 |
+
*
|
100 |
+
* @var array
|
101 |
+
*/
|
102 |
+
private $rules;
|
103 |
+
/**
|
104 |
+
* The priority for loading.
|
105 |
+
*
|
106 |
+
* @var int
|
107 |
+
*/
|
108 |
+
private $priority;
|
109 |
+
|
110 |
+
/**
|
111 |
+
* The library id, if the snippet is created from the snippet library.
|
112 |
+
*
|
113 |
+
* @var int
|
114 |
+
*/
|
115 |
+
private $library_id;
|
116 |
+
|
117 |
+
/**
|
118 |
+
* The version of the snippet from the library.
|
119 |
+
*
|
120 |
+
* @var string
|
121 |
+
*/
|
122 |
+
private $library_version;
|
123 |
+
|
124 |
+
/**
|
125 |
+
* The snippet note.
|
126 |
+
*
|
127 |
+
* @var string
|
128 |
+
*/
|
129 |
+
private $note;
|
130 |
+
/**
|
131 |
+
* The name of the generator used for this snippet (if any).
|
132 |
+
*
|
133 |
+
* @var string
|
134 |
+
*/
|
135 |
+
private $generator;
|
136 |
+
/**
|
137 |
+
* The generator fields.
|
138 |
+
*
|
139 |
+
* @var array
|
140 |
+
*/
|
141 |
+
private $generator_data;
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Constructor. If the post passed is not the correct post type
|
145 |
+
* the object will clear itself.
|
146 |
+
*
|
147 |
+
* @param array|int|WP_Post $snippet Load a snippet by id, WP_Post or array.
|
148 |
+
*/
|
149 |
+
public function __construct( $snippet ) {
|
150 |
+
if ( is_int( $snippet ) ) {
|
151 |
+
$this->load_from_id( $snippet );
|
152 |
+
} elseif ( $snippet instanceof WP_Post ) {
|
153 |
+
$this->post_data = $snippet;
|
154 |
+
} elseif ( is_array( $snippet ) ) {
|
155 |
+
$this->load_from_array( $snippet );
|
156 |
+
}
|
157 |
+
if ( isset( $this->post_data ) && 'wpcode' !== $this->post_data->post_type ) {
|
158 |
+
unset( $this->post_data );
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Load a snippet by its ID.
|
164 |
+
*
|
165 |
+
* @param int $snippet_id The snippet id.
|
166 |
+
*
|
167 |
+
* @return void
|
168 |
+
*/
|
169 |
+
public function load_from_id( $snippet_id ) {
|
170 |
+
$this->post_data = get_post( $snippet_id );
|
171 |
+
$this->id = $this->post_data->ID;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Load snippet from array - useful for creating a new snippet.
|
176 |
+
*
|
177 |
+
* @param array $snippet_data The array of data to load.
|
178 |
+
*
|
179 |
+
* @return void
|
180 |
+
*/
|
181 |
+
public function load_from_array( $snippet_data ) {
|
182 |
+
$available_options = get_object_vars( $this );
|
183 |
+
foreach ( $available_options as $key => $value ) {
|
184 |
+
if ( isset( $snippet_data[ $key ] ) ) {
|
185 |
+
$this->$key = $snippet_data[ $key ];
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Get the snippet location.
|
192 |
+
*
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
public function get_location() {
|
196 |
+
if ( ! isset( $this->location ) ) {
|
197 |
+
$this->set_location();
|
198 |
+
}
|
199 |
+
|
200 |
+
return $this->location;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Grab and set the location term and location string.
|
205 |
+
*
|
206 |
+
* @return void
|
207 |
+
*/
|
208 |
+
public function set_location() {
|
209 |
+
// If something below fails, let's not try again.
|
210 |
+
$this->location = '';
|
211 |
+
$this->location_term = $this->get_single_term( 'wpcode_location' );
|
212 |
+
if ( $this->location_term ) {
|
213 |
+
$this->location = $this->location_term->slug;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Get a single term for this snippet based on the taxonomy.
|
219 |
+
*
|
220 |
+
* @param string $taxonomy The taxonomy to grab data for.
|
221 |
+
*
|
222 |
+
* @return false|WP_Term
|
223 |
+
*/
|
224 |
+
public function get_single_term( $taxonomy ) {
|
225 |
+
if ( ! isset( $this->post_data ) ) {
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
$taxonomy_terms = wp_get_post_terms( $this->post_data->ID, $taxonomy );
|
229 |
+
if ( ! empty( $taxonomy_terms ) && ! is_wp_error( $taxonomy_terms ) ) {
|
230 |
+
return $taxonomy_terms[0];
|
231 |
+
}
|
232 |
+
|
233 |
+
return false;
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Get the author from the post object.
|
238 |
+
*
|
239 |
+
* @return int
|
240 |
+
*/
|
241 |
+
public function get_snippet_author() {
|
242 |
+
if ( isset( $this->post_data ) ) {
|
243 |
+
return $this->post_data->post_author;
|
244 |
+
}
|
245 |
+
|
246 |
+
return 0;
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Get the post data object.
|
251 |
+
*
|
252 |
+
* @return WP_Post
|
253 |
+
*/
|
254 |
+
public function get_post_data() {
|
255 |
+
return isset( $this->post_data ) ? $this->post_data : null;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Get the snippet title.
|
260 |
+
*
|
261 |
+
* @return string
|
262 |
+
*/
|
263 |
+
public function get_title() {
|
264 |
+
if ( ! isset( $this->title ) ) {
|
265 |
+
$this->title = isset( $this->post_data ) ? $this->post_data->post_title : '';
|
266 |
+
}
|
267 |
+
|
268 |
+
return $this->title;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Get the snippet code.
|
273 |
+
*
|
274 |
+
* @return string
|
275 |
+
*/
|
276 |
+
public function get_code() {
|
277 |
+
if ( ! isset( $this->code ) ) {
|
278 |
+
$this->code = isset( $this->post_data ) ? $this->post_data->post_content : '';
|
279 |
+
}
|
280 |
+
|
281 |
+
return $this->code;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Get location term.
|
286 |
+
*
|
287 |
+
* @return WP_Term
|
288 |
+
*/
|
289 |
+
public function get_location_term() {
|
290 |
+
if ( ! isset( $this->location_term ) ) {
|
291 |
+
$this->set_location();
|
292 |
+
}
|
293 |
+
|
294 |
+
return $this->location_term;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Get the code type term.
|
299 |
+
*
|
300 |
+
* @return WP_Term
|
301 |
+
*/
|
302 |
+
public function get_code_type_term() {
|
303 |
+
if ( ! isset( $this->code_type_term ) ) {
|
304 |
+
$this->set_code_type();
|
305 |
+
}
|
306 |
+
|
307 |
+
return $this->code_type_term;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Is the snippet active?
|
312 |
+
*
|
313 |
+
* @return boolean
|
314 |
+
*/
|
315 |
+
public function is_active() {
|
316 |
+
if ( ! isset( $this->active ) ) {
|
317 |
+
$this->active = 'publish' === $this->post_data->post_status;
|
318 |
+
}
|
319 |
+
|
320 |
+
return $this->active;
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Shorthand for activating.
|
325 |
+
*
|
326 |
+
* @return void
|
327 |
+
*/
|
328 |
+
public function activate() {
|
329 |
+
$this->active = true;
|
330 |
+
$this->get_id();
|
331 |
+
$this->save();
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Get the snippet id.
|
336 |
+
*
|
337 |
+
* @return int
|
338 |
+
*/
|
339 |
+
public function get_id() {
|
340 |
+
if ( ! isset( $this->id ) ) {
|
341 |
+
$this->id = isset( $this->post_data ) ? $this->post_data->ID : 0;
|
342 |
+
}
|
343 |
+
|
344 |
+
return $this->id;
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Store current object in the db.
|
349 |
+
*
|
350 |
+
* @return int|false
|
351 |
+
*/
|
352 |
+
public function save() {
|
353 |
+
$post_args = array(
|
354 |
+
'post_type' => 'wpcode',
|
355 |
+
);
|
356 |
+
if ( isset( $this->id ) && 0 !== $this->id ) {
|
357 |
+
$post_args['ID'] = $this->id;
|
358 |
+
$this->load_from_id( $this->id );
|
359 |
+
}
|
360 |
+
if ( isset( $this->title ) ) {
|
361 |
+
$post_args['post_title'] = $this->title;
|
362 |
+
}
|
363 |
+
if ( isset( $this->code ) ) {
|
364 |
+
$post_args['post_content'] = $this->code;
|
365 |
+
}
|
366 |
+
|
367 |
+
// If the user is not allowed to activate/deactivate snippets, prevent it and show error.
|
368 |
+
if ( ! current_user_can( 'wpcode_activate_snippets' ) ) {
|
369 |
+
wpcode()->error->add_error(
|
370 |
+
array(
|
371 |
+
'message' => __( 'You are not allowed to change snippet status, please contact your webmaster.', 'insert-headers-and-footers' ),
|
372 |
+
'type' => 'permissions',
|
373 |
+
)
|
374 |
+
);
|
375 |
+
unset( $this->active );
|
376 |
+
}
|
377 |
+
|
378 |
+
if ( isset( $this->active ) ) {
|
379 |
+
// If we're going to activate a snippet let's check if errors will be thrown.
|
380 |
+
$this->run_activation_checks();
|
381 |
+
$post_args['post_status'] = $this->active ? 'publish' : 'draft';
|
382 |
+
}
|
383 |
+
|
384 |
+
if ( isset( $post_args['ID'] ) ) {
|
385 |
+
$insert_result = wp_update_post( $post_args );
|
386 |
+
} else {
|
387 |
+
if ( empty( $post_args['post_title'] ) ) {
|
388 |
+
$post_args['post_title'] = $this->get_untitled_title();
|
389 |
+
}
|
390 |
+
$insert_result = wp_insert_post( $post_args );
|
391 |
+
}
|
392 |
+
|
393 |
+
if ( 0 === $insert_result || is_wp_error( $insert_result ) ) {
|
394 |
+
return false;
|
395 |
+
}
|
396 |
+
$this->id = $insert_result;
|
397 |
+
|
398 |
+
if ( isset( $this->code_type ) ) {
|
399 |
+
wp_set_post_terms( $this->id, $this->code_type, 'wpcode_type' );
|
400 |
+
}
|
401 |
+
if ( isset( $this->auto_insert ) ) {
|
402 |
+
// Save this value for reference, but we never query by it.
|
403 |
+
update_post_meta( $this->id, '_wpcode_auto_insert', $this->auto_insert );
|
404 |
+
}
|
405 |
+
if ( isset( $this->location ) && 1 === $this->auto_insert ) {
|
406 |
+
wp_set_post_terms( $this->id, $this->location, 'wpcode_location' );
|
407 |
+
} elseif ( isset( $this->auto_insert ) ) {
|
408 |
+
// If auto insert is disabled we just empty the taxonomy.
|
409 |
+
wp_set_post_terms( $this->id, array(), 'wpcode_location' );
|
410 |
+
}
|
411 |
+
if ( isset( $this->tags ) ) {
|
412 |
+
wp_set_post_terms( $this->id, $this->tags, 'wpcode_tags' );
|
413 |
+
}
|
414 |
+
if ( isset( $this->insert_number ) ) {
|
415 |
+
update_post_meta( $this->id, '_wpcode_auto_insert_number', $this->insert_number );
|
416 |
+
}
|
417 |
+
if ( isset( $this->use_rules ) ) {
|
418 |
+
update_post_meta( $this->id, '_wpcode_conditional_logic_enabled', $this->use_rules );
|
419 |
+
}
|
420 |
+
if ( isset( $this->rules ) ) {
|
421 |
+
update_post_meta( $this->id, '_wpcode_conditional_logic', $this->rules );
|
422 |
+
}
|
423 |
+
if ( isset( $this->priority ) ) {
|
424 |
+
update_post_meta( $this->id, '_wpcode_priority', $this->priority );
|
425 |
+
}
|
426 |
+
if ( isset( $this->library_id ) ) {
|
427 |
+
update_post_meta( $this->id, '_wpcode_library_id', $this->library_id );
|
428 |
+
}
|
429 |
+
if ( isset( $this->library_version ) ) {
|
430 |
+
update_post_meta( $this->id, '_wpcode_library_version', $this->library_version );
|
431 |
+
}
|
432 |
+
if ( isset( $this->note ) ) {
|
433 |
+
update_post_meta( $this->id, '_wpcode_note', $this->note );
|
434 |
+
}
|
435 |
+
if ( isset( $this->generator ) ) {
|
436 |
+
update_post_meta( $this->id, '_wpcode_generator', $this->generator );
|
437 |
+
}
|
438 |
+
if ( isset( $this->generator_data ) ) {
|
439 |
+
update_post_meta( $this->id, '_wpcode_generator_data', $this->generator_data );
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Run extra logic after the snippet is saved.
|
444 |
+
*
|
445 |
+
* @param int $id The id of the updated snippet.
|
446 |
+
* @param WPCode_Snippet $snippet The snippet object.
|
447 |
+
*/
|
448 |
+
do_action( 'wpcode_snippet_after_update', $this->id, $this );
|
449 |
+
|
450 |
+
wpcode()->cache->cache_all_loaded_snippets();
|
451 |
+
|
452 |
+
return $this->id;
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Check if a snippet can be run without errors before activating it.
|
457 |
+
*
|
458 |
+
* @return void
|
459 |
+
*/
|
460 |
+
public function run_activation_checks() {
|
461 |
+
$executed_types = array(
|
462 |
+
'php',
|
463 |
+
'universal',
|
464 |
+
);
|
465 |
+
if ( ! in_array( $this->get_code_type(), $executed_types, true ) ) {
|
466 |
+
// If the code is not getting executed just skip.
|
467 |
+
return;
|
468 |
+
}
|
469 |
+
if ( false === $this->active || isset( $this->post_data ) && 'publish' === $this->post_data->post_status ) {
|
470 |
+
// If we're not trying to activate or the snippet is already active, bail.
|
471 |
+
return;
|
472 |
+
}
|
473 |
+
// Make sure no errors are added by something else.
|
474 |
+
wpcode()->error->clear_errors();
|
475 |
+
// Try running the code.
|
476 |
+
// Grab the executor class specific to the code type.
|
477 |
+
$executor = wpcode()->execute->get_type_execute_class( $this->get_code_type() );
|
478 |
+
// Mark this as an activation attempt.
|
479 |
+
wpcode()->execute->doing_activation();
|
480 |
+
/**
|
481 |
+
* Added for convenience.
|
482 |
+
*
|
483 |
+
* @var WPCode_Snippet_Execute_Type $executor
|
484 |
+
*/
|
485 |
+
$execute = new $executor( $this );
|
486 |
+
// Grab the output that executes the code.
|
487 |
+
$execute->get_output();
|
488 |
+
// If any errors are caught, prevent the status from being changed.
|
489 |
+
$has_error = wpcode()->error->has_error();
|
490 |
+
if ( $has_error ) {
|
491 |
+
$this->active = false;
|
492 |
+
}
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Return the code type.
|
497 |
+
*
|
498 |
+
* @return string
|
499 |
+
*/
|
500 |
+
public function get_code_type() {
|
501 |
+
if ( ! isset( $this->code_type ) ) {
|
502 |
+
$this->set_code_type();
|
503 |
+
}
|
504 |
+
|
505 |
+
return $this->code_type;
|
506 |
+
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* Grab the code type from the taxonomy.
|
510 |
+
*
|
511 |
+
* @return void
|
512 |
+
*/
|
513 |
+
public function set_code_type() {
|
514 |
+
// If something below fails, let's not try again.
|
515 |
+
$this->code_type = '';
|
516 |
+
$this->code_type_term = $this->get_single_term( 'wpcode_type' );
|
517 |
+
if ( $this->code_type_term ) {
|
518 |
+
$this->code_type = $this->code_type_term->slug;
|
519 |
+
}
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Get the default title for snippets with no title set.
|
524 |
+
*
|
525 |
+
* @return string
|
526 |
+
*/
|
527 |
+
public function get_untitled_title() {
|
528 |
+
return __( 'Untitled Snippet', 'insert-headers-and-footers' );
|
529 |
+
}
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Shorthand for deactivating a snippet.
|
533 |
+
*
|
534 |
+
* @return void
|
535 |
+
*/
|
536 |
+
public function deactivate() {
|
537 |
+
$this->active = false;
|
538 |
+
$this->get_id();
|
539 |
+
$this->save();
|
540 |
+
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Get the auto insert number.
|
544 |
+
*
|
545 |
+
* @return int
|
546 |
+
*/
|
547 |
+
public function get_auto_insert_number() {
|
548 |
+
if ( ! isset( $this->insert_number ) ) {
|
549 |
+
$this->insert_number = absint( get_post_meta( $this->get_id(), '_wpcode_auto_insert_number', true ) );
|
550 |
+
// Default value should be 1.
|
551 |
+
if ( 0 === $this->insert_number ) {
|
552 |
+
$this->insert_number = 1;
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
return $this->insert_number;
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Get the auto-insert value.
|
561 |
+
*
|
562 |
+
* @return int
|
563 |
+
*/
|
564 |
+
public function get_auto_insert() {
|
565 |
+
if ( ! isset( $this->auto_insert ) ) {
|
566 |
+
$this->auto_insert = absint( get_post_meta( $this->get_id(), '_wpcode_auto_insert', true ) );
|
567 |
+
}
|
568 |
+
|
569 |
+
return $this->auto_insert;
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Get the array of tag slugs.
|
574 |
+
*
|
575 |
+
* @return string[]
|
576 |
+
*/
|
577 |
+
public function get_tags() {
|
578 |
+
if ( ! isset( $this->tags ) ) {
|
579 |
+
$this->set_tags();
|
580 |
+
}
|
581 |
+
|
582 |
+
return $this->tags;
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Set the tags for the current snippet.
|
587 |
+
*
|
588 |
+
* @return void
|
589 |
+
*/
|
590 |
+
public function set_tags() {
|
591 |
+
$tags = wp_get_post_terms( $this->get_id(), 'wpcode_tags' );
|
592 |
+
$tag_slugs = array();
|
593 |
+
foreach ( $tags as $tag ) {
|
594 |
+
/**
|
595 |
+
* The tag term object.
|
596 |
+
*
|
597 |
+
* @var WP_Term $tag
|
598 |
+
*/
|
599 |
+
$tag_slugs[] = $tag->slug;
|
600 |
+
}
|
601 |
+
$this->tags = $tag_slugs;
|
602 |
+
$this->tags_terms = $tags;
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Get the conditional logic rules from the db.
|
607 |
+
*
|
608 |
+
* @return array
|
609 |
+
*/
|
610 |
+
public function get_conditional_rules() {
|
611 |
+
if ( ! isset( $this->rules ) ) {
|
612 |
+
$rules = get_post_meta( $this->get_id(), '_wpcode_conditional_logic', true );
|
613 |
+
if ( empty( $rules ) ) {
|
614 |
+
$rules = array();
|
615 |
+
}
|
616 |
+
$this->rules = $rules;
|
617 |
+
}
|
618 |
+
|
619 |
+
return $this->rules;
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Are the conditional logic rules enabled?
|
624 |
+
*
|
625 |
+
* @return bool
|
626 |
+
*/
|
627 |
+
public function conditional_rules_enabled() {
|
628 |
+
if ( ! isset( $this->use_rules ) ) {
|
629 |
+
$enabled = get_post_meta( $this->get_id(), '_wpcode_conditional_logic_enabled', true );
|
630 |
+
if ( '' === $enabled ) {
|
631 |
+
$enabled = false;
|
632 |
+
}
|
633 |
+
$this->use_rules = boolval( $enabled );
|
634 |
+
}
|
635 |
+
|
636 |
+
return $this->use_rules;
|
637 |
+
}
|
638 |
+
|
639 |
+
/**
|
640 |
+
* Get the note for this snippet.
|
641 |
+
*
|
642 |
+
* @return string
|
643 |
+
*/
|
644 |
+
public function get_note() {
|
645 |
+
if ( ! isset( $this->note ) ) {
|
646 |
+
$this->note = get_post_meta( $this->get_id(), '_wpcode_note', true );
|
647 |
+
}
|
648 |
+
|
649 |
+
return $this->note;
|
650 |
+
}
|
651 |
+
|
652 |
+
/**
|
653 |
+
* Get the priority number for this snippet.
|
654 |
+
*
|
655 |
+
* @return int
|
656 |
+
*/
|
657 |
+
public function get_priority() {
|
658 |
+
if ( ! isset( $this->priority ) ) {
|
659 |
+
$priority = get_post_meta( $this->get_id(), '_wpcode_priority', true );
|
660 |
+
if ( '' === $priority ) {
|
661 |
+
$priority = 10;
|
662 |
+
}
|
663 |
+
$this->priority = intval( $priority );
|
664 |
+
}
|
665 |
+
|
666 |
+
return $this->priority;
|
667 |
+
}
|
668 |
+
|
669 |
+
/**
|
670 |
+
* Get essential data for caching.
|
671 |
+
*
|
672 |
+
* @return array
|
673 |
+
*/
|
674 |
+
public function get_data_for_caching() {
|
675 |
+
return array(
|
676 |
+
'id' => $this->get_id(),
|
677 |
+
'title' => $this->get_title(),
|
678 |
+
'code' => $this->get_code(),
|
679 |
+
'code_type' => $this->get_code_type(),
|
680 |
+
'location' => $this->get_location(),
|
681 |
+
'auto_insert' => $this->get_auto_insert(),
|
682 |
+
'insert_number' => $this->get_auto_insert_number(),
|
683 |
+
'use_rules' => $this->conditional_rules_enabled(),
|
684 |
+
'rules' => $this->get_conditional_rules(),
|
685 |
+
'priority' => $this->get_priority(),
|
686 |
+
);
|
687 |
+
}
|
688 |
+
}
|
includes/conditional-logic/class-wpcode-conditional-page.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class that handles conditional logic related to pages.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The WPCode_Conditional_Page class.
|
10 |
+
*/
|
11 |
+
class WPCode_Conditional_Page extends WPCode_Conditional_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The type unique name (slug).
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'page';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Set the translatable label.
|
22 |
+
*
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
protected function set_label() {
|
26 |
+
$this->label = __( 'Page', 'insert-headers-and-footers' );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the type options for the admin mainly.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function load_type_options() {
|
35 |
+
$this->options = array(
|
36 |
+
'type_of_page' => array(
|
37 |
+
'label' => __( 'Type of page', 'insert-headers-and-footers' ),
|
38 |
+
'type' => 'select',
|
39 |
+
'options' => array(
|
40 |
+
array(
|
41 |
+
'label' => __( 'Homepage', 'insert-headers-and-footers' ),
|
42 |
+
'value' => 'is_front_page',
|
43 |
+
),
|
44 |
+
array(
|
45 |
+
'label' => __( 'Archive', 'insert-headers-and-footers' ),
|
46 |
+
'value' => 'is_archive',
|
47 |
+
),
|
48 |
+
array(
|
49 |
+
'label' => __( 'Single post/page', 'insert-headers-and-footers' ),
|
50 |
+
'value' => 'is_single',
|
51 |
+
),
|
52 |
+
array(
|
53 |
+
'label' => __( 'Search page', 'insert-headers-and-footers' ),
|
54 |
+
'value' => 'is_search',
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'label' => __( '404 page', 'insert-headers-and-footers' ),
|
58 |
+
'value' => 'is_404',
|
59 |
+
),
|
60 |
+
array(
|
61 |
+
'label' => __( 'Author page', 'insert-headers-and-footers' ),
|
62 |
+
'value' => 'is_author',
|
63 |
+
),
|
64 |
+
),
|
65 |
+
'callback' => array( $this, 'get_type_of_page' ),
|
66 |
+
),
|
67 |
+
'post_type' => array(
|
68 |
+
'label' => __( 'Post type', 'insert-headers-and-footers' ),
|
69 |
+
'type' => 'select',
|
70 |
+
'options' => $this->get_post_types(),
|
71 |
+
'callback' => array( $this, 'get_current_post_type' ),
|
72 |
+
),
|
73 |
+
'referrer' => array(
|
74 |
+
'label' => __( 'Referrer', 'insert-headers-and-footers' ),
|
75 |
+
'type' => 'text',
|
76 |
+
'callback' => array( $this, 'get_referer' ),
|
77 |
+
),
|
78 |
+
'taxonomy_page' => array(
|
79 |
+
'label' => __( 'Taxonomy page', 'insert-headers-and-footers' ),
|
80 |
+
'type' => 'select',
|
81 |
+
'options' => $this->get_taxonomies_options(),
|
82 |
+
'callback' => array( $this, 'get_taxonomy' ),
|
83 |
+
),
|
84 |
+
'taxonomy_term' => array(
|
85 |
+
'label' => __( 'Taxonomy term', 'insert-headers-and-footers' ),
|
86 |
+
'type' => 'ajax',
|
87 |
+
'options' => 'wpcode_search_terms',
|
88 |
+
'callback' => array( $this, 'get_term' ),
|
89 |
+
'labels_callback' => array( $this, 'get_taxonomy_term_labels' ),
|
90 |
+
),
|
91 |
+
'page_url' => array(
|
92 |
+
'label' => __( 'Page URL', 'insert-headers-and-footers' ),
|
93 |
+
'type' => 'text',
|
94 |
+
'callback' => array( $this, 'get_page_url' ),
|
95 |
+
),
|
96 |
+
);
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Get a list of options with post types.
|
101 |
+
*
|
102 |
+
* @return array
|
103 |
+
*/
|
104 |
+
protected function get_post_types() {
|
105 |
+
$post_types = get_post_types( array( 'public' => true ), 'objects' );
|
106 |
+
$options = array();
|
107 |
+
foreach ( $post_types as $post_type ) {
|
108 |
+
$options[] = array(
|
109 |
+
'label' => $post_type->label,
|
110 |
+
'value' => $post_type->name,
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
return $options;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Get a list of taxonomy types.
|
119 |
+
*
|
120 |
+
* @return array
|
121 |
+
*/
|
122 |
+
protected function get_taxonomies_options() {
|
123 |
+
$taxonomies = get_taxonomies(
|
124 |
+
array(
|
125 |
+
'public' => true,
|
126 |
+
),
|
127 |
+
'objects'
|
128 |
+
);
|
129 |
+
$options = array();
|
130 |
+
foreach ( $taxonomies as $taxonomy ) {
|
131 |
+
if ( 'post_format' === $taxonomy->name ) {
|
132 |
+
continue;
|
133 |
+
}
|
134 |
+
$options[] = array(
|
135 |
+
// Translators: this is the name of the taxonomy.
|
136 |
+
'label' => $taxonomy->labels->singular_name,
|
137 |
+
'value' => $taxonomy->name,
|
138 |
+
);
|
139 |
+
}
|
140 |
+
|
141 |
+
return $options;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Get the type of page.
|
146 |
+
*
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public function get_type_of_page() {
|
150 |
+
if ( is_singular() ) {
|
151 |
+
return 'is_single';
|
152 |
+
}
|
153 |
+
if ( is_archive() ) {
|
154 |
+
return 'is_archive';
|
155 |
+
}
|
156 |
+
if ( is_search() ) {
|
157 |
+
return 'is_search';
|
158 |
+
}
|
159 |
+
if ( is_front_page() || is_home() ) {
|
160 |
+
return 'is_front_page';
|
161 |
+
}
|
162 |
+
if ( is_404() ) {
|
163 |
+
return 'is_404';
|
164 |
+
}
|
165 |
+
if ( is_author() ) {
|
166 |
+
return 'is_author';
|
167 |
+
}
|
168 |
+
|
169 |
+
return '';
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Get the current page post type, if any.
|
174 |
+
*
|
175 |
+
* @return string
|
176 |
+
*/
|
177 |
+
public function get_current_post_type() {
|
178 |
+
return get_post_type();
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Get the referrer from PHP.
|
183 |
+
*
|
184 |
+
* @return string
|
185 |
+
*/
|
186 |
+
public function get_referer() {
|
187 |
+
return isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Get the page URL.
|
192 |
+
*
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
public function get_page_url() {
|
196 |
+
return isset( $_SERVER['REQUEST_URI'] ) ? home_url( $_SERVER['REQUEST_URI'] ) : '';
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Check if the current page is a taxonomy page and if yes get the taxonomy name.
|
201 |
+
*
|
202 |
+
* @return string
|
203 |
+
*/
|
204 |
+
public function get_taxonomy() {
|
205 |
+
$queried_object = get_queried_object();
|
206 |
+
|
207 |
+
return isset( $queried_object->taxonomy ) ? $queried_object->taxonomy : '';
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Get the term of the current page, if any.
|
212 |
+
*
|
213 |
+
* @return array
|
214 |
+
*/
|
215 |
+
public function get_term() {
|
216 |
+
if ( is_tax() ) {
|
217 |
+
$queried_object = get_queried_object();
|
218 |
+
|
219 |
+
return isset( $queried_object->queried_object_id ) ? array( $queried_object->queried_object_id ) : array();
|
220 |
+
}
|
221 |
+
if ( is_singular() ) {
|
222 |
+
return get_terms(
|
223 |
+
array(
|
224 |
+
'object_ids' => array( get_the_ID() ),
|
225 |
+
'fields' => 'ids',
|
226 |
+
)
|
227 |
+
);
|
228 |
+
}
|
229 |
+
|
230 |
+
return array();
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Get the term labels for the taxonomy term value loading in the admin form.
|
235 |
+
*
|
236 |
+
* @param array $values The values that are selected.
|
237 |
+
*
|
238 |
+
* @return array
|
239 |
+
*/
|
240 |
+
public function get_taxonomy_term_labels( $values ) {
|
241 |
+
$labels = array();
|
242 |
+
foreach ( $values as $term_id ) {
|
243 |
+
$term = get_term( $term_id );
|
244 |
+
if ( is_null( $term ) || is_wp_error( $term ) ) {
|
245 |
+
continue;
|
246 |
+
}
|
247 |
+
$labels[] = array(
|
248 |
+
'value' => $term_id,
|
249 |
+
'label' => $term->name,
|
250 |
+
);
|
251 |
+
}
|
252 |
+
|
253 |
+
return $labels;
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Override the main rule evaluate function to add some specific processing of values.
|
258 |
+
*
|
259 |
+
* @param array $rule_group The rule group array to evaluate.
|
260 |
+
*
|
261 |
+
* @return bool
|
262 |
+
*/
|
263 |
+
public function evaluate_rule_row( $rule_group ) {
|
264 |
+
if ( 'page_url' === $rule_group['option'] ) {
|
265 |
+
$rule_group['value'] = trailingslashit( $rule_group['value'] );
|
266 |
+
}
|
267 |
+
|
268 |
+
return parent::evaluate_rule_row( $rule_group );
|
269 |
+
}
|
270 |
+
}
|
includes/conditional-logic/class-wpcode-conditional-type.php
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Base class for types of conditional logic options.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Abstract class WPCode_Conditional_Type
|
10 |
+
*/
|
11 |
+
abstract class WPCode_Conditional_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* An array of options for this type.
|
15 |
+
*
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $options;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The type label.
|
22 |
+
*
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
public $label;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The type name.
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
public $name;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Constructor.
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
+
// Add hooks.
|
39 |
+
$this->hooks();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add type-specific hooks, if any.
|
44 |
+
* Here's where we should add admin-ajax handlers that are specific
|
45 |
+
* to the conditionals.
|
46 |
+
*
|
47 |
+
* @return void
|
48 |
+
*/
|
49 |
+
protected function hooks() {
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get the options for this type.
|
55 |
+
*
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
public function get_type_options() {
|
59 |
+
if ( ! isset( $this->options ) ) {
|
60 |
+
$this->load_type_options();
|
61 |
+
}
|
62 |
+
|
63 |
+
return $this->options;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Set the type label with a translatable string.
|
68 |
+
*
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
abstract protected function set_label();
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Load the options for this type of conditions.
|
75 |
+
*
|
76 |
+
* @return void
|
77 |
+
*/
|
78 |
+
abstract protected function load_type_options();
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Get the label.
|
82 |
+
*
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function get_label() {
|
86 |
+
if ( ! isset( $this->label ) ) {
|
87 |
+
$this->set_label();
|
88 |
+
}
|
89 |
+
|
90 |
+
return $this->label;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Get the type name.
|
95 |
+
*
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
public function get_name() {
|
99 |
+
return $this->name;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Process a rule group specific to the conditions type.
|
104 |
+
*
|
105 |
+
* @param array $rule_group An array of rules with keys option,relation and value.
|
106 |
+
*
|
107 |
+
* @return bool
|
108 |
+
*/
|
109 |
+
public function evaluate_rule_row( $rule_group ) {
|
110 |
+
return $this->evaluate_rule( $rule_group['option'], $rule_group['relation'], $rule_group['value'] );
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* This takes an option name from the list of options for the type
|
115 |
+
* and if it finds it, it executes the callback defined in the list of
|
116 |
+
* options and compares that value to the set value using the operator
|
117 |
+
* set in the settings.
|
118 |
+
*
|
119 |
+
* @param string $option The option to evaluate.
|
120 |
+
* @param string $relation The comparison relation.
|
121 |
+
* @param string $value The selected value for this condition.
|
122 |
+
*
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
protected function evaluate_rule( $option, $relation, $value ) {
|
126 |
+
$options = $this->get_type_options();
|
127 |
+
if ( ! isset( $options [ $option ] ) ) {
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
$option_details = $options[ $option ];
|
131 |
+
$callback = $option_details['callback'];
|
132 |
+
|
133 |
+
return $this->get_relation_comparison( $callback(), $value, $relation );
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Takes 2 values and an operator and finds the appropriate function
|
138 |
+
* to evaluate the relation between them.
|
139 |
+
*
|
140 |
+
* @param mixed $value1 This is the first value to compare with value 2.
|
141 |
+
* @param mixed $value2 This is the 2nd value.
|
142 |
+
* @param string $operator This is the operator string.
|
143 |
+
*
|
144 |
+
* @return bool
|
145 |
+
*/
|
146 |
+
protected function get_relation_comparison( $value1, $value2, $operator ) {
|
147 |
+
switch ( $operator ) {
|
148 |
+
case '=':
|
149 |
+
$result = $this->equals( $value1, $value2 );
|
150 |
+
break;
|
151 |
+
case '!=':
|
152 |
+
$result = $this->does_not_equal( $value1, $value2 );
|
153 |
+
break;
|
154 |
+
case 'contains':
|
155 |
+
$result = $this->contains( $value1, $value2 );
|
156 |
+
break;
|
157 |
+
case 'notcontains':
|
158 |
+
$result = ! $this->contains( $value1, $value2 );
|
159 |
+
break;
|
160 |
+
default:
|
161 |
+
$result = true;
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
|
165 |
+
return $result;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Does an equals comparison (not strict), also handles arrays to
|
170 |
+
* make it easier to compare things like user roles.
|
171 |
+
*
|
172 |
+
* @param mixed $value1 Value 1.
|
173 |
+
* @param mixed $value2 Value to compare value 1 to.
|
174 |
+
*
|
175 |
+
* @return bool
|
176 |
+
*/
|
177 |
+
private function equals( $value1, $value2 ) {
|
178 |
+
if ( is_array( $value1 ) ) {
|
179 |
+
if ( is_array( $value2 ) ) {
|
180 |
+
return count( array_intersect( $value1, $value2 ) ) > 0;
|
181 |
+
}
|
182 |
+
return in_array( $value2, $value1 );
|
183 |
+
}
|
184 |
+
|
185 |
+
return $value1 == $value2;
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Does an does not equal comparison (not strict), also handles arrays to
|
190 |
+
* make it easier to compare things like user roles.
|
191 |
+
*
|
192 |
+
* @param mixed $value1 Value 1.
|
193 |
+
* @param mixed $value2 Value to compare value 1 to.
|
194 |
+
*
|
195 |
+
* @return bool
|
196 |
+
*/
|
197 |
+
private function does_not_equal( $value1, $value2 ) {
|
198 |
+
if ( is_array( $value1 ) ) {
|
199 |
+
if ( is_array( $value2 ) ) {
|
200 |
+
return count( array_intersect( $value1, $value2 ) ) === 0;
|
201 |
+
}
|
202 |
+
return ! in_array( $value2, $value1 );
|
203 |
+
}
|
204 |
+
|
205 |
+
return $value1 != $value2;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Check if value1 contains value2.
|
210 |
+
*
|
211 |
+
* @param string $value1 Value in which to look for value 2.
|
212 |
+
* @param string $value2 The value to look for in value 1.
|
213 |
+
*
|
214 |
+
* @return bool
|
215 |
+
*/
|
216 |
+
private function contains( $value1, $value2 ) {
|
217 |
+
return false !== strpos( $value1, $value2 );
|
218 |
+
}
|
219 |
+
}
|
includes/conditional-logic/class-wpcode-conditional-user.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class that handles conditional logic related to users.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The WPCode_Conditional_User class.
|
10 |
+
*/
|
11 |
+
class WPCode_Conditional_User extends WPCode_Conditional_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The type unique name (slug).
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'user';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Set the translatable label.
|
22 |
+
*
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
protected function set_label() {
|
26 |
+
$this->label = __( 'User', 'insert-headers-and-footers' );
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the type options for the admin mainly.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function load_type_options() {
|
35 |
+
$this->options = array(
|
36 |
+
'logged_in' => array(
|
37 |
+
'label' => __( 'Logged-in', 'insert-headers-and-footers' ),
|
38 |
+
'type' => 'select',
|
39 |
+
'options' => array(
|
40 |
+
array(
|
41 |
+
'label' => __( 'True', 'insert-headers-and-footers' ),
|
42 |
+
'value' => true,
|
43 |
+
),
|
44 |
+
array(
|
45 |
+
'label' => __( 'False', 'insert-headers-and-footers' ),
|
46 |
+
'value' => false,
|
47 |
+
),
|
48 |
+
),
|
49 |
+
'callback' => 'is_user_logged_in',
|
50 |
+
),
|
51 |
+
'user_role' => array(
|
52 |
+
'label' => __( 'User Role', 'insert-headers-and-footers' ),
|
53 |
+
'type' => 'select',
|
54 |
+
'options' => $this->get_options_user_roles(),
|
55 |
+
'callback' => array( $this, 'get_user_role' ),
|
56 |
+
),
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get a list of options for user roles.
|
62 |
+
*
|
63 |
+
* @return array
|
64 |
+
*/
|
65 |
+
protected function get_options_user_roles() {
|
66 |
+
$user_roles = wp_roles()->roles;
|
67 |
+
$options = array();
|
68 |
+
foreach ( $user_roles as $key => $role ) {
|
69 |
+
$options[] = array(
|
70 |
+
'label' => $role['name'],
|
71 |
+
'value' => $key,
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
return $options;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get an array of user roles for the current user.
|
80 |
+
*
|
81 |
+
* @return string[]
|
82 |
+
*/
|
83 |
+
public function get_user_role() {
|
84 |
+
$user = wp_get_current_user();
|
85 |
+
|
86 |
+
return $user->roles;
|
87 |
+
}
|
88 |
+
}
|
includes/execute/class-wpcode-snippet-execute-html.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Execute html snippets and return their output.
|
4 |
+
* This is probably the simplest one.
|
5 |
+
*
|
6 |
+
* @package wpcode
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* WPCode_Snippet_Execute_HTML class.
|
11 |
+
*/
|
12 |
+
class WPCode_Snippet_Execute_HTML extends WPCode_Snippet_Execute_Type {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* The snippet type, HTML for this one.
|
16 |
+
*
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
public $type = 'html';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Grab snippet code and return its output.
|
23 |
+
*
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
protected function prepare_snippet_output() {
|
27 |
+
// There's nothing to prepare here at this point.
|
28 |
+
return $this->get_snippet_code();
|
29 |
+
}
|
30 |
+
}
|
includes/execute/class-wpcode-snippet-execute-js.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Execute JavaScript snippets and return their output.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Snippet_Execute_Text class.
|
10 |
+
*/
|
11 |
+
class WPCode_Snippet_Execute_JS extends WPCode_Snippet_Execute_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The snippet type, JavaScript for this one.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $type = 'js';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Grab snippet code and return its output.
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
protected function prepare_snippet_output() {
|
26 |
+
$code = $this->get_snippet_code();
|
27 |
+
|
28 |
+
if ( ! empty( $code ) ) {
|
29 |
+
// Wrap our code in a script tag.
|
30 |
+
$code = '<script>' . $code . '</script>';
|
31 |
+
}
|
32 |
+
|
33 |
+
return $code;
|
34 |
+
}
|
35 |
+
}
|
includes/execute/class-wpcode-snippet-execute-php.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Execute php snippets and return their output.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Snippet_Execute_PHP class.
|
10 |
+
*/
|
11 |
+
class WPCode_Snippet_Execute_PHP extends WPCode_Snippet_Execute_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The snippet type, PHP for this one.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $type = 'php';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Grab snippet code and return its output.
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
protected function prepare_snippet_output() {
|
26 |
+
$code = $this->get_snippet_code();
|
27 |
+
|
28 |
+
return wpcode()->execute->safe_execute_php( $code, $this->snippet );
|
29 |
+
}
|
30 |
+
}
|
includes/execute/class-wpcode-snippet-execute-text.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Execute text snippets and return their output.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Snippet_Execute_Text class.
|
10 |
+
*/
|
11 |
+
class WPCode_Snippet_Execute_Text extends WPCode_Snippet_Execute_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The snippet type, Text for this one.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $type = 'text';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Grab snippet code and return its output.
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
protected function prepare_snippet_output() {
|
26 |
+
// There's nothing to prepare here at this point.
|
27 |
+
if ( apply_filters( 'wpcode_text_execute_shortcodes', true ) ) {
|
28 |
+
return do_shortcode( $this->get_snippet_code() );
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this->get_snippet_code();
|
32 |
+
}
|
33 |
+
}
|
includes/execute/class-wpcode-snippet-execute-type.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Abstract class for executing different type of snippets.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Snippet_Execute_Type class.
|
10 |
+
*/
|
11 |
+
abstract class WPCode_Snippet_Execute_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The type of snippet.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $type;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Loaded post data.
|
22 |
+
*
|
23 |
+
* @var WPCode_Snippet
|
24 |
+
*/
|
25 |
+
public $snippet;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Load the snippet by id or post object.
|
29 |
+
*
|
30 |
+
* @param WPCode_Snippet $snippet The snippet post or the id.
|
31 |
+
*/
|
32 |
+
public function __construct( $snippet ) {
|
33 |
+
$this->snippet = $snippet;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get the snippet prepared code and run it through a filter
|
38 |
+
* before returning it.
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function get_output() {
|
43 |
+
if ( ! $this->has_snippet() ) {
|
44 |
+
return '';
|
45 |
+
}
|
46 |
+
|
47 |
+
$code = $this->prepare_snippet_output();
|
48 |
+
|
49 |
+
return apply_filters( "wpcode_snippet_output_{$this->type}", $code, $this->snippet );
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Check if the snippet object is set.
|
54 |
+
*
|
55 |
+
* @return bool
|
56 |
+
*/
|
57 |
+
public function has_snippet() {
|
58 |
+
return isset( $this->snippet );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Override this in child classes to add specific logic for each snippet type.
|
63 |
+
*
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
protected function prepare_snippet_output() {
|
67 |
+
return '';
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get the snippet code.
|
72 |
+
*
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function get_snippet_code() {
|
76 |
+
return $this->snippet->get_code();
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
includes/execute/class-wpcode-snippet-execute-universal.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Execute universal snippets and return their output.
|
4 |
+
* This type handles both HTML and PHP at the same time in the same way
|
5 |
+
* you can write both in a .php file.
|
6 |
+
*
|
7 |
+
* @package wpcode
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* WPCode_Snippet_Execute_Universal class.
|
12 |
+
*/
|
13 |
+
class WPCode_Snippet_Execute_Universal extends WPCode_Snippet_Execute_Type {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* The snippet type, Universal for this one.
|
17 |
+
*
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $type = 'universal';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Grab snippet code and return its output.
|
24 |
+
*
|
25 |
+
* @return string
|
26 |
+
*/
|
27 |
+
protected function prepare_snippet_output() {
|
28 |
+
|
29 |
+
$code = $this->get_snippet_code();
|
30 |
+
|
31 |
+
// Wrap code with PHP tags, so it gets executed correctly.
|
32 |
+
return wpcode()->execute->safe_execute_php( '?>' . $code . '<?php ', $this->snippet );
|
33 |
+
}
|
34 |
+
}
|
includes/generator/class-wpcode-generator-admin-bar.php
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to add a custom menu to the admin bar.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The Post Status generator.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Admin_Bar extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'admin-bar';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'admin',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Admin Bar Menu', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Add a custom admin bar menu with links or content.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Generate a snippet to add a custom menu to the admin bar by filling in a simple form.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms sections using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => __( 'You could add a new admin bar menu for links you use often, a list of posts, a site you often visit when in the admin, etc.', 'insert-headers-and-footers' ),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
'general' => array(
|
84 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
85 |
+
'columns' => array(
|
86 |
+
// Column 1.
|
87 |
+
array(
|
88 |
+
array(
|
89 |
+
'type' => 'text',
|
90 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
91 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
92 |
+
'id' => 'function_name',
|
93 |
+
'placeholder' => 'add_admin_bar_item',
|
94 |
+
'default' => 'add_admin_bar_item' . time(),
|
95 |
+
),
|
96 |
+
),
|
97 |
+
// Column 2.
|
98 |
+
array(
|
99 |
+
array(
|
100 |
+
'type' => 'select',
|
101 |
+
'label' => __( 'Position', 'insert-headers-and-footers' ),
|
102 |
+
'description' => __( 'Select where you want the menu item to be displayed on the admin bar.', 'insert-headers-and-footers' ),
|
103 |
+
'id' => 'priority',
|
104 |
+
'default' => '1100',
|
105 |
+
'options' => array(
|
106 |
+
'1100' => __( 'Last item on the left', 'insert-headers-and-footers' ),
|
107 |
+
'30' => __( 'Before Site Name', 'insert-headers-and-footers' ),
|
108 |
+
'50' => __( 'After Site Name', 'insert-headers-and-footers' ),
|
109 |
+
'70' => __( 'Before "New" Button' ),
|
110 |
+
'80' => __( 'After "New" Button' ),
|
111 |
+
),
|
112 |
+
),
|
113 |
+
),
|
114 |
+
),
|
115 |
+
),
|
116 |
+
'menu' => array(
|
117 |
+
'label' => __( 'Menu Structure', 'insert-headers-and-footers' ),
|
118 |
+
'columns' => array(
|
119 |
+
// Column 1.
|
120 |
+
array(
|
121 |
+
array(
|
122 |
+
'type' => 'text',
|
123 |
+
'label' => __( 'Menu ID', 'insert-headers-and-footers' ),
|
124 |
+
'description' => __( 'Unique menu id for the admin bar menu.', 'insert-headers-and-footers' ),
|
125 |
+
'id' => 'menu_id',
|
126 |
+
'placeholder' => 'custom_menu_id',
|
127 |
+
'default' => 'custom_menu_id',
|
128 |
+
),
|
129 |
+
array(
|
130 |
+
'type' => 'text',
|
131 |
+
'label' => __( 'Menu Title', 'insert-headers-and-footers' ),
|
132 |
+
'description' => __( 'Text or HTML that will show up in the admin bar top-level item. Use HTML if you want to display an image.', 'insert-headers-and-footers' ),
|
133 |
+
'id' => 'menu_title',
|
134 |
+
'placeholder' => '',
|
135 |
+
'default' => '',
|
136 |
+
),
|
137 |
+
array(
|
138 |
+
'type' => 'text',
|
139 |
+
'label' => __( 'Menu item link', 'insert-headers-and-footers' ),
|
140 |
+
'description' => __( 'If left empty, the top level menu item will not be a link, just text.', 'insert-headers-and-footers' ),
|
141 |
+
'id' => 'menu_href',
|
142 |
+
'placeholder' => '',
|
143 |
+
'default' => '',
|
144 |
+
),
|
145 |
+
array(
|
146 |
+
'type' => 'text',
|
147 |
+
'label' => __( 'Menu item target', 'insert-headers-and-footers' ),
|
148 |
+
'description' => __( 'The menu item is a link use this field to set the target attribute. Use "_blank" to open the link in a new tab.', 'insert-headers-and-footers' ),
|
149 |
+
'id' => 'menu_target',
|
150 |
+
'placeholder' => '',
|
151 |
+
'default' => '',
|
152 |
+
),
|
153 |
+
),
|
154 |
+
// Column 2.
|
155 |
+
array(
|
156 |
+
array(
|
157 |
+
'type' => 'text',
|
158 |
+
'label' => __( 'Submenu Item Title', 'insert-headers-and-footers' ),
|
159 |
+
'description' => __( 'Text or HTML for the submenu item.', 'insert-headers-and-footers' ),
|
160 |
+
'id' => 'submenu_title',
|
161 |
+
'name' => 'submenu_title[]',
|
162 |
+
'placeholder' => '',
|
163 |
+
'repeater' => 'submenu',
|
164 |
+
),
|
165 |
+
array(
|
166 |
+
'type' => 'text',
|
167 |
+
'label' => __( 'Submenu item link', 'insert-headers-and-footers' ),
|
168 |
+
'description' => __( 'If left empty, this menu item will not be a link, just text.', 'insert-headers-and-footers' ),
|
169 |
+
'id' => 'submenu_href',
|
170 |
+
'name' => 'submenu_href[]',
|
171 |
+
'placeholder' => '',
|
172 |
+
'repeater' => 'submenu',
|
173 |
+
),
|
174 |
+
array(
|
175 |
+
'type' => 'text',
|
176 |
+
'label' => __( 'Submenu item target attribute', 'insert-headers-and-footers' ),
|
177 |
+
'description' => __( 'If the menu item is a link use this for the target attribute. Use "_blank" to open in a new tab.', 'insert-headers-and-footers' ),
|
178 |
+
'id' => 'submenu_target',
|
179 |
+
'name' => 'submenu_target[]',
|
180 |
+
'placeholder' => '',
|
181 |
+
'repeater' => 'submenu',
|
182 |
+
),
|
183 |
+
),
|
184 |
+
// Column 3.
|
185 |
+
array(
|
186 |
+
array(
|
187 |
+
'type' => 'description',
|
188 |
+
'label' => __( 'Add more submenu items', 'insert-headers-and-footers' ),
|
189 |
+
'content' => __( 'Use the "Add submenu item" button below to add multiple submenu items.', 'insert-headers-and-footers' ),
|
190 |
+
),
|
191 |
+
array(
|
192 |
+
'type' => 'repeater_button',
|
193 |
+
'button_text' => __( 'Add submenu item', 'insert-headers-and-footers' ),
|
194 |
+
'id' => 'submenu', // Repeater to repeat when clicked.
|
195 |
+
),
|
196 |
+
),
|
197 |
+
),
|
198 |
+
),
|
199 |
+
);
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Get the snippet code with dynamic values applied.
|
204 |
+
*
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
+
public function get_snippet_code() {
|
208 |
+
|
209 |
+
$submenu_titles = $this->get_value( 'submenu_title' );
|
210 |
+
$submenu_hrefs = $this->get_value( 'submenu_href' );
|
211 |
+
$submenu_targets = $this->get_value( 'submenu_target' );
|
212 |
+
$submenus_code = '';
|
213 |
+
|
214 |
+
if ( ! empty( $submenu_titles ) ) {
|
215 |
+
foreach ( $submenu_titles as $key => $submenu_title ) {
|
216 |
+
if ( empty( $submenu_title ) ) {
|
217 |
+
continue;
|
218 |
+
}
|
219 |
+
$submenu_href = empty( $submenu_hrefs[ $key ] ) ? '' : $submenu_hrefs[ $key ];
|
220 |
+
$submenu_target = empty( $submenu_targets[ $key ] ) ? '' : $submenu_targets[ $key ];
|
221 |
+
|
222 |
+
$submenus_code .= "
|
223 |
+
\$admin_bar->add_menu(
|
224 |
+
array(
|
225 |
+
'id' => 'submenu_{$this->get_value( 'menu_id' )}_$key',
|
226 |
+
'parent' => '{$this->get_value( 'menu_id' )}',
|
227 |
+
'title' => '$submenu_title',
|
228 |
+
'href' => '$submenu_href',
|
229 |
+
'meta' => array(
|
230 |
+
'target' => '$submenu_target',
|
231 |
+
),
|
232 |
+
)
|
233 |
+
);
|
234 |
+
";
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
return <<<EOD
|
239 |
+
// Add a custom menu item.
|
240 |
+
|
241 |
+
function {$this->get_value( 'function_name' )}( \$admin_bar ) {
|
242 |
+
\$admin_bar->add_menu(
|
243 |
+
array(
|
244 |
+
'id' => '{$this->get_value( 'menu_id' )}',
|
245 |
+
'title' => '{$this->get_value( 'menu_title' )}',
|
246 |
+
'href' => '{$this->get_value( 'menu_href' )}',
|
247 |
+
'meta' => array(
|
248 |
+
'target' => '{$this->get_value( 'menu_target' )}',
|
249 |
+
),
|
250 |
+
)
|
251 |
+
);
|
252 |
+
$submenus_code
|
253 |
+
}
|
254 |
+
|
255 |
+
add_action( 'admin_bar_menu', '{$this->get_value( 'function_name' )}', {$this->get_value( 'priority' )} );
|
256 |
+
|
257 |
+
EOD;
|
258 |
+
}
|
259 |
+
|
260 |
+
}
|
includes/generator/class-wpcode-generator-contact-methods.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to add a extra contact methods to user profiles.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The Contact Methods generator.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Contact_Methods extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'contact-methods';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'admin',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Contact Methods', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Add additional contact methods to WordPress user profiles.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Use this generator to create a snippet which adds more contact methods to your WordPress users profiles.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms sections using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => __( 'You can add extra fields for user profiles like their extended address, city, country, phone number, social media profiles (Facebook, Twitter, etc).', 'insert-headers-and-footers' ),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
'general' => array(
|
84 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
85 |
+
'columns' => array(
|
86 |
+
// Column 1.
|
87 |
+
array(
|
88 |
+
array(
|
89 |
+
'type' => 'text',
|
90 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
91 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets.', 'insert-headers-and-footers' ),
|
92 |
+
'id' => 'function_name',
|
93 |
+
'placeholder' => 'add_custom_contact_methods',
|
94 |
+
'default' => 'add_custom_contact_methods_' . time(),
|
95 |
+
),
|
96 |
+
),
|
97 |
+
// Column 2.
|
98 |
+
array(
|
99 |
+
array(
|
100 |
+
'type' => 'text',
|
101 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
102 |
+
'description' => __( 'Optional text domain for translations.', 'insert-headers-and-footers' ),
|
103 |
+
'id' => 'text_domain',
|
104 |
+
'placeholder' => 'text_domain',
|
105 |
+
'default' => 'text_domain',
|
106 |
+
),
|
107 |
+
),
|
108 |
+
),
|
109 |
+
),
|
110 |
+
'methods' => array(
|
111 |
+
'label' => __( 'Contact Methods', 'insert-headers-and-footers' ),
|
112 |
+
'columns' => array(
|
113 |
+
// Column 1.
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'type' => 'text',
|
117 |
+
'label' => __( 'Contact Method Slug', 'insert-headers-and-footers' ),
|
118 |
+
'description' => __( 'A lowercase with no spaces slug for usage in the code. For example: "facebook" or "telephone".', 'insert-headers-and-footers' ),
|
119 |
+
'id' => 'contact_method_name',
|
120 |
+
'name' => 'contact_method_name[]',
|
121 |
+
'placeholder' => '',
|
122 |
+
'repeater' => 'contact_methods',
|
123 |
+
),
|
124 |
+
array(
|
125 |
+
'type' => 'text',
|
126 |
+
'label' => __( 'Contact Method Label', 'insert-headers-and-footers' ),
|
127 |
+
'description' => __( 'This will show up as a label next to the contact method field. For example: "Facebook URL" or "Phone number".', 'insert-headers-and-footers' ),
|
128 |
+
'id' => 'contact_method_description',
|
129 |
+
'name' => 'contact_method_description[]',
|
130 |
+
'placeholder' => '',
|
131 |
+
'repeater' => 'contact_methods',
|
132 |
+
),
|
133 |
+
),
|
134 |
+
// Column 3.
|
135 |
+
array(
|
136 |
+
array(
|
137 |
+
'type' => 'description',
|
138 |
+
'label' => __( 'Add more contact methods', 'insert-headers-and-footers' ),
|
139 |
+
'content' => __( 'Use the "Add contact method" button below to add as many contact methods as you wish.', 'insert-headers-and-footers' ),
|
140 |
+
),
|
141 |
+
array(
|
142 |
+
'type' => 'repeater_button',
|
143 |
+
'button_text' => __( 'Add contact method', 'insert-headers-and-footers' ),
|
144 |
+
'id' => 'contact_methods', // Repeater to repeat when clicked.
|
145 |
+
),
|
146 |
+
),
|
147 |
+
),
|
148 |
+
),
|
149 |
+
);
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Get the snippet code with dynamic values applied.
|
154 |
+
*
|
155 |
+
* @return string
|
156 |
+
*/
|
157 |
+
public function get_snippet_code() {
|
158 |
+
|
159 |
+
$contact_method_names = $this->get_value( 'contact_method_name' );
|
160 |
+
$contact_method_descriptions = $this->get_value( 'contact_method_description' );
|
161 |
+
|
162 |
+
$contact_methods_code = '';
|
163 |
+
|
164 |
+
if ( ! empty( $contact_method_names ) ) {
|
165 |
+
foreach ( $contact_method_names as $key => $method_name ) {
|
166 |
+
if ( empty( $method_name ) ) {
|
167 |
+
continue;
|
168 |
+
}
|
169 |
+
$method_name = sanitize_title( $method_name );
|
170 |
+
$description = empty( $contact_method_descriptions[ $key ] ) ? '' : $contact_method_descriptions[ $key ];
|
171 |
+
|
172 |
+
$contact_methods_code .= "
|
173 |
+
\$contact_methods[ '$method_name' ] = __( '$description', '{$this->get_value('text_domain')}' );";
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
return <<<EOD
|
178 |
+
// Add custom contact methods
|
179 |
+
|
180 |
+
function {$this->get_value( 'function_name' )}( \$contact_methods ) {
|
181 |
+
$contact_methods_code
|
182 |
+
|
183 |
+
return \$contact_methods;
|
184 |
+
}
|
185 |
+
|
186 |
+
add_filter( 'user_contactmethods', '{$this->get_value( 'function_name' )}' );
|
187 |
+
|
188 |
+
EOD;
|
189 |
+
}
|
190 |
+
|
191 |
+
}
|
includes/generator/class-wpcode-generator-cronjob.php
ADDED
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet for scheduling a cronjob.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Cronjob class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Cronjob extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'cronjob';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'core',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Schedule a Cron Job', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Generate a snippet to schedule a recurring event using the WordPress cron.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => sprintf(
|
56 |
+
// Translators: Placeholders add links to the wordpress.org references.
|
57 |
+
__( 'This generator makes it easy to generate a snippet that will schedule a recurring event using %1$swp_schedule_event%2$s.', 'insert-headers-and-footers' ),
|
58 |
+
'<a href="https://developer.wordpress.org/reference/functions/wp_schedule_event/" target="_blank">',
|
59 |
+
'</a>'
|
60 |
+
),
|
61 |
+
),
|
62 |
+
),
|
63 |
+
// Column 2.
|
64 |
+
array(
|
65 |
+
// Column 2 fields.
|
66 |
+
array(
|
67 |
+
'type' => 'list',
|
68 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
69 |
+
'content' => array(
|
70 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
71 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
72 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
73 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
74 |
+
),
|
75 |
+
),
|
76 |
+
),
|
77 |
+
// Column 3.
|
78 |
+
array(
|
79 |
+
// Column 3 fields.
|
80 |
+
array(
|
81 |
+
'type' => 'description',
|
82 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
83 |
+
'content' => __( 'You may want to run some code once every hour, day or week, for example you could use this to send an email with the number of published posts every week.', 'insert-headers-and-footers' ),
|
84 |
+
),
|
85 |
+
),
|
86 |
+
),
|
87 |
+
),
|
88 |
+
'general' => array(
|
89 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
90 |
+
'columns' => array(
|
91 |
+
// Column 1.
|
92 |
+
array(
|
93 |
+
array(
|
94 |
+
'type' => 'text',
|
95 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
96 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
97 |
+
'id' => 'function_name',
|
98 |
+
'placeholder' => 'add_custom_schedule',
|
99 |
+
'default' => 'add_custom_schedule' . time(),
|
100 |
+
),
|
101 |
+
),
|
102 |
+
// Column 2.
|
103 |
+
array(
|
104 |
+
array(
|
105 |
+
'type' => 'text',
|
106 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
107 |
+
'description' => __( 'Optional text domain for translations.', 'insert-headers-and-footers' ),
|
108 |
+
'id' => 'text_domain',
|
109 |
+
'placeholder' => 'text_domain',
|
110 |
+
'default' => 'text_domain',
|
111 |
+
),
|
112 |
+
),
|
113 |
+
),
|
114 |
+
),
|
115 |
+
'schedule' => array(
|
116 |
+
'label' => __( 'Schedule', 'insert-headers-and-footers' ),
|
117 |
+
'columns' => array(
|
118 |
+
// Column 1.
|
119 |
+
array(
|
120 |
+
array(
|
121 |
+
'type' => 'select',
|
122 |
+
'label' => __( 'Recurrence', 'insert-headers-and-footers' ),
|
123 |
+
'description' => __( 'Choose how often you want this event to run.', 'insert-headers-and-footers' ),
|
124 |
+
'id' => 'recurrence',
|
125 |
+
'default' => 'hourly',
|
126 |
+
'options' => array(
|
127 |
+
'hourly' => __( 'Hourly', 'insert-headers-and-footers' ),
|
128 |
+
'twicedaily' => __( 'Twice Daily', 'insert-headers-and-footers' ),
|
129 |
+
'daily' => __( 'Daily', 'insert-headers-and-footers' ),
|
130 |
+
'custom' => __( 'Custom', 'insert-headers-and-footers' ),
|
131 |
+
),
|
132 |
+
),
|
133 |
+
),
|
134 |
+
// Column 2.
|
135 |
+
array(
|
136 |
+
array(
|
137 |
+
'type' => 'text',
|
138 |
+
'label' => __( 'Custom Recurrence Name', 'insert-headers-and-footers' ),
|
139 |
+
'description' => __( 'This is the recurrence name slug, lowercase and no space.', 'insert-headers-and-footers' ),
|
140 |
+
'id' => 'recurrence_name',
|
141 |
+
'default' => 'biweekly',
|
142 |
+
),
|
143 |
+
array(
|
144 |
+
'type' => 'text',
|
145 |
+
'label' => __( 'Custom Recurrence Label', 'insert-headers-and-footers' ),
|
146 |
+
'id' => 'recurrence_label',
|
147 |
+
'default' => 'Once every 2 weeks',
|
148 |
+
'description' => __( 'This label will be used in a list of cron events, for example.', 'insert-headers-and-footers' ),
|
149 |
+
),
|
150 |
+
array(
|
151 |
+
'type' => 'text',
|
152 |
+
'label' => __( 'Custom Recurrence Interval', 'insert-headers-and-footers' ),
|
153 |
+
'id' => 'recurrence_interval',
|
154 |
+
'default' => 1209600,
|
155 |
+
'description' => __( 'The number of seconds of this interval.', 'insert-headers-and-footers' ),
|
156 |
+
),
|
157 |
+
),
|
158 |
+
),
|
159 |
+
),
|
160 |
+
'hook' => array(
|
161 |
+
'label' => __( 'Code', 'insert-headers-and-footers' ),
|
162 |
+
'columns' => array(
|
163 |
+
// Column 1.
|
164 |
+
array(
|
165 |
+
array(
|
166 |
+
'type' => 'text',
|
167 |
+
'label' => __( 'Hook name', 'insert-headers-and-footers' ),
|
168 |
+
'description' => __( 'Unique name of your hook used to run when scheduled.', 'insert-headers-and-footers' ),
|
169 |
+
'id' => 'hook_name',
|
170 |
+
'default' => 'do_custom_event_' . time(),
|
171 |
+
),
|
172 |
+
),
|
173 |
+
// Column 2.
|
174 |
+
array(
|
175 |
+
array(
|
176 |
+
'type' => 'textarea',
|
177 |
+
'label' => __( 'PHP Code', 'insert-headers-and-footers' ),
|
178 |
+
'description' => __( 'Custom PHP code that will run when the event is triggered.', 'insert-headers-and-footers' ),
|
179 |
+
'id' => 'code',
|
180 |
+
'code' => true,
|
181 |
+
),
|
182 |
+
),
|
183 |
+
),
|
184 |
+
),
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Get the snippet code with dynamic values applied.
|
190 |
+
*
|
191 |
+
* @return string
|
192 |
+
*/
|
193 |
+
public function get_snippet_code() {
|
194 |
+
|
195 |
+
$function_name = $this->sanitize_function_name( $this->get_value( 'function_name' ) );
|
196 |
+
$hook_name = $this->sanitize_function_name( $this->get_value( 'hook_name' ) );
|
197 |
+
$interval = $this->get_value( 'recurrence' );
|
198 |
+
$recurrence_interval = intval( $this->get_value( 'recurrence_interval' ) );
|
199 |
+
$custom_recurrence = '';
|
200 |
+
|
201 |
+
if ( 'custom' === $interval ) {
|
202 |
+
$recurrence_function_name = 'custom_cron_recurrence_' . time();
|
203 |
+
$recurrence_name = $this->sanitize_function_name( $this->get_value( 'recurrence_name' ) );
|
204 |
+
$interval = $recurrence_name;
|
205 |
+
|
206 |
+
$custom_recurrence = "
|
207 |
+
function $recurrence_function_name( \$schedules ) {
|
208 |
+
\$schedules['$recurrence_name'] = array(
|
209 |
+
'display' => __( '{$this->get_value('recurrence_label')}', '{$this->get_value('text_domain')}' ),
|
210 |
+
'interval' => $recurrence_interval,
|
211 |
+
);
|
212 |
+
|
213 |
+
return \$schedules;
|
214 |
+
}
|
215 |
+
add_filter( 'cron_schedules', '$recurrence_function_name' );
|
216 |
+
";
|
217 |
+
}
|
218 |
+
|
219 |
+
return <<<EOD
|
220 |
+
// Schedule a cron event.
|
221 |
+
function $hook_name() {
|
222 |
+
{$this->get_value( 'code' )}
|
223 |
+
}
|
224 |
+
add_action( '$hook_name', '$hook_name' );
|
225 |
+
|
226 |
+
$custom_recurrence
|
227 |
+
|
228 |
+
function $function_name() {
|
229 |
+
if ( ! wp_next_scheduled( '$hook_name' ) ) {
|
230 |
+
wp_schedule_event( time(), '$interval', '$hook_name' );
|
231 |
+
}
|
232 |
+
}
|
233 |
+
add_action( 'wp', '$function_name' );
|
234 |
+
EOD;
|
235 |
+
}
|
236 |
+
|
237 |
+
}
|
includes/generator/class-wpcode-generator-hooks.php
ADDED
@@ -0,0 +1,1426 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet for a hook.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Hooks class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Hooks extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'hooks';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'core',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Hooks', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Generate a snippet for an action or a filter using any available hook.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return a list of hooks for suggestions in the hook autocomplete.
|
41 |
+
*
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
protected function get_all_hooks_options() {
|
45 |
+
return array(
|
46 |
+
'link_category',
|
47 |
+
'link_title',
|
48 |
+
'signup_another_blog_init',
|
49 |
+
'signup_create_blog_meta',
|
50 |
+
'add_signup_meta',
|
51 |
+
'signup_user_init',
|
52 |
+
'signup_blog_init',
|
53 |
+
'signup_get_available_languages',
|
54 |
+
'wpmu_active_signup',
|
55 |
+
'wp_http_cookie_value',
|
56 |
+
'customize_panel_active',
|
57 |
+
'register_post_type_args',
|
58 |
+
'http_origin',
|
59 |
+
'allowed_http_origins',
|
60 |
+
'allowed_http_origin',
|
61 |
+
'wp_mail',
|
62 |
+
'wp_mail_from',
|
63 |
+
'wp_mail_from_name',
|
64 |
+
'wp_mail_content_type',
|
65 |
+
'wp_mail_charset',
|
66 |
+
'authenticate',
|
67 |
+
'auth_cookie',
|
68 |
+
'auth_cookie_expiration',
|
69 |
+
'secure_auth_cookie',
|
70 |
+
'secure_logged_in_cookie',
|
71 |
+
'secure_auth_redirect',
|
72 |
+
'auth_redirect_scheme',
|
73 |
+
'wp_redirect',
|
74 |
+
'wp_redirect_status',
|
75 |
+
'wp_safe_redirect_fallback',
|
76 |
+
'allowed_redirect_hosts',
|
77 |
+
'comment_notification_recipients',
|
78 |
+
'comment_notification_notify_author',
|
79 |
+
'comment_notification_text',
|
80 |
+
'comment_notification_subject',
|
81 |
+
'comment_notification_headers',
|
82 |
+
'notify_moderator',
|
83 |
+
'comment_moderation_recipients',
|
84 |
+
'comment_moderation_text',
|
85 |
+
'comment_moderation_subject',
|
86 |
+
'comment_moderation_headers',
|
87 |
+
'wp_password_change_notification_email',
|
88 |
+
'wp_new_user_notification_email_admin',
|
89 |
+
'wp_new_user_notification_email',
|
90 |
+
'nonce_life',
|
91 |
+
'nonce_user_logged_out',
|
92 |
+
'nonce_user_logged_out',
|
93 |
+
'salt',
|
94 |
+
'salt',
|
95 |
+
'check_password',
|
96 |
+
'check_password',
|
97 |
+
'random_password',
|
98 |
+
'pre_get_avatar',
|
99 |
+
'style_loader_tag',
|
100 |
+
'print_styles_array',
|
101 |
+
'style_loader_src',
|
102 |
+
'graceful_fail',
|
103 |
+
'wp_is_mobile',
|
104 |
+
'wp_kses_allowed_html',
|
105 |
+
'pre_kses',
|
106 |
+
'wp_editor_settings',
|
107 |
+
'the_editor_content',
|
108 |
+
'quicktags_settings',
|
109 |
+
'teeny_mce_plugins',
|
110 |
+
'mce_external_plugins',
|
111 |
+
'tiny_mce_plugins',
|
112 |
+
'mce_external_languages',
|
113 |
+
'mce_css',
|
114 |
+
'teeny_mce_buttons',
|
115 |
+
'mce_buttons',
|
116 |
+
'mce_buttons_2',
|
117 |
+
'mce_buttons_3',
|
118 |
+
'mce_buttons_4',
|
119 |
+
'teeny_mce_before_init',
|
120 |
+
'tiny_mce_before_init',
|
121 |
+
'wp_mce_translation',
|
122 |
+
'wp_link_query_args',
|
123 |
+
'wp_link_query',
|
124 |
+
'use_curl_transport',
|
125 |
+
'old_slug_redirect_post_id',
|
126 |
+
'old_slug_redirect_url',
|
127 |
+
'pre_do_shortcode_tag',
|
128 |
+
'do_shortcode_tag',
|
129 |
+
'strip_shortcodes_tagnames',
|
130 |
+
'wp_http_ixr_client_headers',
|
131 |
+
'session_token_manager',
|
132 |
+
'attach_session_information',
|
133 |
+
'session_token_manager',
|
134 |
+
'get_attached_file',
|
135 |
+
'update_attached_file',
|
136 |
+
'_wp_relative_upload_path',
|
137 |
+
'get_post_status',
|
138 |
+
'wp_count_attachments',
|
139 |
+
'post_mime_types',
|
140 |
+
'pre_delete_post',
|
141 |
+
'pre_trash_post',
|
142 |
+
'pre_untrash_post',
|
143 |
+
'wp_insert_post_parent',
|
144 |
+
'wp_insert_attachment_data',
|
145 |
+
'wp_insert_post_data',
|
146 |
+
'wp_unique_post_slug',
|
147 |
+
'add_ping',
|
148 |
+
'get_enclosed',
|
149 |
+
'get_pung',
|
150 |
+
'get_to_ping',
|
151 |
+
'get_page_uri',
|
152 |
+
'wp_get_attachment_metadata',
|
153 |
+
'wp_get_attachment_url',
|
154 |
+
'wp_get_attachment_caption',
|
155 |
+
'wp_get_attachment_thumb_file',
|
156 |
+
'wp_get_attachment_thumb_url',
|
157 |
+
'icon_dir',
|
158 |
+
'icon_dir_uri',
|
159 |
+
'icon_dirs',
|
160 |
+
'wp_mime_type_icon',
|
161 |
+
'get_lastpostdate',
|
162 |
+
'pre_get_lastpostmodified',
|
163 |
+
'get_lastpostmodified',
|
164 |
+
'post_rewrite_rules',
|
165 |
+
'date_rewrite_rules',
|
166 |
+
'root_rewrite_rules',
|
167 |
+
'comments_rewrite_rules',
|
168 |
+
'search_rewrite_rules',
|
169 |
+
'author_rewrite_rules',
|
170 |
+
'page_rewrite_rules',
|
171 |
+
'tag_rewrite_rules',
|
172 |
+
'rewrite_rules_array',
|
173 |
+
'mod_rewrite_rules',
|
174 |
+
'rewrite_rules',
|
175 |
+
'iis7_url_rewrite_rules',
|
176 |
+
'customize_section_active',
|
177 |
+
'oembed_providers',
|
178 |
+
'pre_oembed_result',
|
179 |
+
'oembed_result',
|
180 |
+
'oembed_remote_get_args',
|
181 |
+
'oembed_fetch_url',
|
182 |
+
'oembed_dataparse',
|
183 |
+
'rest_url_prefix',
|
184 |
+
'rest_url',
|
185 |
+
'wp_rest_server_class',
|
186 |
+
'rest_avatar_sizes',
|
187 |
+
'protected_title_format',
|
188 |
+
'private_title_format',
|
189 |
+
'the_title',
|
190 |
+
'the_guid',
|
191 |
+
'get_the_guid',
|
192 |
+
'the_content',
|
193 |
+
'the_content_more_link',
|
194 |
+
'the_excerpt',
|
195 |
+
'get_the_excerpt',
|
196 |
+
'post_class',
|
197 |
+
'body_class',
|
198 |
+
'post_password_required',
|
199 |
+
'wp_link_pages_args',
|
200 |
+
'wp_link_pages_link',
|
201 |
+
'wp_link_pages',
|
202 |
+
'the_meta_key',
|
203 |
+
'wp_dropdown_pages',
|
204 |
+
'wp_list_pages_excludes',
|
205 |
+
'wp_list_pages',
|
206 |
+
'wp_page_menu_args',
|
207 |
+
'wp_page_menu',
|
208 |
+
'wp_get_attachment_link',
|
209 |
+
'prepend_attachment',
|
210 |
+
'the_password_form',
|
211 |
+
'wp_post_revision_title_expanded',
|
212 |
+
'customize_loaded_components',
|
213 |
+
'customize_changeset_branching',
|
214 |
+
'customize_save_response',
|
215 |
+
'customize_changeset_save_data',
|
216 |
+
'customize_dynamic_setting_args',
|
217 |
+
'customize_dynamic_setting_class',
|
218 |
+
'customize_allowed_urls',
|
219 |
+
'customize_refresh_nonces',
|
220 |
+
'customize_previewable_devices',
|
221 |
+
'customize_load_themes',
|
222 |
+
'user_has_cap',
|
223 |
+
'get_date_sql',
|
224 |
+
'core_version_check_locale',
|
225 |
+
'core_version_check_query_args',
|
226 |
+
'plugins_update_check_locales',
|
227 |
+
'themes_update_check_locales',
|
228 |
+
'wp_get_update_data',
|
229 |
+
'link_category',
|
230 |
+
'wp_list_bookmarks',
|
231 |
+
'script_loader_src',
|
232 |
+
'script_loader_tag',
|
233 |
+
'print_scripts_array',
|
234 |
+
'wp_admin_bar_class',
|
235 |
+
'show_admin_bar',
|
236 |
+
'can_add_user_to_blog',
|
237 |
+
'is_email_address_unsafe',
|
238 |
+
'wpmu_validate_user_signup',
|
239 |
+
'minimum_site_name_length',
|
240 |
+
'newblogname',
|
241 |
+
'wpmu_validate_blog_signup',
|
242 |
+
'signup_site_meta',
|
243 |
+
'signup_user_meta',
|
244 |
+
'newblog_notify_siteadmin',
|
245 |
+
'newuser_notify_siteadmin',
|
246 |
+
'domain_exists',
|
247 |
+
'update_welcome_email',
|
248 |
+
'update_welcome_subject',
|
249 |
+
'update_welcome_user_email',
|
250 |
+
'update_welcome_user_subject',
|
251 |
+
'pre_get_space_used',
|
252 |
+
'get_space_allowed',
|
253 |
+
'wp_is_large_network',
|
254 |
+
'subdirectory_reserved_names',
|
255 |
+
'new_network_admin_email_content',
|
256 |
+
'send_network_admin_email_change_email',
|
257 |
+
'network_admin_email_change_email',
|
258 |
+
'hook',
|
259 |
+
'example_filter',
|
260 |
+
'wpdocs_filter',
|
261 |
+
'oembed_default_width',
|
262 |
+
'oembed_request_post_id',
|
263 |
+
'rest_oembed_ttl',
|
264 |
+
'wp_feed_cache_transient_lifetime',
|
265 |
+
'get_bloginfo_rss',
|
266 |
+
'bloginfo_rss',
|
267 |
+
'default_feed',
|
268 |
+
'get_wp_title_rss',
|
269 |
+
'wp_title_rss',
|
270 |
+
'the_title_rss',
|
271 |
+
'the_content_feed',
|
272 |
+
'the_excerpt_rss',
|
273 |
+
'the_permalink_rss',
|
274 |
+
'comments_link_feed',
|
275 |
+
'comment_link',
|
276 |
+
'comment_author_rss',
|
277 |
+
'comment_text_rss',
|
278 |
+
'the_category_rss',
|
279 |
+
'rss_enclosure',
|
280 |
+
'atom_enclosure',
|
281 |
+
'self_link',
|
282 |
+
'feed_content_type',
|
283 |
+
'wp_doing_ajax',
|
284 |
+
'wp_doing_cron',
|
285 |
+
'file_mod_allowed',
|
286 |
+
'the_sites',
|
287 |
+
'site_search_columns',
|
288 |
+
'sites_clauses',
|
289 |
+
'found_sites_query',
|
290 |
+
'the_permalink',
|
291 |
+
'user_trailingslashit',
|
292 |
+
'pre_post_link',
|
293 |
+
'post_link_category',
|
294 |
+
'post_link',
|
295 |
+
'post_type_link',
|
296 |
+
'page_link',
|
297 |
+
'_get_page_link',
|
298 |
+
'attachment_link',
|
299 |
+
'year_link',
|
300 |
+
'month_link',
|
301 |
+
'day_link',
|
302 |
+
'the_feed_link',
|
303 |
+
'feed_link',
|
304 |
+
'post_comments_feed_link',
|
305 |
+
'post_comments_feed_link_html',
|
306 |
+
'author_feed_link',
|
307 |
+
'category_feed_link',
|
308 |
+
'tag_feed_link',
|
309 |
+
'taxonomy_feed_link',
|
310 |
+
'get_edit_tag_link',
|
311 |
+
'edit_tag_link',
|
312 |
+
'get_edit_term_link',
|
313 |
+
'edit_term_link',
|
314 |
+
'search_link',
|
315 |
+
'search_feed_link',
|
316 |
+
'post_type_archive_feed_link',
|
317 |
+
'preview_post_link',
|
318 |
+
'get_edit_post_link',
|
319 |
+
'edit_post_link',
|
320 |
+
'get_delete_post_link',
|
321 |
+
'get_edit_comment_link',
|
322 |
+
'edit_comment_link',
|
323 |
+
'get_edit_bookmark_link',
|
324 |
+
'edit_bookmark_link',
|
325 |
+
'get_edit_user_link',
|
326 |
+
'get_pagenum_link',
|
327 |
+
'next_posts_link_attributes',
|
328 |
+
'previous_posts_link_attributes',
|
329 |
+
'navigation_markup_template',
|
330 |
+
'get_comments_pagenum_link',
|
331 |
+
'next_comments_link_attributes',
|
332 |
+
'previous_comments_link_attributes',
|
333 |
+
'home_url',
|
334 |
+
'site_url',
|
335 |
+
'admin_url',
|
336 |
+
'includes_url',
|
337 |
+
'content_url',
|
338 |
+
'plugins_url',
|
339 |
+
'network_site_url',
|
340 |
+
'network_home_url',
|
341 |
+
'network_admin_url',
|
342 |
+
'user_admin_url',
|
343 |
+
'self_admin_url',
|
344 |
+
'set_url_scheme',
|
345 |
+
'user_dashboard_url',
|
346 |
+
'edit_profile_url',
|
347 |
+
'get_canonical_url',
|
348 |
+
'pre_get_shortlink',
|
349 |
+
'get_shortlink',
|
350 |
+
'the_shortlink',
|
351 |
+
'pre_get_avatar_data',
|
352 |
+
'get_avatar_comment_types',
|
353 |
+
'get_avatar_url',
|
354 |
+
'theme_file_uri',
|
355 |
+
'parent_theme_file_uri',
|
356 |
+
'theme_file_path',
|
357 |
+
'parent_theme_file_path',
|
358 |
+
'privacy_policy_url',
|
359 |
+
'the_privacy_policy_link',
|
360 |
+
'date_i18n',
|
361 |
+
'number_format_i18n',
|
362 |
+
'enclosure_links',
|
363 |
+
'removable_query_args',
|
364 |
+
'status_header',
|
365 |
+
'nocache_headers',
|
366 |
+
'robots_txt',
|
367 |
+
'upload_dir',
|
368 |
+
'wp_unique_filename',
|
369 |
+
'wp_upload_bits',
|
370 |
+
'wp_check_filetype_and_ext',
|
371 |
+
'upload_mimes',
|
372 |
+
'wp_die_ajax_handler',
|
373 |
+
'wp_die_xmlrpc_handler',
|
374 |
+
'wp_die_handler',
|
375 |
+
'smilies',
|
376 |
+
'iis7_supports_permalinks',
|
377 |
+
'get_main_network_id',
|
378 |
+
'global_terms_enabled',
|
379 |
+
'kses_allowed_protocols',
|
380 |
+
'wp_checkdate',
|
381 |
+
'wp_auth_check_same_domain',
|
382 |
+
'wp_delete_file',
|
383 |
+
'admin_memory_limit',
|
384 |
+
'image_memory_limit',
|
385 |
+
'send_site_admin_email_change_email',
|
386 |
+
'site_admin_email_change_email',
|
387 |
+
'wp_privacy_anonymize_data',
|
388 |
+
'wp_privacy_exports_dir',
|
389 |
+
'wp_privacy_exports_url',
|
390 |
+
'wp_privacy_export_expiration',
|
391 |
+
'the_title',
|
392 |
+
'the_title',
|
393 |
+
'link_category',
|
394 |
+
'the_content_rss',
|
395 |
+
'icon_dir',
|
396 |
+
'attachment_icon',
|
397 |
+
'attachment_innerHTML',
|
398 |
+
'the_title',
|
399 |
+
'index_rel_link',
|
400 |
+
'the_title',
|
401 |
+
'parent_post_rel_link',
|
402 |
+
'richedit_pre',
|
403 |
+
'htmledit_pre',
|
404 |
+
'shortcut_link',
|
405 |
+
'rest_authentication_errors',
|
406 |
+
'rest_send_nocache_headers',
|
407 |
+
'rest_jsonp_enabled',
|
408 |
+
'rest_post_dispatch',
|
409 |
+
'rest_pre_serve_request',
|
410 |
+
'rest_pre_echo_response',
|
411 |
+
'rest_envelope_response',
|
412 |
+
'rest_endpoints',
|
413 |
+
'rest_pre_dispatch',
|
414 |
+
'rest_request_before_callbacks',
|
415 |
+
'rest_dispatch_request',
|
416 |
+
'rest_request_after_callbacks',
|
417 |
+
'rest_index',
|
418 |
+
'rest_namespace_index',
|
419 |
+
'rest_endpoints_description',
|
420 |
+
'rest_route_data',
|
421 |
+
'rest_request_parameter_order',
|
422 |
+
'rest_request_from_url',
|
423 |
+
'rest_comment_query',
|
424 |
+
'rest_allow_anonymous_comments',
|
425 |
+
'rest_pre_insert_comment',
|
426 |
+
'rest_comment_trashable',
|
427 |
+
'rest_prepare_comment',
|
428 |
+
'rest_preprocess_comment',
|
429 |
+
'rest_comment_collection_params',
|
430 |
+
'rest_prepare_attachment',
|
431 |
+
'rest_prepare_revision',
|
432 |
+
'rest_user_query',
|
433 |
+
'rest_prepare_user',
|
434 |
+
'rest_pre_insert_user',
|
435 |
+
'rest_user_collection_params',
|
436 |
+
'rest_pre_get_setting',
|
437 |
+
'rest_pre_update_setting',
|
438 |
+
'rest_prepare_status',
|
439 |
+
'rest_prepare_taxonomy',
|
440 |
+
'rest_prepare_post_type',
|
441 |
+
'rest_response_link_curies',
|
442 |
+
'secure_signon_cookie',
|
443 |
+
'wp_authenticate_user',
|
444 |
+
'wp_authenticate_user',
|
445 |
+
'check_is_user_spammed',
|
446 |
+
'get_usernumposts',
|
447 |
+
'pre_get_blogs_of_user',
|
448 |
+
'get_blogs_of_user',
|
449 |
+
'wp_dropdown_users_args',
|
450 |
+
'wp_dropdown_users',
|
451 |
+
'username_exists',
|
452 |
+
'validate_username',
|
453 |
+
'pre_user_login',
|
454 |
+
'illegal_user_logins',
|
455 |
+
'pre_user_nicename',
|
456 |
+
'pre_user_url',
|
457 |
+
'pre_user_email',
|
458 |
+
'pre_user_nickname',
|
459 |
+
'pre_user_first_name',
|
460 |
+
'pre_user_last_name',
|
461 |
+
'pre_user_display_name',
|
462 |
+
'pre_user_description',
|
463 |
+
'wp_pre_insert_user_data',
|
464 |
+
'insert_user_meta',
|
465 |
+
'send_password_change_email',
|
466 |
+
'send_email_change_email',
|
467 |
+
'password_change_email',
|
468 |
+
'email_change_email',
|
469 |
+
'user_contactmethods',
|
470 |
+
'password_hint',
|
471 |
+
'allow_password_reset',
|
472 |
+
'password_reset_expiration',
|
473 |
+
'password_reset_key_expired',
|
474 |
+
'user_registration_email',
|
475 |
+
'registration_errors',
|
476 |
+
'determine_current_user',
|
477 |
+
'new_user_email_content',
|
478 |
+
'user_request_confirmed_email_to',
|
479 |
+
'user_confirmed_action_email_content',
|
480 |
+
'user_request_confirmed_email_subject',
|
481 |
+
'user_erasure_fulfillment_email_to',
|
482 |
+
'user_erasure_complete_email_subject',
|
483 |
+
'user_confirmed_action_email_content',
|
484 |
+
'user_request_action_confirmed_message',
|
485 |
+
'user_request_action_description',
|
486 |
+
'user_request_action_email_content',
|
487 |
+
'user_request_action_email_subject',
|
488 |
+
'user_request_key_expiration',
|
489 |
+
'get_terms_defaults',
|
490 |
+
'get_terms_args',
|
491 |
+
'list_terms_exclusions',
|
492 |
+
'get_terms_fields',
|
493 |
+
'terms_clauses',
|
494 |
+
'get_terms_orderby',
|
495 |
+
'list_pages',
|
496 |
+
'register_taxonomy_args',
|
497 |
+
'get_categories_taxonomy',
|
498 |
+
'get_tags',
|
499 |
+
'the_comments',
|
500 |
+
'comments_clauses',
|
501 |
+
'found_comments_query',
|
502 |
+
'get_the_categories',
|
503 |
+
'the_category_list',
|
504 |
+
'the_category',
|
505 |
+
'list_cats',
|
506 |
+
'list_cats',
|
507 |
+
'wp_dropdown_cats',
|
508 |
+
'wp_list_categories',
|
509 |
+
'wp_tag_cloud',
|
510 |
+
'tag_cloud_sort',
|
511 |
+
'wp_generate_tag_cloud_data',
|
512 |
+
'wp_generate_tag_cloud',
|
513 |
+
'get_the_tags',
|
514 |
+
'the_tags',
|
515 |
+
'get_the_terms',
|
516 |
+
'the_terms',
|
517 |
+
'pre_get_main_site_id',
|
518 |
+
'network_by_path_segments_count',
|
519 |
+
'pre_get_network_by_path',
|
520 |
+
'get_site',
|
521 |
+
'get_network',
|
522 |
+
'pre_http_send_through_proxy',
|
523 |
+
'customize_partial_render',
|
524 |
+
'customize_dynamic_partial_args',
|
525 |
+
'customize_dynamic_partial_class',
|
526 |
+
'customize_render_partials_response',
|
527 |
+
'wp_query_search_exclusion_prefix',
|
528 |
+
'wp_search_stopwords',
|
529 |
+
'posts_search',
|
530 |
+
'posts_search_orderby',
|
531 |
+
'posts_where',
|
532 |
+
'posts_join',
|
533 |
+
'comment_feed_join',
|
534 |
+
'comment_feed_where',
|
535 |
+
'comment_feed_groupby',
|
536 |
+
'comment_feed_orderby',
|
537 |
+
'comment_feed_limits',
|
538 |
+
'posts_where_paged',
|
539 |
+
'posts_groupby',
|
540 |
+
'posts_join_paged',
|
541 |
+
'posts_orderby',
|
542 |
+
'posts_distinct',
|
543 |
+
'post_limits',
|
544 |
+
'posts_fields',
|
545 |
+
'posts_clauses',
|
546 |
+
'posts_where_request',
|
547 |
+
'posts_groupby_request',
|
548 |
+
'posts_join_request',
|
549 |
+
'posts_orderby_request',
|
550 |
+
'posts_distinct_request',
|
551 |
+
'posts_fields_request',
|
552 |
+
'post_limits_request',
|
553 |
+
'posts_clauses_request',
|
554 |
+
'posts_request',
|
555 |
+
'posts_pre_query',
|
556 |
+
'split_the_query',
|
557 |
+
'posts_request_ids',
|
558 |
+
'posts_results',
|
559 |
+
'comment_feed_orderby',
|
560 |
+
'comment_feed_limits',
|
561 |
+
'the_preview',
|
562 |
+
'the_posts',
|
563 |
+
'found_posts_query',
|
564 |
+
'found_posts',
|
565 |
+
'content_pagination',
|
566 |
+
'embed_handler_html',
|
567 |
+
'oembed_ttl',
|
568 |
+
'embed_oembed_html',
|
569 |
+
'embed_oembed_discover',
|
570 |
+
'embed_maybe_make_link',
|
571 |
+
'is_protected_meta',
|
572 |
+
'register_meta_args',
|
573 |
+
'customizer_widgets_section_args',
|
574 |
+
'is_wide_widget_in_customizer',
|
575 |
+
'widget_customizer_setting_args',
|
576 |
+
'search_form_format',
|
577 |
+
'get_search_form',
|
578 |
+
'loginout',
|
579 |
+
'loginout',
|
580 |
+
'logout_url',
|
581 |
+
'login_url',
|
582 |
+
'register_url',
|
583 |
+
'login_form_defaults',
|
584 |
+
'login_form_top',
|
585 |
+
'login_form_middle',
|
586 |
+
'login_form_bottom',
|
587 |
+
'lostpassword_url',
|
588 |
+
'register',
|
589 |
+
'bloginfo_url',
|
590 |
+
'bloginfo',
|
591 |
+
'get_site_icon_url',
|
592 |
+
'get_custom_logo',
|
593 |
+
'pre_get_document_title',
|
594 |
+
'document_title_separator',
|
595 |
+
'document_title_parts',
|
596 |
+
'wp_title_parts',
|
597 |
+
'wp_title',
|
598 |
+
'single_post_title',
|
599 |
+
'post_type_archive_title',
|
600 |
+
'single_cat_title',
|
601 |
+
'single_tag_title',
|
602 |
+
'single_term_title',
|
603 |
+
'get_the_archive_title',
|
604 |
+
'get_the_archive_description',
|
605 |
+
'get_the_post_type_description',
|
606 |
+
'get_archives_link',
|
607 |
+
'getarchives_where',
|
608 |
+
'getarchives_join',
|
609 |
+
'get_calendar',
|
610 |
+
'get_calendar',
|
611 |
+
'the_date',
|
612 |
+
'get_the_date',
|
613 |
+
'the_modified_date',
|
614 |
+
'get_the_modified_date',
|
615 |
+
'the_time',
|
616 |
+
'get_the_time',
|
617 |
+
'get_post_time',
|
618 |
+
'the_modified_time',
|
619 |
+
'get_the_modified_time',
|
620 |
+
'get_post_modified_time',
|
621 |
+
'the_weekday',
|
622 |
+
'the_weekday_date',
|
623 |
+
'site_icon_meta_tags',
|
624 |
+
'wp_resource_hints',
|
625 |
+
'user_can_richedit',
|
626 |
+
'wp_default_editor',
|
627 |
+
'wp_code_editor_settings',
|
628 |
+
'get_search_query',
|
629 |
+
'the_search_query',
|
630 |
+
'language_attributes',
|
631 |
+
'paginate_links',
|
632 |
+
'wp_admin_css_uri',
|
633 |
+
'wp_admin_css',
|
634 |
+
'wp_generator_type',
|
635 |
+
'the_generator',
|
636 |
+
'redirect_canonical',
|
637 |
+
'role_has_cap',
|
638 |
+
'theme_templates',
|
639 |
+
'theme_scandir_exclusions',
|
640 |
+
'network_allowed_themes',
|
641 |
+
'allowed_themes',
|
642 |
+
'site_allowed_themes',
|
643 |
+
'site_allowed_themes',
|
644 |
+
'wp_http_accept_encoding',
|
645 |
+
'',
|
646 |
+
'incompatible_sql_modes',
|
647 |
+
'query',
|
648 |
+
'pre_get_table_charset',
|
649 |
+
'pre_get_col_charset',
|
650 |
+
'stylesheet',
|
651 |
+
'stylesheet_directory',
|
652 |
+
'stylesheet_directory_uri',
|
653 |
+
'stylesheet_uri',
|
654 |
+
'locale_stylesheet_uri',
|
655 |
+
'template',
|
656 |
+
'template_directory',
|
657 |
+
'template_directory_uri',
|
658 |
+
'theme_root',
|
659 |
+
'theme_root_uri',
|
660 |
+
'get_header_image_tag',
|
661 |
+
'get_header_video_url',
|
662 |
+
'header_video_settings',
|
663 |
+
'is_header_video_active',
|
664 |
+
'wp_get_custom_css',
|
665 |
+
'update_custom_css_data',
|
666 |
+
'editor_stylesheets',
|
667 |
+
'get_theme_starter_content',
|
668 |
+
'rss_update_period',
|
669 |
+
'rss_update_frequency',
|
670 |
+
'pre_cache_alloptions',
|
671 |
+
'alloptions',
|
672 |
+
'pre_update_option',
|
673 |
+
'register_setting_args',
|
674 |
+
'post_thumbnail_size',
|
675 |
+
'post_thumbnail_html',
|
676 |
+
'the_post_thumbnail_caption',
|
677 |
+
'category_description',
|
678 |
+
'category_css_class',
|
679 |
+
'map_meta_cap',
|
680 |
+
'editor_max_image_size',
|
681 |
+
'get_image_tag_class',
|
682 |
+
'get_image_tag',
|
683 |
+
'wp_constrain_dimensions',
|
684 |
+
'image_resize_dimensions',
|
685 |
+
'image_get_intermediate_size',
|
686 |
+
'intermediate_image_sizes',
|
687 |
+
'wp_get_attachment_image_src',
|
688 |
+
'wp_get_attachment_image_attributes',
|
689 |
+
'wp_calculate_image_srcset_meta',
|
690 |
+
'max_srcset_image_width',
|
691 |
+
'wp_calculate_image_srcset',
|
692 |
+
'wp_calculate_image_sizes',
|
693 |
+
'img_caption_shortcode',
|
694 |
+
'img_caption_shortcode_width',
|
695 |
+
'post_gallery',
|
696 |
+
'gallery_style',
|
697 |
+
'post_playlist',
|
698 |
+
'wp_mediaelement_fallback',
|
699 |
+
'wp_audio_extensions',
|
700 |
+
'wp_get_attachment_id3_keys',
|
701 |
+
'wp_audio_shortcode_override',
|
702 |
+
'wp_audio_shortcode_library',
|
703 |
+
'wp_audio_shortcode_class',
|
704 |
+
'wp_audio_shortcode',
|
705 |
+
'wp_video_extensions',
|
706 |
+
'wp_video_shortcode_override',
|
707 |
+
'wp_video_shortcode_library',
|
708 |
+
'wp_video_shortcode_class',
|
709 |
+
'wp_video_shortcode',
|
710 |
+
'upload_size_limit',
|
711 |
+
'wp_image_editors',
|
712 |
+
'plupload_default_settings',
|
713 |
+
'plupload_default_params',
|
714 |
+
'wp_prepare_attachment_for_js',
|
715 |
+
'media_library_show_audio_playlist',
|
716 |
+
'media_library_show_video_playlist',
|
717 |
+
'media_library_months_with_files',
|
718 |
+
'media_view_settings',
|
719 |
+
'media_view_strings',
|
720 |
+
'get_attached_media_args',
|
721 |
+
'get_attached_media',
|
722 |
+
'media_embedded_in_content_allowed_types',
|
723 |
+
'get_post_galleries',
|
724 |
+
'get_post_gallery',
|
725 |
+
'attachment_url_to_postid',
|
726 |
+
'site_details',
|
727 |
+
'page_css_class',
|
728 |
+
'page_menu_link_attributes',
|
729 |
+
'xmlrpc_methods',
|
730 |
+
'pre_option_enable_xmlrpc',
|
731 |
+
'option_enable_xmlrpc',
|
732 |
+
'xmlrpc_enabled',
|
733 |
+
'xmlrpc_login_error',
|
734 |
+
'xmlrpc_blog_options',
|
735 |
+
'xmlrpc_prepare_taxonomy',
|
736 |
+
'xmlrpc_prepare_term',
|
737 |
+
'xmlrpc_prepare_post',
|
738 |
+
'xmlrpc_prepare_post_type',
|
739 |
+
'xmlrpc_prepare_media_item',
|
740 |
+
'xmlrpc_prepare_page',
|
741 |
+
'xmlrpc_prepare_comment',
|
742 |
+
'xmlrpc_prepare_user',
|
743 |
+
'xmlrpc_wp_insert_post_data',
|
744 |
+
'xmlrpc_default_post_fields',
|
745 |
+
'xmlrpc_default_taxonomy_fields',
|
746 |
+
'xmlrpc_default_user_fields',
|
747 |
+
'xmlrpc_allow_anonymous_comments',
|
748 |
+
'xmlrpc_default_posttype_fields',
|
749 |
+
'xmlrpc_default_revision_fields',
|
750 |
+
'xmlrpc_text_filters',
|
751 |
+
'pingback_ping_source_uri',
|
752 |
+
'pre_remote_source',
|
753 |
+
'xmlrpc_pingback_error',
|
754 |
+
'url_to_postid',
|
755 |
+
'wp_editor_set_quality',
|
756 |
+
'jpeg_quality',
|
757 |
+
'image_editor_default_mime_type',
|
758 |
+
'post_format_rewrite_base',
|
759 |
+
'get_term',
|
760 |
+
'get_terms',
|
761 |
+
'pre_category_nicename',
|
762 |
+
'wp_get_object_terms_args',
|
763 |
+
'get_object_terms',
|
764 |
+
'wp_get_object_terms',
|
765 |
+
'pre_insert_term',
|
766 |
+
'wp_insert_term_data',
|
767 |
+
'term_id_filter',
|
768 |
+
'wp_unique_term_slug',
|
769 |
+
'wp_update_term_parent',
|
770 |
+
'wp_update_term_data',
|
771 |
+
'term_id_filter',
|
772 |
+
'pre_term_link',
|
773 |
+
'tag_link',
|
774 |
+
'category_link',
|
775 |
+
'term_link',
|
776 |
+
'https_local_ssl_verify',
|
777 |
+
'https_ssl_verify',
|
778 |
+
'use_streams_transport',
|
779 |
+
'embed_defaults',
|
780 |
+
'wp_audio_embed_handler',
|
781 |
+
'wp_video_embed_handler',
|
782 |
+
'wp_embed_handler_youtube',
|
783 |
+
'wp_embed_handler_audio',
|
784 |
+
'wp_embed_handler_video',
|
785 |
+
'oembed_discovery_links',
|
786 |
+
'post_embed_url',
|
787 |
+
'oembed_endpoint_url',
|
788 |
+
'embed_html',
|
789 |
+
'oembed_response_data',
|
790 |
+
'the_excerpt_embed',
|
791 |
+
'embed_site_title_html',
|
792 |
+
'xmlrpc_element_limit',
|
793 |
+
'xmlrpc_chunk_parsing_size',
|
794 |
+
'embed_thumbnail_id',
|
795 |
+
'embed_thumbnail_image_size',
|
796 |
+
'embed_thumbnail_image_shape',
|
797 |
+
'http_headers_useragent',
|
798 |
+
'http_request_args',
|
799 |
+
'pre_http_request',
|
800 |
+
'https_ssl_verify',
|
801 |
+
'http_response',
|
802 |
+
'http_api_transports',
|
803 |
+
'http_response',
|
804 |
+
'block_local_requests',
|
805 |
+
'schedule_event',
|
806 |
+
'schedule_event',
|
807 |
+
'cron_schedules',
|
808 |
+
'run_wptexturize',
|
809 |
+
'no_texturize_tags',
|
810 |
+
'no_texturize_shortcodes',
|
811 |
+
'sanitize_file_name_chars',
|
812 |
+
'sanitize_file_name',
|
813 |
+
'sanitize_user',
|
814 |
+
'sanitize_key',
|
815 |
+
'sanitize_title',
|
816 |
+
'sanitize_html_class',
|
817 |
+
'format_to_edit',
|
818 |
+
'smilies_src',
|
819 |
+
'is_email',
|
820 |
+
'sanitize_email',
|
821 |
+
'human_time_diff',
|
822 |
+
'excerpt_length',
|
823 |
+
'excerpt_more',
|
824 |
+
'wp_trim_excerpt',
|
825 |
+
'wp_trim_words',
|
826 |
+
'pre_ent2ncr',
|
827 |
+
'format_for_editor',
|
828 |
+
'clean_url',
|
829 |
+
'js_escape',
|
830 |
+
'esc_html',
|
831 |
+
'attribute_escape',
|
832 |
+
'esc_textarea',
|
833 |
+
'tag_escape',
|
834 |
+
'wp_parse_str',
|
835 |
+
'wp_sprintf',
|
836 |
+
'sanitize_text_field',
|
837 |
+
'sanitize_textarea_field',
|
838 |
+
'sanitize_mime_type',
|
839 |
+
'sanitize_trackback_urls',
|
840 |
+
'wp_spaces_regexp',
|
841 |
+
'process_text_diff_html',
|
842 |
+
'user_search_columns',
|
843 |
+
'found_users_query',
|
844 |
+
'wp_get_nav_menu_object',
|
845 |
+
'has_nav_menu',
|
846 |
+
'wp_get_nav_menu_name',
|
847 |
+
'wp_get_nav_menus',
|
848 |
+
'wp_get_nav_menu_items',
|
849 |
+
'nav_menu_attr_title',
|
850 |
+
'nav_menu_description',
|
851 |
+
'wp_setup_nav_menu_item',
|
852 |
+
'_wp_post_revision_fields',
|
853 |
+
'wp_save_post_revision_post_has_changed',
|
854 |
+
'wp_revisions_to_keep',
|
855 |
+
'ms_site_check',
|
856 |
+
'site_by_path_segments_count',
|
857 |
+
'pre_get_site_by_path',
|
858 |
+
'the_author',
|
859 |
+
'the_modified_author',
|
860 |
+
'the_author_posts_link',
|
861 |
+
'author_link',
|
862 |
+
'is_multi_author',
|
863 |
+
'get_comment_author',
|
864 |
+
'comment_author',
|
865 |
+
'get_comment_author_email',
|
866 |
+
'author_email',
|
867 |
+
'comment_email',
|
868 |
+
'get_comment_author_link',
|
869 |
+
'get_comment_author_IP',
|
870 |
+
'get_comment_author_url',
|
871 |
+
'comment_url',
|
872 |
+
'get_comment_author_url_link',
|
873 |
+
'comment_class',
|
874 |
+
'get_comment_date',
|
875 |
+
'comment_excerpt_length',
|
876 |
+
'get_comment_excerpt',
|
877 |
+
'comment_excerpt',
|
878 |
+
'get_comment_ID',
|
879 |
+
'get_comment_link',
|
880 |
+
'get_comments_link',
|
881 |
+
'get_comments_number',
|
882 |
+
'comments_number',
|
883 |
+
'get_comment_text',
|
884 |
+
'comment_text',
|
885 |
+
'get_comment_time',
|
886 |
+
'get_comment_type',
|
887 |
+
'trackback_url',
|
888 |
+
'comments_open',
|
889 |
+
'pings_open',
|
890 |
+
'comments_template_query_args',
|
891 |
+
'comments_array',
|
892 |
+
'comments_template',
|
893 |
+
'respond_link',
|
894 |
+
'comments_popup_link_attributes',
|
895 |
+
'comment_reply_link_args',
|
896 |
+
'comment_reply_link',
|
897 |
+
'post_comments_link',
|
898 |
+
'cancel_comment_reply_link',
|
899 |
+
'comment_id_fields',
|
900 |
+
'wp_list_comments_args',
|
901 |
+
'comment_form_default_fields',
|
902 |
+
'comment_form_defaults',
|
903 |
+
'comment_form_logged_in',
|
904 |
+
'comment_form_fields',
|
905 |
+
'comment_form_field_comment',
|
906 |
+
'comment_form_submit_button',
|
907 |
+
'comment_form_submit_field',
|
908 |
+
'get_bookmarks',
|
909 |
+
'dynamic_sidebar_params',
|
910 |
+
'dynamic_sidebar_has_widgets',
|
911 |
+
'is_active_sidebar',
|
912 |
+
'sidebars_widgets',
|
913 |
+
'customize_control_active',
|
914 |
+
'locale',
|
915 |
+
'locale',
|
916 |
+
'gettext',
|
917 |
+
'gettext_with_context',
|
918 |
+
'ngettext',
|
919 |
+
'ngettext_with_context',
|
920 |
+
'override_load_textdomain',
|
921 |
+
'load_textdomain_mofile',
|
922 |
+
'override_unload_textdomain',
|
923 |
+
'plugin_locale',
|
924 |
+
'plugin_locale',
|
925 |
+
'theme_locale',
|
926 |
+
'get_available_languages',
|
927 |
+
'the_networks',
|
928 |
+
'networks_clauses',
|
929 |
+
'found_networks_query',
|
930 |
+
'query_vars',
|
931 |
+
'request',
|
932 |
+
'wp_headers',
|
933 |
+
'query_string',
|
934 |
+
'widget_categories_dropdown_args',
|
935 |
+
'widget_categories_args',
|
936 |
+
'widget_title',
|
937 |
+
'widget_links_args',
|
938 |
+
'widget_nav_menu_args',
|
939 |
+
'widget_text',
|
940 |
+
'widget_text_content',
|
941 |
+
'widget_custom_html_content',
|
942 |
+
'comment_max_links_url',
|
943 |
+
'get_comment',
|
944 |
+
'get_default_comment_status',
|
945 |
+
'comment_cookie_lifetime',
|
946 |
+
'pre_comment_author_name',
|
947 |
+
'pre_comment_author_email',
|
948 |
+
'pre_comment_author_url',
|
949 |
+
'duplicate_comment_id',
|
950 |
+
'pre_comment_approved',
|
951 |
+
'comment_flood_filter',
|
952 |
+
'get_page_of_comment',
|
953 |
+
'wp_get_comment_fields_max_lengths',
|
954 |
+
'wp_count_comments',
|
955 |
+
'wp_get_current_commenter',
|
956 |
+
'pre_user_id',
|
957 |
+
'pre_comment_user_agent',
|
958 |
+
'pre_comment_content',
|
959 |
+
'pre_comment_user_ip',
|
960 |
+
'preprocess_comment',
|
961 |
+
'notify_post_author',
|
962 |
+
'comment_save_pre',
|
963 |
+
'wp_update_comment_data',
|
964 |
+
'pre_wp_update_comment_count_now',
|
965 |
+
'pingback_useragent',
|
966 |
+
'close_comments_for_post_types',
|
967 |
+
'close_comments_for_post_types',
|
968 |
+
'wp_anonymize_comment',
|
969 |
+
'customize_nav_menu_available_items',
|
970 |
+
'customize_nav_menu_searched_items',
|
971 |
+
'customize_nav_menu_available_item_types',
|
972 |
+
'wp_nav_menu_args',
|
973 |
+
'pre_wp_nav_menu',
|
974 |
+
'wp_nav_menu_container_allowedtags',
|
975 |
+
'wp_nav_menu_objects',
|
976 |
+
'wp_nav_menu_items',
|
977 |
+
'wp_nav_menu',
|
978 |
+
'nav_menu_submenu_css_class',
|
979 |
+
'nav_menu_item_args',
|
980 |
+
'nav_menu_css_class',
|
981 |
+
'nav_menu_item_id',
|
982 |
+
'nav_menu_link_attributes',
|
983 |
+
'nav_menu_item_title',
|
984 |
+
'walker_nav_menu_start_el',
|
985 |
+
'get_meta_sql',
|
986 |
+
'meta_query_find_compatible_table_alias',
|
987 |
+
'widget_display_callback',
|
988 |
+
'widget_update_callback',
|
989 |
+
'widget_form_callback',
|
990 |
+
'wp_xmlrpc_server_class',
|
991 |
+
'comment_post_redirect',
|
992 |
+
'edit_comment_misc_actions',
|
993 |
+
'myblogs_options',
|
994 |
+
'myblogs_blog_actions',
|
995 |
+
'wp_nav_locations_listed_per_menu',
|
996 |
+
'redirect_term_location',
|
997 |
+
'taxonomy_parent_dropdown_args',
|
998 |
+
'whitelist_options',
|
999 |
+
'redirect_user_admin_request',
|
1000 |
+
'delete_site_email_content',
|
1001 |
+
'admin_title',
|
1002 |
+
'admin_body_class',
|
1003 |
+
'parent_file',
|
1004 |
+
'submenu_file',
|
1005 |
+
'export_args',
|
1006 |
+
'bulk_post_updated_messages',
|
1007 |
+
'user_profile_picture_description',
|
1008 |
+
'post_updated_messages',
|
1009 |
+
'enter_title_here',
|
1010 |
+
'tables_to_repair',
|
1011 |
+
'thread_comments_depth_max',
|
1012 |
+
'avatar_defaults',
|
1013 |
+
'default_avatar_select',
|
1014 |
+
'redirect_network_admin_request',
|
1015 |
+
'mu_menu_items',
|
1016 |
+
'media_upload_default_type',
|
1017 |
+
'media_upload_default_tab',
|
1018 |
+
'pre_user_login',
|
1019 |
+
'date_formats',
|
1020 |
+
'time_formats',
|
1021 |
+
'admin_footer_text',
|
1022 |
+
'update_footer',
|
1023 |
+
'install_themes_tabs',
|
1024 |
+
'available_permalink_structure_tags',
|
1025 |
+
'editable_slug',
|
1026 |
+
'wp_header_image_attachment_metadata',
|
1027 |
+
'theme_action_links',
|
1028 |
+
'theme_row_meta',
|
1029 |
+
'heartbeat_nopriv_received',
|
1030 |
+
'heartbeat_nopriv_send',
|
1031 |
+
'term_search_min_chars',
|
1032 |
+
'wp_check_post_lock_window',
|
1033 |
+
'ajax_query_attachments_args',
|
1034 |
+
'wp_refresh_nonces',
|
1035 |
+
'heartbeat_received',
|
1036 |
+
'heartbeat_send',
|
1037 |
+
'wp_ajax_cropped_attachment_metadata',
|
1038 |
+
'wp_ajax_cropped_attachment_id',
|
1039 |
+
'wp_privacy_personal_data_exporters',
|
1040 |
+
'wp_privacy_personal_data_export_page',
|
1041 |
+
'wp_privacy_personal_data_erasers',
|
1042 |
+
'wp_privacy_personal_data_erasure_page',
|
1043 |
+
'intermediate_image_sizes_advanced',
|
1044 |
+
'attachment_thumbnail_args',
|
1045 |
+
'fallback_intermediate_image_sizes',
|
1046 |
+
'wp_generate_attachment_metadata',
|
1047 |
+
'wp_read_image_metadata',
|
1048 |
+
'file_is_displayable_image',
|
1049 |
+
'load_image_to_edit',
|
1050 |
+
'load_image_to_edit_filesystempath',
|
1051 |
+
'load_image_to_edit_attachmenturl',
|
1052 |
+
'load_image_to_edit_path',
|
1053 |
+
'wpmu_users_columns',
|
1054 |
+
'ms_user_list_site_actions',
|
1055 |
+
'ms_user_row_actions',
|
1056 |
+
'default_content',
|
1057 |
+
'default_title',
|
1058 |
+
'default_excerpt',
|
1059 |
+
'edit_posts_per_page',
|
1060 |
+
'upload_per_page',
|
1061 |
+
'get_sample_permalink',
|
1062 |
+
'get_sample_permalink_html',
|
1063 |
+
'admin_post_thumbnail_size',
|
1064 |
+
'admin_post_thumbnail_html',
|
1065 |
+
'override_post_lock',
|
1066 |
+
'redirect_post_location',
|
1067 |
+
'default_hidden_columns',
|
1068 |
+
'hidden_columns',
|
1069 |
+
'default_hidden_meta_boxes',
|
1070 |
+
'hidden_meta_boxes',
|
1071 |
+
'months_dropdown_results',
|
1072 |
+
'list_table_primary_column',
|
1073 |
+
'update_right_now_text',
|
1074 |
+
'install_themes_nonmenu_tabs',
|
1075 |
+
'theme_install_actions',
|
1076 |
+
'plugin_files_exclusions',
|
1077 |
+
'translations_api',
|
1078 |
+
'translations_api_result',
|
1079 |
+
'add_menu_classes',
|
1080 |
+
'menu_order',
|
1081 |
+
'manage_pages_columns',
|
1082 |
+
'manage_posts_columns',
|
1083 |
+
'post_date_column_status',
|
1084 |
+
'post_date_column_time',
|
1085 |
+
'page_row_actions',
|
1086 |
+
'post_row_actions',
|
1087 |
+
'quick_edit_dropdown_pages_args',
|
1088 |
+
'all_plugins',
|
1089 |
+
'show_network_active_plugins',
|
1090 |
+
'network_admin_plugin_action_links',
|
1091 |
+
'plugin_action_links',
|
1092 |
+
'plugin_row_meta',
|
1093 |
+
'install_plugin_complete_actions',
|
1094 |
+
'wp_terms_checklist_args',
|
1095 |
+
'wp_comment_reply',
|
1096 |
+
'postmeta_form_keys',
|
1097 |
+
'postmeta_form_limit',
|
1098 |
+
'import_upload_size_limit',
|
1099 |
+
'display_post_states',
|
1100 |
+
'display_media_states',
|
1101 |
+
'export_wp_filename',
|
1102 |
+
'the_content_export',
|
1103 |
+
'the_excerpt_export',
|
1104 |
+
'update_bulk_plugins_complete_actions',
|
1105 |
+
'get_editable_authors',
|
1106 |
+
'get_others_drafts',
|
1107 |
+
'wp_create_thumbnail',
|
1108 |
+
'site_icon_attachment_metadata',
|
1109 |
+
'site_icon_image_sizes',
|
1110 |
+
'site_icon_image_sizes',
|
1111 |
+
'update_feedback',
|
1112 |
+
'editable_roles',
|
1113 |
+
'get_users_drafts',
|
1114 |
+
'post_types_to_delete_with_user',
|
1115 |
+
'manage_taxonomies_for_attachment_columns',
|
1116 |
+
'manage_media_columns',
|
1117 |
+
'media_row_actions',
|
1118 |
+
'update_bulk_theme_complete_actions',
|
1119 |
+
'install_theme_complete_actions',
|
1120 |
+
'update_theme_complete_actions',
|
1121 |
+
'install_plugins_tabs',
|
1122 |
+
'install_plugins_nonmenu_tabs',
|
1123 |
+
'plugin_install_action_links',
|
1124 |
+
'post_edit_category_parent_dropdown_args',
|
1125 |
+
'page_attributes_dropdown_pages_args',
|
1126 |
+
'default_page_template_title',
|
1127 |
+
'users_list_table_query_args',
|
1128 |
+
'user_row_actions',
|
1129 |
+
'manage_users_custom_column',
|
1130 |
+
'get_role_list',
|
1131 |
+
'comments_per_page',
|
1132 |
+
'comment_status_links',
|
1133 |
+
'term_updated_messages',
|
1134 |
+
'contextual_help_list',
|
1135 |
+
'contextual_help',
|
1136 |
+
'default_contextual_help',
|
1137 |
+
'screen_layout_columns',
|
1138 |
+
'screen_settings',
|
1139 |
+
'screen_options_show_screen',
|
1140 |
+
'screen_options_show_submit',
|
1141 |
+
'view_mode_post_types',
|
1142 |
+
'edit_tags_per_page',
|
1143 |
+
'tagsperpage',
|
1144 |
+
'edit_categories_per_page',
|
1145 |
+
'term_name',
|
1146 |
+
'tag_row_actions',
|
1147 |
+
'automatic_updater_disabled',
|
1148 |
+
'automatic_updates_is_vcs_checkout',
|
1149 |
+
'auto_core_update_email',
|
1150 |
+
'automatic_updates_debug_email',
|
1151 |
+
'async_update_translation',
|
1152 |
+
'plugins_api_args',
|
1153 |
+
'plugins_api',
|
1154 |
+
'plugins_api_result',
|
1155 |
+
'upgrader_pre_download',
|
1156 |
+
'upgrader_pre_install',
|
1157 |
+
'upgrader_source_selection',
|
1158 |
+
'upgrader_clear_destination',
|
1159 |
+
'upgrader_post_install',
|
1160 |
+
'upgrader_package_options',
|
1161 |
+
'themes_api_args',
|
1162 |
+
'themes_api',
|
1163 |
+
'themes_api_result',
|
1164 |
+
'pre_prepare_themes_for_js',
|
1165 |
+
'wp_prepare_themes_for_js',
|
1166 |
+
'dbdelta_queries',
|
1167 |
+
'dbdelta_create_queries',
|
1168 |
+
'dbdelta_insert_queries',
|
1169 |
+
'wp_should_upgrade_global_tables',
|
1170 |
+
'ms_sites_list_table_query_args',
|
1171 |
+
'wpmu_blogs_columns',
|
1172 |
+
'manage_sites_action_links',
|
1173 |
+
'wp_network_dashboard_widgets',
|
1174 |
+
'wp_user_dashboard_widgets',
|
1175 |
+
'wp_dashboard_widgets',
|
1176 |
+
'dashboard_glance_items',
|
1177 |
+
'privacy_on_link_title',
|
1178 |
+
'privacy_on_link_text',
|
1179 |
+
'dashboard_recent_drafts_query_args',
|
1180 |
+
'comment_row_actions',
|
1181 |
+
'dashboard_recent_posts_query_args',
|
1182 |
+
'browse-happy-notice',
|
1183 |
+
'try_gutenberg_learn_more_link',
|
1184 |
+
'allow_minor_auto_core_updates',
|
1185 |
+
'allow_major_auto_core_updates',
|
1186 |
+
'media_upload_tabs',
|
1187 |
+
'image_send_to_editor',
|
1188 |
+
'image_add_caption_text',
|
1189 |
+
'image_add_caption_shortcode',
|
1190 |
+
'media_buttons_context',
|
1191 |
+
'attachment_fields_to_save',
|
1192 |
+
'media_send_to_editor',
|
1193 |
+
'image_send_to_editor_url',
|
1194 |
+
'attachment_fields_to_edit',
|
1195 |
+
'get_media_item_args',
|
1196 |
+
'media_meta',
|
1197 |
+
'get_media_item_args',
|
1198 |
+
'attachment_fields_to_edit',
|
1199 |
+
'upload_post_params',
|
1200 |
+
'plupload_init',
|
1201 |
+
'media_upload_form_url',
|
1202 |
+
'media_upload_form_url',
|
1203 |
+
'type_url_form_media',
|
1204 |
+
'media_upload_form_url',
|
1205 |
+
'media_upload_form_url',
|
1206 |
+
'media_upload_mime_type_links',
|
1207 |
+
'media_meta',
|
1208 |
+
'media_submitbox_misc_sections',
|
1209 |
+
'audio_submitbox_misc_sections',
|
1210 |
+
'wp_read_video_metadata',
|
1211 |
+
'got_rewrite',
|
1212 |
+
'got_url_rewrite',
|
1213 |
+
'documentation_ignore_functions',
|
1214 |
+
'set-screen-option',
|
1215 |
+
'admin_referrer_policy',
|
1216 |
+
'new_admin_email_content',
|
1217 |
+
'wp_get_default_privacy_policy_content',
|
1218 |
+
'terms_to_edit',
|
1219 |
+
'populate_network_meta',
|
1220 |
+
'update_plugin_complete_actions',
|
1221 |
+
'update_translations_complete_actions',
|
1222 |
+
'nav_menu_meta_box_object',
|
1223 |
+
'wp_edit_nav_menu_walker',
|
1224 |
+
'revision_text_diff_options',
|
1225 |
+
'wp_get_revision_ui_diff',
|
1226 |
+
'wp_prepare_revision_for_js',
|
1227 |
+
'wpmu_drop_tables',
|
1228 |
+
'wpmu_delete_blog_upload_dir',
|
1229 |
+
'lang_codes',
|
1230 |
+
'mu_dropdown_languages',
|
1231 |
+
'can_edit_network',
|
1232 |
+
'comment_edit_pre',
|
1233 |
+
'editable_extensions',
|
1234 |
+
'wp_theme_editor_filetypes',
|
1235 |
+
'pre_move_uploaded_file',
|
1236 |
+
'filesystem_method_file',
|
1237 |
+
'filesystem_method',
|
1238 |
+
'request_filesystem_credentials',
|
1239 |
+
'fs_ftp_connection_types',
|
1240 |
+
'wp_privacy_personal_data_email_content',
|
1241 |
+
'image_editor_save_pre',
|
1242 |
+
'image_save_pre',
|
1243 |
+
'wp_save_image_editor_file',
|
1244 |
+
'wp_save_image_file',
|
1245 |
+
'wp_image_editor_before_change',
|
1246 |
+
'image_edit_before_change',
|
1247 |
+
'comment_edit_redirect',
|
1248 |
+
'shake_error_codes',
|
1249 |
+
'login_title',
|
1250 |
+
'login_headerurl',
|
1251 |
+
'login_headertitle',
|
1252 |
+
'login_body_class',
|
1253 |
+
'login_message',
|
1254 |
+
'login_errors',
|
1255 |
+
'login_messages',
|
1256 |
+
'retrieve_password_title',
|
1257 |
+
'retrieve_password_message',
|
1258 |
+
'login_link_separator',
|
1259 |
+
'post_password_expires',
|
1260 |
+
'logout_redirect',
|
1261 |
+
'lostpassword_redirect',
|
1262 |
+
'wp_signup_location',
|
1263 |
+
'registration_redirect',
|
1264 |
+
'login_redirect',
|
1265 |
+
'wp_login_errors',
|
1266 |
+
'wp_mail_original_content',
|
1267 |
+
'phone_content',
|
1268 |
+
);
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
/**
|
1272 |
+
* Load the generator tabs.
|
1273 |
+
*
|
1274 |
+
* @return void
|
1275 |
+
*/
|
1276 |
+
protected function load_tabs() {
|
1277 |
+
$this->tabs = array(
|
1278 |
+
'info' => array(
|
1279 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
1280 |
+
'columns' => array(
|
1281 |
+
// Column 1.
|
1282 |
+
array(
|
1283 |
+
// Column 1 fields.
|
1284 |
+
array(
|
1285 |
+
'type' => 'description',
|
1286 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
1287 |
+
'content' => sprintf(
|
1288 |
+
// Translators: Placeholders add links to the wordpress.org references.
|
1289 |
+
__( 'Using this generator you can safely add custom %1$shooks%2$s using either %3$sadd_action%4$s or %5$sadd_filter%6$s.', 'insert-headers-and-footers' ),
|
1290 |
+
'<a href="https://developer.wordpress.org/reference/hooks/" target="_blank">',
|
1291 |
+
'</a>',
|
1292 |
+
'<a href="https://developer.wordpress.org/reference/functions/add_action/" target="_blank">',
|
1293 |
+
'</a>',
|
1294 |
+
'<a href="https://developer.wordpress.org/reference/functions/add_filter/" target="_blank">',
|
1295 |
+
'</a>'
|
1296 |
+
),
|
1297 |
+
),
|
1298 |
+
),
|
1299 |
+
// Column 2.
|
1300 |
+
array(
|
1301 |
+
// Column 2 fields.
|
1302 |
+
array(
|
1303 |
+
'type' => 'list',
|
1304 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
1305 |
+
'content' => array(
|
1306 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
1307 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
1308 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
1309 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
1310 |
+
),
|
1311 |
+
),
|
1312 |
+
),
|
1313 |
+
// Column 3.
|
1314 |
+
array(
|
1315 |
+
// Column 3 fields.
|
1316 |
+
array(
|
1317 |
+
'type' => 'description',
|
1318 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
1319 |
+
'content' => __( 'You can use this to quickly get started with adding an action or filter.', 'insert-headers-and-footers' ),
|
1320 |
+
),
|
1321 |
+
),
|
1322 |
+
),
|
1323 |
+
),
|
1324 |
+
'hook' => array(
|
1325 |
+
'label' => __( 'Hook Details', 'insert-headers-and-footers' ),
|
1326 |
+
'columns' => array(
|
1327 |
+
// Column 1.
|
1328 |
+
array(
|
1329 |
+
array(
|
1330 |
+
'type' => 'select',
|
1331 |
+
'label' => __( 'Hook type', 'insert-headers-and-footers' ),
|
1332 |
+
'description' => __( 'Can be either an action or a filter', 'insert-headers-and-footers' ),
|
1333 |
+
'id' => 'hook_type',
|
1334 |
+
'default' => 'add_action',
|
1335 |
+
'options' => array(
|
1336 |
+
'add_action' => __( 'Action', 'insert-headers-and-footers' ),
|
1337 |
+
'add_filter' => __( 'Filter', 'insert-headers-and-footers' ),
|
1338 |
+
),
|
1339 |
+
),
|
1340 |
+
array(
|
1341 |
+
'type' => 'text',
|
1342 |
+
'label' => __( 'Hook name', 'insert-headers-and-footers' ),
|
1343 |
+
'description' => __( 'Input hook name or pick one from the suggested list as you type.', 'insert-headers-and-footers' ),
|
1344 |
+
'id' => 'hook_name',
|
1345 |
+
'default' => '',
|
1346 |
+
'autocomplete' => $this->get_all_hooks_options(),
|
1347 |
+
),
|
1348 |
+
),
|
1349 |
+
// Column 2.
|
1350 |
+
array(
|
1351 |
+
array(
|
1352 |
+
'type' => 'text',
|
1353 |
+
'label' => __( 'Callback function', 'insert-headers-and-footers' ),
|
1354 |
+
'description' => __( 'Name of the function you want to add to this hook.', 'insert-headers-and-footers' ),
|
1355 |
+
'id' => 'callback',
|
1356 |
+
'default' => 'custom_function_' . time(),
|
1357 |
+
),
|
1358 |
+
array(
|
1359 |
+
'type' => 'text',
|
1360 |
+
'label' => __( 'Priority', 'insert-headers-and-footers' ),
|
1361 |
+
'description' => __( 'Priority of this hook, by default 10.', 'insert-headers-and-footers' ),
|
1362 |
+
'id' => 'priority',
|
1363 |
+
'default' => '10',
|
1364 |
+
),
|
1365 |
+
),
|
1366 |
+
// Column 3.
|
1367 |
+
array(
|
1368 |
+
array(
|
1369 |
+
'type' => 'text',
|
1370 |
+
'label' => __( 'Arguments list', 'insert-headers-and-footers' ),
|
1371 |
+
'description' => __( 'Add comma-separated custom arguments that will be passed to the callback function depending on the action/filter.', 'insert-headers-and-footers' ),
|
1372 |
+
'id' => 'arguments',
|
1373 |
+
'default' => '',
|
1374 |
+
),
|
1375 |
+
),
|
1376 |
+
),
|
1377 |
+
),
|
1378 |
+
'code' => array(
|
1379 |
+
'label' => __( 'Code', 'insert-headers-and-footers' ),
|
1380 |
+
'columns' => array(
|
1381 |
+
// Column 1.
|
1382 |
+
array(
|
1383 |
+
array(
|
1384 |
+
'type' => 'textarea',
|
1385 |
+
'label' => __( 'PHP Code', 'insert-headers-and-footers' ),
|
1386 |
+
'description' => __( 'Custom PHP code you want to run in the function, you can also edit this after you create the snippet.', 'insert-headers-and-footers' ),
|
1387 |
+
'id' => 'code',
|
1388 |
+
'code' => true,
|
1389 |
+
),
|
1390 |
+
),
|
1391 |
+
),
|
1392 |
+
),
|
1393 |
+
);
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
/**
|
1397 |
+
* Get the snippet code with dynamic values applied.
|
1398 |
+
*
|
1399 |
+
* @return string
|
1400 |
+
*/
|
1401 |
+
public function get_snippet_code() {
|
1402 |
+
|
1403 |
+
$arguments = $this->get_value( 'arguments' );
|
1404 |
+
|
1405 |
+
$arguments_array = explode( ',', $arguments );
|
1406 |
+
$arguments_array = array_map( 'trim', $arguments_array );
|
1407 |
+
$count = count( $arguments_array );
|
1408 |
+
if ( $count > 1 ) {
|
1409 |
+
$count = ", $count";
|
1410 |
+
} else {
|
1411 |
+
$count = '';
|
1412 |
+
}
|
1413 |
+
$arguments_formatted = implode( ', ', $arguments_array );
|
1414 |
+
$priority = intval( $this->get_value( 'priority' ) );
|
1415 |
+
$callback = str_replace( '-', '_', sanitize_title_with_dashes( $this->get_value( 'callback' ) ) );
|
1416 |
+
|
1417 |
+
return <<<EOD
|
1418 |
+
// Add a hook.
|
1419 |
+
function $callback( $arguments_formatted ) {
|
1420 |
+
{$this->get_value( 'code' )}
|
1421 |
+
}
|
1422 |
+
{$this->get_value( 'hook_type' )}( '{$this->get_value( 'hook_name' )}', '$callback', {$priority}$count );
|
1423 |
+
EOD;
|
1424 |
+
}
|
1425 |
+
|
1426 |
+
}
|
includes/generator/class-wpcode-generator-menu.php
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet for adding a custom navigation menu.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Menu class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Menu extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'menu';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'design',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Navigation Menu', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Generate a snippet to register new navigation menus for your website.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => sprintf(
|
56 |
+
// Translators: Placeholders add links to the wordpress.org references.
|
57 |
+
__( 'This generator makes it easy to add new navigation menus to your website using the "register_nav_menus" function.', 'insert-headers-and-footers' ),
|
58 |
+
'<a href="https://developer.wordpress.org/reference/functions/register_nav_menus/" target="_blank">',
|
59 |
+
'</a>'
|
60 |
+
),
|
61 |
+
),
|
62 |
+
),
|
63 |
+
// Column 2.
|
64 |
+
array(
|
65 |
+
// Column 2 fields.
|
66 |
+
array(
|
67 |
+
'type' => 'list',
|
68 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
69 |
+
'content' => array(
|
70 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
71 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
72 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
73 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
74 |
+
),
|
75 |
+
),
|
76 |
+
),
|
77 |
+
// Column 3.
|
78 |
+
array(
|
79 |
+
// Column 3 fields.
|
80 |
+
array(
|
81 |
+
'type' => 'description',
|
82 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
83 |
+
'content' => __( 'You can add a new navigation menu for your website to display in a flyout menu that is not part of the theme, for example.', 'insert-headers-and-footers' ),
|
84 |
+
),
|
85 |
+
),
|
86 |
+
),
|
87 |
+
),
|
88 |
+
'general' => array(
|
89 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
90 |
+
'columns' => array(
|
91 |
+
// Column 1.
|
92 |
+
array(
|
93 |
+
array(
|
94 |
+
'type' => 'text',
|
95 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
96 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
97 |
+
'id' => 'function_name',
|
98 |
+
'placeholder' => 'add_custom_navigation_menu',
|
99 |
+
'default' => 'add_custom_navigation_menu' . time(),
|
100 |
+
),
|
101 |
+
),
|
102 |
+
// Column 2.
|
103 |
+
array(
|
104 |
+
array(
|
105 |
+
'type' => 'text',
|
106 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
107 |
+
'description' => __( 'Optional text domain for translations.', 'insert-headers-and-footers' ),
|
108 |
+
'id' => 'text_domain',
|
109 |
+
'placeholder' => 'text_domain',
|
110 |
+
'default' => 'text_domain',
|
111 |
+
),
|
112 |
+
),
|
113 |
+
),
|
114 |
+
),
|
115 |
+
'schedule' => array(
|
116 |
+
'label' => __( 'Menus', 'insert-headers-and-footers' ),
|
117 |
+
'columns' => array(
|
118 |
+
// Column 1.
|
119 |
+
array(
|
120 |
+
array(
|
121 |
+
'type' => 'text',
|
122 |
+
'label' => __( 'Menu name', 'insert-headers-and-footers' ),
|
123 |
+
'description' => __( 'This is the menu name slug, lowercase and no space.', 'insert-headers-and-footers' ),
|
124 |
+
'id' => 'menu_name',
|
125 |
+
'name' => 'menu_name[]',
|
126 |
+
'repeater' => 'menus',
|
127 |
+
),
|
128 |
+
array(
|
129 |
+
'type' => 'text',
|
130 |
+
'label' => __( 'Menu label', 'insert-headers-and-footers' ),
|
131 |
+
'description' => __( 'Add a descriptive label for this menu in the admin.', 'insert-headers-and-footers' ),
|
132 |
+
'id' => 'menu_description',
|
133 |
+
'name' => 'menu_description[]',
|
134 |
+
'repeater' => 'menus',
|
135 |
+
),
|
136 |
+
),
|
137 |
+
// Column 2.
|
138 |
+
array(
|
139 |
+
array(
|
140 |
+
'type' => 'description',
|
141 |
+
'label' => __( 'Add another menu', 'insert-headers-and-footers' ),
|
142 |
+
'content' => __( 'Use the "Add menu" button below to add as many menu locations as you need.', 'insert-headers-and-footers' ),
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'type' => 'repeater_button',
|
146 |
+
'button_text' => __( 'Add Menu', 'insert-headers-and-footers' ),
|
147 |
+
'id' => 'menus', // Repeater to repeat when clicked.
|
148 |
+
),
|
149 |
+
),
|
150 |
+
),
|
151 |
+
),
|
152 |
+
);
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Get the snippet code with dynamic values applied.
|
157 |
+
*
|
158 |
+
* @return string
|
159 |
+
*/
|
160 |
+
public function get_snippet_code() {
|
161 |
+
|
162 |
+
$menus = $this->get_value( 'menu_name' );
|
163 |
+
$descriptions = $this->get_value( 'menu_description' );
|
164 |
+
$menus_code = '';
|
165 |
+
$textdomain = $this->get_value( 'text_domain' );
|
166 |
+
|
167 |
+
if ( ! empty( $menus ) ) {
|
168 |
+
$array_code = '';
|
169 |
+
foreach ( $menus as $key => $menu ) {
|
170 |
+
if ( empty( $menu ) ) {
|
171 |
+
continue;
|
172 |
+
}
|
173 |
+
$array_code .= "'$menu' => __( '$descriptions[$key]', '$textdomain' ),\n\t\t";
|
174 |
+
}
|
175 |
+
if ( ! empty( $array_code ) ) {
|
176 |
+
$menus_code = "\$menus = array(
|
177 |
+
$array_code);
|
178 |
+
register_nav_menus( \$menus );
|
179 |
+
";
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
return <<<EOD
|
184 |
+
// Add Custom Navigation Menus
|
185 |
+
function {$this->get_value( 'function_name' )}() {
|
186 |
+
$menus_code
|
187 |
+
}
|
188 |
+
add_action( 'init', '{$this->get_value( 'function_name' )}' );
|
189 |
+
EOD;
|
190 |
+
}
|
191 |
+
|
192 |
+
}
|
includes/generator/class-wpcode-generator-post-status.php
ADDED
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to register a new post status.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The Post Status generator.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Post_Status extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'post-status';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'content',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Post Status', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Use this tool to generate a custom post status for your posts.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Generate custom post statuses for your posts to improve the way you manage content.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => __( 'You could add a new status called "Pending Review" that your authors can use before the content will be published', 'insert-headers-and-footers' ),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
'general' => array(
|
84 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
85 |
+
'columns' => array(
|
86 |
+
// Column 1.
|
87 |
+
array(
|
88 |
+
array(
|
89 |
+
'type' => 'text',
|
90 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
91 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
92 |
+
'id' => 'function_name',
|
93 |
+
'placeholder' => 'custom_post_status',
|
94 |
+
'default' => 'custom_post_status' . time(),
|
95 |
+
),
|
96 |
+
),
|
97 |
+
// Column 2.
|
98 |
+
array(
|
99 |
+
array(
|
100 |
+
'type' => 'text',
|
101 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
102 |
+
'description' => __( 'Optional text domain for translations.', 'insert-headers-and-footers' ),
|
103 |
+
'id' => 'text_domain',
|
104 |
+
'placeholder' => 'text_domain',
|
105 |
+
'default' => 'text_domain',
|
106 |
+
),
|
107 |
+
),
|
108 |
+
),
|
109 |
+
),
|
110 |
+
'status' => array(
|
111 |
+
'label' => __( 'Status', 'insert-headers-and-footers' ),
|
112 |
+
'columns' => array(
|
113 |
+
// Column 1.
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'type' => 'text',
|
117 |
+
'label' => __( 'Post Status', 'insert-headers-and-footers' ),
|
118 |
+
'description' => __( 'Name of status used in the code, lowercase maximum 32 characters.', 'insert-headers-and-footers' ),
|
119 |
+
'id' => 'post_status',
|
120 |
+
'placeholder' => 'pending',
|
121 |
+
'default' => 'pending',
|
122 |
+
),
|
123 |
+
),
|
124 |
+
// Column 2.
|
125 |
+
array(
|
126 |
+
array(
|
127 |
+
'type' => 'text',
|
128 |
+
'label' => __( 'Name', 'insert-headers-and-footers' ),
|
129 |
+
'description' => __( 'The singular name that will be displayed in the admin. ' ),
|
130 |
+
'id' => 'label',
|
131 |
+
'placeholder' => 'Pending',
|
132 |
+
'default' => 'Pending',
|
133 |
+
),
|
134 |
+
array(
|
135 |
+
'type' => 'text',
|
136 |
+
'label' => __( 'Name (Plural)', 'insert-headers-and-footers' ),
|
137 |
+
'description' => __( 'The post status plural name. For example: Drafts.' ),
|
138 |
+
'id' => 'label_count',
|
139 |
+
'placeholder' => 'Pending',
|
140 |
+
'default' => 'Pending',
|
141 |
+
),
|
142 |
+
),
|
143 |
+
),
|
144 |
+
),
|
145 |
+
'visibility' => array(
|
146 |
+
'label' => __( 'Visibility', 'insert-headers-and-footers' ),
|
147 |
+
'columns' => array(
|
148 |
+
// Column 1.
|
149 |
+
array(
|
150 |
+
array(
|
151 |
+
'type' => 'select',
|
152 |
+
'label' => __( 'Public', 'insert-headers-and-footers' ),
|
153 |
+
'description' => __( 'Should the posts with this status be visible in the frontend?', 'insert-headers-and-footers' ),
|
154 |
+
'id' => 'public',
|
155 |
+
'options' => array(
|
156 |
+
'true' => __( 'Yes - Default', 'insert-headers-and-footers' ),
|
157 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
158 |
+
),
|
159 |
+
'default' => 'true',
|
160 |
+
),
|
161 |
+
),
|
162 |
+
// Column 2.
|
163 |
+
array(
|
164 |
+
array(
|
165 |
+
'type' => 'select',
|
166 |
+
'label' => __( 'Exclude from search results', 'insert-headers-and-footers' ),
|
167 |
+
'description' => __( 'Should the posts with this status be visible in the frontend?', 'insert-headers-and-footers' ),
|
168 |
+
'id' => 'exclude_from_search',
|
169 |
+
'options' => array(
|
170 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
171 |
+
'false' => __( 'No - Default', 'insert-headers-and-footers' ),
|
172 |
+
),
|
173 |
+
'default' => 'false',
|
174 |
+
),
|
175 |
+
),
|
176 |
+
// Column 3.
|
177 |
+
array(
|
178 |
+
array(
|
179 |
+
'type' => 'select',
|
180 |
+
'label' => __( 'Show in admin all list', 'insert-headers-and-footers' ),
|
181 |
+
'description' => __( 'Show statuses in the edit listing of the post.', 'insert-headers-and-footers' ),
|
182 |
+
'id' => 'show_in_admin_all_list',
|
183 |
+
'options' => array(
|
184 |
+
'true' => __( 'Yes - Default', 'insert-headers-and-footers' ),
|
185 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
186 |
+
),
|
187 |
+
'default' => 'true',
|
188 |
+
),
|
189 |
+
array(
|
190 |
+
'type' => 'select',
|
191 |
+
'label' => __( 'Show in admin status list', 'insert-headers-and-footers' ),
|
192 |
+
'description' => __( 'Show statuses list at the top of the edit listings. e.g. Published (12) Custom Status (2)', 'insert-headers-and-footers' ),
|
193 |
+
'id' => 'show_in_admin_status_list',
|
194 |
+
'options' => array(
|
195 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
196 |
+
'false' => __( 'No - Default', 'insert-headers-and-footers' ),
|
197 |
+
),
|
198 |
+
'default' => 'false',
|
199 |
+
),
|
200 |
+
),
|
201 |
+
),
|
202 |
+
),
|
203 |
+
);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Get the snippet code with dynamic values applied.
|
208 |
+
*
|
209 |
+
* @return string
|
210 |
+
*/
|
211 |
+
public function get_snippet_code() {
|
212 |
+
return <<<EOD
|
213 |
+
// Register Custom Status
|
214 |
+
function {$this->get_value( 'function_name' )}() {
|
215 |
+
|
216 |
+
\$args = array(
|
217 |
+
'label' => _x( '{$this->get_value( 'label' )}', 'Post Status Name', '{$this->get_value( 'text_domain' )}' ),
|
218 |
+
'label_count' => _n_noop( '{$this->get_value( 'label' )} (%s)', '{$this->get_value( 'label_count' )} (%s)', '{$this->get_value( 'text_domain' )}' ),
|
219 |
+
'public' => {$this->get_value( 'public' )},
|
220 |
+
'show_in_admin_all_list' => {$this->get_value( 'show_in_admin_all_list' )},
|
221 |
+
'show_in_admin_status_list' => {$this->get_value( 'show_in_admin_status_list' )},
|
222 |
+
'exclude_from_search' => {$this->get_value( 'exclude_from_search' )},
|
223 |
+
);
|
224 |
+
register_post_status( '{$this->get_value( 'post_status' )}', \$args );
|
225 |
+
|
226 |
+
}
|
227 |
+
add_action( 'init', '{$this->get_value( 'function_name' )}', 5 );
|
228 |
+
EOD;
|
229 |
+
}
|
230 |
+
|
231 |
+
}
|
includes/generator/class-wpcode-generator-post-type.php
ADDED
@@ -0,0 +1,898 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to register a new post type.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The Post Type generator.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Post_Type extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'post-type';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'content',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Post Type', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Use this tool to generate a custom post type for your website.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Generate custom post types for your website using a snippet.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => __( 'You can add custom post types for specific items that are not blog posts, for example, if your site is about music you can have post types for artists, albums or songs.', 'insert-headers-and-footers' ),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
'general' => array(
|
84 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
85 |
+
'columns' => array(
|
86 |
+
// Column 1.
|
87 |
+
array(
|
88 |
+
array(
|
89 |
+
'type' => 'text',
|
90 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
91 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
92 |
+
'id' => 'function_name',
|
93 |
+
'placeholder' => 'custom_post_type',
|
94 |
+
'default' => 'custom_post_type' . time(),
|
95 |
+
),
|
96 |
+
),
|
97 |
+
// Column 2.
|
98 |
+
array(
|
99 |
+
array(
|
100 |
+
'type' => 'text',
|
101 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
102 |
+
'description' => __( 'Optional text domain for translations.', 'insert-headers-and-footers' ),
|
103 |
+
'id' => 'text_domain',
|
104 |
+
'placeholder' => 'text_domain',
|
105 |
+
'default' => 'text_domain',
|
106 |
+
),
|
107 |
+
),
|
108 |
+
),
|
109 |
+
),
|
110 |
+
'post_type' => array(
|
111 |
+
'label' => __( 'Post Type', 'insert-headers-and-footers' ),
|
112 |
+
'columns' => array(
|
113 |
+
// Column 1.
|
114 |
+
array(
|
115 |
+
array(
|
116 |
+
'type' => 'text',
|
117 |
+
'label' => __( 'Post Type Key', 'insert-headers-and-footers' ),
|
118 |
+
'description' => __( 'Name of post type used in the code, lowercase maximum 20 characters.', 'insert-headers-and-footers' ),
|
119 |
+
'id' => 'post_type',
|
120 |
+
'placeholder' => 'post_type',
|
121 |
+
'default' => 'post_type',
|
122 |
+
),
|
123 |
+
array(
|
124 |
+
'type' => 'text',
|
125 |
+
'label' => __( 'Description', 'insert-headers-and-footers' ),
|
126 |
+
'description' => __( 'A short description of the post type.', 'insert-headers-and-footers' ),
|
127 |
+
'id' => 'description',
|
128 |
+
'placeholder' => 'Post type description',
|
129 |
+
'default' => 'Post type description',
|
130 |
+
),
|
131 |
+
),
|
132 |
+
// Column 2.
|
133 |
+
array(
|
134 |
+
array(
|
135 |
+
'type' => 'text',
|
136 |
+
'label' => __( 'Name', 'insert-headers-and-footers' ),
|
137 |
+
'description' => __( 'The singular post type name (e.g. Artist, Album, Song).', 'insert-headers-and-footers' ),
|
138 |
+
'id' => 'label',
|
139 |
+
'placeholder' => 'Post Type',
|
140 |
+
'default' => 'Post Type',
|
141 |
+
),
|
142 |
+
array(
|
143 |
+
'type' => 'text',
|
144 |
+
'label' => __( 'Name (Plural)', 'insert-headers-and-footers' ),
|
145 |
+
'description' => __( 'The post type plural name (e.g. Artists, Albums, Songs).', 'insert-headers-and-footers' ),
|
146 |
+
'id' => 'label_count',
|
147 |
+
'placeholder' => 'Post Types',
|
148 |
+
'default' => 'Post Types',
|
149 |
+
),
|
150 |
+
),
|
151 |
+
// Column 3.
|
152 |
+
array(
|
153 |
+
array(
|
154 |
+
'type' => 'text',
|
155 |
+
'label' => __( 'Link To Taxonomies', 'insert-headers-and-footers' ),
|
156 |
+
'description' => __( 'Comma-separated list of Taxonomies (e.g. post_tag, category)', 'insert-headers-and-footers' ),
|
157 |
+
'id' => 'taxonomies',
|
158 |
+
'placeholder' => 'category,post_tag',
|
159 |
+
'default' => '',
|
160 |
+
),
|
161 |
+
array(
|
162 |
+
'type' => 'select',
|
163 |
+
'label' => __( 'Hierarchical', 'insert-headers-and-footers' ),
|
164 |
+
'description' => __( 'Hierarchical post types can have parents/children.', 'insert-headers-and-footers' ),
|
165 |
+
'id' => 'hierarchical',
|
166 |
+
'default' => 'false',
|
167 |
+
'options' => array(
|
168 |
+
'true' => __( 'Yes, like pages', 'insert-headers-and-footers' ),
|
169 |
+
'false' => __( 'No, like posts', 'insert-headers-and-footers' ),
|
170 |
+
),
|
171 |
+
),
|
172 |
+
),
|
173 |
+
),
|
174 |
+
),
|
175 |
+
'labels' => array(
|
176 |
+
'label' => __( 'Labels', 'insert-headers-and-footers' ),
|
177 |
+
'columns' => array(
|
178 |
+
// Column 1.
|
179 |
+
array(
|
180 |
+
array(
|
181 |
+
'type' => 'text',
|
182 |
+
'label' => __( 'Menu Name', 'insert-headers-and-footers' ),
|
183 |
+
'id' => 'label_menu_name',
|
184 |
+
'placeholder' => 'Post Types',
|
185 |
+
'default' => 'Post Types',
|
186 |
+
),
|
187 |
+
array(
|
188 |
+
'type' => 'text',
|
189 |
+
'label' => __( 'Admin Bar Name', 'insert-headers-and-footers' ),
|
190 |
+
'id' => 'label_admin_bar_name',
|
191 |
+
'placeholder' => 'Post Type',
|
192 |
+
'default' => 'Post Type',
|
193 |
+
),
|
194 |
+
array(
|
195 |
+
'type' => 'text',
|
196 |
+
'label' => __( 'Archives', 'insert-headers-and-footers' ),
|
197 |
+
'id' => 'label_archives',
|
198 |
+
'placeholder' => 'Item Archives',
|
199 |
+
'default' => 'Item Archives',
|
200 |
+
),
|
201 |
+
array(
|
202 |
+
'type' => 'text',
|
203 |
+
'label' => __( 'Attributes', 'insert-headers-and-footers' ),
|
204 |
+
'id' => 'label_attributes',
|
205 |
+
'placeholder' => 'Item Attributes',
|
206 |
+
'default' => 'Item Attributes',
|
207 |
+
),
|
208 |
+
array(
|
209 |
+
'type' => 'text',
|
210 |
+
'label' => __( 'Parent Item', 'insert-headers-and-footers' ),
|
211 |
+
'id' => 'label_parent_item',
|
212 |
+
'placeholder' => 'Parent Item:',
|
213 |
+
'default' => 'Parent Item:',
|
214 |
+
),
|
215 |
+
array(
|
216 |
+
'type' => 'text',
|
217 |
+
'label' => __( 'All Items', 'insert-headers-and-footers' ),
|
218 |
+
'id' => 'label_all_items',
|
219 |
+
'placeholder' => 'All Items',
|
220 |
+
'default' => 'All Items',
|
221 |
+
),
|
222 |
+
array(
|
223 |
+
'type' => 'text',
|
224 |
+
'label' => __( 'Add New Item', 'insert-headers-and-footers' ),
|
225 |
+
'id' => 'label_add_new_item',
|
226 |
+
'placeholder' => 'Add New Item',
|
227 |
+
'default' => 'Add New Item',
|
228 |
+
),
|
229 |
+
array(
|
230 |
+
'type' => 'text',
|
231 |
+
'label' => __( 'Add New', 'insert-headers-and-footers' ),
|
232 |
+
'id' => 'label_add_new',
|
233 |
+
'placeholder' => 'Add New',
|
234 |
+
'default' => 'Add New',
|
235 |
+
),
|
236 |
+
array(
|
237 |
+
'type' => 'text',
|
238 |
+
'label' => __( 'New Item', 'insert-headers-and-footers' ),
|
239 |
+
'id' => 'label_new_item',
|
240 |
+
'placeholder' => 'New Item',
|
241 |
+
'default' => 'New Item',
|
242 |
+
),
|
243 |
+
),
|
244 |
+
// Column 2.
|
245 |
+
array(
|
246 |
+
array(
|
247 |
+
'type' => 'text',
|
248 |
+
'label' => __( 'Edit Item', 'insert-headers-and-footers' ),
|
249 |
+
'id' => 'label_edit_item',
|
250 |
+
'placeholder' => 'Edit Item',
|
251 |
+
'default' => 'Edit Item',
|
252 |
+
),
|
253 |
+
array(
|
254 |
+
'type' => 'text',
|
255 |
+
'label' => __( 'Update Item', 'insert-headers-and-footers' ),
|
256 |
+
'id' => 'label_update_item',
|
257 |
+
'placeholder' => 'Update Item',
|
258 |
+
'default' => 'Update Item',
|
259 |
+
),
|
260 |
+
array(
|
261 |
+
'type' => 'text',
|
262 |
+
'label' => __( 'View Item', 'insert-headers-and-footers' ),
|
263 |
+
'id' => 'label_view_item',
|
264 |
+
'placeholder' => 'View Item',
|
265 |
+
'default' => 'View Item',
|
266 |
+
),
|
267 |
+
array(
|
268 |
+
'type' => 'text',
|
269 |
+
'label' => __( 'View Items', 'insert-headers-and-footers' ),
|
270 |
+
'id' => 'label_view_items',
|
271 |
+
'placeholder' => 'View Items',
|
272 |
+
'default' => 'View Items',
|
273 |
+
),
|
274 |
+
array(
|
275 |
+
'type' => 'text',
|
276 |
+
'label' => __( 'Search Item', 'insert-headers-and-footers' ),
|
277 |
+
'id' => 'label_search_item',
|
278 |
+
'placeholder' => 'Search Item',
|
279 |
+
'default' => 'Search Item',
|
280 |
+
),
|
281 |
+
array(
|
282 |
+
'type' => 'text',
|
283 |
+
'label' => __( 'Not Found', 'insert-headers-and-footers' ),
|
284 |
+
'id' => 'label_not_found',
|
285 |
+
'placeholder' => 'Not Found',
|
286 |
+
'default' => 'Not Found',
|
287 |
+
),
|
288 |
+
array(
|
289 |
+
'type' => 'text',
|
290 |
+
'label' => __( 'Not Found in Trash', 'insert-headers-and-footers' ),
|
291 |
+
'id' => 'label_not_found_in_trash',
|
292 |
+
'placeholder' => 'Not Found in Trash',
|
293 |
+
'default' => 'Not Found in Trash',
|
294 |
+
),
|
295 |
+
array(
|
296 |
+
'type' => 'text',
|
297 |
+
'label' => __( 'Featured Image', 'insert-headers-and-footers' ),
|
298 |
+
'id' => 'label_featured_image',
|
299 |
+
'placeholder' => 'Featured Image',
|
300 |
+
'default' => 'Featured Image',
|
301 |
+
),
|
302 |
+
array(
|
303 |
+
'type' => 'text',
|
304 |
+
'label' => __( 'Set featured image', 'insert-headers-and-footers' ),
|
305 |
+
'id' => 'label_set_featured_image',
|
306 |
+
'placeholder' => 'Set featured image',
|
307 |
+
'default' => 'Set featured image',
|
308 |
+
),
|
309 |
+
),
|
310 |
+
// Column 3.
|
311 |
+
array(
|
312 |
+
array(
|
313 |
+
'type' => 'text',
|
314 |
+
'label' => __( 'Remove featured image', 'insert-headers-and-footers' ),
|
315 |
+
'id' => 'label_remove_featured_image',
|
316 |
+
'placeholder' => 'Remove featured image',
|
317 |
+
'default' => 'Remove featured image',
|
318 |
+
),
|
319 |
+
array(
|
320 |
+
'type' => 'text',
|
321 |
+
'label' => __( 'Use as featured image', 'insert-headers-and-footers' ),
|
322 |
+
'id' => 'label_use_as_featured_image',
|
323 |
+
'placeholder' => 'Use as featured image',
|
324 |
+
'default' => 'Use as featured image',
|
325 |
+
),
|
326 |
+
array(
|
327 |
+
'type' => 'text',
|
328 |
+
'label' => __( 'Insert into item', 'insert-headers-and-footers' ),
|
329 |
+
'id' => 'label_label_insert_into_item',
|
330 |
+
'placeholder' => 'Insert into item',
|
331 |
+
'default' => 'Insert into item',
|
332 |
+
),
|
333 |
+
array(
|
334 |
+
'type' => 'text',
|
335 |
+
'label' => __( 'Uploaded to this item', 'insert-headers-and-footers' ),
|
336 |
+
'id' => 'label_uploaded_to_this_item',
|
337 |
+
'placeholder' => 'Uploaded to this item',
|
338 |
+
'default' => 'Uploaded to this item',
|
339 |
+
),
|
340 |
+
array(
|
341 |
+
'type' => 'text',
|
342 |
+
'label' => __( 'Items list', 'insert-headers-and-footers' ),
|
343 |
+
'id' => 'label_items_list',
|
344 |
+
'placeholder' => 'Items list',
|
345 |
+
'default' => 'Items list',
|
346 |
+
),
|
347 |
+
array(
|
348 |
+
'type' => 'text',
|
349 |
+
'label' => __( 'Items list navigation', 'insert-headers-and-footers' ),
|
350 |
+
'id' => 'label_items_list_navigation',
|
351 |
+
'placeholder' => 'Items list navigation',
|
352 |
+
'default' => 'Items list navigation',
|
353 |
+
),
|
354 |
+
array(
|
355 |
+
'type' => 'text',
|
356 |
+
'label' => __( 'Filter items list', 'insert-headers-and-footers' ),
|
357 |
+
'id' => 'label_filter_items_list',
|
358 |
+
'placeholder' => 'Filter items list',
|
359 |
+
'default' => 'Filter items list',
|
360 |
+
),
|
361 |
+
),
|
362 |
+
),
|
363 |
+
),
|
364 |
+
'options' => array(
|
365 |
+
'label' => __( 'Options', 'insert-headers-and-footers' ),
|
366 |
+
'columns' => array(
|
367 |
+
// Column 1.
|
368 |
+
array(
|
369 |
+
array(
|
370 |
+
'type' => 'checkbox_list',
|
371 |
+
'label' => __( 'Supports', 'insert-headers-and-footers' ),
|
372 |
+
'description' => __( 'Select which features this post type should support', 'insert-headers-and-footers' ),
|
373 |
+
'id' => 'supports',
|
374 |
+
'default' => array( 'title', 'editor' ),
|
375 |
+
'options' => array(
|
376 |
+
'title' => __( 'Title', 'insert-headers-and-footers' ),
|
377 |
+
'editor' => __( 'Content Editor', 'insert-headers-and-footers' ),
|
378 |
+
'author' => __( 'Author', 'insert-headers-and-footers' ),
|
379 |
+
'thumbnail' => __( 'Featured image', 'insert-headers-and-footers' ),
|
380 |
+
'excerpt' => __( 'Excerpt', 'insert-headers-and-footers' ),
|
381 |
+
'trackbacks' => __( 'Trackbacks', 'insert-headers-and-footers' ),
|
382 |
+
'custom-fields' => __( 'Custom Fields', 'insert-headers-and-footers' ),
|
383 |
+
'comments' => __( 'Comments', 'insert-headers-and-footers' ),
|
384 |
+
'revisions' => __( 'Revisions', 'insert-headers-and-footers' ),
|
385 |
+
'page-attributes' => __( 'Page Attributes', 'insert-headers-and-footers' ),
|
386 |
+
'post-formats' => __( 'Post Formats', 'insert-headers-and-footers' ),
|
387 |
+
),
|
388 |
+
),
|
389 |
+
),
|
390 |
+
// Column 2.
|
391 |
+
array(
|
392 |
+
array(
|
393 |
+
'type' => 'select',
|
394 |
+
'label' => __( 'Exclude From Search', 'insert-headers-and-footers' ),
|
395 |
+
'description' => __( 'Exclude the posts of this post type from search results?', 'insert-headers-and-footers' ),
|
396 |
+
'id' => 'exclude_from_search',
|
397 |
+
'default' => 'false',
|
398 |
+
'options' => array(
|
399 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
400 |
+
'false' => __( 'No - default', 'insert-headers-and-footers' ),
|
401 |
+
),
|
402 |
+
),
|
403 |
+
array(
|
404 |
+
'type' => 'select',
|
405 |
+
'label' => __( 'Enable Export', 'insert-headers-and-footers' ),
|
406 |
+
'description' => __( 'Allow exporting posts of this post type in Tools > Export.', 'insert-headers-and-footers' ),
|
407 |
+
'id' => 'can_export',
|
408 |
+
'default' => 'true',
|
409 |
+
'options' => array(
|
410 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
411 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
412 |
+
),
|
413 |
+
),
|
414 |
+
),
|
415 |
+
// Column 3.
|
416 |
+
array(
|
417 |
+
array(
|
418 |
+
'type' => 'select',
|
419 |
+
'label' => __( 'Enable Archives', 'insert-headers-and-footers' ),
|
420 |
+
'description' => __( 'Enables archives for this post type, the post type key is used as default.', 'insert-headers-and-footers' ),
|
421 |
+
'id' => 'has_archive',
|
422 |
+
'default' => 'true',
|
423 |
+
'options' => array(
|
424 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
425 |
+
'custom' => __( 'Yes - using custom slug', 'insert-headers-and-footers' ),
|
426 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
427 |
+
),
|
428 |
+
),
|
429 |
+
array(
|
430 |
+
'type' => 'text',
|
431 |
+
'label' => __( 'Custom Archive Slug', 'insert-headers-and-footers' ),
|
432 |
+
'description' => __( 'Custom archive slug (if selected above).', 'insert-headers-and-footers' ),
|
433 |
+
'id' => 'custom_archive_slug',
|
434 |
+
'placeholder' => '',
|
435 |
+
'default' => '',
|
436 |
+
),
|
437 |
+
),
|
438 |
+
),
|
439 |
+
),
|
440 |
+
'visibility' => array(
|
441 |
+
'label' => __( 'Visibility', 'insert-headers-and-footers' ),
|
442 |
+
'columns' => array(
|
443 |
+
// Column 1.
|
444 |
+
array(
|
445 |
+
array(
|
446 |
+
'type' => 'select',
|
447 |
+
'label' => __( 'Public', 'insert-headers-and-footers' ),
|
448 |
+
// Translators: Placeholders add a link to the wp.org documentation page.
|
449 |
+
'description' => sprintf( __( 'Should this post type be %1$svisible to authors%2$s?', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#public" target="_blank">', '</a>' ),
|
450 |
+
'id' => 'public',
|
451 |
+
'default' => 'true',
|
452 |
+
'options' => array(
|
453 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
454 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
455 |
+
),
|
456 |
+
),
|
457 |
+
array(
|
458 |
+
'type' => 'select',
|
459 |
+
'label' => __( 'Show UI', 'insert-headers-and-footers' ),
|
460 |
+
'description' => __( 'Should this post type be visible in the Admin?', 'insert-headers-and-footers' ),
|
461 |
+
'id' => 'show_ui',
|
462 |
+
'default' => 'true',
|
463 |
+
'options' => array(
|
464 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
465 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
466 |
+
),
|
467 |
+
),
|
468 |
+
),
|
469 |
+
// Column 2.
|
470 |
+
array(
|
471 |
+
array(
|
472 |
+
'type' => 'select',
|
473 |
+
'label' => __( 'Show in Menu?', 'insert-headers-and-footers' ),
|
474 |
+
'description' => __( 'Should this post type be visible in the admin menu?', 'insert-headers-and-footers' ),
|
475 |
+
'id' => 'show_in_menu',
|
476 |
+
'default' => 'true',
|
477 |
+
'options' => array(
|
478 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
479 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
480 |
+
),
|
481 |
+
),
|
482 |
+
array(
|
483 |
+
'type' => 'select',
|
484 |
+
'label' => __( 'Menu position', 'insert-headers-and-footers' ),
|
485 |
+
'description' => __( 'Choose the admin menu position.', 'insert-headers-and-footers' ),
|
486 |
+
'id' => 'menu_position',
|
487 |
+
'default' => '5',
|
488 |
+
'options' => array(
|
489 |
+
'5' => __( 'Below Posts (5)', 'insert-headers-and-footers' ),
|
490 |
+
'10' => __( 'Below Media (10)', 'insert-headers-and-footers' ),
|
491 |
+
'20' => __( 'Below Pages (20)', 'insert-headers-and-footers' ),
|
492 |
+
'30' => __( 'Below Comments (30)', 'insert-headers-and-footers' ),
|
493 |
+
'60' => __( 'Below First Separator (60)', 'insert-headers-and-footers' ),
|
494 |
+
'65' => __( 'Below Plugins (65)', 'insert-headers-and-footers' ),
|
495 |
+
'70' => __( 'Below Users (70)', 'insert-headers-and-footers' ),
|
496 |
+
'75' => __( 'Below Tools (75)', 'insert-headers-and-footers' ),
|
497 |
+
'80' => __( 'Below Settings (80)', 'insert-headers-and-footers' ),
|
498 |
+
'100' => __( 'Below Second Separator (100)', 'insert-headers-and-footers' ),
|
499 |
+
),
|
500 |
+
),
|
501 |
+
array(
|
502 |
+
'type' => 'text',
|
503 |
+
'label' => __( 'Menu Icon', 'insert-headers-and-footers' ),
|
504 |
+
// Translators: Placeholder adds a link to the dashicons page.
|
505 |
+
'description' => sprintf( __( 'Icon used next to the post type label in the admin menu. Use either a %1$sdashicon%2$s name or a full URL to an image file.', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">', '</a>' ),
|
506 |
+
'id' => 'menu_icon',
|
507 |
+
'placeholder' => '',
|
508 |
+
'default' => '',
|
509 |
+
),
|
510 |
+
),
|
511 |
+
// Column 3.
|
512 |
+
array(
|
513 |
+
array(
|
514 |
+
'type' => 'select',
|
515 |
+
'label' => __( 'Show in Admin Bar?', 'insert-headers-and-footers' ),
|
516 |
+
'description' => __( 'Should this post type be visible in the admin bar?', 'insert-headers-and-footers' ),
|
517 |
+
'id' => 'show_in_admin_bar',
|
518 |
+
'default' => 'true',
|
519 |
+
'options' => array(
|
520 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
521 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
522 |
+
),
|
523 |
+
),
|
524 |
+
array(
|
525 |
+
'type' => 'select',
|
526 |
+
'label' => __( 'Show in Navigation Menus?', 'insert-headers-and-footers' ),
|
527 |
+
'description' => __( 'Should this post type be available for use in menus (Appearance > Menus)?', 'insert-headers-and-footers' ),
|
528 |
+
'id' => 'show_in_nav_menus',
|
529 |
+
'default' => 'true',
|
530 |
+
'options' => array(
|
531 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
532 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
533 |
+
),
|
534 |
+
),
|
535 |
+
),
|
536 |
+
),
|
537 |
+
),
|
538 |
+
'query' => array(
|
539 |
+
'label' => __( 'Query', 'insert-headers-and-footers' ),
|
540 |
+
'columns' => array(
|
541 |
+
// Column 1.
|
542 |
+
array(
|
543 |
+
array(
|
544 |
+
'type' => 'select',
|
545 |
+
'label' => __( 'Publicly Queryable', 'insert-headers-and-footers' ),
|
546 |
+
// Translators: Placeholders add link to wp.org docs.
|
547 |
+
'description' => sprintf( __( 'Enable frontend requests using the query variable. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#publicly_queryable" target="_blank">', '</a>' ),
|
548 |
+
'id' => 'publicly_queryable',
|
549 |
+
'default' => 'true',
|
550 |
+
'options' => array(
|
551 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
552 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
553 |
+
),
|
554 |
+
),
|
555 |
+
),
|
556 |
+
// Column 2.
|
557 |
+
array(
|
558 |
+
array(
|
559 |
+
'type' => 'select',
|
560 |
+
'label' => __( 'Query variable', 'insert-headers-and-footers' ),
|
561 |
+
// Translators: Placeholders add link to wp.org docs.
|
562 |
+
'description' => sprintf( __( 'Key used for querying posts in the frontend. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#query_var" target="_blank">', '</a>' ),
|
563 |
+
'id' => 'query_var',
|
564 |
+
'default' => 'true',
|
565 |
+
'options' => array(
|
566 |
+
'true' => __( 'Default (post type key)', 'insert-headers-and-footers' ),
|
567 |
+
'custom' => __( 'Custom variable', 'insert-headers-and-footers' ),
|
568 |
+
),
|
569 |
+
),
|
570 |
+
),
|
571 |
+
// Column 3.
|
572 |
+
array(
|
573 |
+
array(
|
574 |
+
'type' => 'text',
|
575 |
+
'label' => __( 'Custom Query Variable', 'insert-headers-and-footers' ),
|
576 |
+
// Translators: Placeholder adds a link to the dashicons page.
|
577 |
+
'description' => sprintf( __( 'The custom query variable to use for this post type. %1$sSee documentation%2$s.', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#query_var" target="_blank">', '</a>' ),
|
578 |
+
'id' => 'query_var',
|
579 |
+
'placeholder' => '',
|
580 |
+
'default' => '',
|
581 |
+
),
|
582 |
+
),
|
583 |
+
),
|
584 |
+
),
|
585 |
+
'permalinks' => array(
|
586 |
+
'label' => __( 'Permalinks', 'insert-headers-and-footers' ),
|
587 |
+
'columns' => array(
|
588 |
+
// Column 1.
|
589 |
+
array(
|
590 |
+
array(
|
591 |
+
'type' => 'select',
|
592 |
+
'label' => __( 'Rewrite Permalinks', 'insert-headers-and-footers' ),
|
593 |
+
// Translators: Placeholders add link to wp.org docs.
|
594 |
+
'description' => sprintf( __( 'Use the default permalink structure, disable permalinks for this post type or use custom options. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#rewrite" target="_blank">', '</a>' ),
|
595 |
+
'id' => 'rewrite',
|
596 |
+
'default' => 'true',
|
597 |
+
'options' => array(
|
598 |
+
'true' => __( 'Default (post type key)', 'insert-headers-and-footers' ),
|
599 |
+
'false' => __( 'Disable permalink rewrites', 'insert-headers-and-footers' ),
|
600 |
+
'custom' => __( 'Custom permalink structure', 'insert-headers-and-footers' ),
|
601 |
+
),
|
602 |
+
),
|
603 |
+
),
|
604 |
+
// Column 2.
|
605 |
+
array(
|
606 |
+
array(
|
607 |
+
'type' => 'text',
|
608 |
+
'label' => __( 'URL Slug', 'insert-headers-and-footers' ),
|
609 |
+
'description' => __( 'The slug used for this post types base. (for example: artist in www.example.com/artist/ )', 'insert-headers-and-footers' ),
|
610 |
+
'id' => 'rewrite_slug',
|
611 |
+
'placeholder' => '',
|
612 |
+
'default' => '',
|
613 |
+
),
|
614 |
+
array(
|
615 |
+
'type' => 'select',
|
616 |
+
'label' => __( 'Use URL Slug?', 'insert-headers-and-footers' ),
|
617 |
+
'description' => __( 'Use the post type name as URL slug base?', 'insert-headers-and-footers' ),
|
618 |
+
'id' => 'with_front',
|
619 |
+
'default' => 'true',
|
620 |
+
'options' => array(
|
621 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
622 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
623 |
+
),
|
624 |
+
),
|
625 |
+
),
|
626 |
+
// Column 3.
|
627 |
+
array(
|
628 |
+
array(
|
629 |
+
'type' => 'select',
|
630 |
+
'label' => __( 'Use pagination?', 'insert-headers-and-footers' ),
|
631 |
+
'description' => __( 'Allow the post type to have pagination?', 'insert-headers-and-footers' ),
|
632 |
+
'id' => 'pages',
|
633 |
+
'default' => 'true',
|
634 |
+
'options' => array(
|
635 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
636 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
637 |
+
),
|
638 |
+
),
|
639 |
+
array(
|
640 |
+
'type' => 'select',
|
641 |
+
'label' => __( 'Use feeds?', 'insert-headers-and-footers' ),
|
642 |
+
'description' => __( 'Allow the post type to have feeds?', 'insert-headers-and-footers' ),
|
643 |
+
'id' => 'feeds',
|
644 |
+
'default' => 'true',
|
645 |
+
'options' => array(
|
646 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
647 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
648 |
+
),
|
649 |
+
),
|
650 |
+
),
|
651 |
+
),
|
652 |
+
),
|
653 |
+
'capabilities' => array(
|
654 |
+
'label' => __( 'Capabilities', 'insert-headers-and-footers' ),
|
655 |
+
'columns' => array(
|
656 |
+
// Column 1.
|
657 |
+
array(
|
658 |
+
array(
|
659 |
+
'type' => 'select',
|
660 |
+
'label' => __( 'Capabilities', 'insert-headers-and-footers' ),
|
661 |
+
// Translators: Placeholders add link to wp.org docs.
|
662 |
+
'description' => sprintf( __( 'User capabilities in relation to this post type. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#capability_type" target="_blank">', '</a>' ),
|
663 |
+
'id' => 'capabilities',
|
664 |
+
'default' => 'true',
|
665 |
+
'options' => array(
|
666 |
+
'true' => __( 'Base capabilities - default', 'insert-headers-and-footers' ),
|
667 |
+
'custom' => __( 'Custom Capabilities', 'insert-headers-and-footers' ),
|
668 |
+
),
|
669 |
+
),
|
670 |
+
array(
|
671 |
+
'type' => 'select',
|
672 |
+
'label' => __( 'Base Capablities Type', 'insert-headers-and-footers' ),
|
673 |
+
'description' => __( 'Use base capabilities from a core post type.', 'insert-headers-and-footers' ),
|
674 |
+
'id' => 'capability_type',
|
675 |
+
'default' => 'post',
|
676 |
+
'options' => array(
|
677 |
+
'post' => __( 'Posts', 'insert-headers-and-footers' ),
|
678 |
+
'page' => __( 'Pages', 'insert-headers-and-footers' ),
|
679 |
+
),
|
680 |
+
),
|
681 |
+
),
|
682 |
+
// Column 2.
|
683 |
+
array(
|
684 |
+
array(
|
685 |
+
'type' => 'description',
|
686 |
+
'label' => __( 'Custom Capabilities', 'insert-headers-and-footers' ),
|
687 |
+
'content' => __( 'Use the fields below to use custom capabilities for this post type.' ),
|
688 |
+
),
|
689 |
+
array(
|
690 |
+
'type' => 'text',
|
691 |
+
'label' => __( 'Read Post', 'insert-headers-and-footers' ),
|
692 |
+
'id' => 'read_post',
|
693 |
+
'default' => 'read_post',
|
694 |
+
'placeholder' => 'read_post',
|
695 |
+
),
|
696 |
+
array(
|
697 |
+
'type' => 'text',
|
698 |
+
'label' => __( 'Read Private Posts', 'insert-headers-and-footers' ),
|
699 |
+
'id' => 'read_private_posts',
|
700 |
+
'default' => 'read_private_posts',
|
701 |
+
'placeholder' => 'read_private_posts',
|
702 |
+
),
|
703 |
+
array(
|
704 |
+
'type' => 'text',
|
705 |
+
'label' => __( 'Publish Posts', 'insert-headers-and-footers' ),
|
706 |
+
'id' => 'publish_posts',
|
707 |
+
'default' => 'publish_posts',
|
708 |
+
'placeholder' => 'publish_posts',
|
709 |
+
),
|
710 |
+
),
|
711 |
+
// Column 3.
|
712 |
+
array(
|
713 |
+
array(
|
714 |
+
'type' => 'text',
|
715 |
+
'label' => __( 'Delete Posts', 'insert-headers-and-footers' ),
|
716 |
+
'id' => 'delete_post',
|
717 |
+
'default' => 'delete_post',
|
718 |
+
'placeholder' => 'delete_post',
|
719 |
+
),
|
720 |
+
array(
|
721 |
+
'type' => 'text',
|
722 |
+
'label' => __( 'Edit Post', 'insert-headers-and-footers' ),
|
723 |
+
'id' => 'edit_post',
|
724 |
+
'default' => 'edit_post',
|
725 |
+
'placeholder' => 'edit_post',
|
726 |
+
),
|
727 |
+
array(
|
728 |
+
'type' => 'text',
|
729 |
+
'label' => __( 'Edit Posts', 'insert-headers-and-footers' ),
|
730 |
+
'id' => 'edit_posts',
|
731 |
+
'default' => 'edit_posts',
|
732 |
+
'placeholder' => 'edit_posts',
|
733 |
+
),
|
734 |
+
array(
|
735 |
+
'type' => 'text',
|
736 |
+
'label' => __( 'Edit Others Posts', 'insert-headers-and-footers' ),
|
737 |
+
'id' => 'edit_others_posts',
|
738 |
+
'default' => 'edit_others_posts',
|
739 |
+
'placeholder' => 'edit_others_posts',
|
740 |
+
),
|
741 |
+
),
|
742 |
+
),
|
743 |
+
),
|
744 |
+
'rest_api' => array(
|
745 |
+
'label' => __( 'Rest API', 'insert-headers-and-footers' ),
|
746 |
+
'columns' => array(
|
747 |
+
// Column 1.
|
748 |
+
array(
|
749 |
+
array(
|
750 |
+
'type' => 'select',
|
751 |
+
'label' => __( 'Show in Rest API?', 'insert-headers-and-footers' ),
|
752 |
+
// Translators: Placeholders add link to wp.org docs.
|
753 |
+
'description' => sprintf( __( 'Add the post type to the WordPress wp-json API. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#show_in_rest" target="_blank">', '</a>' ),
|
754 |
+
'id' => 'show_in_rest',
|
755 |
+
'default' => 'false',
|
756 |
+
'options' => array(
|
757 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
758 |
+
'false' => __( 'No - default', 'insert-headers-and-footers' ),
|
759 |
+
),
|
760 |
+
),
|
761 |
+
),
|
762 |
+
// Column 2.
|
763 |
+
array(
|
764 |
+
array(
|
765 |
+
'type' => 'text',
|
766 |
+
'label' => __( 'Rest Base', 'insert-headers-and-footers' ),
|
767 |
+
// Translators: Placeholders add link to wp.org docs.
|
768 |
+
'description' => sprintf( __( 'The base slug that this post type will use in the REST API. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#rest_base" target="_blank">', '</a>' ),
|
769 |
+
'id' => 'rest_base',
|
770 |
+
'default' => '',
|
771 |
+
),
|
772 |
+
),
|
773 |
+
// Column 3.
|
774 |
+
array(
|
775 |
+
array(
|
776 |
+
'type' => 'text',
|
777 |
+
'label' => __( 'Rest Controller Class', 'insert-headers-and-footers' ),
|
778 |
+
// Translators: Placeholders add link to wp.org docs.
|
779 |
+
'description' => sprintf( __( 'The name of a custom Rest Controller class instead of WP_REST_Posts_Controller. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_post_type/#rest_controller_class" target="_blank">', '</a>' ),
|
780 |
+
'id' => 'rest_controller_class',
|
781 |
+
'default' => '',
|
782 |
+
),
|
783 |
+
),
|
784 |
+
),
|
785 |
+
),
|
786 |
+
);
|
787 |
+
}
|
788 |
+
|
789 |
+
/**
|
790 |
+
* Get the snippet code with dynamic values applied.
|
791 |
+
*
|
792 |
+
* @return string
|
793 |
+
*/
|
794 |
+
public function get_snippet_code() {
|
795 |
+
$has_archive = $this->get_value( 'has_archive' );
|
796 |
+
if ( 'custom' === $has_archive ) {
|
797 |
+
$has_archive = "'{$this->get_value( 'custom_archive_slug' )}'";
|
798 |
+
}
|
799 |
+
|
800 |
+
$rewrite = $this->get_value( 'rewrite' );
|
801 |
+
$rewrite_options = '';
|
802 |
+
if ( 'true' === $rewrite ) {
|
803 |
+
$rewrite = '';
|
804 |
+
} elseif ( 'custom' === $rewrite ) {
|
805 |
+
$rewrite = "\t\t'rewrite' => \$rewrite_options,\n";
|
806 |
+
$rewrite_options = "
|
807 |
+
\$rewrite_options = array(
|
808 |
+
'slug' => '{$this->get_value('rewrite_slug')}',
|
809 |
+
'with_front' => {$this->get_value( 'with_front')},
|
810 |
+
'pages' => {$this->get_value( 'pages')},
|
811 |
+
'feeds' => {$this->get_value( 'feeds')},
|
812 |
+
);
|
813 |
+
";
|
814 |
+
} else {
|
815 |
+
$rewrite = "\t\t'rewrite' => $rewrite,\n";
|
816 |
+
}
|
817 |
+
|
818 |
+
$custom_capabilities = '';
|
819 |
+
$capabilities = $this->get_value( 'capabilities' );
|
820 |
+
|
821 |
+
if ( 'custom' === $capabilities ) {
|
822 |
+
$custom_capabilities = "
|
823 |
+
\$capabilities = array(
|
824 |
+
'read_post' => '{$this->get_value( 'read_post')}',
|
825 |
+
'read_private_posts' => '{$this->get_value( 'read_private_posts')}',
|
826 |
+
'publish_posts' => '{$this->get_value( 'publish_posts')}',
|
827 |
+
'delete_post' => '{$this->get_value( 'delete_post')}',
|
828 |
+
'edit_post' => '{$this->get_value( 'edit_post')}',
|
829 |
+
'edit_posts' => '{$this->get_value( 'edit_posts')}',
|
830 |
+
'edit_others_posts' => '{$this->get_value( 'edit_others_posts')}',
|
831 |
+
);
|
832 |
+
";
|
833 |
+
$capabilities = "'capabilities' => \$capabilities,\n";
|
834 |
+
} else {
|
835 |
+
$capabilities = "'capability_type' => '{$this->get_value('capability_type')}',\n";
|
836 |
+
}
|
837 |
+
|
838 |
+
return <<<EOD
|
839 |
+
// Register Custom Post Type
|
840 |
+
function {$this->get_value( 'function_name' )}() {
|
841 |
+
|
842 |
+
\$labels = array(
|
843 |
+
'name' => _x( '{$this->get_value( 'label_count' )}', 'Post Type General Name', '{$this->get_value( 'text_domain' )}' ),
|
844 |
+
'singular_name' => _x( '{$this->get_value( 'label' )}', 'Post Type Singular Name', '{$this->get_value( 'text_domain' )}' ),
|
845 |
+
'menu_name' => __( '{$this->get_value( 'label_menu_name' )}', '{$this->get_value( 'text_domain' )}' ),
|
846 |
+
'name_admin_bar' => __( '{$this->get_value( 'label_admin_bar_name' )}', '{$this->get_value( 'text_domain' )}' ),
|
847 |
+
'archives' => __( '{$this->get_value( 'label_archives' )}', '{$this->get_value( 'text_domain' )}' ),
|
848 |
+
'attributes' => __( '{$this->get_value( 'label_attributes' )}', '{$this->get_value( 'text_domain' )}' ),
|
849 |
+
'parent_item_colon' => __( '{$this->get_value( 'label_parent_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
850 |
+
'all_items' => __( '{$this->get_value( 'label_all_items' )}', '{$this->get_value( 'text_domain' )}' ),
|
851 |
+
'add_new_item' => __( '{$this->get_value( 'label_add_new_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
852 |
+
'add_new' => __( '{$this->get_value( 'label_add_new' )}', '{$this->get_value( 'text_domain' )}' ),
|
853 |
+
'new_item' => __( '{$this->get_value( 'label_new_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
854 |
+
'edit_item' => __( '{$this->get_value( 'label_edit_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
855 |
+
'update_item' => __( '{$this->get_value( 'label_update_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
856 |
+
'view_item' => __( '{$this->get_value( 'label_view_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
857 |
+
'view_items' => __( '{$this->get_value( 'label_view_items' )}', '{$this->get_value( 'text_domain' )}' ),
|
858 |
+
'search_items' => __( '{$this->get_value( 'label_search_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
859 |
+
'not_found' => __( '{$this->get_value( 'label_not_found' )}', '{$this->get_value( 'text_domain' )}' ),
|
860 |
+
'not_found_in_trash' => __( '{$this->get_value( 'label_not_found_in_trash' )}', '{$this->get_value( 'text_domain' )}' ),
|
861 |
+
'featured_image' => __( '{$this->get_value( 'label_featured_image' )}', '{$this->get_value( 'text_domain' )}' ),
|
862 |
+
'set_featured_image' => __( '{$this->get_value( 'label_set_featured_image' )}', '{$this->get_value( 'text_domain' )}' ),
|
863 |
+
'remove_featured_image' => __( '{$this->get_value( 'label_remove_featured_image' )}', '{$this->get_value( 'text_domain' )}' ),
|
864 |
+
'use_featured_image' => __( '{$this->get_value( 'label_use_as_featured_image' )}', '{$this->get_value( 'text_domain' )}' ),
|
865 |
+
'insert_into_item' => __( '{$this->get_value( 'label_label_insert_into_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
866 |
+
'uploaded_to_this_item' => __( '{$this->get_value( 'label_uploaded_to_this_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
867 |
+
'items_list' => __( '{$this->get_value( 'label_items_list' )}', '{$this->get_value( 'text_domain' )}' ),
|
868 |
+
'items_list_navigation' => __( '{$this->get_value( 'label_items_list_navigation' )}', '{$this->get_value( 'text_domain' )}' ),
|
869 |
+
'filter_items_list' => __( '{$this->get_value( 'label_filter_items_list' )}', '{$this->get_value( 'text_domain' )}' ),
|
870 |
+
);
|
871 |
+
$custom_capabilities
|
872 |
+
$rewrite_options
|
873 |
+
\$args = array(
|
874 |
+
'label' => __( '{$this->get_value( 'label' )}', '{$this->get_value( 'text_domain' )}' ),
|
875 |
+
'description' => __( '{$this->get_value( 'description' )}', '{$this->get_value( 'text_domain' )}' ),
|
876 |
+
'labels' => \$labels,
|
877 |
+
'supports' => {$this->get_array_value( 'supports' )},
|
878 |
+
'taxonomies' => {$this->get_value_comma_separated( 'taxonomies' )},
|
879 |
+
'hierarchical' => {$this->get_value( 'hierarchical' )},
|
880 |
+
'public' => {$this->get_value( 'public' )},
|
881 |
+
'show_ui' => {$this->get_value( 'show_ui' )},
|
882 |
+
'show_in_menu' => {$this->get_value( 'show_in_menu' )},
|
883 |
+
'menu_position' => {$this->get_value( 'menu_position' )},
|
884 |
+
'show_in_admin_bar' => {$this->get_value( 'show_in_admin_bar' )},
|
885 |
+
'show_in_nav_menus' => {$this->get_value( 'show_in_nav_menus' )},
|
886 |
+
'can_export' => {$this->get_value( 'can_export' )},
|
887 |
+
'has_archive' => $has_archive,
|
888 |
+
'exclude_from_search' => {$this->get_value( 'exclude_from_search' )},
|
889 |
+
'publicly_queryable' => {$this->get_value( 'publicly_queryable' )},
|
890 |
+
$capabilities$rewrite{$this->get_optional_value( 'menu_icon', true )}{$this->get_optional_value( 'show_in_rest' )}{$this->get_optional_value( 'rest_base', true )}{$this->get_optional_value( 'rest_controller_class', true )}\t);
|
891 |
+
register_post_type( '{$this->get_value( 'post_type' )}', \$args );
|
892 |
+
|
893 |
+
}
|
894 |
+
add_action( 'init', '{$this->get_value( 'function_name' )}', 0 );
|
895 |
+
EOD;
|
896 |
+
}
|
897 |
+
|
898 |
+
}
|
includes/generator/class-wpcode-generator-query.php
ADDED
@@ -0,0 +1,745 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet using WP_Query
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Query class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Query extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'query';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'query',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* This snippet should not be auto-inserted by default.
|
31 |
+
*
|
32 |
+
* @var bool
|
33 |
+
*/
|
34 |
+
public $auto_insert = false;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Set the translatable strings.
|
38 |
+
*
|
39 |
+
* @return void
|
40 |
+
*/
|
41 |
+
protected function set_strings() {
|
42 |
+
$this->title = __( 'WP_Query', 'insert-headers-and-footers' );
|
43 |
+
$this->description = __( 'Generate a snippet using WP_Query to load posts from your website.', 'insert-headers-and-footers' );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get a list of available post types for autocomplete.
|
48 |
+
*
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
public function get_autocomplete_post_types() {
|
52 |
+
return array_keys( get_post_types() );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Get a list of available post statuses for autocomplete.
|
57 |
+
*
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
public function get_autocomplete_post_statuses() {
|
61 |
+
return array_keys( get_post_statuses() );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Load the generator tabs.
|
66 |
+
*
|
67 |
+
* @return void
|
68 |
+
*/
|
69 |
+
protected function load_tabs() {
|
70 |
+
$this->tabs = array(
|
71 |
+
'info' => array(
|
72 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
73 |
+
'columns' => array(
|
74 |
+
// Column 1.
|
75 |
+
array(
|
76 |
+
// Column 1 fields.
|
77 |
+
array(
|
78 |
+
'type' => 'description',
|
79 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
80 |
+
'content' => sprintf(
|
81 |
+
// Translators: Placeholders add links to the wordpress.org references.
|
82 |
+
__( 'This generator makes it easy for you to create custom queries using %1$sWP_Query%2$s which you can then extend to display posts or similar.', 'insert-headers-and-footers' ),
|
83 |
+
'<a href="https://developer.wordpress.org/reference/classes/wp_query/" target="_blank">',
|
84 |
+
'</a>'
|
85 |
+
),
|
86 |
+
),
|
87 |
+
),
|
88 |
+
// Column 2.
|
89 |
+
array(
|
90 |
+
// Column 2 fields.
|
91 |
+
array(
|
92 |
+
'type' => 'list',
|
93 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
94 |
+
'content' => array(
|
95 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
96 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
97 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
98 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
99 |
+
),
|
100 |
+
),
|
101 |
+
),
|
102 |
+
// Column 3.
|
103 |
+
array(
|
104 |
+
// Column 3 fields.
|
105 |
+
array(
|
106 |
+
'type' => 'description',
|
107 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
108 |
+
'content' => __( 'You can use this generator to get quickly started with a query for all the posts of an author and display them using the shortcode functionality of WPCode or automatically displaying the posts using the auto-insert option.', 'insert-headers-and-footers' ),
|
109 |
+
),
|
110 |
+
),
|
111 |
+
),
|
112 |
+
),
|
113 |
+
'general' => array(
|
114 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
115 |
+
'columns' => array(
|
116 |
+
// Column 1.
|
117 |
+
array(
|
118 |
+
array(
|
119 |
+
'type' => 'text',
|
120 |
+
'label' => __( 'Query variable name', 'insert-headers-and-footers' ),
|
121 |
+
'description' => __( 'If you want to use something more specific. The leading $ will be automatically added.', 'insert-headers-and-footers' ),
|
122 |
+
'id' => 'var_name',
|
123 |
+
'placeholder' => '$query',
|
124 |
+
'default' => 'query',
|
125 |
+
),
|
126 |
+
),
|
127 |
+
// Column 2.
|
128 |
+
array(
|
129 |
+
array(
|
130 |
+
'type' => 'select',
|
131 |
+
'label' => __( 'Include loop', 'insert-headers-and-footers' ),
|
132 |
+
'description' => __( 'Select yes if you want to include an empty loop of the results that you can fill in for output.', 'insert-headers-and-footers' ),
|
133 |
+
'id' => 'loop',
|
134 |
+
'default' => 'true',
|
135 |
+
'options' => array(
|
136 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
137 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
138 |
+
),
|
139 |
+
),
|
140 |
+
),
|
141 |
+
),
|
142 |
+
),
|
143 |
+
'post' => array(
|
144 |
+
'label' => __( 'IDs & Parents', 'insert-headers-and-footers' ),
|
145 |
+
'columns' => array(
|
146 |
+
// Column 1.
|
147 |
+
array(
|
148 |
+
array(
|
149 |
+
'type' => 'text',
|
150 |
+
'label' => __( 'Post ID(s)', 'insert-headers-and-footers' ),
|
151 |
+
'description' => __( 'Query a specific post ID or comma-separated list of ids. Cannot be combined with "Post ID not in" below.', 'insert-headers-and-footers' ),
|
152 |
+
'id' => 'post__in',
|
153 |
+
'default' => '',
|
154 |
+
'comma-separated' => true,
|
155 |
+
),
|
156 |
+
array(
|
157 |
+
'type' => 'text',
|
158 |
+
'label' => __( 'Post ID not in', 'insert-headers-and-footers' ),
|
159 |
+
'description' => __( 'Post ids to exclude from this query. Cannot be combined with "Post ID(s)" above.', 'insert-headers-and-footers' ),
|
160 |
+
'id' => 'post__not_in',
|
161 |
+
'default' => '',
|
162 |
+
'comma-separated' => true,
|
163 |
+
),
|
164 |
+
),
|
165 |
+
// Column 2.
|
166 |
+
array(
|
167 |
+
array(
|
168 |
+
'type' => 'text',
|
169 |
+
'label' => __( 'Post parent ID(s)', 'insert-headers-and-footers' ),
|
170 |
+
'description' => __( 'Comma-separated list of post parent ids if the post type is hierarchical (like pages).', 'insert-headers-and-footers' ),
|
171 |
+
'id' => 'post_parent__in',
|
172 |
+
'default' => '',
|
173 |
+
'comma-separated' => true,
|
174 |
+
),
|
175 |
+
array(
|
176 |
+
'type' => 'text',
|
177 |
+
'label' => __( 'Post parent not in', 'insert-headers-and-footers' ),
|
178 |
+
'description' => __( 'Comma-separated list of post parent ids to exclude.', 'insert-headers-and-footers' ),
|
179 |
+
'id' => 'post_parent__not_in',
|
180 |
+
'default' => '',
|
181 |
+
'comma-separated' => true,
|
182 |
+
),
|
183 |
+
),
|
184 |
+
// Column 3.
|
185 |
+
array(
|
186 |
+
array(
|
187 |
+
'type' => 'text',
|
188 |
+
'label' => __( 'Post slugs', 'insert-headers-and-footers' ),
|
189 |
+
'description' => __( 'Comma-separated list of post slugs to query by.', 'insert-headers-and-footers' ),
|
190 |
+
'id' => 'post_name__in',
|
191 |
+
'default' => '',
|
192 |
+
'comma-separated' => true,
|
193 |
+
),
|
194 |
+
),
|
195 |
+
),
|
196 |
+
),
|
197 |
+
'status' => array(
|
198 |
+
'label' => __( 'Type & Status', 'insert-headers-and-footers' ),
|
199 |
+
'columns' => array(
|
200 |
+
// Column 1.
|
201 |
+
array(
|
202 |
+
array(
|
203 |
+
'type' => 'text',
|
204 |
+
'label' => __( 'Post type', 'insert-headers-and-footers' ),
|
205 |
+
'description' => __( 'Post type to query by, start typing to get suggestions.', 'insert-headers-and-footers' ),
|
206 |
+
'id' => 'post_type',
|
207 |
+
'default' => 'post',
|
208 |
+
'autocomplete' => $this->get_autocomplete_post_types(),
|
209 |
+
),
|
210 |
+
),
|
211 |
+
// Column 2.
|
212 |
+
array(
|
213 |
+
array(
|
214 |
+
'type' => 'text',
|
215 |
+
'label' => __( 'Post status', 'insert-headers-and-footers' ),
|
216 |
+
'description' => __( 'Post status to query by.', 'insert-headers-and-footers' ),
|
217 |
+
'id' => 'post_status',
|
218 |
+
'default' => 'publish',
|
219 |
+
'autocomplete' => $this->get_autocomplete_post_statuses(),
|
220 |
+
),
|
221 |
+
),
|
222 |
+
),
|
223 |
+
),
|
224 |
+
'author' => array(
|
225 |
+
'label' => __( 'Author', 'insert-headers-and-footers' ),
|
226 |
+
'columns' => array(
|
227 |
+
// Column 1.
|
228 |
+
array(
|
229 |
+
array(
|
230 |
+
'type' => 'text',
|
231 |
+
'label' => __( 'Author ID(s)', 'insert-headers-and-footers' ),
|
232 |
+
'description' => __( 'Author ID or comma-separated list of ids.', 'insert-headers-and-footers' ),
|
233 |
+
'id' => 'author',
|
234 |
+
'default' => '',
|
235 |
+
),
|
236 |
+
array(
|
237 |
+
'type' => 'text',
|
238 |
+
'label' => __( 'Author not in', 'insert-headers-and-footers' ),
|
239 |
+
'description' => __( 'Comma-separated list of author ids to exclude from the query.', 'insert-headers-and-footers' ),
|
240 |
+
'id' => 'author__not_in',
|
241 |
+
'default' => '',
|
242 |
+
'comma-separated' => true,
|
243 |
+
),
|
244 |
+
),
|
245 |
+
// Column 2.
|
246 |
+
array(
|
247 |
+
|
248 |
+
array(
|
249 |
+
'type' => 'text',
|
250 |
+
'label' => __( 'Author name', 'insert-headers-and-footers' ),
|
251 |
+
'description' => __( 'Use the "user_nicename" parameter to query by author.', 'insert-headers-and-footers' ),
|
252 |
+
'id' => 'author_name',
|
253 |
+
'default' => '',
|
254 |
+
),
|
255 |
+
),
|
256 |
+
),
|
257 |
+
),
|
258 |
+
'search' => array(
|
259 |
+
'label' => __( 'Search', 'insert-headers-and-footers' ),
|
260 |
+
'columns' => array(
|
261 |
+
// Column 1.
|
262 |
+
array(
|
263 |
+
array(
|
264 |
+
'type' => 'text',
|
265 |
+
'label' => __( 'Search term', 'insert-headers-and-footers' ),
|
266 |
+
'description' => __( 'Search for posts by this search term.', 'insert-headers-and-footers' ),
|
267 |
+
'id' => 's',
|
268 |
+
'default' => '',
|
269 |
+
),
|
270 |
+
),
|
271 |
+
),
|
272 |
+
),
|
273 |
+
'order' => array(
|
274 |
+
'label' => __( 'Order', 'insert-headers-and-footers' ),
|
275 |
+
'columns' => array(
|
276 |
+
// Column 1.
|
277 |
+
array(
|
278 |
+
array(
|
279 |
+
'type' => 'select',
|
280 |
+
'label' => __( 'Results Order', 'insert-headers-and-footers' ),
|
281 |
+
'id' => 'order',
|
282 |
+
'default' => 'DESC',
|
283 |
+
'options' => array(
|
284 |
+
'DESC' => __( 'Descending order (3, 2, 1; c, b, a)', 'insert-headers-and-footers' ),
|
285 |
+
'ASC' => __( 'Ascending order (1, 2, 3; a, b, c)', 'insert-headers-and-footers' ),
|
286 |
+
),
|
287 |
+
),
|
288 |
+
),
|
289 |
+
// Column 2.
|
290 |
+
array(
|
291 |
+
array(
|
292 |
+
'type' => 'select',
|
293 |
+
'label' => __( 'Order by', 'insert-headers-and-footers' ),
|
294 |
+
'id' => 'orderby',
|
295 |
+
'default' => 'date',
|
296 |
+
'options' => array(
|
297 |
+
'none' => __( 'No order (none)', 'insert-headers-and-footers' ),
|
298 |
+
'ID' => __( 'ID', 'insert-headers-and-footers' ),
|
299 |
+
'author' => __( 'Author', 'insert-headers-and-footers' ),
|
300 |
+
'title' => __( 'Title', 'insert-headers-and-footers' ),
|
301 |
+
'name' => __( 'Slug (name)', 'insert-headers-and-footers' ),
|
302 |
+
'type' => __( 'Post type (type)', 'insert-headers-and-footers' ),
|
303 |
+
'date' => __( 'Date (default)', 'insert-headers-and-footers' ),
|
304 |
+
'modified' => __( 'Modified date', 'insert-headers-and-footers' ),
|
305 |
+
'parent' => __( 'Parent id', 'insert-headers-and-footers' ),
|
306 |
+
'rand' => __( 'Random', 'insert-headers-and-footers' ),
|
307 |
+
'comment_count' => __( 'Comment count', 'insert-headers-and-footers' ),
|
308 |
+
'relevance' => __( 'Relevance (for search)', 'insert-headers-and-footers' ),
|
309 |
+
'menu_order' => __( 'Page Order (menu_order)', 'insert-headers-and-footers' ),
|
310 |
+
//phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
|
311 |
+
'meta_value' => __( 'Meta value', 'insert-headers-and-footers' ),
|
312 |
+
'meta_value_num' => __( 'Numerical meta value (meta_value_num)', 'insert-headers-and-footers' ),
|
313 |
+
'post__in' => __( 'Order of ids in post__in', 'insert-headers-and-footers' ),
|
314 |
+
'post_name__in' => __( 'Order of names in post_name__in', 'insert-headers-and-footers' ),
|
315 |
+
'post_parent__in' => __( 'Order of ids in post_parent__in', 'insert-headers-and-footers' ),
|
316 |
+
),
|
317 |
+
),
|
318 |
+
array(
|
319 |
+
'type' => 'text',
|
320 |
+
'label' => __( 'Meta Key', 'insert-headers-and-footers' ),
|
321 |
+
'description' => __( 'Meta key to use if you choose to order by meta value.', 'insert-headers-and-footers' ),
|
322 |
+
'id' => 'meta_key',
|
323 |
+
'default' => '',
|
324 |
+
),
|
325 |
+
),
|
326 |
+
// Column 3.
|
327 |
+
array(),
|
328 |
+
),
|
329 |
+
),
|
330 |
+
'pagination' => array(
|
331 |
+
'label' => __( 'Pagination', 'insert-headers-and-footers' ),
|
332 |
+
'columns' => array(
|
333 |
+
// Column 1.
|
334 |
+
array(
|
335 |
+
array(
|
336 |
+
'type' => 'select',
|
337 |
+
'label' => __( 'Use Pagination', 'insert-headers-and-footers' ),
|
338 |
+
'id' => 'nopaging',
|
339 |
+
'default' => 'false',
|
340 |
+
'description' => __( 'Choose no to display all posts (not recommended).', 'insert-headers-and-footers' ),
|
341 |
+
'options' => array(
|
342 |
+
'true' => __( 'No', 'insert-headers-and-footers' ),
|
343 |
+
'false' => __( 'Yes (default)', 'insert-headers-and-footers' ),
|
344 |
+
),
|
345 |
+
),
|
346 |
+
array(
|
347 |
+
'type' => 'text',
|
348 |
+
'label' => __( 'Page number', 'insert-headers-and-footers' ),
|
349 |
+
'description' => __( 'Which page to show.', 'insert-headers-and-footers' ),
|
350 |
+
'id' => 'paged',
|
351 |
+
'default' => '',
|
352 |
+
),
|
353 |
+
),
|
354 |
+
// Column 2.
|
355 |
+
array(
|
356 |
+
array(
|
357 |
+
'type' => 'text',
|
358 |
+
'label' => __( 'Posts per page', 'insert-headers-and-footers' ),
|
359 |
+
'description' => __( 'How many posts should be displayed per page.', 'insert-headers-and-footers' ),
|
360 |
+
'id' => 'posts_per_page',
|
361 |
+
'default' => '',
|
362 |
+
),
|
363 |
+
array(
|
364 |
+
'type' => 'text',
|
365 |
+
'label' => __( 'Offset', 'insert-headers-and-footers' ),
|
366 |
+
'description' => __( 'Number of posts to skip.', 'insert-headers-and-footers' ),
|
367 |
+
'id' => 'offset',
|
368 |
+
'default' => '',
|
369 |
+
),
|
370 |
+
),
|
371 |
+
// Column 3.
|
372 |
+
array(
|
373 |
+
array(
|
374 |
+
'type' => 'select',
|
375 |
+
'label' => __( 'Ignore sticky posts', 'insert-headers-and-footers' ),
|
376 |
+
'id' => 'ignore_sticky_posts',
|
377 |
+
'default' => 'false',
|
378 |
+
'options' => array(
|
379 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
380 |
+
'false' => __( 'No (default)', 'insert-headers-and-footers' ),
|
381 |
+
),
|
382 |
+
),
|
383 |
+
),
|
384 |
+
),
|
385 |
+
),
|
386 |
+
'taxonomy' => array(
|
387 |
+
'label' => __( 'Taxonomy', 'insert-headers-and-footers' ),
|
388 |
+
'columns' => array(
|
389 |
+
// Column 1.
|
390 |
+
array(
|
391 |
+
array(
|
392 |
+
'type' => 'text',
|
393 |
+
'label' => __( 'Taxonomy', 'insert-headers-and-footers' ),
|
394 |
+
'description' => __( 'Taxonomy slug that you want to query by.', 'insert-headers-and-footers' ),
|
395 |
+
'id' => 'taxonomy',
|
396 |
+
'name' => 'taxonomy[]',
|
397 |
+
'default' => '',
|
398 |
+
'repeater' => 'tax_query',
|
399 |
+
),
|
400 |
+
array(
|
401 |
+
'type' => 'select',
|
402 |
+
'label' => __( 'Field', 'insert-headers-and-footers' ),
|
403 |
+
'description' => __( 'Select taxonomy term by.', 'insert-headers-and-footers' ),
|
404 |
+
'id' => 'field',
|
405 |
+
'name' => 'field[]',
|
406 |
+
'repeater' => 'tax_query',
|
407 |
+
'default' => 'term_id',
|
408 |
+
'options' => array(
|
409 |
+
'term_id' => __( 'Term ID (default', 'insert-headers-and-footers' ),
|
410 |
+
'name' => __( 'Term Name', 'insert-headers-and-footers' ),
|
411 |
+
'slug' => __( 'Term Slug', 'insert-headers-and-footers' ),
|
412 |
+
'term_taxonomy_id' => __( 'Term Taxonomy ID', 'insert-headers-and-footers' ),
|
413 |
+
),
|
414 |
+
),
|
415 |
+
array(
|
416 |
+
'type' => 'text',
|
417 |
+
'label' => __( 'Terms', 'insert-headers-and-footers' ),
|
418 |
+
'description' => __( 'Comma-separated list of terms to query by.', 'insert-headers-and-footers' ),
|
419 |
+
'id' => 'terms',
|
420 |
+
'name' => 'terms[]',
|
421 |
+
'default' => '',
|
422 |
+
'repeater' => 'tax_query',
|
423 |
+
'comma-separated' => true,
|
424 |
+
),
|
425 |
+
),
|
426 |
+
// Column 2.
|
427 |
+
array(
|
428 |
+
array(
|
429 |
+
'type' => 'select',
|
430 |
+
'label' => __( 'Include Children', 'insert-headers-and-footers' ),
|
431 |
+
'id' => 'include_children',
|
432 |
+
'name' => 'include_children[]',
|
433 |
+
'default' => 'true',
|
434 |
+
'description' => __( 'Whether or not to include children for hierarchical taxonomies.', 'insert-headers-and-footers' ),
|
435 |
+
'options' => array(
|
436 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
437 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
438 |
+
),
|
439 |
+
'repeater' => 'tax_query',
|
440 |
+
),
|
441 |
+
array(
|
442 |
+
'type' => 'select',
|
443 |
+
'label' => __( 'Operator', 'insert-headers-and-footers' ),
|
444 |
+
'id' => 'operator',
|
445 |
+
'name' => 'operator[]',
|
446 |
+
'default' => 'IN',
|
447 |
+
'description' => __( 'Operator to test relation by.', 'insert-headers-and-footers' ),
|
448 |
+
'options' => array(
|
449 |
+
'IN' => 'IN',
|
450 |
+
'NOT IN' => 'NOT IN',
|
451 |
+
'AND' => 'AND',
|
452 |
+
'EXISTS' => 'EXISTS',
|
453 |
+
'NOT EXISTS' => 'NOT EXISTS',
|
454 |
+
),
|
455 |
+
'repeater' => 'tax_query',
|
456 |
+
),
|
457 |
+
array(
|
458 |
+
'type' => 'spacer',
|
459 |
+
),
|
460 |
+
),
|
461 |
+
// Column 3.
|
462 |
+
array(
|
463 |
+
array(
|
464 |
+
'type' => 'description',
|
465 |
+
'label' => __( 'Add another taxonomy', 'insert-headers-and-footers' ),
|
466 |
+
'content' => __( 'Use the "Add Taxonomy" button below to query multiple taxonomies.', 'insert-headers-and-footers' ),
|
467 |
+
),
|
468 |
+
array(
|
469 |
+
'type' => 'repeater_button',
|
470 |
+
'button_text' => __( 'Add Taxonomy', 'insert-headers-and-footers' ),
|
471 |
+
'id' => 'tax_query', // Repeater to repeat when clicked.
|
472 |
+
),
|
473 |
+
array(
|
474 |
+
'type' => 'select',
|
475 |
+
'label' => __( 'Tax Relation', 'insert-headers-and-footers' ),
|
476 |
+
'id' => 'relation',
|
477 |
+
'default' => 'AND',
|
478 |
+
'options' => array(
|
479 |
+
'AND' => __( 'AND (default)', 'insert-headers-and-footers' ),
|
480 |
+
'OR' => __( 'OR', 'insert-headers-and-footers' ),
|
481 |
+
),
|
482 |
+
),
|
483 |
+
),
|
484 |
+
),
|
485 |
+
),
|
486 |
+
'meta' => array(
|
487 |
+
'label' => __( 'Custom Fields', 'insert-headers-and-footers' ),
|
488 |
+
'columns' => array(
|
489 |
+
// Column 1.
|
490 |
+
array(
|
491 |
+
array(
|
492 |
+
'type' => 'text',
|
493 |
+
'label' => __( 'Meta Key', 'insert-headers-and-footers' ),
|
494 |
+
'description' => __( 'The key of the custom field.', 'insert-headers-and-footers' ),
|
495 |
+
'id' => 'key',
|
496 |
+
'name' => 'key[]',
|
497 |
+
'default' => '',
|
498 |
+
'repeater' => 'meta_query',
|
499 |
+
),
|
500 |
+
array(
|
501 |
+
'type' => 'text',
|
502 |
+
'label' => __( 'Meta Value', 'insert-headers-and-footers' ),
|
503 |
+
'description' => __( 'Value to query the meta by.', 'insert-headers-and-footers' ),
|
504 |
+
'id' => 'value',
|
505 |
+
'name' => 'value[]',
|
506 |
+
'default' => '',
|
507 |
+
'repeater' => 'meta_query',
|
508 |
+
),
|
509 |
+
),
|
510 |
+
// Column 2.
|
511 |
+
array(
|
512 |
+
array(
|
513 |
+
'type' => 'select',
|
514 |
+
'label' => __( 'Compare', 'insert-headers-and-footers' ),
|
515 |
+
'description' => __( 'How to compare the value for querying by meta.', 'insert-headers-and-footers' ),
|
516 |
+
'id' => 'compare',
|
517 |
+
'name' => 'compare[]',
|
518 |
+
'repeater' => 'meta_query',
|
519 |
+
'default' => '=',
|
520 |
+
'options' => array(
|
521 |
+
'=' => '=',
|
522 |
+
'!=' => '!=',
|
523 |
+
'>' => '>',
|
524 |
+
'>=' => '>=',
|
525 |
+
'<' => '<',
|
526 |
+
'<=' => '<=',
|
527 |
+
'LIKE' => 'LIKE',
|
528 |
+
'NOT LIKE' => 'NOT LIKE',
|
529 |
+
'IN' => 'IN',
|
530 |
+
'NOT IN' => 'NOT IN',
|
531 |
+
'BETWEEN' => 'BETWEEN',
|
532 |
+
'NOT BETWEEN' => 'NOT BETWEEN',
|
533 |
+
'EXISTS' => 'EXISTS',
|
534 |
+
'NOT EXISTS' => 'NOT EXISTS',
|
535 |
+
'REGEXP' => 'REGEXP',
|
536 |
+
'NOT REGEXP' => 'NOT REGEXP',
|
537 |
+
'RLIKE' => 'RLIKE',
|
538 |
+
),
|
539 |
+
),
|
540 |
+
array(
|
541 |
+
'type' => 'select',
|
542 |
+
'label' => __( 'Type', 'insert-headers-and-footers' ),
|
543 |
+
'description' => __( 'Type of custom field.', 'insert-headers-and-footers' ),
|
544 |
+
'id' => 'meta_type',
|
545 |
+
'name' => 'meta_type[]',
|
546 |
+
'repeater' => 'meta_query',
|
547 |
+
'default' => 'CHAR',
|
548 |
+
'options' => array(
|
549 |
+
'NUMERIC' => 'NUMERIC',
|
550 |
+
'BINARY' => 'BINARY',
|
551 |
+
'CHAR' => 'CHAR',
|
552 |
+
'DATE' => 'DATE',
|
553 |
+
'DATETIME' => 'DATETIME',
|
554 |
+
'DECIMAL' => 'DECIMAL',
|
555 |
+
'SIGNED' => 'SIGNED',
|
556 |
+
'TIME' => 'TIME',
|
557 |
+
'UNSIGNED' => 'UNSIGNED',
|
558 |
+
),
|
559 |
+
),
|
560 |
+
),
|
561 |
+
// Column 3.
|
562 |
+
array(
|
563 |
+
array(
|
564 |
+
'type' => 'description',
|
565 |
+
'label' => __( 'Add another meta query', 'insert-headers-and-footers' ),
|
566 |
+
'content' => __( 'Use the "Add Meta" button below to use multiple meta queries.', 'insert-headers-and-footers' ),
|
567 |
+
),
|
568 |
+
array(
|
569 |
+
'type' => 'repeater_button',
|
570 |
+
'button_text' => __( 'Add Meta', 'insert-headers-and-footers' ),
|
571 |
+
'id' => 'meta_query', // Repeater to repeat when clicked.
|
572 |
+
),
|
573 |
+
array(
|
574 |
+
'type' => 'select',
|
575 |
+
'label' => __( 'Relation', 'insert-headers-and-footers' ),
|
576 |
+
'id' => 'meta_relation',
|
577 |
+
'default' => 'AND',
|
578 |
+
'options' => array(
|
579 |
+
'AND' => __( 'AND (default)', 'insert-headers-and-footers' ),
|
580 |
+
'OR' => __( 'OR', 'insert-headers-and-footers' ),
|
581 |
+
),
|
582 |
+
),
|
583 |
+
),
|
584 |
+
),
|
585 |
+
),
|
586 |
+
);
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Get the snippet code with dynamic values applied.
|
591 |
+
*
|
592 |
+
* @return string
|
593 |
+
*/
|
594 |
+
public function get_snippet_code() {
|
595 |
+
|
596 |
+
$query_variable = '$' . str_replace( '$', '', $this->get_value( 'var_name' ) );
|
597 |
+
$loop_code = '';
|
598 |
+
if ( 'true' === $this->get_value( 'loop' ) ) {
|
599 |
+
$loop_code = "
|
600 |
+
if ( {$query_variable}->have_posts() ) {
|
601 |
+
while ( {$query_variable}->have_posts() ) {
|
602 |
+
{$query_variable}->the_post();
|
603 |
+
// Add you post code here.
|
604 |
+
}
|
605 |
+
} else {
|
606 |
+
// Display a no posts found message here.
|
607 |
+
}
|
608 |
+
|
609 |
+
// Reset post data.
|
610 |
+
wp_reset_postdata();
|
611 |
+
";
|
612 |
+
}
|
613 |
+
|
614 |
+
$optional_values = array(
|
615 |
+
'post__in' => false,
|
616 |
+
'post__not_in' => false,
|
617 |
+
'post_parent__in' => false,
|
618 |
+
'post_parent__not_in' => false,
|
619 |
+
'post_name__in' => true,
|
620 |
+
'post_type' => true,
|
621 |
+
'post_status' => true,
|
622 |
+
'author' => true,
|
623 |
+
'author__not_in' => false,
|
624 |
+
'author_name' => true,
|
625 |
+
's' => true,
|
626 |
+
'order' => true,
|
627 |
+
'orderby' => true,
|
628 |
+
//phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
|
629 |
+
'meta_key' => true,
|
630 |
+
'nopaging' => false,
|
631 |
+
'paged' => false,
|
632 |
+
'posts_per_page' => false,
|
633 |
+
'offset' => false,
|
634 |
+
'ignore_sticky_posts' => false,
|
635 |
+
);
|
636 |
+
|
637 |
+
$args = '';
|
638 |
+
foreach ( $optional_values as $optional_value => $quotes ) {
|
639 |
+
$args .= $this->get_optional_value( $optional_value, $quotes );
|
640 |
+
}
|
641 |
+
|
642 |
+
$tax_query = '';
|
643 |
+
$taxonomies = $this->get_value( 'taxonomy' );
|
644 |
+
$fields = $this->get_value( 'field' );
|
645 |
+
$terms = $this->get_value( 'terms' );
|
646 |
+
$include_children = $this->get_value( 'include_children' );
|
647 |
+
$operator = $this->get_value( 'operator' );
|
648 |
+
|
649 |
+
if ( ! empty( $taxonomies ) ) {
|
650 |
+
$tax_query_arrays = array();
|
651 |
+
foreach ( $taxonomies as $key => $taxonomy ) {
|
652 |
+
if ( empty( $taxonomy ) ) {
|
653 |
+
continue;
|
654 |
+
}
|
655 |
+
$params = array(
|
656 |
+
$this->get_optional_value_code( $fields[ $key ], $this->get_default_value( 'field' ), 'field', true ),
|
657 |
+
$this->get_optional_value_code( $terms[ $key ], $this->get_default_value( 'terms' ), 'terms', true, true ),
|
658 |
+
$this->get_optional_value_code( $include_children[ $key ], $this->get_default_value( 'include_children' ), 'include_children' ),
|
659 |
+
$this->get_optional_value_code( $operator[ $key ], $this->get_default_value( 'operator' ), 'operator', true ),
|
660 |
+
);
|
661 |
+
$params = array_filter( $params );
|
662 |
+
$params = str_replace( "\n", '', $params );
|
663 |
+
$params = implode( "\n\t\t", $params );
|
664 |
+
if ( ! empty( $params ) ) {
|
665 |
+
$params = "\n\t\t" . $params;
|
666 |
+
}
|
667 |
+
$tax_query_arrays[] = "\n\t\t\tarray(
|
668 |
+
'taxonomy' => '$taxonomy',$params
|
669 |
+
),";
|
670 |
+
}
|
671 |
+
if ( ! empty( $tax_query_arrays ) ) {
|
672 |
+
$tax_query = "\t\t'tax_query' => array(";
|
673 |
+
if ( count( $tax_query_arrays ) > 1 ) {
|
674 |
+
$optional_relation = $this->get_optional_value( 'relation', true );
|
675 |
+
if ( ! empty( $optional_relation ) ) {
|
676 |
+
$tax_query .= "\n\t" . str_replace( "\n", '', $optional_relation );
|
677 |
+
}
|
678 |
+
}
|
679 |
+
|
680 |
+
$tax_query .= implode( '', $tax_query_arrays );
|
681 |
+
$tax_query .= '
|
682 |
+
),';
|
683 |
+
}
|
684 |
+
}
|
685 |
+
|
686 |
+
$meta_query = '';
|
687 |
+
$meta_keys = $this->get_value( 'key' );
|
688 |
+
$meta_values = $this->get_value( 'value' );
|
689 |
+
$meta_compares = $this->get_value( 'compare' );
|
690 |
+
$meta_types = $this->get_value( 'meta_type' );
|
691 |
+
|
692 |
+
if ( ! empty( $meta_keys ) ) {
|
693 |
+
$meta_query_arrays = array();
|
694 |
+
foreach ( $meta_keys as $key => $meta_key ) {
|
695 |
+
if ( empty( $meta_key ) ) {
|
696 |
+
continue;
|
697 |
+
}
|
698 |
+
$params = array(
|
699 |
+
$this->get_optional_value_code( $meta_values[ $key ], $this->get_default_value( 'value' ), 'value', true ),
|
700 |
+
$this->get_optional_value_code( $meta_compares[ $key ], $this->get_default_value( 'compare' ), 'compare', true ),
|
701 |
+
$this->get_optional_value_code( $meta_types[ $key ], $this->get_default_value( 'meta_type' ), 'type', true ),
|
702 |
+
);
|
703 |
+
$params = array_filter( $params );
|
704 |
+
$params = str_replace( "\n", '', $params );
|
705 |
+
$params = implode( "\n\t\t", $params );
|
706 |
+
if ( ! empty( $params ) ) {
|
707 |
+
$params = "\n\t\t" . $params;
|
708 |
+
}
|
709 |
+
$meta_query_arrays[] = "\n\t\t\tarray(
|
710 |
+
'key' => '$meta_key',$params
|
711 |
+
),";
|
712 |
+
}
|
713 |
+
|
714 |
+
if ( ! empty( $meta_query_arrays ) ) {
|
715 |
+
$meta_query = "\n\t\t'meta_query' => array(";
|
716 |
+
if ( count( $meta_query_arrays ) > 1 ) {
|
717 |
+
$optional_relation = $this->get_optional_value( 'meta_relation', true, 'relation' );
|
718 |
+
if ( ! empty( $optional_relation ) ) {
|
719 |
+
$meta_query .= "\n\t" . str_replace( "\n", '', $optional_relation );
|
720 |
+
}
|
721 |
+
}
|
722 |
+
|
723 |
+
$meta_query .= implode( '', $meta_query_arrays );
|
724 |
+
$meta_query .= '
|
725 |
+
),';
|
726 |
+
}
|
727 |
+
}
|
728 |
+
|
729 |
+
$args = "\n" . $args;
|
730 |
+
|
731 |
+
return <<<EOD
|
732 |
+
// Query Posts.
|
733 |
+
|
734 |
+
// Query arguments.
|
735 |
+
\$query_args = array($args$tax_query$meta_query
|
736 |
+
);
|
737 |
+
|
738 |
+
// Run the query.
|
739 |
+
$query_variable = new WP_Query( \$query_args );
|
740 |
+
$loop_code
|
741 |
+
|
742 |
+
EOD;
|
743 |
+
}
|
744 |
+
|
745 |
+
}
|
includes/generator/class-wpcode-generator-script.php
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to enqueue scripts.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Script class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Script extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'enqueue_script';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'core',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Register Scripts', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Generate a snippet to load JavaScript scripts using wp_register_script.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Using this generator you can create a WordPress function to register and enqueue scripts.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => sprintf(
|
79 |
+
// Translators: the placeholders add a link to getboostrap.com.
|
80 |
+
__( 'You can use this to load external scripts or even scripts from a theme or plugin. For example, you could load %1$sbootstrap%2$s from a cdn.', 'insert-headers-and-footers' ),
|
81 |
+
'<a href="https://getbootstrap.com/" target="_blank">',
|
82 |
+
'</a>'
|
83 |
+
),
|
84 |
+
),
|
85 |
+
),
|
86 |
+
),
|
87 |
+
),
|
88 |
+
'general' => array(
|
89 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
90 |
+
'columns' => array(
|
91 |
+
// Column 1.
|
92 |
+
array(
|
93 |
+
array(
|
94 |
+
'type' => 'text',
|
95 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
96 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
97 |
+
'id' => 'function_name',
|
98 |
+
'placeholder' => 'add_custom_script',
|
99 |
+
'default' => 'add_custom_script' . time(),
|
100 |
+
// This makes it unique for people who don't want to customize.
|
101 |
+
),
|
102 |
+
),
|
103 |
+
// Column 2.
|
104 |
+
array(
|
105 |
+
array(
|
106 |
+
'type' => 'select',
|
107 |
+
'label' => __( 'Action (hook)', 'insert-headers-and-footers' ),
|
108 |
+
'description' => sprintf(
|
109 |
+
// Translators: placeholders add links to documentation on wordpress.org.
|
110 |
+
__( 'Hook used to add the scripts: %1$sfrontend%2$s, %3$sadmin%4$s, %5$slogin%6$s or %7$sembed%8$s.', 'insert-headers-and-footers' ),
|
111 |
+
'<a href="https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/" target="_blank">',
|
112 |
+
'</a>',
|
113 |
+
'<a href="https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/" target="_blank">',
|
114 |
+
'</a>',
|
115 |
+
'<a href="https://developer.wordpress.org/reference/hooks/login_enqueue_scripts/" target="_blank">',
|
116 |
+
'</a>',
|
117 |
+
'<a href="https://developer.wordpress.org/reference/hooks/enqueue_embed_scripts/" target="_blank">',
|
118 |
+
'</a>'
|
119 |
+
),
|
120 |
+
'id' => 'hook',
|
121 |
+
'default' => 'wp_enqueue_scripts',
|
122 |
+
'options' => array(
|
123 |
+
// Translators: placeholder adds the hook name.
|
124 |
+
'wp_enqueue_scripts' => sprintf( __( 'Frontend (%s)', 'insert-headers-and-footers' ), 'wp_enqueue_scripts' ),
|
125 |
+
// Translators: placeholder adds the hook name.
|
126 |
+
'admin_enqueue_scripts' => sprintf( __( 'Admin (%s)', 'insert-headers-and-footers' ), 'admin_enqueue_scripts' ),
|
127 |
+
// Translators: placeholder adds the hook name.
|
128 |
+
'login_enqueue_scripts' => sprintf( __( 'Login (%s)', 'insert-headers-and-footers' ), 'login_enqueue_scripts' ),
|
129 |
+
// Translators: placeholder adds the hook name.
|
130 |
+
'enqueue_embed_scripts' => sprintf( __( 'Embed (%s)', 'insert-headers-and-footers' ), 'enqueue_embed_scripts' ),
|
131 |
+
),
|
132 |
+
),
|
133 |
+
),
|
134 |
+
),
|
135 |
+
),
|
136 |
+
'scripts' => array(
|
137 |
+
'label' => __( 'Scripts', 'insert-headers-and-footers' ),
|
138 |
+
'columns' => array(
|
139 |
+
// Column 1.
|
140 |
+
array(
|
141 |
+
array(
|
142 |
+
'type' => 'text',
|
143 |
+
'label' => __( 'Script name', 'insert-headers-and-footers' ),
|
144 |
+
'description' => __( 'This will be used as an identifier in the code, should be lowercase with no spaces.', 'insert-headers-and-footers' ),
|
145 |
+
'id' => 'script_name',
|
146 |
+
'name' => 'script_name[]',
|
147 |
+
'default' => '',
|
148 |
+
'placeholder' => '',
|
149 |
+
'repeater' => 'script',
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'type' => 'text',
|
153 |
+
'label' => __( 'Script URL', 'insert-headers-and-footers' ),
|
154 |
+
'description' => __( 'The full URL for the script e.g. https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js.', 'insert-headers-and-footers' ),
|
155 |
+
'id' => 'script_url',
|
156 |
+
'name' => 'script_url[]',
|
157 |
+
'default' => '',
|
158 |
+
'placeholder' => '',
|
159 |
+
'repeater' => 'script',
|
160 |
+
),
|
161 |
+
array(
|
162 |
+
'type' => 'text',
|
163 |
+
'label' => __( 'Dependencies', 'insert-headers-and-footers' ),
|
164 |
+
'description' => __( 'Comma-separated list of scripts required for this script to load, e.g. jquery', 'insert-headers-and-footers' ),
|
165 |
+
'id' => 'script_dependencies',
|
166 |
+
'name' => 'script_dependencies[]',
|
167 |
+
'default' => '',
|
168 |
+
'placeholder' => '',
|
169 |
+
'repeater' => 'script',
|
170 |
+
),
|
171 |
+
array(
|
172 |
+
'type' => 'text',
|
173 |
+
'label' => __( 'Script Version', 'insert-headers-and-footers' ),
|
174 |
+
'description' => __( 'The script version.', 'insert-headers-and-footers' ),
|
175 |
+
'id' => 'script_version',
|
176 |
+
'name' => 'script_version[]',
|
177 |
+
'default' => '1.0.0',
|
178 |
+
'placeholder' => '',
|
179 |
+
'repeater' => 'script',
|
180 |
+
),
|
181 |
+
),
|
182 |
+
// Column 2.
|
183 |
+
array(
|
184 |
+
array(
|
185 |
+
'type' => 'select',
|
186 |
+
'label' => __( 'Header or Footer?', 'insert-headers-and-footers' ),
|
187 |
+
'description' => __( 'Load the script in the page head or in the footer.', 'insert-headers-and-footers' ),
|
188 |
+
'id' => 'script_location',
|
189 |
+
'name' => 'script_location[]',
|
190 |
+
'default' => 'true',
|
191 |
+
'options' => array(
|
192 |
+
'true' => __( 'Footer', 'insert-headers-and-footers' ),
|
193 |
+
'false' => __( 'Header', 'insert-headers-and-footers' ),
|
194 |
+
),
|
195 |
+
'repeater' => 'script',
|
196 |
+
),
|
197 |
+
array(
|
198 |
+
'type' => 'select',
|
199 |
+
'label' => __( 'Deregister script?', 'insert-headers-and-footers' ),
|
200 |
+
'description' => sprintf(
|
201 |
+
// Translators: Placeholders for wp.org docs link.
|
202 |
+
__( 'Should the script be %1$sderegistered%2$s first? (for example, if you are replacing an existing script).', 'insert-headers-and-footers' ),
|
203 |
+
'<a href="https://developer.wordpress.org/reference/functions/wp_deregister_script/" target="_blank">',
|
204 |
+
'</a>'
|
205 |
+
),
|
206 |
+
'id' => 'script_deregister',
|
207 |
+
'name' => 'script_deregister[]',
|
208 |
+
'default' => 'false',
|
209 |
+
'options' => array(
|
210 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
211 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
212 |
+
),
|
213 |
+
'repeater' => 'script',
|
214 |
+
),
|
215 |
+
array(
|
216 |
+
'type' => 'select',
|
217 |
+
'label' => __( 'Enqueue script?', 'insert-headers-and-footers' ),
|
218 |
+
'description' => sprintf(
|
219 |
+
// Translators: Placeholders for wp.org docs link.
|
220 |
+
__( 'Should the script be %1$senqueued%2$s or just registered? (select "No" only if you intend enqueueing it later.', 'insert-headers-and-footers' ),
|
221 |
+
'<a href="https://developer.wordpress.org/reference/functions/wp_enqueue_script/" target="_blank">',
|
222 |
+
'</a>'
|
223 |
+
),
|
224 |
+
'id' => 'script_enqueue',
|
225 |
+
'name' => 'script_enqueue[]',
|
226 |
+
'default' => 'true',
|
227 |
+
'options' => array(
|
228 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
229 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
230 |
+
),
|
231 |
+
'repeater' => 'script',
|
232 |
+
),
|
233 |
+
array(
|
234 |
+
'type' => 'spacer',
|
235 |
+
),
|
236 |
+
),
|
237 |
+
// Column 3.
|
238 |
+
array(
|
239 |
+
array(
|
240 |
+
'type' => 'description',
|
241 |
+
'label' => __( 'Add more scripts', 'insert-headers-and-footers' ),
|
242 |
+
'content' => __( 'Use the "Add script" button below to add multiple scripts in this snippet.', 'insert-headers-and-footers' ),
|
243 |
+
),
|
244 |
+
array(
|
245 |
+
'type' => 'repeater_button',
|
246 |
+
'button_text' => __( 'Add script', 'insert-headers-and-footers' ),
|
247 |
+
'id' => 'script', // Repeater to repeat when clicked.
|
248 |
+
),
|
249 |
+
),
|
250 |
+
),
|
251 |
+
),
|
252 |
+
);
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Get the snippet code with dynamic values applied.
|
257 |
+
*
|
258 |
+
* @return string
|
259 |
+
*/
|
260 |
+
public function get_snippet_code() {
|
261 |
+
|
262 |
+
$scripts = $this->get_value( 'script_name' );
|
263 |
+
$scripts_urls = $this->get_value( 'script_url' );
|
264 |
+
$scripts_deps = $this->get_value( 'script_dependencies' );
|
265 |
+
$scripts_versions = $this->get_value( 'script_version' );
|
266 |
+
$scripts_locations = $this->get_value( 'script_location' );
|
267 |
+
$scripts_deregister = $this->get_value( 'script_deregister' );
|
268 |
+
$scripts_enqueue = $this->get_value( 'script_enqueue' );
|
269 |
+
$code = '';
|
270 |
+
|
271 |
+
if ( ! empty( $scripts ) ) {
|
272 |
+
foreach ( $scripts as $key => $script_name ) {
|
273 |
+
if ( empty( $script_name ) ) {
|
274 |
+
continue;
|
275 |
+
}
|
276 |
+
$script_name = sanitize_title( $script_name );
|
277 |
+
$dependencies = explode( ',', $scripts_deps[ $key ] );
|
278 |
+
$deregister = 'true' === $scripts_deregister[ $key ] ? "wp_deregister_script( '$script_name' );" : '';
|
279 |
+
$enqueue = 'true' === $scripts_enqueue[ $key ] ? "wp_enqueue_script( '$script_name' );" : '';
|
280 |
+
|
281 |
+
$code .= "
|
282 |
+
$deregister
|
283 |
+
wp_register_script( '$script_name', '$scripts_urls[$key]', {$this->array_to_code_string($dependencies)}, '$scripts_versions[$key]', $scripts_locations[$key] );
|
284 |
+
$enqueue
|
285 |
+
";
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
return <<<EOD
|
290 |
+
// Add custom scripts
|
291 |
+
function {$this->get_value( 'function_name' )}() {
|
292 |
+
$code
|
293 |
+
}
|
294 |
+
add_action( '{$this->get_value( 'hook' )}', '{$this->get_value( 'function_name' )}' );
|
295 |
+
EOD;
|
296 |
+
}
|
297 |
+
|
298 |
+
}
|
includes/generator/class-wpcode-generator-sidebar.php
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet for a sidebar.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Sidebar class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Sidebar extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'sidebar';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'design',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Sidebar', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Generate a snippet to register a sidebar for your widgets.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => sprintf(
|
56 |
+
// Translators: Placeholders add links to the wordpress.org references.
|
57 |
+
__( 'This generator makes it easy to add sidebars to your website using the "register_sidebar" function.', 'insert-headers-and-footers' ),
|
58 |
+
'<a href="https://developer.wordpress.org/reference/functions/register_sidebar/" target="_blank">',
|
59 |
+
'</a>'
|
60 |
+
),
|
61 |
+
),
|
62 |
+
),
|
63 |
+
// Column 2.
|
64 |
+
array(
|
65 |
+
// Column 2 fields.
|
66 |
+
array(
|
67 |
+
'type' => 'list',
|
68 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
69 |
+
'content' => array(
|
70 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
71 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
72 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
73 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
74 |
+
),
|
75 |
+
),
|
76 |
+
),
|
77 |
+
// Column 3.
|
78 |
+
array(
|
79 |
+
// Column 3 fields.
|
80 |
+
array(
|
81 |
+
'type' => 'description',
|
82 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
83 |
+
'content' => __( 'You can add multiple widget areas for your footer or post-type specific sidebars.', 'insert-headers-and-footers' ),
|
84 |
+
),
|
85 |
+
),
|
86 |
+
),
|
87 |
+
),
|
88 |
+
'general' => array(
|
89 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
90 |
+
'columns' => array(
|
91 |
+
// Column 1.
|
92 |
+
array(
|
93 |
+
array(
|
94 |
+
'type' => 'text',
|
95 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
96 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
97 |
+
'id' => 'function_name',
|
98 |
+
'placeholder' => 'register_custom_sidebars',
|
99 |
+
'default' => 'register_custom_sidebars' . time(),
|
100 |
+
),
|
101 |
+
),
|
102 |
+
// Column 2.
|
103 |
+
array(
|
104 |
+
array(
|
105 |
+
'type' => 'text',
|
106 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
107 |
+
'description' => __( 'Optional text domain for translations.', 'insert-headers-and-footers' ),
|
108 |
+
'id' => 'text_domain',
|
109 |
+
'placeholder' => 'text_domain',
|
110 |
+
'default' => 'text_domain',
|
111 |
+
),
|
112 |
+
),
|
113 |
+
),
|
114 |
+
),
|
115 |
+
'schedule' => array(
|
116 |
+
'label' => __( 'Sidebars', 'insert-headers-and-footers' ),
|
117 |
+
'columns' => array(
|
118 |
+
// Column 1.
|
119 |
+
array(
|
120 |
+
array(
|
121 |
+
'type' => 'text',
|
122 |
+
'label' => __( 'Sidebar Id', 'insert-headers-and-footers' ),
|
123 |
+
'description' => __( 'This is the sidebar unique id, used in the code, lowercase with no spaces.', 'insert-headers-and-footers' ),
|
124 |
+
'id' => 'sidebar_id',
|
125 |
+
'name' => 'sidebar_id[]',
|
126 |
+
'repeater' => 'sidebars',
|
127 |
+
),
|
128 |
+
array(
|
129 |
+
'type' => 'text',
|
130 |
+
'label' => __( 'Name', 'insert-headers-and-footers' ),
|
131 |
+
'description' => __( 'Add a descriptive label for this sidebar to be used in the admin.', 'insert-headers-and-footers' ),
|
132 |
+
'id' => 'sidebar_name',
|
133 |
+
'name' => 'sidebar_name[]',
|
134 |
+
'repeater' => 'sidebars',
|
135 |
+
),
|
136 |
+
array(
|
137 |
+
'type' => 'text',
|
138 |
+
'label' => __( 'Description', 'insert-headers-and-footers' ),
|
139 |
+
'description' => __( 'A short description for the the admin area..', 'insert-headers-and-footers' ),
|
140 |
+
'id' => 'sidebar_description',
|
141 |
+
'name' => 'sidebar_description[]',
|
142 |
+
'repeater' => 'sidebars',
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'type' => 'text',
|
146 |
+
'label' => __( 'CSS Class', 'insert-headers-and-footers' ),
|
147 |
+
'description' => __( 'Use an unique CSS class name for better control over this sidebar\'s styles in the admin.', 'insert-headers-and-footers' ),
|
148 |
+
'id' => 'sidebar_css_class',
|
149 |
+
'name' => 'sidebar_css_class[]',
|
150 |
+
'repeater' => 'sidebars',
|
151 |
+
),
|
152 |
+
),
|
153 |
+
// Column 2.
|
154 |
+
array(
|
155 |
+
array(
|
156 |
+
'type' => 'html',
|
157 |
+
'label' => __( 'Before Title', 'insert-headers-and-footers' ),
|
158 |
+
'description' => __( 'HTML code to add before each widget title.', 'insert-headers-and-footers' ),
|
159 |
+
'id' => 'before_title',
|
160 |
+
'name' => 'before_title[]',
|
161 |
+
'repeater' => 'sidebars',
|
162 |
+
'default' => '<h2 class="widgettitle">',
|
163 |
+
),
|
164 |
+
array(
|
165 |
+
'type' => 'html',
|
166 |
+
'label' => __( 'After Title', 'insert-headers-and-footers' ),
|
167 |
+
'description' => __( 'HTML code to add after each widget title.', 'insert-headers-and-footers' ),
|
168 |
+
'id' => 'after_title',
|
169 |
+
'name' => 'after_title[]',
|
170 |
+
'repeater' => 'sidebars',
|
171 |
+
'default' => '</h2>',
|
172 |
+
),
|
173 |
+
array(
|
174 |
+
'type' => 'html',
|
175 |
+
'label' => __( 'Before Widget', 'insert-headers-and-footers' ),
|
176 |
+
'description' => __( 'HTML code to add before each widget.', 'insert-headers-and-footers' ),
|
177 |
+
'id' => 'before_widget',
|
178 |
+
'name' => 'before_widget[]',
|
179 |
+
'repeater' => 'sidebars',
|
180 |
+
'default' => '<li id="%1$s" class="widget %2$s">',
|
181 |
+
),
|
182 |
+
array(
|
183 |
+
'type' => 'html',
|
184 |
+
'label' => __( 'After Widget', 'insert-headers-and-footers' ),
|
185 |
+
'description' => __( 'HTML code to add after each widget.', 'insert-headers-and-footers' ),
|
186 |
+
'id' => 'after_widget',
|
187 |
+
'name' => 'after_widget[]',
|
188 |
+
'repeater' => 'sidebars',
|
189 |
+
'default' => '</li>',
|
190 |
+
),
|
191 |
+
array(
|
192 |
+
'type' => 'spacer',
|
193 |
+
),
|
194 |
+
),
|
195 |
+
// Column 3.
|
196 |
+
array(
|
197 |
+
array(
|
198 |
+
'type' => 'description',
|
199 |
+
'label' => __( 'Add another sidebar', 'insert-headers-and-footers' ),
|
200 |
+
'content' => __( 'Use the "Add Sidebar" button below to add as many sidebars as you need.', 'insert-headers-and-footers' ),
|
201 |
+
),
|
202 |
+
array(
|
203 |
+
'type' => 'repeater_button',
|
204 |
+
'button_text' => __( 'Add Sidebar', 'insert-headers-and-footers' ),
|
205 |
+
'id' => 'sidebars', // Repeater to repeat when clicked.
|
206 |
+
),
|
207 |
+
),
|
208 |
+
),
|
209 |
+
),
|
210 |
+
);
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Get the snippet code with dynamic values applied.
|
215 |
+
*
|
216 |
+
* @return string
|
217 |
+
*/
|
218 |
+
public function get_snippet_code() {
|
219 |
+
|
220 |
+
$sidebar_id = $this->get_value( 'sidebar_id' );
|
221 |
+
$sidebar_code = '';
|
222 |
+
|
223 |
+
$values = array(
|
224 |
+
'name' => 'sidebar_name',
|
225 |
+
'description' => 'sidebar_description',
|
226 |
+
'class' => 'sidebar_css_class',
|
227 |
+
'before_title' => 'before_title',
|
228 |
+
'after_title' => 'after_title',
|
229 |
+
'before_widget' => 'before_widget',
|
230 |
+
'after_widget' => 'after_widget',
|
231 |
+
);
|
232 |
+
|
233 |
+
if ( ! empty( $sidebar_id ) ) {
|
234 |
+
foreach ( $sidebar_id as $key => $id ) {
|
235 |
+
if ( empty( $id ) ) {
|
236 |
+
continue;
|
237 |
+
}
|
238 |
+
$id = sanitize_title( $id );
|
239 |
+
$optionals = '';
|
240 |
+
foreach ( $values as $arg_key => $form_key ) {
|
241 |
+
$form_values = $this->get_value( $form_key );
|
242 |
+
|
243 |
+
$optionals .= $this->get_optional_value_code( $form_values[ $key ], $this->get_default_value( $form_key ), $arg_key, true );
|
244 |
+
}
|
245 |
+
|
246 |
+
$sidebar_code .= "
|
247 |
+
\$args = array(
|
248 |
+
'id' => '$id',
|
249 |
+
$optionals);
|
250 |
+
register_sidebar( \$args );
|
251 |
+
";
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
return <<<EOD
|
256 |
+
// Add Sidebars
|
257 |
+
function {$this->get_value( 'function_name' )}() {
|
258 |
+
$sidebar_code
|
259 |
+
}
|
260 |
+
add_action( 'widgets_init', '{$this->get_value( 'function_name' )}' );
|
261 |
+
EOD;
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
includes/generator/class-wpcode-generator-style.php
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to enqueue styles.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Style class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Style extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'enqueue_style';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'core',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Register Stylesheets', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Generate a snippet to load CSS stylesheets using wp_register_style.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Using this generator you can create a WordPress function to register and enqueue styles.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => sprintf(
|
79 |
+
// Translators: the placeholders add a link to getboostrap.com.
|
80 |
+
__( 'You can use this to load external styles or even styles from a theme or plugin. For example, you could load %1$sfontawesome%2$s from a cdn.', 'insert-headers-and-footers' ),
|
81 |
+
'<a href="https://fontawesome.com/" target="_blank">',
|
82 |
+
'</a>'
|
83 |
+
),
|
84 |
+
),
|
85 |
+
),
|
86 |
+
),
|
87 |
+
),
|
88 |
+
'general' => array(
|
89 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
90 |
+
'columns' => array(
|
91 |
+
// Column 1.
|
92 |
+
array(
|
93 |
+
array(
|
94 |
+
'type' => 'text',
|
95 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
96 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
97 |
+
'id' => 'function_name',
|
98 |
+
'placeholder' => 'add_custom_style',
|
99 |
+
'default' => 'add_custom_style' . time(),
|
100 |
+
// This makes it unique for people who don't want to customize.
|
101 |
+
),
|
102 |
+
),
|
103 |
+
// Column 2.
|
104 |
+
array(
|
105 |
+
array(
|
106 |
+
'type' => 'select',
|
107 |
+
'label' => __( 'Action (hook)', 'insert-headers-and-footers' ),
|
108 |
+
'description' => sprintf(
|
109 |
+
// Translators: placeholders add links to documentation on wordpress.org.
|
110 |
+
__( 'Hook used to add the styles: %1$sfrontend%2$s, %3$sadmin%4$s, %5$slogin%6$s or %7$sembed%8$s.', 'insert-headers-and-footers' ),
|
111 |
+
'<a href="https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/" target="_blank">',
|
112 |
+
'</a>',
|
113 |
+
'<a href="https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/" target="_blank">',
|
114 |
+
'</a>',
|
115 |
+
'<a href="https://developer.wordpress.org/reference/hooks/login_enqueue_scripts/" target="_blank">',
|
116 |
+
'</a>',
|
117 |
+
'<a href="https://developer.wordpress.org/reference/hooks/enqueue_embed_scripts/" target="_blank">',
|
118 |
+
'</a>'
|
119 |
+
),
|
120 |
+
'id' => 'hook',
|
121 |
+
'default' => 'wp_enqueue_scripts',
|
122 |
+
'options' => array(
|
123 |
+
// Translators: placeholder adds the hook name.
|
124 |
+
'wp_enqueue_scripts' => sprintf( __( 'Frontend (%s)', 'insert-headers-and-footers' ), 'wp_enqueue_scripts' ),
|
125 |
+
// Translators: placeholder adds the hook name.
|
126 |
+
'admin_enqueue_scripts' => sprintf( __( 'Admin (%s)', 'insert-headers-and-footers' ), 'admin_enqueue_scripts' ),
|
127 |
+
// Translators: placeholder adds the hook name.
|
128 |
+
'login_enqueue_scripts' => sprintf( __( 'Login (%s)', 'insert-headers-and-footers' ), 'login_enqueue_scripts' ),
|
129 |
+
// Translators: placeholder adds the hook name.
|
130 |
+
'enqueue_embed_scripts' => sprintf( __( 'Embed (%s)', 'insert-headers-and-footers' ), 'enqueue_embed_scripts' ),
|
131 |
+
),
|
132 |
+
),
|
133 |
+
),
|
134 |
+
),
|
135 |
+
),
|
136 |
+
'styles' => array(
|
137 |
+
'label' => __( 'Styles', 'insert-headers-and-footers' ),
|
138 |
+
'columns' => array(
|
139 |
+
// Column 1.
|
140 |
+
array(
|
141 |
+
array(
|
142 |
+
'type' => 'text',
|
143 |
+
'label' => __( 'Style name', 'insert-headers-and-footers' ),
|
144 |
+
'description' => __( 'This will be used as an identifier in the code, should be lowercase with no spaces.', 'insert-headers-and-footers' ),
|
145 |
+
'id' => 'style_name',
|
146 |
+
'name' => 'style_name[]',
|
147 |
+
'default' => '',
|
148 |
+
'placeholder' => '',
|
149 |
+
'repeater' => 'style',
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'type' => 'text',
|
153 |
+
'label' => __( 'Stylesheet URL', 'insert-headers-and-footers' ),
|
154 |
+
'description' => __( 'The full URL for the stylesheet e.g. https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css.', 'insert-headers-and-footers' ),
|
155 |
+
'id' => 'style_url',
|
156 |
+
'name' => 'style_url[]',
|
157 |
+
'default' => '',
|
158 |
+
'placeholder' => '',
|
159 |
+
'repeater' => 'style',
|
160 |
+
),
|
161 |
+
array(
|
162 |
+
'type' => 'text',
|
163 |
+
'label' => __( 'Dependencies', 'insert-headers-and-footers' ),
|
164 |
+
'description' => __( 'Comma-separated list of styles required for this style to load, e.g. jquery', 'insert-headers-and-footers' ),
|
165 |
+
'id' => 'style_dependencies',
|
166 |
+
'name' => 'style_dependencies[]',
|
167 |
+
'default' => '',
|
168 |
+
'placeholder' => '',
|
169 |
+
'repeater' => 'style',
|
170 |
+
),
|
171 |
+
array(
|
172 |
+
'type' => 'text',
|
173 |
+
'label' => __( 'Style Version', 'insert-headers-and-footers' ),
|
174 |
+
'description' => __( 'The style version.', 'insert-headers-and-footers' ),
|
175 |
+
'id' => 'style_version',
|
176 |
+
'name' => 'style_version[]',
|
177 |
+
'default' => '1.0.0',
|
178 |
+
'placeholder' => '',
|
179 |
+
'repeater' => 'style',
|
180 |
+
),
|
181 |
+
),
|
182 |
+
// Column 2.
|
183 |
+
array(
|
184 |
+
array(
|
185 |
+
'type' => 'text',
|
186 |
+
'label' => __( 'Media', 'insert-headers-and-footers' ),
|
187 |
+
'description' => sprintf(
|
188 |
+
// Translators: placeholders add a link to the W3.org reference.
|
189 |
+
__( 'Load the style %1$smedia type%2$s, usually "all".', 'insert-headers-and-footers' ),
|
190 |
+
'<a href="https://www.w3.org/TR/CSS2/media.html#media-types" target="_blank">',
|
191 |
+
'</a>'
|
192 |
+
),
|
193 |
+
'id' => 'style_media',
|
194 |
+
'name' => 'style_media[]',
|
195 |
+
'default' => 'all',
|
196 |
+
'repeater' => 'style',
|
197 |
+
),
|
198 |
+
array(
|
199 |
+
'type' => 'select',
|
200 |
+
'label' => __( 'Deregister style?', 'insert-headers-and-footers' ),
|
201 |
+
'description' => sprintf(
|
202 |
+
// Translators: Placeholders for wp.org docs link.
|
203 |
+
__( 'Should the style be %1$sderegistered%2$s first? (for example, if you are replacing an existing style).', 'insert-headers-and-footers' ),
|
204 |
+
'<a href="https://developer.wordpress.org/reference/functions/wp_deregister_style/" target="_blank">',
|
205 |
+
'</a>'
|
206 |
+
),
|
207 |
+
'id' => 'style_deregister',
|
208 |
+
'name' => 'style_deregister[]',
|
209 |
+
'default' => 'false',
|
210 |
+
'options' => array(
|
211 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
212 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
213 |
+
),
|
214 |
+
'repeater' => 'style',
|
215 |
+
),
|
216 |
+
array(
|
217 |
+
'type' => 'select',
|
218 |
+
'label' => __( 'Enqueue style?', 'insert-headers-and-footers' ),
|
219 |
+
'description' => sprintf(
|
220 |
+
// Translators: Placeholders for wp.org docs link.
|
221 |
+
__( 'Should the style be %1$senqueued%2$s or just registered? (select "No" only if you intend enqueueing it later.', 'insert-headers-and-footers' ),
|
222 |
+
'<a href="https://developer.wordpress.org/reference/functions/wp_enqueue_style/" target="_blank">',
|
223 |
+
'</a>'
|
224 |
+
),
|
225 |
+
'id' => 'style_enqueue',
|
226 |
+
'name' => 'style_enqueue[]',
|
227 |
+
'default' => 'true',
|
228 |
+
'options' => array(
|
229 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
230 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
231 |
+
),
|
232 |
+
'repeater' => 'style',
|
233 |
+
),
|
234 |
+
array(
|
235 |
+
'type' => 'spacer',
|
236 |
+
),
|
237 |
+
),
|
238 |
+
// Column 3.
|
239 |
+
array(
|
240 |
+
array(
|
241 |
+
'type' => 'description',
|
242 |
+
'label' => __( 'Add more styles', 'insert-headers-and-footers' ),
|
243 |
+
'content' => __( 'Use the "Add style" button below to add multiple styles in this snippet.', 'insert-headers-and-footers' ),
|
244 |
+
),
|
245 |
+
array(
|
246 |
+
'type' => 'repeater_button',
|
247 |
+
'button_text' => __( 'Add style', 'insert-headers-and-footers' ),
|
248 |
+
'id' => 'style', // Repeater to repeat when clicked.
|
249 |
+
),
|
250 |
+
),
|
251 |
+
),
|
252 |
+
),
|
253 |
+
);
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Get the snippet code with dynamic values applied.
|
258 |
+
*
|
259 |
+
* @return string
|
260 |
+
*/
|
261 |
+
public function get_snippet_code() {
|
262 |
+
|
263 |
+
$styles = $this->get_value( 'style_name' );
|
264 |
+
$styles_urls = $this->get_value( 'style_url' );
|
265 |
+
$styles_deps = $this->get_value( 'style_dependencies' );
|
266 |
+
$styles_versions = $this->get_value( 'style_version' );
|
267 |
+
$styles_media = $this->get_value( 'style_media' );
|
268 |
+
$styles_deregister = $this->get_value( 'style_deregister' );
|
269 |
+
$styles_enqueue = $this->get_value( 'style_enqueue' );
|
270 |
+
$code = '';
|
271 |
+
|
272 |
+
if ( ! empty( $styles ) ) {
|
273 |
+
foreach ( $styles as $key => $style ) {
|
274 |
+
if ( empty( $style ) ) {
|
275 |
+
continue;
|
276 |
+
}
|
277 |
+
$style = sanitize_title( $style );
|
278 |
+
$dependencies = explode( ',', $styles_deps[ $key ] );
|
279 |
+
$deregister = 'true' === $styles_deregister[ $key ] ? "wp_deregister_style( '$style' );" : '';
|
280 |
+
$enqueue = 'true' === $styles_enqueue[ $key ] ? "wp_enqueue_style( '$style' );" : '';
|
281 |
+
$media = 'all' !== $styles_media[ $key ] ? ", '$styles_media[$key]'" : '';
|
282 |
+
|
283 |
+
$code .= "
|
284 |
+
$deregister
|
285 |
+
wp_register_style( '$style', '$styles_urls[$key]', {$this->array_to_code_string($dependencies)}, '$styles_versions[$key]'$media );
|
286 |
+
$enqueue
|
287 |
+
";
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
return <<<EOD
|
292 |
+
// Add custom styles
|
293 |
+
function {$this->get_value( 'function_name' )}() {
|
294 |
+
$code
|
295 |
+
}
|
296 |
+
add_action( '{$this->get_value( 'hook' )}', '{$this->get_value( 'function_name' )}' );
|
297 |
+
EOD;
|
298 |
+
}
|
299 |
+
|
300 |
+
}
|
includes/generator/class-wpcode-generator-taxonomy.php
ADDED
@@ -0,0 +1,624 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to register a new taxonomy.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* The Taxonomy generator class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Taxonomy extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'taxonomy';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'content',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Taxonomy', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Create a custom taxonomy for your posts using this generator.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Use this generator to create custom taxonomies for your WordPress site.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => __( 'Use this to add more taxonomies to posts or custom post types. For example, if you used the Post Type generator to create an Artist post type you can use this one to create a Genre taxonomy.', 'insert-headers-and-footers' ),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
'general' => array(
|
84 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
85 |
+
'columns' => array(
|
86 |
+
// Column 1.
|
87 |
+
array(
|
88 |
+
array(
|
89 |
+
'type' => 'text',
|
90 |
+
'label' => __( 'Function name', 'insert-headers-and-footers' ),
|
91 |
+
'description' => __( 'Make this unique to avoid conflicts with other snippets', 'insert-headers-and-footers' ),
|
92 |
+
'id' => 'function_name',
|
93 |
+
'placeholder' => 'register_custom_taxonomy',
|
94 |
+
'default' => 'register_custom_taxonomy' . time(),
|
95 |
+
// This makes it unique for people who don't want to customize.
|
96 |
+
),
|
97 |
+
),
|
98 |
+
// Column 2.
|
99 |
+
array(
|
100 |
+
array(
|
101 |
+
'type' => 'text',
|
102 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
103 |
+
'description' => __( 'Optional text domain for translations.', 'insert-headers-and-footers' ),
|
104 |
+
'id' => 'text_domain',
|
105 |
+
'placeholder' => 'text_domain',
|
106 |
+
'default' => 'text_domain',
|
107 |
+
),
|
108 |
+
),
|
109 |
+
),
|
110 |
+
),
|
111 |
+
'taxonomy' => array(
|
112 |
+
'label' => __( 'Taxonomy', 'insert-headers-and-footers' ),
|
113 |
+
'columns' => array(
|
114 |
+
// Column 1.
|
115 |
+
array(
|
116 |
+
array(
|
117 |
+
'type' => 'text',
|
118 |
+
'label' => __( 'Taxonomy Key', 'insert-headers-and-footers' ),
|
119 |
+
'description' => __( 'Name of taxonomy used in the code, lowercase maximum 20 characters.', 'insert-headers-and-footers' ),
|
120 |
+
'id' => 'taxonomy',
|
121 |
+
'placeholder' => 'taxonomy',
|
122 |
+
'default' => 'taxonomy',
|
123 |
+
),
|
124 |
+
),
|
125 |
+
// Column 2.
|
126 |
+
array(
|
127 |
+
array(
|
128 |
+
'type' => 'text',
|
129 |
+
'label' => __( 'Name (Singular)', 'insert-headers-and-footers' ),
|
130 |
+
'description' => __( 'The singular taxonomy name (e.g. Genre, Year).', 'insert-headers-and-footers' ),
|
131 |
+
'id' => 'label',
|
132 |
+
'placeholder' => 'Taxonomy',
|
133 |
+
'default' => 'Taxonomy',
|
134 |
+
),
|
135 |
+
array(
|
136 |
+
'type' => 'text',
|
137 |
+
'label' => __( 'Name (Plural)', 'insert-headers-and-footers' ),
|
138 |
+
'description' => __( 'The taxonomy plural name (e.g. Genres, Years).', 'insert-headers-and-footers' ),
|
139 |
+
'id' => 'label_count',
|
140 |
+
'placeholder' => 'Taxonomies',
|
141 |
+
'default' => 'Taxonomies',
|
142 |
+
),
|
143 |
+
),
|
144 |
+
// Column 3.
|
145 |
+
array(
|
146 |
+
array(
|
147 |
+
'type' => 'text',
|
148 |
+
'label' => __( 'Link To Post Type(s)', 'insert-headers-and-footers' ),
|
149 |
+
'description' => __( 'Comma-separated list of Post Types (e.g. post, page)', 'insert-headers-and-footers' ),
|
150 |
+
'id' => 'post_types',
|
151 |
+
'placeholder' => 'post',
|
152 |
+
'default' => 'post',
|
153 |
+
),
|
154 |
+
array(
|
155 |
+
'type' => 'select',
|
156 |
+
'label' => __( 'Hierarchical', 'insert-headers-and-footers' ),
|
157 |
+
'description' => __( 'Hierarchical taxonomies can have descendants.', 'insert-headers-and-footers' ),
|
158 |
+
'id' => 'hierarchical',
|
159 |
+
'default' => 'false',
|
160 |
+
'options' => array(
|
161 |
+
'false' => __( 'No, like tags', 'insert-headers-and-footers' ),
|
162 |
+
'true' => __( 'Yes, like categories', 'insert-headers-and-footers' ),
|
163 |
+
),
|
164 |
+
),
|
165 |
+
),
|
166 |
+
),
|
167 |
+
),
|
168 |
+
'labels' => array(
|
169 |
+
'label' => __( 'Labels', 'insert-headers-and-footers' ),
|
170 |
+
'columns' => array(
|
171 |
+
// Column 1.
|
172 |
+
array(
|
173 |
+
array(
|
174 |
+
'type' => 'text',
|
175 |
+
'label' => __( 'Menu Name', 'insert-headers-and-footers' ),
|
176 |
+
'id' => 'label_menu_name',
|
177 |
+
'placeholder' => 'Taxonomy',
|
178 |
+
'default' => 'Taxonomy',
|
179 |
+
),
|
180 |
+
array(
|
181 |
+
'type' => 'text',
|
182 |
+
'label' => __( 'All Items', 'insert-headers-and-footers' ),
|
183 |
+
'id' => 'label_all_items',
|
184 |
+
'placeholder' => 'All Items',
|
185 |
+
'default' => 'All Items',
|
186 |
+
),
|
187 |
+
array(
|
188 |
+
'type' => 'text',
|
189 |
+
'label' => __( 'Parent Item', 'insert-headers-and-footers' ),
|
190 |
+
'id' => 'label_parent_item',
|
191 |
+
'placeholder' => 'Parent Item',
|
192 |
+
'default' => 'Item Archives',
|
193 |
+
),
|
194 |
+
array(
|
195 |
+
'type' => 'text',
|
196 |
+
'label' => __( 'Parent Item colon', 'insert-headers-and-footers' ),
|
197 |
+
'id' => 'label_parent_item_colon',
|
198 |
+
'placeholder' => 'Parent Item:',
|
199 |
+
'default' => 'Parent Item:',
|
200 |
+
),
|
201 |
+
array(
|
202 |
+
'type' => 'text',
|
203 |
+
'label' => __( 'New Item Name', 'insert-headers-and-footers' ),
|
204 |
+
'id' => 'label_new_item',
|
205 |
+
'placeholder' => 'New Item Name',
|
206 |
+
'default' => 'New Item Name',
|
207 |
+
),
|
208 |
+
array(
|
209 |
+
'type' => 'text',
|
210 |
+
'label' => __( 'Add New Item', 'insert-headers-and-footers' ),
|
211 |
+
'id' => 'label_add_new_item',
|
212 |
+
'placeholder' => 'Add New Item',
|
213 |
+
'default' => 'Add New Item',
|
214 |
+
),
|
215 |
+
),
|
216 |
+
// Column 2.
|
217 |
+
array(
|
218 |
+
array(
|
219 |
+
'type' => 'text',
|
220 |
+
'label' => __( 'Edit Item', 'insert-headers-and-footers' ),
|
221 |
+
'id' => 'label_edit_item',
|
222 |
+
'placeholder' => 'Edit Item',
|
223 |
+
'default' => 'Edit Item',
|
224 |
+
),
|
225 |
+
array(
|
226 |
+
'type' => 'text',
|
227 |
+
'label' => __( 'Update Item', 'insert-headers-and-footers' ),
|
228 |
+
'id' => 'label_update_item',
|
229 |
+
'placeholder' => 'Update Item',
|
230 |
+
'default' => 'Update Item',
|
231 |
+
),
|
232 |
+
array(
|
233 |
+
'type' => 'text',
|
234 |
+
'label' => __( 'View Item', 'insert-headers-and-footers' ),
|
235 |
+
'id' => 'label_view_item',
|
236 |
+
'placeholder' => 'View Item',
|
237 |
+
'default' => 'View Item',
|
238 |
+
),
|
239 |
+
array(
|
240 |
+
'type' => 'text',
|
241 |
+
'label' => __( 'Separate Items with commas', 'insert-headers-and-footers' ),
|
242 |
+
'id' => 'label_separate_items_with_commas',
|
243 |
+
'placeholder' => 'Separate Items with commas',
|
244 |
+
'default' => 'Separate Items with commas',
|
245 |
+
),
|
246 |
+
array(
|
247 |
+
'type' => 'text',
|
248 |
+
'label' => __( 'Add or Remove Items', 'insert-headers-and-footers' ),
|
249 |
+
'id' => 'label_add_or_remove_items',
|
250 |
+
'placeholder' => 'Add or remove items',
|
251 |
+
'default' => 'Add or remove items',
|
252 |
+
),
|
253 |
+
array(
|
254 |
+
'type' => 'text',
|
255 |
+
'label' => __( 'Choose From Most Used', 'insert-headers-and-footers' ),
|
256 |
+
'id' => 'label_choose_from_most_used',
|
257 |
+
'placeholder' => 'Choose from the most used',
|
258 |
+
'default' => 'Choose from the most used',
|
259 |
+
),
|
260 |
+
),
|
261 |
+
// Column 3.
|
262 |
+
array(
|
263 |
+
array(
|
264 |
+
'type' => 'text',
|
265 |
+
'label' => __( 'Popular Items', 'insert-headers-and-footers' ),
|
266 |
+
'id' => 'label_popular_items',
|
267 |
+
'placeholder' => 'Popular Items',
|
268 |
+
'default' => 'Popular Items',
|
269 |
+
),
|
270 |
+
array(
|
271 |
+
'type' => 'text',
|
272 |
+
'label' => __( 'Search Items', 'insert-headers-and-footers' ),
|
273 |
+
'id' => 'label_search_items',
|
274 |
+
'placeholder' => 'Search Items',
|
275 |
+
'default' => 'Search Items',
|
276 |
+
),
|
277 |
+
array(
|
278 |
+
'type' => 'text',
|
279 |
+
'label' => __( 'Not Found', 'insert-headers-and-footers' ),
|
280 |
+
'id' => 'label_not_found',
|
281 |
+
'placeholder' => 'Not Found',
|
282 |
+
'default' => 'Not Found',
|
283 |
+
),
|
284 |
+
array(
|
285 |
+
'type' => 'text',
|
286 |
+
'label' => __( 'No items', 'insert-headers-and-footers' ),
|
287 |
+
'id' => 'label_no_items',
|
288 |
+
'placeholder' => 'No items',
|
289 |
+
'default' => 'No items',
|
290 |
+
),
|
291 |
+
array(
|
292 |
+
'type' => 'text',
|
293 |
+
'label' => __( 'Items list', 'insert-headers-and-footers' ),
|
294 |
+
'id' => 'label_items_list',
|
295 |
+
'placeholder' => 'Items list',
|
296 |
+
'default' => 'Items list',
|
297 |
+
),
|
298 |
+
array(
|
299 |
+
'type' => 'text',
|
300 |
+
'label' => __( 'Items list navigation', 'insert-headers-and-footers' ),
|
301 |
+
'id' => 'label_items_list_navigation',
|
302 |
+
'placeholder' => 'Items list navigation',
|
303 |
+
'default' => 'Items list navigation',
|
304 |
+
),
|
305 |
+
),
|
306 |
+
),
|
307 |
+
),
|
308 |
+
'visibility' => array(
|
309 |
+
'label' => __( 'Visibility', 'insert-headers-and-footers' ),
|
310 |
+
'columns' => array(
|
311 |
+
// Column 1.
|
312 |
+
array(
|
313 |
+
array(
|
314 |
+
'type' => 'select',
|
315 |
+
'label' => __( 'Public', 'insert-headers-and-footers' ),
|
316 |
+
// Translators: Placeholders add a link to the wp.org documentation page.
|
317 |
+
'description' => sprintf( __( 'Should this taxonomy be %1$svisible to authors%2$s?', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_taxonomy/#additional-parameter-information" target="_blank">', '</a>' ),
|
318 |
+
'id' => 'public',
|
319 |
+
'default' => 'true',
|
320 |
+
'options' => array(
|
321 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
322 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
323 |
+
),
|
324 |
+
),
|
325 |
+
),
|
326 |
+
// Column 2.
|
327 |
+
array(
|
328 |
+
array(
|
329 |
+
'type' => 'select',
|
330 |
+
'label' => __( 'Show UI', 'insert-headers-and-footers' ),
|
331 |
+
'description' => __( 'Should this taxonomy have an User Interface for managing?', 'insert-headers-and-footers' ),
|
332 |
+
'id' => 'show_ui',
|
333 |
+
'default' => 'true',
|
334 |
+
'options' => array(
|
335 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
336 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
337 |
+
),
|
338 |
+
),
|
339 |
+
array(
|
340 |
+
'type' => 'select',
|
341 |
+
'label' => __( 'Show Admin Column', 'insert-headers-and-footers' ),
|
342 |
+
'description' => __( 'Should this taxonomy add a column in the list of associated post types?', 'insert-headers-and-footers' ),
|
343 |
+
'id' => 'show_admin_column',
|
344 |
+
'default' => 'true',
|
345 |
+
'options' => array(
|
346 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
347 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
348 |
+
),
|
349 |
+
),
|
350 |
+
),
|
351 |
+
// Column 3.
|
352 |
+
array(
|
353 |
+
array(
|
354 |
+
'type' => 'select',
|
355 |
+
'label' => __( 'Show Tag Cloud', 'insert-headers-and-footers' ),
|
356 |
+
'description' => __( 'Should this taxonomy be visible in the tag cloud widget?', 'insert-headers-and-footers' ),
|
357 |
+
'id' => 'show_tagcloud',
|
358 |
+
'default' => 'true',
|
359 |
+
'options' => array(
|
360 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
361 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
362 |
+
),
|
363 |
+
),
|
364 |
+
array(
|
365 |
+
'type' => 'select',
|
366 |
+
'label' => __( 'Show in Navigation Menus', 'insert-headers-and-footers' ),
|
367 |
+
'description' => __( 'Should this taxonomy be available in menus (Appearance > Menus).', 'insert-headers-and-footers' ),
|
368 |
+
'id' => 'show_in_nav_menus',
|
369 |
+
'default' => 'true',
|
370 |
+
'options' => array(
|
371 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
372 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
373 |
+
),
|
374 |
+
),
|
375 |
+
),
|
376 |
+
),
|
377 |
+
),
|
378 |
+
'permalinks' => array(
|
379 |
+
'label' => __( 'Permalinks', 'insert-headers-and-footers' ),
|
380 |
+
'columns' => array(
|
381 |
+
// Column 1.
|
382 |
+
array(
|
383 |
+
array(
|
384 |
+
'type' => 'select',
|
385 |
+
'label' => __( 'Permalink Rewrite', 'insert-headers-and-footers' ),
|
386 |
+
'description' => __( 'Use Default Permalinks, disable automatic rewriting or use custom permalinks.', 'insert-headers-and-footers' ),
|
387 |
+
'id' => 'rewrite',
|
388 |
+
'default' => 'true',
|
389 |
+
'options' => array(
|
390 |
+
'true' => __( 'Default (taxonomy key)', 'insert-headers-and-footers' ),
|
391 |
+
'false' => __( 'Disable permalink rewrites', 'insert-headers-and-footers' ),
|
392 |
+
'custom' => __( 'Custom permalink structure', 'insert-headers-and-footers' ),
|
393 |
+
),
|
394 |
+
),
|
395 |
+
),
|
396 |
+
// Column 2.
|
397 |
+
array(
|
398 |
+
array(
|
399 |
+
'type' => 'text',
|
400 |
+
'label' => __( 'URL Slug', 'insert-headers-and-footers' ),
|
401 |
+
'description' => __( 'If you selected custom permalinks use this field for the rewrite base, e.g. taxonomy in https://yoursite.com/taxonomy', 'insert-headers-and-footers' ),
|
402 |
+
'id' => 'rewrite_slug',
|
403 |
+
'default' => '',
|
404 |
+
'placeholder' => '',
|
405 |
+
),
|
406 |
+
),
|
407 |
+
// Column 3.
|
408 |
+
array(
|
409 |
+
array(
|
410 |
+
'type' => 'select',
|
411 |
+
'label' => __( 'Prepend permastruct', 'insert-headers-and-footers' ),
|
412 |
+
'description' => __( 'Should the permastruct be prepended to the url (with_front parameter).', 'insert-headers-and-footers' ),
|
413 |
+
'id' => 'rewrite_with_front',
|
414 |
+
'default' => 'true',
|
415 |
+
'options' => array(
|
416 |
+
'true' => __( 'Yes - default', 'insert-headers-and-footers' ),
|
417 |
+
'false' => __( 'No', 'insert-headers-and-footers' ),
|
418 |
+
),
|
419 |
+
),
|
420 |
+
array(
|
421 |
+
'type' => 'select',
|
422 |
+
'label' => __( 'Hierarchical URL Slug', 'insert-headers-and-footers' ),
|
423 |
+
'description' => __( 'For hierarchical taxonomies use the whole hierarchy in the URL?', 'insert-headers-and-footers' ),
|
424 |
+
'id' => 'rewrite_hierarchical',
|
425 |
+
'default' => 'false',
|
426 |
+
'options' => array(
|
427 |
+
'false' => __( 'No - default', 'insert-headers-and-footers' ),
|
428 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
429 |
+
),
|
430 |
+
),
|
431 |
+
),
|
432 |
+
),
|
433 |
+
),
|
434 |
+
'capabilities' => array(
|
435 |
+
'label' => __( 'Capabilities', 'insert-headers-and-footers' ),
|
436 |
+
'columns' => array(
|
437 |
+
// Column 1.
|
438 |
+
array(
|
439 |
+
array(
|
440 |
+
'type' => 'select',
|
441 |
+
'label' => __( 'Capabilities', 'insert-headers-and-footers' ),
|
442 |
+
// Translators: Placeholders add link to wp.org docs.
|
443 |
+
'description' => sprintf( __( 'User capabilities in relation to this taxonomy. %1$sSee Documentation.%2$s', 'insert-headers-and-footers' ), '<a href="https://developer.wordpress.org/reference/functions/register_taxonomy/#additional-parameter-information" target="_blank">', '</a>' ),
|
444 |
+
'id' => 'capabilities',
|
445 |
+
'default' => 'true',
|
446 |
+
'options' => array(
|
447 |
+
'true' => __( 'Base capabilities - default', 'insert-headers-and-footers' ),
|
448 |
+
'custom' => __( 'Custom Capabilities', 'insert-headers-and-footers' ),
|
449 |
+
),
|
450 |
+
),
|
451 |
+
array(
|
452 |
+
'type' => 'description',
|
453 |
+
'label' => __( 'Custom Capabilities', 'insert-headers-and-footers' ),
|
454 |
+
'content' => __( 'Use the fields on the right to assign custom capabilities for this taxonomy.' ),
|
455 |
+
),
|
456 |
+
),
|
457 |
+
// Column 2.
|
458 |
+
array(
|
459 |
+
array(
|
460 |
+
'type' => 'text',
|
461 |
+
'label' => __( 'Edit Terms', 'insert-headers-and-footers' ),
|
462 |
+
'id' => 'edit_terms',
|
463 |
+
'default' => 'manage_categories',
|
464 |
+
'placeholder' => 'manage_categories',
|
465 |
+
),
|
466 |
+
array(
|
467 |
+
'type' => 'text',
|
468 |
+
'label' => __( 'Delete Terms', 'insert-headers-and-footers' ),
|
469 |
+
'id' => 'delete_terms',
|
470 |
+
'default' => 'manage_categories',
|
471 |
+
'placeholder' => 'manage_categories',
|
472 |
+
),
|
473 |
+
),
|
474 |
+
// Column 3.
|
475 |
+
array(
|
476 |
+
array(
|
477 |
+
'type' => 'text',
|
478 |
+
'label' => __( 'Manage Terms', 'insert-headers-and-footers' ),
|
479 |
+
'id' => 'manage_terms',
|
480 |
+
'default' => 'manage_categories',
|
481 |
+
'placeholder' => 'manage_categories',
|
482 |
+
),
|
483 |
+
array(
|
484 |
+
'type' => 'text',
|
485 |
+
'label' => __( 'Assign Terms', 'insert-headers-and-footers' ),
|
486 |
+
'id' => 'assign_terms',
|
487 |
+
'default' => 'edit_posts',
|
488 |
+
'placeholder' => 'edit_posts',
|
489 |
+
),
|
490 |
+
),
|
491 |
+
),
|
492 |
+
),
|
493 |
+
'rest_api' => array(
|
494 |
+
'label' => __( 'Rest API', 'insert-headers-and-footers' ),
|
495 |
+
'columns' => array(
|
496 |
+
// Column 1.
|
497 |
+
array(
|
498 |
+
array(
|
499 |
+
'type' => 'select',
|
500 |
+
'label' => __( 'Show in Rest API?', 'insert-headers-and-footers' ),
|
501 |
+
'description' => __( 'Add the taxonomy to the WordPress wp-json API.', 'insert-headers-and-footers' ),
|
502 |
+
'id' => 'show_in_rest',
|
503 |
+
'default' => 'false',
|
504 |
+
'options' => array(
|
505 |
+
'true' => __( 'Yes', 'insert-headers-and-footers' ),
|
506 |
+
'false' => __( 'No - default', 'insert-headers-and-footers' ),
|
507 |
+
),
|
508 |
+
),
|
509 |
+
),
|
510 |
+
// Column 2.
|
511 |
+
array(
|
512 |
+
array(
|
513 |
+
'type' => 'text',
|
514 |
+
'label' => __( 'Rest Base', 'insert-headers-and-footers' ),
|
515 |
+
'description' => __( 'The base slug that this taxonomy will use in the REST API.', 'insert-headers-and-footers' ),
|
516 |
+
'id' => 'rest_base',
|
517 |
+
'default' => '',
|
518 |
+
),
|
519 |
+
),
|
520 |
+
// Column 3.
|
521 |
+
array(
|
522 |
+
array(
|
523 |
+
'type' => 'text',
|
524 |
+
'label' => __( 'Rest Controller Class', 'insert-headers-and-footers' ),
|
525 |
+
'description' => __( 'The name of a custom Rest Controller class instead of WP_REST_Terms_Controller.', 'insert-headers-and-footers' ),
|
526 |
+
'id' => 'rest_controller_class',
|
527 |
+
'default' => '',
|
528 |
+
),
|
529 |
+
),
|
530 |
+
),
|
531 |
+
),
|
532 |
+
);
|
533 |
+
}
|
534 |
+
|
535 |
+
/**
|
536 |
+
* Get the snippet code with dynamic values applied.
|
537 |
+
*
|
538 |
+
* @return string
|
539 |
+
*/
|
540 |
+
public function get_snippet_code() {
|
541 |
+
|
542 |
+
$rewrite = $this->get_value( 'rewrite' );
|
543 |
+
$rewrite_options = '';
|
544 |
+
if ( 'true' === $rewrite ) {
|
545 |
+
$rewrite = '';
|
546 |
+
} elseif ( 'custom' === $rewrite ) {
|
547 |
+
$rewrite = "\t\t'rewrite' => \$rewrite_options,";
|
548 |
+
$rewrite_options = "
|
549 |
+
\$rewrite_options = array(
|
550 |
+
'slug' => '{$this->get_value('rewrite_slug')}',
|
551 |
+
'with_front' => {$this->get_value( 'rewrite_with_front')},
|
552 |
+
'hierarchical' => {$this->get_value( 'rewrite_hierarchical')},
|
553 |
+
);
|
554 |
+
";
|
555 |
+
} else {
|
556 |
+
$rewrite = "\t\t'rewrite' => $rewrite,";
|
557 |
+
}
|
558 |
+
|
559 |
+
$custom_capabilities = '';
|
560 |
+
$capabilities = $this->get_value( 'capabilities' );
|
561 |
+
|
562 |
+
if ( 'custom' === $capabilities ) {
|
563 |
+
$custom_capabilities = "
|
564 |
+
\$capabilities = array(
|
565 |
+
'edit_terms' => '{$this->get_value( 'edit_terms')}',
|
566 |
+
'delete_terms' => '{$this->get_value( 'delete_terms')}',
|
567 |
+
'manage_terms' => '{$this->get_value( 'manage_terms')}',
|
568 |
+
'assign_terms' => '{$this->get_value( 'assign_terms')}',
|
569 |
+
);
|
570 |
+
";
|
571 |
+
$capabilities = " 'capabilities' => \$capabilities,";
|
572 |
+
} else {
|
573 |
+
$capabilities = '';
|
574 |
+
}
|
575 |
+
|
576 |
+
return <<<EOD
|
577 |
+
// Register Custom Taxonomy
|
578 |
+
function {$this->get_value( 'function_name' )}() {
|
579 |
+
|
580 |
+
\$labels = array(
|
581 |
+
'name' => _x( '{$this->get_value( 'label_count' )}', 'Taxonomy General Name', '{$this->get_value( 'text_domain' )}' ),
|
582 |
+
'singular_name' => _x( '{$this->get_value( 'label' )}', 'Taxonomy Singular Name', '{$this->get_value( 'text_domain' )}' ),
|
583 |
+
'menu_name' => __( '{$this->get_value( 'label_menu_name' )}', '{$this->get_value( 'text_domain' )}' ),
|
584 |
+
'all_items' => __( '{$this->get_value( 'label_all_items' )}', '{$this->get_value( 'text_domain' )}' ),
|
585 |
+
'parent_item' => __( '{$this->get_value( 'label_parent_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
586 |
+
'parent_item_colon' => __( '{$this->get_value( 'label_parent_item_colon' )}', '{$this->get_value( 'text_domain' )}' ),
|
587 |
+
'new_item_name' => __( '{$this->get_value( 'label_new_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
588 |
+
'add_new_item' => __( '{$this->get_value( 'label_add_new_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
589 |
+
'edit_item' => __( '{$this->get_value( 'label_edit_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
590 |
+
'update_item' => __( '{$this->get_value( 'label_update_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
591 |
+
'view_item' => __( '{$this->get_value( 'label_view_item' )}', '{$this->get_value( 'text_domain' )}' ),
|
592 |
+
'separate_items_with_commas' => __( '{$this->get_value( 'label_separate_items_with_commas' )}', '{$this->get_value( 'text_domain' )}' ),
|
593 |
+
'add_or_remove_items' => __( '{$this->get_value( 'label_add_or_remove_items' )}', '{$this->get_value( 'text_domain' )}' ),
|
594 |
+
'choose_from_most_used' => __( '{$this->get_value( 'label_choose_from_most_used' )}', '{$this->get_value( 'text_domain' )}' ),
|
595 |
+
'popular_items' => __( '{$this->get_value( 'label_popular_items' )}', '{$this->get_value( 'text_domain' )}' ),
|
596 |
+
'search_items' => __( '{$this->get_value( 'label_search_items' )}', '{$this->get_value( 'text_domain' )}' ),
|
597 |
+
'not_found' => __( '{$this->get_value( 'label_not_found' )}', '{$this->get_value( 'text_domain' )}' ),
|
598 |
+
'no_terms' => __( '{$this->get_value( 'label_no_items' )}', '{$this->get_value( 'text_domain' )}' ),
|
599 |
+
'items_list' => __( '{$this->get_value( 'label_items_list' )}', '{$this->get_value( 'text_domain' )}' ),
|
600 |
+
'items_list_navigation' => __( '{$this->get_value( 'label_items_list_navigation' )}', '{$this->get_value( 'text_domain' )}' ),
|
601 |
+
);
|
602 |
+
$rewrite_options
|
603 |
+
$custom_capabilities
|
604 |
+
\$args = array(
|
605 |
+
'labels' => \$labels,
|
606 |
+
'hierarchical' => {$this->get_value( 'hierarchical' )},
|
607 |
+
'public' => {$this->get_value( 'public' )},
|
608 |
+
'show_ui' => {$this->get_value( 'show_ui' )},
|
609 |
+
'show_admin_column' => {$this->get_value( 'show_admin_column' )},
|
610 |
+
'show_in_nav_menus' => {$this->get_value( 'show_in_nav_menus' )},
|
611 |
+
'show_tagcloud' => {$this->get_value( 'show_tagcloud' )},
|
612 |
+
'show_in_rest' => {$this->get_value( 'show_in_rest' )},
|
613 |
+
$rewrite
|
614 |
+
$capabilities
|
615 |
+
{$this->get_optional_value( 'show_in_rest' )}{$this->get_optional_value( 'rest_base', true )}{$this->get_optional_value( 'rest_controller_class', true )}
|
616 |
+
);
|
617 |
+
register_taxonomy( '{$this->get_value( 'taxonomy' )}', {$this->get_value_comma_separated( 'post_types' )}, \$args );
|
618 |
+
|
619 |
+
}
|
620 |
+
add_action( 'init', '{$this->get_value( 'function_name' )}', 5 );
|
621 |
+
EOD;
|
622 |
+
}
|
623 |
+
|
624 |
+
}
|
includes/generator/class-wpcode-generator-type.php
ADDED
@@ -0,0 +1,781 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Base for different types of snippet generators.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
abstract class WPCode_Generator_Type {
|
9 |
+
/**
|
10 |
+
* The name (slug) for this generator.
|
11 |
+
*
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
public $name;
|
15 |
+
/**
|
16 |
+
* The title of the generator (translatable field).
|
17 |
+
*
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $title;
|
21 |
+
/**
|
22 |
+
* The description of the generator.
|
23 |
+
* This will be displayed in the list of available generators.
|
24 |
+
*
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
public $description;
|
28 |
+
/**
|
29 |
+
* Array of categories for this generator.
|
30 |
+
*
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
public $categories;
|
34 |
+
/**
|
35 |
+
* Array of tabs for the generator fields.
|
36 |
+
*
|
37 |
+
* @var array;
|
38 |
+
*/
|
39 |
+
public $tabs;
|
40 |
+
/**
|
41 |
+
* Store the form data object in an array so we pick values from it.
|
42 |
+
*
|
43 |
+
* @var array
|
44 |
+
*/
|
45 |
+
public $form_data;
|
46 |
+
/**
|
47 |
+
* Catch here all the fields not using the default value.
|
48 |
+
*
|
49 |
+
* @var array
|
50 |
+
*/
|
51 |
+
public $fields_from_form = array();
|
52 |
+
/**
|
53 |
+
* Location where the snippet will run after being saved.
|
54 |
+
*
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
public $location = 'everywhere';
|
58 |
+
/**
|
59 |
+
* Array of tags to add to the saved snippet.
|
60 |
+
*
|
61 |
+
* @var string[]
|
62 |
+
*/
|
63 |
+
public $tags = array(
|
64 |
+
'generated',
|
65 |
+
);
|
66 |
+
/**
|
67 |
+
* Snippet code type for when it will be saved.
|
68 |
+
*
|
69 |
+
* @var string
|
70 |
+
*/
|
71 |
+
public $code_type = 'php';
|
72 |
+
/**
|
73 |
+
* Should the generated snippet be auto-inserted?
|
74 |
+
*
|
75 |
+
* @var bool
|
76 |
+
*/
|
77 |
+
public $auto_insert = true;
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Constructor.
|
81 |
+
*/
|
82 |
+
public function __construct() {
|
83 |
+
$this->set_strings();
|
84 |
+
$this->load_tabs();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Replace this in the type to add translatable fields on init.
|
89 |
+
*
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
abstract protected function set_strings();
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Load the data for the generator tabs.
|
96 |
+
*
|
97 |
+
* @return void
|
98 |
+
*/
|
99 |
+
protected function load_tabs() {
|
100 |
+
$this->tabs = array();
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Let's use a method.
|
105 |
+
*
|
106 |
+
* @return string
|
107 |
+
*/
|
108 |
+
public function get_title() {
|
109 |
+
return $this->title;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Let's use a method.
|
114 |
+
*
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public function get_description() {
|
118 |
+
return $this->description;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Let's use a method.
|
123 |
+
*
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
+
public function get_location() {
|
127 |
+
return $this->location;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Let's use a method.
|
132 |
+
*
|
133 |
+
* @return array
|
134 |
+
*/
|
135 |
+
public function get_tags() {
|
136 |
+
return $this->tags;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Let's use a method.
|
141 |
+
*
|
142 |
+
* @return string
|
143 |
+
*/
|
144 |
+
public function get_code_type() {
|
145 |
+
return $this->code_type;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Get the name.
|
150 |
+
*
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
public function get_name() {
|
154 |
+
return $this->name;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Get the categories of this generator.
|
159 |
+
*
|
160 |
+
* @return array
|
161 |
+
*/
|
162 |
+
public function get_categories() {
|
163 |
+
return $this->categories;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Takes a tab id and renders the form items.
|
168 |
+
*
|
169 |
+
* @param string $tab_id The tab id.
|
170 |
+
*
|
171 |
+
* @return void
|
172 |
+
*/
|
173 |
+
public function render_tab( $tab_id ) {
|
174 |
+
$tab_info = $this->tabs[ $tab_id ];
|
175 |
+
|
176 |
+
foreach ( $tab_info['columns'] as $column_fields ) {
|
177 |
+
?>
|
178 |
+
<div class="wpcode-generator-column">
|
179 |
+
<?php
|
180 |
+
foreach ( $column_fields as $field ) {
|
181 |
+
$this->render_field( $field );
|
182 |
+
}
|
183 |
+
?>
|
184 |
+
</div>
|
185 |
+
<?php
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Takes a field config from the tabs object and renders it's input.
|
191 |
+
*
|
192 |
+
* @param array $field The field config.
|
193 |
+
*
|
194 |
+
* @return void
|
195 |
+
*/
|
196 |
+
public function render_field( $field ) {
|
197 |
+
// Check if the field type is set.
|
198 |
+
if ( ! isset( $field['type'] ) ) {
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
$type = $field['type'];
|
202 |
+
// Check if we have a method of rendering the field.
|
203 |
+
if ( ! method_exists( $this, 'render_field_' . $type ) ) {
|
204 |
+
return;
|
205 |
+
}
|
206 |
+
|
207 |
+
$this->add_field_wrap( $field );
|
208 |
+
call_user_func_array( array( $this, 'render_field_' . $type ), array( $field ) );
|
209 |
+
$this->add_field_wrap( $field, true );
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Add field wrap.
|
214 |
+
*
|
215 |
+
* @param array $field The field config.
|
216 |
+
* @param bool $end Whether to output the closing tag.
|
217 |
+
*
|
218 |
+
* @return void
|
219 |
+
*/
|
220 |
+
public function add_field_wrap( $field, $end = false ) {
|
221 |
+
if ( $end ) {
|
222 |
+
echo '</div>';
|
223 |
+
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
$type = $field['type'];
|
227 |
+
$repeater = empty( $field['repeater'] ) ? '' : 'data-repeater="' . esc_attr( $field['repeater'] ) . '"';
|
228 |
+
$classes = array(
|
229 |
+
'wpcode-generator-field',
|
230 |
+
'wpcode-generator-field-' . $type,
|
231 |
+
);
|
232 |
+
if ( ! empty( $field['autocomplete'] ) ) {
|
233 |
+
$classes[] = 'wpcode-generator-field-autocomplete';
|
234 |
+
}
|
235 |
+
|
236 |
+
echo '<div class="' . esc_attr( implode( ' ', $classes ) ) . '" ' . $repeater . '>';// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Render the description field.
|
241 |
+
*
|
242 |
+
* @param array $field The field array as defined in the tabs array.
|
243 |
+
*
|
244 |
+
* @return void
|
245 |
+
*/
|
246 |
+
public function render_field_description( $field ) {
|
247 |
+
$field = wp_parse_args(
|
248 |
+
$field,
|
249 |
+
array(
|
250 |
+
'label' => '',
|
251 |
+
'content' => '',
|
252 |
+
)
|
253 |
+
);
|
254 |
+
|
255 |
+
$this->text_field_label( $field['label'] );
|
256 |
+
if ( ! empty( $field['content'] ) ) {
|
257 |
+
?>
|
258 |
+
<p><?php echo wp_kses_post( $field['content'] ); ?></p>
|
259 |
+
<?php
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Render a label for text-type fields (description, list, etc).
|
265 |
+
*
|
266 |
+
* @param string $label The label to render.
|
267 |
+
*
|
268 |
+
* @return void
|
269 |
+
*/
|
270 |
+
public function text_field_label( $label ) {
|
271 |
+
if ( empty( $label ) ) {
|
272 |
+
return;
|
273 |
+
}
|
274 |
+
?>
|
275 |
+
<label><?php echo wp_kses_post( $label ); ?></label>
|
276 |
+
<?php
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Render a list from an array.
|
281 |
+
*
|
282 |
+
* @param array $field The field array.
|
283 |
+
*
|
284 |
+
* @return void
|
285 |
+
*/
|
286 |
+
public function render_field_list( $field ) {
|
287 |
+
$field = wp_parse_args(
|
288 |
+
$field,
|
289 |
+
array(
|
290 |
+
'label' => '',
|
291 |
+
'content' => array(),
|
292 |
+
)
|
293 |
+
);
|
294 |
+
|
295 |
+
$this->text_field_label( $field['label'] );
|
296 |
+
if ( ! empty( $field['content'] ) && is_array( $field['content'] ) ) {
|
297 |
+
?>
|
298 |
+
<ul>
|
299 |
+
<?php foreach ( $field['content'] as $li ) { ?>
|
300 |
+
<li><?php echo wp_kses_post( $li ); ?></li>
|
301 |
+
<?php } ?>
|
302 |
+
</ul>
|
303 |
+
<?php
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Render a text input field.
|
309 |
+
*
|
310 |
+
* @param array $field The field array.
|
311 |
+
*
|
312 |
+
* @return void
|
313 |
+
*/
|
314 |
+
public function render_field_text( $field ) {
|
315 |
+
if ( empty( $field['id'] ) ) {
|
316 |
+
return;
|
317 |
+
}
|
318 |
+
if ( ! empty( $field['label'] ) ) {
|
319 |
+
$this->input_field_label( $field['label'], $field['id'] );
|
320 |
+
}
|
321 |
+
$id = $field['id'];
|
322 |
+
$placeholder = ! empty( $field['placeholder'] ) ? $field['placeholder'] : '';
|
323 |
+
$name = empty( $field['name'] ) ? $id : $field['name'];
|
324 |
+
?>
|
325 |
+
<input type="text" id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" value="<?php echo esc_attr( $this->get_default_value( $field['id'] ) ); ?>" class="wpcode-input-text"/>
|
326 |
+
<?php
|
327 |
+
if ( ! empty( $field['description'] ) ) {
|
328 |
+
$this->input_field_description( $field['description'] );
|
329 |
+
}
|
330 |
+
if ( ! empty( $field['autocomplete'] ) ) {
|
331 |
+
?>
|
332 |
+
<script type="application/json" class="wpcode-field-autocomplete"><?php echo wp_json_encode( $field['autocomplete'] ); ?></script>
|
333 |
+
<?php
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* HTML field just extends the text one for now.
|
339 |
+
*
|
340 |
+
* @param array $field The field array.
|
341 |
+
*
|
342 |
+
* @return void
|
343 |
+
*/
|
344 |
+
public function render_field_html( $field ) {
|
345 |
+
$this->render_field_text( $field );
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Render a label for an input.
|
350 |
+
*
|
351 |
+
* @param string $label The label text.
|
352 |
+
* @param string $id The id to use for the "for" attribute of the label.
|
353 |
+
*
|
354 |
+
* @return void
|
355 |
+
*/
|
356 |
+
public function input_field_label( $label, $id ) {
|
357 |
+
if ( empty( $label ) ) {
|
358 |
+
return;
|
359 |
+
}
|
360 |
+
?>
|
361 |
+
<label for="<?php echo esc_attr( $id ); ?>">
|
362 |
+
<?php echo wp_kses_post( $label ); ?>
|
363 |
+
</label>
|
364 |
+
<?php
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Render a field's description.
|
369 |
+
*
|
370 |
+
* @param string $description The field description.
|
371 |
+
*
|
372 |
+
* @return void
|
373 |
+
*/
|
374 |
+
public function input_field_description( $description ) {
|
375 |
+
?>
|
376 |
+
<p class="wpcode-field-description"><?php echo wp_kses_post( $description ); ?></p>
|
377 |
+
<?php
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Render a select dropdown.
|
382 |
+
*
|
383 |
+
* @param array $field The field options.
|
384 |
+
*
|
385 |
+
* @return void
|
386 |
+
*/
|
387 |
+
public function render_field_select( $field ) {
|
388 |
+
if ( empty( $field['id'] ) ) {
|
389 |
+
return;
|
390 |
+
}
|
391 |
+
if ( ! empty( $field['label'] ) ) {
|
392 |
+
$this->input_field_label( $field['label'], $field['id'] );
|
393 |
+
}
|
394 |
+
$id = $field['id'];
|
395 |
+
$name = empty( $field['name'] ) ? $id : $field['name'];
|
396 |
+
if ( ! empty( $field['options'] ) && is_array( $field['options'] ) ) {
|
397 |
+
reset( $field['options'] );
|
398 |
+
$selected = isset( $field['default'] ) ? $field['default'] : key( $field['options'] );
|
399 |
+
?>
|
400 |
+
<select name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>">
|
401 |
+
<?php
|
402 |
+
foreach ( $field['options'] as $value => $label ) {
|
403 |
+
?>
|
404 |
+
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $selected, $value ); ?>><?php echo esc_html( $label ); ?></option>
|
405 |
+
<?php } ?>
|
406 |
+
</select>
|
407 |
+
<?php
|
408 |
+
}
|
409 |
+
if ( ! empty( $field['description'] ) ) {
|
410 |
+
$this->input_field_description( $field['description'] );
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Render a list of checkboxes from a field list of options.
|
416 |
+
*
|
417 |
+
* @param array $field The field settings array.
|
418 |
+
*
|
419 |
+
* @return void
|
420 |
+
*/
|
421 |
+
public function render_field_checkbox_list( $field ) {
|
422 |
+
if ( empty( $field['options'] ) ) {
|
423 |
+
return;
|
424 |
+
}
|
425 |
+
$checked = empty( $field['default'] ) ? array() : $field['default'];
|
426 |
+
|
427 |
+
foreach ( $field['options'] as $value => $label ) {
|
428 |
+
?>
|
429 |
+
<div class="wpcode-checkbox-line">
|
430 |
+
<label class="wpcode-checkbox-toggle">
|
431 |
+
<input type="checkbox" name="<?php echo esc_attr( $field['id'] ); ?>[]" value="<?php echo esc_attr( $value ); ?>" id="<?php echo esc_attr( $field['id'] . '_' . $value ); ?>" <?php checked( in_array( $value, $checked, true ) ); ?>/>
|
432 |
+
<span class="wpcode-checkbox-toggle-slider"></span>
|
433 |
+
</label>
|
434 |
+
<label for="<?php echo esc_attr( $field['id'] . '_' . $value ); ?>"><?php echo esc_html( $label ); ?></label>
|
435 |
+
</div>
|
436 |
+
<?php
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* The repeater button used to add new repeater rows.
|
442 |
+
*
|
443 |
+
* @param array $field The field array.
|
444 |
+
*
|
445 |
+
* @return void
|
446 |
+
*/
|
447 |
+
public function render_field_repeater_button( $field ) {
|
448 |
+
if ( empty( $field['id'] ) ) {
|
449 |
+
return;
|
450 |
+
}
|
451 |
+
|
452 |
+
?>
|
453 |
+
<button type="button" class="wpcode-button wpcode-button-secondary wpcode-repeater-button" data-target="<?php echo esc_attr( $field['id'] ); ?>"><?php echo esc_html( $field['button_text'] ); ?></button>
|
454 |
+
<?php
|
455 |
+
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Set the form data object from an array - usually the $_POST object.
|
460 |
+
*
|
461 |
+
* @param array $form_data The form data object.
|
462 |
+
*
|
463 |
+
* @return string
|
464 |
+
*/
|
465 |
+
public function process_form_data( $form_data ) {
|
466 |
+
$this->form_data = $form_data;
|
467 |
+
|
468 |
+
return $this->get_snippet_code();
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Get the snippet code with the values added to it.
|
473 |
+
*
|
474 |
+
* @return string
|
475 |
+
*/
|
476 |
+
abstract public function get_snippet_code();
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Get a value for output in the snippet code, if the form data is set
|
480 |
+
* we sanitise that and return it otherwise return the default value.
|
481 |
+
*
|
482 |
+
* @param string $field_id The field id.
|
483 |
+
*
|
484 |
+
* @return string
|
485 |
+
*/
|
486 |
+
public function get_value( $field_id ) {
|
487 |
+
return ! empty( $this->form_data[ $field_id ] ) ? $this->sanitize_form_data( $field_id ) : $this->get_default_value( $field_id );
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Sanitize form value based on the field type.
|
492 |
+
*
|
493 |
+
* @param string $field_id The id of the field.
|
494 |
+
*
|
495 |
+
* @return string
|
496 |
+
*/
|
497 |
+
protected function sanitize_form_data( $field_id ) {
|
498 |
+
$field_type = $this->find_field_prop( $field_id, 'type' );
|
499 |
+
$value = $this->form_data[ $field_id ];
|
500 |
+
if ( 'text' === $field_type && is_array( $value ) ) {
|
501 |
+
$field_type = 'text_array';
|
502 |
+
}
|
503 |
+
if ( 'textarea' === $field_type && is_array( $value ) ) {
|
504 |
+
$field_type = 'textarea_array';
|
505 |
+
}
|
506 |
+
if ( 'select' === $field_type && is_array( $value ) ) {
|
507 |
+
$field_type = 'text_array';
|
508 |
+
}
|
509 |
+
if ( 'html' === $field_type && is_array( $value ) ) {
|
510 |
+
$field_type = 'html_array';
|
511 |
+
}
|
512 |
+
|
513 |
+
switch ( $field_type ) {
|
514 |
+
case 'text_array':
|
515 |
+
case 'checkbox_list':
|
516 |
+
$sanitized = array_map( 'sanitize_text_field', wp_unslash( $value ) );
|
517 |
+
foreach ( $sanitized as $item => $value ) {
|
518 |
+
$sanitized[ $item ] = '' === $value ? $this->get_default_value( $field_id ) : $value;
|
519 |
+
}
|
520 |
+
break;
|
521 |
+
case 'textarea_array':
|
522 |
+
$sanitized = array_map( 'sanitize_textarea_field', wp_unslash( $value ) );
|
523 |
+
foreach ( $sanitized as $item => $value ) {
|
524 |
+
$sanitized[ $item ] = '' === $value ? $this->get_default_value( $field_id ) : $value;
|
525 |
+
}
|
526 |
+
break;
|
527 |
+
case 'html_array':
|
528 |
+
$sanitized = array_map( 'wp_kses_post', wp_unslash( $value ) );
|
529 |
+
foreach ( $sanitized as $item => $value ) {
|
530 |
+
$sanitized[ $item ] = '' === $value ? $this->get_default_value( $field_id ) : $value;
|
531 |
+
}
|
532 |
+
break;
|
533 |
+
case 'textarea':
|
534 |
+
$sanitized = sanitize_textarea_field( wp_unslash( $value ) );
|
535 |
+
break;
|
536 |
+
case 'html':
|
537 |
+
$sanitized = wp_kses_post( wp_unslash( $value ) );
|
538 |
+
break;
|
539 |
+
case 'text':
|
540 |
+
default:
|
541 |
+
$sanitized = sanitize_text_field( wp_unslash( $value ) );
|
542 |
+
}
|
543 |
+
|
544 |
+
if ( ! isset( $this->fields_from_form[ $field_id ] ) ) {
|
545 |
+
$this->fields_from_form[ $field_id ] = $sanitized;
|
546 |
+
}
|
547 |
+
|
548 |
+
return $sanitized;
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* Go through the tabs config and find a field value by its id.
|
553 |
+
*
|
554 |
+
* @param string $field_id The id of the field.
|
555 |
+
* @param string $field_value The key of the value (e.g. 'content').
|
556 |
+
*
|
557 |
+
* @return string
|
558 |
+
*/
|
559 |
+
public function find_field_prop( $field_id, $field_value ) {
|
560 |
+
$tabs = $this->get_tabs();
|
561 |
+
foreach ( $tabs as $tab ) {
|
562 |
+
foreach ( $tab['columns'] as $column_fields ) {
|
563 |
+
foreach ( $column_fields as $field ) {
|
564 |
+
if ( ! empty( $field['id'] ) && $field_id === $field['id'] ) {
|
565 |
+
return ! isset( $field[ $field_value ] ) ? '' : $field[ $field_value ];
|
566 |
+
}
|
567 |
+
}
|
568 |
+
}
|
569 |
+
}
|
570 |
+
|
571 |
+
return '';
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Get the tabs for rendering.
|
576 |
+
*
|
577 |
+
* @return array
|
578 |
+
*/
|
579 |
+
public function get_tabs() {
|
580 |
+
return $this->tabs;
|
581 |
+
}
|
582 |
+
|
583 |
+
/**
|
584 |
+
* Go through the tabs config and find the default value for a field.
|
585 |
+
*
|
586 |
+
* @param string $field_id The id of the field for which we want the default value.
|
587 |
+
*
|
588 |
+
* @return string
|
589 |
+
*/
|
590 |
+
public function get_default_value( $field_id ) {
|
591 |
+
return $this->find_field_prop( $field_id, 'default' );
|
592 |
+
}
|
593 |
+
|
594 |
+
/**
|
595 |
+
* Get a string with values comma-separated and convert it to PHP array.
|
596 |
+
*
|
597 |
+
* @param string $field_id The id of the field to grab the data for.
|
598 |
+
*
|
599 |
+
* @return string
|
600 |
+
*/
|
601 |
+
public function get_value_comma_separated( $field_id ) {
|
602 |
+
return $this->get_value_comma_separated_code( $this->get_value( $field_id ) );
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Get a comma separated string and return an array.
|
607 |
+
*
|
608 |
+
* @param string $value The value to explode.
|
609 |
+
* @param bool $quotes Whether to add quotes to the values or not.
|
610 |
+
*
|
611 |
+
* @return string
|
612 |
+
*/
|
613 |
+
public function get_value_comma_separated_code( $value, $quotes = true ) {
|
614 |
+
$items = explode( ',', $value );
|
615 |
+
|
616 |
+
return $this->array_to_code_string( $items, $quotes );
|
617 |
+
}
|
618 |
+
|
619 |
+
/**
|
620 |
+
* Takes an array of strings and returns php code for an array of strings.
|
621 |
+
*
|
622 |
+
* @param string[] $items The array to convert.
|
623 |
+
* @param bool $quotes Whether to add quotes to the values or not.
|
624 |
+
*
|
625 |
+
* @return string
|
626 |
+
*/
|
627 |
+
public function array_to_code_string( $items, $quotes = true ) {
|
628 |
+
if ( empty( $items ) || empty( $items[0] ) ) {
|
629 |
+
return 'array()';
|
630 |
+
}
|
631 |
+
$items = array_map( 'trim', $items );
|
632 |
+
if ( $quotes ) {
|
633 |
+
$items = array_map( array( $this, 'add_quotes' ), $items );
|
634 |
+
}
|
635 |
+
|
636 |
+
return 'array( ' . implode( ', ', $items ) . ' )';
|
637 |
+
}
|
638 |
+
|
639 |
+
/**
|
640 |
+
* Callback to add quotes because we can't use closures in PHP 5.2.
|
641 |
+
*
|
642 |
+
* @param string $item String to add quotes to.
|
643 |
+
*
|
644 |
+
* @return string
|
645 |
+
*/
|
646 |
+
private function add_quotes( $item ) {
|
647 |
+
return "'$item'";
|
648 |
+
}
|
649 |
+
|
650 |
+
/**
|
651 |
+
* Get value of array fields like checkboxes or select multiple.
|
652 |
+
*
|
653 |
+
* @param string $field_id The field id.
|
654 |
+
*
|
655 |
+
* @return string
|
656 |
+
*/
|
657 |
+
public function get_array_value( $field_id ) {
|
658 |
+
$value = $this->get_value( $field_id );
|
659 |
+
|
660 |
+
return $this->array_to_code_string( $value );
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Get the fields that were updated using the form (not using the default value).
|
665 |
+
*
|
666 |
+
* @return array
|
667 |
+
*/
|
668 |
+
public function get_generator_data() {
|
669 |
+
return $this->fields_from_form;
|
670 |
+
}
|
671 |
+
|
672 |
+
/**
|
673 |
+
* If the generated snippet should be auto-inserted or not (used as a shortcode).
|
674 |
+
*
|
675 |
+
* @return bool
|
676 |
+
*/
|
677 |
+
public function get_auto_insert() {
|
678 |
+
return $this->auto_insert;
|
679 |
+
}
|
680 |
+
|
681 |
+
/**
|
682 |
+
* Get PHP array code for an optional parameter by field ID.
|
683 |
+
*
|
684 |
+
* @param string $field_id The field id to grab the value for.
|
685 |
+
* @param bool $quotes Wrap the output value in quotes?.
|
686 |
+
* @param string $array_key The array key if different from the field id, otherwise the field id is used.
|
687 |
+
*
|
688 |
+
* @return string
|
689 |
+
* @see get_optional_value_code
|
690 |
+
*/
|
691 |
+
public function get_optional_value( $field_id, $quotes = false, $array_key = '' ) {
|
692 |
+
if ( empty( $array_key ) ) {
|
693 |
+
$array_key = $field_id;
|
694 |
+
}
|
695 |
+
$value = $this->get_value( $field_id );
|
696 |
+
$default = $this->get_default_value( $field_id );
|
697 |
+
$comma_separated = $this->find_field_prop( $field_id, 'comma-separated' );
|
698 |
+
|
699 |
+
return $this->get_optional_value_code( $value, $default, $array_key, $quotes, $comma_separated );
|
700 |
+
}
|
701 |
+
|
702 |
+
/**
|
703 |
+
* Get PHP array code for an optional parameter.
|
704 |
+
* If the default value is used nothing will be output.
|
705 |
+
* It will also attempt to align all the values properly.
|
706 |
+
*
|
707 |
+
* @param string $value The current value to compare to the default.
|
708 |
+
* @param string $default The default value.
|
709 |
+
* @param string $array_key The array key to use if the value will be output.
|
710 |
+
* @param bool $quotes Whether to use quotes for the value output.
|
711 |
+
* @param bool $comma_separated If the value is actually a comma-separated list.
|
712 |
+
*
|
713 |
+
* @return string
|
714 |
+
*/
|
715 |
+
public function get_optional_value_code( $value, $default, $array_key, $quotes = false, $comma_separated = false ) {
|
716 |
+
if ( $value === $default ) {
|
717 |
+
return '';
|
718 |
+
}
|
719 |
+
if ( $comma_separated ) {
|
720 |
+
$value = $this->get_value_comma_separated_code( $value, $quotes );
|
721 |
+
} elseif ( $quotes ) {
|
722 |
+
$value = "'$value'";
|
723 |
+
}
|
724 |
+
$indent = 22 - strlen( $array_key );
|
725 |
+
$indent = str_repeat( ' ', $indent );
|
726 |
+
|
727 |
+
return "\t\t'$array_key'$indent=> $value,\n";
|
728 |
+
}
|
729 |
+
|
730 |
+
/**
|
731 |
+
* Output a simple spacer used to align repeater rows.
|
732 |
+
*
|
733 |
+
* @return void
|
734 |
+
*/
|
735 |
+
public function render_field_spacer() {
|
736 |
+
?>
|
737 |
+
<div class="wpcode-column-spacer"></div>
|
738 |
+
<?php
|
739 |
+
}
|
740 |
+
|
741 |
+
/**
|
742 |
+
* Render a textarea field, optionally a code editor.
|
743 |
+
*
|
744 |
+
* @param array $field The field settings.
|
745 |
+
*
|
746 |
+
* @return void
|
747 |
+
*/
|
748 |
+
public function render_field_textarea( $field ) {
|
749 |
+
if ( empty( $field['id'] ) ) {
|
750 |
+
return;
|
751 |
+
}
|
752 |
+
if ( ! empty( $field['label'] ) ) {
|
753 |
+
$this->input_field_label( $field['label'], $field['id'] );
|
754 |
+
}
|
755 |
+
$id = $field['id'];
|
756 |
+
$name = empty( $field['name'] ) ? $id : $field['name'];
|
757 |
+
$classes = array(
|
758 |
+
'wpcode-input-textarea',
|
759 |
+
);
|
760 |
+
if ( ! empty( $field['code'] ) ) {
|
761 |
+
$classes[] = 'wpcode-generator-code';
|
762 |
+
}
|
763 |
+
?>
|
764 |
+
<textarea name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"></textarea>
|
765 |
+
<?php
|
766 |
+
if ( ! empty( $field['description'] ) ) {
|
767 |
+
$this->input_field_description( $field['description'] );
|
768 |
+
}
|
769 |
+
}
|
770 |
+
|
771 |
+
/**
|
772 |
+
* Sanitize a value to be used as a PHP function name.
|
773 |
+
*
|
774 |
+
* @param string $value The name you want sanitized.
|
775 |
+
*
|
776 |
+
* @return string
|
777 |
+
*/
|
778 |
+
public function sanitize_function_name( $value ) {
|
779 |
+
return str_replace( '-', '_', sanitize_title_with_dashes( $value ) );
|
780 |
+
}
|
781 |
+
}
|
includes/generator/class-wpcode-generator-widget.php
ADDED
@@ -0,0 +1,572 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a snippet to add a custom Widget.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WPCode_Generator_Script class.
|
10 |
+
*/
|
11 |
+
class WPCode_Generator_Widget extends WPCode_Generator_Type {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The generator slug.
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $name = 'widget';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The categories for this generator.
|
22 |
+
*
|
23 |
+
* @var string[]
|
24 |
+
*/
|
25 |
+
public $categories = array(
|
26 |
+
'design',
|
27 |
+
);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set the translatable strings.
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
protected function set_strings() {
|
35 |
+
$this->title = __( 'Widget', 'insert-headers-and-footers' );
|
36 |
+
$this->description = __( 'Generate a snippet to register a custom sidebar widget for your website.', 'insert-headers-and-footers' );
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Load the generator tabs.
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
protected function load_tabs() {
|
45 |
+
$this->tabs = array(
|
46 |
+
'info' => array(
|
47 |
+
'label' => __( 'Info', 'insert-headers-and-footers' ),
|
48 |
+
'columns' => array(
|
49 |
+
// Column 1.
|
50 |
+
array(
|
51 |
+
// Column 1 fields.
|
52 |
+
array(
|
53 |
+
'type' => 'description',
|
54 |
+
'label' => __( 'Overview', 'insert-headers-and-footers' ),
|
55 |
+
'content' => __( 'Using this generator you can easily add a custom sidebar widget with settings.', 'insert-headers-and-footers' ),
|
56 |
+
),
|
57 |
+
),
|
58 |
+
// Column 2.
|
59 |
+
array(
|
60 |
+
// Column 2 fields.
|
61 |
+
array(
|
62 |
+
'type' => 'list',
|
63 |
+
'label' => __( 'Usage', 'insert-headers-and-footers' ),
|
64 |
+
'content' => array(
|
65 |
+
__( 'Fill in the forms using the menu on the left.', 'insert-headers-and-footers' ),
|
66 |
+
__( 'Click the "Update Code" button.', 'insert-headers-and-footers' ),
|
67 |
+
__( 'Click on "Use Snippet" to create a new snippet with the generated code.', 'insert-headers-and-footers' ),
|
68 |
+
__( 'Activate and save the snippet and you\'re ready to go', 'insert-headers-and-footers' ),
|
69 |
+
),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
// Column 3.
|
73 |
+
array(
|
74 |
+
// Column 3 fields.
|
75 |
+
array(
|
76 |
+
'type' => 'description',
|
77 |
+
'label' => __( 'Examples', 'insert-headers-and-footers' ),
|
78 |
+
'content' => __( 'Sidebar widgets are very useful when you want to display the same content on multiple pages, you can create a widget with contact methods, for example and fields to set a phone number, email, etc.', 'insert-headers-and-footers' ),
|
79 |
+
),
|
80 |
+
),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
'general' => array(
|
84 |
+
'label' => __( 'General', 'insert-headers-and-footers' ),
|
85 |
+
'columns' => array(
|
86 |
+
// Column 1.
|
87 |
+
array(
|
88 |
+
array(
|
89 |
+
'type' => 'text',
|
90 |
+
'label' => __( 'Class name', 'insert-headers-and-footers' ),
|
91 |
+
'description' => __( 'Make this unique to avoid conflicts with other similar snippets.', 'insert-headers-and-footers' ),
|
92 |
+
'id' => 'class_name',
|
93 |
+
'placeholder' => 'Custom_Generated_Widget',
|
94 |
+
'default' => 'Custom_Generated_Widget' . time(),
|
95 |
+
// This makes it unique for people who don't want to customize.
|
96 |
+
),
|
97 |
+
),
|
98 |
+
// Column 2.
|
99 |
+
array(
|
100 |
+
array(
|
101 |
+
'type' => 'text',
|
102 |
+
'label' => __( 'Prefix', 'insert-headers-and-footers' ),
|
103 |
+
'description' => __( 'Used to prefix all the field names.', 'insert-headers-and-footers' ),
|
104 |
+
'id' => 'prefix',
|
105 |
+
'placeholder' => 'custom_',
|
106 |
+
'default' => 'custom' . time() . '_',
|
107 |
+
),
|
108 |
+
),
|
109 |
+
// Column 3.
|
110 |
+
array(
|
111 |
+
array(
|
112 |
+
'type' => 'text',
|
113 |
+
'label' => __( 'Text Domain', 'insert-headers-and-footers' ),
|
114 |
+
'description' => __( 'Optional textdomain for translations.', 'insert-headers-and-footers' ),
|
115 |
+
'id' => 'text_domain',
|
116 |
+
'placeholder' => 'text_domain',
|
117 |
+
'default' => 'text_domain',
|
118 |
+
),
|
119 |
+
),
|
120 |
+
),
|
121 |
+
),
|
122 |
+
'widget' => array(
|
123 |
+
'label' => __( 'Widget', 'insert-headers-and-footers' ),
|
124 |
+
'columns' => array(
|
125 |
+
// Column 1.
|
126 |
+
array(
|
127 |
+
array(
|
128 |
+
'type' => 'text',
|
129 |
+
'label' => __( 'Widget ID', 'insert-headers-and-footers' ),
|
130 |
+
'description' => __( 'Unique id for the widget, used in the code.', 'insert-headers-and-footers' ),
|
131 |
+
'id' => 'widget_id',
|
132 |
+
'name' => 'widget_id',
|
133 |
+
'default' => 'custom_widget_id',
|
134 |
+
'placeholder' => '',
|
135 |
+
),
|
136 |
+
array(
|
137 |
+
'type' => 'text',
|
138 |
+
'label' => __( 'Widget Title', 'insert-headers-and-footers' ),
|
139 |
+
'description' => __( 'The title of the widget (displayed in the admin).', 'insert-headers-and-footers' ),
|
140 |
+
'id' => 'widget_title',
|
141 |
+
'name' => 'widget_title',
|
142 |
+
'default' => 'Custom Widget',
|
143 |
+
'placeholder' => '',
|
144 |
+
),
|
145 |
+
),
|
146 |
+
// Column 2.
|
147 |
+
array(
|
148 |
+
array(
|
149 |
+
'type' => 'text',
|
150 |
+
'label' => __( 'Description', 'insert-headers-and-footers' ),
|
151 |
+
'description' => __( 'Description used in the admin to explain what the widget is used for.', 'insert-headers-and-footers' ),
|
152 |
+
'id' => 'description',
|
153 |
+
'name' => 'description',
|
154 |
+
'default' => 'This is a custom widget generated with WPCode',
|
155 |
+
),
|
156 |
+
array(
|
157 |
+
'type' => 'text',
|
158 |
+
'label' => __( 'CSS Class', 'insert-headers-and-footers' ),
|
159 |
+
'description' => __( 'Widget-specific CSS class name.', 'insert-headers-and-footers' ),
|
160 |
+
'id' => 'css_class',
|
161 |
+
'default' => 'custom-generated-widget',
|
162 |
+
),
|
163 |
+
),
|
164 |
+
// Column 3.
|
165 |
+
array(
|
166 |
+
array(
|
167 |
+
'type' => 'textarea',
|
168 |
+
'label' => __( 'Widget Output Code', 'insert-headers-and-footers' ),
|
169 |
+
'description' => __( 'PHP Code used for outputting the fields in the frontend. If left empty it will output the fields values in a simple list.', 'insert-headers-and-footers' ),
|
170 |
+
'id' => 'code',
|
171 |
+
'code' => true,
|
172 |
+
),
|
173 |
+
),
|
174 |
+
),
|
175 |
+
),
|
176 |
+
'fields' => array(
|
177 |
+
'label' => __( 'Fields', 'insert-headers-and-footers' ),
|
178 |
+
'columns' => array(
|
179 |
+
// Column 1.
|
180 |
+
array(
|
181 |
+
array(
|
182 |
+
'type' => 'select',
|
183 |
+
'label' => __( 'Field Type', 'insert-headers-and-footers' ),
|
184 |
+
'description' => __( 'Pick the type of field you want to use for this setting.', 'insert-headers-and-footers' ),
|
185 |
+
'id' => 'field_type',
|
186 |
+
'name' => 'field_type[]',
|
187 |
+
'options' => array(
|
188 |
+
'text' => __( 'Text', 'insert-headers-and-footers' ),
|
189 |
+
'email' => __( 'Email', 'insert-headers-and-footers' ),
|
190 |
+
'url' => __( 'URL', 'insert-headers-and-footers' ),
|
191 |
+
'number' => __( 'Number', 'insert-headers-and-footers' ),
|
192 |
+
'textarea' => __( 'Textarea', 'insert-headers-and-footers' ),
|
193 |
+
'select' => __( 'Select', 'insert-headers-and-footers' ),
|
194 |
+
'checkbox' => __( 'Checkboxes', 'insert-headers-and-footers' ),
|
195 |
+
'radio' => __( 'Radio', 'insert-headers-and-footers' ),
|
196 |
+
),
|
197 |
+
'repeater' => 'fields',
|
198 |
+
),
|
199 |
+
array(
|
200 |
+
'type' => 'text',
|
201 |
+
'label' => __( 'Field ID', 'insert-headers-and-footers' ),
|
202 |
+
'description' => __( 'Unique id for this field, used in the code.', 'insert-headers-and-footers' ),
|
203 |
+
'id' => 'field_id',
|
204 |
+
'name' => 'field_id[]',
|
205 |
+
'repeater' => 'fields',
|
206 |
+
),
|
207 |
+
array(
|
208 |
+
'type' => 'text',
|
209 |
+
'label' => __( 'Field Label', 'insert-headers-and-footers' ),
|
210 |
+
'description' => __( 'The label displayed next to this field in the admin form.', 'insert-headers-and-footers' ),
|
211 |
+
'id' => 'field_label',
|
212 |
+
'name' => 'field_label[]',
|
213 |
+
'repeater' => 'fields',
|
214 |
+
),
|
215 |
+
array(
|
216 |
+
'type' => 'spacer',
|
217 |
+
),
|
218 |
+
),
|
219 |
+
// Column 2.
|
220 |
+
array(
|
221 |
+
array(
|
222 |
+
'type' => 'text',
|
223 |
+
'label' => __( 'Description', 'insert-headers-and-footers' ),
|
224 |
+
'description' => __( 'Display a short descriptive text below this field.', 'insert-headers-and-footers' ),
|
225 |
+
'id' => 'field_description',
|
226 |
+
'name' => 'field_description[]',
|
227 |
+
'repeater' => 'fields',
|
228 |
+
),
|
229 |
+
array(
|
230 |
+
'type' => 'text',
|
231 |
+
'label' => __( 'Default', 'insert-headers-and-footers' ),
|
232 |
+
'description' => __( 'Set the default value for this field.', 'insert-headers-and-footers' ),
|
233 |
+
'id' => 'field_default',
|
234 |
+
'name' => 'field_default[]',
|
235 |
+
'repeater' => 'fields',
|
236 |
+
),
|
237 |
+
array(
|
238 |
+
'type' => 'textarea',
|
239 |
+
'label' => __( 'Options', 'insert-headers-and-footers' ),
|
240 |
+
'description' => __( 'Use value|label for each line to add options for select, checkbox or radio.', 'insert-headers-and-footers' ),
|
241 |
+
'id' => 'field_options',
|
242 |
+
'name' => 'field_options[]',
|
243 |
+
'repeater' => 'fields',
|
244 |
+
),
|
245 |
+
),
|
246 |
+
// Column 3.
|
247 |
+
array(
|
248 |
+
array(
|
249 |
+
'type' => 'description',
|
250 |
+
'label' => __( 'Add another field', 'insert-headers-and-footers' ),
|
251 |
+
'content' => __( 'Use the "Add field" button below to add as many fields as you need.', 'insert-headers-and-footers' ),
|
252 |
+
),
|
253 |
+
array(
|
254 |
+
'type' => 'repeater_button',
|
255 |
+
'button_text' => __( 'Add field', 'insert-headers-and-footers' ),
|
256 |
+
'id' => 'fields', // Repeater to repeat when clicked.
|
257 |
+
),
|
258 |
+
),
|
259 |
+
),
|
260 |
+
),
|
261 |
+
);
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Dynamically get the code for a widget field by type.
|
266 |
+
*
|
267 |
+
* @param string $type The type of field.
|
268 |
+
* @param string $id The field id.
|
269 |
+
* @param string $label The field label.
|
270 |
+
* @param string $description The field description.
|
271 |
+
* @param string $options The options for fields that have options.
|
272 |
+
*
|
273 |
+
* @return mixed|string
|
274 |
+
*/
|
275 |
+
public function get_widget_field_code( $type, $id, $label, $description, $options ) {
|
276 |
+
if ( ! method_exists( $this, 'widget_field_' . $type ) ) {
|
277 |
+
return '';
|
278 |
+
}
|
279 |
+
$options = preg_split( "/\r\n|[\r\n]/", $options );
|
280 |
+
$processed_options = array();
|
281 |
+
foreach ( $options as $option ) {
|
282 |
+
$split_option = explode( '|', $option );
|
283 |
+
$processed_options[ $split_option[0] ] = $split_option[0];
|
284 |
+
if ( isset( $split_option[1] ) ) {
|
285 |
+
$processed_options[ $split_option[0] ] = $split_option[1];
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
return call_user_func_array(
|
290 |
+
array( $this, 'widget_field_' . $type ),
|
291 |
+
array(
|
292 |
+
$id,
|
293 |
+
$label,
|
294 |
+
$description,
|
295 |
+
$processed_options,
|
296 |
+
)
|
297 |
+
);
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Get the code for a text field.
|
302 |
+
*
|
303 |
+
* @param string $id The field id.
|
304 |
+
* @param string $label The field label.
|
305 |
+
* @param string $description The field description.
|
306 |
+
* @param array $options The field options (unused here).
|
307 |
+
* @param string $type The input type, so we can reuse this for similar fields.
|
308 |
+
*
|
309 |
+
* @return string
|
310 |
+
*/
|
311 |
+
public function widget_field_text( $id, $label, $description, $options = array(), $type = 'text' ) {
|
312 |
+
return "
|
313 |
+
echo '<p>';
|
314 |
+
echo '<label for=\"'. \$this->get_field_id( '$id' ) .'\">'. __( '$label', '{$this->get_value( 'text_domain' ) }' ) .'</label>';
|
315 |
+
echo '<input type=\"$type\" id=\"'. \$this->get_field_id( '$id' ) .'\" name=\"'. \$this->get_field_name( '$id' ) .'\" class=\"widefat\" value=\"'. esc_attr(\$instance['$id']) .'\" />';
|
316 |
+
{$this->widget_field_description( $description )}
|
317 |
+
echo '</p>';
|
318 |
+
";
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Email field, uses the text field with a different input type.
|
323 |
+
*
|
324 |
+
* @param string $id The field id.
|
325 |
+
* @param string $label The field label.
|
326 |
+
* @param string $description The field description.
|
327 |
+
* @param array $options The field options (unused here).
|
328 |
+
*
|
329 |
+
* @return string
|
330 |
+
*/
|
331 |
+
public function widget_field_email( $id, $label, $description, $options = array() ) {
|
332 |
+
return $this->widget_field_text( $id, $label, $description, $options, 'email' );
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* URL field, uses the text field with a different input type.
|
337 |
+
*
|
338 |
+
* @param string $id The field id.
|
339 |
+
* @param string $label The field label.
|
340 |
+
* @param string $description The field description.
|
341 |
+
* @param array $options The field options (unused here).
|
342 |
+
*
|
343 |
+
* @return string
|
344 |
+
*/
|
345 |
+
public function widget_field_url( $id, $label, $description, $options = array() ) {
|
346 |
+
return $this->widget_field_text( $id, $label, $description, $options, 'url' );
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Number field, uses the text field with a different input type.
|
351 |
+
*
|
352 |
+
* @param string $id The field id.
|
353 |
+
* @param string $label The field label.
|
354 |
+
* @param string $description The field description.
|
355 |
+
* @param array $options The field options (unused here).
|
356 |
+
*
|
357 |
+
* @return string
|
358 |
+
*/
|
359 |
+
public function widget_field_number( $id, $label, $description, $options = array() ) {
|
360 |
+
return $this->widget_field_text( $id, $label, $description, $options, 'number' );
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Textarea field.
|
365 |
+
*
|
366 |
+
* @param string $id The field id.
|
367 |
+
* @param string $label The field label.
|
368 |
+
* @param string $description The field description.
|
369 |
+
* @param array $options The field options (unused here).
|
370 |
+
*
|
371 |
+
* @return string
|
372 |
+
*/
|
373 |
+
public function widget_field_textarea( $id, $label, $description, $options = array() ) {
|
374 |
+
return "
|
375 |
+
echo '<p>';
|
376 |
+
echo '<label for=\"'. \$this->get_field_id( '$id' ) .'\">'. __( '$label', '{$this->get_value( 'text_domain' ) }' ) .'</label>';
|
377 |
+
echo '<textarea id=\"'. \$this->get_field_id( '$id' ) .'\" name=\"'. \$this->get_field_name( '$id' ) .'\" class=\"widefat\">'. esc_html(\$instance['$id']) .'</textarea>';
|
378 |
+
{$this->widget_field_description( $description )}
|
379 |
+
echo '</p>';
|
380 |
+
";
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Get the code for a text field.
|
385 |
+
*
|
386 |
+
* @param string $id The field id.
|
387 |
+
* @param string $label The field label.
|
388 |
+
* @param string $description The field description.
|
389 |
+
* @param string $options The field options.
|
390 |
+
*
|
391 |
+
* @return string
|
392 |
+
*/
|
393 |
+
public function widget_field_select( $id, $label, $description, $options = array() ) {
|
394 |
+
$field_code = "
|
395 |
+
echo '<p>';
|
396 |
+
echo '<label for=\"'. \$this->get_field_id( '$id' ) .'\">'. __( '$label', '{$this->get_value( 'text_domain' ) }' ) .'</label>';
|
397 |
+
echo '<select id=\"'. \$this->get_field_id( '$id' ) .'\" name=\"'. \$this->get_field_name( '$id' ) .'\" class=\"widefat\">';";
|
398 |
+
|
399 |
+
foreach ( $options as $value => $label ) {
|
400 |
+
if ( empty( $value ) ) {
|
401 |
+
continue;
|
402 |
+
}
|
403 |
+
$field_code .= "\n\t\t echo'<option value=\"$value\" '. selected('$value', \$instance['$id'], false) .'>$label</option>';";
|
404 |
+
}
|
405 |
+
$field_code .= "\n\t\techo '</select>';
|
406 |
+
{$this->widget_field_description( $description )}
|
407 |
+
echo '</p>';";
|
408 |
+
|
409 |
+
return $field_code;
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Get the code for a checkbox field.
|
414 |
+
*
|
415 |
+
* @param string $id The field id.
|
416 |
+
* @param string $label The field label.
|
417 |
+
* @param string $description The field description.
|
418 |
+
* @param string $options The field options.
|
419 |
+
*
|
420 |
+
* @return string
|
421 |
+
*/
|
422 |
+
public function widget_field_checkbox( $id, $label, $description, $options = array() ) {
|
423 |
+
$field_code = "
|
424 |
+
echo '<p>';
|
425 |
+
echo '<label for=\"'. \$this->get_field_id( '$id' ) .'\">'. __( '$label', '{$this->get_value( 'text_domain' ) }' ) .'</label>';";
|
426 |
+
foreach ( $options as $value => $label ) {
|
427 |
+
if ( empty( $value ) ) {
|
428 |
+
continue;
|
429 |
+
}
|
430 |
+
$field_code .= "\n\t\t echo'<div><label><input type=\"checkbox\" value=\"$value\" '. checked( in_array( '$value', \$instance['$id'], true ), true, false) .' name=\"'. \$this->get_field_name( '$id' ) .'[]\"> $label</label></div>';";
|
431 |
+
}
|
432 |
+
$field_code .= "{$this->widget_field_description( $description )}
|
433 |
+
echo '</p>';";
|
434 |
+
|
435 |
+
return $field_code;
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Get the code for a radio field.
|
440 |
+
*
|
441 |
+
* @param string $id The field id.
|
442 |
+
* @param string $label The field label.
|
443 |
+
* @param string $description The field description.
|
444 |
+
* @param string $options The field options.
|
445 |
+
*
|
446 |
+
* @return string
|
447 |
+
*/
|
448 |
+
public function widget_field_radio( $id, $label, $description, $options = array() ) {
|
449 |
+
$field_code = "
|
450 |
+
echo '<p>';
|
451 |
+
echo '<label for=\"'. \$this->get_field_id( '$id' ) .'\">'. __( '$label', '{$this->get_value( 'text_domain' ) }' ) .'</label>';";
|
452 |
+
foreach ( $options as $value => $label ) {
|
453 |
+
if ( empty( $value ) ) {
|
454 |
+
continue;
|
455 |
+
}
|
456 |
+
$field_code .= "\n\t\t echo'<div><label><input type=\"radio\" value=\"$value\" '. checked( '$value', \$instance['$id'], false) .' name=\"'. \$this->get_field_name( '$id' ) .'\"> $label</label></div>';";
|
457 |
+
}
|
458 |
+
$field_code .= "\n{$this->widget_field_description( $description )}
|
459 |
+
echo '</p>';";
|
460 |
+
|
461 |
+
return $field_code;
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* Get standard markup for the description of a field.
|
466 |
+
*
|
467 |
+
* @param string $description The field description.
|
468 |
+
*
|
469 |
+
* @return string
|
470 |
+
*/
|
471 |
+
public function widget_field_description( $description ) {
|
472 |
+
if ( empty( $description ) ) {
|
473 |
+
return '';
|
474 |
+
}
|
475 |
+
|
476 |
+
return "echo '<span class=\"description\">' . __( '$description', '{$this->get_value( 'text_domain' ) }' ) . '</span>';";
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Get the snippet code with dynamic values applied.
|
481 |
+
*
|
482 |
+
* @return string
|
483 |
+
*/
|
484 |
+
public function get_snippet_code() {
|
485 |
+
|
486 |
+
$instance_defaults = '';
|
487 |
+
$fields_markup = '';
|
488 |
+
|
489 |
+
$fields = $this->get_value( 'field_id' );
|
490 |
+
$labels = $this->get_value( 'field_label' );
|
491 |
+
$values = $this->get_value( 'field_default' );
|
492 |
+
$type = $this->get_value( 'field_type' );
|
493 |
+
$options = $this->get_value( 'field_options' );
|
494 |
+
$descriptions = $this->get_value( 'field_description' );
|
495 |
+
|
496 |
+
if ( ! empty( $fields ) && is_array( $fields ) ) {
|
497 |
+
foreach ( $fields as $key => $field_id ) {
|
498 |
+
if ( empty( $field_id ) ) {
|
499 |
+
continue;
|
500 |
+
}
|
501 |
+
$value = "'$values[$key]'";
|
502 |
+
if ( 'checkbox' === $type[ $key ] ) {
|
503 |
+
$value = "array('$values[$key]')";
|
504 |
+
}
|
505 |
+
$instance_defaults .= "\t\t\t'$field_id' => $value,\n";
|
506 |
+
|
507 |
+
$fields_markup .= $this->get_widget_field_code( $type[ $key ], $field_id, $labels[ $key ], $descriptions[ $key ], $options[ $key ] );
|
508 |
+
}
|
509 |
+
}
|
510 |
+
|
511 |
+
$widget_output = $this->get_value( 'code' );
|
512 |
+
if ( empty( $widget_output ) && ! empty( $fields ) && is_array( $fields ) ) {
|
513 |
+
// If there's no custom PHP code for the output build a simple list output.
|
514 |
+
$widget_output = "\n\t\techo '<ul>';\n";
|
515 |
+
foreach ( $fields as $key => $field_id ) {
|
516 |
+
if ( empty( $field_id ) ) {
|
517 |
+
continue;
|
518 |
+
}
|
519 |
+
$value = "\$instance['$field_id']";
|
520 |
+
if ( 'checkbox' === $type[ $key ] ) {
|
521 |
+
$value = "implode( ', ', $value )";
|
522 |
+
}
|
523 |
+
$widget_output .= "\t\t\techo '<li>{$labels[ $key ]}: ' . $value . '</li>';\n";
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
$widget_output .= "\t\techo '</ul>';\n";
|
528 |
+
}
|
529 |
+
|
530 |
+
return <<<EOD
|
531 |
+
class {$this->get_value( 'class_name' )} extends WP_Widget {
|
532 |
+
|
533 |
+
public function __construct() {
|
534 |
+
parent::__construct(
|
535 |
+
'{$this->get_value( 'widget_id' )}',
|
536 |
+
__( '{$this->get_value( 'widget_title' )}', '{$this->get_value( 'text_domain' )}' ),
|
537 |
+
array(
|
538 |
+
'description' => __( '{$this->get_value( 'description' )}', '{$this->get_value( 'text_domain' )}' ),
|
539 |
+
'classname' => '{$this->get_value( 'css_class' )}',
|
540 |
+
)
|
541 |
+
);
|
542 |
+
}
|
543 |
+
|
544 |
+
public function widget( \$args, \$instance ) {
|
545 |
+
\$instance = wp_parse_args( (array) \$instance, array(
|
546 |
+
$instance_defaults\t\t) );
|
547 |
+
// Before widget tag
|
548 |
+
echo \$args['before_widget'];
|
549 |
+
{$widget_output}
|
550 |
+
// After widget tag
|
551 |
+
echo \$args['after_widget'];
|
552 |
+
}
|
553 |
+
|
554 |
+
public function form( \$instance ) {
|
555 |
+
// Set default values
|
556 |
+
\$instance = wp_parse_args( (array) \$instance, array(
|
557 |
+
$instance_defaults\t\t) );
|
558 |
+
|
559 |
+
$fields_markup
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
|
564 |
+
function {$this->get_value( 'prefix' )}register_widgets() {
|
565 |
+
register_widget( '{$this->get_value( 'class_name' )}' );
|
566 |
+
}
|
567 |
+
add_action( 'widgets_init', '{$this->get_value( 'prefix' )}register_widgets' );
|
568 |
+
|
569 |
+
EOD;
|
570 |
+
}
|
571 |
+
|
572 |
+
}
|
includes/global-output.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add hooks to output global scripts.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
add_action( 'wp_head', 'wpcode_global_frontend_header' );
|
9 |
+
add_action( 'wp_footer', 'wpcode_global_frontend_footer' );
|
10 |
+
add_action( 'wp_body_open', 'wpcode_global_frontend_body', 1 );
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Output the frontend head scripts.
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
function wpcode_global_frontend_header() {
|
18 |
+
// Filter to prevent specific header output.
|
19 |
+
if ( apply_filters( 'disable_ihaf_header', false ) ) {
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
wpcode_global_script_output( 'ihaf_insert_header' );
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Output the frontend footer scripts.
|
27 |
+
*
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
function wpcode_global_frontend_footer() {
|
31 |
+
// Filter to prevent specific footer output.
|
32 |
+
if ( apply_filters( 'disable_ihaf_footer', false ) ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
wpcode_global_script_output( 'ihaf_insert_footer' );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Output the frontend body scripts.
|
40 |
+
*
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
+
function wpcode_global_frontend_body() {
|
44 |
+
// Filter to prevent specific body output.
|
45 |
+
if ( apply_filters( 'disable_ihaf_body', false ) ) {
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
wpcode_global_script_output( 'ihaf_insert_body' );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Output everything through this function to get a chance to apply some checks.
|
53 |
+
*
|
54 |
+
* @param string $option_name The option name to grab data from.
|
55 |
+
*
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
function wpcode_global_script_output( $option_name ) {
|
59 |
+
// Ignore admin, feed, robots or trackbacks.
|
60 |
+
if ( is_admin() || is_feed() || is_robots() || is_trackback() ) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
// Filter to prevent any output.
|
64 |
+
if ( apply_filters( 'disable_ihaf', false ) ) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
$code = get_option( $option_name );
|
69 |
+
if ( empty( $code ) || empty( trim( $code ) ) ) {
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
echo wp_unslash( $code );
|
74 |
+
}
|
includes/helpers.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generic helpers used in the plugin.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Get a URL with UTM parameters.
|
10 |
+
*
|
11 |
+
* @param string $url The URL to add the params to.
|
12 |
+
* @param string $medium The marketing medium.
|
13 |
+
* @param string $campaign The campaign.
|
14 |
+
*
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
function wpcode_utm_url( $url, $medium = '', $campaign = '' ) {
|
18 |
+
return add_query_arg(
|
19 |
+
array(
|
20 |
+
'utm_source' => 'plugin',
|
21 |
+
'utm_medium' => sanitize_key( $medium ),
|
22 |
+
'utm_campaign' => sanitize_key( $campaign ),
|
23 |
+
'utm_content' => WPCode()->version,
|
24 |
+
),
|
25 |
+
$url
|
26 |
+
);
|
27 |
+
}
|
includes/icons.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handle all svg icons in one place.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Get an SVG icon by name with width, height and viewbox options.
|
10 |
+
*
|
11 |
+
* @param string $name The name of the icon.
|
12 |
+
* @param int $width The width.
|
13 |
+
* @param int $height The height.
|
14 |
+
* @param string $viewbox The viewbox, will be auto-built from width and height if not set.
|
15 |
+
*
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
function get_wpcode_icon( $name, $width = 20, $height = 20, $viewbox = '' ) {
|
19 |
+
$icons = wpcode_icons();
|
20 |
+
|
21 |
+
if ( ! isset( $icons[ $name ] ) ) {
|
22 |
+
return '';
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( empty( $viewbox ) ) {
|
26 |
+
$viewbox = sprintf( '0 0 %1$s %2$s', $width, $height );
|
27 |
+
}
|
28 |
+
|
29 |
+
return sprintf(
|
30 |
+
'<svg class="wpcode-icon wpcode-icon-%5$s" width="%1$s" height="%2$s" viewBox="%3$s" fill="none" xmlns="http://www.w3.org/2000/svg">%4$s</svg>',
|
31 |
+
$width,
|
32 |
+
$height,
|
33 |
+
$viewbox,
|
34 |
+
$icons[ $name ],
|
35 |
+
$name
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Echo an icon in a safe mode.
|
41 |
+
*
|
42 |
+
* @param string $name The name of the icon.
|
43 |
+
* @param int $width The width.
|
44 |
+
* @param int $height The height.
|
45 |
+
* @param string $viewbox The viewbox, will be auto-built from width and height if not set.
|
46 |
+
*
|
47 |
+
* @return void
|
48 |
+
*/
|
49 |
+
function wpcode_icon( $name, $width = 20, $height = 20, $viewbox = '' ) {
|
50 |
+
$icon = get_wpcode_icon( $name, $width, $height, $viewbox );
|
51 |
+
|
52 |
+
if ( ! empty( $icon ) ) {
|
53 |
+
echo wp_kses(
|
54 |
+
$icon,
|
55 |
+
array(
|
56 |
+
'svg' => array(
|
57 |
+
'class' => true,
|
58 |
+
'aria-hidden' => true,
|
59 |
+
'aria-labelledby' => true,
|
60 |
+
'role' => true,
|
61 |
+
'xmlns' => true,
|
62 |
+
'width' => true,
|
63 |
+
'height' => true,
|
64 |
+
'viewbox' => true,
|
65 |
+
),
|
66 |
+
'g' => array( 'fill' => true ),
|
67 |
+
'title' => array( 'title' => true ),
|
68 |
+
'path' => array(
|
69 |
+
'd' => true,
|
70 |
+
'fill' => true,
|
71 |
+
'fill-rule' => true,
|
72 |
+
'clip-rule' => true,
|
73 |
+
),
|
74 |
+
'circle' => array(
|
75 |
+
'cx' => true,
|
76 |
+
'cy' => true,
|
77 |
+
'r' => true,
|
78 |
+
'stroke' => true,
|
79 |
+
'stroke-width' => true,
|
80 |
+
'fill' => true,
|
81 |
+
),
|
82 |
+
'rect' => array(
|
83 |
+
'x' => true,
|
84 |
+
'y' => true,
|
85 |
+
'width' => true,
|
86 |
+
'height' => true,
|
87 |
+
'fill' => true,
|
88 |
+
),
|
89 |
+
)
|
90 |
+
);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Get the whole array of WPCode SVG icons.
|
96 |
+
*
|
97 |
+
* @return array
|
98 |
+
*/
|
99 |
+
function wpcode_icons() {
|
100 |
+
return (array) apply_filters(
|
101 |
+
'wpcode_icons',
|
102 |
+
array(
|
103 |
+
'logo' => '<path fill-rule="evenodd" clip-rule="evenodd" d="M57.5706 64H6.56732C2.89985 64 0 61.1064 0 57.4468V6.55319C0 2.89362 2.89985 0 6.56732 0H57.5706C61.2381 0 64.1379 2.89362 64.1379 6.55319V57.4468C64.1379 61.1064 61.2381 64 57.5706 64ZM15.863 52.0855C15.5219 52.0855 15.0954 52.0004 14.7543 51.9153C13.2191 51.3196 12.4515 49.6175 13.0485 48.0855L26.439 13.7877C27.036 12.2558 28.7418 11.4898 30.277 12.0855C31.8122 12.6813 32.5798 14.3834 31.9828 15.9153L18.6776 50.2132C18.2512 51.4047 17.0571 52.0855 15.863 52.0855ZM35.0534 47.7445C35.6504 48.3403 36.418 48.5956 37.1856 48.5956C37.9532 48.5956 38.7208 48.3403 39.3179 47.7445L49.8085 37.3616C51.6849 35.4892 51.6849 32.3403 49.8085 30.468L39.3179 19.9999C38.2091 18.8084 36.3327 18.8084 35.1386 19.9999C33.9446 21.1063 33.9446 22.9786 35.1386 24.1701L44.7764 33.8722L35.0534 43.5743C33.8593 44.6807 33.8593 46.5531 35.0534 47.7445Z" fill="white"/>',
|
104 |
+
'auto' => '<path d="M9.36005 5.61394V8.56131L13.64 4.63148L9.36005 0.70166V3.64903C4.63065 3.64903 0.800049 7.16622 0.800049 11.5087C0.800049 13.0511 1.29225 14.4855 2.12685 15.6939L3.68905 14.2596C3.20755 13.4441 2.94005 12.501 2.94005 11.5087C2.94005 8.25675 5.81835 5.61394 9.36005 5.61394ZM16.5932 7.32341L15.031 8.7578C15.5018 9.58306 15.78 10.5164 15.78 11.5087C15.78 14.7606 12.9017 17.4034 9.36005 17.4034V14.456L5.08005 18.3859L9.36005 22.3157V19.3683C14.0894 19.3683 17.92 15.8511 17.92 11.5087C17.92 9.96622 17.4278 8.53183 16.5932 7.32341Z" fill="#454545"/>',
|
105 |
+
'shortcode' => '<path d="M0 0.137207H4.47458V1.89055H2.40664V14.2398H4.47458V16.0016H0V0.137207Z" fill="#454545"/><path d="M13.885 0.137207H16.2713L10.5019 16.0016H8.13574L13.885 0.137207Z" fill="#454545"/><path d="M24 0.137207H19.5254V1.89055H21.5934V14.2398H19.5254V16.0016H24V0.137207Z" fill="#454545"/>',
|
106 |
+
'copy' => '<path d="M10.8125 1.125H3.3125C2.625 1.125 2.0625 1.6875 2.0625 2.375V11.125H3.3125V2.375H10.8125V1.125ZM12.6875 3.625H5.8125C5.125 3.625 4.5625 4.1875 4.5625 4.875V13.625C4.5625 14.3125 5.125 14.875 5.8125 14.875H12.6875C13.375 14.875 13.9375 14.3125 13.9375 13.625V4.875C13.9375 4.1875 13.375 3.625 12.6875 3.625ZM12.6875 13.625H5.8125V4.875H12.6875V13.625Z" fill="#777777"/>',
|
107 |
+
'check' => '<path d="M5.8002 10.9L1.6002 6.70005L0.200195 8.10005L5.8002 13.7L17.8002 1.70005L16.4002 0.300049L5.8002 10.9Z" fill="#777777"/>',
|
108 |
+
'remove' => '<circle cx="10" cy="10" r="9" stroke="#777777" stroke-width="2"/><rect x="4.6156" y="9.23071" width="10.7692" height="1.53846" fill="#777777"/>',
|
109 |
+
'search' => '<path d="M11.1292 9.87907H10.4709L10.2375 9.65407C11.0542 8.70407 11.5459 7.47074 11.5459 6.12907C11.5459 3.1374 9.12086 0.712402 6.12919 0.712402C3.13752 0.712402 0.712524 3.1374 0.712524 6.12907C0.712524 9.12074 3.13752 11.5457 6.12919 11.5457C7.47086 11.5457 8.70419 11.0541 9.65419 10.2374L9.87919 10.4707V11.1291L14.0459 15.2874L15.2875 14.0457L11.1292 9.87907ZM6.12919 9.87907C4.05419 9.87907 2.37919 8.20407 2.37919 6.12907C2.37919 4.05407 4.05419 2.37907 6.12919 2.37907C8.20419 2.37907 9.87919 4.05407 9.87919 6.12907C9.87919 8.20407 8.20419 9.87907 6.12919 9.87907Z" fill="#BBBBBB"/>',
|
110 |
+
'close' => '<path d="M14.5649 1.41L13.1587 0L7.58348 5.59L2.00831 0L0.602051 1.41L6.17722 7L0.602051 12.59L2.00831 14L7.58348 8.41L13.1587 14L14.5649 12.59L8.98974 7L14.5649 1.41Z" fill="#8C8F9A"/>',
|
111 |
+
'upload' => '<path d="M10.5 8.25V10.5H1.5V8.25H0V10.5C0 11.325 0.675 12 1.5 12H10.5C11.325 12 12 11.325 12 10.5V8.25H10.5ZM2.25 3.75L3.3075 4.8075L5.25 2.8725V9H6.75V2.8725L8.6925 4.8075L9.75 3.75L6 0L2.25 3.75Z" fill="#777777"/>',
|
112 |
+
'folder' => '<path d="M10.2266 3.00016L12.8933 5.66683H24.6666V19.0002H3.33329V3.00016H10.2266ZM11.3333 0.333496H3.33329C1.86663 0.333496 0.679959 1.5335 0.679959 3.00016L0.666626 19.0002C0.666626 20.4668 1.86663 21.6668 3.33329 21.6668H24.6666C26.1333 21.6668 27.3333 20.4668 27.3333 19.0002V5.66683C27.3333 4.20016 26.1333 3.00016 24.6666 3.00016H14L11.3333 0.333496Z" fill="#777777"/>',
|
113 |
+
'arrow' => '<path d="M1.94006 0L0.0600586 1.88L6.16673 8L0.0600586 14.12L1.94006 16L9.94006 8L1.94006 0Z" fill="#777777"/>',
|
114 |
+
'file-text' => '<path d="M13.8333 2.16667V13.8333H2.16667V2.16667H13.8333ZM13.8333 0.5H2.16667C1.25 0.5 0.5 1.25 0.5 2.16667V13.8333C0.5 14.75 1.25 15.5 2.16667 15.5H13.8333C14.75 15.5 15.5 14.75 15.5 13.8333V2.16667C15.5 1.25 14.75 0.5 13.8333 0.5Z" fill="#DDDDDD"/><path d="M9.66667 12.1667H3.83333V10.5H9.66667V12.1667ZM12.1667 8.83333H3.83333V7.16667H12.1667V8.83333ZM12.1667 5.5H3.83333V3.83333H12.1667V5.5Z" fill="#DDDDDD"/>',
|
115 |
+
'help' => '<path fill-rule="evenodd" clip-rule="evenodd" d="M2.16667 9.99984C2.16667 5.39984 5.90001 1.6665 10.5 1.6665C15.1 1.6665 18.8333 5.39984 18.8333 9.99984C18.8333 14.5998 15.1 18.3332 10.5 18.3332C5.90001 18.3332 2.16667 14.5998 2.16667 9.99984ZM11.3333 13.3332V14.9998H9.66667V13.3332H11.3333ZM10.5 16.6665C6.82501 16.6665 3.83334 13.6748 3.83334 9.99984C3.83334 6.32484 6.82501 3.33317 10.5 3.33317C14.175 3.33317 17.1667 6.32484 17.1667 9.99984C17.1667 13.6748 14.175 16.6665 10.5 16.6665ZM7.16667 8.33317C7.16667 6.4915 8.65834 4.99984 10.5 4.99984C12.3417 4.99984 13.8333 6.4915 13.8333 8.33317C13.8333 9.40227 13.175 9.9776 12.534 10.5378C11.9259 11.0692 11.3333 11.587 11.3333 12.4998H9.66667C9.66667 10.9821 10.4518 10.3803 11.142 9.85123C11.6835 9.43618 12.1667 9.06585 12.1667 8.33317C12.1667 7.4165 11.4167 6.6665 10.5 6.6665C9.58334 6.6665 8.83334 7.4165 8.83334 8.33317H7.16667Z" fill="#777777"/>',
|
116 |
+
'inbox' => '<path fill-rule="evenodd" clip-rule="evenodd" d="M13.3333 0.5H1.66667C0.75 0.5 0 1.25 0 2.16667V13.8333C0 14.75 0.741667 15.5 1.66667 15.5H13.3333C14.25 15.5 15 14.75 15 13.8333V2.16667C15 1.25 14.25 0.5 13.3333 0.5ZM13.3333 13.8333H1.66667V11.3333H4.63333C5.20833 12.325 6.275 13 7.50833 13C8.74167 13 9.8 12.325 10.3833 11.3333H13.3333V13.8333ZM9.175 9.66667H13.3333V2.16667H1.66667V9.66667H5.84167C5.84167 10.5833 6.59167 11.3333 7.50833 11.3333C8.425 11.3333 9.175 10.5833 9.175 9.66667Z" fill="#777777"/>',
|
117 |
+
'info' => '<path d="M7.66667 4.33333H9.33334V6H7.66667V4.33333ZM7.66667 7.66666H9.33334V12.6667H7.66667V7.66666ZM8.50001 0.166664C3.90001 0.166664 0.166672 3.9 0.166672 8.5C0.166672 13.1 3.90001 16.8333 8.50001 16.8333C13.1 16.8333 16.8333 13.1 16.8333 8.5C16.8333 3.9 13.1 0.166664 8.50001 0.166664ZM8.50001 15.1667C4.82501 15.1667 1.83334 12.175 1.83334 8.5C1.83334 4.825 4.82501 1.83333 8.50001 1.83333C12.175 1.83333 15.1667 4.825 15.1667 8.5C15.1667 12.175 12.175 15.1667 8.50001 15.1667Z" fill="#EBAD35"/>',
|
118 |
+
'success' => '<path d="M8.50001 0.666656C3.90001 0.666656 0.166672 4.39999 0.166672 8.99999C0.166672 13.6 3.90001 17.3333 8.50001 17.3333C13.1 17.3333 16.8333 13.6 16.8333 8.99999C16.8333 4.39999 13.1 0.666656 8.50001 0.666656ZM8.50001 15.6667C4.82501 15.6667 1.83334 12.675 1.83334 8.99999C1.83334 5.32499 4.82501 2.33332 8.50001 2.33332C12.175 2.33332 15.1667 5.32499 15.1667 8.99999C15.1667 12.675 12.175 15.6667 8.50001 15.6667ZM12.325 5.31666L6.83334 10.8083L4.675 8.65832L3.50001 9.83332L6.83334 13.1667L13.5 6.49999L12.325 5.31666Z" fill="#09A347"/>',
|
119 |
+
'warning' => '<path d="M12.73 0H5.27L0 5.27V12.73L5.27 18H12.73L18 12.73V5.27L12.73 0ZM16 11.9L11.9 16H6.1L2 11.9V6.1L6.1 2H11.9L16 6.1V11.9ZM11.83 4.76L9 7.59L6.17 4.76L4.76 6.17L7.59 9L4.76 11.83L6.17 13.24L9 10.41L11.83 13.24L13.24 11.83L10.41 9L13.24 6.17L11.83 4.76Z" fill="#DF2A35"/>',
|
120 |
+
'file' => '<path d="M28 4H12C9.8 4 8.02 5.8 8.02 8L8 40C8 42.2 9.78 44 11.98 44H36C38.2 44 40 42.2 40 40V16L28 4ZM12 40V8H26V18H36V40H12Z" fill="#777777"/>',
|
121 |
+
'support' => '<path d="M24 4C12.96 4 4 12.96 4 24C4 35.04 12.96 44 24 44C35.04 44 44 35.04 44 24C44 12.96 35.04 4 24 4ZM38.92 18.24L33.36 20.54C32.34 17.82 30.2 15.66 27.46 14.66L29.76 9.1C33.96 10.7 37.3 14.04 38.92 18.24ZM24 30C20.68 30 18 27.32 18 24C18 20.68 20.68 18 24 18C27.32 18 30 20.68 30 24C30 27.32 27.32 30 24 30ZM18.26 9.08L20.6 14.64C17.84 15.64 15.66 17.82 14.64 20.58L9.08 18.26C10.7 14.04 14.04 10.7 18.26 9.08ZM9.08 29.74L14.64 27.44C15.66 30.2 17.82 32.36 20.58 33.36L18.24 38.92C14.04 37.3 10.7 33.96 9.08 29.74ZM29.76 38.92L27.46 33.36C30.2 32.34 32.36 30.18 33.36 27.42L38.92 29.76C37.3 33.96 33.96 37.3 29.76 38.92Z" fill="#777777"/>',
|
122 |
+
'code' => '<path d="M34 36 31.9 33.9 41.7 24 31.9 14.1 34 12 46 24ZM14 36 2 24 14 12 16.1 14.1 6.3 24 16.1 33.9ZM16 25.75Q15.3 25.75 14.775 25.225Q14.25 24.7 14.25 24Q14.25 23.3 14.775 22.775Q15.3 22.25 16 22.25Q16.7 22.25 17.225 22.775Q17.75 23.3 17.75 24Q17.75 24.7 17.225 25.225Q16.7 25.75 16 25.75ZM24 25.75Q23.3 25.75 22.775 25.225Q22.25 24.7 22.25 24Q22.25 23.3 22.775 22.775Q23.3 22.25 24 22.25Q24.7 22.25 25.225 22.775Q25.75 23.3 25.75 24Q25.75 24.7 25.225 25.225Q24.7 25.75 24 25.75ZM32 25.75Q31.3 25.75 30.775 25.225Q30.25 24.7 30.25 24Q30.25 23.3 30.775 22.775Q31.3 22.25 32 22.25Q32.7 22.25 33.225 22.775Q33.75 23.3 33.75 24Q33.75 24.7 33.225 25.225Q32.7 25.75 32 25.75Z"/>',
|
123 |
+
'filter' => '<path d="M28 26V38Q28 38.85 27.425 39.425Q26.85 40 26 40H22Q21.15 40 20.575 39.425Q20 38.85 20 38V26L8.05 10.75Q7.35 9.9 7.85 8.95Q8.35 8 9.4 8H38.6Q39.65 8 40.15 8.95Q40.65 9.9 39.95 10.75ZM24 26.2 36 11H12ZM24 26.2Z"/>',
|
124 |
+
'split' => '<path d="M22.5 44V34Q22.5 31.6 21.7 30.05Q20.9 28.5 19.25 26.85L21.4 24.7Q22.05 25.25 22.775 26.2Q23.5 27.15 24 27.95Q24.85 26.65 25.675 25.7Q26.5 24.75 27.25 24.1Q30.15 21.75 31.425 18.425Q32.7 15.1 32.4 9.7L27.9 14.2L25.8 12.1L33.9 4L42 12.1L39.9 14.2L35.4 9.7Q35.65 16 34.175 19.625Q32.7 23.25 29.25 26.4Q27.05 28.4 26.275 30.05Q25.5 31.7 25.5 34V44ZM12.9 16.2Q12.7 15.3 12.575 13.575Q12.45 11.85 12.55 9.75L8.1 14.2L6 12.1L14.1 4L22.2 12.1L20.1 14.2L15.6 9.7Q15.5 11.6 15.55 13.025Q15.6 14.45 15.8 15.5ZM17.1 24.75Q16.25 23.85 15.225 22.375Q14.2 20.9 13.65 19.15L16.6 18.4Q17.05 19.65 17.8 20.8Q18.55 21.95 19.2 22.65Z"/>',
|
125 |
+
'terminal' => '<path d="M7 40Q5.8 40 4.9 39.1Q4 38.2 4 37V11Q4 9.8 4.9 8.9Q5.8 8 7 8H41Q42.2 8 43.1 8.9Q44 9.8 44 11V37Q44 38.2 43.1 39.1Q42.2 40 41 40ZM7 37H41Q41 37 41 37Q41 37 41 37V15.2H7V37Q7 37 7 37Q7 37 7 37ZM24.5 33.6V30.6H35.5V33.6ZM15 33.4 12.9 31.3 18.05 26.1 12.85 20.9 15 18.8 22.3 26.1Z"/>',
|
126 |
+
'error_badge' => '<path d="M22.5 24.6H25.5V14.25H22.5ZM24 31.3Q24.7 31.3 25.2 30.8Q25.7 30.3 25.7 29.6Q25.7 28.9 25.2 28.4Q24.7 27.9 24 27.9Q23.3 27.9 22.8 28.4Q22.3 28.9 22.3 29.6Q22.3 30.3 22.8 30.8Q23.3 31.3 24 31.3ZM24 43.95Q17 42.2 12.5 35.825Q8 29.45 8 21.85V9.95L24 3.95L40 9.95V21.85Q40 29.45 35.5 35.825Q31 42.2 24 43.95ZM24 24.55Q24 24.55 24 24.55Q24 24.55 24 24.55Q24 24.55 24 24.55Q24 24.55 24 24.55ZM24 40.85Q29.75 38.95 33.375 33.675Q37 28.4 37 21.85V12.05L24 7.15L11 12.05V21.85Q11 28.4 14.625 33.675Q18.25 38.95 24 40.85Z"/>',
|
127 |
+
'php' => '<path d="M19.2 31.25 21.35 29.1 16.3 24 21.35 18.95 19.2 16.8 12 24ZM28.8 31.25 36.05 24 28.85 16.8 26.7 18.95 31.75 24 26.65 29.1ZM9 39H39Q39 39 39 39Q39 39 39 39V9Q39 9 39 9Q39 9 39 9H9Q9 9 9 9Q9 9 9 9V39Q9 39 9 39Q9 39 9 39ZM9 9Q9 9 9 9Q9 9 9 9V39Q9 39 9 39Q9 39 9 39Q9 39 9 39Q9 39 9 39V9Q9 9 9 9Q9 9 9 9ZM9 42Q7.75 42 6.875 41.125Q6 40.25 6 39V9Q6 7.75 6.875 6.875Q7.75 6 9 6H19.25Q19.5 4.25 20.85 3.125Q22.2 2 24 2Q25.8 2 27.15 3.125Q28.5 4.25 28.75 6H39Q40.25 6 41.125 6.875Q42 7.75 42 9V39Q42 40.25 41.125 41.125Q40.25 42 39 42ZM24 8.15Q24.7 8.15 25.225 7.625Q25.75 7.1 25.75 6.4Q25.75 5.7 25.225 5.175Q24.7 4.65 24 4.65Q23.3 4.65 22.775 5.175Q22.25 5.7 22.25 6.4Q22.25 7.1 22.775 7.625Q23.3 8.15 24 8.15Z"/>',
|
128 |
+
)
|
129 |
+
);
|
130 |
+
}
|
includes/legacy.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Call new methods using the old class for backwards compatibility.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'InsertHeadersAndFooters' ) ) {
|
9 |
+
/**
|
10 |
+
* Class InsertHeadersAndFooters used in the IHAF 1.x.x.
|
11 |
+
*/
|
12 |
+
class InsertHeadersAndFooters {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Output the header code.
|
16 |
+
*
|
17 |
+
* @return void
|
18 |
+
*/
|
19 |
+
public function frontendHeader() {// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
|
20 |
+
wpcode_global_frontend_header();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Output the footer code.
|
25 |
+
*
|
26 |
+
* @return void
|
27 |
+
*/
|
28 |
+
public function frontendFooter() {// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
|
29 |
+
wpcode_global_frontend_footer();
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Output the body code.
|
34 |
+
*
|
35 |
+
* @return void
|
36 |
+
*/
|
37 |
+
public function frontendBody() {// phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
|
38 |
+
wpcode_global_frontend_body();
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
42 |
+
}
|
includes/post-type.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Register custom post type and taxonomies.
|
4 |
+
*
|
5 |
+
* @package wpcode
|
6 |
+
*/
|
7 |
+
|
8 |
+
add_action( 'init', 'wpcode_register_post_type', - 5 );
|
9 |
+
add_action( 'init', 'wpcode_register_taxonomies', - 5 );
|
10 |
+
add_filter( 'update_post_term_count_statuses', 'wpcode_taxonomies_count_drafts', 10, 2 );
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Register the post type for
|
14 |
+
*
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
function wpcode_register_post_type() {
|
18 |
+
register_post_type(
|
19 |
+
'wpcode',
|
20 |
+
array(
|
21 |
+
'public' => false,
|
22 |
+
'show_ui' => false,
|
23 |
+
)
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Register the custom taxonomies used for snippets.
|
29 |
+
*
|
30 |
+
* @return void
|
31 |
+
*/
|
32 |
+
function wpcode_register_taxonomies() {
|
33 |
+
register_taxonomy(
|
34 |
+
'wpcode_type',
|
35 |
+
'wpcode',
|
36 |
+
array(
|
37 |
+
'public' => false,
|
38 |
+
)
|
39 |
+
);
|
40 |
+
register_taxonomy(
|
41 |
+
'wpcode_location',
|
42 |
+
'wpcode',
|
43 |
+
array(
|
44 |
+
'public' => false,
|
45 |
+
)
|
46 |
+
);
|
47 |
+
register_taxonomy(
|
48 |
+
'wpcode_tags',
|
49 |
+
'wpcode',
|
50 |
+
array(
|
51 |
+
'public' => false,
|
52 |
+
)
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Count draft (inactive) snippets as part of our custom taxonomies count.
|
58 |
+
*
|
59 |
+
* @param array $statuses The statuses to include in the count.
|
60 |
+
* @param WP_Taxonomy $taxonomy The taxonomy object.
|
61 |
+
*
|
62 |
+
* @return array
|
63 |
+
*/
|
64 |
+
function wpcode_taxonomies_count_drafts( $statuses, $taxonomy ) {
|
65 |
+
$taxonomies = array(
|
66 |
+
'wpcode_type',
|
67 |
+
'wpcode_location',
|
68 |
+
'wpcode_tags',
|
69 |
+
);
|
70 |
+
if ( in_array( $taxonomy->name, $taxonomies, true ) ) {
|
71 |
+
$statuses[] = 'draft';
|
72 |
+
}
|
73 |
+
|
74 |
+
return $statuses;
|
75 |
+
}
|
includes/safe-mode.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Safe mode query var logic.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
add_action( 'plugins_loaded', 'wpcode_maybe_enable_safe_mode' );
|
9 |
+
add_filter( 'wpcode_do_auto_insert', 'wpcode_maybe_prevent_execution' );
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Simple check to see if we should be adding safe-mode logic.
|
13 |
+
*
|
14 |
+
* @return void
|
15 |
+
*/
|
16 |
+
function wpcode_maybe_enable_safe_mode() {
|
17 |
+
if ( ! isset( $_GET['wpcode-safe-mode'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
|
21 |
+
// If we're in safe mode, let's make sure all URLs keep the param until we are safe to get out.
|
22 |
+
add_filter( 'home_url', 'wpcode_keep_safe_mode' );
|
23 |
+
add_filter( 'admin_url', 'wpcode_keep_safe_mode' );
|
24 |
+
add_filter( 'site_url', 'wpcode_keep_safe_mode_login', 10, 3 );
|
25 |
+
// The admin menu doesn't offer a hook to change all the menu links so we do it with JS.
|
26 |
+
add_action( 'admin_footer', 'wpcode_keep_safe_mode_admin_menu' );
|
27 |
+
// Show a notice informing the user we're in safe mode and offer a way to get out.
|
28 |
+
add_action( 'admin_notices', 'wpcode_safe_mode_notice' );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Make sure the URL keeps the safe mode variable.
|
33 |
+
*
|
34 |
+
* @param string $url The home or admin base URL.
|
35 |
+
*
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
function wpcode_keep_safe_mode( $url ) {
|
39 |
+
return add_query_arg( 'wpcode-safe-mode', 1, $url );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Force safe mode to all URLs displayed in the admin so we can keep navigating
|
44 |
+
* using safe mode as there's no hook in WP to change the main admin menu.
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
function wpcode_keep_safe_mode_admin_menu() {
|
49 |
+
// There's no reliable way to filter all the admin menu links so we have to force them via JS.
|
50 |
+
// There's also a notice being added to allow users to "exit" safe mode.
|
51 |
+
?>
|
52 |
+
<script type="text/javascript">
|
53 |
+
[...document.querySelectorAll( 'a:not(.wpcode-safe-mode)' )].forEach( e => {
|
54 |
+
const url = new URL( e.href );
|
55 |
+
url.searchParams.set( 'wpcode-safe-mode', '1' );
|
56 |
+
e.href = url.toString();
|
57 |
+
} );
|
58 |
+
</script>
|
59 |
+
<?php
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Show a notice informing the user we're in safe mode and offer a way to get out.
|
64 |
+
*
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
function wpcode_safe_mode_notice() {
|
68 |
+
?>
|
69 |
+
<div class="notice notice-warning">
|
70 |
+
<p><?php esc_html_e( 'WPCode is in Safe Mode which means no snippets are getting executed. Please disable any snippets that have caused errors and when done click the button below to exit safe mode.', 'insert-headers-and-footers' ); ?></p>
|
71 |
+
<p><?php esc_html_e( 'The link will open in a new window so if you are still encountering issues you safely can return to this tab and make further adjustments', 'insert-headers-and-footers' ); ?></p>
|
72 |
+
<p>
|
73 |
+
<a class="button button-secondary wpcode-safe-mode" href="<?php echo esc_url( remove_query_arg( 'wpcode-safe-mode' ) ); ?>" target="_blank"><?php esc_html_e( 'Exit safe mode', 'insert-headers-and-footers' ); ?></a>
|
74 |
+
</p>
|
75 |
+
</div>
|
76 |
+
<?php
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Let's check if we're in the admin or if the current user can manage
|
81 |
+
* snippets before allowing them to see the site with snippets disabled.
|
82 |
+
*
|
83 |
+
* @param bool $execute Execute snippets or not.
|
84 |
+
*
|
85 |
+
* @return mixed
|
86 |
+
*/
|
87 |
+
function wpcode_maybe_prevent_execution( $execute ) {
|
88 |
+
if ( ! isset( $_GET['wpcode-safe-mode'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
89 |
+
return $execute;
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( wpcode_is_wplogin() || current_user_can( 'wpcode_activate_snippets' ) ) {
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
|
96 |
+
return $execute;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Checks schema passed to site_url and adds the safe mode query param
|
101 |
+
* so we can login using safe mode.
|
102 |
+
*
|
103 |
+
* @param string $url The site_url already processed.
|
104 |
+
* @param string $path The path that was added to the URL.
|
105 |
+
* @param string $scheme The scheme that was requested.
|
106 |
+
*
|
107 |
+
* @return string
|
108 |
+
*/
|
109 |
+
function wpcode_keep_safe_mode_login( $url, $path, $scheme ) {
|
110 |
+
if ( 'login_post' !== $scheme ) {
|
111 |
+
return $url;
|
112 |
+
}
|
113 |
+
|
114 |
+
return add_query_arg( 'wpcode-safe-mode', 1, $url );
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Helper function that checks if we are on the login screen
|
119 |
+
* to allow admins to attempt to log in and disable snippets
|
120 |
+
* without having to edit code.
|
121 |
+
*
|
122 |
+
* @return bool
|
123 |
+
*/
|
124 |
+
function wpcode_is_wplogin() {
|
125 |
+
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
|
129 |
+
return false !== stripos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), strrchr( wp_login_url(), '/' ) );
|
130 |
+
}
|
includes/shortcode.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handle the generic WPCode shortcode.
|
4 |
+
*
|
5 |
+
* @package WPCode
|
6 |
+
*/
|
7 |
+
|
8 |
+
add_shortcode( 'wpcode', 'wpcode_shortcode_handler' );
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Generic handler for the shortcode.
|
12 |
+
*
|
13 |
+
* @param array $args The shortcode attributes.
|
14 |
+
*
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
function wpcode_shortcode_handler( $args ) {
|
18 |
+
$atts = wp_parse_args(
|
19 |
+
$args,
|
20 |
+
array(
|
21 |
+
'id' => 0,
|
22 |
+
)
|
23 |
+
);
|
24 |
+
|
25 |
+
if ( 0 === $atts['id'] ) {
|
26 |
+
return '';
|
27 |
+
}
|
28 |
+
|
29 |
+
return wpcode()->execute->get_snippet_output( absint( $atts['id'] ) );
|
30 |
+
}
|
languages/index.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//Nothing to see here
|
3 |
+
|
4 |
+
header( 'HTTP/1.0 403 Forbidden' );
|
languages/insert-headers-and-footers.pot
ADDED
@@ -0,0 +1,3551 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2022 WPCode
|
2 |
+
# This file is distributed under the GPLv2 or later.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: WPCode - Insert Headers, Footers, and Code Snippets 2.0.0\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wpcode\n"
|
7 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2022-07-19T10:07:09+00:00\n"
|
13 |
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
+
"X-Generator: WP-CLI 2.5.0\n"
|
15 |
+
"X-Domain: insert-headers-and-footers\n"
|
16 |
+
|
17 |
+
#. Plugin Name of the plugin
|
18 |
+
msgid "WPCode - Insert Headers, Footers, and Code Snippets"
|
19 |
+
msgstr ""
|
20 |
+
|
21 |
+
#. Plugin URI of the plugin
|
22 |
+
#. Author URI of the plugin
|
23 |
+
msgid "https://www.wpcode.com/"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#. Description of the plugin
|
27 |
+
msgid "Easily add code snippets in WordPress. Insert scripts to the header and footer, add PHP code snippets with conditional logic, insert ads pixel, custom content, and more."
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#. Author of the plugin
|
31 |
+
msgid "WPCode"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#. Translators: formatted error code.
|
35 |
+
#: includes/admin/admin-ajax-handlers.php:38
|
36 |
+
msgid "Snippet not %2$s, the following error was encountered: %1$s"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: includes/admin/admin-ajax-handlers.php:40
|
40 |
+
msgctxt "Snippet status change"
|
41 |
+
msgid "activated"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: includes/admin/admin-ajax-handlers.php:40
|
45 |
+
msgctxt "Snippet status change"
|
46 |
+
msgid "deactivated"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#. Translators: this an auto-generated title for when a snippet is saved from the generator.
|
50 |
+
#: includes/admin/admin-ajax-handlers.php:135
|
51 |
+
msgid "Generated Snippet %s"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: includes/admin/admin-ajax-handlers.php:174
|
55 |
+
msgid "Success! Your server can make SSL connections."
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: includes/admin/admin-ajax-handlers.php:181
|
59 |
+
msgid "There was an error and the connection failed. Please contact your web host with the technical details below."
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: includes/admin/admin-menu.php:28
|
63 |
+
#: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:32
|
64 |
+
msgid "Code Snippets"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#. Translators: Placeholder for the category name.
|
68 |
+
#: includes/admin/class-wpcode-docs.php:164
|
69 |
+
msgid "View All %s Docs"
|
70 |
+
msgstr ""
|
71 |
+
|
72 |
+
#. Translators: Human-Readable time to display.
|
73 |
+
#: includes/admin/class-wpcode-notifications.php:282
|
74 |
+
msgid "%1$s ago"
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:30
|
78 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:31
|
79 |
+
msgid "Welcome to WPCode"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:124
|
83 |
+
msgid "Header & Footer Scripts"
|
84 |
+
msgstr ""
|
85 |
+
|
86 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:125
|
87 |
+
msgid "Effortlessly manage global headers & footers in a familiar interface."
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:129
|
91 |
+
msgid "Conversion Pixels"
|
92 |
+
msgstr ""
|
93 |
+
|
94 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:130
|
95 |
+
msgid "Easily target specific pages to track conversions reliably."
|
96 |
+
msgstr ""
|
97 |
+
|
98 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:134
|
99 |
+
msgid "PHP Snippets"
|
100 |
+
msgstr ""
|
101 |
+
|
102 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:135
|
103 |
+
msgid "Add or remove features with full confidence that your site will not break."
|
104 |
+
msgstr ""
|
105 |
+
|
106 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:139
|
107 |
+
msgid "Conditional Logic"
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:140
|
111 |
+
msgid "Create advanced conditional logic rules in an easy-to-use interface."
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:144
|
115 |
+
msgid "Error Handling"
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:145
|
119 |
+
msgid "Unique error handling capabilities ensure you will not get locked out of your site."
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:149
|
123 |
+
msgid "Snippets Library"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:150
|
127 |
+
msgid "One-click install from our extensive library of commonly-used snippets."
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#. Translators: This simply adds the plugin name before the logo text.
|
131 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:155
|
132 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:374
|
133 |
+
msgid "%s logo"
|
134 |
+
msgstr ""
|
135 |
+
|
136 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:164
|
137 |
+
msgid "Insert Headers and Footers is now WPCode"
|
138 |
+
msgstr ""
|
139 |
+
|
140 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:165
|
141 |
+
msgid "When we first built Insert Headers and Footers over a decade ago, it was meant to do one very simple thing: add header and footer scripts to your site without editing theme files."
|
142 |
+
msgstr ""
|
143 |
+
|
144 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:166
|
145 |
+
msgid "Since then, the plugin has grown to over 1 million active installs with an amazing user base. We have continued to receive feature requests to add more options like controlling which pages the scripts get loaded, allowing more types of code snippets, etc."
|
146 |
+
msgstr ""
|
147 |
+
|
148 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:167
|
149 |
+
msgid "We listened to your feedback, and we are excited to present WPCode, the next generation of Insert Headers and Footers. We chose a new name because it was only fair considering the plugin is now 10x more powerful. Aside from adding global headers and footer snippets, you can also add multiple other types of code snippets, have granular control of where the snippets are output with conditional logic, and a whole lot more."
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
#. Translators: Placeholders 1 & 2 add a link to scroll down the page and 3 & 4 add a link to the suggestions form.
|
153 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:172
|
154 |
+
msgid "Please see the full list of features %1$sbelow%2$s and let us know what you'd like us to add next by %3$ssharing your feedback%4$s."
|
155 |
+
msgstr ""
|
156 |
+
|
157 |
+
#. Translators: Placeholders add link to the details about settings.
|
158 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:187
|
159 |
+
msgid "For those of you who want to limit the functionality and switch back to the old interface, you can do so with one click. %1$sSee details here%2$s."
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:196
|
163 |
+
msgid "We have an exciting roadmap ahead of us since you have shared tons of great ideas with us over the last several years. We truly appreciate your continued support and thank you for being an awesome user."
|
164 |
+
msgstr ""
|
165 |
+
|
166 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:197
|
167 |
+
msgid "We truly appreciate your continued support and thank you for using WPCode."
|
168 |
+
msgstr ""
|
169 |
+
|
170 |
+
#. Translators: Placeholder for "WPBeginner".
|
171 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:208
|
172 |
+
msgid "Founder of %s"
|
173 |
+
msgstr ""
|
174 |
+
|
175 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:220
|
176 |
+
msgid "Lead Developer"
|
177 |
+
msgstr ""
|
178 |
+
|
179 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:226
|
180 |
+
msgid "What’s New in WPCode (Features & Highlights)"
|
181 |
+
msgstr ""
|
182 |
+
|
183 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:246
|
184 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:284
|
185 |
+
msgid "WPCode Generator Screen capture"
|
186 |
+
msgstr ""
|
187 |
+
|
188 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:249
|
189 |
+
msgid "Snippet Generator"
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:250
|
193 |
+
msgid "WPCode now includes a snippet generator directly in the plugin."
|
194 |
+
msgstr ""
|
195 |
+
|
196 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:251
|
197 |
+
msgid "Using the built-in generators, you can quickly add custom post types, custom post statuses, widgets, menus, build complex WP Queries and much more."
|
198 |
+
msgstr ""
|
199 |
+
|
200 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:252
|
201 |
+
msgid "Simply fill in the fields in our guided wizard to generate a custom ready-to-use snippet for your website with 1 click. Try WordPress Snippet Generator."
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:259
|
205 |
+
msgid "Store Snippets in Cloud (Coming Soon)"
|
206 |
+
msgstr ""
|
207 |
+
|
208 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:260
|
209 |
+
msgid "A lot of you requested the ability to save and re-use snippets on multiple websites."
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:261
|
213 |
+
msgid "We're working on this feature to help you save time when managing multiple projects."
|
214 |
+
msgstr ""
|
215 |
+
|
216 |
+
#. Translators: Placeholders add a link to the suggestions page.
|
217 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:266
|
218 |
+
msgid "If you have specific ideas or feature requests, please let us know by %1$sfilling out this form%2$s."
|
219 |
+
msgstr ""
|
220 |
+
|
221 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:277
|
222 |
+
msgid "WPCode Cloud Screen capture"
|
223 |
+
msgstr ""
|
224 |
+
|
225 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:287
|
226 |
+
msgid "Not ready for the new interface?"
|
227 |
+
msgstr ""
|
228 |
+
|
229 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:288
|
230 |
+
msgid "If you are not ready to switch to the new interface, or you simply want to use the plugin just for inserting headers and footers we've got you covered."
|
231 |
+
msgstr ""
|
232 |
+
|
233 |
+
#. Translators: Placeholders add a link to the settings page.
|
234 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:293
|
235 |
+
msgid "You can switch to the simple Headers & Footers interface at any time from the %1$ssettings page%2$s."
|
236 |
+
msgstr ""
|
237 |
+
|
238 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:302
|
239 |
+
msgid "And if you change your mind later and want to give the full plugin a shot, you can always switch back with just 2 clicks using the option at the top of the page."
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#: includes/admin/class-wpcode-upgrade-welcome.php:307
|
243 |
+
msgid "Add Your First Snippet"
|
244 |
+
msgstr ""
|
245 |
+
|
246 |
+
#: includes/admin/importers/class-wpcode-importer-code-snippets.php:92
|
247 |
+
#: includes/admin/importers/class-wpcode-importer-woody.php:89
|
248 |
+
msgid "Unknown Snippet"
|
249 |
+
msgstr ""
|
250 |
+
|
251 |
+
#: includes/admin/importers/class-wpcode-importer-code-snippets.php:93
|
252 |
+
#: includes/admin/importers/class-wpcode-importer-woody.php:90
|
253 |
+
msgid "The snippet you are trying to import does not exist."
|
254 |
+
msgstr ""
|
255 |
+
|
256 |
+
#: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:173
|
257 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:805
|
258 |
+
msgid "Search Snippets"
|
259 |
+
msgstr ""
|
260 |
+
|
261 |
+
#: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:191
|
262 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:805
|
263 |
+
msgid "All Snippets"
|
264 |
+
msgstr ""
|
265 |
+
|
266 |
+
#: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:193
|
267 |
+
#: includes/generator/class-wpcode-generator-post-type.php:231
|
268 |
+
msgid "Add New"
|
269 |
+
msgstr ""
|
270 |
+
|
271 |
+
#. Translators: %d - Trashed snippets count.
|
272 |
+
#: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:210
|
273 |
+
msgid "%d snippet was successfully moved to Trash."
|
274 |
+
msgid_plural "%d snippets were successfully moved to Trash."
|
275 |
+
msgstr[0] ""
|
276 |
+
msgstr[1] ""
|
277 |
+
|
278 |
+
#. translators: %d - Restored from trash snippets count.
|
279 |
+
#: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:218
|
280 |
+
msgid "%d snippet was successfully restored."
|
281 |
+
msgid_plural "%d snippet were successfully restored."
|
282 |
+
msgstr[0] ""
|
283 |
+
msgstr[1] ""
|
284 |
+
|
285 |
+
#. translators: %d - Deleted snippets count.
|
286 |
+
#: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:226
|
287 |
+
msgid "%d snippet was successfully permanently deleted."
|
288 |
+
msgid_plural "%d snippets were successfully permanently deleted."
|
289 |
+
msgstr[0] ""
|
290 |
+
msgstr[1] ""
|
291 |
+
|
292 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:52
|
293 |
+
msgid "Generator"
|
294 |
+
msgstr ""
|
295 |
+
|
296 |
+
#. Translators: gets replace with the generator name.
|
297 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:75
|
298 |
+
msgid "%s Generator"
|
299 |
+
msgstr ""
|
300 |
+
|
301 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:101
|
302 |
+
msgid "All Generators"
|
303 |
+
msgstr ""
|
304 |
+
|
305 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:113
|
306 |
+
msgid "Generate"
|
307 |
+
msgstr ""
|
308 |
+
|
309 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:159
|
310 |
+
msgid "Update code"
|
311 |
+
msgstr ""
|
312 |
+
|
313 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:166
|
314 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:294
|
315 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:883
|
316 |
+
msgid "Code Preview"
|
317 |
+
msgstr ""
|
318 |
+
|
319 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:167
|
320 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:888
|
321 |
+
msgid "Use Snippet"
|
322 |
+
msgstr ""
|
323 |
+
|
324 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:169
|
325 |
+
msgctxt "Copy to clipboard"
|
326 |
+
msgid "Copy Code"
|
327 |
+
msgstr ""
|
328 |
+
|
329 |
+
#: includes/admin/pages/class-wpcode-admin-page-generator.php:202
|
330 |
+
msgid "Remove Row"
|
331 |
+
msgstr ""
|
332 |
+
|
333 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:50
|
334 |
+
msgid "Header & Footer"
|
335 |
+
msgstr ""
|
336 |
+
|
337 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:91
|
338 |
+
msgid "Headers & Footers mode activated. Use the toggle next to the Save Changes button to disable it at any time."
|
339 |
+
msgstr ""
|
340 |
+
|
341 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:92
|
342 |
+
msgid "Headers & Footers mode deactivated, if you wish to switch back please use the option on the settings page."
|
343 |
+
msgstr ""
|
344 |
+
|
345 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:110
|
346 |
+
msgid "Sorry, only have read-only access to this page. Ask your administrator for assistance editing."
|
347 |
+
msgstr ""
|
348 |
+
|
349 |
+
#. translators: %s: The `<head>` tag
|
350 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:132
|
351 |
+
msgid "These scripts will be printed in the %s section."
|
352 |
+
msgstr ""
|
353 |
+
|
354 |
+
#. translators: %s: The `<head>` tag
|
355 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:137
|
356 |
+
msgid "These scripts will be printed just below the opening %s tag."
|
357 |
+
msgstr ""
|
358 |
+
|
359 |
+
#. translators: %s: The `</body>` tag
|
360 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:142
|
361 |
+
msgid "These scripts will be printed above the closing %s tag."
|
362 |
+
msgstr ""
|
363 |
+
|
364 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:145
|
365 |
+
#: includes/generator/class-wpcode-generator-script.php:193
|
366 |
+
msgid "Header"
|
367 |
+
msgstr ""
|
368 |
+
|
369 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:147
|
370 |
+
msgid "Body"
|
371 |
+
msgstr ""
|
372 |
+
|
373 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:149
|
374 |
+
#: includes/generator/class-wpcode-generator-script.php:192
|
375 |
+
msgid "Footer"
|
376 |
+
msgstr ""
|
377 |
+
|
378 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:184
|
379 |
+
msgid "Global Header and Footer"
|
380 |
+
msgstr ""
|
381 |
+
|
382 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:189
|
383 |
+
#: includes/admin/pages/class-wpcode-admin-page-settings.php:108
|
384 |
+
msgid "Save Changes"
|
385 |
+
msgstr ""
|
386 |
+
|
387 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:207
|
388 |
+
msgid "Simple mode"
|
389 |
+
msgstr ""
|
390 |
+
|
391 |
+
#: includes/admin/pages/class-wpcode-admin-page-headers-footers.php:268
|
392 |
+
#: includes/admin/pages/class-wpcode-admin-page-settings.php:144
|
393 |
+
msgid "Settings Saved."
|
394 |
+
msgstr ""
|
395 |
+
|
396 |
+
#: includes/admin/pages/class-wpcode-admin-page-library.php:30
|
397 |
+
msgid "Library"
|
398 |
+
msgstr ""
|
399 |
+
|
400 |
+
#: includes/admin/pages/class-wpcode-admin-page-library.php:108
|
401 |
+
msgid "Snippet Library"
|
402 |
+
msgstr ""
|
403 |
+
|
404 |
+
#: includes/admin/pages/class-wpcode-admin-page-library.php:125
|
405 |
+
msgid "We encountered an error while trying to load the snippet data. Please try again."
|
406 |
+
msgstr ""
|
407 |
+
|
408 |
+
#: includes/admin/pages/class-wpcode-admin-page-settings.php:38
|
409 |
+
#: includes/admin/pages/class-wpcode-admin-page-settings.php:104
|
410 |
+
msgid "Settings"
|
411 |
+
msgstr ""
|
412 |
+
|
413 |
+
#: includes/admin/pages/class-wpcode-admin-page-settings.php:72
|
414 |
+
msgid "This allows you to disable all Code Snippets functionality and have a single \"Headers & Footers\" item under the settings menu."
|
415 |
+
msgstr ""
|
416 |
+
|
417 |
+
#. Translators: Placeholders make the text bold.
|
418 |
+
#: includes/admin/pages/class-wpcode-admin-page-settings.php:77
|
419 |
+
msgid "%1$sNOTE:%2$s Please use this setting with caution. It will disable all custom snippets that you add using the new snippet management interface."
|
420 |
+
msgstr ""
|
421 |
+
|
422 |
+
#: includes/admin/pages/class-wpcode-admin-page-settings.php:83
|
423 |
+
msgid "Headers & Footers mode"
|
424 |
+
msgstr ""
|
425 |
+
|
426 |
+
#. Translators: This adds the name of the plugin "WPCode".
|
427 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:68
|
428 |
+
msgid "Add %s Snippet"
|
429 |
+
msgstr ""
|
430 |
+
|
431 |
+
#. Translators: This adds the name of the plugin "WPCode".
|
432 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:69
|
433 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:99
|
434 |
+
msgid "Add Snippet"
|
435 |
+
msgstr ""
|
436 |
+
|
437 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:92
|
438 |
+
msgid "Save Snippet"
|
439 |
+
msgstr ""
|
440 |
+
|
441 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:93
|
442 |
+
msgid "Create Custom Snippet"
|
443 |
+
msgstr ""
|
444 |
+
|
445 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:95
|
446 |
+
msgid "Edit Snippet"
|
447 |
+
msgstr ""
|
448 |
+
|
449 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:96
|
450 |
+
msgid "Update"
|
451 |
+
msgstr ""
|
452 |
+
|
453 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:122
|
454 |
+
msgid "You cannot edit this snippet because it is in the Trash. Please restore it and try again."
|
455 |
+
msgstr ""
|
456 |
+
|
457 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:138
|
458 |
+
msgid "Snippet updated."
|
459 |
+
msgstr ""
|
460 |
+
|
461 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:139
|
462 |
+
msgid "Snippet created & Saved."
|
463 |
+
msgstr ""
|
464 |
+
|
465 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:140
|
466 |
+
msgid "We encountered an error activating your snippet, please check the syntax and try again."
|
467 |
+
msgstr ""
|
468 |
+
|
469 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:141
|
470 |
+
msgid "Sorry, you are not allowed to change the status of the snippet."
|
471 |
+
msgstr ""
|
472 |
+
|
473 |
+
#. Translators: this changes the edit page title to show the snippet title.
|
474 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:186
|
475 |
+
msgid "Edit snippet \"%s\""
|
476 |
+
msgstr ""
|
477 |
+
|
478 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:236
|
479 |
+
msgid "Add Your Custom Code (New Snippet)"
|
480 |
+
msgstr ""
|
481 |
+
|
482 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:237
|
483 |
+
msgid "Choose this blank snippet to start from scratch and paste any custom code or simply write your own."
|
484 |
+
msgstr ""
|
485 |
+
|
486 |
+
#. Translators: The placeholders add links to create a new custom snippet or the suggest-a-snippet form.
|
487 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:256
|
488 |
+
msgid "To speed up the process you can select from one of our pre-made library, or you can start with a %1$sblank snippet%2$s and %1$screate your own%2$s. Have a suggestion for new snippet? %3$sWe’d love to hear it!%4$s"
|
489 |
+
msgstr ""
|
490 |
+
|
491 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:277
|
492 |
+
msgid "Add title for snippet"
|
493 |
+
msgstr ""
|
494 |
+
|
495 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:328
|
496 |
+
msgid "Code Type"
|
497 |
+
msgstr ""
|
498 |
+
|
499 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:346
|
500 |
+
msgid "Insertion"
|
501 |
+
msgstr ""
|
502 |
+
|
503 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:353
|
504 |
+
msgid "Choose \"Auto Insert\" if you want the snippet to be automatically executed in one of the locations available. In \"Shortcode\" mode, the snippet will only be executed where the shortcode is inserted."
|
505 |
+
msgstr ""
|
506 |
+
|
507 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:356
|
508 |
+
msgid "Insert Method"
|
509 |
+
msgstr ""
|
510 |
+
|
511 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:359
|
512 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:459
|
513 |
+
msgid "Location"
|
514 |
+
msgstr ""
|
515 |
+
|
516 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:361
|
517 |
+
msgid "Insert Number"
|
518 |
+
msgstr ""
|
519 |
+
|
520 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:384
|
521 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:433
|
522 |
+
msgid "Shortcode"
|
523 |
+
msgstr ""
|
524 |
+
|
525 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:394
|
526 |
+
msgid "Your snippet can be either automatically executed or only used as a shortcode. When using the \"Auto Insert\" option you can choose the location where your snippet will be placed automatically."
|
527 |
+
msgstr ""
|
528 |
+
|
529 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:405
|
530 |
+
msgid "Number of paragraphs before which to insert the snippet."
|
531 |
+
msgstr ""
|
532 |
+
|
533 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:406
|
534 |
+
msgid "Number of paragraphs after which to insert the snippet."
|
535 |
+
msgstr ""
|
536 |
+
|
537 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:407
|
538 |
+
msgid "Number of posts before which to insert the snippet."
|
539 |
+
msgstr ""
|
540 |
+
|
541 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:408
|
542 |
+
msgid "Number of posts after which to insert the snippet."
|
543 |
+
msgstr ""
|
544 |
+
|
545 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:429
|
546 |
+
msgid "Auto Insert"
|
547 |
+
msgstr ""
|
548 |
+
|
549 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:525
|
550 |
+
msgid "Please save the snippet first"
|
551 |
+
msgstr ""
|
552 |
+
|
553 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:537
|
554 |
+
msgctxt "Copy to clipboard"
|
555 |
+
msgid "Copy"
|
556 |
+
msgstr ""
|
557 |
+
|
558 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:599
|
559 |
+
msgid "Tag"
|
560 |
+
msgstr ""
|
561 |
+
|
562 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:600
|
563 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1360
|
564 |
+
msgid "Priority"
|
565 |
+
msgstr ""
|
566 |
+
|
567 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:601
|
568 |
+
msgid "Note"
|
569 |
+
msgstr ""
|
570 |
+
|
571 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:604
|
572 |
+
msgid "Basic info"
|
573 |
+
msgstr ""
|
574 |
+
|
575 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:606
|
576 |
+
msgid "Tags: Use tags to make it easier to group similar snippets together. <br />Priority: A lower priority will result in the snippet being executed before others with a higher priority. <br />Note: Add a private note related to this snippet."
|
577 |
+
msgstr ""
|
578 |
+
|
579 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:618
|
580 |
+
msgid "Using conditional logic you can limit the pages where you want the snippet to be auto-inserted."
|
581 |
+
msgstr ""
|
582 |
+
|
583 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:622
|
584 |
+
msgid "Enable Logic"
|
585 |
+
msgstr ""
|
586 |
+
|
587 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:623
|
588 |
+
msgid "Conditions"
|
589 |
+
msgstr ""
|
590 |
+
|
591 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:628
|
592 |
+
msgid "Smart Conditional Logic"
|
593 |
+
msgstr ""
|
594 |
+
|
595 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:630
|
596 |
+
msgid "Enable logic to add rules and limit where your snippets are inserted automatically. Use multiple groups for different sets of rules."
|
597 |
+
msgstr ""
|
598 |
+
|
599 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:702
|
600 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:358
|
601 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:695
|
602 |
+
msgid "Active"
|
603 |
+
msgstr ""
|
604 |
+
|
605 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:705
|
606 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:359
|
607 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:698
|
608 |
+
msgid "Inactive"
|
609 |
+
msgstr ""
|
610 |
+
|
611 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:843
|
612 |
+
msgid "+ Add new group"
|
613 |
+
msgstr ""
|
614 |
+
|
615 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:860
|
616 |
+
msgid "Show"
|
617 |
+
msgstr ""
|
618 |
+
|
619 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:861
|
620 |
+
msgid "Hide"
|
621 |
+
msgstr ""
|
622 |
+
|
623 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:876
|
624 |
+
msgid "This code snippet if"
|
625 |
+
msgstr ""
|
626 |
+
|
627 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:959
|
628 |
+
msgctxt "Conditional logic add another \"and\" rules row."
|
629 |
+
msgid "AND"
|
630 |
+
msgstr ""
|
631 |
+
|
632 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:1008
|
633 |
+
msgid "Is"
|
634 |
+
msgstr ""
|
635 |
+
|
636 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:1009
|
637 |
+
msgid "Is not"
|
638 |
+
msgstr ""
|
639 |
+
|
640 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:1010
|
641 |
+
msgid "Contains"
|
642 |
+
msgstr ""
|
643 |
+
|
644 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:1011
|
645 |
+
msgid "Doesn't Contain"
|
646 |
+
msgstr ""
|
647 |
+
|
648 |
+
#: includes/admin/pages/class-wpcode-admin-page-snippet-manager.php:1031
|
649 |
+
msgctxt "Conditional logic \"or\" another rule"
|
650 |
+
msgid "OR"
|
651 |
+
msgstr ""
|
652 |
+
|
653 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:52
|
654 |
+
msgid "Tools"
|
655 |
+
msgstr ""
|
656 |
+
|
657 |
+
#. Translators: Adds a link to the snippets list in the admin.
|
658 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:83
|
659 |
+
msgid "Import was successfully finished. You can go and check %1$syour snippets%2$s."
|
660 |
+
msgstr ""
|
661 |
+
|
662 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:129
|
663 |
+
msgid "WPCode Snippet Import"
|
664 |
+
msgstr ""
|
665 |
+
|
666 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:130
|
667 |
+
msgid "Select a WPCode export file"
|
668 |
+
msgstr ""
|
669 |
+
|
670 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:136
|
671 |
+
msgid "No file chosen"
|
672 |
+
msgstr ""
|
673 |
+
|
674 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:140
|
675 |
+
msgid "Choose a file…"
|
676 |
+
msgstr ""
|
677 |
+
|
678 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:149
|
679 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:182
|
680 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:304
|
681 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:480
|
682 |
+
msgid "Import"
|
683 |
+
msgstr ""
|
684 |
+
|
685 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:155
|
686 |
+
msgid "Import from Other Code Plugins"
|
687 |
+
msgstr ""
|
688 |
+
|
689 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:156
|
690 |
+
msgid "WPCode makes it easy for you to switch by allowing you import your third-party snippet plugins with a single click."
|
691 |
+
msgstr ""
|
692 |
+
|
693 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:159
|
694 |
+
msgid "Select previous Code plugin"
|
695 |
+
msgstr ""
|
696 |
+
|
697 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:165
|
698 |
+
msgid "Not Installed"
|
699 |
+
msgstr ""
|
700 |
+
|
701 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:167
|
702 |
+
msgid "Not Active"
|
703 |
+
msgstr ""
|
704 |
+
|
705 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:197
|
706 |
+
msgid "Export Code Snippets"
|
707 |
+
msgstr ""
|
708 |
+
|
709 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:201
|
710 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:464
|
711 |
+
#: includes/generator/class-wpcode-generator-post-status.php:111
|
712 |
+
msgid "Status"
|
713 |
+
msgstr ""
|
714 |
+
|
715 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:206
|
716 |
+
msgid "Code type"
|
717 |
+
msgstr ""
|
718 |
+
|
719 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:211
|
720 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:461
|
721 |
+
msgid "Tags"
|
722 |
+
msgstr ""
|
723 |
+
|
724 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:218
|
725 |
+
msgid "Export Snippets"
|
726 |
+
msgstr ""
|
727 |
+
|
728 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:232
|
729 |
+
msgid "System Information"
|
730 |
+
msgstr ""
|
731 |
+
|
732 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:237
|
733 |
+
msgid "Test SSL Connections"
|
734 |
+
msgstr ""
|
735 |
+
|
736 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:238
|
737 |
+
msgid "Click the button below to verify your web server can perform SSL connections successfully."
|
738 |
+
msgstr ""
|
739 |
+
|
740 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:240
|
741 |
+
msgid "Test Connection"
|
742 |
+
msgstr ""
|
743 |
+
|
744 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:263
|
745 |
+
msgid "Snippets import"
|
746 |
+
msgstr ""
|
747 |
+
|
748 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:267
|
749 |
+
msgid "Select the Snippets you would like to import."
|
750 |
+
msgstr ""
|
751 |
+
|
752 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:271
|
753 |
+
msgid "Available Snippets"
|
754 |
+
msgstr ""
|
755 |
+
|
756 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:276
|
757 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:337
|
758 |
+
msgid "No snippets found."
|
759 |
+
msgstr ""
|
760 |
+
|
761 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:290
|
762 |
+
msgid "Select All"
|
763 |
+
msgstr ""
|
764 |
+
|
765 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:295
|
766 |
+
msgid "Snippets to Import"
|
767 |
+
msgstr ""
|
768 |
+
|
769 |
+
#. Translators: These add markup to display which snippet out of the total from the provider name.
|
770 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:316
|
771 |
+
msgid "Importing %1$s of %2$s snippets from %3$s."
|
772 |
+
msgstr ""
|
773 |
+
|
774 |
+
#. Translators: this adds the total snippets count that have been completed.
|
775 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:334
|
776 |
+
msgid "Congrats, the import process has finished! We have successfully imported %s snippets. You can review the results below."
|
777 |
+
msgstr ""
|
778 |
+
|
779 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:357
|
780 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:692
|
781 |
+
msgid "All"
|
782 |
+
msgstr ""
|
783 |
+
|
784 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:391
|
785 |
+
msgid "No snippets available to export."
|
786 |
+
msgstr ""
|
787 |
+
|
788 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:416
|
789 |
+
msgid "No tags available."
|
790 |
+
msgstr ""
|
791 |
+
|
792 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:481
|
793 |
+
msgid "Export"
|
794 |
+
msgstr ""
|
795 |
+
|
796 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:482
|
797 |
+
msgid "System Info"
|
798 |
+
msgstr ""
|
799 |
+
|
800 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:483
|
801 |
+
msgid "Importer"
|
802 |
+
msgstr ""
|
803 |
+
|
804 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:589
|
805 |
+
msgid "Please upload a valid .json snippets export file."
|
806 |
+
msgstr ""
|
807 |
+
|
808 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:590
|
809 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:603
|
810 |
+
msgid "Error"
|
811 |
+
msgstr ""
|
812 |
+
|
813 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:602
|
814 |
+
msgid "Snippets data cannot be imported."
|
815 |
+
msgstr ""
|
816 |
+
|
817 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:659
|
818 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:284
|
819 |
+
msgid "Edit"
|
820 |
+
msgstr ""
|
821 |
+
|
822 |
+
#: includes/admin/pages/class-wpcode-admin-page-tools.php:675
|
823 |
+
msgid "Testing"
|
824 |
+
msgstr ""
|
825 |
+
|
826 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:218
|
827 |
+
msgid "Search docs"
|
828 |
+
msgstr ""
|
829 |
+
|
830 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:222
|
831 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:598
|
832 |
+
msgid "Clear"
|
833 |
+
msgstr ""
|
834 |
+
|
835 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:229
|
836 |
+
msgid "No docs found"
|
837 |
+
msgstr ""
|
838 |
+
|
839 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:243
|
840 |
+
msgid "View Documentation"
|
841 |
+
msgstr ""
|
842 |
+
|
843 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:244
|
844 |
+
msgid "Browse documentation, reference material, and tutorials for WPCode."
|
845 |
+
msgstr ""
|
846 |
+
|
847 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:245
|
848 |
+
msgid "View All Documentation"
|
849 |
+
msgstr ""
|
850 |
+
|
851 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:249
|
852 |
+
msgid "Get Support"
|
853 |
+
msgstr ""
|
854 |
+
|
855 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:250
|
856 |
+
msgid "Submit a ticket and our world class support team will be in touch soon."
|
857 |
+
msgstr ""
|
858 |
+
|
859 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:251
|
860 |
+
msgid "Submit a Support Ticket"
|
861 |
+
msgstr ""
|
862 |
+
|
863 |
+
#. Translators: Placeholder for the number of active notifications.
|
864 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:263
|
865 |
+
msgid "New Notifications (%s)"
|
866 |
+
msgstr ""
|
867 |
+
|
868 |
+
#. Translators: Placeholder for the number of dismissed notifications.
|
869 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:274
|
870 |
+
msgid "Notifications (%s)"
|
871 |
+
msgstr ""
|
872 |
+
|
873 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:281
|
874 |
+
msgid "Dismissed Notifications"
|
875 |
+
msgstr ""
|
876 |
+
|
877 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:284
|
878 |
+
msgid "Active Notifications"
|
879 |
+
msgstr ""
|
880 |
+
|
881 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:307
|
882 |
+
msgid "Dismiss all"
|
883 |
+
msgstr ""
|
884 |
+
|
885 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:348
|
886 |
+
msgid "Dismiss"
|
887 |
+
msgstr ""
|
888 |
+
|
889 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:406
|
890 |
+
msgid "Help"
|
891 |
+
msgstr ""
|
892 |
+
|
893 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:693
|
894 |
+
msgid "Use snippet"
|
895 |
+
msgstr ""
|
896 |
+
|
897 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:712
|
898 |
+
msgid "Edit snippet"
|
899 |
+
msgstr ""
|
900 |
+
|
901 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:713
|
902 |
+
msgid "Used"
|
903 |
+
msgstr ""
|
904 |
+
|
905 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:733
|
906 |
+
msgid "Preview"
|
907 |
+
msgstr ""
|
908 |
+
|
909 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:811
|
910 |
+
msgid "We encountered a problem loading the Snippet Library items, please try again later."
|
911 |
+
msgstr ""
|
912 |
+
|
913 |
+
#: includes/admin/pages/class-wpcode-admin-page.php:879
|
914 |
+
msgid "Preview Snippet"
|
915 |
+
msgstr ""
|
916 |
+
|
917 |
+
#. Translators: This is the format for displaying the date in the admin list, [date] at [time].
|
918 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:106
|
919 |
+
msgid "%1$s at %2$s"
|
920 |
+
msgstr ""
|
921 |
+
|
922 |
+
#. Translators: The tag by which to filter the list of snippets in the admin.
|
923 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:137
|
924 |
+
msgid "Filter snippets by tag: %s"
|
925 |
+
msgstr ""
|
926 |
+
|
927 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:216
|
928 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:283
|
929 |
+
msgid "Edit This Snippet"
|
930 |
+
msgstr ""
|
931 |
+
|
932 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:256
|
933 |
+
msgid "Restore this snippet"
|
934 |
+
msgstr ""
|
935 |
+
|
936 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:257
|
937 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:320
|
938 |
+
msgid "Restore"
|
939 |
+
msgstr ""
|
940 |
+
|
941 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:273
|
942 |
+
msgid "Delete this snippet permanently"
|
943 |
+
msgstr ""
|
944 |
+
|
945 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:274
|
946 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:321
|
947 |
+
msgid "Delete Permanently"
|
948 |
+
msgstr ""
|
949 |
+
|
950 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:303
|
951 |
+
msgid "Move this snippet to trash"
|
952 |
+
msgstr ""
|
953 |
+
|
954 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:304
|
955 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:326
|
956 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:701
|
957 |
+
msgid "Trash"
|
958 |
+
msgstr ""
|
959 |
+
|
960 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:457
|
961 |
+
#: includes/generator/class-wpcode-generator-post-status.php:128
|
962 |
+
#: includes/generator/class-wpcode-generator-post-type.php:136
|
963 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:130
|
964 |
+
msgid "Name"
|
965 |
+
msgstr ""
|
966 |
+
|
967 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:458
|
968 |
+
#: includes/generator/class-wpcode-generator-post-type.php:378
|
969 |
+
#: includes/generator/class-wpcode-generator-query.php:225
|
970 |
+
#: includes/generator/class-wpcode-generator-query.php:299
|
971 |
+
msgid "Author"
|
972 |
+
msgstr ""
|
973 |
+
|
974 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:460
|
975 |
+
msgid "Created"
|
976 |
+
msgstr ""
|
977 |
+
|
978 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:578
|
979 |
+
msgid "0 items"
|
980 |
+
msgstr ""
|
981 |
+
|
982 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:594
|
983 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1337
|
984 |
+
msgid "Filter"
|
985 |
+
msgstr ""
|
986 |
+
|
987 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:628
|
988 |
+
msgid "Filter by code type"
|
989 |
+
msgstr ""
|
990 |
+
|
991 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:630
|
992 |
+
msgid "All types"
|
993 |
+
msgstr ""
|
994 |
+
|
995 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:670
|
996 |
+
msgid "Filter by location"
|
997 |
+
msgstr ""
|
998 |
+
|
999 |
+
#: includes/admin/pages/class-wpcode-code-snippets-table.php:672
|
1000 |
+
msgid "All locations"
|
1001 |
+
msgstr ""
|
1002 |
+
|
1003 |
+
#: includes/auto-insert/class-wpcode-auto-insert-archive.php:19
|
1004 |
+
msgid "Categories, Archives, Tags, Taxonomies"
|
1005 |
+
msgstr ""
|
1006 |
+
|
1007 |
+
#: includes/auto-insert/class-wpcode-auto-insert-archive.php:21
|
1008 |
+
msgid "Insert Before Excerpt"
|
1009 |
+
msgstr ""
|
1010 |
+
|
1011 |
+
#: includes/auto-insert/class-wpcode-auto-insert-archive.php:22
|
1012 |
+
msgid "Insert After Excerpt"
|
1013 |
+
msgstr ""
|
1014 |
+
|
1015 |
+
#: includes/auto-insert/class-wpcode-auto-insert-archive.php:23
|
1016 |
+
msgid "Between Posts"
|
1017 |
+
msgstr ""
|
1018 |
+
|
1019 |
+
#: includes/auto-insert/class-wpcode-auto-insert-archive.php:24
|
1020 |
+
msgid "Before Post"
|
1021 |
+
msgstr ""
|
1022 |
+
|
1023 |
+
#: includes/auto-insert/class-wpcode-auto-insert-archive.php:25
|
1024 |
+
msgid "After Post"
|
1025 |
+
msgstr ""
|
1026 |
+
|
1027 |
+
#: includes/auto-insert/class-wpcode-auto-insert-everywhere.php:26
|
1028 |
+
msgid "PHP Snippets Only"
|
1029 |
+
msgstr ""
|
1030 |
+
|
1031 |
+
#: includes/auto-insert/class-wpcode-auto-insert-everywhere.php:28
|
1032 |
+
msgid "Run Everywhere"
|
1033 |
+
msgstr ""
|
1034 |
+
|
1035 |
+
#: includes/auto-insert/class-wpcode-auto-insert-everywhere.php:29
|
1036 |
+
msgid "Frontend Only"
|
1037 |
+
msgstr ""
|
1038 |
+
|
1039 |
+
#: includes/auto-insert/class-wpcode-auto-insert-everywhere.php:30
|
1040 |
+
msgid "Admin Only"
|
1041 |
+
msgstr ""
|
1042 |
+
|
1043 |
+
#: includes/auto-insert/class-wpcode-auto-insert-single.php:26
|
1044 |
+
msgid "Page, Post, Custom Post Type"
|
1045 |
+
msgstr ""
|
1046 |
+
|
1047 |
+
#: includes/auto-insert/class-wpcode-auto-insert-single.php:28
|
1048 |
+
msgid "Insert Before Post"
|
1049 |
+
msgstr ""
|
1050 |
+
|
1051 |
+
#: includes/auto-insert/class-wpcode-auto-insert-single.php:29
|
1052 |
+
msgid "Insert After Post"
|
1053 |
+
msgstr ""
|
1054 |
+
|
1055 |
+
#: includes/auto-insert/class-wpcode-auto-insert-single.php:30
|
1056 |
+
msgid "Insert Before Content"
|
1057 |
+
msgstr ""
|
1058 |
+
|
1059 |
+
#: includes/auto-insert/class-wpcode-auto-insert-single.php:31
|
1060 |
+
msgid "Insert After Content"
|
1061 |
+
msgstr ""
|
1062 |
+
|
1063 |
+
#: includes/auto-insert/class-wpcode-auto-insert-single.php:32
|
1064 |
+
msgid "Insert Before Paragraph"
|
1065 |
+
msgstr ""
|
1066 |
+
|
1067 |
+
#: includes/auto-insert/class-wpcode-auto-insert-single.php:33
|
1068 |
+
msgid "Insert After Paragraph"
|
1069 |
+
msgstr ""
|
1070 |
+
|
1071 |
+
#: includes/auto-insert/class-wpcode-auto-insert-site-wide.php:19
|
1072 |
+
msgid "Site wide"
|
1073 |
+
msgstr ""
|
1074 |
+
|
1075 |
+
#: includes/auto-insert/class-wpcode-auto-insert-site-wide.php:21
|
1076 |
+
msgid "Site Wide Header"
|
1077 |
+
msgstr ""
|
1078 |
+
|
1079 |
+
#: includes/auto-insert/class-wpcode-auto-insert-site-wide.php:22
|
1080 |
+
msgid "Site Wide Body"
|
1081 |
+
msgstr ""
|
1082 |
+
|
1083 |
+
#: includes/auto-insert/class-wpcode-auto-insert-site-wide.php:23
|
1084 |
+
msgid "Site Wide Footer"
|
1085 |
+
msgstr ""
|
1086 |
+
|
1087 |
+
#: includes/class-wpcode-generator.php:94
|
1088 |
+
msgid "Admin"
|
1089 |
+
msgstr ""
|
1090 |
+
|
1091 |
+
#: includes/class-wpcode-generator.php:95
|
1092 |
+
msgid "Content"
|
1093 |
+
msgstr ""
|
1094 |
+
|
1095 |
+
#: includes/class-wpcode-generator.php:96
|
1096 |
+
msgid "Core"
|
1097 |
+
msgstr ""
|
1098 |
+
|
1099 |
+
#: includes/class-wpcode-generator.php:97
|
1100 |
+
msgid "Design"
|
1101 |
+
msgstr ""
|
1102 |
+
|
1103 |
+
#: includes/class-wpcode-generator.php:98
|
1104 |
+
#: includes/generator/class-wpcode-generator-post-type.php:539
|
1105 |
+
msgid "Query"
|
1106 |
+
msgstr ""
|
1107 |
+
|
1108 |
+
#: includes/class-wpcode-install.php:73
|
1109 |
+
msgid "Display a message after the 1st paragraph of posts"
|
1110 |
+
msgstr ""
|
1111 |
+
|
1112 |
+
#: includes/class-wpcode-install.php:85
|
1113 |
+
msgid "Completely Disable Comments"
|
1114 |
+
msgstr ""
|
1115 |
+
|
1116 |
+
#: includes/class-wpcode-snippet-execute.php:77
|
1117 |
+
msgid "HTML Snippet"
|
1118 |
+
msgstr ""
|
1119 |
+
|
1120 |
+
#: includes/class-wpcode-snippet-execute.php:82
|
1121 |
+
msgid "Text Snippet"
|
1122 |
+
msgstr ""
|
1123 |
+
|
1124 |
+
#: includes/class-wpcode-snippet-execute.php:86
|
1125 |
+
msgid "JavaScript Snippet"
|
1126 |
+
msgstr ""
|
1127 |
+
|
1128 |
+
#: includes/class-wpcode-snippet-execute.php:90
|
1129 |
+
msgid "PHP Snippet"
|
1130 |
+
msgstr ""
|
1131 |
+
|
1132 |
+
#: includes/class-wpcode-snippet-execute.php:94
|
1133 |
+
msgid "Universal Snippet"
|
1134 |
+
msgstr ""
|
1135 |
+
|
1136 |
+
#: includes/class-wpcode-snippet-execute.php:351
|
1137 |
+
msgid "Snippet has not been activated due to an error."
|
1138 |
+
msgstr ""
|
1139 |
+
|
1140 |
+
#: includes/class-wpcode-snippet-execute.php:355
|
1141 |
+
msgid "Please click the back button in the browser to update the snippet."
|
1142 |
+
msgstr ""
|
1143 |
+
|
1144 |
+
#: includes/class-wpcode-snippet-execute.php:358
|
1145 |
+
msgid "WPCode has detected an error in one of the snippets which has now been automatically deactivated."
|
1146 |
+
msgstr ""
|
1147 |
+
|
1148 |
+
#. Translators: the placeholders add a link to edit the snippet that threw the error.
|
1149 |
+
#: includes/class-wpcode-snippet-execute.php:370
|
1150 |
+
msgid "%1$sClick here%2$s to update the snippet that threw the error."
|
1151 |
+
msgstr ""
|
1152 |
+
|
1153 |
+
#: includes/class-wpcode-snippet-execute.php:373
|
1154 |
+
msgid "Error message:"
|
1155 |
+
msgstr ""
|
1156 |
+
|
1157 |
+
#: includes/class-wpcode-snippet.php:371
|
1158 |
+
msgid "You are not allowed to change snippet status, please contact your webmaster."
|
1159 |
+
msgstr ""
|
1160 |
+
|
1161 |
+
#: includes/class-wpcode-snippet.php:528
|
1162 |
+
msgid "Untitled Snippet"
|
1163 |
+
msgstr ""
|
1164 |
+
|
1165 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:26
|
1166 |
+
msgid "Page"
|
1167 |
+
msgstr ""
|
1168 |
+
|
1169 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:37
|
1170 |
+
msgid "Type of page"
|
1171 |
+
msgstr ""
|
1172 |
+
|
1173 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:41
|
1174 |
+
msgid "Homepage"
|
1175 |
+
msgstr ""
|
1176 |
+
|
1177 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:45
|
1178 |
+
msgid "Archive"
|
1179 |
+
msgstr ""
|
1180 |
+
|
1181 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:49
|
1182 |
+
msgid "Single post/page"
|
1183 |
+
msgstr ""
|
1184 |
+
|
1185 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:53
|
1186 |
+
msgid "Search page"
|
1187 |
+
msgstr ""
|
1188 |
+
|
1189 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:57
|
1190 |
+
msgid "404 page"
|
1191 |
+
msgstr ""
|
1192 |
+
|
1193 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:61
|
1194 |
+
msgid "Author page"
|
1195 |
+
msgstr ""
|
1196 |
+
|
1197 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:68
|
1198 |
+
#: includes/generator/class-wpcode-generator-query.php:204
|
1199 |
+
msgid "Post type"
|
1200 |
+
msgstr ""
|
1201 |
+
|
1202 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:74
|
1203 |
+
msgid "Referrer"
|
1204 |
+
msgstr ""
|
1205 |
+
|
1206 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:79
|
1207 |
+
msgid "Taxonomy page"
|
1208 |
+
msgstr ""
|
1209 |
+
|
1210 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:85
|
1211 |
+
msgid "Taxonomy term"
|
1212 |
+
msgstr ""
|
1213 |
+
|
1214 |
+
#: includes/conditional-logic/class-wpcode-conditional-page.php:92
|
1215 |
+
msgid "Page URL"
|
1216 |
+
msgstr ""
|
1217 |
+
|
1218 |
+
#: includes/conditional-logic/class-wpcode-conditional-user.php:26
|
1219 |
+
msgid "User"
|
1220 |
+
msgstr ""
|
1221 |
+
|
1222 |
+
#: includes/conditional-logic/class-wpcode-conditional-user.php:37
|
1223 |
+
msgid "Logged-in"
|
1224 |
+
msgstr ""
|
1225 |
+
|
1226 |
+
#: includes/conditional-logic/class-wpcode-conditional-user.php:41
|
1227 |
+
msgid "True"
|
1228 |
+
msgstr ""
|
1229 |
+
|
1230 |
+
#: includes/conditional-logic/class-wpcode-conditional-user.php:45
|
1231 |
+
msgid "False"
|
1232 |
+
msgstr ""
|
1233 |
+
|
1234 |
+
#: includes/conditional-logic/class-wpcode-conditional-user.php:52
|
1235 |
+
msgid "User Role"
|
1236 |
+
msgstr ""
|
1237 |
+
|
1238 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:35
|
1239 |
+
msgid "Admin Bar Menu"
|
1240 |
+
msgstr ""
|
1241 |
+
|
1242 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:36
|
1243 |
+
msgid "Add a custom admin bar menu with links or content."
|
1244 |
+
msgstr ""
|
1245 |
+
|
1246 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:47
|
1247 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:47
|
1248 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:47
|
1249 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1279
|
1250 |
+
#: includes/generator/class-wpcode-generator-menu.php:47
|
1251 |
+
#: includes/generator/class-wpcode-generator-post-status.php:47
|
1252 |
+
#: includes/generator/class-wpcode-generator-post-type.php:47
|
1253 |
+
#: includes/generator/class-wpcode-generator-query.php:72
|
1254 |
+
#: includes/generator/class-wpcode-generator-script.php:47
|
1255 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:47
|
1256 |
+
#: includes/generator/class-wpcode-generator-style.php:47
|
1257 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:47
|
1258 |
+
#: includes/generator/class-wpcode-generator-widget.php:47
|
1259 |
+
msgid "Info"
|
1260 |
+
msgstr ""
|
1261 |
+
|
1262 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:54
|
1263 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:54
|
1264 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:54
|
1265 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1286
|
1266 |
+
#: includes/generator/class-wpcode-generator-menu.php:54
|
1267 |
+
#: includes/generator/class-wpcode-generator-post-status.php:54
|
1268 |
+
#: includes/generator/class-wpcode-generator-post-type.php:54
|
1269 |
+
#: includes/generator/class-wpcode-generator-query.php:79
|
1270 |
+
#: includes/generator/class-wpcode-generator-script.php:54
|
1271 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:54
|
1272 |
+
#: includes/generator/class-wpcode-generator-style.php:54
|
1273 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:54
|
1274 |
+
#: includes/generator/class-wpcode-generator-widget.php:54
|
1275 |
+
msgid "Overview"
|
1276 |
+
msgstr ""
|
1277 |
+
|
1278 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:55
|
1279 |
+
msgid "Generate a snippet to add a custom menu to the admin bar by filling in a simple form."
|
1280 |
+
msgstr ""
|
1281 |
+
|
1282 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:63
|
1283 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:63
|
1284 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:68
|
1285 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1304
|
1286 |
+
#: includes/generator/class-wpcode-generator-menu.php:68
|
1287 |
+
#: includes/generator/class-wpcode-generator-post-status.php:63
|
1288 |
+
#: includes/generator/class-wpcode-generator-post-type.php:63
|
1289 |
+
#: includes/generator/class-wpcode-generator-query.php:93
|
1290 |
+
#: includes/generator/class-wpcode-generator-script.php:63
|
1291 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:68
|
1292 |
+
#: includes/generator/class-wpcode-generator-style.php:63
|
1293 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:63
|
1294 |
+
#: includes/generator/class-wpcode-generator-widget.php:63
|
1295 |
+
msgid "Usage"
|
1296 |
+
msgstr ""
|
1297 |
+
|
1298 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:65
|
1299 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:65
|
1300 |
+
msgid "Fill in the forms sections using the menu on the left."
|
1301 |
+
msgstr ""
|
1302 |
+
|
1303 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:66
|
1304 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:66
|
1305 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:71
|
1306 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1307
|
1307 |
+
#: includes/generator/class-wpcode-generator-menu.php:71
|
1308 |
+
#: includes/generator/class-wpcode-generator-post-status.php:66
|
1309 |
+
#: includes/generator/class-wpcode-generator-post-type.php:66
|
1310 |
+
#: includes/generator/class-wpcode-generator-query.php:96
|
1311 |
+
#: includes/generator/class-wpcode-generator-script.php:66
|
1312 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:71
|
1313 |
+
#: includes/generator/class-wpcode-generator-style.php:66
|
1314 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:66
|
1315 |
+
#: includes/generator/class-wpcode-generator-widget.php:66
|
1316 |
+
msgid "Click the \"Update Code\" button."
|
1317 |
+
msgstr ""
|
1318 |
+
|
1319 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:67
|
1320 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:67
|
1321 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:72
|
1322 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1308
|
1323 |
+
#: includes/generator/class-wpcode-generator-menu.php:72
|
1324 |
+
#: includes/generator/class-wpcode-generator-post-status.php:67
|
1325 |
+
#: includes/generator/class-wpcode-generator-post-type.php:67
|
1326 |
+
#: includes/generator/class-wpcode-generator-query.php:97
|
1327 |
+
#: includes/generator/class-wpcode-generator-script.php:67
|
1328 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:72
|
1329 |
+
#: includes/generator/class-wpcode-generator-style.php:67
|
1330 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:67
|
1331 |
+
#: includes/generator/class-wpcode-generator-widget.php:67
|
1332 |
+
msgid "Click on \"Use Snippet\" to create a new snippet with the generated code."
|
1333 |
+
msgstr ""
|
1334 |
+
|
1335 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:68
|
1336 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:68
|
1337 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:73
|
1338 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1309
|
1339 |
+
#: includes/generator/class-wpcode-generator-menu.php:73
|
1340 |
+
#: includes/generator/class-wpcode-generator-post-status.php:68
|
1341 |
+
#: includes/generator/class-wpcode-generator-post-type.php:68
|
1342 |
+
#: includes/generator/class-wpcode-generator-query.php:98
|
1343 |
+
#: includes/generator/class-wpcode-generator-script.php:68
|
1344 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:73
|
1345 |
+
#: includes/generator/class-wpcode-generator-style.php:68
|
1346 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:68
|
1347 |
+
#: includes/generator/class-wpcode-generator-widget.php:68
|
1348 |
+
msgid "Activate and save the snippet and you're ready to go"
|
1349 |
+
msgstr ""
|
1350 |
+
|
1351 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:77
|
1352 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:77
|
1353 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:82
|
1354 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1318
|
1355 |
+
#: includes/generator/class-wpcode-generator-menu.php:82
|
1356 |
+
#: includes/generator/class-wpcode-generator-post-status.php:77
|
1357 |
+
#: includes/generator/class-wpcode-generator-post-type.php:77
|
1358 |
+
#: includes/generator/class-wpcode-generator-query.php:107
|
1359 |
+
#: includes/generator/class-wpcode-generator-script.php:77
|
1360 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:82
|
1361 |
+
#: includes/generator/class-wpcode-generator-style.php:77
|
1362 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:77
|
1363 |
+
#: includes/generator/class-wpcode-generator-widget.php:77
|
1364 |
+
msgid "Examples"
|
1365 |
+
msgstr ""
|
1366 |
+
|
1367 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:78
|
1368 |
+
msgid "You could add a new admin bar menu for links you use often, a list of posts, a site you often visit when in the admin, etc."
|
1369 |
+
msgstr ""
|
1370 |
+
|
1371 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:84
|
1372 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:84
|
1373 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:89
|
1374 |
+
#: includes/generator/class-wpcode-generator-menu.php:89
|
1375 |
+
#: includes/generator/class-wpcode-generator-post-status.php:84
|
1376 |
+
#: includes/generator/class-wpcode-generator-post-type.php:84
|
1377 |
+
#: includes/generator/class-wpcode-generator-query.php:114
|
1378 |
+
#: includes/generator/class-wpcode-generator-script.php:89
|
1379 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:89
|
1380 |
+
#: includes/generator/class-wpcode-generator-style.php:89
|
1381 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:84
|
1382 |
+
#: includes/generator/class-wpcode-generator-widget.php:84
|
1383 |
+
msgid "General"
|
1384 |
+
msgstr ""
|
1385 |
+
|
1386 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:90
|
1387 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:90
|
1388 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:95
|
1389 |
+
#: includes/generator/class-wpcode-generator-menu.php:95
|
1390 |
+
#: includes/generator/class-wpcode-generator-post-status.php:90
|
1391 |
+
#: includes/generator/class-wpcode-generator-post-type.php:90
|
1392 |
+
#: includes/generator/class-wpcode-generator-script.php:95
|
1393 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:95
|
1394 |
+
#: includes/generator/class-wpcode-generator-style.php:95
|
1395 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:90
|
1396 |
+
msgid "Function name"
|
1397 |
+
msgstr ""
|
1398 |
+
|
1399 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:91
|
1400 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:96
|
1401 |
+
#: includes/generator/class-wpcode-generator-menu.php:96
|
1402 |
+
#: includes/generator/class-wpcode-generator-post-status.php:91
|
1403 |
+
#: includes/generator/class-wpcode-generator-post-type.php:91
|
1404 |
+
#: includes/generator/class-wpcode-generator-script.php:96
|
1405 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:96
|
1406 |
+
#: includes/generator/class-wpcode-generator-style.php:96
|
1407 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:91
|
1408 |
+
msgid "Make this unique to avoid conflicts with other snippets"
|
1409 |
+
msgstr ""
|
1410 |
+
|
1411 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:101
|
1412 |
+
msgid "Position"
|
1413 |
+
msgstr ""
|
1414 |
+
|
1415 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:102
|
1416 |
+
msgid "Select where you want the menu item to be displayed on the admin bar."
|
1417 |
+
msgstr ""
|
1418 |
+
|
1419 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:106
|
1420 |
+
msgid "Last item on the left"
|
1421 |
+
msgstr ""
|
1422 |
+
|
1423 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:107
|
1424 |
+
msgid "Before Site Name"
|
1425 |
+
msgstr ""
|
1426 |
+
|
1427 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:108
|
1428 |
+
msgid "After Site Name"
|
1429 |
+
msgstr ""
|
1430 |
+
|
1431 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:117
|
1432 |
+
msgid "Menu Structure"
|
1433 |
+
msgstr ""
|
1434 |
+
|
1435 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:123
|
1436 |
+
msgid "Menu ID"
|
1437 |
+
msgstr ""
|
1438 |
+
|
1439 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:124
|
1440 |
+
msgid "Unique menu id for the admin bar menu."
|
1441 |
+
msgstr ""
|
1442 |
+
|
1443 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:131
|
1444 |
+
msgid "Menu Title"
|
1445 |
+
msgstr ""
|
1446 |
+
|
1447 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:132
|
1448 |
+
msgid "Text or HTML that will show up in the admin bar top-level item. Use HTML if you want to display an image."
|
1449 |
+
msgstr ""
|
1450 |
+
|
1451 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:139
|
1452 |
+
msgid "Menu item link"
|
1453 |
+
msgstr ""
|
1454 |
+
|
1455 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:140
|
1456 |
+
msgid "If left empty, the top level menu item will not be a link, just text."
|
1457 |
+
msgstr ""
|
1458 |
+
|
1459 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:147
|
1460 |
+
msgid "Menu item target"
|
1461 |
+
msgstr ""
|
1462 |
+
|
1463 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:148
|
1464 |
+
msgid "The menu item is a link use this field to set the target attribute. Use \"_blank\" to open the link in a new tab."
|
1465 |
+
msgstr ""
|
1466 |
+
|
1467 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:158
|
1468 |
+
msgid "Submenu Item Title"
|
1469 |
+
msgstr ""
|
1470 |
+
|
1471 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:159
|
1472 |
+
msgid "Text or HTML for the submenu item."
|
1473 |
+
msgstr ""
|
1474 |
+
|
1475 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:167
|
1476 |
+
msgid "Submenu item link"
|
1477 |
+
msgstr ""
|
1478 |
+
|
1479 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:168
|
1480 |
+
msgid "If left empty, this menu item will not be a link, just text."
|
1481 |
+
msgstr ""
|
1482 |
+
|
1483 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:176
|
1484 |
+
msgid "Submenu item target attribute"
|
1485 |
+
msgstr ""
|
1486 |
+
|
1487 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:177
|
1488 |
+
msgid "If the menu item is a link use this for the target attribute. Use \"_blank\" to open in a new tab."
|
1489 |
+
msgstr ""
|
1490 |
+
|
1491 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:188
|
1492 |
+
msgid "Add more submenu items"
|
1493 |
+
msgstr ""
|
1494 |
+
|
1495 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:189
|
1496 |
+
msgid "Use the \"Add submenu item\" button below to add multiple submenu items."
|
1497 |
+
msgstr ""
|
1498 |
+
|
1499 |
+
#: includes/generator/class-wpcode-generator-admin-bar.php:193
|
1500 |
+
msgid "Add submenu item"
|
1501 |
+
msgstr ""
|
1502 |
+
|
1503 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:35
|
1504 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:111
|
1505 |
+
msgid "Contact Methods"
|
1506 |
+
msgstr ""
|
1507 |
+
|
1508 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:36
|
1509 |
+
msgid "Add additional contact methods to WordPress user profiles."
|
1510 |
+
msgstr ""
|
1511 |
+
|
1512 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:55
|
1513 |
+
msgid "Use this generator to create a snippet which adds more contact methods to your WordPress users profiles."
|
1514 |
+
msgstr ""
|
1515 |
+
|
1516 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:78
|
1517 |
+
msgid "You can add extra fields for user profiles like their extended address, city, country, phone number, social media profiles (Facebook, Twitter, etc)."
|
1518 |
+
msgstr ""
|
1519 |
+
|
1520 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:91
|
1521 |
+
msgid "Make this unique to avoid conflicts with other snippets."
|
1522 |
+
msgstr ""
|
1523 |
+
|
1524 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:101
|
1525 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:106
|
1526 |
+
#: includes/generator/class-wpcode-generator-menu.php:106
|
1527 |
+
#: includes/generator/class-wpcode-generator-post-status.php:101
|
1528 |
+
#: includes/generator/class-wpcode-generator-post-type.php:101
|
1529 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:106
|
1530 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:102
|
1531 |
+
#: includes/generator/class-wpcode-generator-widget.php:113
|
1532 |
+
msgid "Text Domain"
|
1533 |
+
msgstr ""
|
1534 |
+
|
1535 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:102
|
1536 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:107
|
1537 |
+
#: includes/generator/class-wpcode-generator-menu.php:107
|
1538 |
+
#: includes/generator/class-wpcode-generator-post-status.php:102
|
1539 |
+
#: includes/generator/class-wpcode-generator-post-type.php:102
|
1540 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:107
|
1541 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:103
|
1542 |
+
msgid "Optional text domain for translations."
|
1543 |
+
msgstr ""
|
1544 |
+
|
1545 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:117
|
1546 |
+
msgid "Contact Method Slug"
|
1547 |
+
msgstr ""
|
1548 |
+
|
1549 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:118
|
1550 |
+
msgid "A lowercase with no spaces slug for usage in the code. For example: \"facebook\" or \"telephone\"."
|
1551 |
+
msgstr ""
|
1552 |
+
|
1553 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:126
|
1554 |
+
msgid "Contact Method Label"
|
1555 |
+
msgstr ""
|
1556 |
+
|
1557 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:127
|
1558 |
+
msgid "This will show up as a label next to the contact method field. For example: \"Facebook URL\" or \"Phone number\"."
|
1559 |
+
msgstr ""
|
1560 |
+
|
1561 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:138
|
1562 |
+
msgid "Add more contact methods"
|
1563 |
+
msgstr ""
|
1564 |
+
|
1565 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:139
|
1566 |
+
msgid "Use the \"Add contact method\" button below to add as many contact methods as you wish."
|
1567 |
+
msgstr ""
|
1568 |
+
|
1569 |
+
#: includes/generator/class-wpcode-generator-contact-methods.php:143
|
1570 |
+
msgid "Add contact method"
|
1571 |
+
msgstr ""
|
1572 |
+
|
1573 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:35
|
1574 |
+
msgid "Schedule a Cron Job"
|
1575 |
+
msgstr ""
|
1576 |
+
|
1577 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:36
|
1578 |
+
msgid "Generate a snippet to schedule a recurring event using the WordPress cron."
|
1579 |
+
msgstr ""
|
1580 |
+
|
1581 |
+
#. Translators: Placeholders add links to the wordpress.org references.
|
1582 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:57
|
1583 |
+
msgid "This generator makes it easy to generate a snippet that will schedule a recurring event using %1$swp_schedule_event%2$s."
|
1584 |
+
msgstr ""
|
1585 |
+
|
1586 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:70
|
1587 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1306
|
1588 |
+
#: includes/generator/class-wpcode-generator-menu.php:70
|
1589 |
+
#: includes/generator/class-wpcode-generator-post-status.php:65
|
1590 |
+
#: includes/generator/class-wpcode-generator-post-type.php:65
|
1591 |
+
#: includes/generator/class-wpcode-generator-query.php:95
|
1592 |
+
#: includes/generator/class-wpcode-generator-script.php:65
|
1593 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:70
|
1594 |
+
#: includes/generator/class-wpcode-generator-style.php:65
|
1595 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:65
|
1596 |
+
#: includes/generator/class-wpcode-generator-widget.php:65
|
1597 |
+
msgid "Fill in the forms using the menu on the left."
|
1598 |
+
msgstr ""
|
1599 |
+
|
1600 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:83
|
1601 |
+
msgid "You may want to run some code once every hour, day or week, for example you could use this to send an email with the number of published posts every week."
|
1602 |
+
msgstr ""
|
1603 |
+
|
1604 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:116
|
1605 |
+
msgid "Schedule"
|
1606 |
+
msgstr ""
|
1607 |
+
|
1608 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:122
|
1609 |
+
msgid "Recurrence"
|
1610 |
+
msgstr ""
|
1611 |
+
|
1612 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:123
|
1613 |
+
msgid "Choose how often you want this event to run."
|
1614 |
+
msgstr ""
|
1615 |
+
|
1616 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:127
|
1617 |
+
msgid "Hourly"
|
1618 |
+
msgstr ""
|
1619 |
+
|
1620 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:128
|
1621 |
+
msgid "Twice Daily"
|
1622 |
+
msgstr ""
|
1623 |
+
|
1624 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:129
|
1625 |
+
msgid "Daily"
|
1626 |
+
msgstr ""
|
1627 |
+
|
1628 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:130
|
1629 |
+
msgid "Custom"
|
1630 |
+
msgstr ""
|
1631 |
+
|
1632 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:138
|
1633 |
+
msgid "Custom Recurrence Name"
|
1634 |
+
msgstr ""
|
1635 |
+
|
1636 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:139
|
1637 |
+
msgid "This is the recurrence name slug, lowercase and no space."
|
1638 |
+
msgstr ""
|
1639 |
+
|
1640 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:145
|
1641 |
+
msgid "Custom Recurrence Label"
|
1642 |
+
msgstr ""
|
1643 |
+
|
1644 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:148
|
1645 |
+
msgid "This label will be used in a list of cron events, for example."
|
1646 |
+
msgstr ""
|
1647 |
+
|
1648 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:152
|
1649 |
+
msgid "Custom Recurrence Interval"
|
1650 |
+
msgstr ""
|
1651 |
+
|
1652 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:155
|
1653 |
+
msgid "The number of seconds of this interval."
|
1654 |
+
msgstr ""
|
1655 |
+
|
1656 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:161
|
1657 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1379
|
1658 |
+
msgid "Code"
|
1659 |
+
msgstr ""
|
1660 |
+
|
1661 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:167
|
1662 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1342
|
1663 |
+
msgid "Hook name"
|
1664 |
+
msgstr ""
|
1665 |
+
|
1666 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:168
|
1667 |
+
msgid "Unique name of your hook used to run when scheduled."
|
1668 |
+
msgstr ""
|
1669 |
+
|
1670 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:177
|
1671 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1385
|
1672 |
+
msgid "PHP Code"
|
1673 |
+
msgstr ""
|
1674 |
+
|
1675 |
+
#: includes/generator/class-wpcode-generator-cronjob.php:178
|
1676 |
+
msgid "Custom PHP code that will run when the event is triggered."
|
1677 |
+
msgstr ""
|
1678 |
+
|
1679 |
+
#: includes/generator/class-wpcode-generator-hooks.php:35
|
1680 |
+
msgid "Hooks"
|
1681 |
+
msgstr ""
|
1682 |
+
|
1683 |
+
#: includes/generator/class-wpcode-generator-hooks.php:36
|
1684 |
+
msgid "Generate a snippet for an action or a filter using any available hook."
|
1685 |
+
msgstr ""
|
1686 |
+
|
1687 |
+
#. Translators: Placeholders add links to the wordpress.org references.
|
1688 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1289
|
1689 |
+
msgid "Using this generator you can safely add custom %1$shooks%2$s using either %3$sadd_action%4$s or %5$sadd_filter%6$s."
|
1690 |
+
msgstr ""
|
1691 |
+
|
1692 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1319
|
1693 |
+
msgid "You can use this to quickly get started with adding an action or filter."
|
1694 |
+
msgstr ""
|
1695 |
+
|
1696 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1325
|
1697 |
+
msgid "Hook Details"
|
1698 |
+
msgstr ""
|
1699 |
+
|
1700 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1331
|
1701 |
+
msgid "Hook type"
|
1702 |
+
msgstr ""
|
1703 |
+
|
1704 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1332
|
1705 |
+
msgid "Can be either an action or a filter"
|
1706 |
+
msgstr ""
|
1707 |
+
|
1708 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1336
|
1709 |
+
msgid "Action"
|
1710 |
+
msgstr ""
|
1711 |
+
|
1712 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1343
|
1713 |
+
msgid "Input hook name or pick one from the suggested list as you type."
|
1714 |
+
msgstr ""
|
1715 |
+
|
1716 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1353
|
1717 |
+
msgid "Callback function"
|
1718 |
+
msgstr ""
|
1719 |
+
|
1720 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1354
|
1721 |
+
msgid "Name of the function you want to add to this hook."
|
1722 |
+
msgstr ""
|
1723 |
+
|
1724 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1361
|
1725 |
+
msgid "Priority of this hook, by default 10."
|
1726 |
+
msgstr ""
|
1727 |
+
|
1728 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1370
|
1729 |
+
msgid "Arguments list"
|
1730 |
+
msgstr ""
|
1731 |
+
|
1732 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1371
|
1733 |
+
msgid "Add comma-separated custom arguments that will be passed to the callback function depending on the action/filter."
|
1734 |
+
msgstr ""
|
1735 |
+
|
1736 |
+
#: includes/generator/class-wpcode-generator-hooks.php:1386
|
1737 |
+
msgid "Custom PHP code you want to run in the function, you can also edit this after you create the snippet."
|
1738 |
+
msgstr ""
|
1739 |
+
|
1740 |
+
#: includes/generator/class-wpcode-generator-menu.php:35
|
1741 |
+
msgid "Navigation Menu"
|
1742 |
+
msgstr ""
|
1743 |
+
|
1744 |
+
#: includes/generator/class-wpcode-generator-menu.php:36
|
1745 |
+
msgid "Generate a snippet to register new navigation menus for your website."
|
1746 |
+
msgstr ""
|
1747 |
+
|
1748 |
+
#. Translators: Placeholders add links to the wordpress.org references.
|
1749 |
+
#: includes/generator/class-wpcode-generator-menu.php:57
|
1750 |
+
msgid "This generator makes it easy to add new navigation menus to your website using the \"register_nav_menus\" function."
|
1751 |
+
msgstr ""
|
1752 |
+
|
1753 |
+
#: includes/generator/class-wpcode-generator-menu.php:83
|
1754 |
+
msgid "You can add a new navigation menu for your website to display in a flyout menu that is not part of the theme, for example."
|
1755 |
+
msgstr ""
|
1756 |
+
|
1757 |
+
#: includes/generator/class-wpcode-generator-menu.php:116
|
1758 |
+
msgid "Menus"
|
1759 |
+
msgstr ""
|
1760 |
+
|
1761 |
+
#: includes/generator/class-wpcode-generator-menu.php:122
|
1762 |
+
msgid "Menu name"
|
1763 |
+
msgstr ""
|
1764 |
+
|
1765 |
+
#: includes/generator/class-wpcode-generator-menu.php:123
|
1766 |
+
msgid "This is the menu name slug, lowercase and no space."
|
1767 |
+
msgstr ""
|
1768 |
+
|
1769 |
+
#: includes/generator/class-wpcode-generator-menu.php:130
|
1770 |
+
msgid "Menu label"
|
1771 |
+
msgstr ""
|
1772 |
+
|
1773 |
+
#: includes/generator/class-wpcode-generator-menu.php:131
|
1774 |
+
msgid "Add a descriptive label for this menu in the admin."
|
1775 |
+
msgstr ""
|
1776 |
+
|
1777 |
+
#: includes/generator/class-wpcode-generator-menu.php:141
|
1778 |
+
msgid "Add another menu"
|
1779 |
+
msgstr ""
|
1780 |
+
|
1781 |
+
#: includes/generator/class-wpcode-generator-menu.php:142
|
1782 |
+
msgid "Use the \"Add menu\" button below to add as many menu locations as you need."
|
1783 |
+
msgstr ""
|
1784 |
+
|
1785 |
+
#: includes/generator/class-wpcode-generator-menu.php:146
|
1786 |
+
msgid "Add Menu"
|
1787 |
+
msgstr ""
|
1788 |
+
|
1789 |
+
#: includes/generator/class-wpcode-generator-post-status.php:35
|
1790 |
+
#: includes/generator/class-wpcode-generator-post-status.php:117
|
1791 |
+
msgid "Post Status"
|
1792 |
+
msgstr ""
|
1793 |
+
|
1794 |
+
#: includes/generator/class-wpcode-generator-post-status.php:36
|
1795 |
+
msgid "Use this tool to generate a custom post status for your posts."
|
1796 |
+
msgstr ""
|
1797 |
+
|
1798 |
+
#: includes/generator/class-wpcode-generator-post-status.php:55
|
1799 |
+
msgid "Generate custom post statuses for your posts to improve the way you manage content."
|
1800 |
+
msgstr ""
|
1801 |
+
|
1802 |
+
#: includes/generator/class-wpcode-generator-post-status.php:78
|
1803 |
+
msgid "You could add a new status called \"Pending Review\" that your authors can use before the content will be published"
|
1804 |
+
msgstr ""
|
1805 |
+
|
1806 |
+
#: includes/generator/class-wpcode-generator-post-status.php:118
|
1807 |
+
msgid "Name of status used in the code, lowercase maximum 32 characters."
|
1808 |
+
msgstr ""
|
1809 |
+
|
1810 |
+
#: includes/generator/class-wpcode-generator-post-status.php:136
|
1811 |
+
#: includes/generator/class-wpcode-generator-post-type.php:144
|
1812 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:137
|
1813 |
+
msgid "Name (Plural)"
|
1814 |
+
msgstr ""
|
1815 |
+
|
1816 |
+
#: includes/generator/class-wpcode-generator-post-status.php:146
|
1817 |
+
#: includes/generator/class-wpcode-generator-post-type.php:441
|
1818 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:309
|
1819 |
+
msgid "Visibility"
|
1820 |
+
msgstr ""
|
1821 |
+
|
1822 |
+
#: includes/generator/class-wpcode-generator-post-status.php:152
|
1823 |
+
#: includes/generator/class-wpcode-generator-post-type.php:447
|
1824 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:315
|
1825 |
+
msgid "Public"
|
1826 |
+
msgstr ""
|
1827 |
+
|
1828 |
+
#: includes/generator/class-wpcode-generator-post-status.php:153
|
1829 |
+
#: includes/generator/class-wpcode-generator-post-status.php:167
|
1830 |
+
msgid "Should the posts with this status be visible in the frontend?"
|
1831 |
+
msgstr ""
|
1832 |
+
|
1833 |
+
#: includes/generator/class-wpcode-generator-post-status.php:156
|
1834 |
+
#: includes/generator/class-wpcode-generator-post-status.php:184
|
1835 |
+
msgid "Yes - Default"
|
1836 |
+
msgstr ""
|
1837 |
+
|
1838 |
+
#: includes/generator/class-wpcode-generator-post-status.php:157
|
1839 |
+
#: includes/generator/class-wpcode-generator-post-status.php:185
|
1840 |
+
#: includes/generator/class-wpcode-generator-post-type.php:411
|
1841 |
+
#: includes/generator/class-wpcode-generator-post-type.php:426
|
1842 |
+
#: includes/generator/class-wpcode-generator-post-type.php:454
|
1843 |
+
#: includes/generator/class-wpcode-generator-post-type.php:465
|
1844 |
+
#: includes/generator/class-wpcode-generator-post-type.php:479
|
1845 |
+
#: includes/generator/class-wpcode-generator-post-type.php:521
|
1846 |
+
#: includes/generator/class-wpcode-generator-post-type.php:532
|
1847 |
+
#: includes/generator/class-wpcode-generator-post-type.php:552
|
1848 |
+
#: includes/generator/class-wpcode-generator-post-type.php:622
|
1849 |
+
#: includes/generator/class-wpcode-generator-post-type.php:636
|
1850 |
+
#: includes/generator/class-wpcode-generator-post-type.php:647
|
1851 |
+
#: includes/generator/class-wpcode-generator-query.php:137
|
1852 |
+
#: includes/generator/class-wpcode-generator-query.php:342
|
1853 |
+
#: includes/generator/class-wpcode-generator-query.php:437
|
1854 |
+
#: includes/generator/class-wpcode-generator-script.php:210
|
1855 |
+
#: includes/generator/class-wpcode-generator-script.php:229
|
1856 |
+
#: includes/generator/class-wpcode-generator-style.php:211
|
1857 |
+
#: includes/generator/class-wpcode-generator-style.php:230
|
1858 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:322
|
1859 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:336
|
1860 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:347
|
1861 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:361
|
1862 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:372
|
1863 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:417
|
1864 |
+
msgid "No"
|
1865 |
+
msgstr ""
|
1866 |
+
|
1867 |
+
#: includes/generator/class-wpcode-generator-post-status.php:166
|
1868 |
+
msgid "Exclude from search results"
|
1869 |
+
msgstr ""
|
1870 |
+
|
1871 |
+
#: includes/generator/class-wpcode-generator-post-status.php:170
|
1872 |
+
#: includes/generator/class-wpcode-generator-post-status.php:195
|
1873 |
+
#: includes/generator/class-wpcode-generator-post-type.php:399
|
1874 |
+
#: includes/generator/class-wpcode-generator-post-type.php:551
|
1875 |
+
#: includes/generator/class-wpcode-generator-post-type.php:757
|
1876 |
+
#: includes/generator/class-wpcode-generator-query.php:136
|
1877 |
+
#: includes/generator/class-wpcode-generator-query.php:379
|
1878 |
+
#: includes/generator/class-wpcode-generator-query.php:436
|
1879 |
+
#: includes/generator/class-wpcode-generator-script.php:211
|
1880 |
+
#: includes/generator/class-wpcode-generator-script.php:228
|
1881 |
+
#: includes/generator/class-wpcode-generator-style.php:212
|
1882 |
+
#: includes/generator/class-wpcode-generator-style.php:229
|
1883 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:428
|
1884 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:505
|
1885 |
+
msgid "Yes"
|
1886 |
+
msgstr ""
|
1887 |
+
|
1888 |
+
#: includes/generator/class-wpcode-generator-post-status.php:171
|
1889 |
+
#: includes/generator/class-wpcode-generator-post-status.php:196
|
1890 |
+
msgid "No - Default"
|
1891 |
+
msgstr ""
|
1892 |
+
|
1893 |
+
#: includes/generator/class-wpcode-generator-post-status.php:180
|
1894 |
+
msgid "Show in admin all list"
|
1895 |
+
msgstr ""
|
1896 |
+
|
1897 |
+
#: includes/generator/class-wpcode-generator-post-status.php:181
|
1898 |
+
msgid "Show statuses in the edit listing of the post."
|
1899 |
+
msgstr ""
|
1900 |
+
|
1901 |
+
#: includes/generator/class-wpcode-generator-post-status.php:191
|
1902 |
+
msgid "Show in admin status list"
|
1903 |
+
msgstr ""
|
1904 |
+
|
1905 |
+
#: includes/generator/class-wpcode-generator-post-status.php:192
|
1906 |
+
msgid "Show statuses list at the top of the edit listings. e.g. Published (12) Custom Status (2)"
|
1907 |
+
msgstr ""
|
1908 |
+
|
1909 |
+
#: includes/generator/class-wpcode-generator-post-type.php:35
|
1910 |
+
#: includes/generator/class-wpcode-generator-post-type.php:111
|
1911 |
+
msgid "Post Type"
|
1912 |
+
msgstr ""
|
1913 |
+
|
1914 |
+
#: includes/generator/class-wpcode-generator-post-type.php:36
|
1915 |
+
msgid "Use this tool to generate a custom post type for your website."
|
1916 |
+
msgstr ""
|
1917 |
+
|
1918 |
+
#: includes/generator/class-wpcode-generator-post-type.php:55
|
1919 |
+
msgid "Generate custom post types for your website using a snippet."
|
1920 |
+
msgstr ""
|
1921 |
+
|
1922 |
+
#: includes/generator/class-wpcode-generator-post-type.php:78
|
1923 |
+
msgid "You can add custom post types for specific items that are not blog posts, for example, if your site is about music you can have post types for artists, albums or songs."
|
1924 |
+
msgstr ""
|
1925 |
+
|
1926 |
+
#: includes/generator/class-wpcode-generator-post-type.php:117
|
1927 |
+
msgid "Post Type Key"
|
1928 |
+
msgstr ""
|
1929 |
+
|
1930 |
+
#: includes/generator/class-wpcode-generator-post-type.php:118
|
1931 |
+
msgid "Name of post type used in the code, lowercase maximum 20 characters."
|
1932 |
+
msgstr ""
|
1933 |
+
|
1934 |
+
#: includes/generator/class-wpcode-generator-post-type.php:125
|
1935 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:138
|
1936 |
+
#: includes/generator/class-wpcode-generator-widget.php:150
|
1937 |
+
#: includes/generator/class-wpcode-generator-widget.php:223
|
1938 |
+
msgid "Description"
|
1939 |
+
msgstr ""
|
1940 |
+
|
1941 |
+
#: includes/generator/class-wpcode-generator-post-type.php:126
|
1942 |
+
msgid "A short description of the post type."
|
1943 |
+
msgstr ""
|
1944 |
+
|
1945 |
+
#: includes/generator/class-wpcode-generator-post-type.php:137
|
1946 |
+
msgid "The singular post type name (e.g. Artist, Album, Song)."
|
1947 |
+
msgstr ""
|
1948 |
+
|
1949 |
+
#: includes/generator/class-wpcode-generator-post-type.php:145
|
1950 |
+
msgid "The post type plural name (e.g. Artists, Albums, Songs)."
|
1951 |
+
msgstr ""
|
1952 |
+
|
1953 |
+
#: includes/generator/class-wpcode-generator-post-type.php:155
|
1954 |
+
msgid "Link To Taxonomies"
|
1955 |
+
msgstr ""
|
1956 |
+
|
1957 |
+
#: includes/generator/class-wpcode-generator-post-type.php:156
|
1958 |
+
msgid "Comma-separated list of Taxonomies (e.g. post_tag, category)"
|
1959 |
+
msgstr ""
|
1960 |
+
|
1961 |
+
#: includes/generator/class-wpcode-generator-post-type.php:163
|
1962 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:156
|
1963 |
+
msgid "Hierarchical"
|
1964 |
+
msgstr ""
|
1965 |
+
|
1966 |
+
#: includes/generator/class-wpcode-generator-post-type.php:164
|
1967 |
+
msgid "Hierarchical post types can have parents/children."
|
1968 |
+
msgstr ""
|
1969 |
+
|
1970 |
+
#: includes/generator/class-wpcode-generator-post-type.php:168
|
1971 |
+
msgid "Yes, like pages"
|
1972 |
+
msgstr ""
|
1973 |
+
|
1974 |
+
#: includes/generator/class-wpcode-generator-post-type.php:169
|
1975 |
+
msgid "No, like posts"
|
1976 |
+
msgstr ""
|
1977 |
+
|
1978 |
+
#: includes/generator/class-wpcode-generator-post-type.php:176
|
1979 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:169
|
1980 |
+
msgid "Labels"
|
1981 |
+
msgstr ""
|
1982 |
+
|
1983 |
+
#: includes/generator/class-wpcode-generator-post-type.php:182
|
1984 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:175
|
1985 |
+
msgid "Menu Name"
|
1986 |
+
msgstr ""
|
1987 |
+
|
1988 |
+
#: includes/generator/class-wpcode-generator-post-type.php:189
|
1989 |
+
msgid "Admin Bar Name"
|
1990 |
+
msgstr ""
|
1991 |
+
|
1992 |
+
#: includes/generator/class-wpcode-generator-post-type.php:196
|
1993 |
+
msgid "Archives"
|
1994 |
+
msgstr ""
|
1995 |
+
|
1996 |
+
#: includes/generator/class-wpcode-generator-post-type.php:203
|
1997 |
+
msgid "Attributes"
|
1998 |
+
msgstr ""
|
1999 |
+
|
2000 |
+
#: includes/generator/class-wpcode-generator-post-type.php:210
|
2001 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:189
|
2002 |
+
msgid "Parent Item"
|
2003 |
+
msgstr ""
|
2004 |
+
|
2005 |
+
#: includes/generator/class-wpcode-generator-post-type.php:217
|
2006 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:182
|
2007 |
+
msgid "All Items"
|
2008 |
+
msgstr ""
|
2009 |
+
|
2010 |
+
#: includes/generator/class-wpcode-generator-post-type.php:224
|
2011 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:210
|
2012 |
+
msgid "Add New Item"
|
2013 |
+
msgstr ""
|
2014 |
+
|
2015 |
+
#: includes/generator/class-wpcode-generator-post-type.php:238
|
2016 |
+
msgid "New Item"
|
2017 |
+
msgstr ""
|
2018 |
+
|
2019 |
+
#: includes/generator/class-wpcode-generator-post-type.php:248
|
2020 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:220
|
2021 |
+
msgid "Edit Item"
|
2022 |
+
msgstr ""
|
2023 |
+
|
2024 |
+
#: includes/generator/class-wpcode-generator-post-type.php:255
|
2025 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:227
|
2026 |
+
msgid "Update Item"
|
2027 |
+
msgstr ""
|
2028 |
+
|
2029 |
+
#: includes/generator/class-wpcode-generator-post-type.php:262
|
2030 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:234
|
2031 |
+
msgid "View Item"
|
2032 |
+
msgstr ""
|
2033 |
+
|
2034 |
+
#: includes/generator/class-wpcode-generator-post-type.php:269
|
2035 |
+
msgid "View Items"
|
2036 |
+
msgstr ""
|
2037 |
+
|
2038 |
+
#: includes/generator/class-wpcode-generator-post-type.php:276
|
2039 |
+
msgid "Search Item"
|
2040 |
+
msgstr ""
|
2041 |
+
|
2042 |
+
#: includes/generator/class-wpcode-generator-post-type.php:283
|
2043 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:279
|
2044 |
+
msgid "Not Found"
|
2045 |
+
msgstr ""
|
2046 |
+
|
2047 |
+
#: includes/generator/class-wpcode-generator-post-type.php:290
|
2048 |
+
msgid "Not Found in Trash"
|
2049 |
+
msgstr ""
|
2050 |
+
|
2051 |
+
#: includes/generator/class-wpcode-generator-post-type.php:297
|
2052 |
+
msgid "Featured Image"
|
2053 |
+
msgstr ""
|
2054 |
+
|
2055 |
+
#: includes/generator/class-wpcode-generator-post-type.php:304
|
2056 |
+
msgid "Set featured image"
|
2057 |
+
msgstr ""
|
2058 |
+
|
2059 |
+
#: includes/generator/class-wpcode-generator-post-type.php:314
|
2060 |
+
msgid "Remove featured image"
|
2061 |
+
msgstr ""
|
2062 |
+
|
2063 |
+
#: includes/generator/class-wpcode-generator-post-type.php:321
|
2064 |
+
msgid "Use as featured image"
|
2065 |
+
msgstr ""
|
2066 |
+
|
2067 |
+
#: includes/generator/class-wpcode-generator-post-type.php:328
|
2068 |
+
msgid "Insert into item"
|
2069 |
+
msgstr ""
|
2070 |
+
|
2071 |
+
#: includes/generator/class-wpcode-generator-post-type.php:335
|
2072 |
+
msgid "Uploaded to this item"
|
2073 |
+
msgstr ""
|
2074 |
+
|
2075 |
+
#: includes/generator/class-wpcode-generator-post-type.php:342
|
2076 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:293
|
2077 |
+
msgid "Items list"
|
2078 |
+
msgstr ""
|
2079 |
+
|
2080 |
+
#: includes/generator/class-wpcode-generator-post-type.php:349
|
2081 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:300
|
2082 |
+
msgid "Items list navigation"
|
2083 |
+
msgstr ""
|
2084 |
+
|
2085 |
+
#: includes/generator/class-wpcode-generator-post-type.php:356
|
2086 |
+
msgid "Filter items list"
|
2087 |
+
msgstr ""
|
2088 |
+
|
2089 |
+
#: includes/generator/class-wpcode-generator-post-type.php:365
|
2090 |
+
#: includes/generator/class-wpcode-generator-widget.php:239
|
2091 |
+
msgid "Options"
|
2092 |
+
msgstr ""
|
2093 |
+
|
2094 |
+
#: includes/generator/class-wpcode-generator-post-type.php:371
|
2095 |
+
msgid "Supports"
|
2096 |
+
msgstr ""
|
2097 |
+
|
2098 |
+
#: includes/generator/class-wpcode-generator-post-type.php:372
|
2099 |
+
msgid "Select which features this post type should support"
|
2100 |
+
msgstr ""
|
2101 |
+
|
2102 |
+
#: includes/generator/class-wpcode-generator-post-type.php:376
|
2103 |
+
#: includes/generator/class-wpcode-generator-query.php:300
|
2104 |
+
msgid "Title"
|
2105 |
+
msgstr ""
|
2106 |
+
|
2107 |
+
#: includes/generator/class-wpcode-generator-post-type.php:377
|
2108 |
+
msgid "Content Editor"
|
2109 |
+
msgstr ""
|
2110 |
+
|
2111 |
+
#: includes/generator/class-wpcode-generator-post-type.php:379
|
2112 |
+
msgid "Featured image"
|
2113 |
+
msgstr ""
|
2114 |
+
|
2115 |
+
#: includes/generator/class-wpcode-generator-post-type.php:380
|
2116 |
+
msgid "Excerpt"
|
2117 |
+
msgstr ""
|
2118 |
+
|
2119 |
+
#: includes/generator/class-wpcode-generator-post-type.php:381
|
2120 |
+
msgid "Trackbacks"
|
2121 |
+
msgstr ""
|
2122 |
+
|
2123 |
+
#: includes/generator/class-wpcode-generator-post-type.php:382
|
2124 |
+
#: includes/generator/class-wpcode-generator-query.php:487
|
2125 |
+
msgid "Custom Fields"
|
2126 |
+
msgstr ""
|
2127 |
+
|
2128 |
+
#: includes/generator/class-wpcode-generator-post-type.php:383
|
2129 |
+
msgid "Comments"
|
2130 |
+
msgstr ""
|
2131 |
+
|
2132 |
+
#: includes/generator/class-wpcode-generator-post-type.php:384
|
2133 |
+
msgid "Revisions"
|
2134 |
+
msgstr ""
|
2135 |
+
|
2136 |
+
#: includes/generator/class-wpcode-generator-post-type.php:385
|
2137 |
+
msgid "Page Attributes"
|
2138 |
+
msgstr ""
|
2139 |
+
|
2140 |
+
#: includes/generator/class-wpcode-generator-post-type.php:386
|
2141 |
+
msgid "Post Formats"
|
2142 |
+
msgstr ""
|
2143 |
+
|
2144 |
+
#: includes/generator/class-wpcode-generator-post-type.php:394
|
2145 |
+
msgid "Exclude From Search"
|
2146 |
+
msgstr ""
|
2147 |
+
|
2148 |
+
#: includes/generator/class-wpcode-generator-post-type.php:395
|
2149 |
+
msgid "Exclude the posts of this post type from search results?"
|
2150 |
+
msgstr ""
|
2151 |
+
|
2152 |
+
#: includes/generator/class-wpcode-generator-post-type.php:400
|
2153 |
+
#: includes/generator/class-wpcode-generator-post-type.php:758
|
2154 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:427
|
2155 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:506
|
2156 |
+
msgid "No - default"
|
2157 |
+
msgstr ""
|
2158 |
+
|
2159 |
+
#: includes/generator/class-wpcode-generator-post-type.php:405
|
2160 |
+
msgid "Enable Export"
|
2161 |
+
msgstr ""
|
2162 |
+
|
2163 |
+
#: includes/generator/class-wpcode-generator-post-type.php:406
|
2164 |
+
msgid "Allow exporting posts of this post type in Tools > Export."
|
2165 |
+
msgstr ""
|
2166 |
+
|
2167 |
+
#: includes/generator/class-wpcode-generator-post-type.php:410
|
2168 |
+
#: includes/generator/class-wpcode-generator-post-type.php:424
|
2169 |
+
#: includes/generator/class-wpcode-generator-post-type.php:453
|
2170 |
+
#: includes/generator/class-wpcode-generator-post-type.php:464
|
2171 |
+
#: includes/generator/class-wpcode-generator-post-type.php:478
|
2172 |
+
#: includes/generator/class-wpcode-generator-post-type.php:520
|
2173 |
+
#: includes/generator/class-wpcode-generator-post-type.php:531
|
2174 |
+
#: includes/generator/class-wpcode-generator-post-type.php:621
|
2175 |
+
#: includes/generator/class-wpcode-generator-post-type.php:635
|
2176 |
+
#: includes/generator/class-wpcode-generator-post-type.php:646
|
2177 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:321
|
2178 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:335
|
2179 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:346
|
2180 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:360
|
2181 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:371
|
2182 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:416
|
2183 |
+
msgid "Yes - default"
|
2184 |
+
msgstr ""
|
2185 |
+
|
2186 |
+
#: includes/generator/class-wpcode-generator-post-type.php:419
|
2187 |
+
msgid "Enable Archives"
|
2188 |
+
msgstr ""
|
2189 |
+
|
2190 |
+
#: includes/generator/class-wpcode-generator-post-type.php:420
|
2191 |
+
msgid "Enables archives for this post type, the post type key is used as default."
|
2192 |
+
msgstr ""
|
2193 |
+
|
2194 |
+
#: includes/generator/class-wpcode-generator-post-type.php:425
|
2195 |
+
msgid "Yes - using custom slug"
|
2196 |
+
msgstr ""
|
2197 |
+
|
2198 |
+
#: includes/generator/class-wpcode-generator-post-type.php:431
|
2199 |
+
msgid "Custom Archive Slug"
|
2200 |
+
msgstr ""
|
2201 |
+
|
2202 |
+
#: includes/generator/class-wpcode-generator-post-type.php:432
|
2203 |
+
msgid "Custom archive slug (if selected above)."
|
2204 |
+
msgstr ""
|
2205 |
+
|
2206 |
+
#. Translators: Placeholders add a link to the wp.org documentation page.
|
2207 |
+
#: includes/generator/class-wpcode-generator-post-type.php:449
|
2208 |
+
msgid "Should this post type be %1$svisible to authors%2$s?"
|
2209 |
+
msgstr ""
|
2210 |
+
|
2211 |
+
#: includes/generator/class-wpcode-generator-post-type.php:459
|
2212 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:330
|
2213 |
+
msgid "Show UI"
|
2214 |
+
msgstr ""
|
2215 |
+
|
2216 |
+
#: includes/generator/class-wpcode-generator-post-type.php:460
|
2217 |
+
msgid "Should this post type be visible in the Admin?"
|
2218 |
+
msgstr ""
|
2219 |
+
|
2220 |
+
#: includes/generator/class-wpcode-generator-post-type.php:473
|
2221 |
+
msgid "Show in Menu?"
|
2222 |
+
msgstr ""
|
2223 |
+
|
2224 |
+
#: includes/generator/class-wpcode-generator-post-type.php:474
|
2225 |
+
msgid "Should this post type be visible in the admin menu?"
|
2226 |
+
msgstr ""
|
2227 |
+
|
2228 |
+
#: includes/generator/class-wpcode-generator-post-type.php:484
|
2229 |
+
msgid "Menu position"
|
2230 |
+
msgstr ""
|
2231 |
+
|
2232 |
+
#: includes/generator/class-wpcode-generator-post-type.php:485
|
2233 |
+
msgid "Choose the admin menu position."
|
2234 |
+
msgstr ""
|
2235 |
+
|
2236 |
+
#: includes/generator/class-wpcode-generator-post-type.php:489
|
2237 |
+
msgid "Below Posts (5)"
|
2238 |
+
msgstr ""
|
2239 |
+
|
2240 |
+
#: includes/generator/class-wpcode-generator-post-type.php:490
|
2241 |
+
msgid "Below Media (10)"
|
2242 |
+
msgstr ""
|
2243 |
+
|
2244 |
+
#: includes/generator/class-wpcode-generator-post-type.php:491
|
2245 |
+
msgid "Below Pages (20)"
|
2246 |
+
msgstr ""
|
2247 |
+
|
2248 |
+
#: includes/generator/class-wpcode-generator-post-type.php:492
|
2249 |
+
msgid "Below Comments (30)"
|
2250 |
+
msgstr ""
|
2251 |
+
|
2252 |
+
#: includes/generator/class-wpcode-generator-post-type.php:493
|
2253 |
+
msgid "Below First Separator (60)"
|
2254 |
+
msgstr ""
|
2255 |
+
|
2256 |
+
#: includes/generator/class-wpcode-generator-post-type.php:494
|
2257 |
+
msgid "Below Plugins (65)"
|
2258 |
+
msgstr ""
|
2259 |
+
|
2260 |
+
#: includes/generator/class-wpcode-generator-post-type.php:495
|
2261 |
+
msgid "Below Users (70)"
|
2262 |
+
msgstr ""
|
2263 |
+
|
2264 |
+
#: includes/generator/class-wpcode-generator-post-type.php:496
|
2265 |
+
msgid "Below Tools (75)"
|
2266 |
+
msgstr ""
|
2267 |
+
|
2268 |
+
#: includes/generator/class-wpcode-generator-post-type.php:497
|
2269 |
+
msgid "Below Settings (80)"
|
2270 |
+
msgstr ""
|
2271 |
+
|
2272 |
+
#: includes/generator/class-wpcode-generator-post-type.php:498
|
2273 |
+
msgid "Below Second Separator (100)"
|
2274 |
+
msgstr ""
|
2275 |
+
|
2276 |
+
#: includes/generator/class-wpcode-generator-post-type.php:503
|
2277 |
+
msgid "Menu Icon"
|
2278 |
+
msgstr ""
|
2279 |
+
|
2280 |
+
#. Translators: Placeholder adds a link to the dashicons page.
|
2281 |
+
#: includes/generator/class-wpcode-generator-post-type.php:505
|
2282 |
+
msgid "Icon used next to the post type label in the admin menu. Use either a %1$sdashicon%2$s name or a full URL to an image file."
|
2283 |
+
msgstr ""
|
2284 |
+
|
2285 |
+
#: includes/generator/class-wpcode-generator-post-type.php:515
|
2286 |
+
msgid "Show in Admin Bar?"
|
2287 |
+
msgstr ""
|
2288 |
+
|
2289 |
+
#: includes/generator/class-wpcode-generator-post-type.php:516
|
2290 |
+
msgid "Should this post type be visible in the admin bar?"
|
2291 |
+
msgstr ""
|
2292 |
+
|
2293 |
+
#: includes/generator/class-wpcode-generator-post-type.php:526
|
2294 |
+
msgid "Show in Navigation Menus?"
|
2295 |
+
msgstr ""
|
2296 |
+
|
2297 |
+
#: includes/generator/class-wpcode-generator-post-type.php:527
|
2298 |
+
msgid "Should this post type be available for use in menus (Appearance > Menus)?"
|
2299 |
+
msgstr ""
|
2300 |
+
|
2301 |
+
#: includes/generator/class-wpcode-generator-post-type.php:545
|
2302 |
+
msgid "Publicly Queryable"
|
2303 |
+
msgstr ""
|
2304 |
+
|
2305 |
+
#. Translators: Placeholders add link to wp.org docs.
|
2306 |
+
#: includes/generator/class-wpcode-generator-post-type.php:547
|
2307 |
+
msgid "Enable frontend requests using the query variable. %1$sSee Documentation.%2$s"
|
2308 |
+
msgstr ""
|
2309 |
+
|
2310 |
+
#: includes/generator/class-wpcode-generator-post-type.php:560
|
2311 |
+
msgid "Query variable"
|
2312 |
+
msgstr ""
|
2313 |
+
|
2314 |
+
#. Translators: Placeholders add link to wp.org docs.
|
2315 |
+
#: includes/generator/class-wpcode-generator-post-type.php:562
|
2316 |
+
msgid "Key used for querying posts in the frontend. %1$sSee Documentation.%2$s"
|
2317 |
+
msgstr ""
|
2318 |
+
|
2319 |
+
#: includes/generator/class-wpcode-generator-post-type.php:566
|
2320 |
+
#: includes/generator/class-wpcode-generator-post-type.php:598
|
2321 |
+
msgid "Default (post type key)"
|
2322 |
+
msgstr ""
|
2323 |
+
|
2324 |
+
#: includes/generator/class-wpcode-generator-post-type.php:567
|
2325 |
+
msgid "Custom variable"
|
2326 |
+
msgstr ""
|
2327 |
+
|
2328 |
+
#: includes/generator/class-wpcode-generator-post-type.php:575
|
2329 |
+
msgid "Custom Query Variable"
|
2330 |
+
msgstr ""
|
2331 |
+
|
2332 |
+
#. Translators: Placeholder adds a link to the dashicons page.
|
2333 |
+
#: includes/generator/class-wpcode-generator-post-type.php:577
|
2334 |
+
msgid "The custom query variable to use for this post type. %1$sSee documentation%2$s."
|
2335 |
+
msgstr ""
|
2336 |
+
|
2337 |
+
#: includes/generator/class-wpcode-generator-post-type.php:586
|
2338 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:379
|
2339 |
+
msgid "Permalinks"
|
2340 |
+
msgstr ""
|
2341 |
+
|
2342 |
+
#: includes/generator/class-wpcode-generator-post-type.php:592
|
2343 |
+
msgid "Rewrite Permalinks"
|
2344 |
+
msgstr ""
|
2345 |
+
|
2346 |
+
#. Translators: Placeholders add link to wp.org docs.
|
2347 |
+
#: includes/generator/class-wpcode-generator-post-type.php:594
|
2348 |
+
msgid "Use the default permalink structure, disable permalinks for this post type or use custom options. %1$sSee Documentation.%2$s"
|
2349 |
+
msgstr ""
|
2350 |
+
|
2351 |
+
#: includes/generator/class-wpcode-generator-post-type.php:599
|
2352 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:391
|
2353 |
+
msgid "Disable permalink rewrites"
|
2354 |
+
msgstr ""
|
2355 |
+
|
2356 |
+
#: includes/generator/class-wpcode-generator-post-type.php:600
|
2357 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:392
|
2358 |
+
msgid "Custom permalink structure"
|
2359 |
+
msgstr ""
|
2360 |
+
|
2361 |
+
#: includes/generator/class-wpcode-generator-post-type.php:608
|
2362 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:400
|
2363 |
+
msgid "URL Slug"
|
2364 |
+
msgstr ""
|
2365 |
+
|
2366 |
+
#: includes/generator/class-wpcode-generator-post-type.php:609
|
2367 |
+
msgid "The slug used for this post types base. (for example: artist in www.example.com/artist/ )"
|
2368 |
+
msgstr ""
|
2369 |
+
|
2370 |
+
#: includes/generator/class-wpcode-generator-post-type.php:616
|
2371 |
+
msgid "Use URL Slug?"
|
2372 |
+
msgstr ""
|
2373 |
+
|
2374 |
+
#: includes/generator/class-wpcode-generator-post-type.php:617
|
2375 |
+
msgid "Use the post type name as URL slug base?"
|
2376 |
+
msgstr ""
|
2377 |
+
|
2378 |
+
#: includes/generator/class-wpcode-generator-post-type.php:630
|
2379 |
+
msgid "Use pagination?"
|
2380 |
+
msgstr ""
|
2381 |
+
|
2382 |
+
#: includes/generator/class-wpcode-generator-post-type.php:631
|
2383 |
+
msgid "Allow the post type to have pagination?"
|
2384 |
+
msgstr ""
|
2385 |
+
|
2386 |
+
#: includes/generator/class-wpcode-generator-post-type.php:641
|
2387 |
+
msgid "Use feeds?"
|
2388 |
+
msgstr ""
|
2389 |
+
|
2390 |
+
#: includes/generator/class-wpcode-generator-post-type.php:642
|
2391 |
+
msgid "Allow the post type to have feeds?"
|
2392 |
+
msgstr ""
|
2393 |
+
|
2394 |
+
#: includes/generator/class-wpcode-generator-post-type.php:654
|
2395 |
+
#: includes/generator/class-wpcode-generator-post-type.php:660
|
2396 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:435
|
2397 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:441
|
2398 |
+
msgid "Capabilities"
|
2399 |
+
msgstr ""
|
2400 |
+
|
2401 |
+
#. Translators: Placeholders add link to wp.org docs.
|
2402 |
+
#: includes/generator/class-wpcode-generator-post-type.php:662
|
2403 |
+
msgid "User capabilities in relation to this post type. %1$sSee Documentation.%2$s"
|
2404 |
+
msgstr ""
|
2405 |
+
|
2406 |
+
#: includes/generator/class-wpcode-generator-post-type.php:666
|
2407 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:447
|
2408 |
+
msgid "Base capabilities - default"
|
2409 |
+
msgstr ""
|
2410 |
+
|
2411 |
+
#: includes/generator/class-wpcode-generator-post-type.php:667
|
2412 |
+
#: includes/generator/class-wpcode-generator-post-type.php:686
|
2413 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:448
|
2414 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:453
|
2415 |
+
msgid "Custom Capabilities"
|
2416 |
+
msgstr ""
|
2417 |
+
|
2418 |
+
#: includes/generator/class-wpcode-generator-post-type.php:672
|
2419 |
+
msgid "Base Capablities Type"
|
2420 |
+
msgstr ""
|
2421 |
+
|
2422 |
+
#: includes/generator/class-wpcode-generator-post-type.php:673
|
2423 |
+
msgid "Use base capabilities from a core post type."
|
2424 |
+
msgstr ""
|
2425 |
+
|
2426 |
+
#: includes/generator/class-wpcode-generator-post-type.php:677
|
2427 |
+
msgid "Posts"
|
2428 |
+
msgstr ""
|
2429 |
+
|
2430 |
+
#: includes/generator/class-wpcode-generator-post-type.php:678
|
2431 |
+
msgid "Pages"
|
2432 |
+
msgstr ""
|
2433 |
+
|
2434 |
+
#: includes/generator/class-wpcode-generator-post-type.php:691
|
2435 |
+
msgid "Read Post"
|
2436 |
+
msgstr ""
|
2437 |
+
|
2438 |
+
#: includes/generator/class-wpcode-generator-post-type.php:698
|
2439 |
+
msgid "Read Private Posts"
|
2440 |
+
msgstr ""
|
2441 |
+
|
2442 |
+
#: includes/generator/class-wpcode-generator-post-type.php:705
|
2443 |
+
msgid "Publish Posts"
|
2444 |
+
msgstr ""
|
2445 |
+
|
2446 |
+
#: includes/generator/class-wpcode-generator-post-type.php:715
|
2447 |
+
msgid "Delete Posts"
|
2448 |
+
msgstr ""
|
2449 |
+
|
2450 |
+
#: includes/generator/class-wpcode-generator-post-type.php:722
|
2451 |
+
msgid "Edit Post"
|
2452 |
+
msgstr ""
|
2453 |
+
|
2454 |
+
#: includes/generator/class-wpcode-generator-post-type.php:729
|
2455 |
+
msgid "Edit Posts"
|
2456 |
+
msgstr ""
|
2457 |
+
|
2458 |
+
#: includes/generator/class-wpcode-generator-post-type.php:736
|
2459 |
+
msgid "Edit Others Posts"
|
2460 |
+
msgstr ""
|
2461 |
+
|
2462 |
+
#: includes/generator/class-wpcode-generator-post-type.php:745
|
2463 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:494
|
2464 |
+
msgid "Rest API"
|
2465 |
+
msgstr ""
|
2466 |
+
|
2467 |
+
#: includes/generator/class-wpcode-generator-post-type.php:751
|
2468 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:500
|
2469 |
+
msgid "Show in Rest API?"
|
2470 |
+
msgstr ""
|
2471 |
+
|
2472 |
+
#. Translators: Placeholders add link to wp.org docs.
|
2473 |
+
#: includes/generator/class-wpcode-generator-post-type.php:753
|
2474 |
+
msgid "Add the post type to the WordPress wp-json API. %1$sSee Documentation.%2$s"
|
2475 |
+
msgstr ""
|
2476 |
+
|
2477 |
+
#: includes/generator/class-wpcode-generator-post-type.php:766
|
2478 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:514
|
2479 |
+
msgid "Rest Base"
|
2480 |
+
msgstr ""
|
2481 |
+
|
2482 |
+
#. Translators: Placeholders add link to wp.org docs.
|
2483 |
+
#: includes/generator/class-wpcode-generator-post-type.php:768
|
2484 |
+
msgid "The base slug that this post type will use in the REST API. %1$sSee Documentation.%2$s"
|
2485 |
+
msgstr ""
|
2486 |
+
|
2487 |
+
#: includes/generator/class-wpcode-generator-post-type.php:777
|
2488 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:524
|
2489 |
+
msgid "Rest Controller Class"
|
2490 |
+
msgstr ""
|
2491 |
+
|
2492 |
+
#. Translators: Placeholders add link to wp.org docs.
|
2493 |
+
#: includes/generator/class-wpcode-generator-post-type.php:779
|
2494 |
+
msgid "The name of a custom Rest Controller class instead of WP_REST_Posts_Controller. %1$sSee Documentation.%2$s"
|
2495 |
+
msgstr ""
|
2496 |
+
|
2497 |
+
#: includes/generator/class-wpcode-generator-query.php:42
|
2498 |
+
msgid "WP_Query"
|
2499 |
+
msgstr ""
|
2500 |
+
|
2501 |
+
#: includes/generator/class-wpcode-generator-query.php:43
|
2502 |
+
msgid "Generate a snippet using WP_Query to load posts from your website."
|
2503 |
+
msgstr ""
|
2504 |
+
|
2505 |
+
#. Translators: Placeholders add links to the wordpress.org references.
|
2506 |
+
#: includes/generator/class-wpcode-generator-query.php:82
|
2507 |
+
msgid "This generator makes it easy for you to create custom queries using %1$sWP_Query%2$s which you can then extend to display posts or similar."
|
2508 |
+
msgstr ""
|
2509 |
+
|
2510 |
+
#: includes/generator/class-wpcode-generator-query.php:108
|
2511 |
+
msgid "You can use this generator to get quickly started with a query for all the posts of an author and display them using the shortcode functionality of WPCode or automatically displaying the posts using the auto-insert option."
|
2512 |
+
msgstr ""
|
2513 |
+
|
2514 |
+
#: includes/generator/class-wpcode-generator-query.php:120
|
2515 |
+
msgid "Query variable name"
|
2516 |
+
msgstr ""
|
2517 |
+
|
2518 |
+
#: includes/generator/class-wpcode-generator-query.php:121
|
2519 |
+
msgid "If you want to use something more specific. The leading $ will be automatically added."
|
2520 |
+
msgstr ""
|
2521 |
+
|
2522 |
+
#: includes/generator/class-wpcode-generator-query.php:131
|
2523 |
+
msgid "Include loop"
|
2524 |
+
msgstr ""
|
2525 |
+
|
2526 |
+
#: includes/generator/class-wpcode-generator-query.php:132
|
2527 |
+
msgid "Select yes if you want to include an empty loop of the results that you can fill in for output."
|
2528 |
+
msgstr ""
|
2529 |
+
|
2530 |
+
#: includes/generator/class-wpcode-generator-query.php:144
|
2531 |
+
msgid "IDs & Parents"
|
2532 |
+
msgstr ""
|
2533 |
+
|
2534 |
+
#: includes/generator/class-wpcode-generator-query.php:150
|
2535 |
+
msgid "Post ID(s)"
|
2536 |
+
msgstr ""
|
2537 |
+
|
2538 |
+
#: includes/generator/class-wpcode-generator-query.php:151
|
2539 |
+
msgid "Query a specific post ID or comma-separated list of ids. Cannot be combined with \"Post ID not in\" below."
|
2540 |
+
msgstr ""
|
2541 |
+
|
2542 |
+
#: includes/generator/class-wpcode-generator-query.php:158
|
2543 |
+
msgid "Post ID not in"
|
2544 |
+
msgstr ""
|
2545 |
+
|
2546 |
+
#: includes/generator/class-wpcode-generator-query.php:159
|
2547 |
+
msgid "Post ids to exclude from this query. Cannot be combined with \"Post ID(s)\" above."
|
2548 |
+
msgstr ""
|
2549 |
+
|
2550 |
+
#: includes/generator/class-wpcode-generator-query.php:169
|
2551 |
+
msgid "Post parent ID(s)"
|
2552 |
+
msgstr ""
|
2553 |
+
|
2554 |
+
#: includes/generator/class-wpcode-generator-query.php:170
|
2555 |
+
msgid "Comma-separated list of post parent ids if the post type is hierarchical (like pages)."
|
2556 |
+
msgstr ""
|
2557 |
+
|
2558 |
+
#: includes/generator/class-wpcode-generator-query.php:177
|
2559 |
+
msgid "Post parent not in"
|
2560 |
+
msgstr ""
|
2561 |
+
|
2562 |
+
#: includes/generator/class-wpcode-generator-query.php:178
|
2563 |
+
msgid "Comma-separated list of post parent ids to exclude."
|
2564 |
+
msgstr ""
|
2565 |
+
|
2566 |
+
#: includes/generator/class-wpcode-generator-query.php:188
|
2567 |
+
msgid "Post slugs"
|
2568 |
+
msgstr ""
|
2569 |
+
|
2570 |
+
#: includes/generator/class-wpcode-generator-query.php:189
|
2571 |
+
msgid "Comma-separated list of post slugs to query by."
|
2572 |
+
msgstr ""
|
2573 |
+
|
2574 |
+
#: includes/generator/class-wpcode-generator-query.php:198
|
2575 |
+
msgid "Type & Status"
|
2576 |
+
msgstr ""
|
2577 |
+
|
2578 |
+
#: includes/generator/class-wpcode-generator-query.php:205
|
2579 |
+
msgid "Post type to query by, start typing to get suggestions."
|
2580 |
+
msgstr ""
|
2581 |
+
|
2582 |
+
#: includes/generator/class-wpcode-generator-query.php:215
|
2583 |
+
msgid "Post status"
|
2584 |
+
msgstr ""
|
2585 |
+
|
2586 |
+
#: includes/generator/class-wpcode-generator-query.php:216
|
2587 |
+
msgid "Post status to query by."
|
2588 |
+
msgstr ""
|
2589 |
+
|
2590 |
+
#: includes/generator/class-wpcode-generator-query.php:231
|
2591 |
+
msgid "Author ID(s)"
|
2592 |
+
msgstr ""
|
2593 |
+
|
2594 |
+
#: includes/generator/class-wpcode-generator-query.php:232
|
2595 |
+
msgid "Author ID or comma-separated list of ids."
|
2596 |
+
msgstr ""
|
2597 |
+
|
2598 |
+
#: includes/generator/class-wpcode-generator-query.php:238
|
2599 |
+
msgid "Author not in"
|
2600 |
+
msgstr ""
|
2601 |
+
|
2602 |
+
#: includes/generator/class-wpcode-generator-query.php:239
|
2603 |
+
msgid "Comma-separated list of author ids to exclude from the query."
|
2604 |
+
msgstr ""
|
2605 |
+
|
2606 |
+
#: includes/generator/class-wpcode-generator-query.php:250
|
2607 |
+
msgid "Author name"
|
2608 |
+
msgstr ""
|
2609 |
+
|
2610 |
+
#: includes/generator/class-wpcode-generator-query.php:251
|
2611 |
+
msgid "Use the \"user_nicename\" parameter to query by author."
|
2612 |
+
msgstr ""
|
2613 |
+
|
2614 |
+
#: includes/generator/class-wpcode-generator-query.php:259
|
2615 |
+
msgid "Search"
|
2616 |
+
msgstr ""
|
2617 |
+
|
2618 |
+
#: includes/generator/class-wpcode-generator-query.php:265
|
2619 |
+
msgid "Search term"
|
2620 |
+
msgstr ""
|
2621 |
+
|
2622 |
+
#: includes/generator/class-wpcode-generator-query.php:266
|
2623 |
+
msgid "Search for posts by this search term."
|
2624 |
+
msgstr ""
|
2625 |
+
|
2626 |
+
#: includes/generator/class-wpcode-generator-query.php:274
|
2627 |
+
msgid "Order"
|
2628 |
+
msgstr ""
|
2629 |
+
|
2630 |
+
#: includes/generator/class-wpcode-generator-query.php:280
|
2631 |
+
msgid "Results Order"
|
2632 |
+
msgstr ""
|
2633 |
+
|
2634 |
+
#: includes/generator/class-wpcode-generator-query.php:284
|
2635 |
+
msgid "Descending order (3, 2, 1; c, b, a)"
|
2636 |
+
msgstr ""
|
2637 |
+
|
2638 |
+
#: includes/generator/class-wpcode-generator-query.php:285
|
2639 |
+
msgid "Ascending order (1, 2, 3; a, b, c)"
|
2640 |
+
msgstr ""
|
2641 |
+
|
2642 |
+
#: includes/generator/class-wpcode-generator-query.php:293
|
2643 |
+
msgid "Order by"
|
2644 |
+
msgstr ""
|
2645 |
+
|
2646 |
+
#: includes/generator/class-wpcode-generator-query.php:297
|
2647 |
+
msgid "No order (none)"
|
2648 |
+
msgstr ""
|
2649 |
+
|
2650 |
+
#: includes/generator/class-wpcode-generator-query.php:298
|
2651 |
+
msgid "ID"
|
2652 |
+
msgstr ""
|
2653 |
+
|
2654 |
+
#: includes/generator/class-wpcode-generator-query.php:301
|
2655 |
+
msgid "Slug (name)"
|
2656 |
+
msgstr ""
|
2657 |
+
|
2658 |
+
#: includes/generator/class-wpcode-generator-query.php:302
|
2659 |
+
msgid "Post type (type)"
|
2660 |
+
msgstr ""
|
2661 |
+
|
2662 |
+
#: includes/generator/class-wpcode-generator-query.php:303
|
2663 |
+
msgid "Date (default)"
|
2664 |
+
msgstr ""
|
2665 |
+
|
2666 |
+
#: includes/generator/class-wpcode-generator-query.php:304
|
2667 |
+
msgid "Modified date"
|
2668 |
+
msgstr ""
|
2669 |
+
|
2670 |
+
#: includes/generator/class-wpcode-generator-query.php:305
|
2671 |
+
msgid "Parent id"
|
2672 |
+
msgstr ""
|
2673 |
+
|
2674 |
+
#: includes/generator/class-wpcode-generator-query.php:306
|
2675 |
+
msgid "Random"
|
2676 |
+
msgstr ""
|
2677 |
+
|
2678 |
+
#: includes/generator/class-wpcode-generator-query.php:307
|
2679 |
+
msgid "Comment count"
|
2680 |
+
msgstr ""
|
2681 |
+
|
2682 |
+
#: includes/generator/class-wpcode-generator-query.php:308
|
2683 |
+
msgid "Relevance (for search)"
|
2684 |
+
msgstr ""
|
2685 |
+
|
2686 |
+
#: includes/generator/class-wpcode-generator-query.php:309
|
2687 |
+
msgid "Page Order (menu_order)"
|
2688 |
+
msgstr ""
|
2689 |
+
|
2690 |
+
#: includes/generator/class-wpcode-generator-query.php:311
|
2691 |
+
msgid "Meta value"
|
2692 |
+
msgstr ""
|
2693 |
+
|
2694 |
+
#: includes/generator/class-wpcode-generator-query.php:312
|
2695 |
+
msgid "Numerical meta value (meta_value_num)"
|
2696 |
+
msgstr ""
|
2697 |
+
|
2698 |
+
#: includes/generator/class-wpcode-generator-query.php:313
|
2699 |
+
msgid "Order of ids in post__in"
|
2700 |
+
msgstr ""
|
2701 |
+
|
2702 |
+
#: includes/generator/class-wpcode-generator-query.php:314
|
2703 |
+
msgid "Order of names in post_name__in"
|
2704 |
+
msgstr ""
|
2705 |
+
|
2706 |
+
#: includes/generator/class-wpcode-generator-query.php:315
|
2707 |
+
msgid "Order of ids in post_parent__in"
|
2708 |
+
msgstr ""
|
2709 |
+
|
2710 |
+
#: includes/generator/class-wpcode-generator-query.php:320
|
2711 |
+
#: includes/generator/class-wpcode-generator-query.php:493
|
2712 |
+
msgid "Meta Key"
|
2713 |
+
msgstr ""
|
2714 |
+
|
2715 |
+
#: includes/generator/class-wpcode-generator-query.php:321
|
2716 |
+
msgid "Meta key to use if you choose to order by meta value."
|
2717 |
+
msgstr ""
|
2718 |
+
|
2719 |
+
#: includes/generator/class-wpcode-generator-query.php:331
|
2720 |
+
msgid "Pagination"
|
2721 |
+
msgstr ""
|
2722 |
+
|
2723 |
+
#: includes/generator/class-wpcode-generator-query.php:337
|
2724 |
+
msgid "Use Pagination"
|
2725 |
+
msgstr ""
|
2726 |
+
|
2727 |
+
#: includes/generator/class-wpcode-generator-query.php:340
|
2728 |
+
msgid "Choose no to display all posts (not recommended)."
|
2729 |
+
msgstr ""
|
2730 |
+
|
2731 |
+
#: includes/generator/class-wpcode-generator-query.php:343
|
2732 |
+
msgid "Yes (default)"
|
2733 |
+
msgstr ""
|
2734 |
+
|
2735 |
+
#: includes/generator/class-wpcode-generator-query.php:348
|
2736 |
+
msgid "Page number"
|
2737 |
+
msgstr ""
|
2738 |
+
|
2739 |
+
#: includes/generator/class-wpcode-generator-query.php:349
|
2740 |
+
msgid "Which page to show."
|
2741 |
+
msgstr ""
|
2742 |
+
|
2743 |
+
#: includes/generator/class-wpcode-generator-query.php:358
|
2744 |
+
msgid "Posts per page"
|
2745 |
+
msgstr ""
|
2746 |
+
|
2747 |
+
#: includes/generator/class-wpcode-generator-query.php:359
|
2748 |
+
msgid "How many posts should be displayed per page."
|
2749 |
+
msgstr ""
|
2750 |
+
|
2751 |
+
#: includes/generator/class-wpcode-generator-query.php:365
|
2752 |
+
msgid "Offset"
|
2753 |
+
msgstr ""
|
2754 |
+
|
2755 |
+
#: includes/generator/class-wpcode-generator-query.php:366
|
2756 |
+
msgid "Number of posts to skip."
|
2757 |
+
msgstr ""
|
2758 |
+
|
2759 |
+
#: includes/generator/class-wpcode-generator-query.php:375
|
2760 |
+
msgid "Ignore sticky posts"
|
2761 |
+
msgstr ""
|
2762 |
+
|
2763 |
+
#: includes/generator/class-wpcode-generator-query.php:380
|
2764 |
+
msgid "No (default)"
|
2765 |
+
msgstr ""
|
2766 |
+
|
2767 |
+
#: includes/generator/class-wpcode-generator-query.php:387
|
2768 |
+
#: includes/generator/class-wpcode-generator-query.php:393
|
2769 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:35
|
2770 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:112
|
2771 |
+
msgid "Taxonomy"
|
2772 |
+
msgstr ""
|
2773 |
+
|
2774 |
+
#: includes/generator/class-wpcode-generator-query.php:394
|
2775 |
+
msgid "Taxonomy slug that you want to query by."
|
2776 |
+
msgstr ""
|
2777 |
+
|
2778 |
+
#: includes/generator/class-wpcode-generator-query.php:402
|
2779 |
+
msgid "Field"
|
2780 |
+
msgstr ""
|
2781 |
+
|
2782 |
+
#: includes/generator/class-wpcode-generator-query.php:403
|
2783 |
+
msgid "Select taxonomy term by."
|
2784 |
+
msgstr ""
|
2785 |
+
|
2786 |
+
#: includes/generator/class-wpcode-generator-query.php:409
|
2787 |
+
msgid "Term ID (default"
|
2788 |
+
msgstr ""
|
2789 |
+
|
2790 |
+
#: includes/generator/class-wpcode-generator-query.php:410
|
2791 |
+
msgid "Term Name"
|
2792 |
+
msgstr ""
|
2793 |
+
|
2794 |
+
#: includes/generator/class-wpcode-generator-query.php:411
|
2795 |
+
msgid "Term Slug"
|
2796 |
+
msgstr ""
|
2797 |
+
|
2798 |
+
#: includes/generator/class-wpcode-generator-query.php:412
|
2799 |
+
msgid "Term Taxonomy ID"
|
2800 |
+
msgstr ""
|
2801 |
+
|
2802 |
+
#: includes/generator/class-wpcode-generator-query.php:417
|
2803 |
+
msgid "Terms"
|
2804 |
+
msgstr ""
|
2805 |
+
|
2806 |
+
#: includes/generator/class-wpcode-generator-query.php:418
|
2807 |
+
msgid "Comma-separated list of terms to query by."
|
2808 |
+
msgstr ""
|
2809 |
+
|
2810 |
+
#: includes/generator/class-wpcode-generator-query.php:430
|
2811 |
+
msgid "Include Children"
|
2812 |
+
msgstr ""
|
2813 |
+
|
2814 |
+
#: includes/generator/class-wpcode-generator-query.php:434
|
2815 |
+
msgid "Whether or not to include children for hierarchical taxonomies."
|
2816 |
+
msgstr ""
|
2817 |
+
|
2818 |
+
#: includes/generator/class-wpcode-generator-query.php:443
|
2819 |
+
msgid "Operator"
|
2820 |
+
msgstr ""
|
2821 |
+
|
2822 |
+
#: includes/generator/class-wpcode-generator-query.php:447
|
2823 |
+
msgid "Operator to test relation by."
|
2824 |
+
msgstr ""
|
2825 |
+
|
2826 |
+
#: includes/generator/class-wpcode-generator-query.php:465
|
2827 |
+
msgid "Add another taxonomy"
|
2828 |
+
msgstr ""
|
2829 |
+
|
2830 |
+
#: includes/generator/class-wpcode-generator-query.php:466
|
2831 |
+
msgid "Use the \"Add Taxonomy\" button below to query multiple taxonomies."
|
2832 |
+
msgstr ""
|
2833 |
+
|
2834 |
+
#: includes/generator/class-wpcode-generator-query.php:470
|
2835 |
+
msgid "Add Taxonomy"
|
2836 |
+
msgstr ""
|
2837 |
+
|
2838 |
+
#: includes/generator/class-wpcode-generator-query.php:475
|
2839 |
+
msgid "Tax Relation"
|
2840 |
+
msgstr ""
|
2841 |
+
|
2842 |
+
#: includes/generator/class-wpcode-generator-query.php:479
|
2843 |
+
#: includes/generator/class-wpcode-generator-query.php:579
|
2844 |
+
msgid "AND (default)"
|
2845 |
+
msgstr ""
|
2846 |
+
|
2847 |
+
#: includes/generator/class-wpcode-generator-query.php:480
|
2848 |
+
#: includes/generator/class-wpcode-generator-query.php:580
|
2849 |
+
msgid "OR"
|
2850 |
+
msgstr ""
|
2851 |
+
|
2852 |
+
#: includes/generator/class-wpcode-generator-query.php:494
|
2853 |
+
msgid "The key of the custom field."
|
2854 |
+
msgstr ""
|
2855 |
+
|
2856 |
+
#: includes/generator/class-wpcode-generator-query.php:502
|
2857 |
+
msgid "Meta Value"
|
2858 |
+
msgstr ""
|
2859 |
+
|
2860 |
+
#: includes/generator/class-wpcode-generator-query.php:503
|
2861 |
+
msgid "Value to query the meta by."
|
2862 |
+
msgstr ""
|
2863 |
+
|
2864 |
+
#: includes/generator/class-wpcode-generator-query.php:514
|
2865 |
+
msgid "Compare"
|
2866 |
+
msgstr ""
|
2867 |
+
|
2868 |
+
#: includes/generator/class-wpcode-generator-query.php:515
|
2869 |
+
msgid "How to compare the value for querying by meta."
|
2870 |
+
msgstr ""
|
2871 |
+
|
2872 |
+
#: includes/generator/class-wpcode-generator-query.php:542
|
2873 |
+
msgid "Type"
|
2874 |
+
msgstr ""
|
2875 |
+
|
2876 |
+
#: includes/generator/class-wpcode-generator-query.php:543
|
2877 |
+
msgid "Type of custom field."
|
2878 |
+
msgstr ""
|
2879 |
+
|
2880 |
+
#: includes/generator/class-wpcode-generator-query.php:565
|
2881 |
+
msgid "Add another meta query"
|
2882 |
+
msgstr ""
|
2883 |
+
|
2884 |
+
#: includes/generator/class-wpcode-generator-query.php:566
|
2885 |
+
msgid "Use the \"Add Meta\" button below to use multiple meta queries."
|
2886 |
+
msgstr ""
|
2887 |
+
|
2888 |
+
#: includes/generator/class-wpcode-generator-query.php:570
|
2889 |
+
msgid "Add Meta"
|
2890 |
+
msgstr ""
|
2891 |
+
|
2892 |
+
#: includes/generator/class-wpcode-generator-query.php:575
|
2893 |
+
msgid "Relation"
|
2894 |
+
msgstr ""
|
2895 |
+
|
2896 |
+
#: includes/generator/class-wpcode-generator-script.php:35
|
2897 |
+
msgid "Register Scripts"
|
2898 |
+
msgstr ""
|
2899 |
+
|
2900 |
+
#: includes/generator/class-wpcode-generator-script.php:36
|
2901 |
+
msgid "Generate a snippet to load JavaScript scripts using wp_register_script."
|
2902 |
+
msgstr ""
|
2903 |
+
|
2904 |
+
#: includes/generator/class-wpcode-generator-script.php:55
|
2905 |
+
msgid "Using this generator you can create a WordPress function to register and enqueue scripts."
|
2906 |
+
msgstr ""
|
2907 |
+
|
2908 |
+
#. Translators: the placeholders add a link to getboostrap.com.
|
2909 |
+
#: includes/generator/class-wpcode-generator-script.php:80
|
2910 |
+
msgid "You can use this to load external scripts or even scripts from a theme or plugin. For example, you could load %1$sbootstrap%2$s from a cdn."
|
2911 |
+
msgstr ""
|
2912 |
+
|
2913 |
+
#: includes/generator/class-wpcode-generator-script.php:107
|
2914 |
+
#: includes/generator/class-wpcode-generator-style.php:107
|
2915 |
+
msgid "Action (hook)"
|
2916 |
+
msgstr ""
|
2917 |
+
|
2918 |
+
#. Translators: placeholders add links to documentation on wordpress.org.
|
2919 |
+
#: includes/generator/class-wpcode-generator-script.php:110
|
2920 |
+
msgid "Hook used to add the scripts: %1$sfrontend%2$s, %3$sadmin%4$s, %5$slogin%6$s or %7$sembed%8$s."
|
2921 |
+
msgstr ""
|
2922 |
+
|
2923 |
+
#. Translators: placeholder adds the hook name.
|
2924 |
+
#: includes/generator/class-wpcode-generator-script.php:124
|
2925 |
+
#: includes/generator/class-wpcode-generator-style.php:124
|
2926 |
+
msgid "Frontend (%s)"
|
2927 |
+
msgstr ""
|
2928 |
+
|
2929 |
+
#. Translators: placeholder adds the hook name.
|
2930 |
+
#: includes/generator/class-wpcode-generator-script.php:126
|
2931 |
+
#: includes/generator/class-wpcode-generator-style.php:126
|
2932 |
+
msgid "Admin (%s)"
|
2933 |
+
msgstr ""
|
2934 |
+
|
2935 |
+
#. Translators: placeholder adds the hook name.
|
2936 |
+
#: includes/generator/class-wpcode-generator-script.php:128
|
2937 |
+
#: includes/generator/class-wpcode-generator-style.php:128
|
2938 |
+
msgid "Login (%s)"
|
2939 |
+
msgstr ""
|
2940 |
+
|
2941 |
+
#. Translators: placeholder adds the hook name.
|
2942 |
+
#: includes/generator/class-wpcode-generator-script.php:130
|
2943 |
+
#: includes/generator/class-wpcode-generator-style.php:130
|
2944 |
+
msgid "Embed (%s)"
|
2945 |
+
msgstr ""
|
2946 |
+
|
2947 |
+
#: includes/generator/class-wpcode-generator-script.php:137
|
2948 |
+
msgid "Scripts"
|
2949 |
+
msgstr ""
|
2950 |
+
|
2951 |
+
#: includes/generator/class-wpcode-generator-script.php:143
|
2952 |
+
msgid "Script name"
|
2953 |
+
msgstr ""
|
2954 |
+
|
2955 |
+
#: includes/generator/class-wpcode-generator-script.php:144
|
2956 |
+
#: includes/generator/class-wpcode-generator-style.php:144
|
2957 |
+
msgid "This will be used as an identifier in the code, should be lowercase with no spaces."
|
2958 |
+
msgstr ""
|
2959 |
+
|
2960 |
+
#: includes/generator/class-wpcode-generator-script.php:153
|
2961 |
+
msgid "Script URL"
|
2962 |
+
msgstr ""
|
2963 |
+
|
2964 |
+
#: includes/generator/class-wpcode-generator-script.php:154
|
2965 |
+
msgid "The full URL for the script e.g. https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js."
|
2966 |
+
msgstr ""
|
2967 |
+
|
2968 |
+
#: includes/generator/class-wpcode-generator-script.php:163
|
2969 |
+
#: includes/generator/class-wpcode-generator-style.php:163
|
2970 |
+
msgid "Dependencies"
|
2971 |
+
msgstr ""
|
2972 |
+
|
2973 |
+
#: includes/generator/class-wpcode-generator-script.php:164
|
2974 |
+
msgid "Comma-separated list of scripts required for this script to load, e.g. jquery"
|
2975 |
+
msgstr ""
|
2976 |
+
|
2977 |
+
#: includes/generator/class-wpcode-generator-script.php:173
|
2978 |
+
msgid "Script Version"
|
2979 |
+
msgstr ""
|
2980 |
+
|
2981 |
+
#: includes/generator/class-wpcode-generator-script.php:174
|
2982 |
+
msgid "The script version."
|
2983 |
+
msgstr ""
|
2984 |
+
|
2985 |
+
#: includes/generator/class-wpcode-generator-script.php:186
|
2986 |
+
msgid "Header or Footer?"
|
2987 |
+
msgstr ""
|
2988 |
+
|
2989 |
+
#: includes/generator/class-wpcode-generator-script.php:187
|
2990 |
+
msgid "Load the script in the page head or in the footer."
|
2991 |
+
msgstr ""
|
2992 |
+
|
2993 |
+
#: includes/generator/class-wpcode-generator-script.php:199
|
2994 |
+
msgid "Deregister script?"
|
2995 |
+
msgstr ""
|
2996 |
+
|
2997 |
+
#. Translators: Placeholders for wp.org docs link.
|
2998 |
+
#: includes/generator/class-wpcode-generator-script.php:202
|
2999 |
+
msgid "Should the script be %1$sderegistered%2$s first? (for example, if you are replacing an existing script)."
|
3000 |
+
msgstr ""
|
3001 |
+
|
3002 |
+
#: includes/generator/class-wpcode-generator-script.php:217
|
3003 |
+
msgid "Enqueue script?"
|
3004 |
+
msgstr ""
|
3005 |
+
|
3006 |
+
#. Translators: Placeholders for wp.org docs link.
|
3007 |
+
#: includes/generator/class-wpcode-generator-script.php:220
|
3008 |
+
msgid "Should the script be %1$senqueued%2$s or just registered? (select \"No\" only if you intend enqueueing it later."
|
3009 |
+
msgstr ""
|
3010 |
+
|
3011 |
+
#: includes/generator/class-wpcode-generator-script.php:241
|
3012 |
+
msgid "Add more scripts"
|
3013 |
+
msgstr ""
|
3014 |
+
|
3015 |
+
#: includes/generator/class-wpcode-generator-script.php:242
|
3016 |
+
msgid "Use the \"Add script\" button below to add multiple scripts in this snippet."
|
3017 |
+
msgstr ""
|
3018 |
+
|
3019 |
+
#: includes/generator/class-wpcode-generator-script.php:246
|
3020 |
+
msgid "Add script"
|
3021 |
+
msgstr ""
|
3022 |
+
|
3023 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:35
|
3024 |
+
msgid "Sidebar"
|
3025 |
+
msgstr ""
|
3026 |
+
|
3027 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:36
|
3028 |
+
msgid "Generate a snippet to register a sidebar for your widgets."
|
3029 |
+
msgstr ""
|
3030 |
+
|
3031 |
+
#. Translators: Placeholders add links to the wordpress.org references.
|
3032 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:57
|
3033 |
+
msgid "This generator makes it easy to add sidebars to your website using the \"register_sidebar\" function."
|
3034 |
+
msgstr ""
|
3035 |
+
|
3036 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:83
|
3037 |
+
msgid "You can add multiple widget areas for your footer or post-type specific sidebars."
|
3038 |
+
msgstr ""
|
3039 |
+
|
3040 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:116
|
3041 |
+
msgid "Sidebars"
|
3042 |
+
msgstr ""
|
3043 |
+
|
3044 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:122
|
3045 |
+
msgid "Sidebar Id"
|
3046 |
+
msgstr ""
|
3047 |
+
|
3048 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:123
|
3049 |
+
msgid "This is the sidebar unique id, used in the code, lowercase with no spaces."
|
3050 |
+
msgstr ""
|
3051 |
+
|
3052 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:131
|
3053 |
+
msgid "Add a descriptive label for this sidebar to be used in the admin."
|
3054 |
+
msgstr ""
|
3055 |
+
|
3056 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:139
|
3057 |
+
msgid "A short description for the the admin area.."
|
3058 |
+
msgstr ""
|
3059 |
+
|
3060 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:146
|
3061 |
+
#: includes/generator/class-wpcode-generator-widget.php:158
|
3062 |
+
msgid "CSS Class"
|
3063 |
+
msgstr ""
|
3064 |
+
|
3065 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:147
|
3066 |
+
msgid "Use an unique CSS class name for better control over this sidebar's styles in the admin."
|
3067 |
+
msgstr ""
|
3068 |
+
|
3069 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:157
|
3070 |
+
msgid "Before Title"
|
3071 |
+
msgstr ""
|
3072 |
+
|
3073 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:158
|
3074 |
+
msgid "HTML code to add before each widget title."
|
3075 |
+
msgstr ""
|
3076 |
+
|
3077 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:166
|
3078 |
+
msgid "After Title"
|
3079 |
+
msgstr ""
|
3080 |
+
|
3081 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:167
|
3082 |
+
msgid "HTML code to add after each widget title."
|
3083 |
+
msgstr ""
|
3084 |
+
|
3085 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:175
|
3086 |
+
msgid "Before Widget"
|
3087 |
+
msgstr ""
|
3088 |
+
|
3089 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:176
|
3090 |
+
msgid "HTML code to add before each widget."
|
3091 |
+
msgstr ""
|
3092 |
+
|
3093 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:184
|
3094 |
+
msgid "After Widget"
|
3095 |
+
msgstr ""
|
3096 |
+
|
3097 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:185
|
3098 |
+
msgid "HTML code to add after each widget."
|
3099 |
+
msgstr ""
|
3100 |
+
|
3101 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:199
|
3102 |
+
msgid "Add another sidebar"
|
3103 |
+
msgstr ""
|
3104 |
+
|
3105 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:200
|
3106 |
+
msgid "Use the \"Add Sidebar\" button below to add as many sidebars as you need."
|
3107 |
+
msgstr ""
|
3108 |
+
|
3109 |
+
#: includes/generator/class-wpcode-generator-sidebar.php:204
|
3110 |
+
msgid "Add Sidebar"
|
3111 |
+
msgstr ""
|
3112 |
+
|
3113 |
+
#: includes/generator/class-wpcode-generator-style.php:35
|
3114 |
+
msgid "Register Stylesheets"
|
3115 |
+
msgstr ""
|
3116 |
+
|
3117 |
+
#: includes/generator/class-wpcode-generator-style.php:36
|
3118 |
+
msgid "Generate a snippet to load CSS stylesheets using wp_register_style."
|
3119 |
+
msgstr ""
|
3120 |
+
|
3121 |
+
#: includes/generator/class-wpcode-generator-style.php:55
|
3122 |
+
msgid "Using this generator you can create a WordPress function to register and enqueue styles."
|
3123 |
+
msgstr ""
|
3124 |
+
|
3125 |
+
#. Translators: the placeholders add a link to getboostrap.com.
|
3126 |
+
#: includes/generator/class-wpcode-generator-style.php:80
|
3127 |
+
msgid "You can use this to load external styles or even styles from a theme or plugin. For example, you could load %1$sfontawesome%2$s from a cdn."
|
3128 |
+
msgstr ""
|
3129 |
+
|
3130 |
+
#. Translators: placeholders add links to documentation on wordpress.org.
|
3131 |
+
#: includes/generator/class-wpcode-generator-style.php:110
|
3132 |
+
msgid "Hook used to add the styles: %1$sfrontend%2$s, %3$sadmin%4$s, %5$slogin%6$s or %7$sembed%8$s."
|
3133 |
+
msgstr ""
|
3134 |
+
|
3135 |
+
#: includes/generator/class-wpcode-generator-style.php:137
|
3136 |
+
msgid "Styles"
|
3137 |
+
msgstr ""
|
3138 |
+
|
3139 |
+
#: includes/generator/class-wpcode-generator-style.php:143
|
3140 |
+
msgid "Style name"
|
3141 |
+
msgstr ""
|
3142 |
+
|
3143 |
+
#: includes/generator/class-wpcode-generator-style.php:153
|
3144 |
+
msgid "Stylesheet URL"
|
3145 |
+
msgstr ""
|
3146 |
+
|
3147 |
+
#: includes/generator/class-wpcode-generator-style.php:154
|
3148 |
+
msgid "The full URL for the stylesheet e.g. https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css."
|
3149 |
+
msgstr ""
|
3150 |
+
|
3151 |
+
#: includes/generator/class-wpcode-generator-style.php:164
|
3152 |
+
msgid "Comma-separated list of styles required for this style to load, e.g. jquery"
|
3153 |
+
msgstr ""
|
3154 |
+
|
3155 |
+
#: includes/generator/class-wpcode-generator-style.php:173
|
3156 |
+
msgid "Style Version"
|
3157 |
+
msgstr ""
|
3158 |
+
|
3159 |
+
#: includes/generator/class-wpcode-generator-style.php:174
|
3160 |
+
msgid "The style version."
|
3161 |
+
msgstr ""
|
3162 |
+
|
3163 |
+
#: includes/generator/class-wpcode-generator-style.php:186
|
3164 |
+
msgid "Media"
|
3165 |
+
msgstr ""
|
3166 |
+
|
3167 |
+
#. Translators: placeholders add a link to the W3.org reference.
|
3168 |
+
#: includes/generator/class-wpcode-generator-style.php:189
|
3169 |
+
msgid "Load the style %1$smedia type%2$s, usually \"all\"."
|
3170 |
+
msgstr ""
|
3171 |
+
|
3172 |
+
#: includes/generator/class-wpcode-generator-style.php:200
|
3173 |
+
msgid "Deregister style?"
|
3174 |
+
msgstr ""
|
3175 |
+
|
3176 |
+
#. Translators: Placeholders for wp.org docs link.
|
3177 |
+
#: includes/generator/class-wpcode-generator-style.php:203
|
3178 |
+
msgid "Should the style be %1$sderegistered%2$s first? (for example, if you are replacing an existing style)."
|
3179 |
+
msgstr ""
|
3180 |
+
|
3181 |
+
#: includes/generator/class-wpcode-generator-style.php:218
|
3182 |
+
msgid "Enqueue style?"
|
3183 |
+
msgstr ""
|
3184 |
+
|
3185 |
+
#. Translators: Placeholders for wp.org docs link.
|
3186 |
+
#: includes/generator/class-wpcode-generator-style.php:221
|
3187 |
+
msgid "Should the style be %1$senqueued%2$s or just registered? (select \"No\" only if you intend enqueueing it later."
|
3188 |
+
msgstr ""
|
3189 |
+
|
3190 |
+
#: includes/generator/class-wpcode-generator-style.php:242
|
3191 |
+
msgid "Add more styles"
|
3192 |
+
msgstr ""
|
3193 |
+
|
3194 |
+
#: includes/generator/class-wpcode-generator-style.php:243
|
3195 |
+
msgid "Use the \"Add style\" button below to add multiple styles in this snippet."
|
3196 |
+
msgstr ""
|
3197 |
+
|
3198 |
+
#: includes/generator/class-wpcode-generator-style.php:247
|
3199 |
+
msgid "Add style"
|
3200 |
+
msgstr ""
|
3201 |
+
|
3202 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:36
|
3203 |
+
msgid "Create a custom taxonomy for your posts using this generator."
|
3204 |
+
msgstr ""
|
3205 |
+
|
3206 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:55
|
3207 |
+
msgid "Use this generator to create custom taxonomies for your WordPress site."
|
3208 |
+
msgstr ""
|
3209 |
+
|
3210 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:78
|
3211 |
+
msgid "Use this to add more taxonomies to posts or custom post types. For example, if you used the Post Type generator to create an Artist post type you can use this one to create a Genre taxonomy."
|
3212 |
+
msgstr ""
|
3213 |
+
|
3214 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:118
|
3215 |
+
msgid "Taxonomy Key"
|
3216 |
+
msgstr ""
|
3217 |
+
|
3218 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:119
|
3219 |
+
msgid "Name of taxonomy used in the code, lowercase maximum 20 characters."
|
3220 |
+
msgstr ""
|
3221 |
+
|
3222 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:129
|
3223 |
+
msgid "Name (Singular)"
|
3224 |
+
msgstr ""
|
3225 |
+
|
3226 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:130
|
3227 |
+
msgid "The singular taxonomy name (e.g. Genre, Year)."
|
3228 |
+
msgstr ""
|
3229 |
+
|
3230 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:138
|
3231 |
+
msgid "The taxonomy plural name (e.g. Genres, Years)."
|
3232 |
+
msgstr ""
|
3233 |
+
|
3234 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:148
|
3235 |
+
msgid "Link To Post Type(s)"
|
3236 |
+
msgstr ""
|
3237 |
+
|
3238 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:149
|
3239 |
+
msgid "Comma-separated list of Post Types (e.g. post, page)"
|
3240 |
+
msgstr ""
|
3241 |
+
|
3242 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:157
|
3243 |
+
msgid "Hierarchical taxonomies can have descendants."
|
3244 |
+
msgstr ""
|
3245 |
+
|
3246 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:161
|
3247 |
+
msgid "No, like tags"
|
3248 |
+
msgstr ""
|
3249 |
+
|
3250 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:162
|
3251 |
+
msgid "Yes, like categories"
|
3252 |
+
msgstr ""
|
3253 |
+
|
3254 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:196
|
3255 |
+
msgid "Parent Item colon"
|
3256 |
+
msgstr ""
|
3257 |
+
|
3258 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:203
|
3259 |
+
msgid "New Item Name"
|
3260 |
+
msgstr ""
|
3261 |
+
|
3262 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:241
|
3263 |
+
msgid "Separate Items with commas"
|
3264 |
+
msgstr ""
|
3265 |
+
|
3266 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:248
|
3267 |
+
msgid "Add or Remove Items"
|
3268 |
+
msgstr ""
|
3269 |
+
|
3270 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:255
|
3271 |
+
msgid "Choose From Most Used"
|
3272 |
+
msgstr ""
|
3273 |
+
|
3274 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:265
|
3275 |
+
msgid "Popular Items"
|
3276 |
+
msgstr ""
|
3277 |
+
|
3278 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:272
|
3279 |
+
msgid "Search Items"
|
3280 |
+
msgstr ""
|
3281 |
+
|
3282 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:286
|
3283 |
+
msgid "No items"
|
3284 |
+
msgstr ""
|
3285 |
+
|
3286 |
+
#. Translators: Placeholders add a link to the wp.org documentation page.
|
3287 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:317
|
3288 |
+
msgid "Should this taxonomy be %1$svisible to authors%2$s?"
|
3289 |
+
msgstr ""
|
3290 |
+
|
3291 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:331
|
3292 |
+
msgid "Should this taxonomy have an User Interface for managing?"
|
3293 |
+
msgstr ""
|
3294 |
+
|
3295 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:341
|
3296 |
+
msgid "Show Admin Column"
|
3297 |
+
msgstr ""
|
3298 |
+
|
3299 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:342
|
3300 |
+
msgid "Should this taxonomy add a column in the list of associated post types?"
|
3301 |
+
msgstr ""
|
3302 |
+
|
3303 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:355
|
3304 |
+
msgid "Show Tag Cloud"
|
3305 |
+
msgstr ""
|
3306 |
+
|
3307 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:356
|
3308 |
+
msgid "Should this taxonomy be visible in the tag cloud widget?"
|
3309 |
+
msgstr ""
|
3310 |
+
|
3311 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:366
|
3312 |
+
msgid "Show in Navigation Menus"
|
3313 |
+
msgstr ""
|
3314 |
+
|
3315 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:367
|
3316 |
+
msgid "Should this taxonomy be available in menus (Appearance > Menus)."
|
3317 |
+
msgstr ""
|
3318 |
+
|
3319 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:385
|
3320 |
+
msgid "Permalink Rewrite"
|
3321 |
+
msgstr ""
|
3322 |
+
|
3323 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:386
|
3324 |
+
msgid "Use Default Permalinks, disable automatic rewriting or use custom permalinks."
|
3325 |
+
msgstr ""
|
3326 |
+
|
3327 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:390
|
3328 |
+
msgid "Default (taxonomy key)"
|
3329 |
+
msgstr ""
|
3330 |
+
|
3331 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:401
|
3332 |
+
msgid "If you selected custom permalinks use this field for the rewrite base, e.g. taxonomy in https://yoursite.com/taxonomy"
|
3333 |
+
msgstr ""
|
3334 |
+
|
3335 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:411
|
3336 |
+
msgid "Prepend permastruct"
|
3337 |
+
msgstr ""
|
3338 |
+
|
3339 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:412
|
3340 |
+
msgid "Should the permastruct be prepended to the url (with_front parameter)."
|
3341 |
+
msgstr ""
|
3342 |
+
|
3343 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:422
|
3344 |
+
msgid "Hierarchical URL Slug"
|
3345 |
+
msgstr ""
|
3346 |
+
|
3347 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:423
|
3348 |
+
msgid "For hierarchical taxonomies use the whole hierarchy in the URL?"
|
3349 |
+
msgstr ""
|
3350 |
+
|
3351 |
+
#. Translators: Placeholders add link to wp.org docs.
|
3352 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:443
|
3353 |
+
msgid "User capabilities in relation to this taxonomy. %1$sSee Documentation.%2$s"
|
3354 |
+
msgstr ""
|
3355 |
+
|
3356 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:461
|
3357 |
+
msgid "Edit Terms"
|
3358 |
+
msgstr ""
|
3359 |
+
|
3360 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:468
|
3361 |
+
msgid "Delete Terms"
|
3362 |
+
msgstr ""
|
3363 |
+
|
3364 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:478
|
3365 |
+
msgid "Manage Terms"
|
3366 |
+
msgstr ""
|
3367 |
+
|
3368 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:485
|
3369 |
+
msgid "Assign Terms"
|
3370 |
+
msgstr ""
|
3371 |
+
|
3372 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:501
|
3373 |
+
msgid "Add the taxonomy to the WordPress wp-json API."
|
3374 |
+
msgstr ""
|
3375 |
+
|
3376 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:515
|
3377 |
+
msgid "The base slug that this taxonomy will use in the REST API."
|
3378 |
+
msgstr ""
|
3379 |
+
|
3380 |
+
#: includes/generator/class-wpcode-generator-taxonomy.php:525
|
3381 |
+
msgid "The name of a custom Rest Controller class instead of WP_REST_Terms_Controller."
|
3382 |
+
msgstr ""
|
3383 |
+
|
3384 |
+
#: includes/generator/class-wpcode-generator-widget.php:35
|
3385 |
+
#: includes/generator/class-wpcode-generator-widget.php:123
|
3386 |
+
msgid "Widget"
|
3387 |
+
msgstr ""
|
3388 |
+
|
3389 |
+
#: includes/generator/class-wpcode-generator-widget.php:36
|
3390 |
+
msgid "Generate a snippet to register a custom sidebar widget for your website."
|
3391 |
+
msgstr ""
|
3392 |
+
|
3393 |
+
#: includes/generator/class-wpcode-generator-widget.php:55
|
3394 |
+
msgid "Using this generator you can easily add a custom sidebar widget with settings."
|
3395 |
+
msgstr ""
|
3396 |
+
|
3397 |
+
#: includes/generator/class-wpcode-generator-widget.php:78
|
3398 |
+
msgid "Sidebar widgets are very useful when you want to display the same content on multiple pages, you can create a widget with contact methods, for example and fields to set a phone number, email, etc."
|
3399 |
+
msgstr ""
|
3400 |
+
|
3401 |
+
#: includes/generator/class-wpcode-generator-widget.php:90
|
3402 |
+
msgid "Class name"
|
3403 |
+
msgstr ""
|
3404 |
+
|
3405 |
+
#: includes/generator/class-wpcode-generator-widget.php:91
|
3406 |
+
msgid "Make this unique to avoid conflicts with other similar snippets."
|
3407 |
+
msgstr ""
|
3408 |
+
|
3409 |
+
#: includes/generator/class-wpcode-generator-widget.php:102
|
3410 |
+
msgid "Prefix"
|
3411 |
+
msgstr ""
|
3412 |
+
|
3413 |
+
#: includes/generator/class-wpcode-generator-widget.php:103
|
3414 |
+
msgid "Used to prefix all the field names."
|
3415 |
+
msgstr ""
|
3416 |
+
|
3417 |
+
#: includes/generator/class-wpcode-generator-widget.php:114
|
3418 |
+
msgid "Optional textdomain for translations."
|
3419 |
+
msgstr ""
|
3420 |
+
|
3421 |
+
#: includes/generator/class-wpcode-generator-widget.php:129
|
3422 |
+
msgid "Widget ID"
|
3423 |
+
msgstr ""
|
3424 |
+
|
3425 |
+
#: includes/generator/class-wpcode-generator-widget.php:130
|
3426 |
+
msgid "Unique id for the widget, used in the code."
|
3427 |
+
msgstr ""
|
3428 |
+
|
3429 |
+
#: includes/generator/class-wpcode-generator-widget.php:138
|
3430 |
+
msgid "Widget Title"
|
3431 |
+
msgstr ""
|
3432 |
+
|
3433 |
+
#: includes/generator/class-wpcode-generator-widget.php:139
|
3434 |
+
msgid "The title of the widget (displayed in the admin)."
|
3435 |
+
msgstr ""
|
3436 |
+
|
3437 |
+
#: includes/generator/class-wpcode-generator-widget.php:151
|
3438 |
+
msgid "Description used in the admin to explain what the widget is used for."
|
3439 |
+
msgstr ""
|
3440 |
+
|
3441 |
+
#: includes/generator/class-wpcode-generator-widget.php:159
|
3442 |
+
msgid "Widget-specific CSS class name."
|
3443 |
+
msgstr ""
|
3444 |
+
|
3445 |
+
#: includes/generator/class-wpcode-generator-widget.php:168
|
3446 |
+
msgid "Widget Output Code"
|
3447 |
+
msgstr ""
|
3448 |
+
|
3449 |
+
#: includes/generator/class-wpcode-generator-widget.php:169
|
3450 |
+
msgid "PHP Code used for outputting the fields in the frontend. If left empty it will output the fields values in a simple list."
|
3451 |
+
msgstr ""
|
3452 |
+
|
3453 |
+
#: includes/generator/class-wpcode-generator-widget.php:177
|
3454 |
+
msgid "Fields"
|
3455 |
+
msgstr ""
|
3456 |
+
|
3457 |
+
#: includes/generator/class-wpcode-generator-widget.php:183
|
3458 |
+
msgid "Field Type"
|
3459 |
+
msgstr ""
|
3460 |
+
|
3461 |
+
#: includes/generator/class-wpcode-generator-widget.php:184
|
3462 |
+
msgid "Pick the type of field you want to use for this setting."
|
3463 |
+
msgstr ""
|
3464 |
+
|
3465 |
+
#: includes/generator/class-wpcode-generator-widget.php:188
|
3466 |
+
msgid "Text"
|
3467 |
+
msgstr ""
|
3468 |
+
|
3469 |
+
#: includes/generator/class-wpcode-generator-widget.php:189
|
3470 |
+
msgid "Email"
|
3471 |
+
msgstr ""
|
3472 |
+
|
3473 |
+
#: includes/generator/class-wpcode-generator-widget.php:190
|
3474 |
+
msgid "URL"
|
3475 |
+
msgstr ""
|
3476 |
+
|
3477 |
+
#: includes/generator/class-wpcode-generator-widget.php:191
|
3478 |
+
msgid "Number"
|
3479 |
+
msgstr ""
|
3480 |
+
|
3481 |
+
#: includes/generator/class-wpcode-generator-widget.php:192
|
3482 |
+
msgid "Textarea"
|
3483 |
+
msgstr ""
|
3484 |
+
|
3485 |
+
#: includes/generator/class-wpcode-generator-widget.php:193
|
3486 |
+
msgid "Select"
|
3487 |
+
msgstr ""
|
3488 |
+
|
3489 |
+
#: includes/generator/class-wpcode-generator-widget.php:194
|
3490 |
+
msgid "Checkboxes"
|
3491 |
+
msgstr ""
|
3492 |
+
|
3493 |
+
#: includes/generator/class-wpcode-generator-widget.php:195
|
3494 |
+
msgid "Radio"
|
3495 |
+
msgstr ""
|
3496 |
+
|
3497 |
+
#: includes/generator/class-wpcode-generator-widget.php:201
|
3498 |
+
msgid "Field ID"
|
3499 |
+
msgstr ""
|
3500 |
+
|
3501 |
+
#: includes/generator/class-wpcode-generator-widget.php:202
|
3502 |
+
msgid "Unique id for this field, used in the code."
|
3503 |
+
msgstr ""
|
3504 |
+
|
3505 |
+
#: includes/generator/class-wpcode-generator-widget.php:209
|
3506 |
+
msgid "Field Label"
|
3507 |
+
msgstr ""
|
3508 |
+
|
3509 |
+
#: includes/generator/class-wpcode-generator-widget.php:210
|
3510 |
+
msgid "The label displayed next to this field in the admin form."
|
3511 |
+
msgstr ""
|
3512 |
+
|
3513 |
+
#: includes/generator/class-wpcode-generator-widget.php:224
|
3514 |
+
msgid "Display a short descriptive text below this field."
|
3515 |
+
msgstr ""
|
3516 |
+
|
3517 |
+
#: includes/generator/class-wpcode-generator-widget.php:231
|
3518 |
+
msgid "Default"
|
3519 |
+
msgstr ""
|
3520 |
+
|
3521 |
+
#: includes/generator/class-wpcode-generator-widget.php:232
|
3522 |
+
msgid "Set the default value for this field."
|
3523 |
+
msgstr ""
|
3524 |
+
|
3525 |
+
#: includes/generator/class-wpcode-generator-widget.php:240
|
3526 |
+
msgid "Use value|label for each line to add options for select, checkbox or radio."
|
3527 |
+
msgstr ""
|
3528 |
+
|
3529 |
+
#: includes/generator/class-wpcode-generator-widget.php:250
|
3530 |
+
msgid "Add another field"
|
3531 |
+
msgstr ""
|
3532 |
+
|
3533 |
+
#: includes/generator/class-wpcode-generator-widget.php:251
|
3534 |
+
msgid "Use the \"Add field\" button below to add as many fields as you need."
|
3535 |
+
msgstr ""
|
3536 |
+
|
3537 |
+
#: includes/generator/class-wpcode-generator-widget.php:255
|
3538 |
+
msgid "Add field"
|
3539 |
+
msgstr ""
|
3540 |
+
|
3541 |
+
#: includes/safe-mode.php:70
|
3542 |
+
msgid "WPCode is in Safe Mode which means no snippets are getting executed. Please disable any snippets that have caused errors and when done click the button below to exit safe mode."
|
3543 |
+
msgstr ""
|
3544 |
+
|
3545 |
+
#: includes/safe-mode.php:71
|
3546 |
+
msgid "The link will open in a new window so if you are still encountering issues you safely can return to this tab and make further adjustments"
|
3547 |
+
msgstr ""
|
3548 |
+
|
3549 |
+
#: includes/safe-mode.php:73
|
3550 |
+
msgid "Exit safe mode"
|
3551 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -1,103 +1,297 @@
|
|
1 |
-
=== Insert Headers and Footers by
|
2 |
-
Contributors: WPbeginner, smub,
|
3 |
-
Tags: code,
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 6.0
|
6 |
-
Requires PHP: 5.
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
|
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
|
|
20 |
|
21 |
-
=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
* Quick to set up
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
* Insert
|
|
|
|
|
|
|
29 |
* Insert any code or script, including HTML and Javascript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
= Credits =
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
|
|
|
|
36 |
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
* <a href="https://smashballoon.com/" rel="friend" title="Smash Balloon">Smash Balloon</a> - #1 social feeds plugin for WordPress - display social media content in WordPress without code.
|
46 |
-
* <a href="https://aioseo.com/" rel="friend" title="AIOSEO">AIOSEO</a> - The original WordPress SEO plugin to help you rank higher in search results (trusted by over 3 million sites).
|
47 |
-
* <a href="https://www.pushengage.com/" rel="friend" title="PushEngage">PushEngage</a> - Connect with visitors after they leave your website with the leading web push notification plugin.
|
48 |
-
* <a href="https://www.trustpulse.com/" rel="friend" title="TrustPulse">TrustPulse</a> - Add real-time social proof notifications to boost your store conversions by up to 15%.
|
49 |
-
* <a href="https://searchwp.com/" rel="friend" title="SearchWP">SearchWP</a> - The most advanced custom WordPress search plugin to improve WordPress search quality.
|
50 |
-
* <a href="https://affiliatewp.com/" rel="friend" title="AffiliateWP">AffiliateWP</a> - #1 affiliate management plugin for WordPress. Add a referral program to your online store.
|
51 |
-
* <a href="https://wpsimplepay.com/" rel="friend" title="WP Simple Pay">WP Simple Pay</a> - #1 Stripe payments plugin for WordPress. Start accepting one-time or recurring payments without a shopping cart.
|
52 |
-
* <a href="https://easydigitaldownloads.com/" rel="friend" title="Easy Digital Downloads">Easy Digital Downloads</a> - The best WordPress eCommerce plugin to sell digital products (eBooks, software, music, and more).
|
53 |
-
* <a href="https://sugarcalendar.com/" rel="friend" title="Sugar Calendar">Sugar Calendar</a> - A simple event calendar plugin for WordPress that’s both easy and powerful.
|
54 |
|
55 |
-
|
56 |
|
57 |
-
* <a href="
|
58 |
-
* <a href="
|
59 |
-
* <a href="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
...and many more <a href="http://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress tutorials</a>.
|
62 |
|
63 |
== Installation ==
|
64 |
|
65 |
-
1. Install Insert Headers and
|
66 |
-
2. Activate Insert Headers and
|
67 |
-
3. Insert code in your header
|
68 |
|
69 |
[youtube https://www.youtube.com/watch?v=QXbrdVjWaME]
|
70 |
|
71 |
== Screenshots ==
|
72 |
|
73 |
-
1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
== Frequently Asked Questions ==
|
76 |
|
77 |
-
= Can I use Insert Headers and Footers to install Google Analytics? =
|
78 |
|
79 |
Yes, you can insert your Google Analytics code in the `Scripts in Header` field.
|
80 |
|
81 |
-
= Can I use Insert Headers and Footers for Google AdSense? =
|
82 |
|
83 |
Yes, to verify your account or to tag your page for Auto ads, paste the code AdSense gives you, into the Scripts in Header field.
|
84 |
|
85 |
-
=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
== Notes ==
|
90 |
-
|
|
|
91 |
|
92 |
Our goal is to make using WordPress easy, both with our <a href="http://www.wpbeginner.com/wordpress-plugins/" rel="friend" title="WordPress Plugins">WordPress plugins</a> and resources like <a href="http://www.wpbeginner.com/" rel="friend">WPBeginner</a>, the largest WordPress resource site for beginners.
|
93 |
|
94 |
-
I feel that we have done that here. I hope find Insert Headers and Footers useful to insert scripts on your site.
|
95 |
|
96 |
Thank you
|
97 |
Syed Balkhi
|
98 |
|
99 |
== Changelog ==
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
= 1.6.2 =
|
102 |
* Fix: Reverted a method visibility that was conflicting with other plugins using it.
|
103 |
|
@@ -159,4 +353,4 @@ Syed Balkhi
|
|
159 |
* fixed unnecessary CSS loading
|
160 |
|
161 |
= 1.0 =
|
162 |
-
* Initial version
|
1 |
+
=== Insert Headers and Footers - Code Snippets by WPCode - Easy WordPress Code Manager ===
|
2 |
+
Contributors: WPbeginner, smub, gripgrip
|
3 |
+
Tags: code, css, php, footer, functions, content, facebook pixel, footer code, footer scripts, footers, google analytics, head, header, header code, header scripts, headers, insert, insert code, insert scripts, js, meta, meta tags, scripts, html, javascript, multisite, code snippets
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 6.0
|
6 |
+
Requires PHP: 5.5
|
7 |
+
Stable tag: 2.0.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Easily add code snippets in WordPress. Insert header and footer scripts, add PHP code snippets with conditional logic, insert ads pixel code, and more.
|
12 |
+
|
13 |
|
14 |
== Description ==
|
15 |
|
16 |
+
= Insert Headers & Footers + Full WordPress Code Snippets Plugin =
|
17 |
+
|
18 |
+
<a href="https://wpcode.com/?utm_source=wprepo&utm_medium=link&utm_campaign=liteplugin" rel="friend" title="WPCode">WPCode</a> (formerly known as Insert Headers and Footers by WPBeginner) is the most popular code snippets plugin for WordPress used by over 1 million websites.
|
19 |
+
|
20 |
+
We make it easy for you to add code snippets in WordPress without having to edit your theme's functions.php file.
|
21 |
+
|
22 |
+
Our simple insert headers and footers interface allows you to insert code like Google Analytics, custom CSS, Facebook Pixel, and more to your WordPress site's header and footer as well other areas of your website. No need to edit your theme files!
|
23 |
+
|
24 |
+
Aside from Header and Footer scripts, you can also use WPCode to insert custom PHP code snippets, JavaScript code snippets, CSS code snipets, HTML code snippets, and text snippets with full conditional logic and code priority support.
|
25 |
+
|
26 |
+
We took the pain out of adding custom code snippets in WordPress and made it easy.
|
27 |
+
|
28 |
+
> I have been using Insert Headers and Footers and it is such a useful tool. Super helpful and the very best of its kind. Highly recommend
|
29 |
+
> The_Gibble - WordPress user
|
30 |
+
|
31 |
+
= Future Proof Code Snippet Management =
|
32 |
+
|
33 |
+
Most <a href="https://www.wpbeginner.com/category/wp-tutorials/">WordPress tutorial websites</a> ask you to add code snippets to your theme's functions.php file. This makes managing code snippets messy, and it also prevents you from updating your theme.
|
34 |
+
|
35 |
+
If you ever update your theme or switch to another theme, then you will lose all custom code functions that you added in your functions.php file.
|
36 |
+
|
37 |
+
WPCode solves this by providing you an easy way to insert header and footer scripts along with other code snippets directly from your WordPress dashboard. These code snippets actually run as if they were in your theme's functions.php file.
|
38 |
+
|
39 |
+
Our smart code snippet validation helps you prevent common code errors to ensure you never break your website when adding code snippets or header and footer scripts.
|
40 |
+
|
41 |
+
You can manage all your header and footer scripts as well as other custom code snippets from a single screen. We even make it easy for you to organize code snippets using Tags and add reminder notes with each code snippet.
|
42 |
+
|
43 |
+
> This plugin allows me to not only add things to my site whenever needed, but it takes me only seconds to accomplish it.
|
44 |
+
> David Weber - WordPress user
|
45 |
+
|
46 |
+
= Full Code Snippets Library and Code Generators =
|
47 |
+
|
48 |
+
Ever wanted a central place to find all the most popular WordPress code snippets that are tested and proven to work?
|
49 |
+
|
50 |
+
When we started Insert Headers and Footers plugin, we did too. So we built a WordPress code snippets library right inside the WPCode plugin.
|
51 |
+
|
52 |
+
This makes it easy for you to customize WordPress functions with just a click using expert written code snippets.
|
53 |
+
|
54 |
+
You will find verified PHP code snippets for popular feature requests like disable REST API, disable XML-RPC, disable comments, allow SVG file uploads, disable Gutenberg, add Classic Editor, and more without installing separate plugins for each.
|
55 |
+
|
56 |
+
> I was very hesitant to get into any of the code for my website. Your plugin made it easy for me to do.
|
57 |
+
> Conbrio75 - WordPress user
|
58 |
+
|
59 |
+
Aside from our growing code snippets library, we also have WordPress code generators to help you quickly get ready-to-use custom code using the latest WordPress coding standards and API's.
|
60 |
+
|
61 |
+
Examples of Custom Code Generators with Admin UI include:
|
62 |
+
|
63 |
+
* Custom Post Type Generator - Create custom code snippet for Post Types.
|
64 |
+
* Custom Taxonomy Generator - Get custom code snippet for Taxonomies.
|
65 |
+
* WP Query Generator - Get custom code snippet for WP_Query to load posts.
|
66 |
+
* Custom Sidebar Generator - Create custom code snippet to register custom sidebars or widget-ready areas.
|
67 |
+
* Custom Widget Generator - Custom code snippet to register custom widgets.
|
68 |
+
* Navigation Menu Generator - Custom code snippet for registering new navigation menu locations in your theme.
|
69 |
+
|
70 |
+
Aside from the above, we also have code snippet generator for scheduling a cron job, registering scripts & stylesheets, adding custom post status, and more.
|
71 |
+
|
72 |
+
= Conditional Logic for Code Snippets + Code Insertion Priority =
|
73 |
+
|
74 |
+
Our goal with WPCode was to create a WordPress code snippets plugin that's both EASY and POWERFUL.
|
75 |
+
|
76 |
+
That's why aside from our global header and footer scripts, we added advanced features like conditional logic for code snippets and made it easy.
|
77 |
+
|
78 |
+
Instead of learning WordPress conditional logic queries, you can use our beginner-friendly conditional logic user interface to:
|
79 |
+
|
80 |
+
* Load code snippets for logged in users only
|
81 |
+
* Load PHP code snippets for specific user roles
|
82 |
+
* Load PHP code snippets only on specific page URLs
|
83 |
+
* Insert header and footer pixel scripts on specific pages
|
84 |
+
* Show code snippets based on type of page
|
85 |
+
* Run code snippet only on certain post types
|
86 |
+
* Load header and footer code snippet based on referrer source
|
87 |
+
* and more...
|
88 |
+
|
89 |
+
We also added both automatic code insertion and manual code output using shortcodes.
|
90 |
+
|
91 |
+
Our Auto Insert feature allows you to run the code snippet everywhere or choose from custom options like:
|
92 |
+
|
93 |
+
* Run code snippet only on frontend
|
94 |
+
* Run code snippet only in WordPress admin area
|
95 |
+
* Add header and footer scripts sitewide
|
96 |
+
* Insert PHP code snippet before or after post content
|
97 |
+
* Insert code snippet before or after specific paragraph
|
98 |
+
* Insert code snippet on specific archive pages
|
99 |
|
100 |
+
Aside from that, we also added a visual code snippet priority system, so you can choose the order for your custom functions to avoid code conflict.
|
101 |
|
102 |
+
> This is such a useful plugin! It makes it so much easier to include things on your website!
|
103 |
+
> Understoryliving - WordPress user
|
104 |
|
105 |
+
= Import and Export Code Snippets =
|
106 |
+
|
107 |
+
Managing multiple websites or developing in a staging environment?
|
108 |
+
|
109 |
+
We offer an easy way to import and export your custom code snippets, functions, and header and footer scripts to help you save time.
|
110 |
+
|
111 |
+
Switching from another code snippets plugin?
|
112 |
+
|
113 |
+
We have an automatic import feature that imports your custom code snippets from both Woody Code Snippets and Code Snippets Pro plugin.
|
114 |
+
|
115 |
+
> Simple plugin I use in quite every site. Very useful to insert scripts and tags.
|
116 |
+
> tommasoperego - WordPress user
|
117 |
+
|
118 |
+
= Example Use Cases =
|
119 |
+
|
120 |
+
WPCode is the most powerful code snippet + headers and footers plugin for WordPress. Here are some of the top use-cases why smart website owners and developers love us:
|
121 |
+
|
122 |
+
* Insert Headers and Footers scripts
|
123 |
+
* Insert Google Analytics Tracking Code in Header and Footer
|
124 |
+
* Insert PHP Code Snippets or JavaScript code snippet without modifying theme's functions.php file
|
125 |
+
* Insert Facebook Pixels code, Google Conversion Pixels code, and other Advertising Conversion Pixel Scripts in WordPress header and footer with conditional logic
|
126 |
+
* Insert Google AdSense Ads code, Amazon Native Contextual Ads code, and other Media Ads code
|
127 |
+
* Insert Custom JavaScript, CSS, and HTML code
|
128 |
+
* Insert Site Verification Meta tags for Social Media, Google Search Console, and other Domain verification in the header and footer of your site
|
129 |
+
* Insert re-usable custom content blocks and PHP code snippets
|
130 |
+
* Insert Ads code in content after specific paragraphs
|
131 |
+
* Show or hide custom code snippets based on conditional logic
|
132 |
+
* Disable XML-RPC, Disable Rest API, disable comments, allow SVG file uploads, disable Gutenberg and enable Classic Editor without adding extra plugins.
|
133 |
+
|
134 |
+
Simply put, WPCode is the one plugin that helps you get rid of dozens of other plugins without losing functionality.
|
135 |
+
|
136 |
+
= Full WPCode Feature List =
|
137 |
+
|
138 |
+
The simple interface of WPCode plugin (formerly known as Insert Headers and Footers) gives you one place where you can insert header and footer scripts as well as custom code snippets rather than dealing with dozens of different plugins.
|
139 |
+
|
140 |
+
Below is a full list of WPCode features:
|
141 |
|
142 |
* Quick to set up
|
143 |
+
* Unlimited code snippets
|
144 |
+
* Simple to insert header and footer scripts globally
|
145 |
+
* Beginner Friendly Code Editor with Syntax Highlighter for PHP, JavaScript, and HTML
|
146 |
+
* Smart Code Validation to Prevent PHP Errors
|
147 |
+
* Insert header code and/or footer code using Conditional Logic
|
148 |
+
* Add <strong>Google Analytics</strong> code to header and footer
|
149 |
+
* Add <strong>custom CSS</strong> code to any theme
|
150 |
+
* Insert <strong>Facebook pixel</strong> code in header and footer
|
151 |
* Insert any code or script, including HTML and Javascript
|
152 |
+
* Insert PHP Code Snippets
|
153 |
+
* Ready-made Code Snippet Library
|
154 |
+
* Custom WordPress Code Snippet Generator
|
155 |
+
* Show or Hide PHP Code Snippets based on conditional logic
|
156 |
+
* Run PHP code and custom code snippets everywhere or in select areas using smart auto-insert rules.
|
157 |
+
* Manually insert PHP code snippets using shortcodes anywhere on website
|
158 |
+
* Add Rich Text Ads and Content Snippets automatically on posts & pages.
|
159 |
+
* Export / Import Code Snippets
|
160 |
+
* and more features coming soon.
|
161 |
|
162 |
= Credits =
|
163 |
|
164 |
+
Insert Headers and Footers plugin was first created by <a href="https://syedbalkhi.com/" rel="friend" title="Syed Balkhi">Syed Balkhi</a> and the <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> team in 2011.
|
165 |
|
166 |
+
It was later rebranded to WPCode in 2022 by Syed Balkhi to add powerful code snippets features that users were requesting for.
|
167 |
+
|
168 |
+
= Branding Guideline =
|
169 |
|
170 |
+
WPCode™ is a trademark of WPCode LLC. When writing about the Insert Headers and Footers - Code Snippets plugin by WPCode, please make sure to uppercase the initial 3 letters.
|
171 |
|
172 |
+
WPCode (correct)
|
173 |
+
WP Code (incorrect)
|
174 |
+
wpcode (incorrect)
|
175 |
+
wp code snippets (incorrect)
|
176 |
+
|
177 |
+
= What's Next =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
+
If you find this plugin useful to insert header and footer + custom code snippets, then please leave a good rating and consider checking out our other projects:
|
180 |
|
181 |
+
* <a href="https://wpforms.com/">WPForms</a> - #1 drag & drop online form builder for WordPress (trusted by 5 million sites).
|
182 |
+
* <a href="https://optinmonster.com/">OptinMonster</a> - Get More Email Subscribers with the most popular conversion optimization plugin for WordPress.
|
183 |
+
* <a href="https://www.monsterinsights.com/">MonsterInsights</a> - See the stats that matter and grow your business with confidence. The best Google Analytics plugin for WordPress.
|
184 |
+
* <a href="https://www.seedprod.com/">SeedProd</a> - Create beautiful landing pages with our powerful drag & drop landing page builder.
|
185 |
+
* <a href="https://wpmailsmtp.com">WP Mail SMTP</a> - Improve email deliverability for your contact form with the most popular SMTP plugin for WordPress.
|
186 |
+
* <a href="https://rafflepress.com/">RafflePress</a> - Best WordPress giveaway and contest plugin to grow traffic and social followers.
|
187 |
+
* <a href="https://smashballoon.com/">Smash Balloon</a> - #1 social feeds plugin for WordPress - display social media content in WordPress without code.
|
188 |
+
* <a href="https://aioseo.com/">AIOSEO</a> - The original WordPress SEO plugin to help you rank higher in search results (trusted by over 3 million sites).
|
189 |
+
* <a href="https://www.pushengage.com/">Push Engage</a> - Connect with visitors after they leave your website with the leading web push notification plugin.
|
190 |
+
* <a href="https://trustpulse.com/">TrustPulse</a> - Add real-time social proof notifications to boost your store conversions by up to 15%.
|
191 |
+
* <a href="https://searchwp.com/">SearchWP</a> - The most advanced custom WordPress search plugin to improve WordPress search quality.
|
192 |
+
* <a href="https://affiliatewp.com/">AffiliateWP</a> - #1 affiliate management plugin for WordPress. Add a referral program to your online store.
|
193 |
+
* <a href="https://wpsimplepay.com/">WP Simple Pay</a> - #1 Stripe payments plugin for WordPress. Start accepting one-time or recurring payments without a shopping cart.
|
194 |
+
* <a href="https://easydigitaldownloads.com/">Easy Digital Downloads</a> - The best WordPress eCommerce plugin to sell digital products (eBooks, software, music, and more).
|
195 |
+
* <a href="https://sugarcalendar.com/">Sugar Calendar</a> - A simple event calendar plugin for WordPress that's both easy and powerful.
|
196 |
+
* <a href="https://www.wpcharitable.com/">WP Charitable</a> - Top-rated WordPress donation and fundraising plugin for non-profits.
|
197 |
+
|
198 |
+
Visit <a href="https://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> to learn from our <a href="https://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress Tutorials</a> and find out about other <a href="https://www.wpbeginner.com/category/plugins/" rel="friend" title="Best WordPress Plugins">best WordPress plugins</a>.
|
199 |
|
|
|
200 |
|
201 |
== Installation ==
|
202 |
|
203 |
+
1. Install WPCode - Insert Headers, Footers, and Code Snippets plugin by uploading the `insert-headers-and-footers` directory to the `/wp-content/plugins/` directory. (See instructions on <a href="http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/" rel="friend">how to install a WordPress plugin</a>.)
|
204 |
+
2. Activate WPCode - Insert Headers, Footers, and Code Snippets plugin through the `Plugins` menu in WordPress.
|
205 |
+
3. Insert code in your header and footer or add custom code snippets by going to the `Code Snippets` menu.
|
206 |
|
207 |
[youtube https://www.youtube.com/watch?v=QXbrdVjWaME]
|
208 |
|
209 |
== Screenshots ==
|
210 |
|
211 |
+
1. WordPress Code Snippets Management Screen
|
212 |
+
2. Ready-Made Code Snippets Library
|
213 |
+
3. Edit PHP Snippets with Code Syntax Highlighter
|
214 |
+
4. Show / Hide Code Snippets with Smart Conditional Logic
|
215 |
+
5. Custom WordPress Code Generators
|
216 |
+
6. Example of Custom Post Type Generator
|
217 |
+
7. Insert Header and Footer Scripts Globally
|
218 |
+
8. Import and Export Code Snippets
|
219 |
|
220 |
== Frequently Asked Questions ==
|
221 |
|
222 |
+
= Can I use WPCode - Insert Headers and Footers to install Google Analytics? =
|
223 |
|
224 |
Yes, you can insert your Google Analytics code in the `Scripts in Header` field.
|
225 |
|
226 |
+
= Can I use WPCode - Insert Headers and Footers for Google AdSense? =
|
227 |
|
228 |
Yes, to verify your account or to tag your page for Auto ads, paste the code AdSense gives you, into the Scripts in Header field.
|
229 |
|
230 |
+
= Will I lose my snippets if I change my WordPress theme? =
|
231 |
+
|
232 |
+
No, the idea behind WPCode - Insert Headers, Footers, and Code Snippets plugin is so you can safely add code snippets.
|
233 |
+
|
234 |
+
All code snippets are stored in the WordPress database, independent of the theme upgrades.
|
235 |
+
|
236 |
+
= Can I switch back to the old version of Insert Headers and Footers? =
|
237 |
+
|
238 |
+
Yes, if you don't want the advanced code snippets functionality, then you can switch back to the old Insert Headers and Footers features by simply going to the Settings Menu and clicking on the Headers & Footers mode.
|
239 |
+
|
240 |
+
= What Type of Code Snippets can I add? =
|
241 |
+
|
242 |
+
With WPCode, you can add any type of code snippet that you would otherwise add in your theme's functions.php file or in a site-specific plugin.
|
243 |
+
|
244 |
+
This includes custom PHP snippets, JavaScript snippets, HTML snippet, Text Snippets, Conversion pixels, Tracking scripts, AdSense or other banner ads code, and more.
|
245 |
|
246 |
+
= What are some example plugins WPCode can replace? =
|
247 |
+
|
248 |
+
WPCode comes with a ready-made code snippets library that allows you to replace several popular plugins including:
|
249 |
+
|
250 |
+
* Disable Comment plugins
|
251 |
+
* Disable XML-RPC plugins
|
252 |
+
* Disable Rest API plugins
|
253 |
+
* Disable Gutenberg plugins
|
254 |
+
* Classic Editor plugin
|
255 |
+
* Allow SVG File Upload plugins
|
256 |
+
* Disable RSS feed plugins
|
257 |
+
* Disable Search plugins
|
258 |
+
* Disable Automatic Updates plugins
|
259 |
+
* Disable Admin Bar plugins
|
260 |
+
* Disable Widget Blocks plugin
|
261 |
+
* Classic Widgets plugin
|
262 |
+
* Remove WordPress Version Number plugins
|
263 |
+
* Google Analytics plugins
|
264 |
+
* Facebook Pixel plugins
|
265 |
+
* Google AdSense plugins
|
266 |
+
* Custom Post Types UI plugins
|
267 |
+
* Other WordPress Generator plugins
|
268 |
+
|
269 |
+
... and basically any plugin that adds a functionality which can be added via custom code snippets.
|
270 |
+
|
271 |
+
= Is WPCode translation ready? =
|
272 |
+
|
273 |
+
Yes, WPCode has full translation and localization support via the insert-headers-and-footers textdomain. Based on your site language, required .mo and .po translation files will be downloaded and placed into the default WordPress languages directory.
|
274 |
|
275 |
== Notes ==
|
276 |
+
|
277 |
+
Insert Headers and Footers by WPCode is the easiest way to insert code in your WordPress headers and footers.
|
278 |
|
279 |
Our goal is to make using WordPress easy, both with our <a href="http://www.wpbeginner.com/wordpress-plugins/" rel="friend" title="WordPress Plugins">WordPress plugins</a> and resources like <a href="http://www.wpbeginner.com/" rel="friend">WPBeginner</a>, the largest WordPress resource site for beginners.
|
280 |
|
281 |
+
I feel that we have done that here. I hope you find Insert Headers and Footers useful to insert scripts on your site.
|
282 |
|
283 |
Thank you
|
284 |
Syed Balkhi
|
285 |
|
286 |
== Changelog ==
|
287 |
|
288 |
+
= 2.0.0 =
|
289 |
+
* New: Insert Headers and Footers is now WPCode - We make it easy for you to add code snippets in WordPress without having to edit your theme’s functions.php file.
|
290 |
+
* New: Full Code Snippets Library - WordPress code snippets library right inside the WPCode plugin.
|
291 |
+
* New: WordPress code generators to help you quickly generate ready-to-use code using the latest WordPress coding standards and API’s.
|
292 |
+
* New: Conditional Logic for Code Snippets - Instead of learning the various WordPress conditional logic queries, you can use our beginner-friendly conditional logic user interface.
|
293 |
+
* New: Auto-insert in various locations of your site or manual code output using shortcodes.
|
294 |
+
|
295 |
= 1.6.2 =
|
296 |
* Fix: Reverted a method visibility that was conflicting with other plugins using it.
|
297 |
|
353 |
* fixed unnecessary CSS loading
|
354 |
|
355 |
= 1.0 =
|
356 |
+
* Initial version
|
uninstall.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Uninstall WPCode.
|
4 |
+
*
|
5 |
+
* Remove:
|
6 |
+
* - custom capabilities.
|
7 |
+
*
|
8 |
+
* @package WPCode
|
9 |
+
*/
|
10 |
+
|
11 |
+
// Exit if accessed directly.
|
12 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
require_once 'ihaf.php';
|
17 |
+
|
18 |
+
if ( class_exists( 'WPCode_Capabilities' ) ) {
|
19 |
+
// Remove custom capabilities on uninstall.
|
20 |
+
WPCode_Capabilities::uninstall();
|
21 |
+
}
|
22 |
+
|
23 |
+
if ( class_exists( 'WPCode_Notifications' ) ) {
|
24 |
+
WPCode_Notifications::delete_notifications_data();
|
25 |
+
}
|
views/dashboard-notices.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Notices template
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<div class="notice notice-success is-dismissible <?php echo $this->plugin->name; ?>-notice-welcome">
|
7 |
-
<p>
|
8 |
-
<?php
|
9 |
-
printf(
|
10 |
-
/* translators: %s: Name of this plugin */
|
11 |
-
__( 'Thank you for installing %1$s!', 'insert-headers-and-footers' ),
|
12 |
-
$this->plugin->displayName
|
13 |
-
);
|
14 |
-
?>
|
15 |
-
<a href="<?php echo $setting_page; ?>"><?php esc_html_e( 'Click here', 'insert-headers-and-footers' ); ?></a> <?php esc_html_e( 'to configure the plugin.', 'insert-headers-and-footers' ); ?>
|
16 |
-
</p>
|
17 |
-
</div>
|
18 |
-
<script type="text/javascript">
|
19 |
-
jQuery(document).ready( function($) {
|
20 |
-
$(document).on( 'click', '.<?php echo $this->plugin->name; ?>-notice-welcome button.notice-dismiss', function( event ) {
|
21 |
-
event.preventDefault();
|
22 |
-
$.post( ajaxurl, {
|
23 |
-
action: '<?php echo $this->plugin->name . '_dismiss_dashboard_notices'; ?>',
|
24 |
-
nonce: '<?php echo wp_create_nonce( $this->plugin->name . '-nonce' ); ?>'
|
25 |
-
});
|
26 |
-
$('.<?php echo $this->plugin->name; ?>-notice-welcome').remove();
|
27 |
-
});
|
28 |
-
});
|
29 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/settings.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<div class="wrap">
|
2 |
-
<h2><?php echo $this->plugin->displayName; ?> » <?php esc_html_e( 'Settings', 'insert-headers-and-footers' ); ?></h2>
|
3 |
-
|
4 |
-
<?php
|
5 |
-
if ( isset( $this->message ) ) {
|
6 |
-
?>
|
7 |
-
<div class="updated fade"><p><?php echo $this->message; ?></p></div>
|
8 |
-
<?php
|
9 |
-
}
|
10 |
-
if ( isset( $this->errorMessage ) ) {
|
11 |
-
?>
|
12 |
-
<div class="error fade"><p><?php echo $this->errorMessage; ?></p></div>
|
13 |
-
<?php
|
14 |
-
}
|
15 |
-
?>
|
16 |
-
|
17 |
-
<div id="poststuff">
|
18 |
-
<div id="post-body" class="metabox-holder columns-2">
|
19 |
-
<!-- Content -->
|
20 |
-
<div id="post-body-content">
|
21 |
-
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
22 |
-
<div class="postbox">
|
23 |
-
<h3 class="hndle"><?php esc_html_e( 'Settings', 'insert-headers-and-footers' ); ?></h3>
|
24 |
-
|
25 |
-
<div class="inside">
|
26 |
-
<form action="options-general.php?page=<?php echo $this->plugin->name; ?>" method="post">
|
27 |
-
<p>
|
28 |
-
<label for="ihaf_insert_header"><strong><?php esc_html_e( 'Scripts in Header', 'insert-headers-and-footers' ); ?></strong></label>
|
29 |
-
<textarea name="ihaf_insert_header" id="ihaf_insert_header" class="widefat" rows="8" style="font-family:Courier New;" <?php echo ( ! current_user_can( 'unfiltered_html' ) ) ? ' disabled="disabled" ' : ''; ?>><?php echo $this->settings['ihaf_insert_header']; ?></textarea>
|
30 |
-
<?php
|
31 |
-
printf(
|
32 |
-
/* translators: %s: The `<head>` tag */
|
33 |
-
esc_html__( 'These scripts will be printed in the %s section.', 'insert-headers-and-footers' ),
|
34 |
-
'<code><head></code>'
|
35 |
-
);
|
36 |
-
?>
|
37 |
-
</p>
|
38 |
-
<?php if ( $this->body_open_supported ) : ?>
|
39 |
-
<p>
|
40 |
-
<label for="ihaf_insert_body"><strong><?php esc_html_e( 'Scripts in Body', 'insert-headers-and-footers' ); ?></strong></label>
|
41 |
-
<textarea name="ihaf_insert_body" id="ihaf_insert_body" class="widefat" rows="8" style="font-family:Courier New;" <?php echo ( ! current_user_can( 'unfiltered_html' ) ) ? ' disabled="disabled" ' : ''; ?>><?php echo $this->settings['ihaf_insert_body']; ?></textarea>
|
42 |
-
<?php
|
43 |
-
printf(
|
44 |
-
/* translators: %s: The `<head>` tag */
|
45 |
-
esc_html__( 'These scripts will be printed just below the opening %s tag.', 'insert-headers-and-footers' ),
|
46 |
-
'<code><body></code>'
|
47 |
-
);
|
48 |
-
?>
|
49 |
-
</p>
|
50 |
-
<?php endif; ?>
|
51 |
-
<p>
|
52 |
-
<label for="ihaf_insert_footer"><strong><?php esc_html_e( 'Scripts in Footer', 'insert-headers-and-footers' ); ?></strong></label>
|
53 |
-
<textarea name="ihaf_insert_footer" id="ihaf_insert_footer" class="widefat" rows="8" style="font-family:Courier New;" <?php echo ( ! current_user_can( 'unfiltered_html' ) ) ? ' disabled="disabled" ' : ''; ?>><?php echo $this->settings['ihaf_insert_footer']; ?></textarea>
|
54 |
-
<?php
|
55 |
-
printf(
|
56 |
-
/* translators: %s: The `</body>` tag */
|
57 |
-
esc_html__( 'These scripts will be printed above the closing %s tag.', 'insert-headers-and-footers' ),
|
58 |
-
'<code></body></code>'
|
59 |
-
);
|
60 |
-
?>
|
61 |
-
</p>
|
62 |
-
<?php if ( current_user_can( 'unfiltered_html' ) ) : ?>
|
63 |
-
<?php wp_nonce_field( $this->plugin->name, $this->plugin->name . '_nonce' ); ?>
|
64 |
-
<p>
|
65 |
-
<input name="submit" type="submit" name="Submit" class="button button-primary" value="<?php esc_attr_e( 'Save', 'insert-headers-and-footers' ); ?>" />
|
66 |
-
</p>
|
67 |
-
<?php endif; ?>
|
68 |
-
</form>
|
69 |
-
</div>
|
70 |
-
</div>
|
71 |
-
<!-- /postbox -->
|
72 |
-
</div>
|
73 |
-
<!-- /normal-sortables -->
|
74 |
-
</div>
|
75 |
-
<!-- /post-body-content -->
|
76 |
-
|
77 |
-
<!-- Sidebar -->
|
78 |
-
<div id="postbox-container-1" class="postbox-container">
|
79 |
-
<?php require_once( $this->plugin->folder . '/views/sidebar.php' ); ?>
|
80 |
-
</div>
|
81 |
-
<!-- /postbox-container -->
|
82 |
-
</div>
|
83 |
-
</div>
|
84 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/sidebar.php
DELETED
@@ -1,121 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Donations Sidebar
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<!-- Improve Your Site -->
|
7 |
-
<div class="postbox">
|
8 |
-
<h3 class="hndle">
|
9 |
-
<span><?php esc_html_e( 'Improve Your Site', 'insert-headers-and-footers' ); ?></span>
|
10 |
-
</h3>
|
11 |
-
|
12 |
-
<div class="inside">
|
13 |
-
<p>
|
14 |
-
<?php
|
15 |
-
printf(
|
16 |
-
/* translators: %s: Link to WPBeginner blog */
|
17 |
-
esc_html__( 'Want to take your site to the next level? Check out our daily free WordPress tutorials on %s.', 'insert-headers-and-footers' ),
|
18 |
-
sprintf(
|
19 |
-
'<a href="http://www.wpbeginner.com/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">%s</a>',
|
20 |
-
esc_html__( 'WPBeginner blog', 'insert-headers-and-footers' )
|
21 |
-
)
|
22 |
-
);
|
23 |
-
?>
|
24 |
-
</p>
|
25 |
-
|
26 |
-
<p>
|
27 |
-
<?php esc_html_e( 'Some of our popular guides:', 'insert-headers-and-footers' ); ?>
|
28 |
-
</p>
|
29 |
-
|
30 |
-
<ul>
|
31 |
-
<li>
|
32 |
-
<a href="http://www.wpbeginner.com/wordpress-performance-speed/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
|
33 |
-
<?php esc_html_e( 'Speed Up WordPress', 'insert-headers-and-footers' ); ?>
|
34 |
-
</a>
|
35 |
-
</li>
|
36 |
-
<li>
|
37 |
-
<a href="http://www.wpbeginner.com/wordpress-security/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
|
38 |
-
<?php esc_html_e( 'Improve WordPress Security', 'insert-headers-and-footers' ); ?>
|
39 |
-
</a>
|
40 |
-
</li>
|
41 |
-
<li>
|
42 |
-
<a href="http://www.wpbeginner.com/wordpress-seo/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
|
43 |
-
<?php esc_html_e( 'Boost Your WordPress SEO', 'insert-headers-and-footers' ); ?>
|
44 |
-
</a>
|
45 |
-
</li>
|
46 |
-
</ul>
|
47 |
-
|
48 |
-
</div>
|
49 |
-
</div>
|
50 |
-
|
51 |
-
<!-- Donate -->
|
52 |
-
<div class="postbox">
|
53 |
-
<h3 class="hndle">
|
54 |
-
<span><?php esc_html_e( 'Our WordPress Plugins', 'insert-headers-and-footers' ); ?></span>
|
55 |
-
</h3>
|
56 |
-
<div class="inside">
|
57 |
-
<p>
|
58 |
-
<?php esc_html_e( 'Like this plugin? Check out our other WordPress plugins:', 'insert-headers-and-footers' ); ?>
|
59 |
-
</p>
|
60 |
-
<p>
|
61 |
-
<?php
|
62 |
-
printf(
|
63 |
-
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
64 |
-
esc_url( 'https://wordpress.org/plugins/wpforms-lite/' ),
|
65 |
-
esc_html__( 'WPForms', 'insert-headers-and-footers' ),
|
66 |
-
esc_html__( 'Drag & Drop WordPress Form Builder', 'insert-headers-and-footers' )
|
67 |
-
);
|
68 |
-
?>
|
69 |
-
</p>
|
70 |
-
<p>
|
71 |
-
<?php
|
72 |
-
printf(
|
73 |
-
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
74 |
-
esc_url( 'https://wordpress.org/plugins/google-analytics-for-wordpress/' ),
|
75 |
-
esc_html__( 'MonsterInsights', 'insert-headers-and-footers' ),
|
76 |
-
esc_html__( 'Google Analytics Made Easy for WordPress', 'insert-headers-and-footers' )
|
77 |
-
);
|
78 |
-
?>
|
79 |
-
</p>
|
80 |
-
<p>
|
81 |
-
<?php
|
82 |
-
printf(
|
83 |
-
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
84 |
-
esc_url( 'http://optinmonster.com/' ),
|
85 |
-
esc_html__( 'OptinMonster', 'insert-headers-and-footers' ),
|
86 |
-
esc_html__( 'Best WordPress Lead Generation Plugin', 'insert-headers-and-footers' )
|
87 |
-
);
|
88 |
-
?>
|
89 |
-
</p>
|
90 |
-
<p>
|
91 |
-
<?php
|
92 |
-
printf(
|
93 |
-
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
94 |
-
esc_url( 'https://www.seedprod.com/' ),
|
95 |
-
esc_html__( 'SeedProd', 'insert-headers-and-footers' ),
|
96 |
-
esc_html__( 'Get the best Drag & Drop WordPress Website Builder', 'insert-headers-and-footers' )
|
97 |
-
);
|
98 |
-
?>
|
99 |
-
</p>
|
100 |
-
<p>
|
101 |
-
<?php
|
102 |
-
printf(
|
103 |
-
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
104 |
-
esc_url( 'https://wordpress.org/plugins/all-in-one-seo-pack/' ),
|
105 |
-
esc_html__( 'AIOSEO', 'insert-headers-and-footers' ),
|
106 |
-
esc_html__( 'Best WordPress SEO plugin (used by 3 million sites).', 'insert-headers-and-footers' )
|
107 |
-
);
|
108 |
-
?>
|
109 |
-
</p>
|
110 |
-
<p>
|
111 |
-
<?php
|
112 |
-
printf(
|
113 |
-
'<a href="%1$s" target="_blank">%2$s</a> - %3$s',
|
114 |
-
esc_url( 'https://wordpress.org/plugins/wp-mail-smtp/' ),
|
115 |
-
esc_html__( 'WP Mail SMTP', 'insert-headers-and-footers' ),
|
116 |
-
esc_html__( 'Fix WordPress email deliverability with the best SMTP plugin.', 'insert-headers-and-footers' )
|
117 |
-
);
|
118 |
-
?>
|
119 |
-
</p>
|
120 |
-
</div>
|
121 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|