Version Description
- now you can set
more_tag=""
to remove the[...] …
that unfortunetly shows up as&hellip
Download this release
Release Info
Developer | sewmyheadon |
Plugin | Posts in Page |
Version | 1.2.4 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.2.4
- lib/page_posts.php +82 -47
- posts_in_page.php +39 -40
- readme.txt +10 -3
lib/page_posts.php
CHANGED
@@ -7,55 +7,55 @@ if ( !function_exists( 'add_action' ) )
|
|
7 |
wp_die( 'You are trying to access this file in a manner not allowed.', 'Direct Access Forbidden', array( 'response' => '403' ) );
|
8 |
|
9 |
class ICPagePosts {
|
10 |
-
|
11 |
protected $args = array(
|
12 |
-
'post_type'
|
13 |
-
'post_status'
|
14 |
-
'orderby'
|
15 |
-
'order'
|
16 |
-
'paginate'
|
17 |
-
'template'
|
18 |
); // set defaults for wp_parse_args
|
19 |
-
|
20 |
public function __construct( $atts ) {
|
21 |
self::set_args( $atts );
|
22 |
}
|
23 |
-
|
24 |
/**
|
25 |
* Output's the posts
|
26 |
*
|
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;
|
48 |
$page_url = home_url( '/' . $wp_query->post->post_name . '/' );
|
49 |
$page = isset( $_GET['page'] ) ? $_GET['page'] : 1;
|
50 |
$total_pages = $posts->max_num_pages;
|
51 |
$per_page = $posts->query_vars['posts_per_page'];
|
52 |
-
$curr_page = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0
|
53 |
-
//echo '<pre>' . print_r( $posts, true ) . '</pre>';
|
54 |
$prev = ( $curr_page && $curr_page > 1 ) ? '<li><a href="'.$page_url.'?page='. ( $curr_page-1 ).'">Previous</a></li>' : '';
|
55 |
$next = ( $curr_page && $curr_page < $total_pages ) ? '<li><a href="'.$page_url.'?page='. ( $curr_page+1 ).'">Next</a></li>' : '';
|
56 |
return '<ul>' . $prev . $next . '</ul>';
|
57 |
}
|
58 |
-
|
59 |
/**
|
60 |
* Build additional Arguments for the WP_Query object
|
61 |
*
|
@@ -66,31 +66,31 @@ class ICPagePosts {
|
|
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'] ) ){
|
72 |
$post_types = explode( ',', $this->args['post_type'] );
|
73 |
$this->args['post_type'] = $post_types;
|
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 (
|
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'] ) ){
|
@@ -100,65 +100,100 @@ class ICPagePosts {
|
|
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'] ) &&
|
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' );
|
120 |
}
|
121 |
-
|
122 |
if ( ! isset( $this->args['ignore_sticky_posts'] ) ) {
|
123 |
$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(
|
137 |
-
: get_stylesheet_directory(
|
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 |
-
|
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 |
}
|
7 |
wp_die( 'You are trying to access this file in a manner not allowed.', 'Direct Access Forbidden', array( 'response' => '403' ) );
|
8 |
|
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 |
/**
|
25 |
* Output's the posts
|
26 |
*
|
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', $this->paginate_links( $page_posts ) ) . '</div>' : '';
|
|
|
|
|
39 |
endif;
|
40 |
+
wp_reset_postdata();
|
41 |
+
|
42 |
+
remove_filter( 'excerpt_more', array( &$this, 'custom_excerpt_more' ) );
|
43 |
+
|
44 |
return $output;
|
45 |
}
|
46 |
+
|
47 |
protected function paginate_links( $posts ){
|
48 |
global $wp_query;
|
49 |
$page_url = home_url( '/' . $wp_query->post->post_name . '/' );
|
50 |
$page = isset( $_GET['page'] ) ? $_GET['page'] : 1;
|
51 |
$total_pages = $posts->max_num_pages;
|
52 |
$per_page = $posts->query_vars['posts_per_page'];
|
53 |
+
$curr_page = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0 ) ? $posts->query_vars['paged'] : 1;
|
|
|
54 |
$prev = ( $curr_page && $curr_page > 1 ) ? '<li><a href="'.$page_url.'?page='. ( $curr_page-1 ).'">Previous</a></li>' : '';
|
55 |
$next = ( $curr_page && $curr_page < $total_pages ) ? '<li><a href="'.$page_url.'?page='. ( $curr_page+1 ).'">Next</a></li>' : '';
|
56 |
return '<ul>' . $prev . $next . '</ul>';
|
57 |
}
|
58 |
+
|
59 |
/**
|
60 |
* Build additional Arguments for the WP_Query object
|
61 |
*
|
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'] ) ){
|
72 |
$post_types = explode( ',', $this->args['post_type'] );
|
73 |
$this->args['post_type'] = $post_types;
|
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'] ) ){
|
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 |
+
// exclude posts with certain category by name (slug)
|
110 |
+
if ( isset( $atts['exclude_category'] ) ) {
|
111 |
+
$category = $atts['exclude_category'];
|
112 |
+
if( preg_match( '`,`', $category ) ) { // multiple
|
113 |
+
$category = explode( ',', $category );
|
114 |
+
|
115 |
+
foreach( $category AS $cat ) {
|
116 |
+
$term = get_category_by_slug( $cat );
|
117 |
+
$exclude[] = '-' . $term->term_id;
|
118 |
+
}
|
119 |
+
$category = implode( ',', $exclude );
|
120 |
+
|
121 |
+
} else { // single
|
122 |
+
$term = get_category_by_slug( $category );
|
123 |
+
$category = '-' . $term->term_id;
|
124 |
+
}
|
125 |
+
|
126 |
+
if( !is_null( $this->args['cat'] ) ) { // merge lists
|
127 |
+
$this->args['cat'] .= ',' . $category;
|
128 |
+
}
|
129 |
+
$this->args['cat'] = $category;
|
130 |
+
// unset our unneeded variables
|
131 |
+
unset( $category, $term, $exclude );
|
132 |
+
}
|
133 |
+
|
134 |
// show number of posts (default is 10, showposts or posts_per_page are both valid, only one is needed)
|
135 |
if ( isset( $atts['showposts'] ) )
|
136 |
$this->args[ 'posts_per_page' ] = $atts['showposts'];
|
137 |
+
|
138 |
// handle pagination (for code, template pagination is in the template)
|
139 |
+
if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
|
140 |
$this->args['paged'] = $wp_query->query_vars['page'];
|
141 |
}
|
142 |
+
|
143 |
if ( ! isset( $this->args['ignore_sticky_posts'] ) ) {
|
144 |
$this->args['post__not_in'] = get_option( 'sticky_posts' );
|
145 |
}
|
146 |
+
|
147 |
if ( ! isset( $this->args['ignore_sticky_posts'] ) ) {
|
148 |
$this->args['post__not_in'] = get_option( 'sticky_posts' );
|
149 |
}
|
150 |
+
|
151 |
+
if ( isset( $this->args['more_tag'] ) ) {
|
152 |
+
add_filter( 'excerpt_more', array( &$this, 'custom_excerpt_more' ), 1 );
|
153 |
+
}
|
154 |
+
|
155 |
$this->args = apply_filters( 'posts_in_page_args', $this->args );
|
156 |
+
|
157 |
}
|
158 |
+
|
159 |
/**
|
160 |
* Tests if a theme has a theme template file that exists
|
161 |
*
|
162 |
* @return true if template exists, false otherwise.
|
163 |
*/
|
164 |
+
protected function has_theme_template() {
|
165 |
$template_file = ( $this->args['template'] )
|
166 |
+
? get_stylesheet_directory() . '/' . $this->args['template'] // use specified template file
|
167 |
+
: get_stylesheet_directory() . '/posts_loop_template.php'; // use default template file
|
168 |
+
|
169 |
return ( file_exists( $template_file ) ) ? $template_file : false;
|
170 |
}
|
171 |
+
|
172 |
/**
|
173 |
* Retrieves the post loop template and returns the output
|
174 |
*
|
175 |
* @return string results of the output
|
176 |
*/
|
177 |
+
protected function add_template_part( $ic_posts, $singles=false ) {
|
178 |
if ( $singles ) {
|
179 |
setup_postdata( $ic_posts );
|
180 |
} else {
|
181 |
+
$ic_posts->the_post();
|
182 |
}
|
183 |
$output = '';
|
184 |
+
ob_start();
|
185 |
$output .= apply_filters( 'posts_in_page_pre_loop', '' );
|
186 |
+
require ( $file_path = self::has_theme_template() )
|
187 |
? $file_path // use template file in theme
|
188 |
: POSTSPAGE_DIR . '/posts_loop_template.php'; // use default plugin template file
|
189 |
+
$output .= ob_get_contents();
|
190 |
$output .= apply_filters( 'posts_in_page_post_loop', '' );
|
191 |
+
return ob_get_clean();
|
192 |
+
}
|
193 |
+
|
194 |
+
public function custom_excerpt_more( $more ) {
|
195 |
+
$more_tag = $this->args['more_tag'];
|
196 |
+
return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . $more_tag . '</a>';
|
197 |
+
}
|
198 |
|
199 |
}
|
posts_in_page.php
CHANGED
@@ -1,32 +1,31 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
------------------------------------------------------------------------
|
14 |
-
IvyCat Posts in Page, Copyright
|
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
|
18 |
-
the Free Software Foundation; either version 2 of the License, or
|
19 |
-
(at your option) any later version.
|
20 |
-
|
21 |
-
This program is distributed in the hope that it will be useful,
|
22 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
-
GNU General Public License for more details.
|
25 |
-
|
26 |
-
You should have received a copy of the GNU General Public License
|
27 |
-
along with this program; if not, write to the Free Software
|
28 |
-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
29 |
-
|
30 |
*/
|
31 |
|
32 |
if ( !function_exists( 'add_action' ) )
|
@@ -34,21 +33,21 @@ if ( !function_exists( 'add_action' ) )
|
|
34 |
|
35 |
if ( ! defined( 'POSTSPAGE_DIR' ) )
|
36 |
define( 'POSTSPAGE_DIR', plugin_dir_path( __FILE__ ) );
|
37 |
-
|
38 |
if ( ! defined( 'POSTPAGE_URL' ) )
|
39 |
define( 'POSTPAGE_URL', plugin_dir_url( __FILE__ ) );
|
40 |
|
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 |
*/
|
@@ -57,7 +56,7 @@ class ICAddPostsToPage {
|
|
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 |
*
|
@@ -67,7 +66,7 @@ class ICAddPostsToPage {
|
|
67 |
$posts = new ICPagePosts( $atts );
|
68 |
return $posts->output_posts( );
|
69 |
}
|
70 |
-
|
71 |
/**
|
72 |
* Deprecated shortcode (routing to posts in page function now)
|
73 |
*
|
@@ -76,18 +75,18 @@ class ICAddPostsToPage {
|
|
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 |
}
|
@@ -100,21 +99,21 @@ class ICAddPostsToPage {
|
|
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 |
/**
|
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 |
+
/**
|
4 |
+
* Plugin Name: Posts in Page
|
5 |
+
* Plugin URI: http://www.ivycat.com/wordpress/wordpress-plugins/posts-in-page/
|
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.4
|
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 - 2015 IvyCat, Inc. (wp@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
|
18 |
+
* the Free Software Foundation; either version 2 of the License, or
|
19 |
+
* (at your option) any later version.
|
20 |
+
*
|
21 |
+
* This program is distributed in the hope that it will be useful,
|
22 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
* GNU General Public License for more details.
|
25 |
+
*
|
26 |
+
* You should have received a copy of the GNU General Public License
|
27 |
+
* along with this program; if not, write to the Free Software
|
28 |
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
29 |
*/
|
30 |
|
31 |
if ( !function_exists( 'add_action' ) )
|
33 |
|
34 |
if ( ! defined( 'POSTSPAGE_DIR' ) )
|
35 |
define( 'POSTSPAGE_DIR', plugin_dir_path( __FILE__ ) );
|
36 |
+
|
37 |
if ( ! defined( 'POSTPAGE_URL' ) )
|
38 |
define( 'POSTPAGE_URL', plugin_dir_url( __FILE__ ) );
|
39 |
|
40 |
require_once 'lib/page_posts.php';
|
41 |
|
42 |
class ICAddPostsToPage {
|
43 |
+
|
44 |
public function __construct( ) {
|
45 |
add_shortcode( 'ic_add_posts', array( &$this, 'posts_in_page' ) );
|
46 |
add_shortcode( 'ic_add_post', array( &$this, 'post_in_page' ) );
|
47 |
add_action( 'admin_menu', array( &$this, 'plugin_page_init' ) );
|
48 |
add_filter( 'plugin_action_links_'. plugin_basename( __FILE__ ), array( &$this, 'plugin_action_links' ), 10, 4 );
|
49 |
}
|
50 |
+
|
51 |
/**
|
52 |
* Add settings link on plugins page.
|
53 |
*/
|
56 |
$actions[] = '<a href="' . admin_url('options-general.php?page=posts_in_page') . '">' . __( ' Help', 'posts_in_page' ) . '</a>';
|
57 |
return apply_filters( 'post_in_page_actions', $actions );
|
58 |
}
|
59 |
+
|
60 |
/**
|
61 |
* Main shortcode
|
62 |
*
|
66 |
$posts = new ICPagePosts( $atts );
|
67 |
return $posts->output_posts( );
|
68 |
}
|
69 |
+
|
70 |
/**
|
71 |
* Deprecated shortcode (routing to posts in page function now)
|
72 |
*
|
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 |
$hooks = array( );
|
87 |
$hooks[] = add_options_page( __( 'Posts In Page' ), __( 'Posts In Page' ), 'read', 'posts_in_page',
|
88 |
array( $this, 'plugin_page' ) );
|
89 |
+
|
90 |
foreach ( $hooks as $hook ) {
|
91 |
add_action( "admin_print_styles-{$hook}", array( $this, 'load_assets' ) );
|
92 |
}
|
99 |
wp_enqueue_style( 'postpagestyle', POSTPAGE_URL. '/assets/post-page_styles.css' );
|
100 |
wp_enqueue_script( 'postpagescript', POSTPAGE_URL. '/assets/post-page_scripts.js' );
|
101 |
}
|
102 |
+
|
103 |
/**
|
104 |
* Plugin Settings page - includes view for the page
|
105 |
*/
|
106 |
public function plugin_page( ) {
|
107 |
require_once 'assets/posts_in_page_help_view.php';
|
108 |
}
|
109 |
+
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
+
* Instantiate the Plugin - called using the plugins_loaded action hook.
|
114 |
+
*/
|
115 |
function init_ic_posts_in_page( ) {
|
116 |
new ICAddPostsToPage( );
|
117 |
}
|
118 |
|
119 |
+
add_action( 'plugins_loaded', 'init_ic_posts_in_page' );
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Posts in Page ===
|
2 |
-
Contributors: sewmyheadon, ivycat, dgilfoy
|
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:
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -48,6 +48,7 @@ To 'pull' posts into a page, you can either:
|
|
48 |
* `[ic_add_posts showposts='5']` - limit number of posts (or override default setting)
|
49 |
* `[ic_add_posts orderby='title' order='ASC']` - orderby title - supports all WP orderby variables. Order is optional, WP default is 'DESC'.
|
50 |
* `[ic_add_posts category='category-slug']` - Show posts within a specific category. Uses slugs, can have multiple but separate by commas. category-1,category2, etc (no spaces.)
|
|
|
51 |
* `[ic_add_posts tag='tag-slug']` - 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.)
|
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.
|
@@ -127,6 +128,9 @@ Not likely, but let us know if it does; then we'll know we have something specia
|
|
127 |
|
128 |
== Changelog ==
|
129 |
|
|
|
|
|
|
|
130 |
= 1.2.3 =
|
131 |
* Added minor doc tweaks.
|
132 |
|
@@ -173,6 +177,9 @@ Not likely, but let us know if it does; then we'll know we have something specia
|
|
173 |
|
174 |
== Upgrade Notice ==
|
175 |
|
|
|
|
|
|
|
176 |
= 1.2.3 =
|
177 |
* Housekeeping only; not urgent.
|
178 |
|
1 |
=== Posts in Page ===
|
2 |
+
Contributors: sewmyheadon, ivycat, gehidore, dgilfoy
|
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: 4.1.1
|
7 |
+
Stable tag: 1.2.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
48 |
* `[ic_add_posts showposts='5']` - limit number of posts (or override default setting)
|
49 |
* `[ic_add_posts orderby='title' order='ASC']` - orderby title - supports all WP orderby variables. Order is optional, WP default is 'DESC'.
|
50 |
* `[ic_add_posts category='category-slug']` - Show posts within a specific category. Uses slugs, can have multiple but separate by commas. category-1,category2, etc (no spaces.)
|
51 |
+
* `[ic_add_posts exclude_category='category-slug']` - Exclude posts within specific category. Uses slugs, can have multiple slugs seperated by commas. category-1,category2, etc (no spaces.)
|
52 |
* `[ic_add_posts tag='tag-slug']` - 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.)
|
53 |
* `[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
|
54 |
* `[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.
|
128 |
|
129 |
== Changelog ==
|
130 |
|
131 |
+
= 1.2.4 =
|
132 |
+
* now you can set `more_tag=""` to remove the `[...] …` that unfortunetly shows up as `&hellip`
|
133 |
+
|
134 |
= 1.2.3 =
|
135 |
* Added minor doc tweaks.
|
136 |
|
177 |
|
178 |
== Upgrade Notice ==
|
179 |
|
180 |
+
= 1.2.4 =
|
181 |
+
* Presentational fixes: clean up whitespace, extra tabs, add in customization of more tag.
|
182 |
+
|
183 |
= 1.2.3 =
|
184 |
* Housekeeping only; not urgent.
|
185 |
|