Posts in Page - Version 1.4.2

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 Icon 128x128 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 CHANGED
@@ -2,216 +2,216 @@
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
  }
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
- $('#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
- });
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 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+
11
  */
 
12
  ?>
13
 
14
  <div class="wrap">
15
 
16
- <div id="icon-options-general" class="icon32"></div>
17
- <h1><?php esc_attr_e( 'Posts in Page', 'wp_admin_style' ); ?></h1>
18
-
19
- <div id="poststuff">
20
-
21
- <div id="post-body" class="metabox-holder columns-2">
22
-
23
- <!-- main content -->
24
- <div id="post-body-content">
25
-
26
- <div class="meta-box-sortables ui-sortable">
27
-
28
- <div class="postbox">
29
-
30
- <div class="handlediv" title="Click to toggle"><br></div>
31
- <!-- Toggle -->
32
-
33
- <h2 class="hndle">
34
- <span><?php esc_attr_e( 'How to use Posts in Page', 'wp_admin_style' ); ?></span>
35
- </h2>
36
-
37
- <div class="inside">
38
-
39
- <p>To 'pull' posts into a page, you can either:</p>
40
-
41
- <ol>
42
- <li><a href="#place-a-shortcode-wordpress-editor">Place a shortcode in the WordPress
43
- editor</a>, or
44
- </li>
45
- <li><a href="#embed-php-function-wordpress-editor">Embed a PHP function in a theme
46
- template file</a></li>
47
- </ol>
48
-
49
- <h4 name="place-a-shortcode-wordpress-editor" id="place-a-shortcode-wordpress-editor">Place
50
- a Shortcode in the WordPress Editor</h4>
51
-
52
- <table class="widefat">
53
- <thead>
54
- <tr>
55
- <th>Task</th>
56
- <th>Shortcode</th>
57
- <th>Notes</th>
58
- </tr>
59
- </thead>
60
- <tfoot>
61
- <tr>
62
- <th>Task</th>
63
- <th>Shortcode</th>
64
- <th>Notes</th>
65
- </tr>
66
- </tfoot>
67
- <tbody>
68
- <tr>
69
- <td>Add all posts</td>
70
- <td><code>[ic_add_posts]</code></td>
71
- <td><?php _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>
72
- </tr>
73
- <tr>
74
- <td>Show posts by Post Type</td>
75
- <td><code>[ic_add_posts post_type='post_type']</code></td>
76
- <td><?php _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' ); ?>
77
- <code>post_type='post_type1,post_type2'</code>)
78
- </td>
79
- </tr>
80
- <tr>
81
- <td>Show specific number of posts</td>
82
- <td><code>[ic_add_posts showposts='5']</code></td>
83
- <td><?php _e( 'Limit number of posts (or override default setting)', 'posts-in-page' ); ?></td>
84
- </tr>
85
- <tr>
86
- <td>Change post order</td>
87
- <td><code>[ic_add_posts orderby='title' order='ASC']</code></td>
88
- <td><?php _e( 'orderby title - supports all WP orderby variables. Order is optional, WP default', 'posts-in-page' ); ?></td>
89
- </tr>
90
- <tr>
91
- <td>Show posts by ID</td>
92
- <td><code>[ic_add_posts ids='1,2,3']</code></td>
93
- <td><?php _e( 'Show one or many posts by specifying the post ID(s) ( specify all post types )', 'posts-in-page' ); ?></td>
94
- </tr>
95
- <tr>
96
- <td>Exclude posts by ID</td>
97
- <td><code>[ic_add_posts exclude_ids='4,5,6']</code></td>
98
- <td><?php _e( 'Exclude one or more posts by specifying the post ID(s) ( specify all post types )', 'posts-in-page' ); ?></td>
99
- </tr>
100
- <tr>
101
- <td>Include posts from specific categories</td>
102
- <td><code>[ic_add_posts category='category-slug']</code></td>
103
- <td><?php _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>
104
- </tr>
105
- <tr>
106
- <td>Exclude posts from specific categories</td>
107
- <td><code>[ic_add_posts exclude_category='category-slug']</code></td>
108
- <td><?php _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>
109
- </tr>
110
- <tr>
111
- <td>Specify tags</td>
112
- <td><code>[ic_add_posts tag='tag-slug']</code></td>
113
- <td><?php _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>
114
- </tr>
115
- <tr>
116
- <td>Specify custom taxonomy</td>
117
- <td><code>[ic_add_posts tax='taxonomy' term='term']</code></td>
118
- <td><?php _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>
119
- </tr>
120
- <tr>
121
- <td>Change output template</td>
122
- <td><code>[ic_add_posts template='template-in-theme-dir.php']</code></td>
123
- <td><?php _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>
124
- </tr>
125
- <tr>
126
- <td>Sticky posts</td>
127
- <td><code>[ic_add_posts ignore_sticky_posts='no']</code></td>
128
- <td><?php _e( "Show sticky posts too (they're ignored by default)", 'posts-in-page' ); ?></td>
129
- </tr>
130
- <tr>
131
- <td>Pagination</td>
132
- <td><code>[ic_add_posts paginate='yes']</code></td>
133
- <td><?php _e( 'use pagination links (off by default)', 'posts-in-page' ); ?></td>
134
- </tr>
135
- <tr>
136
- <td>Pagination - Post navigation links</td>
137
- <td><code>[ic_add_posts label_next='Next' label_previous='Previous']</code></td>
138
- <td><?php _e( 'Change the post navigation labels', 'posts-in-page' ); ?></td>
139
- </tr>
140
- <tr>
141
- <td>Post status</td>
142
- <td><code>[ic_add_posts post_status='private']</code></td>
143
- <td><?php _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>
144
- </tr>
145
- <tr>
146
- <td>Post offset</td>
147
- <td><code>[ic_add_posts offset='3']</code></td>
148
- <td><?php _e( 'Displays posts after the offset. An offset=\'3\' will show all posts from the 4th one onward.', 'posts-in-page' ); ?></td>
149
- </tr>
150
- <tr>
151
- <td>Specific Dates</td>
152
- <td><code>[ic_add_posts date='today']</code></td>
153
- <td><?php _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>
154
- </tr>
155
- <tr>
156
- <td>Date Ranges</td>
157
- <td><code>[ic_add_posts from_date='15-01-2016' to_date='31-12-2016']</code></td>
158
- <td><?php _e( 'Shows posts published within a specified absolute date range', 'posts-in-page' ); ?></td>
159
- </tr>
160
- <tr>
161
- <td>Read more</td>
162
- <td><code>[ic_add_posts more_tag='Read more...']</code></td>
163
- <td><?php _e( 'Set the link text for read more links shown after an excerpt', 'posts-in-page' ); ?></td>
164
- </tr>
165
- <tr>
166
- <td>Custom error message</td>
167
- <td><code>[ic_add_posts none_found='No Posts Found']</code></td>
168
- <td><?php _e( 'Custom message to display if no posts are found', 'posts-in-page' ); ?></td>
169
- </tr>
170
- </tbody>
171
- </table>
172
- <p><?php _e( 'Or any combination of the above.', 'posts-in-page' ); ?></p>
173
-
174
- <h4 name="embed-php-function-wordpress-editor"
175
- id="embed-php-function-wordpress-editor"><?php _e( 'Embed a PHP function in a theme template file', 'posts-in-page' ); ?></h4>
176
-
177
- <p><?php _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>
178
-
179
- <pre><code>&lt;?php echo do_shortcode("[shortcode]"); ?&gt;</code></pre>
180
- </div>
181
- <!-- .inside -->
182
-
183
- </div>
184
- <!-- .postbox -->
185
-
186
- </div>
187
- <!-- .meta-box-sortables .ui-sortable -->
188
-
189
- </div>
190
- <!-- post-body-content -->
191
-
192
- <!-- sidebar -->
193
- <div id="postbox-container-1" class="postbox-container">
194
-
195
- <div class="meta-box-sortables">
196
-
197
- <div class="postbox help-contributing">
198
-
199
- <div class="handlediv" title="Click to toggle"><br></div>
200
- <!-- Toggle -->
201
-
202
- <h2><span><?php esc_attr_e(
203
- 'Help & Contributing', 'wp_admin_style'
204
- ); ?></span></h2>
205
-
206
- <div class="inside">
207
- <div class="meta-box-sortables" style="min-height: 0">
208
- <div id="ivycat_contribute">
209
- <div class="inside_wrap">
210
- <h4>Questions, bugs, or great ideas? <span
211
- class="dashicons dashicons-format-status"></span></h4>
212
- <ul>
213
- <li><a href="https://wordpress.org/support/plugin/posts-in-page"> Get help
214
- on our plugin support page</a> or
215
- </li>
216
- <li><a href="https://github.com/ivycat/posts-in-page/"> Report bugs and
217
- contribute on Github</a></li>
218
- </div>
219
- </div>
220
- </div>
221
- </div>
222
- <!-- .inside -->
223
-
224
- </div>
225
- <!-- .postbox -->
226
- <div class="postbox">
227
-
228
- <div class="handlediv" title="Click to toggle"><br></div>
229
- <!-- Toggle -->
230
-
231
- <h2 class="hndle"><span><?php esc_attr_e(
232
- 'Connect with IvyCat!', 'wp_admin_style'
233
- ); ?></span></h2>
234
-
235
- <div class="inside">
236
- <div class="inside_wrap">
237
- <!-- Begin MailChimp Signup Form -->
238
- <div id="mc_embed_signup" class="clearfix">
239
- <form action="//ivycat.us1.list-manage.com/subscribe/post?u=599f2f6b712f346e11c2930d4&amp;id=6ee02404ab"
240
- method="post" id="mc-embedded-subscribe-form"
241
- name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
242
- <label for="mce-EMAIL">Signup for email updates</label>
243
- <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL"
244
- placeholder="email address" required>
245
- <input type="submit" value="Subscribe" name="subscribe"
246
- id="mc-embedded-subscribe" class="button">
247
- </form>
248
- </div>
249
- <!--End mc_embed_signup-->
250
-
251
- <hr/>
252
-
253
- <ul class="ivycat-social clearfix">
254
- <li><a href="https://twitter.com/ivycatweb"><span
255
- class="dashicons dashicons-twitter"></span> <span
256
- class="screen-reader-text">Twitter</span></span></a></li>
257
- <li><a href="https://www.facebook.com/ivycatweb"><span
258
- class="dashicons dashicons-facebook"></span> <span
259
- class="screen-reader-text">Facebook</span></a></li>
260
- <li><a href="https://profiles.wordpress.org/ivycat"><span
261
- class="dashicons dashicons-wordpress"></span> <span
262
- class="screen-reader-text">WordPress.org</span></a></li>
263
- <li class="ic_mc"><a href="http://eepurl.com/b3_65" target="_blank"><span
264
- class="dashicons dashicons-email"></span> <span
265
- class="screen-reader-text">Sign up for our free newsletter!</span></a>
266
- </li>
267
- </ul>
268
-
269
- </div>
270
- </div>
271
- <!-- .inside -->
272
-
273
- </div>
274
- <!-- .postbox -->
275
-
276
- <div class="postbox">
277
-
278
- <div class="handlediv" title="Click to toggle"><br></div>
279
- <!-- Toggle -->
280
-
281
- <h2 class="hndle"><span><?php esc_attr_e(
282
- 'Spread the word', 'wp_admin_style'
283
- ); ?></span></h2>
284
-
285
- <div class="inside">
286
- <div class="inside_wrap">
287
- <h4>Help make this plugin better</h4>
288
- <ul>
289
- <li><a href="https://wordpress.org/support/plugin/posts-in-page/reviews/#new-post">Rate
290
- <div class="ivycat-rating"><span
291
- class="dashicons dashicons-star-filled"></span><span
292
- class="dashicons dashicons-star-filled"></span><span
293
- class="dashicons dashicons-star-filled"></span><span
294
- class="dashicons dashicons-star-filled"></span><span
295
- class="dashicons dashicons-star-filled"></span></div>
296
- on WordPress.org</a></li>
297
- <li>
298
- <a href="https://twitter.com/home/?status=Check%20out%20the%20Posts%20in%20Page%20WordPress%20plugin%20from%20IvyCat!%20http%3A%2F%2Fbit.ly%2F1bmI8pS">Tweet
299
- about Posts in Page</a></li>
300
- </ul>
301
- </div>
302
- </div>
303
- <!-- .inside -->
304
-
305
- </div>
306
- <!-- .postbox -->
307
- <div class="postbox signature clearfix">
308
-
309
- <div class="handlediv" title="Click to toggle"><br></div>
310
- <!-- Toggle -->
311
-
312
- <h2 class="hndle"><span><?php esc_attr_e(
313
- 'IvyCat Web Services', 'wp_admin_style'
314
- ); ?></span></h2>
315
-
316
- <div class="inside">
317
- <div class="inside_wrap">
318
- <img src="https://s.gravatar.com/avatar/f1c6ff76072edfd217215f3acd412c26?s=80?s=200"
319
- class="ivycat-gravatar alignleft"/>
320
- <div class="ivycat_text_wrap alignleft">
321
- <ul class="link-list">
322
- <li><a href="https://ivycat.com/wordpress/wordpress-support-maintenance/">WP
323
- Maintenance & Support</a></li>
324
- <li><a href="http://ivycat.com/web-design/">WordPress Development</a></li>
325
- </ul>
326
- </div>
327
- </div>
328
- </div>
329
- <!-- .inside -->
330
-
331
- </div>
332
- <!-- .postbox -->
333
- </div>
334
- <!-- .meta-box-sortables -->
335
-
336
- </div>
337
- <!-- #postbox-container-1 .postbox-container -->
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>&lt;?php echo do_shortcode("[shortcode]"); ?&gt;</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&amp;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 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+
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
- class ICPagePosts {
18
-
19
- protected $args = array();
20
-
21
- public function __construct( $atts ) {
22
- $this->set_default_args(); //set default args
23
- $this->set_args( $atts );
24
- }
25
-
26
- protected function set_default_args() {
27
- $this->args = array(
28
- 'post_type' => 'post',
29
- 'post_status' => 'publish',
30
- 'orderby' => 'date',
31
- 'order' => 'DESC',
32
- 'paginate' => false,
33
- 'template' => false,
34
- 'label_next' => __( 'Next', 'posts-in-page' ),
35
- 'label_previous' => __( 'Previous', 'posts-in-page' ),
36
- 'date_query' => '',
37
- 'none_found' => '',
38
- 'paged' => false,
39
- );
40
- }
41
-
42
- protected function get_paged_query_var() {
43
- if ( get_query_var( 'paged' ) ) {
44
- $paged = get_query_var( 'paged' );
45
- } elseif ( get_query_var( 'page' ) ) {
46
- $paged = get_query_var( 'page' );
47
- } else {
48
- $paged = 1;
49
- }
50
-
51
- return $paged;
52
- }
53
- /**
54
- * Spits out the posts, in a gentlemanly way
55
- *
56
- * @return string output of template file
57
- */
58
- public function output_posts() {
59
- if ( ! $this->args ) {
60
- return '';
61
- }
62
- if ( $this->args['paginate'] ) {
63
- $this->get_paged_query_var();
64
- $this->args['paged'] = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
65
- }
66
- // commandeering wp_query for pagination quirkiness
67
- global $wp_query;
68
- $temp = $wp_query;
69
- $wp_query = null;
70
- $wp_query = apply_filters( 'posts_in_page_results', new WP_Query( $this->args ) ); // New WP_Query object
71
-
72
- $output = '';
73
- if ( have_posts() ) {
74
- while ( have_posts() ):
75
- $output .= self::add_template_part( $wp_query );
76
- endwhile;
77
-
78
- if ( $this->args['paginate'] ) {
79
- $output .= apply_filters( 'posts_in_page_paginate', $this->paginate_links() );
80
- }
81
- } else {
82
- $output = '<div class="post hentry ivycat-post"><span class="pip-not-found">' . esc_html( $this->args['none_found'] ) . '</span></div>';
83
- }
84
-
85
- // restore wp_query
86
- $wp_query = null;
87
- $wp_query = $temp;
88
- wp_reset_query();
89
- remove_filter( 'excerpt_more', array( &$this, 'custom_excerpt_more' ) );
90
-
91
- return $output;
92
- }
93
-
94
-
95
- protected function paginate_links() {
96
-
97
- $prev = get_previous_posts_link( $this->args['label_previous'] );
98
- $next = get_next_posts_link( $this->args['label_next'] );
99
-
100
- if ( $prev || $next ) {
101
- $prev_link = $prev ? "<li class='pip-nav-prev'>$prev</li>" : '';
102
- $next_link = $next ? "<li class='pip-nav-next'>$next</li>" : '';
103
-
104
- return "<ul class='pip-nav'>$prev_link $next_link</ul>";
105
- }
106
-
107
- return '';
108
-
109
- }
110
-
111
-
112
- /**
113
- * Build additional Arguments for the WP_Query object
114
- *
115
- * @param array $atts Attributes for building the $args array.
116
- */
117
- protected function set_args( $atts ) {
118
- global $wp_query;
119
- $this->args['posts_per_page'] = get_option( 'posts_per_page' );
120
- // parse the arguments using the defaults
121
- $this->args = wp_parse_args( $atts, $this->args );
122
- // multiple post types are indicated, pass as an array
123
- if ( strpos( $this->args['post_type'], ',' ) ) {
124
- $post_types = explode( ',', $this->args['post_type'] );
125
- $this->args['post_type'] = $post_types;
126
- }
127
-
128
- // Show specific posts by ID
129
- if ( isset( $atts['ids'] ) ) {
130
- $post_ids = explode( ',', $atts['ids'] );
131
- $this->args['post__in'] = $post_ids;
132
- $this->args['posts_per_page'] = count( $post_ids );
133
- }
134
-
135
- // Use a specified template
136
- if ( isset( $atts['template'] ) ) {
137
- $this->args['template'] = $atts['template'];
138
- }
139
-
140
- // get posts in a certain category by name (slug)
141
- if ( isset( $atts['category'] ) ) {
142
- $this->args['category_name'] = $atts['category'];
143
- } elseif ( isset( $atts['cats'] ) ) {
144
- // get posts in a certain category by id
145
- $this->args['cat'] = $atts['cats'];
146
- }
147
-
148
- // Do a tax query, tax and term a required.
149
- if ( isset( $atts['tax'] ) ) {
150
- if ( isset( $atts['term'] ) ) {
151
- $terms = explode( ',', $atts['term'] );
152
- $this->args['tax_query'] = array(
153
- array(
154
- 'taxonomy' => $atts['tax'],
155
- 'field' => 'slug',
156
- 'terms' => ( count( $terms ) > 1 ) ? $terms : $atts['term'],
157
- )
158
- );
159
- }
160
- }
161
-
162
- // get posts with a certain tag
163
- if ( isset( $atts['tag'] ) ) {
164
- $this->args['tag'] = $atts['tag'];
165
- }
166
-
167
- // override default post_type argument ('publish')
168
- if ( isset( $atts['post_status'] ) ) {
169
- $this->args['post_status'] = $atts['post_status'];
170
- }
171
-
172
- // exclude posts with certain category by name (slug)
173
- if ( isset( $atts['exclude_category'] ) ) {
174
- $category = $atts['exclude_category'];
175
- if ( strpos( $category, ',' ) ) {
176
- // multiple
177
- $category = explode( ',', $category );
178
- foreach ( $category AS $cat ) {
179
- $term = get_category_by_slug( $cat );
180
- $exclude[] = '-' . $term->term_id;
181
- }
182
- $category = implode( ',', $exclude );
183
- } else {
184
- // single
185
- $term = get_category_by_slug( $category );
186
- $category = '-' . $term->term_id;
187
- }
188
- if ( isset( $this->args['cat'] ) && ! is_null( $this->args['cat'] ) ) {
189
- // merge lists
190
- $this->args['cat'] .= ',' . $category;
191
- }
192
- $this->args['cat'] = $category;
193
- // unset our unneeded variables
194
- unset( $category, $term, $exclude );
195
- }
196
-
197
- // show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed)
198
- if ( isset( $atts['showposts'] ) ) {
199
- $this->args['posts_per_page'] = $atts['showposts'];
200
- }
201
-
202
- // handle pagination (for code, template pagination is in the template)
203
- if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
204
- $this->args['paged'] = $wp_query->query_vars['page'];
205
- }
206
-
207
- if ( ! ( isset( $this->args['ignore_sticky_posts'] ) &&
208
- ( 'no' === strtolower( $this->args['ignore_sticky_posts'] ) ||
209
- 'false' === strtolower( $this->args['ignore_sticky_posts'] ) ) ) ) {
210
-
211
- $this->args['post__not_in'] = get_option( 'sticky_posts' );
212
- }
213
-
214
- $this->args['ignore_sticky_posts'] = isset( $this->args['ignore_sticky_posts'] ) ? $this->shortcode_bool( $this->args['ignore_sticky_posts'] ) : true;
215
-
216
- if ( isset( $this->args['more_tag'] ) ) {
217
- add_filter( 'excerpt_more', array( &$this, 'custom_excerpt_more' ), 11 );
218
- }
219
-
220
- if ( isset( $atts['exclude_ids'] ) ) {
221
- $exclude_posts = explode( ',', $atts['exclude_ids'] );
222
- if ( isset( $this->args['post__not_in'] ) ) {
223
- $this->args['post__not_in'] = array_merge( $this->args['post__not_in'], $exclude_posts );
224
- } else {
225
- $this->args['post__not_in'] = $exclude_posts;
226
- }
227
- }
228
-
229
- if ( isset( $atts['from_date'] ) && isset( $atts['to_date'] ) ) {
230
- $r_from = explode( '-', $atts['from_date'] );
231
- $r_to = explode( '-', $atts['to_date'] );
232
- $this->args['date_query'] = array(
233
- array(
234
- 'after' => array(
235
- 'year' => $r_from[2],
236
- 'month' => $r_from[1],
237
- 'day' => $r_from[0],
238
- ),
239
- 'before' => array(
240
- 'year' => $r_to[2],
241
- 'month' => $r_to[1],
242
- 'day' => $r_to[0],
243
- ),
244
- 'inclusive' => true,
245
- ),
246
- );
247
- } else if ( isset( $atts['from_date'] ) ) {
248
- $r_from = explode( '-', $atts['from_date'] );
249
- $r_to = explode( '-', $atts['to_date'] );
250
- $this->args['date_query'] = array(
251
- array(
252
- 'after' => array(
253
- 'year' => $r_from[2],
254
- 'month' => $r_from[1],
255
- 'day' => $r_from[0],
256
- ),
257
- 'inclusive' => true,
258
- ),
259
- );
260
- }
261
-
262
- $current_time_value = current_time( 'timestamp' );
263
- if ( isset( $atts['date'] ) ) {
264
- $date_data = explode( '-', $atts['date'] );
265
- if ( ! isset( $date_data[1] ) ) {
266
- $date_data[1] = 0;
267
- }
268
- switch ( $date_data[0] ) {
269
- case 'today':
270
- $today = getdate( $current_time_value - ( $date_data[1] * DAY_IN_SECONDS ) );
271
- $this->args['date_query'] = array(
272
- 'year' => $today['year'],
273
- 'month' => $today['mon'],
274
- 'day' => $today['mday'],
275
- );
276
- break;
277
- case 'week':
278
- $week = date( 'W', $current_time_value - $date_data[1] * WEEK_IN_SECONDS );
279
- $year = date( 'Y', $current_time_value - $date_data[1] * WEEK_IN_SECONDS );
280
- $this->args['date_query'] = array(
281
- 'year' => $year,
282
- 'week' => $week,
283
- );
284
- break;
285
- case 'month':
286
- $month = date( 'm', strtotime( ( strval( - $date_data[1] ) . ' Months' ), $current_time_value ) );
287
- $year = date( 'Y', strtotime( ( strval( - $date_data[1] ) . ' Months' ), $current_time_value ) );
288
- $this->args['date_query'] = array(
289
- 'monthnum' => $month,
290
- 'year' => $year,
291
- );
292
- break;
293
- case 'year':
294
- $year = date( 'Y', strtotime( ( strval( - $date_data[1] ) . ' Years' ), $current_time_value ) );
295
- $this->args['date_query'] = array(
296
- 'year' => $year,
297
- );
298
- break;
299
- }
300
- }
301
- $this->args = apply_filters( 'posts_in_page_args', $this->args );
302
-
303
- }
304
-
305
- /**
306
- * Sets a shortcode boolean value to a real boolean
307
- *
308
- * @return bool
309
- */
310
- public function shortcode_bool( $var ) {
311
-
312
- $falsey = array( 'false', '0', 'no', 'n' );
313
-
314
- return ( ! $var || in_array( strtolower( $var ), $falsey ) ) ? false : true;
315
-
316
- }
317
-
318
- /**
319
- * Tests if a theme has a template file that exists in one of two locations
320
- * 1- posts-in-page directory or 2- theme directory
321
- *
322
- * @return true if template exists, false otherwise.
323
- */
324
- protected function has_theme_template() {
325
-
326
- // try default template filename if empty
327
- $filename = empty( $this->args['template'] ) ? 'posts_loop_template.php' : $this->args['template'];
328
-
329
- // Checking first of two locations - theme root
330
- $template_file = get_stylesheet_directory() . '/' . $filename;
331
-
332
- // check for traversal attack
333
- $path_parts = pathinfo( $template_file );
334
- if ( $template_file != get_stylesheet_directory() . '/' .
335
- $path_parts['filename'] . '.' . $path_parts['extension']
336
- ) {
337
- // something fishy
338
- return false;
339
- }
340
-
341
- return ( file_exists( $template_file ) ) ? $template_file : false;
342
-
343
- }
344
-
345
- /**
346
- * Retrieves the post loop template and returns the output
347
- *
348
- * @return string results of the output
349
- */
350
- protected function add_template_part( $ic_posts, $singles = false ) {
351
- if ( $singles ) {
352
- setup_postdata( $ic_posts );
353
- } else {
354
- $ic_posts->the_post();
355
- }
356
- /**
357
- * Because legacy versions of pip forced users to echo content in the filter callback
358
- * we are using both the filters and the output buffer to cover all bases of usage.
359
- */
360
- ob_start();
361
- $output_start = apply_filters( 'posts_in_page_pre_loop', '' );
362
- require ( $file_path = self::has_theme_template() )
363
- ? $file_path // use template file in theme
364
- : POSTSPAGE_DIR . '/templates/posts_loop_template.php'; // use default plugin template file
365
- $output_start .= ob_get_clean();
366
- /*
367
- * Output buffering to handle legacy versions which forced filter callbacks to echo content rather than return it.
368
- */
369
- ob_start();
370
- /**
371
- * Standard use of filter
372
- */
373
- $output = apply_filters( 'posts_in_page_post_loop', $output_start );
374
- /**
375
- * Just in case someone has a legacy callback that doesn't return anything...
376
- */
377
- if ( empty( $output ) ) {
378
- $output = $output_start;
379
- }
380
- /**
381
- * Allow for legacy use of filter which forced echoing content
382
- */
383
- $output .= ob_get_clean();
384
-
385
- return $output;
386
- }
387
-
388
- public function custom_excerpt_more( $more ) {
389
- $more_tag = $this->args['more_tag'];
390
-
391
- return ' <a class="read-more" href="' . get_permalink( get_the_ID() ) . '">' . $more_tag . '</a>';
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
- * @package Posts_in_Page
4
- * @author Eric Amundson <eric@ivycat.com>
5
- * @copyright Copyright (c) 2019, IvyCat, Inc.
6
- * @license http://www.gnu.org/licenses/gpl-2.0.html
7
- *
8
- * Plugin Name: Posts in Page
9
- * Plugin URI: https://ivycat.com/wordpress/wordpress-plugins/posts-in-page/
10
- * Description: Easily add one or more posts to any page using simple shortcodes. Supports categories, tags, custom post types, custom taxonomies, and more.
11
- * Version: 1.4.1
12
- * Author: IvyCat, Inc.
13
- * Author URI: https://ivycat.com/wordpress/
14
- * Text Domain: posts-in-page
15
- * Domain Path: /languages
16
- * License: GNU General Public License v2.0
17
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
18
- */
19
-
20
- if ( ! function_exists( 'add_action' ) ) {
21
- wp_die( 'You are trying to access this file in a manner not allowed.', 'Direct Access Forbidden', array( 'response' => '403' ) );
22
- }
23
-
24
- if ( ! defined( 'POSTSPAGE_DIR' ) ) {
25
- define( 'POSTSPAGE_DIR', plugin_dir_path( __FILE__ ) );
26
- }
27
-
28
- if ( ! defined( 'POSTPAGE_URL' ) ) {
29
- define( 'POSTPAGE_URL', plugin_dir_url( __FILE__ ) );
30
- }
31
-
32
- require_once 'includes/class-page-posts.php';
33
-
34
- class ICAddPostsToPage {
35
-
36
- public function __construct() {
37
- add_shortcode( 'ic_add_posts', array( &$this, 'posts_in_page', ) );
38
- add_shortcode( 'ic_add_post', array( &$this, 'post_in_page', ) );
39
- add_action( 'admin_menu', array( &$this, 'plugin_page_init', ) );
40
- add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array(
41
- &$this,
42
- 'plugin_action_links',
43
- ), 10, 4 );
44
- load_plugin_textdomain( 'posts-in-page', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
45
- }
46
-
47
- /**
48
- * Add settings link on plugins page.
49
- */
50
- public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
51
- if ( is_plugin_active( $plugin_file ) ) {
52
- $actions[] = '<a href="' . admin_url( 'options-general.php?page=posts_in_page' ) . '">' . __( ' Help', 'posts-in-page' ) . '</a>';
53
- }
54
-
55
- return apply_filters( 'post_in_page_actions', $actions );
56
- }
57
-
58
- /**
59
- * Main shortcode
60
- * @return array
61
- *
62
- * @param array $atts An array of shortcode parameters. None required
63
- */
64
- public function posts_in_page( $atts ) {
65
- $posts = new ICPagePosts( $atts );
66
-
67
- return $posts->output_posts();
68
- }
69
-
70
- /**
71
- * Deprecated shortcode (routing to posts in page function now)
72
- *
73
- * @todo Remove this deprecated function
74
- */
75
- public function post_in_page( $atts ) {
76
- return self::posts_in_page( $atts );
77
- }
78
-
79
- /**
80
- * Init plugin, add menu page, and setup hooks to load assets on the plugin options page
81
- */
82
- public function plugin_page_init() {
83
- if ( ! current_user_can( 'administrator' ) ) {
84
- return;
85
- }
86
-
87
- $hooks = array();
88
- $hooks[] = add_options_page( __( 'Posts in Page', 'posts-in-page' ), __( 'Posts in Page', 'posts-in-page' ), 'read', 'posts_in_page',
89
- array( $this, 'plugin_page' ) );
90
-
91
- foreach ( $hooks as $hook ) {
92
- add_action( "admin_print_styles-{$hook}", array( $this, 'load_assets' ) );
93
- }
94
- }
95
-
96
- /**
97
- * Enqueue plugin assets (scripts & styles)
98
- */
99
- public function load_assets() {
100
- wp_enqueue_style( 'postpagestyle', POSTPAGE_URL . 'admin/assets/css/post-page_styles.css' );
101
- wp_enqueue_script( 'postpagescript', POSTPAGE_URL . 'admin/assets/js/post-page_scripts.js' );
102
- }
103
-
104
- /**
105
- * Plugin Settings page - includes view for the page
106
- */
107
- public function plugin_page() {
108
- require_once 'admin/views/help-main.php';
109
- }
110
-
111
- }
112
-
113
- /**
114
- * Instantiate the Plugin - called using the plugins_loaded action hook.
115
- */
116
- function init_ic_posts_in_page() {
117
- new ICAddPostsToPage();
118
- }
119
-
120
- add_action( 'plugins_loaded', 'init_ic_posts_in_page' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1
7
  License: GPLv2 or later
8
- License URI: http://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, 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 modify theme files.
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
- Some of our clients wanted to output some posts in a specific page without fiddling with templates.
 
 
 
 
 
 
119
 
120
- = How do I change the output template =
121
 
122
- Simply copy the `posts_loop_template.php` to your theme directory and make changes as necessary.
123
 
124
- You can even rename it - but make sure to indicate that in the shortcode using the `template='template_name.php'`.
 
 
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
- = How about with custom taxonomies?
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 shortcodes directly in your template using `do_shortcode`.
 
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 `[...] &hellip;` 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 `[...] &hellip;` 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
- * @package Posts_in_Page
4
- * @author Eric Amundson <eric@ivycat.com>
5
- * @copyright Copyright (c) 2019, IvyCat, Inc.
6
- * @link https://ivycat.com
7
- * @since 1.0.0
8
- * @license GPL-2.0+
 
 
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
- <!-- This outputs the post TITLE -->
19
- <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
20
 
21
- <!-- This outputs the post EXCERPT. To display full content including images and html,
22
  replace the_excerpt(); with the_content(); below. -->
23
- <div class="entry-summary">
24
  <?php the_excerpt(); ?>
25
- </div>
26
 
27
- <!-- This outputs the post META information -->
28
- <div class="entry-utility">
29
- <?php if ( count( get_the_category() ) ) : ?>
30
- <span class="cat-links">
31
- <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'posts-in-page' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
 
 
 
 
 
 
 
 
 
 
 
32
  </span>
33
- <span class="meta-sep">|</span>
34
  <?php endif; ?>
35
  <?php
36
- $tags_list = get_the_tag_list( '', ', ' );
37
- if ( $tags_list ): ?>
38
- <span class="tag-links">
39
- <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'posts-in-page' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
 
 
 
 
 
 
 
 
 
40
  </span>
41
- <span class="meta-sep">|</span>
42
  <?php endif; ?>
43
- <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'posts-in-page' ), __( '1 Comment', 'posts-in-page' ), __( '% Comments', 'posts-in-page' ) ); ?></span>
44
- <?php edit_post_link( __( 'Edit', 'posts-in-page' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
45
- </div>
 
 
 
 
 
 
 
 
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 -->