Posts in Page - Version 1.2.2

Version Description

  • Added pagination, tweaked to turn off by default.
  • Bug fixes.
Download this release

Release Info

Developer sewmyheadon
Plugin Icon 128x128 Posts in Page
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

assets/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
  });
assets/post-page_styles.css CHANGED
@@ -1,234 +1,234 @@
1
  #posts-in-page-settings h2 span {
2
- display:block;
3
- width: 150px;
4
- float: right;
5
  }
6
-
7
  #side-sortables {
8
- min-height: 300px;
9
- padding: 0;
10
- width: 280px;
11
- color: #333333;
12
  }
13
  .postbox {
14
- background-color: #F5F5F5;
15
- background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
16
- border-color: #DFDFDF;
17
- border-radius: 3px 3px 3px 3px;
18
- box-shadow: 0 1px 0 #FFFFFF inset;
19
- min-width: 255px;
20
- position: relative;
21
- border-style: solid;
22
- border-width: 1px;
23
- line-height: 1;
24
- margin-bottom: 20px;
25
- padding: 0;
26
  }
27
  .postbox .handlediv {
28
- cursor: pointer;
29
- float: right;
30
- height: 30px;
31
- width: 27px;
32
  }
33
  .postbox h3 {
34
- font-size: 15px;
35
- font-weight: normal;
36
- line-height: 1;
37
- margin: 0;
38
- padding: 7px 10px;
39
- color: #464646;
40
- font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
41
- text-shadow: 0 1px 0 #FFFFFF;
42
- background-color: #F1F1F1;
43
- background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC);
44
- border-bottom-color: #DFDFDF;
45
- box-shadow: 0 1px 0 #FFFFFF;
46
  }
47
  .postbox h4 {
48
- font-size: 14px;
49
- font-weight: bold;
50
- line-height: 1;
51
- margin: 0;
52
- padding: 7px 0px;
53
- color: #464646;
54
- text-align: left;
55
- text-shadow: 0 1px 0 #FFFFFF;
56
  }
57
  .postbox .inside {
58
- margin: 6px 0 8px;
59
- position: relative;
60
- line-height: 1.4em;
61
- padding:0 ;
62
  }
63
 
64
  .postbox .inside_wrap{
65
- margin:0 15px;
66
  }
67
  .postbox .inside_wrap ul,
68
  .postbox .inside_wrap p {
69
- margin-top:0;
70
- font-size:13px;margin-bottom:0.7em;
71
  }
72
  .postbox .inside_wrap ul {
73
- list-style:disc;
74
- margin-left:15px;
75
 
76
  }
77
  .postbox ul{
78
- list-style-type: none;
79
- padding: 0;
80
- margin-top: 0;
81
  }
82
  .postbox ul li.img{
83
- text-align: center;
84
- background: #ffffff;
85
- padding: 10px 0 ;
86
  }
87
  .postbox a{
88
- color: #628C29;
89
- text-decoration: none;
90
  }
91
  .postbox a:hover{
92
- color: #8EC73C;
93
  }
94
 
95
  .postbox .ivy_social li {
96
- list-style-type:none;
97
- text-indent:-9999px;
98
- display:inline;
99
  }
100
  .postbox .ivy_social li a {
101
- display:block;
102
- float:left;
103
- width:16px;
104
- height:16px;
105
- margin:0 12px;
106
  }
107
  .postbox .ivy_social li.ic_fb a {
108
- background: url("facebook.png") no-repeat top left;
109
  }
110
  .postbox .ivy_social li.ic_tw a {
111
- background: url("twitter.png") no-repeat top left;
112
  }
113
  .postbox .ivy_social li.ic_li a {
114
- background: url("linkedin.png") no-repeat top left;
115
  }
116
  .postbox .ivy_social li.ic_mc a {
117
- background: url("email.png") no-repeat top left;
118
  }
119
  .postbox .ivy_social li.ic_rss a {
120
- background: url("feed.png") no-repeat top left;
121
  }
122
  #body-wrap {
123
- margin-top: 25px;
124
  }
125
  #body-wrap inside {
126
- padding: 10px;
127
  }
128
  #body-wrap .hndle h3 ul {
129
- margin-bottom: 0;
130
  }
131
  #body-wrap .hndle{
132
- margin-bottom: 10px;
133
  }
134
  #body-wrap .hndle a{
135
- font-size: 18px;
136
  }
137
  #body-wrap .hndle li.current-menu-tab a{
138
- font-size: 21px;
139
- font-weight: bold;
140
  }
141
  #posts-in-page-settings #body-wrap{
142
- width: 55%;
143
- float:left;
144
  }
145
  #posts-in-page-settings #sidebar-wrap{
146
- width: 35%;
147
- float:left;
148
- margin: 25px 0 0 20px;
149
  }
150
  #posts-in-page-settings .top-menu{
151
- width: 100%;
152
  }
153
 
154
  #posts-in-page-settings .top-menu li{
155
- margin-bottom: 0px;
156
- text-align: center;
157
  }
158
  #posts-in-page-settings .settings{
159
- padding: 10px;
160
  }
161
  #posts-in-page-settings .help{
162
- margin-top: 20px;
163
- padding: 10px;
164
  }
165
  .clearfix:before, .clearfix:after {
166
- content: ""; display: table;
167
- }
168
  .clearfix:after {
169
- clear: both;
170
- }
171
  .clearfix {
172
- *zoom: 1;
173
- }
174
  #ivycat_donate form input[type="image"] {
175
- margin:0 auto;
176
- display:block;
177
- }
178
 
