Version Description
- Thanks to Brady Vercher (@bradyvercher) for the thorough code review and fixes.
- Cleanup code to better conform to WP Coding standards and remove legacy cruft.
- PHPCS configuration.
- Update docblock and comments.
- Remove legacy i18n code.
- Escaping output of URLs, translation strings, and more.
- Updated enqueueing to add version for cache busting, add missing jQuery dependency, load admin script in footer.
Download this release
Release Info
Developer | sewmyheadon |
Plugin | Posts in Page |
Version | 1.4.2 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.4.2
- admin/assets/css/post-page_styles.css +105 -105
- admin/assets/js/post-page_scripts.js +9 -9
- admin/views/help-main.php +330 -337
- includes/class-page-posts.php +398 -395
- index.php +0 -2
- languages/Posts-in-Page.pot +0 -214
- posts_in_page.php +142 -120
- readme.txt +66 -43
- templates/posts_loop_template.php +56 -25
admin/assets/css/post-page_styles.css
CHANGED
@@ -2,216 +2,216 @@
|
|
2 |
* Admin page styles
|
3 |
*/
|
4 |
.settings_page_posts_in_page th {
|
5 |
-
|
6 |
}
|
7 |
|
8 |
/* Clearfix */
|
9 |
.clearfix:before, .clearfix:after {
|
10 |
-
|
11 |
-
|
12 |
}
|
13 |
|
14 |
.clearfix:after {
|
15 |
-
|
16 |
}
|
17 |
|
18 |
.clearfix {
|
19 |
-
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
* Help & Support metabox styles
|
24 |
*/
|
25 |
#ivycat_contribute .dashicons {
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
}
|
30 |
|
31 |
#ivycat_contribute h4 {
|
32 |
-
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
* Connect with IvyCat metabox styles
|
37 |
*/
|
38 |
.ivycat-social {
|
39 |
-
|
40 |
-
|
41 |
}
|
42 |
|
43 |
.ivycat-social li {
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
}
|
50 |
|
51 |
.ivycat-social a {
|
52 |
-
|
53 |
}
|
54 |
|
55 |
.ivycat-social .dashicons {
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
}
|
60 |
|
61 |
/* MailChimp Form Embed Code - Slim - 08/17/2011 */
|
62 |
#mc_embed_signup form {
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
}
|
69 |
|
70 |
#mc_embed_signup h2 {
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
}
|
76 |
|
77 |
#mc_embed_signup input {
|
78 |
-
|
79 |
-
|
80 |
}
|
81 |
|
82 |
#mc_embed_signup input[type=checkbox] {
|
83 |
-
|
84 |
}
|
85 |
|
86 |
#mc_embed_signup input[type=radio] {
|
87 |
-
|
88 |
}
|
89 |
|
90 |
#mc_embed_signup input:focus {
|
91 |
-
|
92 |
}
|
93 |
|
94 |
#mc_embed_signup .button {
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
}
|
113 |
|
114 |
#mc_embed_signup .button:hover {
|
115 |
-
|
116 |
}
|
117 |
|
118 |
#mc_embed_signup .small-meta {
|
119 |
-
|
120 |
}
|
121 |
|
122 |
#mc_embed_signup .nowrap {
|
123 |
-
|
124 |
}
|
125 |
|
126 |
#mc_embed_signup label {
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
}
|
133 |
|
134 |
#mc_embed_signup input.email {
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
}
|
143 |
|
144 |
#mc_embed_signup input.button {
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
}
|
154 |
|
155 |
#mc_embed_signup div#mce-responses {
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
}
|
164 |
|
165 |
#mc_embed_signup div.response {
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
}
|
174 |
|
175 |
#mc_embed_signup #mce-error-response {
|
176 |
-
|
177 |
}
|
178 |
|
179 |
#mc_embed_signup #mce-success-response {
|
180 |
-
|
181 |
-
|
182 |
}
|
183 |
|
184 |
#mc_embed_signup label.error {
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
* Spread the Word styles & Support metabox styles
|
195 |
*/
|
196 |
.ivycat-rating {
|
197 |
-
|
198 |
-
|
199 |
}
|
200 |
|
201 |
.ivycat-rating .dashicons {
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
IvyCat metabox styles
|
209 |
*/
|
210 |
.signature .inside {
|
211 |
-
|
212 |
}
|
213 |
|
214 |
.signature img {
|
215 |
-
|
216 |
-
|
217 |
}
|
2 |
* Admin page styles
|
3 |
*/
|
4 |
.settings_page_posts_in_page th {
|
5 |
+
width: 33%
|
6 |
}
|
7 |
|
8 |
/* Clearfix */
|
9 |
.clearfix:before, .clearfix:after {
|
10 |
+
content: "";
|
11 |
+
display: table;
|
12 |
}
|
13 |
|
14 |
.clearfix:after {
|
15 |
+
clear: both;
|
16 |
}
|
17 |
|
18 |
.clearfix {
|
19 |
+
*zoom: 1;
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
* Help & Support metabox styles
|
24 |
*/
|
25 |
#ivycat_contribute .dashicons {
|
26 |
+
font-size: 48px;
|
27 |
+
margin-top: -.75em;
|
28 |
+
color: #f1f1f1;
|
29 |
}
|
30 |
|
31 |
#ivycat_contribute h4 {
|
32 |
+
margin-top: 0
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
* Connect with IvyCat metabox styles
|
37 |
*/
|
38 |
.ivycat-social {
|
39 |
+
margin: 0;
|
40 |
+
padding: 0;
|
41 |
}
|
42 |
|
43 |
.ivycat-social li {
|
44 |
+
float: left;
|
45 |
+
line-height: 1;
|
46 |
+
margin: 0 .6em;
|
47 |
+
padding: 0;
|
48 |
+
display: inline-block;
|
49 |
}
|
50 |
|
51 |
.ivycat-social a {
|
52 |
+
text-decoration: none;
|
53 |
}
|
54 |
|
55 |
.ivycat-social .dashicons {
|
56 |
+
font-size: 32px;
|
57 |
+
width: 32px;
|
58 |
+
height: 32px;
|
59 |
}
|
60 |
|
61 |
/* MailChimp Form Embed Code - Slim - 08/17/2011 */
|
62 |
#mc_embed_signup form {
|
63 |
+
display: block;
|
64 |
+
position: relative;
|
65 |
+
text-align: left;
|
66 |
+
padding: 10px 0 10px 0;
|
67 |
+
width: 250px;
|
68 |
}
|
69 |
|
70 |
#mc_embed_signup h2 {
|
71 |
+
font-weight: bold;
|
72 |
+
padding: 0;
|
73 |
+
margin: 15px 0;
|
74 |
+
font-size: 1.4em;
|
75 |
}
|
76 |
|
77 |
#mc_embed_signup input {
|
78 |
+
border: 1px solid #e5e5e5;
|
79 |
+
-webkit-appearance: none;
|
80 |
}
|
81 |
|
82 |
#mc_embed_signup input[type=checkbox] {
|
83 |
+
-webkit-appearance: checkbox;
|
84 |
}
|
85 |
|
86 |
#mc_embed_signup input[type=radio] {
|
87 |
+
-webkit-appearance: radio;
|
88 |
}
|
89 |
|
90 |
#mc_embed_signup input:focus {
|
91 |
+
border-color: #333;
|
92 |
}
|
93 |
|
94 |
#mc_embed_signup .button {
|
95 |
+
clear: both;
|
96 |
+
background-color: #aaa;
|
97 |
+
border: 0 none;
|
98 |
+
border-radius: 4px;
|
99 |
+
color: #FFF;
|
100 |
+
cursor: pointer;
|
101 |
+
display: inline-block;
|
102 |
+
font-size: 16px;
|
103 |
+
height: 34px;
|
104 |
+
line-height: 34px;
|
105 |
+
margin: 0 5px 10px 0;
|
106 |
+
padding: 0;
|
107 |
+
text-align: center;
|
108 |
+
text-decoration: none;
|
109 |
+
vertical-align: top;
|
110 |
+
white-space: nowrap;
|
111 |
+
width: auto;
|
112 |
}
|
113 |
|
114 |
#mc_embed_signup .button:hover {
|
115 |
+
background-color: #777;
|
116 |
}
|
117 |
|
118 |
#mc_embed_signup .small-meta {
|
119 |
+
font-size: 11px;
|
120 |
}
|
121 |
|
122 |
#mc_embed_signup .nowrap {
|
123 |
+
white-space: nowrap;
|
124 |
}
|
125 |
|
126 |
#mc_embed_signup label {
|
127 |
+
display: block;
|
128 |
+
font-size: 14px;
|
129 |
+
padding-bottom: 10px;
|
130 |
+
font-weight: bold;
|
131 |
+
color: #464646
|
132 |
}
|
133 |
|
134 |
#mc_embed_signup input.email {
|
135 |
+
display: block;
|
136 |
+
padding: 8px 0;
|
137 |
+
margin: 0 0 10px 0;
|
138 |
+
text-indent: 5px;
|
139 |
+
width: 62%;
|
140 |
+
min-width: 130px;
|
141 |
+
float: left;
|
142 |
}
|
143 |
|
144 |
#mc_embed_signup input.button {
|
145 |
+
display: block;
|
146 |
+
clear: none;
|
147 |
+
background: #628C29;
|
148 |
+
width: 35%;
|
149 |
+
margin: 0 0 10px 0;
|
150 |
+
min-width: 90px;
|
151 |
+
float: right;
|
152 |
+
text-shadow: 0 1px 0 #666;
|
153 |
}
|
154 |
|
155 |
#mc_embed_signup div#mce-responses {
|
156 |
+
float: left;
|
157 |
+
top: -1.4em;
|
158 |
+
padding: 0em .5em 0em .5em;
|
159 |
+
overflow: hidden;
|
160 |
+
width: 90%;
|
161 |
+
margin: 0 5%;
|
162 |
+
clear: both;
|
163 |
}
|
164 |
|
165 |
#mc_embed_signup div.response {
|
166 |
+
margin: 1em 0;
|
167 |
+
padding: 1em .5em .5em 0;
|
168 |
+
font-weight: bold;
|
169 |
+
float: left;
|
170 |
+
top: -1.5em;
|
171 |
+
z-index: 1;
|
172 |
+
width: 80%;
|
173 |
}
|
174 |
|
175 |
#mc_embed_signup #mce-error-response {
|
176 |
+
display: none;
|
177 |
}
|
178 |
|
179 |
#mc_embed_signup #mce-success-response {
|
180 |
+
color: #529214;
|
181 |
+
display: none;
|
182 |
}
|
183 |
|
184 |
#mc_embed_signup label.error {
|
185 |
+
display: block;
|
186 |
+
float: none;
|
187 |
+
width: auto;
|
188 |
+
margin-left: 1.05em;
|
189 |
+
text-align: left;
|
190 |
+
padding: .5em 0;
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
* Spread the Word styles & Support metabox styles
|
195 |
*/
|
196 |
.ivycat-rating {
|
197 |
+
display: inline;
|
198 |
+
color: #ffb900;
|
199 |
}
|
200 |
|
201 |
.ivycat-rating .dashicons {
|
202 |
+
width: 16px;
|
203 |
+
height: 16px;
|
204 |
+
font-size: 16px;
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
IvyCat metabox styles
|
209 |
*/
|
210 |
.signature .inside {
|
211 |
+
text-align: center;
|
212 |
}
|
213 |
|
214 |
.signature img {
|
215 |
+
margin-left: -.95em;
|
216 |
+
margin-right: .5em;
|
217 |
}
|
admin/assets/js/post-page_scripts.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
jQuery('document').ready(function ($) {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
});
|
1 |
jQuery('document').ready(function ($) {
|
2 |
+
$('#posts-in-page-settings .top-menu li a').click(function () {
|
3 |
+
var toshow = $(this).attr('href').replace('#', '');
|
4 |
+
$('.top-menu li').removeClass('current-menu-tab');
|
5 |
+
$(this).parent('li').addClass('current-menu-tab');
|
6 |
+
$('.group').hide().removeClass('current-tab');
|
7 |
+
$('.' + toshow).show().addClass('current-tab');
|
8 |
+
return false;
|
9 |
+
});
|
10 |
+
});
|
admin/views/help-main.php
CHANGED
@@ -2,345 +2,338 @@
|
|
2 |
/**
|
3 |
* Main admin help screen located at: Settings > Posts in Page.
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author
|
7 |
-
* @copyright
|
8 |
-
* @link
|
9 |
-
* @since
|
10 |
-
* @license
|
11 |
*/
|
|
|
12 |
?>
|
13 |
|
14 |
<div class="wrap">
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
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 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
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 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
</div>
|
340 |
-
<!-- #post-body .metabox-holder .columns-2 -->
|
341 |
-
|
342 |
-
<br class="clear">
|
343 |
-
</div>
|
344 |
-
<!-- #poststuff -->
|
345 |
-
|
346 |
-
</div> <!-- .wrap -->
|
2 |
/**
|
3 |
* Main admin help screen located at: Settings > Posts in Page.
|
4 |
*
|
5 |
+
* @package Posts_in_Page
|
6 |
+
* @author Eric Amundson <eric@ivycat.com>
|
7 |
+
* @copyright Copyright (c) 2019, IvyCat, Inc.
|
8 |
+
* @link https://ivycat.com
|
9 |
+
* @since 1.0.0
|
10 |
+
* @license GPL-2.0-or-later
|
11 |
*/
|
12 |
+
|
13 |
?>
|
14 |
|
15 |
<div class="wrap">
|
16 |
|
17 |
+
<div id="icon-options-general" class="icon32"></div>
|
18 |
+
<h1><?php esc_attr_e( 'Posts in Page', 'posts-in-page' ); ?></h1>
|
19 |
+
|
20 |
+
<div id="poststuff">
|
21 |
+
|
22 |
+
<div id="post-body" class="metabox-holder columns-2">
|
23 |
+
|
24 |
+
<!-- main content -->
|
25 |
+
<div id="post-body-content">
|
26 |
+
|
27 |
+
<div class="meta-box-sortables ui-sortable">
|
28 |
+
|
29 |
+
<div class="postbox">
|
30 |
+
|
31 |
+
<div class="handlediv" title="Click to toggle"><br></div>
|
32 |
+
<!-- Toggle -->
|
33 |
+
|
34 |
+
<h2 class="hndle">
|
35 |
+
<span><?php esc_attr_e( 'How to use Posts in Page', 'posts-in-page' ); ?></span>
|
36 |
+
</h2>
|
37 |
+
|
38 |
+
<div class="inside">
|
39 |
+
|
40 |
+
<p>To 'pull' posts into a page, you can either:</p>
|
41 |
+
|
42 |
+
<ol>
|
43 |
+
<li><a href="#place-a-shortcode-wordpress-editor">Place a shortcode in the WordPress
|
44 |
+
editor</a>, or
|
45 |
+
</li>
|
46 |
+
<li><a href="#embed-php-function-wordpress-editor">Embed a PHP function in a theme
|
47 |
+
template file</a></li>
|
48 |
+
</ol>
|
49 |
+
|
50 |
+
<h4 name="place-a-shortcode-wordpress-editor" id="place-a-shortcode-wordpress-editor">Place
|
51 |
+
a Shortcode in the WordPress Editor</h4>
|
52 |
+
|
53 |
+
<table class="widefat">
|
54 |
+
<thead>
|
55 |
+
<tr>
|
56 |
+
<th>Task</th>
|
57 |
+
<th>Shortcode</th>
|
58 |
+
<th>Notes</th>
|
59 |
+
</tr>
|
60 |
+
</thead>
|
61 |
+
<tfoot>
|
62 |
+
<tr>
|
63 |
+
<th>Task</th>
|
64 |
+
<th>Shortcode</th>
|
65 |
+
<th>Notes</th>
|
66 |
+
</tr>
|
67 |
+
</tfoot>
|
68 |
+
<tbody>
|
69 |
+
<tr>
|
70 |
+
<td>Add all posts</td>
|
71 |
+
<td><code>[ic_add_posts]</code></td>
|
72 |
+
<td><?php esc_html_e( 'Add all posts to a page (limit to what number posts in WordPress is set to), essentially adds blog "page" to page.', 'posts-in-page' ); ?></td>
|
73 |
+
</tr>
|
74 |
+
<tr>
|
75 |
+
<td>Show posts by Post Type</td>
|
76 |
+
<td><code>[ic_add_posts post_type='post_type']</code></td>
|
77 |
+
<td><?php esc_html_e( 'Show posts from a custom post type by specifying the post type slug ( must give post type if not a standard post ) add multiple post types by separating with commas (ex.', 'posts-in-page' ); ?>
|
78 |
+
<code>post_type='post_type1,post_type2'</code>)
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
+
<tr>
|
82 |
+
<td>Show specific number of posts</td>
|
83 |
+
<td><code>[ic_add_posts showposts='5']</code></td>
|
84 |
+
<td><?php esc_html_e( 'Limit number of posts (or override default setting)', 'posts-in-page' ); ?></td>
|
85 |
+
</tr>
|
86 |
+
<tr>
|
87 |
+
<td>Change post order</td>
|
88 |
+
<td><code>[ic_add_posts orderby='title' order='ASC']</code></td>
|
89 |
+
<td><?php esc_html_e( 'orderby title - supports all WP orderby variables. Order is optional, WP default', 'posts-in-page' ); ?></td>
|
90 |
+
</tr>
|
91 |
+
<tr>
|
92 |
+
<td>Show posts by ID</td>
|
93 |
+
<td><code>[ic_add_posts ids='1,2,3']</code></td>
|
94 |
+
<td><?php esc_html_e( 'Show one or many posts by specifying the post ID(s) ( specify all post types )', 'posts-in-page' ); ?></td>
|
95 |
+
</tr>
|
96 |
+
<tr>
|
97 |
+
<td>Exclude posts by ID</td>
|
98 |
+
<td><code>[ic_add_posts exclude_ids='4,5,6']</code></td>
|
99 |
+
<td><?php esc_html_e( 'Exclude one or more posts by specifying the post ID(s) ( specify all post types )', 'posts-in-page' ); ?></td>
|
100 |
+
</tr>
|
101 |
+
<tr>
|
102 |
+
<td>Include posts from specific categories</td>
|
103 |
+
<td><code>[ic_add_posts category='category-slug']</code></td>
|
104 |
+
<td><?php esc_html_e( 'Show posts within a specific category. Uses slugs, can have multiple but separate by commas. category-1,category2, etc (no spaces.)', 'posts-in-page' ); ?></td>
|
105 |
+
</tr>
|
106 |
+
<tr>
|
107 |
+
<td>Exclude posts from specific categories</td>
|
108 |
+
<td><code>[ic_add_posts exclude_category='category-slug']</code></td>
|
109 |
+
<td><?php esc_html_e( 'Show posts within a specific category. Uses slugs, can have multiple but separate by commas. category-1,category2, etc (no spaces.)', 'posts-in-page' ); ?></td>
|
110 |
+
</tr>
|
111 |
+
<tr>
|
112 |
+
<td>Specify tags</td>
|
113 |
+
<td><code>[ic_add_posts tag='tag-slug']</code></td>
|
114 |
+
<td><?php esc_html_e( 'Show posts using a specific tag. Like categories, it uses slugs, and can accommodate multiple tags separate by commas. tag-1,tag-2, etc (no spaces.)', 'posts-in-page' ); ?></td>
|
115 |
+
</tr>
|
116 |
+
<tr>
|
117 |
+
<td>Specify custom taxonomy</td>
|
118 |
+
<td><code>[ic_add_posts tax='taxonomy' term='term']</code></td>
|
119 |
+
<td><?php esc_html_e( 'Limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work', 'posts-in-page' ); ?></td>
|
120 |
+
</tr>
|
121 |
+
<tr>
|
122 |
+
<td>Change output template</td>
|
123 |
+
<td><code>[ic_add_posts template='template-in-theme-dir.php']</code></td>
|
124 |
+
<td><?php esc_html_e( 'In case you want to style your markup, add meta data, etc. Each shortcode can reference a different template. These templates must exist in the theme directory or in a subfolder named posts-in-page.', 'posts-in-page' ); ?></td>
|
125 |
+
</tr>
|
126 |
+
<tr>
|
127 |
+
<td>Sticky posts</td>
|
128 |
+
<td><code>[ic_add_posts ignore_sticky_posts='no']</code></td>
|
129 |
+
<td><?php esc_html_e( "Show sticky posts too (they're ignored by default)", 'posts-in-page' ); ?></td>
|
130 |
+
</tr>
|
131 |
+
<tr>
|
132 |
+
<td>Pagination</td>
|
133 |
+
<td><code>[ic_add_posts paginate='yes']</code></td>
|
134 |
+
<td><?php esc_html_e( 'use pagination links (off by default)', 'posts-in-page' ); ?></td>
|
135 |
+
</tr>
|
136 |
+
<tr>
|
137 |
+
<td>Pagination - Post navigation links</td>
|
138 |
+
<td><code>[ic_add_posts label_next='Next' label_previous='Previous']</code></td>
|
139 |
+
<td><?php esc_html_e( 'Change the post navigation labels', 'posts-in-page' ); ?></td>
|
140 |
+
</tr>
|
141 |
+
<tr>
|
142 |
+
<td>Post status</td>
|
143 |
+
<td><code>[ic_add_posts post_status='private']</code></td>
|
144 |
+
<td><?php esc_html_e( "Show posts with the specified status(es); the default is to only show posts with status 'publish'. To choose more than one status, separate them with commas. For example: <code>post_status='private,publish'</code>.", 'posts-in-page' ); ?></td>
|
145 |
+
</tr>
|
146 |
+
<tr>
|
147 |
+
<td>Post offset</td>
|
148 |
+
<td><code>[ic_add_posts offset='3']</code></td>
|
149 |
+
<td><?php esc_html_e( 'Displays posts after the offset. An offset=\'3\' will show all posts from the 4th one onward.', 'posts-in-page' ); ?></td>
|
150 |
+
</tr>
|
151 |
+
<tr>
|
152 |
+
<td>Specific Dates</td>
|
153 |
+
<td><code>[ic_add_posts date='today']</code></td>
|
154 |
+
<td><?php esc_html_e( "Shows posts associated (published) on specified date period, today, 'today-1' show's posts published yesterday, 'today-2' shows posts published two days ago, etc. Also 'week(-n)' shows posts n weeks ago. Also available 'month(-n)' and 'year(-n)'", 'posts-in-page' ); ?></td>
|
155 |
+
</tr>
|
156 |
+
<tr>
|
157 |
+
<td>Date Ranges</td>
|
158 |
+
<td><code>[ic_add_posts from_date='15-01-2016' to_date='31-12-2016']</code></td>
|
159 |
+
<td><?php esc_html_e( 'Shows posts published within a specified absolute date range', 'posts-in-page' ); ?></td>
|
160 |
+
</tr>
|
161 |
+
<tr>
|
162 |
+
<td>Read more</td>
|
163 |
+
<td><code>[ic_add_posts more_tag='Read more...']</code></td>
|
164 |
+
<td><?php esc_html_e( 'Set the link text for read more links shown after an excerpt', 'posts-in-page' ); ?></td>
|
165 |
+
</tr>
|
166 |
+
<tr>
|
167 |
+
<td>Custom error message</td>
|
168 |
+
<td><code>[ic_add_posts none_found='No Posts Found']</code></td>
|
169 |
+
<td><?php esc_html_e( 'Custom message to display if no posts are found', 'posts-in-page' ); ?></td>
|
170 |
+
</tr>
|
171 |
+
</tbody>
|
172 |
+
</table>
|
173 |
+
<p><?php esc_html_e( 'Or any combination of the above.', 'posts-in-page' ); ?></p>
|
174 |
+
|
175 |
+
<h4 name="embed-php-function-wordpress-editor"
|
176 |
+
id="embed-php-function-wordpress-editor"><?php esc_html_e( 'Embed a PHP function in a theme template file', 'posts-in-page' ); ?></h4>
|
177 |
+
|
178 |
+
<p><?php esc_html_e( 'If you\'d like to use this plugin to pull posts directly into your theme\'s template files, you can drop the following WordPress function in your template files, replacing the <code>[shortcode]</code> part with your, custom shortcode.', 'posts-in-page' ); ?></p>
|
179 |
+
|
180 |
+
<pre><code><?php echo do_shortcode("[shortcode]"); ?></code></pre>
|
181 |
+
</div>
|
182 |
+
<!-- .inside -->
|
183 |
+
|
184 |
+
</div>
|
185 |
+
<!-- .postbox -->
|
186 |
+
|
187 |
+
</div>
|
188 |
+
<!-- .meta-box-sortables .ui-sortable -->
|
189 |
+
|
190 |
+
</div>
|
191 |
+
<!-- post-body-content -->
|
192 |
+
|
193 |
+
<!-- sidebar -->
|
194 |
+
<div id="postbox-container-1" class="postbox-container">
|
195 |
+
|
196 |
+
<div class="meta-box-sortables">
|
197 |
+
|
198 |
+
<div class="postbox help-contributing">
|
199 |
+
|
200 |
+
<div class="handlediv" title="Click to toggle"><br></div>
|
201 |
+
<!-- Toggle -->
|
202 |
+
|
203 |
+
<h2><span><?php esc_attr_e( 'Help & Contributing', 'posts-in-page' ); ?></span></h2>
|
204 |
+
|
205 |
+
<div class="inside">
|
206 |
+
<div class="meta-box-sortables" style="min-height: 0">
|
207 |
+
<div id="ivycat_contribute">
|
208 |
+
<div class="inside_wrap">
|
209 |
+
<h4>Questions, bugs, or great ideas? <span
|
210 |
+
class="dashicons dashicons-format-status"></span></h4>
|
211 |
+
<ul>
|
212 |
+
<li><a href="https://wordpress.org/support/plugin/posts-in-page"> Get help
|
213 |
+
on our plugin support page</a> or
|
214 |
+
</li>
|
215 |
+
<li><a href="https://github.com/ivycat/posts-in-page/"> Report bugs and
|
216 |
+
contribute on Github</a></li>
|
217 |
+
</div>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
</div>
|
221 |
+
<!-- .inside -->
|
222 |
+
|
223 |
+
</div>
|
224 |
+
<!-- .postbox -->
|
225 |
+
<div class="postbox">
|
226 |
+
|
227 |
+
<div class="handlediv" title="Click to toggle"><br></div>
|
228 |
+
<!-- Toggle -->
|
229 |
+
|
230 |
+
<h2 class="hndle"><span><?php esc_attr_e( 'Connect with IvyCat!', 'posts-in-page' ); ?></span></h2>
|
231 |
+
|
232 |
+
<div class="inside">
|
233 |
+
<div class="inside_wrap">
|
234 |
+
<!-- Begin MailChimp Signup Form -->
|
235 |
+
<div id="mc_embed_signup" class="clearfix">
|
236 |
+
<form action="//ivycat.us1.list-manage.com/subscribe/post?u=599f2f6b712f346e11c2930d4&id=6ee02404ab"
|
237 |
+
method="post" id="mc-embedded-subscribe-form"
|
238 |
+
name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
|
239 |
+
<label for="mce-EMAIL">Signup for email updates</label>
|
240 |
+
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL"
|
241 |
+
placeholder="email address" required>
|
242 |
+
<input type="submit" value="Subscribe" name="subscribe"
|
243 |
+
id="mc-embedded-subscribe" class="button">
|
244 |
+
</form>
|
245 |
+
</div>
|
246 |
+
<!--End mc_embed_signup-->
|
247 |
+
|
248 |
+
<hr/>
|
249 |
+
|
250 |
+
<ul class="ivycat-social clearfix">
|
251 |
+
<li><a href="https://twitter.com/ivycatweb"><span
|
252 |
+
class="dashicons dashicons-twitter"></span> <span
|
253 |
+
class="screen-reader-text">Twitter</span></span></a></li>
|
254 |
+
<li><a href="https://www.facebook.com/ivycatweb"><span
|
255 |
+
class="dashicons dashicons-facebook"></span> <span
|
256 |
+
class="screen-reader-text">Facebook</span></a></li>
|
257 |
+
<li><a href="https://profiles.wordpress.org/ivycat"><span
|
258 |
+
class="dashicons dashicons-wordpress"></span> <span
|
259 |
+
class="screen-reader-text">WordPress.org</span></a></li>
|
260 |
+
<li class="ic_mc"><a href="https://eepurl.com/b3_65" target="_blank"><span
|
261 |
+
class="dashicons dashicons-email"></span> <span
|
262 |
+
class="screen-reader-text">Sign up for our free newsletter!</span></a>
|
263 |
+
</li>
|
264 |
+
</ul>
|
265 |
+
|
266 |
+
</div>
|
267 |
+
</div>
|
268 |
+
<!-- .inside -->
|
269 |
+
|
270 |
+
</div>
|
271 |
+
<!-- .postbox -->
|
272 |
+
|
273 |
+
<div class="postbox">
|
274 |
+
|
275 |
+
<div class="handlediv" title="Click to toggle"><br></div>
|
276 |
+
<!-- Toggle -->
|
277 |
+
|
278 |
+
<h2 class="hndle"><span><?php esc_attr_e( 'Spread the word', 'posts-in-page' ); ?></span></h2>
|
279 |
+
|
280 |
+
<div class="inside">
|
281 |
+
<div class="inside_wrap">
|
282 |
+
<h4>Help make this plugin better</h4>
|
283 |
+
<ul>
|
284 |
+
<li><a href="https://wordpress.org/support/plugin/posts-in-page/reviews/#new-post">Rate
|
285 |
+
<div class="ivycat-rating"><span
|
286 |
+
class="dashicons dashicons-star-filled"></span><span
|
287 |
+
class="dashicons dashicons-star-filled"></span><span
|
288 |
+
class="dashicons dashicons-star-filled"></span><span
|
289 |
+
class="dashicons dashicons-star-filled"></span><span
|
290 |
+
class="dashicons dashicons-star-filled"></span></div>
|
291 |
+
on WordPress.org</a></li>
|
292 |
+
<li>
|
293 |
+
<a href="https://twitter.com/home/?status=Check%20out%20the%20Posts%20in%20Page%20WordPress%20plugin%20from%20IvyCat!%20http%3A%2F%2Fbit.ly%2F1bmI8pS">Tweet
|
294 |
+
about Posts in Page</a></li>
|
295 |
+
</ul>
|
296 |
+
</div>
|
297 |
+
</div>
|
298 |
+
<!-- .inside -->
|
299 |
+
|
300 |
+
</div>
|
301 |
+
<!-- .postbox -->
|
302 |
+
<div class="postbox signature clearfix">
|
303 |
+
|
304 |
+
<div class="handlediv" title="Click to toggle"><br></div>
|
305 |
+
<!-- Toggle -->
|
306 |
+
|
307 |
+
<h2 class="hndle"><span><?php esc_attr_e( 'IvyCat Web Services', 'posts-in-page' ); ?></span></h2>
|
308 |
+
|
309 |
+
<div class="inside">
|
310 |
+
<div class="inside_wrap">
|
311 |
+
<img src="https://s.gravatar.com/avatar/f1c6ff76072edfd217215f3acd412c26?s=80?s=200"
|
312 |
+
class="ivycat-gravatar alignleft"/>
|
313 |
+
<div class="ivycat_text_wrap alignleft">
|
314 |
+
<ul class="link-list">
|
315 |
+
<li><a href="https://ivycat.com/wordpress/wordpress-support-maintenance/">WP
|
316 |
+
Maintenance & Support</a></li>
|
317 |
+
<li><a href="https://ivycat.com/web-design/">WordPress Development</a></li>
|
318 |
+
</ul>
|
319 |
+
</div>
|
320 |
+
</div>
|
321 |
+
</div>
|
322 |
+
<!-- .inside -->
|
323 |
+
|
324 |
+
</div>
|
325 |
+
<!-- .postbox -->
|
326 |
+
</div>
|
327 |
+
<!-- .meta-box-sortables -->
|
328 |
+
|
329 |
+
</div>
|
330 |
+
<!-- #postbox-container-1 .postbox-container -->
|
331 |
+
|
332 |
+
</div>
|
333 |
+
<!-- #post-body .metabox-holder .columns-2 -->
|
334 |
+
|
335 |
+
<br class="clear">
|
336 |
+
</div>
|
337 |
+
<!-- #poststuff -->
|
338 |
+
|
339 |
+
</div> <!-- .wrap -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-page-posts.php
CHANGED
@@ -1,395 +1,398 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Page posts class, the main workhorse for the ic_add_posts shortcode.
|
4 |
-
*
|
5 |
-
* @package
|
6 |
-
* @author
|
7 |
-
* @copyright
|
8 |
-
* @link
|
9 |
-
* @since
|
10 |
-
* @license
|
11 |
-
*/
|
12 |
-
|
13 |
-
if ( ! function_exists( 'add_action' ) ) {
|
14 |
-
wp_die( 'You are trying to access this file in a manner not allowed.', 'Direct Access Forbidden', array( 'response' => '403' ) );
|
15 |
-
}
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
protected
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
$
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
//
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
$this->args['
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
$this->args['
|
146 |
-
}
|
147 |
-
|
148 |
-
//
|
149 |
-
if ( isset( $atts['
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
//
|
185 |
-
$
|
186 |
-
$category
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
$
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
$
|
232 |
-
$this->args['
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
'
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
);
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
$
|
281 |
-
|
282 |
-
'
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
$
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
);
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
$output_start
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
}
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Page posts class, the main workhorse for the ic_add_posts shortcode.
|
4 |
+
*
|
5 |
+
* @package Posts_in_Page
|
6 |
+
* @author Eric Amundson <eric@ivycat.com>
|
7 |
+
* @copyright Copyright (c) 2019, IvyCat, Inc.
|
8 |
+
* @link https://ivycat.com
|
9 |
+
* @since 1.0.0
|
10 |
+
* @license GPL-2.0-or-later
|
11 |
+
*/
|
12 |
+
|
13 |
+
if ( ! function_exists( 'add_action' ) ) {
|
14 |
+
wp_die( 'You are trying to access this file in a manner not allowed.', 'Direct Access Forbidden', array( 'response' => '403' ) );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Page in posts class.
|
19 |
+
*/
|
20 |
+
class ICPagePosts {
|
21 |
+
/**
|
22 |
+
* Arguments.
|
23 |
+
*
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
protected $args = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Constructor method.
|
30 |
+
*
|
31 |
+
* @param array $atts Shortcode attributes.
|
32 |
+
*/
|
33 |
+
public function __construct( $atts ) {
|
34 |
+
$this->set_default_args();
|
35 |
+
$this->set_args( $atts );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Set default arguments.
|
40 |
+
*/
|
41 |
+
protected function set_default_args() {
|
42 |
+
$this->args = array(
|
43 |
+
'post_type' => 'post',
|
44 |
+
'post_status' => 'publish',
|
45 |
+
'orderby' => 'date',
|
46 |
+
'order' => 'DESC',
|
47 |
+
'paginate' => false,
|
48 |
+
'template' => false,
|
49 |
+
'label_next' => esc_html__( 'Next', 'posts-in-page' ),
|
50 |
+
'label_previous' => esc_html__( 'Previous', 'posts-in-page' ),
|
51 |
+
'date_query' => '',
|
52 |
+
'none_found' => '',
|
53 |
+
'paged' => false,
|
54 |
+
);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Spits out the posts, in a gentlemanly way.
|
59 |
+
*
|
60 |
+
* @return string Output of template file.
|
61 |
+
*/
|
62 |
+
public function output_posts() {
|
63 |
+
global $wp_query;
|
64 |
+
|
65 |
+
if ( ! $this->args ) {
|
66 |
+
return '';
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( $this->args['paginate'] ) {
|
70 |
+
$this->args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
|
71 |
+
}
|
72 |
+
|
73 |
+
// Commandeering wp_query for pagination quirkiness.
|
74 |
+
$temp = $wp_query;
|
75 |
+
$wp_query = null;
|
76 |
+
$wp_query = apply_filters( 'posts_in_page_results', new WP_Query( $this->args ) );
|
77 |
+
|
78 |
+
$output = '';
|
79 |
+
if ( have_posts() ) {
|
80 |
+
while ( have_posts() ) {
|
81 |
+
$output .= self::add_template_part( $wp_query );
|
82 |
+
}
|
83 |
+
|
84 |
+
if ( $this->args['paginate'] ) {
|
85 |
+
$output .= apply_filters( 'posts_in_page_paginate', $this->paginate_links() );
|
86 |
+
}
|
87 |
+
} else {
|
88 |
+
$output = '<div class="post hentry ivycat-post"><span class="pip-not-found">' . esc_html( $this->args['none_found'] ) . '</span></div>';
|
89 |
+
}
|
90 |
+
|
91 |
+
// Restore wp_query.
|
92 |
+
$wp_query = null;
|
93 |
+
$wp_query = $temp;
|
94 |
+
wp_reset_query(); // phpcs:ignore WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query
|
95 |
+
remove_filter( 'excerpt_more', array( $this, 'custom_excerpt_more' ) );
|
96 |
+
|
97 |
+
return $output;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Retrieve pagination links.
|
102 |
+
*
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
protected function paginate_links() {
|
106 |
+
$prev = get_previous_posts_link( $this->args['label_previous'] );
|
107 |
+
$next = get_next_posts_link( $this->args['label_next'] );
|
108 |
+
|
109 |
+
if ( $prev || $next ) {
|
110 |
+
$prev_link = $prev ? "<li class='pip-nav-prev'>$prev</li>" : '';
|
111 |
+
$next_link = $next ? "<li class='pip-nav-next'>$next</li>" : '';
|
112 |
+
|
113 |
+
return "<ul class='pip-nav'>$prev_link $next_link</ul>";
|
114 |
+
}
|
115 |
+
|
116 |
+
return '';
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Build additional arguments for the WP_Query object.
|
122 |
+
*
|
123 |
+
* @param array $atts Attributes for building the $args array.
|
124 |
+
*/
|
125 |
+
protected function set_args( $atts ) {
|
126 |
+
global $wp_query;
|
127 |
+
$this->args['posts_per_page'] = get_option( 'posts_per_page' );
|
128 |
+
// Parse the arguments using the defaults.
|
129 |
+
$this->args = wp_parse_args( $atts, $this->args );
|
130 |
+
// Multiple post types are indicated, pass as an array.
|
131 |
+
if ( strpos( $this->args['post_type'], ',' ) ) {
|
132 |
+
$post_types = explode( ',', $this->args['post_type'] );
|
133 |
+
$this->args['post_type'] = $post_types;
|
134 |
+
}
|
135 |
+
|
136 |
+
// Show specific posts by ID.
|
137 |
+
if ( isset( $atts['ids'] ) ) {
|
138 |
+
$post_ids = explode( ',', $atts['ids'] );
|
139 |
+
$this->args['post__in'] = $post_ids;
|
140 |
+
$this->args['posts_per_page'] = count( $post_ids );
|
141 |
+
}
|
142 |
+
|
143 |
+
// Use a specified template.
|
144 |
+
if ( isset( $atts['template'] ) ) {
|
145 |
+
$this->args['template'] = $atts['template'];
|
146 |
+
}
|
147 |
+
|
148 |
+
// Get posts in a certain category by name (slug).
|
149 |
+
if ( isset( $atts['category'] ) ) {
|
150 |
+
$this->args['category_name'] = $atts['category'];
|
151 |
+
} elseif ( isset( $atts['cats'] ) ) {
|
152 |
+
// Get posts in a certain category by id.
|
153 |
+
$this->args['cat'] = $atts['cats'];
|
154 |
+
}
|
155 |
+
|
156 |
+
// Do a tax query, tax and term a required.
|
157 |
+
if ( isset( $atts['tax'] ) ) {
|
158 |
+
if ( isset( $atts['term'] ) ) {
|
159 |
+
$terms = explode( ',', $atts['term'] );
|
160 |
+
$this->args['tax_query'] = array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
|
161 |
+
array(
|
162 |
+
'taxonomy' => $atts['tax'],
|
163 |
+
'field' => 'slug',
|
164 |
+
'terms' => ( count( $terms ) > 1 ) ? $terms : $atts['term'],
|
165 |
+
),
|
166 |
+
);
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
// Get posts with a certain tag.
|
171 |
+
if ( isset( $atts['tag'] ) ) {
|
172 |
+
$this->args['tag'] = $atts['tag'];
|
173 |
+
}
|
174 |
+
|
175 |
+
// Override default post_type argument ('publish').
|
176 |
+
if ( isset( $atts['post_status'] ) ) {
|
177 |
+
$this->args['post_status'] = $atts['post_status'];
|
178 |
+
}
|
179 |
+
|
180 |
+
// Exclude posts with certain category by name (slug).
|
181 |
+
if ( isset( $atts['exclude_category'] ) ) {
|
182 |
+
$category = $atts['exclude_category'];
|
183 |
+
if ( strpos( $category, ',' ) ) {
|
184 |
+
// Multiple.
|
185 |
+
$category = explode( ',', $category );
|
186 |
+
foreach ( $category as $cat ) {
|
187 |
+
$term = get_category_by_slug( $cat );
|
188 |
+
$exclude[] = '-' . $term->term_id;
|
189 |
+
}
|
190 |
+
$category = implode( ',', $exclude );
|
191 |
+
} else {
|
192 |
+
// Single.
|
193 |
+
$term = get_category_by_slug( $category );
|
194 |
+
$category = '-' . $term->term_id;
|
195 |
+
}
|
196 |
+
if ( isset( $this->args['cat'] ) && ! is_null( $this->args['cat'] ) ) {
|
197 |
+
// Merge lists.
|
198 |
+
$this->args['cat'] .= ',' . $category;
|
199 |
+
}
|
200 |
+
$this->args['cat'] = $category;
|
201 |
+
// Unset our unneeded variables.
|
202 |
+
unset( $category, $term, $exclude );
|
203 |
+
}
|
204 |
+
|
205 |
+
// Show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed).
|
206 |
+
if ( isset( $atts['showposts'] ) ) {
|
207 |
+
$this->args['posts_per_page'] = $atts['showposts'];
|
208 |
+
}
|
209 |
+
|
210 |
+
// Handle pagination (for code, template pagination is in the template).
|
211 |
+
if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
|
212 |
+
$this->args['paged'] = $wp_query->query_vars['page'];
|
213 |
+
}
|
214 |
+
|
215 |
+
if (
|
216 |
+
! ( isset( $this->args['ignore_sticky_posts'] ) &&
|
217 |
+
( 'no' === strtolower( $this->args['ignore_sticky_posts'] ) ||
|
218 |
+
'false' === strtolower( $this->args['ignore_sticky_posts'] ) ) )
|
219 |
+
) {
|
220 |
+
|
221 |
+
$this->args['post__not_in'] = get_option( 'sticky_posts' );
|
222 |
+
}
|
223 |
+
|
224 |
+
$this->args['ignore_sticky_posts'] = isset( $this->args['ignore_sticky_posts'] ) ? $this->shortcode_bool( $this->args['ignore_sticky_posts'] ) : true;
|
225 |
+
|
226 |
+
if ( isset( $this->args['more_tag'] ) ) {
|
227 |
+
add_filter( 'excerpt_more', array( $this, 'custom_excerpt_more' ), 11 );
|
228 |
+
}
|
229 |
+
|
230 |
+
if ( isset( $atts['exclude_ids'] ) ) {
|
231 |
+
$exclude_posts = explode( ',', $atts['exclude_ids'] );
|
232 |
+
if ( isset( $this->args['post__not_in'] ) ) {
|
233 |
+
$this->args['post__not_in'] = array_merge( $this->args['post__not_in'], $exclude_posts );
|
234 |
+
} else {
|
235 |
+
$this->args['post__not_in'] = $exclude_posts;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
if ( isset( $atts['from_date'] ) && isset( $atts['to_date'] ) ) {
|
240 |
+
$r_from = explode( '-', $atts['from_date'] );
|
241 |
+
$r_to = explode( '-', $atts['to_date'] );
|
242 |
+
$this->args['date_query'] = array(
|
243 |
+
array(
|
244 |
+
'after' => array(
|
245 |
+
'year' => $r_from[2],
|
246 |
+
'month' => $r_from[1],
|
247 |
+
'day' => $r_from[0],
|
248 |
+
),
|
249 |
+
'before' => array(
|
250 |
+
'year' => $r_to[2],
|
251 |
+
'month' => $r_to[1],
|
252 |
+
'day' => $r_to[0],
|
253 |
+
),
|
254 |
+
'inclusive' => true,
|
255 |
+
),
|
256 |
+
);
|
257 |
+
} elseif ( isset( $atts['from_date'] ) ) {
|
258 |
+
$r_from = explode( '-', $atts['from_date'] );
|
259 |
+
$r_to = explode( '-', $atts['to_date'] );
|
260 |
+
$this->args['date_query'] = array(
|
261 |
+
array(
|
262 |
+
'after' => array(
|
263 |
+
'year' => $r_from[2],
|
264 |
+
'month' => $r_from[1],
|
265 |
+
'day' => $r_from[0],
|
266 |
+
),
|
267 |
+
'inclusive' => true,
|
268 |
+
),
|
269 |
+
);
|
270 |
+
}
|
271 |
+
|
272 |
+
$current_time_value = current_time( 'timestamp' );
|
273 |
+
if ( isset( $atts['date'] ) ) {
|
274 |
+
$date_data = explode( '-', $atts['date'] );
|
275 |
+
if ( ! isset( $date_data[1] ) ) {
|
276 |
+
$date_data[1] = 0;
|
277 |
+
}
|
278 |
+
switch ( $date_data[0] ) {
|
279 |
+
case 'today':
|
280 |
+
$today = getdate( $current_time_value - ( $date_data[1] * DAY_IN_SECONDS ) );
|
281 |
+
$this->args['date_query'] = array(
|
282 |
+
'year' => $today['year'],
|
283 |
+
'month' => $today['mon'],
|
284 |
+
'day' => $today['mday'],
|
285 |
+
);
|
286 |
+
break;
|
287 |
+
case 'week':
|
288 |
+
$week = date( 'W', $current_time_value - $date_data[1] * WEEK_IN_SECONDS );
|
289 |
+
$year = date( 'Y', $current_time_value - $date_data[1] * WEEK_IN_SECONDS );
|
290 |
+
$this->args['date_query'] = array(
|
291 |
+
'year' => $year,
|
292 |
+
'week' => $week,
|
293 |
+
);
|
294 |
+
break;
|
295 |
+
case 'month':
|
296 |
+
$month = date( 'm', strtotime( ( strval( - $date_data[1] ) . ' Months' ), $current_time_value ) );
|
297 |
+
$year = date( 'Y', strtotime( ( strval( - $date_data[1] ) . ' Months' ), $current_time_value ) );
|
298 |
+
$this->args['date_query'] = array(
|
299 |
+
'monthnum' => $month,
|
300 |
+
'year' => $year,
|
301 |
+
);
|
302 |
+
break;
|
303 |
+
case 'year':
|
304 |
+
$year = date( 'Y', strtotime( ( strval( - $date_data[1] ) . ' Years' ), $current_time_value ) );
|
305 |
+
$this->args['date_query'] = array(
|
306 |
+
'year' => $year,
|
307 |
+
);
|
308 |
+
break;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
$this->args = apply_filters( 'posts_in_page_args', $this->args );
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Sets a shortcode boolean value to a real boolean.
|
316 |
+
*
|
317 |
+
* @param mixed $var Value to evaluate to a boolean.
|
318 |
+
* @return bool
|
319 |
+
*/
|
320 |
+
public function shortcode_bool( $var ) {
|
321 |
+
$falsey = array( 'false', '0', 'no', 'n' );
|
322 |
+
|
323 |
+
return ( ! $var || in_array( strtolower( $var ), $falsey, true ) ) ? false : true;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Tests if a theme has a template file that exists in one of two locations
|
328 |
+
* 1- posts-in-page directory or 2- theme directory.
|
329 |
+
*
|
330 |
+
* @return true if template exists, false otherwise.
|
331 |
+
*/
|
332 |
+
protected function has_theme_template() {
|
333 |
+
// Try default template filename if empty.
|
334 |
+
$filename = empty( $this->args['template'] ) ? 'posts_loop_template.php' : $this->args['template'];
|
335 |
+
|
336 |
+
// Checking first of two locations - theme root.
|
337 |
+
$template_file = get_stylesheet_directory() . '/' . $filename;
|
338 |
+
|
339 |
+
// Check for traversal attack.
|
340 |
+
$path_parts = pathinfo( $template_file );
|
341 |
+
if ( get_stylesheet_directory() . '/' . $path_parts['filename'] . '.' . $path_parts['extension'] !== $template_file ) {
|
342 |
+
// Something fishy.
|
343 |
+
return false;
|
344 |
+
}
|
345 |
+
|
346 |
+
return ( file_exists( $template_file ) ) ? $template_file : false;
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Retrieves the post loop template and returns the output.
|
351 |
+
*
|
352 |
+
* @param WP_Query $ic_posts Posts in Page query.
|
353 |
+
* @param bool $singles Whether a single post should be set up.
|
354 |
+
* @return string Results of the output.
|
355 |
+
*/
|
356 |
+
protected function add_template_part( $ic_posts, $singles = false ) {
|
357 |
+
if ( $singles ) {
|
358 |
+
setup_postdata( $ic_posts );
|
359 |
+
} else {
|
360 |
+
$ic_posts->the_post();
|
361 |
+
}
|
362 |
+
// Because legacy versions of pip forced users to echo content in the filter callback
|
363 |
+
// we are using both the filters and the output buffer to cover all bases of usage.
|
364 |
+
ob_start();
|
365 |
+
$output_start = apply_filters( 'posts_in_page_pre_loop', '' );
|
366 |
+
$file_path = self::has_theme_template();
|
367 |
+
require $file_path
|
368 |
+
? $file_path // Use template file in theme.
|
369 |
+
: POSTSPAGE_DIR . '/templates/posts_loop_template.php'; // Use default plugin template file.
|
370 |
+
$output_start .= ob_get_clean();
|
371 |
+
// Output buffering to handle legacy versions which forced filter callbacks to echo content rather than return it.
|
372 |
+
ob_start();
|
373 |
+
// Standard use of filter.
|
374 |
+
$output = apply_filters( 'posts_in_page_post_loop', $output_start );
|
375 |
+
// Just in case someone has a legacy callback that doesn't return anything...
|
376 |
+
if ( empty( $output ) ) {
|
377 |
+
$output = $output_start;
|
378 |
+
}
|
379 |
+
// Allow for legacy use of filter which forced echoing content.
|
380 |
+
$output .= ob_get_clean();
|
381 |
+
|
382 |
+
return $output;
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Retrieve a custom more link for excerpts.
|
387 |
+
*
|
388 |
+
* @param string $more Link text.
|
389 |
+
* @return string
|
390 |
+
*/
|
391 |
+
public function custom_excerpt_more( $more ) {
|
392 |
+
$more_tag = $this->args['more_tag'];
|
393 |
+
|
394 |
+
return ' <a class="read-more" href="' . esc_url( get_permalink( get_the_ID() ) ) . '">' . $more_tag . '</a>';
|
395 |
+
}
|
396 |
+
|
397 |
+
|
398 |
+
}
|
index.php
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// silence is golden.
|
|
|
|
languages/Posts-in-Page.pot
DELETED
@@ -1,214 +0,0 @@
|
|
1 |
-
# Copyright (C) 2019 IvyCat, Inc.
|
2 |
-
# This file is distributed under the GNU General Public License v2.0.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: Posts in Page 1.4.1\n"
|
6 |
-
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/posts-in-page\n"
|
7 |
-
"POT-Creation-Date: 2019-03-08 17:09:17+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: 2019-MO-DA HO:MI+ZONE\n"
|
12 |
-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
-
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
-
"X-Generator: grunt-wp-i18n1.0.2\n"
|
15 |
-
|
16 |
-
#. Plugin Name of the plugin/theme
|
17 |
-
msgid "Posts in Page"
|
18 |
-
msgstr ""
|
19 |
-
|
20 |
-
#: admin/views/help-main.php:34
|
21 |
-
msgid "How to use Posts in Page"
|
22 |
-
msgstr ""
|
23 |
-
|
24 |
-
#: admin/views/help-main.php:71
|
25 |
-
msgid ""
|
26 |
-
"Add all posts to a page (limit to what number posts in WordPress is set "
|
27 |
-
"to), essentially adds blog \"page\" to page."
|
28 |
-
msgstr ""
|
29 |
-
|
30 |
-
#: admin/views/help-main.php:76
|
31 |
-
msgid ""
|
32 |
-
"Show posts from a custom post type by specifying the post type slug ( must "
|
33 |
-
"give post type if not a standard post ) add multiple post types by "
|
34 |
-
"separating with commas (ex."
|
35 |
-
msgstr ""
|
36 |
-
|
37 |
-
#: admin/views/help-main.php:83
|
38 |
-
msgid "Limit number of posts (or override default setting)"
|
39 |
-
msgstr ""
|
40 |
-
|
41 |
-
#: admin/views/help-main.php:88
|
42 |
-
msgid ""
|
43 |
-
"orderby title - supports all WP orderby variables. Order is optional, WP "
|
44 |
-
"default"
|
45 |
-
msgstr ""
|
46 |
-
|
47 |
-
#: admin/views/help-main.php:93
|
48 |
-
msgid ""
|
49 |
-
"Show one or many posts by specifying the post ID(s) ( specify all post "
|
50 |
-
"types )"
|
51 |
-
msgstr ""
|
52 |
-
|
53 |
-
#: admin/views/help-main.php:98
|
54 |
-
msgid ""
|
55 |
-
"Exclude one or more posts by specifying the post ID(s) ( specify all post "
|
56 |
-
"types )"
|
57 |
-
msgstr ""
|
58 |
-
|
59 |
-
#: admin/views/help-main.php:103 admin/views/help-main.php:108
|
60 |
-
msgid ""
|
61 |
-
"Show posts within a specific category. Uses slugs, can have multiple but "
|
62 |
-
"separate by commas. category-1,category2, etc (no spaces.)"
|
63 |
-
msgstr ""
|
64 |
-
|
65 |
-
#: admin/views/help-main.php:113
|
66 |
-
msgid ""
|
67 |
-
"Show posts using a specific tag. Like categories, it uses slugs, and can "
|
68 |
-
"accommodate multiple tags separate by commas. tag-1,tag-2, etc (no "
|
69 |
-
"spaces.)"
|
70 |
-
msgstr ""
|
71 |
-
|
72 |
-
#: admin/views/help-main.php:118
|
73 |
-
msgid ""
|
74 |
-
"Limit posts to those that exist in a taxonomy and have a specific term. "
|
75 |
-
"Both are required for either one to work"
|
76 |
-
msgstr ""
|
77 |
-
|
78 |
-
#: admin/views/help-main.php:123
|
79 |
-
msgid ""
|
80 |
-
"In case you want to style your markup, add meta data, etc. Each shortcode "
|
81 |
-
"can reference a different template. These templates must exist in the "
|
82 |
-
"theme directory or in a subfolder named posts-in-page."
|
83 |
-
msgstr ""
|
84 |
-
|
85 |
-
#: admin/views/help-main.php:128
|
86 |
-
msgid "Show sticky posts too (they're ignored by default)"
|
87 |
-
msgstr ""
|
88 |
-
|
89 |
-
#: admin/views/help-main.php:133
|
90 |
-
msgid "use pagination links (off by default)"
|
91 |
-
msgstr ""
|
92 |
-
|
93 |
-
#: admin/views/help-main.php:138
|
94 |
-
msgid "Change the post navigation labels"
|
95 |
-
msgstr ""
|
96 |
-
|
97 |
-
#: admin/views/help-main.php:143
|
98 |
-
msgid ""
|
99 |
-
"Show posts with the specified status(es); the default is to only show posts "
|
100 |
-
"with status 'publish'. To choose more than one status, separate them with "
|
101 |
-
"commas. For example: <code>post_status='private,publish'</code>."
|
102 |
-
msgstr ""
|
103 |
-
|
104 |
-
#: admin/views/help-main.php:148
|
105 |
-
msgid ""
|
106 |
-
"Displays posts after the offset. An offset='3' will show all posts from the "
|
107 |
-
"4th one onward."
|
108 |
-
msgstr ""
|
109 |
-
|
110 |
-
#: admin/views/help-main.php:153
|
111 |
-
msgid ""
|
112 |
-
"Shows posts associated (published) on specified date period, today, "
|
113 |
-
"'today-1' show's posts published yesterday, 'today-2' shows posts published "
|
114 |
-
"two days ago, etc. Also 'week(-n)' shows posts n weeks ago. Also available "
|
115 |
-
"'month(-n)' and 'year(-n)'"
|
116 |
-
msgstr ""
|
117 |
-
|
118 |
-
#: admin/views/help-main.php:158
|
119 |
-
msgid "Shows posts published within a specified absolute date range"
|
120 |
-
msgstr ""
|
121 |
-
|
122 |
-
#: admin/views/help-main.php:163
|
123 |
-
msgid "Set the link text for read more links shown after an excerpt"
|
124 |
-
msgstr ""
|
125 |
-
|
126 |
-
#: admin/views/help-main.php:168
|
127 |
-
msgid "Custom message to display if no posts are found"
|
128 |
-
msgstr ""
|
129 |
-
|
130 |
-
#: admin/views/help-main.php:172
|
131 |
-
msgid "Or any combination of the above."
|
132 |
-
msgstr ""
|
133 |
-
|
134 |
-
#: admin/views/help-main.php:175
|
135 |
-
msgid "Embed a PHP function in a theme template file"
|
136 |
-
msgstr ""
|
137 |
-
|
138 |
-
#: admin/views/help-main.php:177
|
139 |
-
msgid ""
|
140 |
-
"If you'd like to use this plugin to pull posts directly into your theme's "
|
141 |
-
"template files, you can drop the following WordPress function in your "
|
142 |
-
"template files, replacing the <code>[shortcode]</code> part with your, "
|
143 |
-
"custom shortcode."
|
144 |
-
msgstr ""
|
145 |
-
|
146 |
-
#: admin/views/help-main.php:202
|
147 |
-
msgid "Help & Contributing"
|
148 |
-
msgstr ""
|
149 |
-
|
150 |
-
#: admin/views/help-main.php:231
|
151 |
-
msgid "Connect with IvyCat!"
|
152 |
-
msgstr ""
|
153 |
-
|
154 |
-
#: admin/views/help-main.php:281
|
155 |
-
msgid "Spread the word"
|
156 |
-
msgstr ""
|
157 |
-
|
158 |
-
#: admin/views/help-main.php:312
|
159 |
-
msgid "IvyCat Web Services"
|
160 |
-
msgstr ""
|
161 |
-
|
162 |
-
#: includes/class-page-posts.php:34
|
163 |
-
msgid "Next"
|
164 |
-
msgstr ""
|
165 |
-
|
166 |
-
#: includes/class-page-posts.php:35
|
167 |
-
msgid "Previous"
|
168 |
-
msgstr ""
|
169 |
-
|
170 |
-
#: posts_in_page.php:52
|
171 |
-
msgid " Help"
|
172 |
-
msgstr ""
|
173 |
-
|
174 |
-
#: templates/posts_loop_template.php:31
|
175 |
-
msgid "<span class=\"%1$s\">Posted in</span> %2$s"
|
176 |
-
msgstr ""
|
177 |
-
|
178 |
-
#: templates/posts_loop_template.php:39
|
179 |
-
msgid "<span class=\"%1$s\">Tagged</span> %2$s"
|
180 |
-
msgstr ""
|
181 |
-
|
182 |
-
#: templates/posts_loop_template.php:43
|
183 |
-
msgid "Leave a comment"
|
184 |
-
msgstr ""
|
185 |
-
|
186 |
-
#: templates/posts_loop_template.php:43
|
187 |
-
msgid "1 Comment"
|
188 |
-
msgstr ""
|
189 |
-
|
190 |
-
#: templates/posts_loop_template.php:43
|
191 |
-
msgid "% Comments"
|
192 |
-
msgstr ""
|
193 |
-
|
194 |
-
#: templates/posts_loop_template.php:44
|
195 |
-
msgid "Edit"
|
196 |
-
msgstr ""
|
197 |
-
|
198 |
-
#. Plugin URI of the plugin/theme
|
199 |
-
msgid "https://ivycat.com/wordpress/wordpress-plugins/posts-in-page/"
|
200 |
-
msgstr ""
|
201 |
-
|
202 |
-
#. Description of the plugin/theme
|
203 |
-
msgid ""
|
204 |
-
"Easily add one or more posts to any page using simple shortcodes. Supports "
|
205 |
-
"categories, tags, custom post types, custom taxonomies, and more."
|
206 |
-
msgstr ""
|
207 |
-
|
208 |
-
#. Author of the plugin/theme
|
209 |
-
msgid "IvyCat, Inc."
|
210 |
-
msgstr ""
|
211 |
-
|
212 |
-
#. Author URI of the plugin/theme
|
213 |
-
msgid "https://ivycat.com/wordpress/"
|
214 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
posts_in_page.php
CHANGED
@@ -1,120 +1,142 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
* @
|
6 |
-
* @
|
7 |
-
*
|
8 |
-
*
|
9 |
-
*
|
10 |
-
*
|
11 |
-
*
|
12 |
-
*
|
13 |
-
*
|
14 |
-
*
|
15 |
-
*
|
16 |
-
*
|
17 |
-
*
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
class
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
*
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
return
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
*
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Posts In Page
|
4 |
+
*
|
5 |
+
* @package Posts_in_Page
|
6 |
+
* @author Eric Amundson <eric@ivycat.com>
|
7 |
+
* @copyright Copyright (c) 2019, IvyCat, Inc.
|
8 |
+
* @license GPL-2.0-or-later
|
9 |
+
*
|
10 |
+
* @wordpress-plugin
|
11 |
+
* Plugin Name: Posts in Page
|
12 |
+
* Plugin URI: https://ivycat.com/wordpress/wordpress-plugins/posts-in-page/
|
13 |
+
* Description: Easily add one or more posts to any page using simple shortcodes. Supports categories, tags, custom post types, custom taxonomies, and more.
|
14 |
+
* Version: 1.4.2
|
15 |
+
* Author: IvyCat, Inc.
|
16 |
+
* Author URI: https://ivycat.com/wordpress/
|
17 |
+
* Text Domain: posts-in-page
|
18 |
+
* License: GNU General Public License v2.0
|
19 |
+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
20 |
+
*/
|
21 |
+
|
22 |
+
if ( ! function_exists( 'add_action' ) ) {
|
23 |
+
wp_die( 'You are trying to access this file in a manner not allowed.', 'Direct Access Forbidden', array( 'response' => '403' ) );
|
24 |
+
}
|
25 |
+
|
26 |
+
if ( ! defined( 'POSTSPAGE_DIR' ) ) {
|
27 |
+
define( 'POSTSPAGE_DIR', plugin_dir_path( __FILE__ ) );
|
28 |
+
}
|
29 |
+
|
30 |
+
if ( ! defined( 'POSTPAGE_URL' ) ) {
|
31 |
+
define( 'POSTPAGE_URL', plugin_dir_url( __FILE__ ) );
|
32 |
+
}
|
33 |
+
|
34 |
+
require_once 'includes/class-page-posts.php';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Main plugin class.
|
38 |
+
*/
|
39 |
+
class ICAddPostsToPage {
|
40 |
+
/**
|
41 |
+
* Constructor method.
|
42 |
+
*/
|
43 |
+
public function __construct() {
|
44 |
+
add_shortcode( 'ic_add_posts', array( $this, 'posts_in_page' ) );
|
45 |
+
add_shortcode( 'ic_add_post', array( $this, 'post_in_page' ) );
|
46 |
+
add_action( 'admin_menu', array( $this, 'plugin_page_init' ) );
|
47 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ), 10, 2 );
|
48 |
+
load_plugin_textdomain( 'posts-in-page' );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Add settings link on plugins page.
|
53 |
+
*
|
54 |
+
* @param string[] $actions An array of plugin action links. By default this can include 'activate',
|
55 |
+
* 'deactivate', and 'delete'.
|
56 |
+
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function plugin_action_links( $actions, $plugin_file ) {
|
60 |
+
if ( is_plugin_active( $plugin_file ) ) {
|
61 |
+
$actions[] = '<a href="' . esc_url( admin_url( 'options-general.php?page=posts_in_page' ) ) . '">' . esc_html__( ' Help', 'posts-in-page' ) . '</a>';
|
62 |
+
}
|
63 |
+
|
64 |
+
return apply_filters( 'post_in_page_actions', $actions );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Main shortcode.
|
69 |
+
*
|
70 |
+
* @param array $atts An array of shortcode parameters. None required.
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
public function posts_in_page( $atts ) {
|
74 |
+
$posts = new ICPagePosts( $atts );
|
75 |
+
|
76 |
+
return $posts->output_posts();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Deprecated shortcode (routing to posts in page function now).
|
81 |
+
*
|
82 |
+
* @deprecated Deprecated since 1.1.0.
|
83 |
+
*
|
84 |
+
* @param array $atts An array of shortcode parameters. None required.
|
85 |
+
* @return array
|
86 |
+
*/
|
87 |
+
public function post_in_page( $atts ) {
|
88 |
+
return self::posts_in_page( $atts );
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Init plugin, add menu page, and setup hooks to load assets on the plugin options page.
|
93 |
+
*/
|
94 |
+
public function plugin_page_init() {
|
95 |
+
$hook = add_options_page(
|
96 |
+
esc_html__( 'Posts in Page', 'posts-in-page' ),
|
97 |
+
esc_html__( 'Posts in Page', 'posts-in-page' ),
|
98 |
+
'manage_options',
|
99 |
+
'posts_in_page',
|
100 |
+
array( $this, 'plugin_page' )
|
101 |
+
);
|
102 |
+
|
103 |
+
add_action( "admin_print_styles-{$hook}", array( $this, 'load_assets' ) );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Enqueue plugin assets (scripts & styles).
|
108 |
+
*/
|
109 |
+
public function load_assets() {
|
110 |
+
wp_enqueue_style(
|
111 |
+
'postpagestyle',
|
112 |
+
POSTPAGE_URL . 'admin/assets/css/post-page_styles.css',
|
113 |
+
array(),
|
114 |
+
'20190311'
|
115 |
+
);
|
116 |
+
|
117 |
+
wp_enqueue_script(
|
118 |
+
'postpagescript',
|
119 |
+
POSTPAGE_URL . 'admin/assets/js/post-page_scripts.js',
|
120 |
+
array( 'jquery' ),
|
121 |
+
'20190311',
|
122 |
+
true
|
123 |
+
);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Plugin Settings page - includes view for the page.
|
128 |
+
*/
|
129 |
+
public function plugin_page() {
|
130 |
+
require_once 'admin/views/help-main.php';
|
131 |
+
}
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Instantiate the Plugin - called using the plugins_loaded action hook.
|
137 |
+
*/
|
138 |
+
function init_ic_posts_in_page() {
|
139 |
+
new ICAddPostsToPage();
|
140 |
+
}
|
141 |
+
|
142 |
+
add_action( 'plugins_loaded', 'init_ic_posts_in_page' );
|
readme.txt
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
=== Posts in Page ===
|
2 |
-
Contributors: ivycat, sewmyheadon, anvilzephyr, jasonm4563, pjackson1972
|
3 |
Tags: shortcode, pages, posts, custom post types, taxonomy, terms
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.1
|
6 |
-
Stable tag: 1.4.
|
7 |
License: GPLv2 or later
|
8 |
-
License URI:
|
9 |
|
10 |
Easily add one or more posts to any page using simple shortcodes.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
Easily add one or more posts to any page using simple shortcodes.
|
15 |
|
16 |
-
Supports categories, tags, custom post types, custom taxonomies, and more.
|
17 |
|
18 |
-
You can get all of the same functionality provided by this plugin by modifying your theme's template files; this plugin just makes it easy for anyone to _pull_ posts into other areas of the site without having to
|
19 |
|
20 |
-
Plugin is depending upon your theme's styling; version 1.x of this plugin _does not_ contain native styles.
|
21 |
|
22 |
This is a minimal plugin, function over form. Give us feedback, suggestions, bug reports, and any other contributions on the in the plugin's [GitHub repository](https://github.com/ivycat/posts-in-page).
|
23 |
|
@@ -26,11 +26,11 @@ This is a minimal plugin, function over form. Give us feedback, suggestions, bug
|
|
26 |
You can install from within WordPress using the Plugin/Add New feature, or if you wish to manually install:
|
27 |
|
28 |
1. Download the plugin.
|
29 |
-
1. Upload the entire `posts-in-page` directory to your plugins folder
|
30 |
1. Activate the plugin from the plugin page in your WordPress Dashboard
|
31 |
1. Start embedding posts in whatever pages you like using shortcodes.
|
32 |
|
33 |
-
### Shortcode Usage
|
34 |
|
35 |
To 'pull' posts into a page, you can:
|
36 |
|
@@ -115,13 +115,21 @@ There are several hooks you can use to filter the output of your template files:
|
|
115 |
|
116 |
= What is the point of this plugin? =
|
117 |
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
-
|
121 |
|
122 |
-
|
123 |
|
124 |
-
|
|
|
|
|
125 |
|
126 |
For file housekeeping, you can also create a _posts-in-page_ folder in your theme to store all of your custom templates. It isn't necessary to specify the _posts-in-page_ folder in your shortcode - Posts in Page will find it automatically.
|
127 |
You can even use multiple templates for use with different shortcodes.
|
@@ -130,53 +138,67 @@ You can even use multiple templates for use with different shortcodes.
|
|
130 |
|
131 |
Absolutely.
|
132 |
|
133 |
-
=
|
134 |
|
135 |
You bet.
|
136 |
|
137 |
-
= Will it make me coffee?
|
138 |
|
139 |
Not likely, but let us know if it does; then we'll *know* we have something special.
|
140 |
|
|
|
|
|
|
|
|
|
141 |
== Screenshots ==
|
142 |
|
143 |
1. Embed a shortcode into a page, and it will automatically pull in the post(s) you need.
|
144 |
-
2. Embed
|
|
|
145 |
|
146 |
== Changelog ==
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
= 1.4.1 =
|
149 |
* Fix wp_reset_query bug
|
150 |
* Patch pagination to make it more reliable across themes.
|
151 |
|
152 |
= 1.4.0 =
|
153 |
-
* Add templates folder to structure and moved default template there
|
154 |
-
* Fix pagination issues #42, 59
|
155 |
-
* Fix bug preventing including or excluding multiple post_types or categories
|
156 |
-
* Add a few new date-based shortcode arguments including `date=` and `from_date=` and `to_date
|
157 |
-
* Document post format support, new shortcode arguments
|
158 |
-
* Code cleanup
|
159 |
-
* Updates to admin page layout and documentation
|
160 |
|
161 |
= 1.3.1 =
|
162 |
-
* File header housekeeping
|
163 |
-
* Code cleanup
|
164 |
-
* Fix WPML compatibility issue (thanks @azrall)
|
165 |
-
* Document new shortcode functions including `exclude_ids`, `more_tag
|
166 |
|
167 |
= 1.3.0 =
|
168 |
-
* File reorganization / housekeeping
|
169 |
-
* Admin UI cleanup
|
170 |
* Security: Fixed [directory traversal vulnerability](https://www.pluginvulnerabilities.com/2017/02/13/authenticated-local-file-inclusion-lfi-vulnerability-in-posts-in-page/).
|
171 |
-
* Added ability to optionally include private posts - Thanks StarsoftAnalysis!
|
172 |
|
173 |
-
= 1.2.4 =
|
174 |
-
* now you can set `more_tag=""` to remove the `[...] …` that unfortunetly shows up as `&hellip
|
175 |
|
176 |
-
= 1.2.3 =
|
177 |
* Added minor doc tweaks.
|
178 |
|
179 |
-
= 1.2.2 =
|
180 |
* Added pagination, tweaked to turn off by default.
|
181 |
* Bug fixes.
|
182 |
|
@@ -184,8 +206,8 @@ Not likely, but let us know if it does; then we'll *know* we have something spec
|
|
184 |
* Added code to allow ignoring, or showing of sticky posts. By default, sticky posts are ignored, but can be re-enabled using the shortcode `[ic_add_posts ignore_sticky_posts='no']`.
|
185 |
|
186 |
= 1.2.0 =
|
187 |
-
* Code maintenance to better comply with standards
|
188 |
-
* Added post pagination
|
189 |
* Plugin now honors default post reading settings under Settings/Reading in the WordPress Dashboard.
|
190 |
* Improved and simplified documentation.
|
191 |
|
@@ -202,8 +224,8 @@ Not likely, but let us know if it does; then we'll *know* we have something spec
|
|
202 |
* Fixed template bug introduced by comments.
|
203 |
|
204 |
= 1.0.8 =
|
205 |
-
* Code cleanup & indentation
|
206 |
-
* Added comments and notes to output template file: `posts_loop_template.php
|
207 |
|
208 |
= 1.0.7 =
|
209 |
* Added Help Page under Setting in WP Dashboard.
|
@@ -219,19 +241,22 @@ Not likely, but let us know if it does; then we'll *know* we have something spec
|
|
219 |
|
220 |
== Upgrade Notice ==
|
221 |
|
|
|
|
|
|
|
222 |
= 1.4.1 =
|
223 |
* Critical bug fixes. Please upgrade.
|
224 |
|
225 |
= 1.4.0 =
|
226 |
* Bug fixes, new shortcodes, and code improvements. Please upgrade.
|
227 |
|
228 |
-
= 1.3.0 =
|
229 |
* Important security and version updates. Please upgrade.
|
230 |
|
231 |
-
= 1.2.4 =
|
232 |
* Presentational fixes: clean up whitespace, extra tabs, add in customization of more tag.
|
233 |
|
234 |
-
= 1.2.3 =
|
235 |
* Housekeeping only; not urgent.
|
236 |
|
237 |
= 1.2.2 =
|
@@ -269,5 +294,3 @@ Not likely, but let us know if it does; then we'll *know* we have something spec
|
|
269 |
|
270 |
= 1.0.3 =
|
271 |
* Added single post or specific post capabilities. Important feature.
|
272 |
-
|
273 |
-
|
1 |
=== Posts in Page ===
|
2 |
+
Contributors: ivycat, sewmyheadon, anvilzephyr, bradyvercher, jasonm4563, pjackson1972
|
3 |
Tags: shortcode, pages, posts, custom post types, taxonomy, terms
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 5.1
|
6 |
+
Stable tag: 1.4.2
|
7 |
License: GPLv2 or later
|
8 |
+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
Easily add one or more posts to any page using simple shortcodes.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
Easily add one or more posts to any page using simple shortcodes.
|
15 |
|
16 |
+
Supports categories, tags, custom post types, custom taxonomies, date ranges, post status, and much more.
|
17 |
|
18 |
+
You can get all of the same functionality provided by this plugin by modifying your theme's template files; this plugin just makes it easy for anyone to _pull_ posts into other areas of the site without having to get their hands dirty with code.
|
19 |
|
20 |
+
Plugin is depending upon your theme's styling; version 1.x of this plugin _does not_ contain native styles.
|
21 |
|
22 |
This is a minimal plugin, function over form. Give us feedback, suggestions, bug reports, and any other contributions on the in the plugin's [GitHub repository](https://github.com/ivycat/posts-in-page).
|
23 |
|
26 |
You can install from within WordPress using the Plugin/Add New feature, or if you wish to manually install:
|
27 |
|
28 |
1. Download the plugin.
|
29 |
+
1. Upload the entire `posts-in-page` directory to your plugins folder
|
30 |
1. Activate the plugin from the plugin page in your WordPress Dashboard
|
31 |
1. Start embedding posts in whatever pages you like using shortcodes.
|
32 |
|
33 |
+
### Shortcode Usage
|
34 |
|
35 |
To 'pull' posts into a page, you can:
|
36 |
|
115 |
|
116 |
= What is the point of this plugin? =
|
117 |
|
118 |
+
Posts in Page makes it easy to output or embed the posts, pages, or custom post types in any page without modifying WordPress theme templates.
|
119 |
+
|
120 |
+
= Does it work with Gutenberg? =
|
121 |
+
|
122 |
+
Absolutely. Just use a Gutenberg Shortcode block or the Classic Edit block to add your shortcode.
|
123 |
+
|
124 |
+
= Wait! The posts aren't styled like the posts on the rest of my site.
|
125 |
|
126 |
+
That is likely true. Currently, Posts in Page doesn't output any styles; just some basic markup. To change how the posts appear on the page, you'll need to change the _output template_.
|
127 |
|
128 |
+
= How do I change the output template? =
|
129 |
|
130 |
+
Simply copy the `posts_loop_template.php` to your theme directory and make changes as necessary.
|
131 |
+
|
132 |
+
You can even rename it - but make sure to indicate that in the shortcode using the `template='my-new-template-name.php'`.
|
133 |
|
134 |
For file housekeeping, you can also create a _posts-in-page_ folder in your theme to store all of your custom templates. It isn't necessary to specify the _posts-in-page_ folder in your shortcode - Posts in Page will find it automatically.
|
135 |
You can even use multiple templates for use with different shortcodes.
|
138 |
|
139 |
Absolutely.
|
140 |
|
141 |
+
= Does it work with custom taxonomies?
|
142 |
|
143 |
You bet.
|
144 |
|
145 |
+
= Will it make me coffee? =
|
146 |
|
147 |
Not likely, but let us know if it does; then we'll *know* we have something special.
|
148 |
|
149 |
+
= How can I help? =
|
150 |
+
|
151 |
+
We'd love feedback, issues, pull requests, and ideas on the [Posts in Page GitHub repo](https://github.com/ivycat/posts-in-page).
|
152 |
+
|
153 |
== Screenshots ==
|
154 |
|
155 |
1. Embed a shortcode into a page, and it will automatically pull in the post(s) you need.
|
156 |
+
2. Embed shortcode using a Gutenberg shortcode block.
|
157 |
+
3. Embed shortcodes directly in your template using `do_shortcode`.
|
158 |
|
159 |
== Changelog ==
|
160 |
|
161 |
+
= 1.4.2 =
|
162 |
+
* Thanks to Brady Vercher (@bradyvercher) for the thorough code review and fixes.
|
163 |
+
* Cleanup code to better conform to WP Coding standards and remove legacy cruft.
|
164 |
+
* PHPCS configuration.
|
165 |
+
* Update docblock and comments.
|
166 |
+
* Remove legacy i18n code.
|
167 |
+
* Escaping output of URLs, translation strings, and more.
|
168 |
+
* Updated enqueueing to add version for cache busting, add missing jQuery dependency, load admin script in footer.
|
169 |
+
|
170 |
= 1.4.1 =
|
171 |
* Fix wp_reset_query bug
|
172 |
* Patch pagination to make it more reliable across themes.
|
173 |
|
174 |
= 1.4.0 =
|
175 |
+
* Add templates folder to structure and moved default template there.
|
176 |
+
* Fix pagination issues #42, 59.
|
177 |
+
* Fix bug preventing including or excluding multiple post_types or categories.
|
178 |
+
* Add a few new date-based shortcode arguments including `date=` and `from_date=` and `to_date=`.
|
179 |
+
* Document post format support, new shortcode arguments.
|
180 |
+
* Code cleanup.
|
181 |
+
* Updates to admin page layout and documentation.
|
182 |
|
183 |
= 1.3.1 =
|
184 |
+
* File header housekeeping.
|
185 |
+
* Code cleanup.
|
186 |
+
* Fix WPML compatibility issue (thanks @azrall).
|
187 |
+
* Document new shortcode functions including `exclude_ids`, `more_tag`.
|
188 |
|
189 |
= 1.3.0 =
|
190 |
+
* File reorganization / housekeeping.
|
191 |
+
* Admin UI cleanup.
|
192 |
* Security: Fixed [directory traversal vulnerability](https://www.pluginvulnerabilities.com/2017/02/13/authenticated-local-file-inclusion-lfi-vulnerability-in-posts-in-page/).
|
193 |
+
* Added ability to optionally include private posts - Thanks, StarsoftAnalysis!
|
194 |
|
195 |
+
= 1.2.4 =
|
196 |
+
* now you can set `more_tag=""` to remove the `[...] …` that unfortunetly shows up as `&hellip`.
|
197 |
|
198 |
+
= 1.2.3 =
|
199 |
* Added minor doc tweaks.
|
200 |
|
201 |
+
= 1.2.2 =
|
202 |
* Added pagination, tweaked to turn off by default.
|
203 |
* Bug fixes.
|
204 |
|
206 |
* Added code to allow ignoring, or showing of sticky posts. By default, sticky posts are ignored, but can be re-enabled using the shortcode `[ic_add_posts ignore_sticky_posts='no']`.
|
207 |
|
208 |
= 1.2.0 =
|
209 |
+
* Code maintenance to better comply with standards.
|
210 |
+
* Added post pagination.
|
211 |
* Plugin now honors default post reading settings under Settings/Reading in the WordPress Dashboard.
|
212 |
* Improved and simplified documentation.
|
213 |
|
224 |
* Fixed template bug introduced by comments.
|
225 |
|
226 |
= 1.0.8 =
|
227 |
+
* Code cleanup & indentation.
|
228 |
+
* Added comments and notes to output template file: `posts_loop_template.php`.
|
229 |
|
230 |
= 1.0.7 =
|
231 |
* Added Help Page under Setting in WP Dashboard.
|
241 |
|
242 |
== Upgrade Notice ==
|
243 |
|
244 |
+
= 1.4.2 =
|
245 |
+
* Code review, cleanup. Minor fixes and security updates. Please upgrade.
|
246 |
+
|
247 |
= 1.4.1 =
|
248 |
* Critical bug fixes. Please upgrade.
|
249 |
|
250 |
= 1.4.0 =
|
251 |
* Bug fixes, new shortcodes, and code improvements. Please upgrade.
|
252 |
|
253 |
+
= 1.3.0 =
|
254 |
* Important security and version updates. Please upgrade.
|
255 |
|
256 |
+
= 1.2.4 =
|
257 |
* Presentational fixes: clean up whitespace, extra tabs, add in customization of more tag.
|
258 |
|
259 |
+
= 1.2.3 =
|
260 |
* Housekeeping only; not urgent.
|
261 |
|
262 |
= 1.2.2 =
|
294 |
|
295 |
= 1.0.3 =
|
296 |
* Added single post or specific post capabilities. Important feature.
|
|
|
|
templates/posts_loop_template.php
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
* @
|
6 |
-
* @
|
7 |
-
* @
|
8 |
-
* @
|
|
|
|
|
9 |
*/
|
|
|
10 |
?>
|
11 |
|
12 |
<!-- NOTE: If you need to make changes to this file, copy it to your current theme's main
|
@@ -15,33 +18,61 @@
|
|
15 |
<!-- Post Wrap Start-->
|
16 |
<div class="post hentry ivycat-post">
|
17 |
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
replace the_excerpt(); with the_content(); below. -->
|
23 |
-
|
24 |
<?php the_excerpt(); ?>
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
<?php
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
</span>
|
33 |
-
|
34 |
<?php endif; ?>
|
35 |
<?php
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
</span>
|
41 |
-
|
42 |
<?php endif; ?>
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
</div>
|
47 |
<!-- // Post Wrap End -->
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Template for displaying a post in the [ic_add_posts] shortcode.
|
4 |
+
*
|
5 |
+
* @package Posts_in_Page
|
6 |
+
* @author Eric Amundson <eric@ivycat.com>
|
7 |
+
* @copyright Copyright (c) 2019, IvyCat, Inc.
|
8 |
+
* @link https://ivycat.com
|
9 |
+
* @since 1.0.0
|
10 |
+
* @license GPL-2.0-or-later
|
11 |
*/
|
12 |
+
|
13 |
?>
|
14 |
|
15 |
<!-- NOTE: If you need to make changes to this file, copy it to your current theme's main
|
18 |
<!-- Post Wrap Start-->
|
19 |
<div class="post hentry ivycat-post">
|
20 |
|
21 |
+
<!-- This outputs the post TITLE -->
|
22 |
+
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
23 |
|
24 |
+
<!-- This outputs the post EXCERPT. To display full content including images and html,
|
25 |
replace the_excerpt(); with the_content(); below. -->
|
26 |
+
<div class="entry-summary">
|
27 |
<?php the_excerpt(); ?>
|
28 |
+
</div>
|
29 |
|
30 |
+
<!-- This outputs the post META information -->
|
31 |
+
<div class="entry-utility">
|
32 |
+
<?php
|
33 |
+
/* translators: used between list items, there is a space after the comma. */
|
34 |
+
$categories_list = get_the_category_list( __( ', ', 'posts-in-page' ) );
|
35 |
+
if ( $categories_list ) :
|
36 |
+
?>
|
37 |
+
<span class="cat-links">
|
38 |
+
<?php
|
39 |
+
printf(
|
40 |
+
/* translators: 1: posted in label. 2: list of categories. */
|
41 |
+
'<span class="entry-utility-prep entry-utility-prep-cat-links">%1$s</span> %2$s',
|
42 |
+
esc_html__( 'Posted in', 'posts-in-page' ),
|
43 |
+
$categories_list // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
44 |
+
);
|
45 |
+
?>
|
46 |
</span>
|
47 |
+
<span class="meta-sep">|</span>
|
48 |
<?php endif; ?>
|
49 |
<?php
|
50 |
+
/* translators: used between list items, there is a space after the comma. */
|
51 |
+
$tags_list = get_the_tag_list( '', __( ', ', 'posts-in-page' ) );
|
52 |
+
if ( $tags_list ) :
|
53 |
+
?>
|
54 |
+
<span class="tag-links">
|
55 |
+
<?php
|
56 |
+
printf(
|
57 |
+
/* translators: 1: tagged label. 2: list of tags. */
|
58 |
+
'<span class="entry-utility-prep entry-utility-prep-tag-links">%1$s</span> %2$s',
|
59 |
+
esc_html__( 'Tagged', 'posts-in-page' ),
|
60 |
+
$tags_list // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
61 |
+
);
|
62 |
+
?>
|
63 |
</span>
|
64 |
+
<span class="meta-sep">|</span>
|
65 |
<?php endif; ?>
|
66 |
+
<span class="comments-link">
|
67 |
+
<?php
|
68 |
+
comments_popup_link(
|
69 |
+
esc_html__( 'Leave a comment', 'posts-in-page' ),
|
70 |
+
esc_html__( '1 Comment', 'posts-in-page' ),
|
71 |
+
esc_html__( '% Comments', 'posts-in-page' )
|
72 |
+
);
|
73 |
+
?>
|
74 |
+
</span>
|
75 |
+
<?php edit_post_link( esc_html__( 'Edit', 'posts-in-page' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
|
76 |
+
</div>
|
77 |
</div>
|
78 |
<!-- // Post Wrap End -->
|