-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
list-category-posts.php
252 lines (231 loc) · 8.2 KB
/
list-category-posts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
/*
Plugin Name: List category posts
Plugin URI: https://github.com/picandocodigo/List-Category-Posts
Description: List Category Posts allows you to list posts by category in a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
Version: 0.89.8
Author: Fernando Briano
Author URI: http://fernandobriano.com
Text Domain: list-category-posts
Domain Path: /languages/
Copyright 2008-2020 Fernando Briano (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
include 'include/lcp-widget.php';
include 'include/lcp-options.php';
require_once 'include/lcp-catlistdisplayer.php';
class ListCategoryPosts{
private static $default_params = null;
public static function default_params(){
if (self::$default_params === null) {
self::$default_params = array(
'id' => '0',
'name' => '',
'orderby' => '',
'order' => '',
'numberposts' => '',
'date' => 'no',
'date_tag' => '',
'date_class' =>'',
'dateformat' => get_option('date_format'),
'date_modified' => '',
'date_modified_tag' => '',
'date_modified_class' => '',
'author' => 'no',
'author_posts_link' => 'no',
'author_tag' =>'',
'author_class' => '',
'author_posts' => '',
'template' => '',
'excerpt' => 'no',
'excerpt_size' => '55',
'excerpt_strip' => 'yes',
'excerpt_overwrite' => 'no',
'excerpt_tag' =>'',
'excerpt_class' =>'',
'exclude' => '0',
'excludeposts' => '0',
'includeposts' => '0',
'offset' => '0',
'tags' => '',
'exclude_tags' => '',
'currenttags' => '',
'content' => 'no',
'content_tag' => '',
'content_class' => '',
'display_id' => 'no',
'catlink' => 'no',
'catname' => 'no',
'catlink_string' => '',
'catlink_tag' =>'',
'catlink_class' => '',
'posts_tags' => '',
'posts_tags_tag' => '',
'posts_tags_class' => '',
'posts_tags_prefix' => ' ',
'posts_tags_glue' => ', ',
'posts_tags_inner' => '',
'posts_taglink' => 'no',
'posts_cats' => '',
'posts_cats_tag' => '',
'posts_cats_class' => '',
'posts_cats_prefix' => ' ',
'posts_cats_glue' => ', ',
'posts_cats_inner' => '',
'posts_catlink' => '',
'child_categories' => 'yes',
'comments' => 'no',
'comments_tag' => '',
'comments_class' => '',
'starting_with' => '',
'thumbnail' => 'no',
'thumbnail_size' => 'thumbnail',
'thumbnail_tag' => '',
'thumbnail_class' => '',
'force_thumbnail' => '',
'title_tag' => '',
'title_class' => '',
'title_limit' => '0',
'post_type' => '',
'post_status' => '',
'post_parent' => '',
'post_suffix' => '',
'show_protected' => 'no',
'class' => '',
'conditional_title' => '',
'conditional_title_tag' => '',
'conditional_title_class' => '',
'customfield_name' => '',
'customfield_value' =>'',
'customfield_display' =>'',
'customfield_display_glue' => '',
'customfield_display_name' =>'',
'customfield_display_name_glue' => ' : ',
'customfield_display_separately' => 'no',
'customfield_orderby' => '',
'customfield_orderby_type' => '',
'customfield_tag' => '',
'customfield_class' => '',
'customfield_compare' => '',
'taxonomy' => '',
'taxonomies_and' => '',
'taxonomies_or' => '',
'terms' => '',
'currentterms' => '',
'categorypage' => '',
'category_count' => '',
'category_description' => 'no',
'category_description_tag' => '',
'category_description_class' => '',
'morelink' => '',
'morelink_class' => '',
'morelink_tag' => '',
'posts_morelink' => '',
'posts_morelink_class' => '',
'year' => '',
'monthnum' => '',
'search' => '',
'link_target' => '',
'pagination' => '',
'pagination_next' => '>>',
'pagination_prev' => '<<',
'pagination_padding' => '5',
'no_posts_text' => "",
'instance' => '0',
'no_post_titles' => 'no',
'link_titles' => true,
'link_current' => '',
'link_dates' => 'no',
'after' => '',
'after_year' => '',
'after_month' => '',
'after_day' => '',
'before' => '',
'before_year' => '',
'before_month' => '',
'before_day' => '',
'tags_as_class' => 'no',
'pagination_bookmarks' => '',
'ol_offset' => '',
'main_query' => '',
'keep_orderby_filters' => '',
'ignore_sticky_posts' => '',
'cat_sticky_posts' => '',
'main_cat_only' => '',
);
}
return self::$default_params;
}
/**
* Gets the shortcode parameters and instantiate plugin objects
* @param $atts
* @param $content
*/
static function catlist_func($atts) {
// Can be filtered using the shortcode_atts_catlist hook.
$atts = shortcode_atts(self::default_params(), $atts, 'catlist');
if($atts['numberposts'] == ''){
$atts['numberposts'] = get_option('numberposts');
}
if($atts['pagination'] == 'yes' ||
(get_option('lcp_pagination') === 'true' &&
$atts['pagination'] !== 'false') ){
lcp_pagination_css();
}
$catlist_displayer = new CatListDisplayer($atts);
return $catlist_displayer->display();
}
}
add_shortcode( 'catlist', array('ListCategoryPosts', 'catlist_func') );
function lpc_meta($links, $file) {
$plugin = plugin_basename(__FILE__);
if ($file == $plugin) {
return array_merge(
$links,
array( sprintf('<a href="http://wordpress.org/extend/plugins/list-category-posts/other_notes/">%s</a>', __('How to use','list-category-posts')) ),
array( sprintf('<a href="http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/#support">%s</a>', __('Donate','list-category-posts')) ),
array( sprintf('<a href="https://github.com/picandocodigo/List-Category-Posts">%s</a>', __('Fork on Github','list-category-posts')) )
);
}
return $links;
}
add_filter( 'plugin_row_meta', 'lpc_meta', 10, 2 );
//adds a default value to numberposts on plugin activation
function set_default_numberposts() {
add_option('numberposts', 10);
}
register_activation_hook( __FILE__, 'set_default_numberposts' );
function load_i18n(){
load_plugin_textdomain(
'list-category-posts',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages/'
);
}
add_action( 'plugins_loaded', 'load_i18n' );
function lcp_pagination_css(){
if ( @file_exists( get_stylesheet_directory() . '/lcp_paginator.css' ) ) {
$css_file = get_stylesheet_directory_uri() . '/lcp_paginator.css';
} elseif ( @file_exists( get_template_directory() . '/lcp_paginator.css' ) ) {
$css_file = get_template_directory_uri() . '/lcp_paginator.css';
} else {
$css_file = plugin_dir_url(__FILE__) . '/lcp_paginator.css';
}
wp_enqueue_style( 'lcp_paginator', $css_file);
}
/**
* TO-DO:
- Add Older Posts at bottom of List Category Post page
- Simpler template system
- Exclude child categories
*/