179
  /* MailChimp Form Embed Code - Slim - 08/17/2011 */
180
  #mc_embed_signup form {
181
- display:block; position:relative; text-align:left; padding:10px 0 10px 0;width: 250px;
182
- }
183
  #mc_embed_signup h2 {
184
- font-weight:bold; padding:0; margin:15px 0; font-size:1.4em;
185
- }
186
  #mc_embed_signup input {
187
- border:1px solid #999; -webkit-appearance:none;
188
  }
189
  #mc_embed_signup input[type=checkbox] {
190
- -webkit-appearance:checkbox;
191
  }
192
  #mc_embed_signup input[type=radio] {
193
- -webkit-appearance:radio;
194
  }
195
  #mc_embed_signup input:focus {
196
- border-color:#333;
197
  }
198
  #mc_embed_signup .button {
199
- clear:both; background-color: #aaa; border: 0 none; border-radius:4px; color: #FFFFFF; cursor: pointer; display: inline-block; font-size:15px; font-weight: bold; height: 32px; line-height: 32px; margin: 0 5px 10px 0; padding:0; text-align: center; text-decoration: none; vertical-align: top; white-space: nowrap; width: auto;
200
- }
201
  #mc_embed_signup .button:hover {
202
- background-color:#777;
203
  }
204
  #mc_embed_signup .small-meta {
205
- font-size: 11px;
206
- }
207
  #mc_embed_signup .nowrap {
208
- white-space:nowrap;
209
- }
210
  #mc_embed_signup label {
211
- display:block; font-size:14px; padding-bottom:10px; font-weight:bold;color:#464646
212
- }
213
  #mc_embed_signup input.email {
214
- display:block; padding:8px 0; margin:0 0 10px 0; text-indent:5px; width:58%; min-width:130px;float:left;
215
- }
216
  #mc_embed_signup input.button {
217
- display:block; clear:none; background:#628C29; width:35%; margin:0 0 10px 0; min-width:90px;float:right;text-shadow:0 1px 0 #666;
218
- }
219
  #mc_embed_signup div#mce-responses {
220
- float:left; top:-1.4em; padding:0em .5em 0em .5em; overflow:hidden; width:90%;margin: 0 5%; clear: both;}
221
  #mc_embed_signup div.response {
222
- margin:1em 0; padding:1em .5em .5em 0; font-weight:bold; float:left; top:-1.5em; z-index:1; width:80%;
223
- }
224
  #mc_embed_signup #mce-error-response {
225
- display:none;
226
- }
227
  #mc_embed_signup #mce-success-response {
228
- color:#529214; display:none;
229
- }
230
  #mc_embed_signup label.error {
231
- display:block; float:none; width:auto; margin-left:1.05em; text-align:left; padding:.5em 0;
232
- }
233
 
234
 
1
  #posts-in-page-settings h2 span {
2
+ display:block;
3
+ width: 150px;
4
+ float: right;
5
  }
6
+
7
  #side-sortables {
8
+ min-height: 300px;
9
+ padding: 0;
10
+ width: 280px;
11
+ color: #333333;
12
  }
13
  .postbox {
14
+ background-color: #F5F5F5;
15
+ background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
16
+ border-color: #DFDFDF;
17
+ border-radius: 3px 3px 3px 3px;
18
+ box-shadow: 0 1px 0 #FFFFFF inset;
19
+ min-width: 255px;
20
+ position: relative;
21
+ border-style: solid;
22
+ border-width: 1px;
23
+ line-height: 1;
24
+ margin-bottom: 20px;
25
+ padding: 0;
26
  }
27
  .postbox .handlediv {
28
+ cursor: pointer;
29
+ float: right;
30
+ height: 30px;
31
+ width: 27px;
32
  }
33
  .postbox h3 {
34
+ font-size: 15px;
35
+ font-weight: normal;
36
+ line-height: 1;
37
+ margin: 0;
38
+ padding: 7px 10px;
39
+ color: #464646;
40
+ font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
41
+ text-shadow: 0 1px 0 #FFFFFF;
42
+ background-color: #F1F1F1;
43
+ background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC);
44
+ border-bottom-color: #DFDFDF;
45
+ box-shadow: 0 1px 0 #FFFFFF;
46
  }
47
  .postbox h4 {
48
+ font-size: 14px;
49
+ font-weight: bold;
50
+ line-height: 1;
51
+ margin: 0;
52
+ padding: 7px 0;
53
+ color: #464646;
54
+ text-align: left;
55
+ text-shadow: 0 1px 0 #FFFFFF;
56
  }
57
  .postbox .inside {
58
+ margin: 6px 0 8px;
59
+ position: relative;
60
+ line-height: 1.4em;
61
+ padding:0 ;
62
  }
63
 
64
  .postbox .inside_wrap{
65
+ margin:0 15px;
66
  }
67
  .postbox .inside_wrap ul,
68
  .postbox .inside_wrap p {
69
+ margin-top:0;
70
+ font-size:13px;margin-bottom:0.7em;
71
  }
72
  .postbox .inside_wrap ul {
73
+ list-style:disc;
74
+ margin-left:15px;
75
 
76
  }
77
  .postbox ul{
78
+ list-style-type: none;
79
+ padding: 0;
80
+ margin-top: 0;
81
  }
82
  .postbox ul li.img{
83
+ text-align: center;
84
+ background: #ffffff;
85
+ padding: 10px 0 ;
86
  }
87
  .postbox a{
88
+ color: #628C29;
89
+ text-decoration: none;
90
  }
