Version Description
- Public release of the 1.0 refactoring.
Download this release
Release Info
Developer | kasparsd |
Plugin | Widget Context |
Version | 1.0 |
Comparing to | |
See all releases |
Code changes from version 0.8.3 to 1.0
- admin-style.css +0 -25
- css/admin.css +61 -0
- js/widget-context.js +47 -0
- languages/widget-context-lv_LV.mo +0 -0
- languages/widget-context-lv_LV.po +266 -0
- languages/widget-context.pot +258 -0
- modules/custom-post-types-taxonomies/custom-cpt-tax.php +155 -0
- modules/word-count/word-count.php +112 -0
- readme.txt +33 -14
- widget-context.php +822 -281
admin-style.css
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
|
2 |
-
.widget-context { float:left; width:100%; clear:both; margin:0.5em -12px; padding:0.25em 12px; border-top:1px solid #dfdfdf; border-bottom:1px solid #dfdfdf; background:#eee; }
|
3 |
-
.widget .widget-context-inside p { margin:0.5em 0; }
|
4 |
-
|
5 |
-
.wl-incexc select { max-width:11em; }
|
6 |
-
|
7 |
-
.wl-columns input { vertical-align:middle; }
|
8 |
-
.wl-column-2-1 { float:left; width:48%; }
|
9 |
-
.wl-column-2-2 { float:right; width:50%; }
|
10 |
-
.wl-columns label { display:block; }
|
11 |
-
|
12 |
-
.wl-word-count { clear:both; }
|
13 |
-
.wl-word-count .wl-check-wordcount-type select { font-size:1.1em; padding:0; }
|
14 |
-
.wl-word-count label { display:inline; }
|
15 |
-
.wl-word-count .wl-word-count input { display:inline; width:3em; }
|
16 |
-
|
17 |
-
.wl-options { }
|
18 |
-
.wl-options .wl-urls { clear:both; }
|
19 |
-
.wl-options .wl-urls textarea { width:100%; height:7em; font-size:0.96em; line-height:1.25em; }
|
20 |
-
.wl-visibility { }
|
21 |
-
|
22 |
-
.wl-notes { float:left; width:100%; clear:both; margin-bottom:0.5em; }
|
23 |
-
.wl-notes textarea { float:left; width:100%; clear:both; height:4em; font-size:1em; line-height:1.25em; }
|
24 |
-
|
25 |
-
.widget .widget-inside .wl-tip { font-size:0.9em; line-height:1.1; margin:0 0 1em 0; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/admin.css
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
.widget-context { float:left; width:100%; clear:both; margin:0.5em 0; padding:0 0 0.5em 0; border-bottom:1px solid #dfdfdf; }
|
3 |
+
.widget-context-inside { float:left; width:100%; clear:both; }
|
4 |
+
.widget-context-inside p { margin:0 0 0.5em; }
|
5 |
+
.widget-context textarea { display:block; width:100%; height:8em; font:inherit; }
|
6 |
+
.widget-context .help { line-height:1.2; color:#666; }
|
7 |
+
|
8 |
+
.widget-context .widget-context-header { float:left; width:100%; clear:both; }
|
9 |
+
.widget-context .widget-context-header h3 { font-size:1.1em; margin:0 0.5em 0.5em 0; padding:0; }
|
10 |
+
.widget-context .widget-context-header h3:before { font-family: 'dashicons'; content: "\f489"; vertical-align:bottom; margin-right:0.2em; }
|
11 |
+
|
12 |
+
.widget-context .context-group { float:left; width:100%; clear:both; margin-bottom:0.5em; }
|
13 |
+
.widget-context .context-toggle { margin:0 0 0.3em 0; display:block; text-decoration:none; color:inherit; font-weight:bold; }
|
14 |
+
|
15 |
+
.widget-context .context-inactive { display:none; }
|
16 |
+
|
17 |
+
.widget-context .context-global .context-group { display:none; }
|
18 |
+
.widget-context .context-global .context-group-incexc { display:block; }
|
19 |
+
|
20 |
+
/** Modules **/
|
21 |
+
|
22 |
+
.context-group-incexc select { width:100%; border-width:2px; }
|
23 |
+
.context-group-incexc .context-toggle { display:none; }
|
24 |
+
|
25 |
+
.context-group-location .context-group-wrap { max-height:10em; overflow:auto; padding:0.5em; margin-bottom:0.5em; background:#fff; border:1px solid #ddd; }
|
26 |
+
.context-group-location label { display:block; padding:0.25em 0; }
|
27 |
+
|
28 |
+
.context-group-custom_post_types_taxonomies .context-group-wrap { max-height:10em; overflow:auto; padding:0.5em; margin-bottom:0.5em; background:#fff; border:1px solid #ddd; }
|
29 |
+
.context-group-custom_post_types_taxonomies label { display:block; padding:0.25em 0; }
|
30 |
+
|
31 |
+
.context-group-wrap .wc-field-text-word-count input { width:3em; }
|
32 |
+
|
33 |
+
.context-group-admin_notes textarea { height:4em; }
|
34 |
+
|
35 |
+
/** Settings UI **/
|
36 |
+
|
37 |
+
.widget-context-form th { width:auto; }
|
38 |
+
.widget-context-form ul { border-top:1px solid #ddd; margin:0 0 1em 0; padding:0; float:left; width:100%; clear:both; display:block; }
|
39 |
+
.widget-context-form li { float:left; width:100%; clear:both; margin:0; padding:0.5em 0; border-bottom:1px solid #ddd; }
|
40 |
+
.widget-context-form li label { vertical-align:middle; float:left; width:34%; margin:0 -100em 0 0; }
|
41 |
+
.widget-context-form li label input { vertical-align:middle; }
|
42 |
+
.widget-context-form .context-desc { font-style:italic; color:#666; margin:0 0 0 40%; }
|
43 |
+
.widget-context-settings-wrap { padding-right:300px; }
|
44 |
+
.widget-context-form { float:left; width:100%; margin-right:-100em; }
|
45 |
+
.widget-context-sidebar { float:right; width:280px; position:relative; right:-300px; border:1px solid #ddd; }
|
46 |
+
.widget-context-sidebar h2, .widget-context-sidebar h3 { margin-bottom:0.5em ; }
|
47 |
+
.widget-context-sidebar p { margin:0 0 1em 0; }
|
48 |
+
.wc-sidebar-in { padding:1em; }
|
49 |
+
.wc-sidebar-credits { padding-bottom:0.5em; margin-bottom:1em; border-bottom:1px solid #ddd; }
|
50 |
+
.wc-sidebar-credits img { float:left; margin:0 1em 1em 0; }
|
51 |
+
|
52 |
+
/** Sets correct widget height when child element height changes **/
|
53 |
+
.widget-control-actions,
|
54 |
+
.widget-content,
|
55 |
+
#widgets-right .widget { clear:left; }
|
56 |
+
|
57 |
+
@media screen and ( max-width: 900px ) {
|
58 |
+
.widget-context-settings-wrap { padding-right:0; }
|
59 |
+
.widget-context-form { margin:0; }
|
60 |
+
.widget-context-sidebar { width:100%; right:0; }
|
61 |
+
}
|
js/widget-context.js
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($) {
|
2 |
+
|
3 |
+
function show_hide_controls( widget_id ) {
|
4 |
+
|
5 |
+
var value = $( '#widget-context-' + widget_id + ' .wc-field-select-condition select' ).val();
|
6 |
+
|
7 |
+
if ( value == 'show' || value == 'hide' ) {
|
8 |
+
$( '#widget-context-' + widget_id ).addClass('context-global');
|
9 |
+
} else {
|
10 |
+
$( '#widget-context-' + widget_id ).removeClass('context-global');
|
11 |
+
}
|
12 |
+
|
13 |
+
}
|
14 |
+
|
15 |
+
$('.widget-context-inside').each(function() {
|
16 |
+
|
17 |
+
show_hide_controls( $(this).data('widget-id') );
|
18 |
+
|
19 |
+
});
|
20 |
+
|
21 |
+
$('#widgets-right, #widgets-left').on( 'change', '.wc-field-select-condition select', function(){
|
22 |
+
|
23 |
+
show_hide_controls( $(this).parent().data('widget-id') );
|
24 |
+
|
25 |
+
});
|
26 |
+
|
27 |
+
$(document).ajaxSuccess(function(e, xhr, settings) {
|
28 |
+
var widget_id = get_query_arg_val( settings.data, 'widget-id' );
|
29 |
+
if ( widget_id ) {
|
30 |
+
show_hide_controls( widget_id );
|
31 |
+
}
|
32 |
+
});
|
33 |
+
|
34 |
+
var get_query_arg_val = function( query, key ) {
|
35 |
+
var vars = query.split('&');
|
36 |
+
|
37 |
+
for ( var i=0; i<vars.length; i++ ) {
|
38 |
+
pair = vars[i].split('=');
|
39 |
+
if ( pair[0] == key ) {
|
40 |
+
return pair[1];
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
return false;
|
45 |
+
};
|
46 |
+
|
47 |
+
});
|
languages/widget-context-lv_LV.mo
ADDED
Binary file
|
languages/widget-context-lv_LV.po
ADDED
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2014 Widget Context
|
2 |
+
# This file is distributed under the same license as the Widget Context package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Widget Context 1.0-alpha.6\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/git\n"
|
7 |
+
"POT-Creation-Date: 2014-07-10 14:48:47+00:00\n"
|
8 |
+
"PO-Revision-Date: 2014-07-10 17:49+0200\n"
|
9 |
+
"Last-Translator: Kaspars <kaspars@konstruktors.com>\n"
|
10 |
+
"Language-Team: Kaspars Dambis <LL@li.org>\n"
|
11 |
+
"Language: lv_LV\n"
|
12 |
+
"MIME-Version: 1.0\n"
|
13 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
+
"Content-Transfer-Encoding: 8bit\n"
|
15 |
+
"X-Generator: Poedit 1.6.6\n"
|
16 |
+
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : "
|
17 |
+
"2);\n"
|
18 |
+
|
19 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:71
|
20 |
+
msgid "Custom Post Types and Taxonomies"
|
21 |
+
msgstr "Ierakstu tipi un taksonomijas"
|
22 |
+
|
23 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:72
|
24 |
+
msgid "Context based custom post types and taxonomies"
|
25 |
+
msgstr "Konteksts atkarīgs no ierakstu tipa un taksanomijas"
|
26 |
+
|
27 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:123
|
28 |
+
msgid "All \"%s\" posts"
|
29 |
+
msgstr "Visi \"%s\" ieraksti"
|
30 |
+
|
31 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:129
|
32 |
+
msgid "Archive of \"%s\" posts"
|
33 |
+
msgstr "Arhīvs \"%s\" ierakstiem"
|
34 |
+
|
35 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:138
|
36 |
+
msgid "All \"%s\" taxonomy archives"
|
37 |
+
msgstr "Visi \"%s\" taksonomijas arhīvi"
|
38 |
+
|
39 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:150
|
40 |
+
msgid "None."
|
41 |
+
msgstr "Neviens."
|
42 |
+
|
43 |
+
#: modules/word-count/word-count.php:49
|
44 |
+
msgid "Word Count"
|
45 |
+
msgstr "Vārdu skaits"
|
46 |
+
|
47 |
+
#: modules/word-count/word-count.php:50
|
48 |
+
msgid "Context based on word count on the page."
|
49 |
+
msgstr "Konteksts izmanto vārdu skaitu konkrētā lapā."
|
50 |
+
|
51 |
+
#: modules/word-count/word-count.php:104
|
52 |
+
msgid "Has"
|
53 |
+
msgstr "Ir"
|
54 |
+
|
55 |
+
#: modules/word-count/word-count.php:105
|
56 |
+
msgid "less"
|
57 |
+
msgstr "mazāk"
|
58 |
+
|
59 |
+
#: modules/word-count/word-count.php:105
|
60 |
+
msgid "more"
|
61 |
+
msgstr "vairāk"
|
62 |
+
|
63 |
+
#: modules/word-count/word-count.php:105
|
64 |
+
msgid "than"
|
65 |
+
msgstr "kā"
|
66 |
+
|
67 |
+
#: modules/word-count/word-count.php:106
|
68 |
+
msgid "words"
|
69 |
+
msgstr "vārdu"
|
70 |
+
|
71 |
+
#. Plugin Name of the plugin/theme
|
72 |
+
#: widget-context.php:91 widget-context.php:530 widget-context.php:838
|
73 |
+
msgid "Widget Context"
|
74 |
+
msgstr "Logrīku konteksts"
|
75 |
+
|
76 |
+
#: widget-context.php:92
|
77 |
+
msgid "Set the default logic to show or hide."
|
78 |
+
msgstr "Iestatīt noklusēto loģiku slēpšanai vai rādīšanai."
|
79 |
+
|
80 |
+
#: widget-context.php:97
|
81 |
+
msgid "Global Sections"
|
82 |
+
msgstr "Globālās sadaļas"
|
83 |
+
|
84 |
+
#: widget-context.php:98
|
85 |
+
msgid "Based on standard WordPress template tags."
|
86 |
+
msgstr "Izmanto standarta WordPress \"template tags\"."
|
87 |
+
|
88 |
+
#: widget-context.php:102
|
89 |
+
msgid "Target by URL"
|
90 |
+
msgstr "Pēc URL"
|
91 |
+
|
92 |
+
#: widget-context.php:103
|
93 |
+
msgid "Based on URL patterns."
|
94 |
+
msgstr "Balstīts uz URL "
|
95 |
+
|
96 |
+
#: widget-context.php:107
|
97 |
+
msgid "Notes (invisible to public)"
|
98 |
+
msgstr "Piezīmes (nav publiskas)"
|
99 |
+
|
100 |
+
#: widget-context.php:108
|
101 |
+
msgid "Enables private notes on widget context settings."
|
102 |
+
msgstr "Iespējo privātas piezīmes logrīku konteksta uzstādījumos."
|
103 |
+
|
104 |
+
#: widget-context.php:491
|
105 |
+
msgid ""
|
106 |
+
"No widget controls enabled. You can enable them in <a href=\"%s\">Widget "
|
107 |
+
"Context settings</a>."
|
108 |
+
msgstr ""
|
109 |
+
"Nav iespējots neviens konteksta modulis. Tu vari tos iespējot <a href=\"%s"
|
110 |
+
"\">Logrīku konteksta uzstādījumos</a>."
|
111 |
+
|
112 |
+
#: widget-context.php:500
|
113 |
+
msgid "No widget controls enabled."
|
114 |
+
msgstr "Nav iespējots neviens logrīku kontekts."
|
115 |
+
|
116 |
+
#: widget-context.php:512 widget-context.php:837 widget-context.php:898
|
117 |
+
msgid "Widget Context Settings"
|
118 |
+
msgstr "Logrīku konteksta uzstādījumi"
|
119 |
+
|
120 |
+
#: widget-context.php:533
|
121 |
+
msgid "Expand"
|
122 |
+
msgstr "Izvērst"
|
123 |
+
|
124 |
+
#: widget-context.php:534
|
125 |
+
msgid "Collapse"
|
126 |
+
msgstr "Samazināt"
|
127 |
+
|
128 |
+
#: widget-context.php:548
|
129 |
+
msgid "Show widget everywhere"
|
130 |
+
msgstr "Radīt logrīku visur"
|
131 |
+
|
132 |
+
#: widget-context.php:549
|
133 |
+
msgid "Show widget on selected"
|
134 |
+
msgstr "Rādīt logrīku pēc izvēles"
|
135 |
+
|
136 |
+
#: widget-context.php:550
|
137 |
+
msgid "Hide widget on selected"
|
138 |
+
msgstr "Slēpt logrīku pēc izvēles"
|
139 |
+
|
140 |
+
#: widget-context.php:551
|
141 |
+
msgid "Hide widget everywhere"
|
142 |
+
msgstr "Slēpt logrīku pavisam"
|
143 |
+
|
144 |
+
#: widget-context.php:562
|
145 |
+
msgid "Front page"
|
146 |
+
msgstr "Sākuma lapa"
|
147 |
+
|
148 |
+
#: widget-context.php:563
|
149 |
+
msgid "Blog page"
|
150 |
+
msgstr "Bloga lapa"
|
151 |
+
|
152 |
+
#: widget-context.php:564
|
153 |
+
msgid "All posts, pages and custom post types"
|
154 |
+
msgstr "Visi ierakstu, lapas un custom post types"
|
155 |
+
|
156 |
+
#: widget-context.php:565
|
157 |
+
msgid "All posts"
|
158 |
+
msgstr "Visi ieraksti"
|
159 |
+
|
160 |
+
#: widget-context.php:566
|
161 |
+
msgid "All pages"
|
162 |
+
msgstr "Visas lapas"
|
163 |
+
|
164 |
+
#: widget-context.php:567
|
165 |
+
msgid "All attachments"
|
166 |
+
msgstr "Visi pielikumi"
|
167 |
+
|
168 |
+
#: widget-context.php:568
|
169 |
+
msgid "Search results"
|
170 |
+
msgstr "Meklēšanas rezultāti"
|
171 |
+
|
172 |
+
#: widget-context.php:569
|
173 |
+
msgid "404 error page"
|
174 |
+
msgstr "404 kļūdas lapa"
|
175 |
+
|
176 |
+
#: widget-context.php:570
|
177 |
+
msgid "All archives"
|
178 |
+
msgstr "Visi arhīvi"
|
179 |
+
|
180 |
+
#: widget-context.php:571
|
181 |
+
msgid "All date archives"
|
182 |
+
msgstr "Visi datuma arhīvi"
|
183 |
+
|
184 |
+
#: widget-context.php:572
|
185 |
+
msgid "Daily archives"
|
186 |
+
msgstr "Dienu arhīvi"
|
187 |
+
|
188 |
+
#: widget-context.php:573
|
189 |
+
msgid "Monthly archives"
|
190 |
+
msgstr "Mēneša arhīvi"
|
191 |
+
|
192 |
+
#: widget-context.php:574
|
193 |
+
msgid "Yearly archives"
|
194 |
+
msgstr "Gada arhīvi"
|
195 |
+
|
196 |
+
#: widget-context.php:575
|
197 |
+
msgid "All category archives"
|
198 |
+
msgstr "Visi kategoriju arhīvi"
|
199 |
+
|
200 |
+
#: widget-context.php:576
|
201 |
+
msgid "All tag archives"
|
202 |
+
msgstr "Visi tagu arhīvi"
|
203 |
+
|
204 |
+
#: widget-context.php:577
|
205 |
+
msgid "All author archives"
|
206 |
+
msgstr "Visi autoru arhīvi"
|
207 |
+
|
208 |
+
#: widget-context.php:594
|
209 |
+
msgid ""
|
210 |
+
"Enter one location fragment per line. Use <strong>*</strong> character as a "
|
211 |
+
"wildcard. Example: <code>category/peace/*</code> to target all posts in "
|
212 |
+
"category <em>peace</em>."
|
213 |
+
msgstr ""
|
214 |
+
|
215 |
+
#: widget-context.php:709
|
216 |
+
msgid "No options available"
|
217 |
+
msgstr "Nav pieejama neviena iespēja."
|
218 |
+
|
219 |
+
#: widget-context.php:915
|
220 |
+
msgid "Enabled Context Modules"
|
221 |
+
msgstr "Iespējot konteksta moduļus"
|
222 |
+
|
223 |
+
#: widget-context.php:932
|
224 |
+
msgid "Widget Context is created and maintained by %s."
|
225 |
+
msgstr "\"Logrīku konteksts\" spraudni veido un uztur %s."
|
226 |
+
|
227 |
+
#: widget-context.php:937
|
228 |
+
msgid "News & Updates"
|
229 |
+
msgstr "Jaunumi un atjauninājumi"
|
230 |
+
|
231 |
+
#: widget-context.php:938
|
232 |
+
#, fuzzy
|
233 |
+
msgid "Subscribe to receive news & updates about the plugin."
|
234 |
+
msgstr ""
|
235 |
+
"Pieraksties lai saņemtu jaunumus un informāciju par šī spraudņa "
|
236 |
+
"atjauninājumiem."
|
237 |
+
|
238 |
+
#: widget-context.php:941
|
239 |
+
msgid "Your Name"
|
240 |
+
msgstr "Tavs vārds"
|
241 |
+
|
242 |
+
#: widget-context.php:942
|
243 |
+
msgid "Your Email"
|
244 |
+
msgstr "Tavs e-pasts"
|
245 |
+
|
246 |
+
#: widget-context.php:943
|
247 |
+
msgid "Subscribe"
|
248 |
+
msgstr "Pierakstīties"
|
249 |
+
|
250 |
+
#. Plugin URI of the plugin/theme
|
251 |
+
msgid "http://wordpress.org/extend/plugins/widget-context/"
|
252 |
+
msgstr ""
|
253 |
+
|
254 |
+
#. Description of the plugin/theme
|
255 |
+
msgid ""
|
256 |
+
"Show or hide widgets depending on the section of the site that is being "
|
257 |
+
"viewed."
|
258 |
+
msgstr ""
|
259 |
+
|
260 |
+
#. Author of the plugin/theme
|
261 |
+
msgid "Kaspars Dambis"
|
262 |
+
msgstr ""
|
263 |
+
|
264 |
+
#. Author URI of the plugin/theme
|
265 |
+
msgid "http://kaspars.net"
|
266 |
+
msgstr ""
|
languages/widget-context.pot
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2014 Widget Context
|
2 |
+
# This file is distributed under the same license as the Widget Context package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Widget Context 1.0-beta.3\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/git\n"
|
7 |
+
"POT-Creation-Date: 2014-07-10 14:48:47+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
+
|
15 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:71
|
16 |
+
msgid "Custom Post Types and Taxonomies"
|
17 |
+
msgstr ""
|
18 |
+
|
19 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:72
|
20 |
+
msgid "Context based custom post types and taxonomies"
|
21 |
+
msgstr ""
|
22 |
+
|
23 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:123
|
24 |
+
msgid "All \"%s\" posts"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:129
|
28 |
+
msgid "Archive of \"%s\" posts"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:138
|
32 |
+
msgid "All \"%s\" taxonomy archives"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: modules/custom-post-types-taxonomies/custom-cpt-tax.php:150
|
36 |
+
msgid "None."
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: modules/word-count/word-count.php:49
|
40 |
+
msgid "Word Count"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: modules/word-count/word-count.php:50
|
44 |
+
msgid "Context based on word count on the page."
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: modules/word-count/word-count.php:104
|
48 |
+
msgid "Has"
|
49 |
+
msgstr ""
|
50 |
+
|
51 |
+
#: modules/word-count/word-count.php:105
|
52 |
+
msgid "less"
|
53 |
+
msgstr ""
|
54 |
+
|
55 |
+
#: modules/word-count/word-count.php:105
|
56 |
+
msgid "more"
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: modules/word-count/word-count.php:105
|
60 |
+
msgid "than"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: modules/word-count/word-count.php:106
|
64 |
+
msgid "words"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#. #-#-#-#-# widget-context.pot (Widget Context 1.0-beta.3) #-#-#-#-#
|
68 |
+
#. Plugin Name of the plugin/theme
|
69 |
+
#: widget-context.php:91 widget-context.php:530 widget-context.php:838
|
70 |
+
msgid "Widget Context"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: widget-context.php:92
|
74 |
+
msgid "Set the default logic to show or hide."
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: widget-context.php:97
|
78 |
+
msgid "Global Sections"
|
79 |
+
msgstr ""
|
80 |
+
|
81 |
+
#: widget-context.php:98
|
82 |
+
msgid "Based on standard WordPress template tags."
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: widget-context.php:102
|
86 |
+
msgid "Target by URL"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: widget-context.php:103
|
90 |
+
msgid "Based on URL patterns."
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: widget-context.php:107
|
94 |
+
msgid "Notes (invisible to public)"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: widget-context.php:108
|
98 |
+
msgid "Enables private notes on widget context settings."
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: widget-context.php:491
|
102 |
+
msgid ""
|
103 |
+
"No widget controls enabled. You can enable them in <a href=\"%s\">Widget "
|
104 |
+
"Context settings</a>."
|
105 |
+
msgstr ""
|
106 |
+
|
107 |
+
#: widget-context.php:500
|
108 |
+
msgid "No widget controls enabled."
|
109 |
+
msgstr ""
|
110 |
+
|
111 |
+
#: widget-context.php:512 widget-context.php:837 widget-context.php:898
|
112 |
+
msgid "Widget Context Settings"
|
113 |
+
msgstr ""
|
114 |
+
|
115 |
+
#: widget-context.php:533
|
116 |
+
msgid "Expand"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: widget-context.php:534
|
120 |
+
msgid "Collapse"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: widget-context.php:548
|
124 |
+
msgid "Show widget everywhere"
|
125 |
+
msgstr ""
|
126 |
+
|
127 |
+
#: widget-context.php:549
|
128 |
+
msgid "Show widget on selected"
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: widget-context.php:550
|
132 |
+
msgid "Hide widget on selected"
|
133 |
+
msgstr ""
|
134 |
+
|
135 |
+
#: widget-context.php:551
|
136 |
+
msgid "Hide widget everywhere"
|
137 |
+
msgstr ""
|
138 |
+
|
139 |
+
#: widget-context.php:562
|
140 |
+
msgid "Front page"
|
141 |
+
msgstr ""
|
142 |
+
|
143 |
+
#: widget-context.php:563
|
144 |
+
msgid "Blog page"
|
145 |
+
msgstr ""
|
146 |
+
|
147 |
+
#: widget-context.php:564
|
148 |
+
msgid "All posts, pages and custom post types"
|
149 |
+
msgstr ""
|
150 |
+
|
151 |
+
#: widget-context.php:565
|
152 |
+
msgid "All posts"
|
153 |
+
msgstr ""
|
154 |
+
|
155 |
+
#: widget-context.php:566
|
156 |
+
msgid "All pages"
|
157 |
+
msgstr ""
|
158 |
+
|
159 |
+
#: widget-context.php:567
|
160 |
+
msgid "All attachments"
|
161 |
+
msgstr ""
|
162 |
+
|
163 |
+
#: widget-context.php:568
|
164 |
+
msgid "Search results"
|
165 |
+
msgstr ""
|
166 |
+
|
167 |
+
#: widget-context.php:569
|
168 |
+
msgid "404 error page"
|
169 |
+
msgstr ""
|
170 |
+
|
171 |
+
#: widget-context.php:570
|
172 |
+
msgid "All archives"
|
173 |
+
msgstr ""
|
174 |
+
|
175 |
+
#: widget-context.php:571
|
176 |
+
msgid "All date archives"
|
177 |
+
msgstr ""
|
178 |
+
|
179 |
+
#: widget-context.php:572
|
180 |
+
msgid "Daily archives"
|
181 |
+
msgstr ""
|
182 |
+
|
183 |
+
#: widget-context.php:573
|
184 |
+
msgid "Monthly archives"
|
185 |
+
msgstr ""
|
186 |
+
|
187 |
+
#: widget-context.php:574
|
188 |
+
msgid "Yearly archives"
|
189 |
+
msgstr ""
|
190 |
+
|
191 |
+
#: widget-context.php:575
|
192 |
+
msgid "All category archives"
|
193 |
+
msgstr ""
|
194 |
+
|
195 |
+
#: widget-context.php:576
|
196 |
+
msgid "All tag archives"
|
197 |
+
msgstr ""
|
198 |
+
|
199 |
+
#: widget-context.php:577
|
200 |
+
msgid "All author archives"
|
201 |
+
msgstr ""
|
202 |
+
|
203 |
+
#: widget-context.php:594
|
204 |
+
msgid ""
|
205 |
+
"Enter one location fragment per line. Use <strong>*</strong> character as a "
|
206 |
+
"wildcard. Example: <code>category/peace/*</code> to target all posts in "
|
207 |
+
"category <em>peace</em>."
|
208 |
+
msgstr ""
|
209 |
+
|
210 |
+
#: widget-context.php:709
|
211 |
+
msgid "No options available"
|
212 |
+
msgstr ""
|
213 |
+
|
214 |
+
#: widget-context.php:915
|
215 |
+
msgid "Enabled Context Modules"
|
216 |
+
msgstr ""
|
217 |
+
|
218 |
+
#: widget-context.php:932
|
219 |
+
msgid "Widget Context is created and maintained by %s."
|
220 |
+
msgstr ""
|
221 |
+
|
222 |
+
#: widget-context.php:937
|
223 |
+
msgid "News & Updates"
|
224 |
+
msgstr ""
|
225 |
+
|
226 |
+
#: widget-context.php:938
|
227 |
+
msgid "Subscribe to receive news & updates about the plugin."
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: widget-context.php:941
|
231 |
+
msgid "Your Name"
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: widget-context.php:942
|
235 |
+
msgid "Your Email"
|
236 |
+
msgstr ""
|
237 |
+
|
238 |
+
#: widget-context.php:943
|
239 |
+
msgid "Subscribe"
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#. Plugin URI of the plugin/theme
|
243 |
+
msgid "http://wordpress.org/extend/plugins/widget-context/"
|
244 |
+
msgstr ""
|
245 |
+
|
246 |
+
#. Description of the plugin/theme
|
247 |
+
msgid ""
|
248 |
+
"Show or hide widgets depending on the section of the site that is being "
|
249 |
+
"viewed."
|
250 |
+
msgstr ""
|
251 |
+
|
252 |
+
#. Author of the plugin/theme
|
253 |
+
msgid "Kaspars Dambis"
|
254 |
+
msgstr ""
|
255 |
+
|
256 |
+
#. Author URI of the plugin/theme
|
257 |
+
msgid "http://kaspars.net"
|
258 |
+
msgstr ""
|
modules/custom-post-types-taxonomies/custom-cpt-tax.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Check for Widget Context plugin
|
4 |
+
if ( ! class_exists( 'widget_context' ) )
|
5 |
+
die;
|
6 |
+
|
7 |
+
|
8 |
+
// Go!
|
9 |
+
WidgetContextCustomCPTTax::instance();
|
10 |
+
|
11 |
+
|
12 |
+
class WidgetContextCustomCPTTax {
|
13 |
+
|
14 |
+
private static $instance;
|
15 |
+
private $wc;
|
16 |
+
public $post_types;
|
17 |
+
public $taxonomies;
|
18 |
+
|
19 |
+
|
20 |
+
static function instance() {
|
21 |
+
|
22 |
+
if ( ! self::$instance )
|
23 |
+
self::$instance = new self();
|
24 |
+
|
25 |
+
return self::$instance;
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
private function __construct() {
|
31 |
+
|
32 |
+
$this->wc = widget_context::instance();
|
33 |
+
|
34 |
+
// This should run really late so that all post types get registered
|
35 |
+
add_action( 'init', array( $this, 'init' ), 987 );
|
36 |
+
|
37 |
+
add_filter( 'widget_contexts', array( $this, 'add_context' ) );
|
38 |
+
|
39 |
+
add_filter( 'widget_context_control-custom_post_types_taxonomies', array( $this, 'context_controls' ), 10, 2 );
|
40 |
+
|
41 |
+
add_filter( 'widget_context_check-custom_post_types_taxonomies', array( $this, 'context_check' ), 10, 2 );
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
function init() {
|
47 |
+
|
48 |
+
$this->post_types = get_post_types(
|
49 |
+
array(
|
50 |
+
'public' => true,
|
51 |
+
'_builtin' => false,
|
52 |
+
'publicly_queryable' => true
|
53 |
+
),
|
54 |
+
'objects'
|
55 |
+
);
|
56 |
+
|
57 |
+
$this->taxonomies = get_taxonomies(
|
58 |
+
array(
|
59 |
+
'public' => true,
|
60 |
+
'_builtin' => false
|
61 |
+
),
|
62 |
+
'objects'
|
63 |
+
);
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
function add_context( $contexts ) {
|
69 |
+
|
70 |
+
$contexts[ 'custom_post_types_taxonomies' ] = array(
|
71 |
+
'label' => __( 'Custom Post Types and Taxonomies', 'widget-context' ),
|
72 |
+
'description' => __( 'Context based custom post types and taxonomies', 'widget-context' ),
|
73 |
+
'weight' => 10
|
74 |
+
);
|
75 |
+
|
76 |
+
return $contexts;
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
function context_check( $check, $settings ) {
|
82 |
+
|
83 |
+
if ( empty( $settings ) )
|
84 |
+
return $check;
|
85 |
+
|
86 |
+
$status = array();
|
87 |
+
|
88 |
+
foreach ( $this->post_types as $post_type => $post_type_settings ) {
|
89 |
+
|
90 |
+
if ( isset( $settings[ 'is_singular-' . $post_type ] ) && $settings[ 'is_singular-' . $post_type ] )
|
91 |
+
$status[ 'is_singular-' . $post_type ] = is_singular( $post_type );
|
92 |
+
|
93 |
+
if ( isset( $settings[ 'is_archive-' . $post_type ] ) && $settings[ 'is_archive-' . $post_type ] )
|
94 |
+
$status[ 'is_archive-' . $post_type ] = is_post_type_archive( $post_type );
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
foreach ( $this->taxonomies as $taxonomy => $tax_settings ) {
|
99 |
+
|
100 |
+
if ( isset( $settings[ 'is_tax-' . $taxonomy ] ) && $settings[ 'is_tax-' . $taxonomy ] )
|
101 |
+
$status[ 'is_tax-' . $taxonomy ] = is_tax( $taxonomy );
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
$matched = array_intersect_assoc( $settings, $status );
|
106 |
+
|
107 |
+
if ( ! empty( $matched ) )
|
108 |
+
return true;
|
109 |
+
|
110 |
+
return $check;
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
|
115 |
+
function context_controls( $control_args ) {
|
116 |
+
|
117 |
+
$options = array();
|
118 |
+
$out = array();
|
119 |
+
|
120 |
+
foreach ( $this->post_types as $post_type => $post_type_settings ) {
|
121 |
+
|
122 |
+
$options[ 'is_singular-' . $post_type ] = sprintf(
|
123 |
+
__( 'All "%s" posts', 'widget-context' ),
|
124 |
+
$post_type_settings->label
|
125 |
+
);
|
126 |
+
|
127 |
+
if ( $post_type_settings->has_archive )
|
128 |
+
$options[ 'is_archive-' . $post_type ] = sprintf(
|
129 |
+
__( 'Archive of "%s" posts', 'widget-context' ),
|
130 |
+
$post_type_settings->label
|
131 |
+
);
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
foreach ( $this->taxonomies as $taxonomy => $tax_settings ) {
|
136 |
+
|
137 |
+
$options[ 'is_tax-' . $taxonomy ] = sprintf(
|
138 |
+
__( 'All "%s" taxonomy archives', 'widget-context' ),
|
139 |
+
$tax_settings->label
|
140 |
+
);
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
foreach ( $options as $option => $label )
|
145 |
+
$out[] = $this->wc->make_simple_checkbox( $control_args, $option, $label );
|
146 |
+
|
147 |
+
if ( ! empty( $out ) )
|
148 |
+
return implode( '', $out );
|
149 |
+
|
150 |
+
return sprintf( '%s', esc_html__( 'None.', 'widget-context' ) );
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
}
|
modules/word-count/word-count.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Check for Widget Context plugin
|
4 |
+
if ( ! class_exists( 'widget_context' ) )
|
5 |
+
die;
|
6 |
+
|
7 |
+
|
8 |
+
// Go!
|
9 |
+
WidgetContextWordCount::instance();
|
10 |
+
|
11 |
+
|
12 |
+
class WidgetContextWordCount {
|
13 |
+
|
14 |
+
private static $instance;
|
15 |
+
private $wc;
|
16 |
+
|
17 |
+
var $words_on_page = 0;
|
18 |
+
|
19 |
+
|
20 |
+
static function instance() {
|
21 |
+
|
22 |
+
if ( ! self::$instance )
|
23 |
+
self::$instance = new self();
|
24 |
+
|
25 |
+
return self::$instance;
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
private function __construct() {
|
31 |
+
|
32 |
+
$this->wc = widget_context::instance();
|
33 |
+
|
34 |
+
// Check the number of words on page
|
35 |
+
add_action( 'wp', array( $this, 'count_words_on_page' ) );
|
36 |
+
|
37 |
+
// Define our context
|
38 |
+
add_filter( 'widget_contexts', array( $this, 'add_word_count_context' ) );
|
39 |
+
|
40 |
+
add_filter( 'widget_context_control-word_count', array( $this, 'control_word_count' ), 10, 2 );
|
41 |
+
add_filter( 'widget_context_check-word_count', array( $this, 'context_check_word_count' ), 10, 2 );
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
function add_word_count_context( $contexts ) {
|
47 |
+
|
48 |
+
$contexts[ 'word_count' ] = array(
|
49 |
+
'label' => __( 'Word Count', 'widget-context' ),
|
50 |
+
'description' => __( 'Context based on word count on the page.', 'widget-context' ),
|
51 |
+
'weight' => 15
|
52 |
+
);
|
53 |
+
|
54 |
+
return $contexts;
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
function count_words_on_page() {
|
60 |
+
|
61 |
+
global $wp_query;
|
62 |
+
|
63 |
+
if ( empty( $wp_query->posts ) || is_admin() )
|
64 |
+
return;
|
65 |
+
|
66 |
+
foreach ( $wp_query->posts as $post_data )
|
67 |
+
$this->words_on_page += str_word_count( strip_tags( strip_shortcodes( $post_data->post_content ) ) );
|
68 |
+
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
function context_check_word_count( $check, $settings ) {
|
73 |
+
|
74 |
+
$settings = wp_parse_args( $settings, array(
|
75 |
+
'check_wordcount' => false,
|
76 |
+
'word_count' => null,
|
77 |
+
'check_wordcount_type' => null
|
78 |
+
) );
|
79 |
+
|
80 |
+
// Make sure this context check was enabled
|
81 |
+
if ( ! $settings['check_wordcount'] )
|
82 |
+
return $check;
|
83 |
+
|
84 |
+
$word_count = (int) $settings['word_count'];
|
85 |
+
|
86 |
+
// No word count specified, bail out
|
87 |
+
if ( ! $word_count )
|
88 |
+
return $check;
|
89 |
+
|
90 |
+
if ( $settings['check_wordcount_type'] == 'less' && $this->words_on_page < $word_count )
|
91 |
+
return true;
|
92 |
+
elseif ( $settings['check_wordcount_type'] == 'more' && $this->words_on_page > $word_count )
|
93 |
+
return true;
|
94 |
+
|
95 |
+
return $check;
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
function control_word_count( $control_args ) {
|
101 |
+
|
102 |
+
return sprintf(
|
103 |
+
'<p>%s %s %s</p>',
|
104 |
+
$this->wc->make_simple_checkbox( $control_args, 'check_wordcount', __('Has') ),
|
105 |
+
$this->wc->make_simple_dropdown( $control_args, 'check_wordcount_type', array( 'less' => __('less'), 'more' => __('more') ), null, __('than') ),
|
106 |
+
$this->wc->make_simple_textfield( $control_args, 'word_count', null, __('words') )
|
107 |
+
);
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
}
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
=== Widget Context ===
|
2 |
-
|
3 |
-
|
4 |
-
Tags: widget, widget context, context, logic, widget logic, cms
|
5 |
-
Requires at least: 3.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 0
|
8 |
-
License: GPLv2 or later
|
9 |
|
10 |
Show or hide widgets on specific posts, pages or sections of your site.
|
11 |
|
@@ -17,7 +17,7 @@ Widget Context allows you to show or hide widgets on certain sections of your si
|
|
17 |
|
18 |
= Get Involved: =
|
19 |
|
20 |
-
* News and updates on [
|
21 |
* Development and pull requests [on GitHub](https://github.com/kasparsd/widget-context-wporg),
|
22 |
* Bug reports and suggestions on [WordPress.org forums](http://wordpress.org/support/plugin/widget-context).
|
23 |
|
@@ -30,27 +30,36 @@ Widget Context allows you to show or hide widgets on certain sections of your si
|
|
30 |
|
31 |
== Changelog ==
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
* Fix PHP warning that occurred on PHP 5.2.x.
|
36 |
|
37 |
-
|
38 |
|
39 |
* Improved SSL/HTTPS detection.
|
40 |
* Fix: Ensure that is_active_sidebar() & is_dynamic_sidebar() don't return true when there are no widgets displayed on a page.
|
41 |
* Two new filters so that other plugins can override widget context display/visibility logic.
|
42 |
|
43 |
-
|
44 |
|
45 |
* Revert back to changing callback function in `$wp_registered_widgets` for attaching widget context setting controls.
|
46 |
* Fix the word count logic.
|
47 |
|
48 |
-
|
49 |
|
50 |
* Major code rewrite and refactoring to improve performance and usability.
|
51 |
* Fix bugs with URL targeting and empty lines in the "Target by URL" textarea.
|
52 |
|
53 |
-
|
54 |
|
55 |
* Fix PHP warnings/notices. Props to [James Collins](http://om4.com.au/).
|
56 |
|
@@ -85,26 +94,36 @@ Widget Context allows you to show or hide widgets on certain sections of your si
|
|
85 |
|
86 |
== Upgrade Notice ==
|
87 |
|
|
|
|
|
|
|
|
|
88 |
= 0.8.1 =
|
|
|
89 |
(1) Revert to a legacy method for attaching widget control settings in order to make it work with old plugins. (2) Fix the word count context logic.
|
90 |
|
91 |
= 0.8 =
|
|
|
92 |
Major code rewrite and refactoring to improve plugin performance and usability.
|
93 |
|
94 |
= 0.7.2 =
|
|
|
95 |
Fix PHP warnings/notices.
|
96 |
|
97 |
= 0.7.1 =
|
|
|
98 |
Confirm that plugin works with the latest version of WordPress.
|
99 |
|
100 |
= 0.7 =
|
|
|
101 |
Bug fix: check for active sidebars only after $paged has been set.
|
102 |
|
103 |
= 0.6 =
|
|
|
104 |
Performance improvements - don't check if sidebar has any widgets on every widget load.
|
105 |
|
106 |
|
107 |
-
== Screenshots ==
|
108 |
|
109 |
1. Widget Context settings at the bottom of every widget
|
110 |
|
1 |
=== Widget Context ===
|
2 |
+
|
3 |
+
Contributors: kasparsd, jamescollins
|
4 |
+
Tags: widget, widget context, context, logic, widget logic, cms
|
5 |
+
Requires at least: 3.0
|
6 |
+
Tested up to: 3.9.1
|
7 |
+
Stable tag: 1.0
|
8 |
+
License: GPLv2 or later
|
9 |
|
10 |
Show or hide widgets on specific posts, pages or sections of your site.
|
11 |
|
17 |
|
18 |
= Get Involved: =
|
19 |
|
20 |
+
* News and updates on [kaspars.net](http://kaspars.net/blog),
|
21 |
* Development and pull requests [on GitHub](https://github.com/kasparsd/widget-context-wporg),
|
22 |
* Bug reports and suggestions on [WordPress.org forums](http://wordpress.org/support/plugin/widget-context).
|
23 |
|
30 |
|
31 |
== Changelog ==
|
32 |
|
33 |
+
= 1.0 =
|
34 |
+
* Public release of the 1.0 refactoring.
|
35 |
+
|
36 |
+
= 1.0-beta =
|
37 |
+
* Improved settings page.
|
38 |
+
|
39 |
+
= 1.0-alpha =
|
40 |
+
* Refactor code to allow custom widget context modules.
|
41 |
+
|
42 |
+
= 0.8.3 =
|
43 |
|
44 |
* Fix PHP warning that occurred on PHP 5.2.x.
|
45 |
|
46 |
+
= 0.8.2 =
|
47 |
|
48 |
* Improved SSL/HTTPS detection.
|
49 |
* Fix: Ensure that is_active_sidebar() & is_dynamic_sidebar() don't return true when there are no widgets displayed on a page.
|
50 |
* Two new filters so that other plugins can override widget context display/visibility logic.
|
51 |
|
52 |
+
= 0.8.1 =
|
53 |
|
54 |
* Revert back to changing callback function in `$wp_registered_widgets` for attaching widget context setting controls.
|
55 |
* Fix the word count logic.
|
56 |
|
57 |
+
= 0.8 =
|
58 |
|
59 |
* Major code rewrite and refactoring to improve performance and usability.
|
60 |
* Fix bugs with URL targeting and empty lines in the "Target by URL" textarea.
|
61 |
|
62 |
+
= 0.7.2 =
|
63 |
|
64 |
* Fix PHP warnings/notices. Props to [James Collins](http://om4.com.au/).
|
65 |
|
94 |
|
95 |
== Upgrade Notice ==
|
96 |
|
97 |
+
= 1.0 =
|
98 |
+
|
99 |
+
New modular architecture and settings page. Please make sure you test this version before deploying to a production website.
|
100 |
+
|
101 |
= 0.8.1 =
|
102 |
+
|
103 |
(1) Revert to a legacy method for attaching widget control settings in order to make it work with old plugins. (2) Fix the word count context logic.
|
104 |
|
105 |
= 0.8 =
|
106 |
+
|
107 |
Major code rewrite and refactoring to improve plugin performance and usability.
|
108 |
|
109 |
= 0.7.2 =
|
110 |
+
|
111 |
Fix PHP warnings/notices.
|
112 |
|
113 |
= 0.7.1 =
|
114 |
+
|
115 |
Confirm that plugin works with the latest version of WordPress.
|
116 |
|
117 |
= 0.7 =
|
118 |
+
|
119 |
Bug fix: check for active sidebars only after $paged has been set.
|
120 |
|
121 |
= 0.6 =
|
122 |
+
|
123 |
Performance improvements - don't check if sidebar has any widgets on every widget load.
|
124 |
|
125 |
|
126 |
+
== Screenshots ==
|
127 |
|
128 |
1. Widget Context settings at the bottom of every widget
|
129 |
|
widget-context.php
CHANGED
@@ -1,392 +1,763 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Widget Context
|
4 |
-
Plugin URI: http://wordpress.org/plugins/widget-context/
|
5 |
-
Description:
|
6 |
-
Version: 0
|
7 |
Author: Kaspars Dambis
|
8 |
-
Author URI: http://
|
9 |
-
|
10 |
-
For changelog see readme.txt
|
11 |
-
----------------------------
|
12 |
-
|
13 |
-
Copyright 2009 Kaspars Dambis (email: kaspars@konstruktors.com)
|
14 |
-
|
15 |
-
This program is free software; you can redistribute it and/or modify
|
16 |
-
it under the terms of the GNU General Public License as published by
|
17 |
-
the Free Software Foundation; either version 2 of the License, or
|
18 |
-
(at your option) any later version.
|
19 |
-
This program is distributed in the hope that it will be useful,
|
20 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
-
GNU General Public License for more details.
|
23 |
-
You should have received a copy of the GNU General Public License
|
24 |
-
along with this program; if not, write to the Free Software
|
25 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
// Go!
|
29 |
-
|
30 |
|
31 |
class widget_context {
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
function widget_context() {
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
//
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
// Add admin menu for config
|
47 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
|
|
|
|
|
|
|
|
48 |
// Save widget context settings, when in admin area
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
|
55 |
-
function
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
if ( ! is_array( $this->context_options ) || empty( $this->context_options ) )
|
59 |
-
$this->context_options = array();
|
60 |
}
|
61 |
|
62 |
|
63 |
function admin_scripts() {
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
|
68 |
function save_widget_context_settings() {
|
69 |
-
|
|
|
70 |
return;
|
71 |
|
72 |
-
// Delete
|
73 |
-
if ( isset( $_POST['delete_widget'] ) && $_POST['
|
74 |
-
unset( $this->context_options[ $_POST['widget-id'] ] );
|
75 |
|
76 |
// Add / Update
|
77 |
$this->context_options = array_merge( $this->context_options, $_POST['wl'] );
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
update_option( $this->options_name, $this->context_options );
|
|
|
80 |
}
|
81 |
-
|
82 |
-
|
83 |
-
function attach_widget_context_controls() {
|
84 |
-
global $wp_registered_widget_controls, $wp_registered_widgets;
|
85 |
-
|
86 |
-
foreach ($wp_registered_widgets as $widget_id => $widget_data) {
|
87 |
-
// Pass widget id as param, so that we can later call the original callback function
|
88 |
-
$wp_registered_widget_controls[$widget_id]['params'][]['widget_id'] = $widget_id;
|
89 |
-
// Store the original callback functions and replace them with Widget Context
|
90 |
-
$wp_registered_widget_controls[$widget_id]['callback_original_wc'] = $wp_registered_widget_controls[$widget_id]['callback'];
|
91 |
-
$wp_registered_widget_controls[$widget_id]['callback'] = array($this, 'replace_widget_control_callback');
|
92 |
-
}
|
93 |
-
}
|
94 |
|
95 |
|
96 |
-
function
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
continue;
|
100 |
-
|
101 |
foreach( $widget_list as $pos => $widget_id ) {
|
|
|
102 |
if ( ! $this->check_widget_visibility( $widget_id ) )
|
103 |
-
unset( $sidebars_widgets[$widget_area][$pos] );
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
|
|
|
|
|
|
106 |
return $sidebars_widgets;
|
|
|
107 |
}
|
108 |
|
109 |
|
110 |
-
function
|
111 |
-
|
112 |
-
|
113 |
-
$
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
return
|
139 |
-
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
}
|
142 |
|
143 |
|
144 |
// Thanks to Drupal: http://api.drupal.org/api/function/drupal_match_path/6
|
145 |
-
function match_path( $
|
|
|
|
|
|
|
146 |
$patterns_safe = array();
|
147 |
|
148 |
-
//
|
149 |
-
$
|
|
|
|
|
|
|
|
|
150 |
|
151 |
foreach ( explode( "\n", $patterns ) as $pattern )
|
152 |
-
$patterns_safe[] = trim( trim( $pattern ), '/' );
|
|
|
|
|
|
|
153 |
|
154 |
$regexps = '/^('. preg_replace( array( '/(\r\n|\n| )+/', '/\\\\\*/' ), array( '|', '.*' ), preg_quote( implode( "\n", array_filter( $patterns_safe, 'trim' ) ), '/' ) ) .')$/';
|
155 |
|
156 |
-
|
157 |
-
//echo $regexps;
|
158 |
-
//print_r(array_filter( $patterns_safe, 'trim' ));
|
159 |
|
160 |
-
return preg_match( $regexps, $path );
|
161 |
}
|
162 |
-
|
163 |
-
|
164 |
-
function count_words_on_page() {
|
165 |
-
global $wp_query;
|
166 |
-
|
167 |
-
if ( empty( $wp_query->posts ) || is_admin() )
|
168 |
-
return;
|
169 |
|
170 |
-
foreach ( $wp_query->posts as $post_data )
|
171 |
-
$this->words_on_page += str_word_count( strip_tags( strip_shortcodes( $post_data->post_content ) ) );
|
172 |
-
}
|
173 |
|
174 |
-
|
175 |
-
function
|
176 |
-
// Show widget because no context settings found
|
177 |
-
if ( ! isset( $this->context_options[ $widget_id ] ) )
|
178 |
-
return true;
|
179 |
-
|
180 |
-
$vis_settings = $this->context_options[ $widget_id ];
|
181 |
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
if (
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
if (
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
-
// Check for selected pages/sections
|
218 |
-
if ( array_intersect_key( $currently, $vis_settings['location'] ) )
|
219 |
-
$do_show_by_select = true;
|
220 |
-
|
221 |
-
// Word count
|
222 |
-
if ( isset( $vis_settings['location']['check_wordcount'] ) ) {
|
223 |
-
// Check for word count
|
224 |
-
$word_count_to_check = intval( $vis_settings['location']['word_count'] );
|
225 |
-
$check_type = $vis_settings['location']['check_wordcount_type'];
|
226 |
-
|
227 |
-
if ( $this->words_on_page > $word_count_to_check && $check_type == 'more' )
|
228 |
-
$do_show_by_word_count = true;
|
229 |
-
elseif ( $this->words_on_page < $word_count_to_check && $check_type == 'less' )
|
230 |
-
$do_show_by_word_count = true;
|
231 |
-
else
|
232 |
-
$do_show_by_word_count = false;
|
233 |
-
}
|
234 |
}
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
$
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
$do_show = true;
|
245 |
-
} elseif (($vis_settings['incexc'] == 'notselected') && !$one_is_true) {
|
246 |
-
// Hide on selected
|
247 |
-
$do_show = true;
|
248 |
-
} elseif (!empty($vis_settings['incexc'])) {
|
249 |
-
$do_show = false;
|
250 |
-
} else {
|
251 |
-
$do_show = true;
|
252 |
}
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
}
|
259 |
-
|
260 |
-
|
261 |
-
function
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_home' ), __('Blog Index') )
|
272 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_single' ), __('All Posts') )
|
273 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_page' ), __('All Pages') )
|
274 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_attachment' ), __('All Attachments') )
|
275 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_search' ), __('Search') )
|
276 |
-
. '</p></div>'
|
277 |
-
. '<div class="wl-column-2-2"><p>'
|
278 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_archive' ), __('All Archives') )
|
279 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_category' ), __('Category Archive') )
|
280 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_tag' ), __('Tag Archive') )
|
281 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_author' ), __('Author Archive') )
|
282 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'is_404' ), __('404 Error') )
|
283 |
-
. '</p></div>'
|
284 |
-
|
285 |
-
. '<div class="wl-word-count"><p>'
|
286 |
-
. $this->make_simple_checkbox( array( $wid, 'location', 'check_wordcount' ), __('Has') )
|
287 |
-
. $this->make_simple_dropdown( array( $wid, 'location', 'check_wordcount_type' ), array('less' => __('less'), 'more' => __('more')), '', __('than') )
|
288 |
-
. $this->make_simple_textfield( array( $wid, 'location', 'word_count' ), __('words') )
|
289 |
-
. '</p></div>'
|
290 |
-
. '</div>'
|
291 |
-
|
292 |
-
. '<div class="wl-options">'
|
293 |
-
. $this->make_simple_textarea( array( $wid, 'url', 'urls' ), __('or target by URL'), __('Enter one location fragment per line. Use <strong>*</strong> character as a wildcard. Example: <code>category/peace/*</code> to target all posts in category <em>peace</em>.') )
|
294 |
-
. '</div>'
|
295 |
-
|
296 |
-
. $this->make_simple_textarea( array( $wid, 'general', 'notes' ), __('Notes (invisible to public)'))
|
297 |
-
. '</div></div>';
|
298 |
|
299 |
}
|
|
|
300 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
*/
|
307 |
|
308 |
|
309 |
-
function make_simple_checkbox( $
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
);
|
|
|
317 |
}
|
318 |
|
319 |
|
320 |
-
function make_simple_textarea( $
|
321 |
-
|
322 |
-
|
|
|
|
|
|
|
323 |
|
324 |
return sprintf(
|
325 |
-
'<
|
326 |
-
<
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
$
|
335 |
-
|
336 |
-
$
|
337 |
);
|
|
|
338 |
}
|
339 |
|
340 |
|
341 |
-
function make_simple_textfield( $
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
return sprintf(
|
343 |
-
'<label class="
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
$label_before,
|
346 |
-
|
347 |
-
|
348 |
-
$
|
|
|
|
|
|
|
349 |
);
|
|
|
350 |
}
|
351 |
|
352 |
|
353 |
-
function make_simple_dropdown( $
|
354 |
-
|
355 |
$options = array();
|
356 |
|
|
|
|
|
|
|
|
|
|
|
357 |
if ( empty( $selection ) )
|
358 |
-
$options[] = sprintf(
|
|
|
|
|
|
|
359 |
|
360 |
foreach ( $selection as $sid => $svalue )
|
361 |
-
$options[] = sprintf(
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
return sprintf(
|
364 |
-
'<label class="
|
365 |
%s
|
366 |
-
<select name="
|
367 |
%s
|
368 |
</select>
|
369 |
%s
|
370 |
</label>',
|
371 |
-
$this->get_field_classname( $
|
|
|
|
|
372 |
$label_before,
|
373 |
-
|
374 |
-
|
|
|
|
|
|
|
375 |
$label_after
|
376 |
);
|
|
|
377 |
}
|
378 |
|
|
|
379 |
/**
|
380 |
* Returns [part1][part2][partN] from array( 'part1', 'part2', 'part3' )
|
381 |
* @param array $parts i.e. array( 'part1', 'part2', 'part3' )
|
382 |
* @return string i.e. [part1][part2][partN]
|
383 |
*/
|
384 |
function get_field_name( $parts ) {
|
|
|
385 |
return esc_attr( sprintf( '[%s]', implode( '][', $parts ) ) );
|
|
|
386 |
}
|
387 |
|
388 |
-
function get_field_classname( $
|
389 |
-
|
|
|
|
|
|
|
|
|
|
|
390 |
}
|
391 |
|
392 |
|
@@ -396,23 +767,193 @@ class widget_context {
|
|
396 |
* @param array $options i.e. array( 'part1' => array( 'part2' => array( 'part3' => 'VALUE' ) ) )
|
397 |
* @return string Returns option value
|
398 |
*/
|
399 |
-
function get_field_value( $parts, $options =
|
400 |
-
|
|
|
401 |
$options = $this->context_options;
|
402 |
|
403 |
-
|
404 |
-
$part = array_shift( $parts );
|
405 |
|
406 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
407 |
$value = $this->get_field_value( $parts, $options[ $part ] );
|
408 |
elseif ( isset( $options[ $part ] ) )
|
409 |
-
|
410 |
-
|
411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
|
413 |
-
return trim( $value );
|
414 |
}
|
415 |
|
416 |
|
417 |
}
|
418 |
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Widget Context
|
4 |
+
Plugin URI: http://wordpress.org/extend/plugins/widget-context/
|
5 |
+
Description: Show or hide widgets depending on the section of the site that is being viewed.
|
6 |
+
Version: 1.0
|
7 |
Author: Kaspars Dambis
|
8 |
+
Author URI: http://kaspars.net
|
9 |
+
Text Domain: widget-context
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
// Go!
|
13 |
+
widget_context::instance();
|
14 |
|
15 |
class widget_context {
|
16 |
|
17 |
+
private static $instance;
|
18 |
+
private $sidebars_widgets;
|
19 |
+
private $options_name = 'widget_logic_options'; // Context settings for widgets (visibility, etc)
|
20 |
+
private $settings_name = 'widget_context_settings'; // Widget Context global settings
|
21 |
+
|
22 |
+
private $core_modules = array(
|
23 |
+
'word-count/word-count.php',
|
24 |
+
'custom-post-types-taxonomies/custom-cpt-tax.php'
|
25 |
+
);
|
26 |
+
|
27 |
+
var $context_options = array(); // Store visibility settings
|
28 |
+
var $context_settings = array(); // Store admin settings
|
29 |
+
var $contexts = array();
|
30 |
+
var $plugin_path;
|
31 |
+
|
32 |
|
33 |
+
static function instance() {
|
34 |
+
|
35 |
+
if ( ! self::$instance )
|
36 |
+
self::$instance = new self();
|
37 |
+
|
38 |
+
return self::$instance;
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
|
43 |
+
private function widget_context() {
|
44 |
+
|
45 |
+
// Define available widget contexts
|
46 |
+
add_action( 'init', array( $this, 'define_widget_contexts' ), 5 );
|
47 |
+
|
48 |
+
// Load plugin settings and show/hide widgets by altering the
|
49 |
+
// $sidebars_widgets global variable
|
50 |
+
add_action( 'init', array( $this, 'init_widget_context' ) );
|
51 |
+
|
52 |
+
// Enable localization
|
53 |
+
add_action( 'plugins_loaded', array( $this, 'init_l10n' ) );
|
54 |
+
|
55 |
+
// Append Widget Context settings to widget controls
|
56 |
+
add_action( 'in_widget_form', array( $this, 'widget_context_controls' ), 10, 3 );
|
57 |
+
|
58 |
// Add admin menu for config
|
59 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
60 |
+
|
61 |
+
// Style things based on admin color scheme
|
62 |
+
add_action( 'admin_footer', array( $this, 'admin_styles_inline' ) );
|
63 |
+
|
64 |
// Save widget context settings, when in admin area
|
65 |
+
add_action( 'sidebar_admin_setup', array( $this, 'save_widget_context_settings' ) );
|
66 |
+
|
67 |
+
// Fix legacy context option naming
|
68 |
+
add_filter( 'widget_context_options', array( $this, 'fix_legacy_options' ) );
|
69 |
+
|
70 |
+
// Register admin settings menu
|
71 |
+
add_action( 'admin_menu', array( $this, 'widget_context_settings_menu' ) );
|
72 |
+
|
73 |
+
// Register admin settings
|
74 |
+
add_action( 'admin_init', array( $this, 'widget_context_settings_init' ) );
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
function define_widget_contexts() {
|
80 |
+
|
81 |
+
// Initialize core modules
|
82 |
+
$include_path = plugin_dir_path( __FILE__ ) . '/modules';
|
83 |
+
|
84 |
+
foreach ( $this->core_modules as $module ) {
|
85 |
+
include sprintf( '%s/%s', $include_path, $module );
|
86 |
+
}
|
87 |
+
|
88 |
+
// Default context
|
89 |
+
$default_contexts = array(
|
90 |
+
'incexc' => array(
|
91 |
+
'label' => __( 'Widget Context', 'widget-context' ),
|
92 |
+
'description' => __( 'Set the default logic to show or hide.', 'widget-context' ),
|
93 |
+
'weight' => -100,
|
94 |
+
'type' => 'core',
|
95 |
+
),
|
96 |
+
'location' => array(
|
97 |
+
'label' => __( 'Global Sections', 'widget-context' ),
|
98 |
+
'description' => __( 'Based on standard WordPress template tags.', 'widget-context' ),
|
99 |
+
'weight' => 10
|
100 |
+
),
|
101 |
+
'url' => array(
|
102 |
+
'label' => __( 'Target by URL', 'widget-context' ),
|
103 |
+
'description' => __( 'Based on URL patterns.', 'widget-context' ),
|
104 |
+
'weight' => 20
|
105 |
+
),
|
106 |
+
'admin_notes' => array(
|
107 |
+
'label' => __( 'Notes (invisible to public)', 'widget-context' ),
|
108 |
+
'description' => __( 'Enables private notes on widget context settings.'),
|
109 |
+
'weight' => 90
|
110 |
+
)
|
111 |
+
);
|
112 |
+
|
113 |
+
// Add default context controls and checks
|
114 |
+
foreach ( $default_contexts as $context_name => $context_desc ) {
|
115 |
+
|
116 |
+
add_filter( 'widget_context_control-' . $context_name, array( $this, 'control_' . $context_name ), 10, 2 );
|
117 |
+
add_filter( 'widget_context_check-' . $context_name, array( $this, 'context_check_' . $context_name ), 10, 2 );
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
// Enable other plugins and themes to specify their own contexts
|
122 |
+
$this->contexts = apply_filters( 'widget_contexts', $default_contexts );
|
123 |
+
|
124 |
+
// Sort contexts by their weight
|
125 |
+
uasort( $this->contexts, array( $this, 'sort_context_by_weight' ) );
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
function sort_context_by_weight( $a, $b ) {
|
131 |
+
|
132 |
+
if ( ! isset( $a['weight'] ) )
|
133 |
+
$a['weight'] = 10;
|
134 |
+
|
135 |
+
if ( ! isset( $b['weight'] ) )
|
136 |
+
$b['weight'] = 10;
|
137 |
+
|
138 |
+
return ( $a['weight'] < $b['weight'] ) ? -1 : 1;
|
139 |
+
|
140 |
}
|
141 |
|
142 |
|
143 |
+
function init_widget_context() {
|
144 |
+
|
145 |
+
$this->context_options = apply_filters(
|
146 |
+
'widget_context_options',
|
147 |
+
(array) get_option( $this->options_name, array() )
|
148 |
+
);
|
149 |
+
|
150 |
+
$this->context_settings = wp_parse_args(
|
151 |
+
(array) get_option( $this->settings_name, array() ),
|
152 |
+
array(
|
153 |
+
'contexts' => array()
|
154 |
+
)
|
155 |
+
);
|
156 |
+
|
157 |
+
// Hide/show widgets for is_active_sidebar() to work
|
158 |
+
add_filter( 'sidebars_widgets', array( $this, 'maybe_unset_widgets_by_context' ), 10 );
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
function init_l10n() {
|
164 |
+
|
165 |
+
load_plugin_textdomain( 'widget-context', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
166 |
|
|
|
|
|
167 |
}
|
168 |
|
169 |
|
170 |
function admin_scripts() {
|
171 |
+
|
172 |
+
wp_enqueue_style(
|
173 |
+
'widget-context-css',
|
174 |
+
plugins_url( 'css/admin.css', plugin_basename( __FILE__ ) )
|
175 |
+
);
|
176 |
+
|
177 |
+
wp_enqueue_script(
|
178 |
+
'widget-context-js',
|
179 |
+
plugins_url( 'js/widget-context.js', plugin_basename( __FILE__ ) ),
|
180 |
+
array( 'jquery' )
|
181 |
+
);
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
|
186 |
+
function admin_styles_inline() {
|
187 |
+
|
188 |
+
global $_wp_admin_css_colors;
|
189 |
+
|
190 |
+
$color_scheme = get_user_option( 'admin_color' );
|
191 |
+
|
192 |
+
if ( isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
|
193 |
+
|
194 |
+
printf(
|
195 |
+
'<style type="text/css">
|
196 |
+
.widget-context .widget-context-header h3:before { color:%1$s; }
|
197 |
+
</style>',
|
198 |
+
$_wp_admin_css_colors[ $color_scheme ]->colors[3]
|
199 |
+
);
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
function widget_context_controls( $object, $return, $instance ) {
|
207 |
+
|
208 |
+
echo $this->display_widget_context( $object->id );
|
209 |
+
|
210 |
}
|
211 |
|
212 |
|
213 |
function save_widget_context_settings() {
|
214 |
+
|
215 |
+
if ( ! current_user_can( 'edit_theme_options' ) || empty( $_POST ) || ! isset( $_POST['wl'] ) )
|
216 |
return;
|
217 |
|
218 |
+
// Delete a widget
|
219 |
+
if ( isset( $_POST['delete_widget'] ) && isset( $_POST['the-widget-id'] ) )
|
220 |
+
unset( $this->context_options[ $_POST['the-widget-id'] ] );
|
221 |
|
222 |
// Add / Update
|
223 |
$this->context_options = array_merge( $this->context_options, $_POST['wl'] );
|
224 |
|
225 |
+
$sidebars_widgets = wp_get_sidebars_widgets();
|
226 |
+
$all_widget_ids = array();
|
227 |
+
|
228 |
+
// Get a lits of all widget IDs
|
229 |
+
foreach ( $sidebars_widgets as $widget_area => $widgets )
|
230 |
+
foreach ( $widgets as $widget_order => $widget_id )
|
231 |
+
$all_widget_ids[] = $widget_id;
|
232 |
+
|
233 |
+
// Remove non-existant widget contexts from the settings
|
234 |
+
foreach ( $this->context_options as $widget_id => $widget_context )
|
235 |
+
if ( ! in_array( $widget_id, $all_widget_ids ) )
|
236 |
+
unset( $this->context_options[ $widget_id ] );
|
237 |
+
|
238 |
update_option( $this->options_name, $this->context_options );
|
239 |
+
|
240 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
|
243 |
+
function maybe_unset_widgets_by_context( $sidebars_widgets ) {
|
244 |
+
|
245 |
+
// Don't run this on the backend
|
246 |
+
if ( is_admin() )
|
247 |
+
return $sidebars_widgets;
|
248 |
+
|
249 |
+
// Return from cache if we have done the context checks already
|
250 |
+
if ( ! empty( $this->sidebars_widgets ) )
|
251 |
+
return $this->sidebars_widgets;
|
252 |
+
|
253 |
+
foreach( $sidebars_widgets as $widget_area => $widget_list ) {
|
254 |
+
|
255 |
+
if ( $widget_area == 'wp_inactive_widgets' || empty( $widget_list ) )
|
256 |
continue;
|
257 |
+
|
258 |
foreach( $widget_list as $pos => $widget_id ) {
|
259 |
+
|
260 |
if ( ! $this->check_widget_visibility( $widget_id ) )
|
261 |
+
unset( $sidebars_widgets[ $widget_area ][ $pos ] );
|
262 |
+
|
263 |
}
|
264 |
+
|
265 |
}
|
266 |
+
|
267 |
+
// Store in class cache
|
268 |
+
$this->sidebars_widgets = $sidebars_widgets;
|
269 |
+
|
270 |
return $sidebars_widgets;
|
271 |
+
|
272 |
}
|
273 |
|
274 |
|
275 |
+
function check_widget_visibility( $widget_id ) {
|
276 |
+
|
277 |
+
// Check if this widget even has context set
|
278 |
+
if ( ! isset( $this->context_options[ $widget_id ] ) )
|
279 |
+
return true;
|
280 |
+
|
281 |
+
$matches = array();
|
282 |
+
|
283 |
+
foreach ( $this->contexts as $context_id => $context_settings ) {
|
284 |
+
|
285 |
+
// This context check has been disabled in the plugin settings
|
286 |
+
if ( isset( $this->context_settings['contexts'][ $context_id ] ) && ! $this->context_settings['contexts'][ $context_id ] )
|
287 |
+
continue;
|
288 |
+
|
289 |
+
// Make sure that context settings for this widget are defined
|
290 |
+
if ( ! isset( $this->context_options[ $widget_id ][ $context_id ] ) )
|
291 |
+
$widget_context_args = array();
|
292 |
+
else
|
293 |
+
$widget_context_args = $this->context_options[ $widget_id ][ $context_id ];
|
294 |
+
|
295 |
+
$matches[ $context_id ] = apply_filters(
|
296 |
+
'widget_context_check-' . $context_id,
|
297 |
+
null,
|
298 |
+
$widget_context_args
|
299 |
+
);
|
300 |
+
|
301 |
}
|
302 |
+
|
303 |
+
// Get the match rule for this widget (show/hide/selected/notselected)
|
304 |
+
$match_rule = $this->context_options[ $widget_id ][ 'incexc' ][ 'condition' ];
|
305 |
+
|
306 |
+
// Force show or hide the widget!
|
307 |
+
if ( $match_rule == 'show' )
|
308 |
+
return true;
|
309 |
+
elseif ( $match_rule == 'hide' )
|
310 |
+
return false;
|
311 |
+
|
312 |
+
if ( $match_rule == 'selected' )
|
313 |
+
$inc = true;
|
314 |
+
else
|
315 |
+
$inc = false;
|
316 |
+
|
317 |
+
if ( $inc && in_array( true, $matches ) )
|
318 |
+
return true;
|
319 |
+
elseif ( ! $inc && ! in_array( true, $matches ) )
|
320 |
+
return true;
|
321 |
+
else
|
322 |
+
return false;
|
323 |
+
|
324 |
}
|
325 |
+
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Default context checks
|
329 |
+
*/
|
330 |
+
|
331 |
+
function context_check_incexc( $check, $settings ) {
|
332 |
+
|
333 |
+
return $check;
|
334 |
+
|
335 |
+
}
|
336 |
+
|
337 |
+
|
338 |
+
function context_check_location( $check, $settings ) {
|
339 |
+
|
340 |
+
$status = array(
|
341 |
+
'is_front_page' => is_front_page(),
|
342 |
+
'is_home' => is_home(),
|
343 |
+
'is_singular' => is_singular(),
|
344 |
+
'is_single' => is_singular( 'post' ),
|
345 |
+
'is_page' => ( is_page() && ! is_front_page() ),
|
346 |
+
'is_attachment' => is_attachment(),
|
347 |
+
'is_search' => is_search(),
|
348 |
+
'is_404' => is_404(),
|
349 |
+
'is_archive' => is_archive(),
|
350 |
+
'is_date' => is_date(),
|
351 |
+
'is_day' => is_day(),
|
352 |
+
'is_month' => is_month(),
|
353 |
+
'is_year' => is_year(),
|
354 |
+
'is_category' => is_category(),
|
355 |
+
'is_tag' => is_tag(),
|
356 |
+
'is_author' => is_author()
|
357 |
+
);
|
358 |
+
|
359 |
+
$matched = array_intersect_assoc( $settings, $status );
|
360 |
+
|
361 |
+
if ( ! empty( $matched ) )
|
362 |
+
return true;
|
363 |
+
|
364 |
+
return $check;
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
function context_check_url( $check, $settings ) {
|
370 |
+
|
371 |
+
$urls = trim( $settings['urls'] );
|
372 |
+
|
373 |
+
if ( empty( $urls ) )
|
374 |
+
return $check;
|
375 |
+
|
376 |
+
if ( $this->match_path( $urls ) )
|
377 |
+
return true;
|
378 |
+
|
379 |
+
return $check;
|
380 |
+
|
381 |
}
|
382 |
|
383 |
|
384 |
// Thanks to Drupal: http://api.drupal.org/api/function/drupal_match_path/6
|
385 |
+
function match_path( $patterns ) {
|
386 |
+
|
387 |
+
global $wp;
|
388 |
+
|
389 |
$patterns_safe = array();
|
390 |
|
391 |
+
// Get the request URI from WP
|
392 |
+
$url_request = $wp->request;
|
393 |
+
|
394 |
+
// Append the query string
|
395 |
+
if ( ! empty( $_SERVER['QUERY_STRING'] ) )
|
396 |
+
$url_request .= '?' . $_SERVER['QUERY_STRING'];
|
397 |
|
398 |
foreach ( explode( "\n", $patterns ) as $pattern )
|
399 |
+
$patterns_safe[] = trim( trim( $pattern ), '/' ); // Trim trailing and leading slashes
|
400 |
+
|
401 |
+
// Remove empty URL patterns
|
402 |
+
$patterns_safe = array_filter( $patterns_safe );
|
403 |
|
404 |
$regexps = '/^('. preg_replace( array( '/(\r\n|\n| )+/', '/\\\\\*/' ), array( '|', '.*' ), preg_quote( implode( "\n", array_filter( $patterns_safe, 'trim' ) ), '/' ) ) .')$/';
|
405 |
|
406 |
+
return preg_match( $regexps, $url_request );
|
|
|
|
|
407 |
|
|
|
408 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
|
|
|
|
|
|
|
410 |
|
411 |
+
// Dummy function
|
412 |
+
function context_check_admin_notes( $check, $widget_id ) {}
|
|
|
|
|
|
|
|
|
|
|
413 |
|
414 |
+
|
415 |
+
// Dummy function
|
416 |
+
function context_check_general( $check, $widget_id ) {}
|
417 |
+
|
418 |
+
|
419 |
+
/*
|
420 |
+
Widget Controls
|
421 |
+
*/
|
422 |
+
|
423 |
+
function display_widget_context( $widget_id = null ) {
|
424 |
+
|
425 |
+
$controls = array();
|
426 |
+
$controls_disabled = array();
|
427 |
+
$controls_core = array();
|
428 |
+
|
429 |
+
foreach ( $this->contexts as $context_name => $context_settings ) {
|
430 |
+
|
431 |
+
$context_classes = array(
|
432 |
+
'context-group',
|
433 |
+
sprintf( 'context-group-%s', esc_attr( $context_name ) )
|
434 |
+
);
|
435 |
+
|
436 |
+
// Hide this context from the admin UX. We can't remove them
|
437 |
+
// because settings will get lost if this page is submitted.
|
438 |
+
if ( isset( $this->context_settings['contexts'][ $context_name ] ) && ! $this->context_settings['contexts'][ $context_name ] ) {
|
439 |
+
$context_classes[] = 'context-inactive';
|
440 |
+
$controls_disabled[] = $context_name;
|
441 |
+
}
|
442 |
+
|
443 |
+
// Store core controls
|
444 |
+
if ( isset( $context_settings['type'] ) && 'core' == $context_settings['type'] ) {
|
445 |
+
$controls_core[] = $context_name;
|
446 |
+
}
|
447 |
+
|
448 |
+
$control_args = array(
|
449 |
+
'name' => $context_name,
|
450 |
+
'input_prefix' => 'wl' . $this->get_field_name( array( $widget_id, $context_name ) ),
|
451 |
+
'settings' => $this->get_field_value( array( $widget_id, $context_name ) ),
|
452 |
+
'widget_id' => $widget_id
|
453 |
+
);
|
454 |
+
|
455 |
+
$context_controls = apply_filters( 'widget_context_control-' . $context_name, $control_args );
|
456 |
+
$context_classes = apply_filters( 'widget_context_classes-' . $context_name, $context_classes, $control_args );
|
457 |
+
|
458 |
+
if ( ! empty( $context_controls ) && is_string( $context_controls ) ) {
|
459 |
+
|
460 |
+
$controls[ $context_name ] = sprintf(
|
461 |
+
'<div class="%s">
|
462 |
+
<h4 class="context-toggle">%s</h4>
|
463 |
+
<div class="context-group-wrap">
|
464 |
+
%s
|
465 |
+
</div>
|
466 |
+
</div>',
|
467 |
+
esc_attr( implode( ' ', $context_classes ) ),
|
468 |
+
esc_html( $context_settings['label'] ),
|
469 |
+
$context_controls
|
470 |
+
);
|
471 |
+
|
472 |
+
}
|
473 |
+
|
474 |
+
}
|
475 |
+
|
476 |
+
|
477 |
+
|
478 |
+
// Non-core controls that should be visible if enabled
|
479 |
+
$controls_not_core = array_diff( array_keys( $controls ), $controls_core );
|
480 |
+
|
481 |
+
// Check if any non-core context controls have been enabled
|
482 |
+
$has_controls = array_diff( $controls_not_core, $controls_disabled );
|
483 |
+
|
484 |
+
if ( empty( $controls ) || empty( $has_controls ) ) {
|
485 |
+
|
486 |
+
if ( current_user_can( 'edit_theme_options' ) ) {
|
487 |
+
|
488 |
+
$controls = array( sprintf(
|
489 |
+
'<p class="error">%s</p>',
|
490 |
+
sprintf(
|
491 |
+
__( 'No widget controls enabled. You can enable them in <a href="%s">Widget Context settings</a>.', 'widget-context' ),
|
492 |
+
admin_url( 'options-general.php?page=widget_context_settings' )
|
493 |
+
)
|
494 |
+
) );
|
495 |
+
|
496 |
+
} else {
|
497 |
+
|
498 |
+
$controls = array( sprintf(
|
499 |
+
'<p class="error">%s</p>',
|
500 |
+
__( 'No widget controls enabled.', 'widget-context' )
|
501 |
+
) );
|
502 |
+
|
503 |
+
}
|
504 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
}
|
506 |
+
|
507 |
+
if ( current_user_can( 'edit_theme_options' ) ) {
|
508 |
+
|
509 |
+
$controls[] = sprintf(
|
510 |
+
'<p class="widget-context-settings-link"><a href="%s">%s</a></p>',
|
511 |
+
admin_url( 'options-general.php?page=widget_context_settings' ),
|
512 |
+
__( 'Widget Context Settings', 'widget-context' )
|
513 |
+
);
|
514 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
}
|
516 |
|
517 |
+
return sprintf(
|
518 |
+
'<div class="widget-context">
|
519 |
+
<div class="widget-context-header">
|
520 |
+
<h3>%s</h3>
|
521 |
+
<!-- <a href="#widget-context-%s" class="toggle-contexts hide-if-no-js">
|
522 |
+
<span class="expand">%s</span>
|
523 |
+
<span class="collapse">%s</span>
|
524 |
+
</a> -->
|
525 |
+
</div>
|
526 |
+
<div class="widget-context-inside" id="widget-context-%s" data-widget-id="%s">
|
527 |
+
%s
|
528 |
+
</div>
|
529 |
+
</div>',
|
530 |
+
__( 'Widget Context', 'widget-context' ),
|
531 |
+
esc_attr( $widget_id ),
|
532 |
+
// Toggle buttons
|
533 |
+
__( 'Expand', 'widget-context' ),
|
534 |
+
__( 'Collapse', 'widget-context' ),
|
535 |
+
// Inslide classes
|
536 |
+
esc_attr( $widget_id ),
|
537 |
+
esc_attr( $widget_id ),
|
538 |
+
// Controls
|
539 |
+
implode( '', $controls )
|
540 |
+
);
|
541 |
+
|
542 |
}
|
543 |
+
|
544 |
+
|
545 |
+
function control_incexc( $control_args ) {
|
546 |
+
|
547 |
+
$options = array(
|
548 |
+
'show' => __( 'Show widget everywhere', 'widget-context' ),
|
549 |
+
'selected' => __( 'Show widget on selected', 'widget-context' ),
|
550 |
+
'notselected' => __( 'Hide widget on selected', 'widget-context' ),
|
551 |
+
'hide' => __( 'Hide widget everywhere', 'widget-context' )
|
552 |
+
);
|
553 |
+
|
554 |
+
return $this->make_simple_dropdown( $control_args, 'condition', $options );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
|
556 |
}
|
557 |
+
|
558 |
|
559 |
+
function control_location( $control_args ) {
|
560 |
+
|
561 |
+
$options = array(
|
562 |
+
'is_front_page' => __( 'Front page', 'widget-context' ),
|
563 |
+
'is_home' => __( 'Blog page', 'widget-context' ),
|
564 |
+
'is_singular' => __( 'All posts, pages and custom post types', 'widget-context' ),
|
565 |
+
'is_single' => __( 'All posts', 'widget-context' ),
|
566 |
+
'is_page' => __( 'All pages', 'widget-context' ),
|
567 |
+
'is_attachment' => __( 'All attachments', 'widget-context' ),
|
568 |
+
'is_search' => __( 'Search results', 'widget-context' ),
|
569 |
+
'is_404' => __( '404 error page', 'widget-context' ),
|
570 |
+
'is_archive' => __( 'All archives', 'widget-context' ),
|
571 |
+
'is_date' => __( 'All date archives', 'widget-context' ),
|
572 |
+
'is_day' => __( 'Daily archives', 'widget-context' ),
|
573 |
+
'is_month' => __( 'Monthly archives', 'widget-context' ),
|
574 |
+
'is_year' => __( 'Yearly archives', 'widget-context' ),
|
575 |
+
'is_category' => __( 'All category archives', 'widget-context' ),
|
576 |
+
'is_tag' => __( 'All tag archives', 'widget-context' ),
|
577 |
+
'is_author' => __( 'All author archives', 'widget-context' )
|
578 |
+
);
|
579 |
+
|
580 |
+
foreach ( $options as $option => $label )
|
581 |
+
$out[] = $this->make_simple_checkbox( $control_args, $option, $label );
|
582 |
+
|
583 |
+
return implode( '', $out );
|
584 |
+
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
function control_url( $control_args ) {
|
589 |
+
|
590 |
+
return sprintf(
|
591 |
+
'<div>%s</div>
|
592 |
+
<p class="help">%s</p>',
|
593 |
+
$this->make_simple_textarea( $control_args, 'urls' ),
|
594 |
+
__( 'Enter one location fragment per line. Use <strong>*</strong> character as a wildcard. Example: <code>category/peace/*</code> to target all posts in category <em>peace</em>.', 'widget-context' )
|
595 |
+
);
|
596 |
+
|
597 |
+
}
|
598 |
+
|
599 |
+
|
600 |
+
function control_admin_notes( $control_args ) {
|
601 |
+
|
602 |
+
return sprintf(
|
603 |
+
'<div>%s</div>',
|
604 |
+
$this->make_simple_textarea( $control_args, 'notes' )
|
605 |
+
);
|
606 |
+
|
607 |
+
}
|
608 |
+
|
609 |
|
610 |
+
|
611 |
+
/**
|
612 |
+
* Widget control helpers
|
613 |
+
*/
|
|
|
614 |
|
615 |
|
616 |
+
function make_simple_checkbox( $control_args, $option, $label ) {
|
617 |
+
|
618 |
+
if ( isset( $control_args['settings'][ $option ] ) && $control_args['settings'][ $option ] )
|
619 |
+
$value = true;
|
620 |
+
else
|
621 |
+
$value = false;
|
622 |
+
|
623 |
+
return sprintf(
|
624 |
+
'<label class="wc-field-checkbox-%s" data-widget-id="%s">
|
625 |
+
<input type="hidden" value="0" name="%s[%s]" />
|
626 |
+
<input type="checkbox" value="1" name="%s[%s]" %s /> %s
|
627 |
+
</label>',
|
628 |
+
$this->get_field_classname( $option ),
|
629 |
+
esc_attr( $control_args['widget_id'] ),
|
630 |
+
// Input hidden
|
631 |
+
$control_args['input_prefix'],
|
632 |
+
esc_attr( $option ),
|
633 |
+
// Input value
|
634 |
+
$control_args['input_prefix'],
|
635 |
+
esc_attr( $option ),
|
636 |
+
checked( $value, true, false ),
|
637 |
+
// Label
|
638 |
+
esc_html( $label )
|
639 |
);
|
640 |
+
|
641 |
}
|
642 |
|
643 |
|
644 |
+
function make_simple_textarea( $control_args, $option, $label = null ) {
|
645 |
+
|
646 |
+
if ( isset( $control_args['settings'][ $option ] ) )
|
647 |
+
$value = esc_textarea( $control_args['settings'][ $option ] );
|
648 |
+
else
|
649 |
+
$value = '';
|
650 |
|
651 |
return sprintf(
|
652 |
+
'<label class="wc-field-textarea-%s" data-widget-id="%s">
|
653 |
+
<strong>%s</strong>
|
654 |
+
<textarea name="%s[%s]">%s</textarea>
|
655 |
+
</label>',
|
656 |
+
$this->get_field_classname( $option ),
|
657 |
+
esc_attr( $control_args['widget_id'] ),
|
658 |
+
// Label
|
659 |
+
esc_html( $label ),
|
660 |
+
// Input
|
661 |
+
$control_args['input_prefix'],
|
662 |
+
$option,
|
663 |
+
$value
|
664 |
);
|
665 |
+
|
666 |
}
|
667 |
|
668 |
|
669 |
+
function make_simple_textfield( $control_args, $option, $label_before = null, $label_after = null) {
|
670 |
+
|
671 |
+
if ( isset( $control_args['settings'][ $option ] ) )
|
672 |
+
$value = esc_attr( $control_args['settings'][ $option ] );
|
673 |
+
else
|
674 |
+
$value = false;
|
675 |
+
|
676 |
return sprintf(
|
677 |
+
'<label class="wc-field-text-%s" data-widget-id="%s">
|
678 |
+
%s
|
679 |
+
<input type="text" name="%s[%s]" value="%s" />
|
680 |
+
%s
|
681 |
+
</label>',
|
682 |
+
$this->get_field_classname( $option ),
|
683 |
+
esc_attr( $control_args['widget_id'] ),
|
684 |
+
// Before
|
685 |
$label_before,
|
686 |
+
// Input
|
687 |
+
$control_args['input_prefix'],
|
688 |
+
$option,
|
689 |
+
esc_attr( $value ),
|
690 |
+
// After
|
691 |
+
esc_html( $label_after )
|
692 |
);
|
693 |
+
|
694 |
}
|
695 |
|
696 |
|
697 |
+
function make_simple_dropdown( $control_args, $option, $selection = array(), $label_before = null, $label_after = null ) {
|
698 |
+
|
699 |
$options = array();
|
700 |
|
701 |
+
if ( isset( $control_args['settings'][ $option ] ) )
|
702 |
+
$value = $control_args['settings'][ $option ];
|
703 |
+
else
|
704 |
+
$value = false;
|
705 |
+
|
706 |
if ( empty( $selection ) )
|
707 |
+
$options[] = sprintf(
|
708 |
+
'<option value="">%s</option>',
|
709 |
+
esc_html__( 'No options available', 'widget-context' )
|
710 |
+
);
|
711 |
|
712 |
foreach ( $selection as $sid => $svalue )
|
713 |
+
$options[] = sprintf(
|
714 |
+
'<option value="%s" %s>%s</option>',
|
715 |
+
esc_attr( $sid ),
|
716 |
+
selected( $value, $sid, false ),
|
717 |
+
esc_html( $svalue )
|
718 |
+
);
|
719 |
|
720 |
return sprintf(
|
721 |
+
'<label class="wc-field-select-%s" data-widget-id="%s">
|
722 |
%s
|
723 |
+
<select name="%s[%s]">
|
724 |
%s
|
725 |
</select>
|
726 |
%s
|
727 |
</label>',
|
728 |
+
$this->get_field_classname( $option ),
|
729 |
+
esc_attr( $control_args['widget_id'] ),
|
730 |
+
// Before
|
731 |
$label_before,
|
732 |
+
// Input
|
733 |
+
$control_args['input_prefix'],
|
734 |
+
$option,
|
735 |
+
implode( '', $options ),
|
736 |
+
// After
|
737 |
$label_after
|
738 |
);
|
739 |
+
|
740 |
}
|
741 |
|
742 |
+
|
743 |
/**
|
744 |
* Returns [part1][part2][partN] from array( 'part1', 'part2', 'part3' )
|
745 |
* @param array $parts i.e. array( 'part1', 'part2', 'part3' )
|
746 |
* @return string i.e. [part1][part2][partN]
|
747 |
*/
|
748 |
function get_field_name( $parts ) {
|
749 |
+
|
750 |
return esc_attr( sprintf( '[%s]', implode( '][', $parts ) ) );
|
751 |
+
|
752 |
}
|
753 |
|
754 |
+
function get_field_classname( $name ) {
|
755 |
+
|
756 |
+
if ( is_array( $name ) )
|
757 |
+
$name = end( $name );
|
758 |
+
|
759 |
+
return sanitize_html_class( str_replace( '_', '-', $name ) );
|
760 |
+
|
761 |
}
|
762 |
|
763 |
|
767 |
* @param array $options i.e. array( 'part1' => array( 'part2' => array( 'part3' => 'VALUE' ) ) )
|
768 |
* @return string Returns option value
|
769 |
*/
|
770 |
+
function get_field_value( $parts, $options = null ) {
|
771 |
+
|
772 |
+
if ( $options == null )
|
773 |
$options = $this->context_options;
|
774 |
|
775 |
+
$value = false;
|
|
|
776 |
|
777 |
+
if ( empty( $parts ) || ! is_array( $parts ) )
|
778 |
+
return false;
|
779 |
+
|
780 |
+
$part = array_shift( $parts );
|
781 |
+
|
782 |
+
if ( ! empty( $parts ) && isset( $options[ $part ] ) && is_array( $options[ $part ] ) )
|
783 |
$value = $this->get_field_value( $parts, $options[ $part ] );
|
784 |
elseif ( isset( $options[ $part ] ) )
|
785 |
+
return $options[ $part ];
|
786 |
+
|
787 |
+
return $value;
|
788 |
+
|
789 |
+
}
|
790 |
+
|
791 |
+
|
792 |
+
function fix_legacy_options( $options ) {
|
793 |
+
|
794 |
+
if ( empty( $options ) || ! is_array( $options ) )
|
795 |
+
return $options;
|
796 |
+
|
797 |
+
foreach ( $options as $widget_id => $option ) {
|
798 |
+
|
799 |
+
// This doesn't have an include/exclude rule defined
|
800 |
+
if ( ! isset( $option['incexc'] ) )
|
801 |
+
unset( $options[ $widget_id ] );
|
802 |
+
|
803 |
+
// We moved from [incexc] = 1/0 to [incexc][condition] = 1/0
|
804 |
+
if ( isset( $option['incexc'] ) && ! is_array( $option['incexc'] ) )
|
805 |
+
$options[ $widget_id ]['incexc'] = array( 'condition' => $option['incexc'] );
|
806 |
+
|
807 |
+
// Move notes from "general" group to "admin_notes"
|
808 |
+
if ( isset( $option['general']['notes'] ) ) {
|
809 |
+
$options[ $widget_id ]['admin_notes']['notes'] = $option['general']['notes'];
|
810 |
+
unset( $option['general']['notes'] );
|
811 |
+
}
|
812 |
+
|
813 |
+
// We moved word count out of location context group
|
814 |
+
if ( isset( $option['location']['check_wordcount'] ) )
|
815 |
+
$options[ $widget_id ]['word_count'] = array(
|
816 |
+
'check_wordcount' => true,
|
817 |
+
'check_wordcount_type' => $option['location']['check_wordcount_type'],
|
818 |
+
'word_count' => $option['location']['word_count']
|
819 |
+
);
|
820 |
+
|
821 |
+
}
|
822 |
+
|
823 |
+
return $options;
|
824 |
+
|
825 |
+
}
|
826 |
+
|
827 |
+
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Admin Settings
|
831 |
+
*/
|
832 |
+
|
833 |
+
|
834 |
+
function widget_context_settings_menu() {
|
835 |
+
|
836 |
+
add_options_page(
|
837 |
+
__( 'Widget Context Settings', 'widget-context' ),
|
838 |
+
__( 'Widget Context', 'widget-context' ),
|
839 |
+
'manage_options',
|
840 |
+
$this->settings_name,
|
841 |
+
array( $this, 'widget_context_admin_view' )
|
842 |
+
);
|
843 |
+
|
844 |
+
}
|
845 |
+
|
846 |
+
|
847 |
+
function widget_context_settings_init() {
|
848 |
+
|
849 |
+
register_setting( $this->settings_name, $this->settings_name );
|
850 |
+
|
851 |
+
}
|
852 |
+
|
853 |
+
|
854 |
+
function widget_context_admin_view() {
|
855 |
+
|
856 |
+
$context_controls = array();
|
857 |
+
|
858 |
+
foreach ( $this->contexts as $context_id => $context_args ) {
|
859 |
+
|
860 |
+
// Hide core modules from being disabled
|
861 |
+
if ( isset( $context_args['type'] ) && $context_args['type'] == 'core' )
|
862 |
+
continue;
|
863 |
+
|
864 |
+
if ( ! empty( $context_args['description'] ) )
|
865 |
+
$context_description = sprintf(
|
866 |
+
'<p class="context-desc">%s</p>',
|
867 |
+
esc_html( $context_args['description'] )
|
868 |
+
);
|
869 |
+
else
|
870 |
+
$context_description = null;
|
871 |
+
|
872 |
+
// Enable new modules by default
|
873 |
+
if ( ! isset( $this->context_settings['contexts'][ $context_id ] ) )
|
874 |
+
$this->context_settings['contexts'][ $context_id ] = 1;
|
875 |
+
|
876 |
+
$context_controls[] = sprintf(
|
877 |
+
'<li class="context-%s">
|
878 |
+
<label>
|
879 |
+
<input type="hidden" name="%s[contexts][%s]" value="0" />
|
880 |
+
<input type="checkbox" name="%s[contexts][%s]" value="1" %s /> %s
|
881 |
+
</label>
|
882 |
+
%s
|
883 |
+
</li>',
|
884 |
+
esc_attr( $context_id ),
|
885 |
+
$this->settings_name,
|
886 |
+
esc_attr( $context_id ),
|
887 |
+
$this->settings_name,
|
888 |
+
esc_attr( $context_id ),
|
889 |
+
checked( $this->context_settings['contexts'][ $context_id ], 1, false ),
|
890 |
+
esc_html( $context_args['label'] ),
|
891 |
+
$context_description
|
892 |
+
);
|
893 |
+
|
894 |
+
}
|
895 |
+
|
896 |
+
?>
|
897 |
+
<div class="wrap wrap-widget-context">
|
898 |
+
<h2><?php esc_html_e( 'Widget Context Settings', 'widget-context' ); ?></h2>
|
899 |
+
|
900 |
+
<div class="widget-context-settings-wrap">
|
901 |
+
|
902 |
+
<div class="widget-context-form">
|
903 |
+
<form method="post" action="options.php">
|
904 |
+
<?php
|
905 |
+
settings_fields( $this->settings_name );
|
906 |
+
do_settings_sections( $this->settings_name );
|
907 |
+
?>
|
908 |
+
|
909 |
+
<?php
|
910 |
+
printf(
|
911 |
+
'<div class="settings-section settings-section-modules">
|
912 |
+
<h3>%s</h3>
|
913 |
+
<ul>%s</ul>
|
914 |
+
</div>',
|
915 |
+
esc_html__( 'Enabled Context Modules', 'widget-context' ),
|
916 |
+
implode( '', $context_controls )
|
917 |
+
);
|
918 |
+
?>
|
919 |
+
|
920 |
+
<?php
|
921 |
+
submit_button();
|
922 |
+
?>
|
923 |
+
</form>
|
924 |
+
</div>
|
925 |
+
|
926 |
+
<div class="widget-context-sidebar">
|
927 |
+
<div class="wc-sidebar-in">
|
928 |
+
|
929 |
+
<div class="wc-sidebar-section wc-sidebar-credits">
|
930 |
+
<p>
|
931 |
+
<img src="http://gravatar.com/avatar/661eb21385c25c01ad64ab9e13b37331/?s=60" alt="Kaspars Dambis" width="60" height="60" />
|
932 |
+
<?php printf( esc_html__( 'Widget Context is created and maintained by %s.' ), '<a href="http://kaspars.net">Kaspars Dambis</a>' ); ?>
|
933 |
+
</p>
|
934 |
+
</div>
|
935 |
+
|
936 |
+
<div class="wc-sidebar-section wc-sidebar-newsletter">
|
937 |
+
<h3><?php esc_html_e( 'News & Updates' ); ?></h3>
|
938 |
+
<p><?php esc_html_e( 'Subscribe to receive news & updates about the plugin.' ); ?></p>
|
939 |
+
<form action="//osc.us2.list-manage.com/subscribe/post?u=e8d173fc54c0fc4286a2b52e8&id=8afe96c5a3" method="post" target="_blank">
|
940 |
+
<?php $user = wp_get_current_user(); ?>
|
941 |
+
<p><label><?php _e( 'Your Name', 'widget-context' ); ?>: <input type="text" name="NAME" value="<?php echo esc_attr( sprintf( '%s %s', $user->first_name, $user->last_name ) ) ?>" /></label></p>
|
942 |
+
<p><label><?php _e( 'Your Email', 'widget-context' ); ?>: <input type="text" name="EMAIL" value="<?php echo esc_attr( $user->user_email ); ?>" /></label></p>
|
943 |
+
<p><input class="button" name="subscribe" type="submit" value="<?php _e( 'Subscribe', 'widget-context' ); ?>" /></p>
|
944 |
+
</form>
|
945 |
+
</div>
|
946 |
+
|
947 |
+
</div>
|
948 |
+
</div>
|
949 |
+
|
950 |
+
</div>
|
951 |
+
</div>
|
952 |
+
<?php
|
953 |
|
|
|
954 |
}
|
955 |
|
956 |
|
957 |
}
|
958 |
|
959 |
+
|