91
  .postbox a:hover{
92
+ color: #8EC73C;
93
  }
94
 
95
  .postbox .ivy_social li {
96
+ list-style-type:none;
97
+ text-indent:-9999px;
98
+ display:inline;
99
  }
100
  .postbox .ivy_social li a {
101
+ display:block;
102
+ float:left;
103
+ width:16px;
104
+ height:16px;
105
+ margin:0 12px;
106
  }
107
  .postbox .ivy_social li.ic_fb a {
108
+ background: url("facebook.png") no-repeat top left;
109
  }
110
  .postbox .ivy_social li.ic_tw a {
111
+ background: url("twitter.png") no-repeat top left;
112
  }
113
  .postbox .ivy_social li.ic_li a {
114
+ background: url("linkedin.png") no-repeat top left;
115
  }
116
  .postbox .ivy_social li.ic_mc a {
117
+ background: url("email.png") no-repeat top left;
118
  }
119
  .postbox .ivy_social li.ic_rss a {
120
+ background: url("feed.png") no-repeat top left;
121
  }
122
  #body-wrap {
123
+ margin-top: 25px;
124
  }
125
  #body-wrap inside {
126
+ padding: 10px;
127
  }
128
  #body-wrap .hndle h3 ul {
129
+ margin-bottom: 0;
130
  }
131
  #body-wrap .hndle{
132
+ margin-bottom: 10px;
133
  }
134
  #body-wrap .hndle a{
135
+ font-size: 18px;
136
  }
137
  #body-wrap .hndle li.current-menu-tab a{
138
+ font-size: 21px;
139
+ font-weight: bold;
140
  }
141
  #posts-in-page-settings #body-wrap{
142
+ width: 55%;
143
+ float:left;
144
  }
145
  #posts-in-page-settings #sidebar-wrap{
146
+ width: 35%;
147
+ float:left;
148
+ margin: 25px 0 0 20px;
149
  }
150
  #posts-in-page-settings .top-menu{
151
+ width: 100%;
152
  }
153
 
154
  #posts-in-page-settings .top-menu li{
155
+ margin-bottom: 0px;
156
+ text-align: center;
157
  }
158
  #posts-in-page-settings .settings{
159
+ padding: 10px;
160
  }
161
  #posts-in-page-settings .help{
162
+ margin-top: 20px;
163
+ padding: 10px;
164
  }
165
  .clearfix:before, .clearfix:after {
166
+ content: ""; display: table;
167
+ }
168
  .clearfix:after {
169
+ clear: both;
170
+ }
171
  .clearfix {
172
+ *zoom: 1;
173
+ }
174
  #ivycat_donate form input[type="image"] {
175
+ margin:0 auto;
176
+ display:block;
177
+ }
178
 
179
  /* MailChimp Form Embed Code - Slim - 08/17/2011 */
180
  #mc_embed_signup form {
181
+ display:block; position:relative; text-align:left; padding:10px 0 10px 0;width: 250px;
182
+ }
183
  #mc_embed_signup h2 {
184
+ font-weight:bold; padding:0; margin:15px 0; font-size:1.4em;
185
+ }
186
  #mc_embed_signup input {
187
+ border:1px solid #999; -webkit-appearance:none;
188
  }
189
  #mc_embed_signup input[type=checkbox] {
190
+ -webkit-appearance:checkbox;
191
  }
192
  #mc_embed_signup input[type=radio] {
193
+ -webkit-appearance:radio;
194
  }
195
  #mc_embed_signup input:focus {
196
+ border-color:#333;
197
  }
198
  #mc_embed_signup .button {
199
+ clear:both; background-color: #aaa; border: 0 none; border-radius:4px; color: #FFFFFF; cursor: pointer; display: inline-block; font-size:15px; font-weight: bold; height: 32px; line-height: 32px; margin: 0 5px 10px 0; padding:0; text-align: center; text-decoration: none; vertical-align: top; white-space: nowrap; width: auto;
200
+ }
201
  #mc_embed_signup .button:hover {
202
+ background-color:#777;
203
  }
204
  #mc_embed_signup .small-meta {
205
+ font-size: 11px;
206
+ }
207
  #mc_embed_signup .nowrap {
208
+ white-space:nowrap;
209
+ }
210
  #mc_embed_signup label {
211
+ display:block; font-size:14px; padding-bottom:10px; font-weight:bold;color:#464646
212
+ }
213
  #mc_embed_signup input.email {
214
+ display:block; padding:8px 0; margin:0 0 10px 0; text-indent:5px; width:58%; min-width:130px;float:left;
215
+ }
216
  #mc_embed_signup input.button {
217
+ display:block; clear:none; background:#628C29; width:35%; margin:0 0 10px 0; min-width:90px;float:right;text-shadow:0 1px 0 #666;
218
+ }
219
  #mc_embed_signup div#mce-responses {
220
+ float:left; top:-1.4em; padding:0em .5em 0em .5em; overflow:hidden; width:90%;margin: 0 5%; clear: both;}
221
  #mc_embed_signup div.response {
222
+ margin:1em 0; padding:1em .5em .5em 0; font-weight:bold; float:left; top:-1.5em; z-index:1; width:80%;
223
+ }
224
  #mc_embed_signup #mce-error-response {
225
+ display:none;
226
+ }
227
  #mc_embed_signup #mce-success-response {
228
+ color:#529214; display:none;
229
+ }
230
  #mc_embed_signup label.error {
231
+ display:block; float:none; width:auto; margin-left:1.05em; text-align:left; padding:.5em 0;
232
+ }
233
 
234
 
assets/posts_in_page_help_view.php CHANGED
@@ -1,51 +1,49 @@
1
  <div class="wrap" id="posts-in-page-settings">
2
  <div id="icon-options-general" class="icon32"></div>
3
- <h2>Posts in Page</h2>
4
- <div id="body-wrap" class="meta-box-sortables ui-sortable">
5
- <div id="metabox_desc" class="postbox">
6
- <div class="handlediv" title="Click to toggle">
7
- <br>
8
- </div>
9
- <div class="hndle">
10
- <h3><ul class="top-menu clearfix">
11
- <li class="menu-item"><a href="#help">Help</a></li>
12
- </ul></h3>
13
- </div>
14
- <div class="group help inside">
15
- <ul>
16
- <li>
17
- <strong>[ic_add_posts]</strong> - Add all posts to a page (limit to what number posts in WordPress is set to). This essentially makes the page look like a blog.
18
- </li>
19
- <li>
20
- <strong>[ic_add_posts post_type='post_type' ids='1,2,3']</strong> - show posts with certain IDs (currently only one post type per category)
21
- </li>
22
- <li>
23
- <strong>[ic_add_posts id='1']</strong> - show a single post with the given ID ( must give post type if not post )
24
- </li>
25
- <li>
26
- <strong>[ic_add_posts showposts='5']</strong> - limit number of posts (or override default setting)
27
- </li>
28
- <li>
29
- <strong>[ic_add_posts orderby='title' order='ASC']</strong> - orderby title - supports all WordPress orderby variables. Order is optional, WP default
30
- </li>
31
- <li>
32
- <strong>[ic_add_posts category='category-slug']</strong> - Show posts within a specific category. Uses slugs, and can have multiple categories separate by commas. category-1,category2, etc (no spaces.)
33
- </li>
34
- <li>
35
- <strong>[ic_add_posts post_type='post-type']</strong> - Show posts that belong to a specific post type (only one post type right now)
36
- </li>
37
- <li>
38
- <strong>[ic_add_posts tax='taxonomy' term='term']</strong> - limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work.
39
- </li>
40
- <li>
41
- <strong>[ic_add_posts template='template-in-theme-dir.php']</strong> - 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.
42
- Or any combination above.
43
- </li>
44
- </ul>
45
- </div>
46
- </div>
47
- </div>
48
- <div id="sidebar-wrap">
49
- <?php require_once 'desc.php'; ?>
50
- </div>
51
  </div>
1
  <div class="wrap" id="posts-in-page-settings">
2
  <div id="icon-options-general" class="icon32"></div>
3
+ <h2>Posts in Page</h2>
4
+ <div id="body-wrap" class="meta-box-sortables ui-sortable">
5
+ <div id="metabox_desc" class="postbox">
6
+ <div class="handlediv" title="Click to toggle">
7
+ <br>
8
+ </div>
9
+ <div class="hndle">
10
+ <h3><ul class="top-menu clearfix">
11
+ <li class="menu-item"><a href="#help">Shortcode Usage</a></li>
12
+ </ul></h3>
13
+ </div>
14
+ <div class="group help inside">
15
+ <p>To 'pull' posts into a page, you can either:</p>
16
+
17
+ <ol>
18
+ <li>place a shortcode in the editor window of the page you're editing, or </li>
19
+ <li>modify a theme template file using the shortcode in a PHP function.</li>
20
+ </ol>
21
+
22
+ <h4>Using Shortcodes in the WordPress editor</h4>
23
+
24
+ <ul>
25
+ <li><code>[ic_add_posts]</code> - Add all posts to a page (limit to what number posts in WordPress is set to), essentially adds blog "page" to page.</li>
26
+ <li><code>[ic_add_posts ids='1,2,3']</code> - show one or many posts by specifying the post ID(s) ( specify all post types )</li>
27
+ <li><code>[ic_add_posts post_type='post_type']</code> - 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. <code>post_type='post_type1,post_type2'</code>)</li>
28
+ <li><code>[ic_add_posts showposts='5']</code> - limit number of posts (or override default setting)</li>
29
+ <li><code>[ic_add_posts orderby='title' order='ASC']</code> - orderby title - supports all WP orderby variables. Order is optional, WP default </li>
30
+ <li><code>[ic_add_posts category='category-slug']</code> - Show posts within a specific category. Uses slugs, can have multiple but separate by commas. category-1,category2, etc (no spaces.)</li>
31
+ <li><code>[ic_add_posts tag='tag-slug']</code> - 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.)</li>
32
+ <li><code>[ic_add_posts tax='taxonomy' term='term']</code> - limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work</li>
33
+ <li><code>[ic_add_posts template='template-in-theme-dir.php']</code> - 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.</li>
34
+ </ul>
35
+
36
+ <p>Or any combination of the above.</p>
37
+
38
+ <h4>Using Shortcodes within a PHP function</h4>
39
+
40
+ <p>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.</p>
41
+
42
+ <pre><code>&lt;?php echo do_shortcode("[shortcode]"); ?&gt;</code></pre>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ <div id="sidebar-wrap">
47
+ <?php require_once 'desc.php'; ?>
48
+ </div>
 
 
49
  </div>
lib/page_posts.php CHANGED
@@ -9,15 +9,16 @@ if ( !function_exists( 'add_action' ) )
9
  class ICPagePosts {
10
 
11
  protected $args = array(
12
- 'post_type' => 'post',
13
- 'post_status' => 'publish',
14
- 'orderby' => 'date',
15
- 'order' => 'DESC',
16
- 'template' => false
 
17
  ); // set defaults for wp_parse_args
18
 
19
  public function __construct( $atts ) {
20
- self::set_args( $atts );
21
  }
22
 
23
  /**
@@ -26,20 +27,21 @@ class ICPagePosts {
26
  * @return string output of template file
27
  */
28
  public function output_posts() {
29
- if ( !$this->args ) return '';
30
- $page_posts = apply_filters( 'posts_in_page_results', new WP_Query( $this->args ) ); // New WP_Query object
31
- $output = '';
32
- if ( $page_posts->have_posts( ) ):
 
33
  while ( $page_posts->have_posts( ) ):
34
  $output .= self::add_template_part( $page_posts );
35
  endwhile;
36
- $output .= '<div class="pip-nav">' . apply_filters( 'posts_in_page_paginate',
37
  $this->paginate_links( $page_posts )
38
- ) . '</div>';
39
  endif;
40
- wp_reset_postdata( );
41
- return $output;
42
- }
43
 
44
  protected function paginate_links( $posts ){
45
  global $wp_query;
@@ -59,11 +61,11 @@ class ICPagePosts {
59
  *
60
  * @param array $atts Attritubes for building the $args array.
61
  */
62
- protected function set_args( $atts ) {
63
- global $wp_query;
64
  $this->args['posts_per_page'] = get_option( 'posts_per_page' );
65
  // parse the arguments using the defaults
66
- $this->args = wp_parse_args( $atts, $this->args );
67
 
68
  // multiple post types are indicated, pass as an array
69
  if( preg_match( '`,`', $this->args['post_type'] ) ){
@@ -72,47 +74,46 @@ class ICPagePosts {
72
  }
73
 
74
  // Show specific posts by ID
75
- if ( isset( $atts['ids'] ) ) {
76
- $post_ids = explode( ',', $atts['ids'] );
77
- $this->args['post__in'] = $post_ids;
78
- $this->args['posts_per_page'] = count( $post_ids );
79
- }
80
 
81
  // Use a specified template
82
- if ( isset( $atts['template'] ) )
83
  $this->args['template'] = $atts['template'];
84
-
85
  // get posts in a certain category by name (slug)
86
  if ( isset( $atts['category'] ) ) {
87
- $this->args['category_name'] = $atts['category'];
88
- } elseif ( isset( $atts['cats'] ) ) { // get posts in a certain category by id
89
- $this->args['cat'] = $atts['cats'];
90
- }
91
 
92
  // Do a tex query, tax and term a required.
93
- if( isset( $atts['tax'] ) ) {
94
- if( isset( $atts['term'] ) ){
95
- $terms = explode( ',', $atts['term'] );
96
- $this->args['tax_query'] = array(
97
- array( 'taxonomy' => $atts['tax'], 'field' => 'slug', 'terms' => ( count( $terms ) > 1 ) ? $terms : $atts['term'] )
98
- );
99
- }
100
- }
101
 
102
  // get posts with a certain tag
103
- if ( isset( $atts['tag'] ) ) {
104
- $tags = explode( ',', $atts['tag'] );
105
- $this->args['tag'] = ( count( $tags ) > 1 ) ? $tags : $atts['tag'];
106
- }
107
 
108
  // show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed)
109
- if ( isset( $atts['showposts'] ) )
110
  $this->args[ 'posts_per_page' ] = $atts['showposts'];
111
 
112
  // handle pagination (for code, template pagination is in the template)
113
- if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
114
- $this->args['paged'] = $wp_query->query_vars['page'];
115
- }
116
 
117
  if ( ! isset( $this->args['ignore_sticky_posts'] ) ) {
118
  $this->args['post__not_in'] = get_option( 'sticky_posts' );
@@ -123,41 +124,41 @@ class ICPagePosts {
123
  }
124
 
125
  $this->args = apply_filters( 'posts_in_page_args', $this->args );
126
- }
127
-
128
  /**
129
  * Tests if a theme has a theme template file that exists
130
  *
131
  * @return true if template exists, false otherwise.
132
  */
133
- protected function has_theme_template( ) {
134
- $template_file = ( $this->args['template'] )
135
  ? get_stylesheet_directory( ) . '/' . $this->args['template'] // use specified template file
136
  : get_stylesheet_directory( ) . '/posts_loop_template.php'; // use default template file
137
-
138
- return ( file_exists( $template_file ) ) ? $template_file : false;
139
- }
140
-
141
  /**
142
  * Retrieves the post loop template and returns the output
143
  *
144
  * @return string results of the output
145
  */
146
  protected function add_template_part( $ic_posts, $singles=false ) {
147
- if ( $singles ) {
148
- setup_postdata( $ic_posts );
149
- } else {
150
- $ic_posts->the_post( );
151
- }
152
  $output = '';
153
- ob_start( );
154
  $output .= apply_filters( 'posts_in_page_pre_loop', '' );
155
- require ( $file_path = self::has_theme_template( ) )
156
  ? $file_path // use template file in theme
157
  : POSTSPAGE_DIR . '/posts_loop_template.php'; // use default plugin template file
158
- $output .= ob_get_contents( );
159
  $output .= apply_filters( 'posts_in_page_post_loop', '' );
160
- return ob_get_clean( );
161
  }
162
 
163
- }
9
  class ICPagePosts {
10
 
11
  protected $args = array(
12
+ 'post_type' => 'post',
13
+ 'post_status' => 'publish',
14
+ 'orderby' => 'date',
15
+ 'order' => 'DESC',
16
+ 'paginate' => false,
17
+ 'template' => false
18
  ); // set defaults for wp_parse_args
19
 
20
  public function __construct( $atts ) {
21
+ self::set_args( $atts );
22
  }
23
 
24
  /**
27
  * @return string output of template file
28
  */
29
  public function output_posts() {
30
+ if ( !$this->args )
31
+ return '';
32
+ $page_posts = apply_filters( 'posts_in_page_results', new WP_Query( $this->args ) ); // New WP_Query object
33
+ $output = '';
34
+ if ( $page_posts->have_posts( ) ):
35
  while ( $page_posts->have_posts( ) ):
36
  $output .= self::add_template_part( $page_posts );
37
  endwhile;
38
+ $output .= ( $this->args['paginate'] ) ? '<div class="pip-nav">' . apply_filters( 'posts_in_page_paginate',
39
  $this->paginate_links( $page_posts )
40
+ ) . '</div>' : '';
41
  endif;
42
+ wp_reset_postdata( );
43
+ return $output;
44
+ }
45
 
46
  protected function paginate_links( $posts ){
47
  global $wp_query;
61
  *
62
  * @param array $atts Attritubes for building the $args array.
63
  */
64
+ protected function set_args( $atts ) {
65
+ global $wp_query;
66
  $this->args['posts_per_page'] = get_option( 'posts_per_page' );
67
  // parse the arguments using the defaults
68
+ $this->args = wp_parse_args( $atts, $this->args );
69
 
70
  // multiple post types are indicated, pass as an array
71
  if( preg_match( '`,`', $this->args['post_type'] ) ){
74
  }
75
 
76
  // Show specific posts by ID
77
+ if ( isset( $atts['ids'] ) ) {
78
+ $post_ids = explode( ',', $atts['ids'] );
79
+ $this->args['post__in'] = $post_ids;
80
+ $this->args['posts_per_page'] = count( $post_ids );
81
+ }
82
 
83
  // Use a specified template
84
+ if ( isset( $atts['template'] ) )
85
  $this->args['template'] = $atts['template'];
86
+
87
  // get posts in a certain category by name (slug)
88
  if ( isset( $atts['category'] ) ) {
89
+ $this->args['category_name'] = $atts['category'];
90
+ } elseif ( isset( $atts['cats'] ) ) { // get posts in a certain category by id
91
+ $this->args['cat'] = $atts['cats'];
92
+ }
93
 
94
  // Do a tex query, tax and term a required.
95
+ if( isset( $atts['tax'] ) ) {
96
+ if( isset( $atts['term'] ) ){
97
+ $terms = explode( ',', $atts['term'] );
98
+ $this->args['tax_query'] = array(
99
+ array( 'taxonomy' => $atts['tax'], 'field' => 'slug', 'terms' => ( count( $terms ) > 1 ) ? $terms : $atts['term'] )
100
+ );
101
+ }
102
+ }
103
 
104
  // get posts with a certain tag
105
+ if ( isset( $atts['tag'] ) ) {
106
+ $this->args['tag'] = $atts['tag'];
107
+ }
 
108
 
109
  // show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed)
110
+ if ( isset( $atts['showposts'] ) )
111
  $this->args[ 'posts_per_page' ] = $atts['showposts'];
112
 
113
  // handle pagination (for code, template pagination is in the template)
114
+ if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
115
+ $this->args['paged'] = $wp_query->query_vars['page'];
116
+ }
117
 
118
  if ( ! isset( $this->args['ignore_sticky_posts'] ) ) {
119
  $this->args['post__not_in'] = get_option( 'sticky_posts' );
124
  }
125
 
126
  $this->args = apply_filters( 'posts_in_page_args', $this->args );
127
+ }
128
+
129
  /**
130
  * Tests if a theme has a theme template file that exists
131
  *
132
  * @return true if template exists, false otherwise.
133
  */
134
+ protected function has_theme_template( ) {
135
+ $template_file = ( $this->args['template'] )
136
  ? get_stylesheet_directory( ) . '/' . $this->args['template'] // use specified template file
137
  : get_stylesheet_directory( ) . '/posts_loop_template.php'; // use default template file
138
+
139
+ return ( file_exists( $template_file ) ) ? $template_file : false;
140
+ }
141
+
142
  /**
143
  * Retrieves the post loop template and returns the output
144
  *
145
  * @return string results of the output
146
  */
147
  protected function add_template_part( $ic_posts, $singles=false ) {
148
+ if ( $singles ) {
149
+ setup_postdata( $ic_posts );
150
+ } else {
151
+ $ic_posts->the_post( );
152
+ }
153
  $output = '';
154
+ ob_start( );
155
  $output .= apply_filters( 'posts_in_page_pre_loop', '' );
156
+ require ( $file_path = self::has_theme_template( ) )
157
  ? $file_path // use template file in theme
158
  : POSTSPAGE_DIR . '/posts_loop_template.php'; // use default plugin template file
159
+ $output .= ob_get_contents( );
160
  $output .= apply_filters( 'posts_in_page_post_loop', '' );
161
+ return ob_get_clean( );
162
  }
163
 
164
+ }
posts_in_page.php CHANGED
@@ -6,12 +6,12 @@
6
  * Description: Easily add one or more posts to any page using simple shortcodes. Supports categories, tags, custom post types, custom taxonomies, and more.
7
  * Author: IvyCat Web Services
8
  * Author URI: http://www.ivycat.com
9
- * version: 1.2.1
10
  * License: GNU General Public License v2.0
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
13
  ------------------------------------------------------------------------
14
- IvyCat Posts in Page, Copyright 2012 IvyCat, Inc. (admins@ivycat.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
@@ -41,73 +41,73 @@ if ( ! defined( 'POSTPAGE_URL' ) )
41
  require_once 'lib/page_posts.php';
42
 
43
  class ICAddPostsToPage {
44
-
45
- public function __construct( ) {
46
- add_shortcode( 'ic_add_posts', array( &$this, 'posts_in_page' ) );
47
- add_shortcode( 'ic_add_post', array( &$this, 'post_in_page' ) );
48
- add_action( 'admin_menu', array( &$this, 'plugin_page_init' ) );
49
- add_filter( 'plugin_action_links_'. plugin_basename( __FILE__ ), array( &$this, 'plugin_action_links' ), 10, 4 );
50
- }
51
-
52
  /**
53
  * Add settings link on plugins page.
54
  */
55
- public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
56
- if ( is_plugin_active( $plugin_file ) )
57
- $actions[] = '<a href="' . admin_url('options-general.php?page=posts_in_page') . '">' . __( ' Help', 'posts_in_page' ) . '</a>';
58
- return apply_filters( 'post_in_page_actions', $actions );
59
- }
60
 
61
  /**
62
- * Main Shortcode
63
  *
64
  * @param array $atts An array of shortcode parameters. None required
65
  */
66
- public function posts_in_page( $atts ) {
67
- $posts = new ICPagePosts( $atts );
68
  return $posts->output_posts( );
69
- }
70
 
71
  /**
72
- * Deprecated Shortcode (routing to posts in page function now )
73
  *
74
  * @todo Remove this depreciated function.
75
  */
76
  public function post_in_page( $atts ) {
77
- return self::posts_in_page( $atts );
78
  }
79
 
80
  /**
81
- * Init Plugin, add menu page and setup hooks to load assets on the plugin options page
82
  */
83
- public function plugin_page_init() {
84
- if ( ! current_user_can( 'administrator' ) )
85
  return;
86
 
87
- $hooks = array( );
88
- $hooks[] = add_options_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 and Styles)
98
  */
99
- public function load_assets( ) {
100
- wp_enqueue_style( 'postpagestyle', POSTPAGE_URL. '/assets/post-page_styles.css' );
101
- wp_enqueue_script( 'postpagescript', POSTPAGE_URL. '/assets/post-page_scripts.js' );
102
- }
103
 
104
  /**
105
- * Plugin Setting page - includes view for the page
106
  */
107
- public function plugin_page( ) {
108
- require_once 'assets/posts_in_page_help_view.php';
109
- }
110
-
111
  }
112
 
113
  /**
6
  * Description: Easily add one or more posts to any page using simple shortcodes. Supports categories, tags, custom post types, custom taxonomies, and more.
7
  * Author: IvyCat Web Services
8
  * Author URI: http://www.ivycat.com
9
+ * version: 1.2.2
10
  * License: GNU General Public License v2.0
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
13
  ------------------------------------------------------------------------
14
+ IvyCat Posts in Page, Copyright 2012 -2013 IvyCat, Inc. (admins@ivycat.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
41
  require_once 'lib/page_posts.php';
42
 
43
  class ICAddPostsToPage {
44
+
45
+ public function __construct( ) {
46
+ add_shortcode( 'ic_add_posts', array( &$this, 'posts_in_page' ) );
47
+ add_shortcode( 'ic_add_post', array( &$this, 'post_in_page' ) );
48
+ add_action( 'admin_menu', array( &$this, 'plugin_page_init' ) );
49
+ add_filter( 'plugin_action_links_'. plugin_basename( __FILE__ ), array( &$this, 'plugin_action_links' ), 10, 4 );
50
+ }
51
+
52
  /**
53
  * Add settings link on plugins page.
54
  */
55
+ public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
56
+ if ( is_plugin_active( $plugin_file ) )
57
+ $actions[] = '<a href="' . admin_url('options-general.php?page=posts_in_page') . '">' . __( ' Help', 'posts_in_page' ) . '</a>';
58
+ return apply_filters( 'post_in_page_actions', $actions );
59
+ }
60
 
61
  /**
62
+ * Main shortcode
63
  *
64
  * @param array $atts An array of shortcode parameters. None required
65
  */
66
+ public function posts_in_page( $atts ) {
67
+ $posts = new ICPagePosts( $atts );
68
  return $posts->output_posts( );
69
+ }
70
 
71
  /**
72
+ * Deprecated shortcode (routing to posts in page function now)
73
  *
74
  * @todo Remove this depreciated function.
75
  */
76
  public function post_in_page( $atts ) {
77
+ return self::posts_in_page( $atts );
78
  }
79
 
80
  /**
81
+ * Init plugin, add menu page, and setup hooks to load assets on the plugin options page
82
  */
83
+ public function plugin_page_init() {
84
+ if ( ! current_user_can( 'administrator' ) )
85
  return;
86
 
87
+ $hooks = array( );
88
+ $hooks[] = add_options_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. '/assets/post-page_styles.css' );
101
+ wp_enqueue_script( 'postpagescript', POSTPAGE_URL. '/assets/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 'assets/posts_in_page_help_view.php';
109
+ }
110
+
111
  }
112
 
113
  /**
posts_loop_template.php CHANGED
@@ -1,17 +1,17 @@
1
- <!-- Note: if you make changes to this file, move it to your current theme's
2
- directory so this file won't be overwritten when the plugin is upgraded. -->
3
 
4
  <!-- Start of Post Wrap -->
5
  <div class="post hentry ivycat-post">
6
- <!-- This is the output of the post title -->
7
  <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
8
 
9
- <!-- This is the output of the excerpt -->
10
  <div class="entry-summary">
11
  <?php the_excerpt(); ?>
12
  </div>
13
 
14
- <!-- This is the output of the meta information -->
15
  <div class="entry-utility">
16
  <?php if ( count( get_the_category() ) ) : ?>
17
  <span class="cat-links">
1
+ <!-- NOTE: If you need to make changes to this file, copy it to your current theme's main
2
+ directory so your changes won't be overwritten when the plugin is upgraded. -->
3
 
4
  <!-- Start of Post Wrap -->
5
  <div class="post hentry ivycat-post">
6
+ <!-- This is the output of the post TITLE -->
7
  <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
8
 
9
+ <!-- This is the output of the EXCERPT -->
10
  <div class="entry-summary">
11
  <?php the_excerpt(); ?>
12
  </div>
13
 
14
+ <!-- This is the output of the META information -->
15
  <div class="entry-utility">
16
  <?php if ( count( get_the_category() ) ) : ?>
17
  <span class="cat-links">
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dgilfoy, ivycat, sewmyheadon
3
  Donate link: http://www.ivycat.com/contribute/
4
  Tags: shortcode, pages, posts, custom post types
5
  Requires at least: 3.0
6
- Tested up to: 3.4.1
7
- Stable tag: 1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -52,6 +52,7 @@ To 'pull' posts into a page, you can either:
52
  * `[ic_add_posts tax='taxonomy' term='term']` - limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work
53
  * `[ic_add_posts template='template-in-theme-dir.php']` - 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.
54
  * `[ic_add_posts ignore_sticky_posts='no']` - Show sticky posts too (they're ignored by default).
 
55
 
56
  Or any combination of the above.
57
 
@@ -76,9 +77,9 @@ Alright, now lets say that you want to pull in all posts from two categories int
76
  Now, you're ambitious and want to try something complex. Let's say you've got a page called _Plugins Are Awesome_ and, in it, you want to pull in posts that match the following criteria:
77
 
78
  * posts from a custom post type called _Testimonials_,
79
- * posts that are in the _Testimonial Type_ custom taxonomy using the term _Customer_
80
  * you want to display six testimonials per page,
81
- * you'd like them displayed in ascending order
82
  * finally, you've created a custom template to use in presenting these posts and named it `my-posts-in-page-template.php`
83
 
84
  Your shortcode might look like this:
@@ -126,6 +127,10 @@ Not likely, but let us know if it does; then we'll know we have something specia
126
 
127
  == Changelog ==
128
 
 
 
 
 
129
  = 1.2.1 =
130
  * 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']`.
131
 
@@ -134,7 +139,6 @@ Not likely, but let us know if it does; then we'll know we have something specia
134
  * Added post pagination
135
  * Plugin now honors default post reading settings under Settings/Reading in the WordPress Dashboard.
136
  * Improved and simplified documentation.
137
- * Added filters & hooks (documentation coming)
138
 
139
  = 1.1.1 =
140
  * Code maintenance, fix for category bug, also added ability for multiple post types per shortcode.
@@ -166,6 +170,9 @@ Not likely, but let us know if it does; then we'll know we have something specia
166
 
167
  == Upgrade Notice ==
168
 
 
 
 
169
  = 1.2.1 =
170
  * Small feature update, not critical.
171
 
3
  Donate link: http://www.ivycat.com/contribute/
4
  Tags: shortcode, pages, posts, custom post types
5
  Requires at least: 3.0
6
+ Tested up to: 3.5.1
7
+ Stable tag: 1.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
52
  * `[ic_add_posts tax='taxonomy' term='term']` - limit posts to those that exist in a taxonomy and have a specific term. Both are required for either one to work
53
  * `[ic_add_posts template='template-in-theme-dir.php']` - 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.
54
  * `[ic_add_posts ignore_sticky_posts='no']` - Show sticky posts too (they're ignored by default).
55
+ * `[ic_add_posts paginate='yes']` - use pagination links (off by default)
56
 
57
  Or any combination of the above.
58
 
77
  Now, you're ambitious and want to try something complex. Let's say you've got a page called _Plugins Are Awesome_ and, in it, you want to pull in posts that match the following criteria:
78
 
79
  * posts from a custom post type called _Testimonials_,
80
+ * posts that are in the _Testimonial Type_ custom taxonomy using the term _Customer_,
81
  * you want to display six testimonials per page,
82
+ * you'd like them displayed in ascending order,
83
  * finally, you've created a custom template to use in presenting these posts and named it `my-posts-in-page-template.php`
84
 
85
  Your shortcode might look like this:
127
 
128
  == Changelog ==
129
 
130
+ = 1.2.2 =
131
+ * Added pagination, tweaked to turn off by default.
132
+ * Bug fixes.
133
+
134
  = 1.2.1 =
135
  * 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']`.
136
 
139
  * Added post pagination
140
  * Plugin now honors default post reading settings under Settings/Reading in the WordPress Dashboard.
141
  * Improved and simplified documentation.
 
142
 
143
  = 1.1.1 =
144
  * Code maintenance, fix for category bug, also added ability for multiple post types per shortcode.
170
 
171
  == Upgrade Notice ==
172
 
173
+ = 1.2.2 =
174
+ * Small bug fixes for tags, pagination; not critical.
175
+
176
  = 1.2.1 =
177
  * Small feature update, not critical.
178