Skip to content

Commit

Permalink
Adds Ukranian translation by Michael Yunat [http://getvoip.com](http:…
Browse files Browse the repository at this point in the history
…//getvoip.com/blog)

Adds `display_id` parameter. Set it to yes to show the Post's ID next to the post title.
Adds `starting_with` parameter. Gets posts whose title start with a given letter.
  • Loading branch information
picandocodigo committed Jun 21, 2014
1 parent fb71d55 commit b0f7d5c
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 50 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# List Category Posts
[![Code Climate](https://codeclimate.com/github/picandocodigo/List-Category-Posts.png)](https://codeclimate.com/github/picandocodigo/List-Category-Posts)
List Category Posts is a **[WordPress](http://wordpress.org) plugin**
that allows you to list posts from a category into a post/page using
the [catlist] shortcode. This shortcode accepts a category name or id,
Expand Down
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ then
fi

if [ ! -d /var/www ];
then
then
a2enmod rewrite
sed -i '/AllowOverride None/c AllowOverride All' /etc/apache2/sites-available/default
service apache2 restart
Expand Down
32 changes: 23 additions & 9 deletions include/CatList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Each time you use the shortcode, you get an instance of this class.
* @author fernando@picandocodigo.net
*/

class CatList{
private $params = array();
private $lcp_category_id = 0;
Expand All @@ -19,6 +18,11 @@ class CatList{
* @param array $atts
*/
public function __construct($atts) {
load_plugin_textdomain(
'list-category-posts',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages/'
);
$this->params = $atts;

if ($this->lcp_not_empty('instance')){
Expand Down Expand Up @@ -158,6 +162,11 @@ private function set_lcp_parameters(){
endif;
endif;

// Posts that start with a given letter:
if ( $this->lcp_not_empty('starting_with') ){
add_filter('posts_where' , array( $this, 'starting_with') );
}

// for WP_Query compatibility
// http://core.trac.wordpress.org/browser/tags/3.7.1/src/wp-includes/post.php#L1686
$args['posts_per_page'] = $args['numberposts'];
Expand All @@ -166,6 +175,13 @@ private function set_lcp_parameters(){
$query = new WP_Query;
$this->lcp_categories_posts = $query->query($args);
$this->posts_count = $query->found_posts;
remove_all_filters('posts_where');
}

public function starting_with($where){
$letter = $this->params['starting_with'];
$where .= ' AND wp_posts.post_title LIKE \'' . $letter . "%'";
return $where;
}

/* Should I return posts or show that the tag/category or whatever
Expand All @@ -176,14 +192,12 @@ private function set_lcp_parameters(){
private function lcp_should_return_posts() */

private function lcp_not_empty($param){
if ( ( isset($this->params[$param]) ) &&
( !empty($this->params[$param]) ) &&
( $this->params[$param] != '0' ) &&
( $this->params[$param] != '') ) :
return true;
else:
return false;
endif;
return (
isset($this->params[$param]) &&
!empty($this->params[$param]) &&
$this->params[$param] !== '0' &&
$this->params[$param] !== ''
);
}


Expand Down
24 changes: 14 additions & 10 deletions include/CatListDisplayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,27 +223,31 @@ private function lcp_build_post($single, $tag){
$lcp_display_output .= $this->get_author($single);
endif;

// Display ID
if (!empty($this->params['display_id']) && $this->params['display_id'] == 'yes'){
$lcp_display_output .= $single->ID;
}

// Custom field display
if (!empty($this->params['customfield_display'])) :
if (!empty($this->params['customfield_tag'])):
if (!empty($this->params['customfield_class'])):
$lcp_display_output .= $this->get_custom_fields(
$this->params['customfield_display'],
$single->ID,
$this->params['customfield_tag'],
$this->params['customfield_class']);
$this->params['customfield_display'],
$single->ID,
$this->params['customfield_tag'],
$this->params['customfield_class']);
else:
$lcp_display_output .= $this->get_custom_fields(
$this->params['customfield_display'],
$single->ID,
$this->params['customfield_tag']);
$this->params['customfield_display'],
$single->ID,
$this->params['customfield_tag']);
endif;
else:
$lcp_display_output .= $this->get_custom_fields(
$this->params['customfield_display'],
$single->ID
);
$this->params['customfield_display'],
$single->ID
);
endif;
endif;

Expand Down
Binary file added languages/list-category-posts-uk_UA.mo
Binary file not shown.
127 changes: 127 additions & 0 deletions languages/list-category-posts-uk_UA.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Copyright (C) 2012
# This file is distributed under the same license as the package.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/wp\n"
"POT-Creation-Date: 2012-12-19 13:23:13+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2014-05-22 14:05+0200\n"
"Last-Translator: Michael Yunat <Michael.Yunat@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: uk_UA\n"
"X-Generator: Poedit 1.6.5\n"

#: include/ListCategoryPostsWidget.php:5
msgid ""
"List Category Posts allows you to list posts from a category into 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, and the number of "
"posts to display. You can use [catlist] as many times as needed with "
"different arguments. Usage: [catlist argument1=value1 argument2=value2]."
msgstr ""
"Список Категорія Повідомлень дозволяють перерахувати повідомлення від "
"категорії в запису / сторінки, використовуючи [Catlist] шорткод. Це шорткод "
"приймає ім&#39;я категорії або ідентифікатор, порядок, в якому ви хочете "
"пости для відображення, та кількість повідомлень для відображення. Ви можете "
"використовувати [Catlist] стільки разів, скільки необхідно з різними "
"аргументами. Використання: [Catlist аргумент1 = значение1 аргумент2 = "
"значення2]."

#: include/ListCategoryPostsWidget.php:11
msgid "List posts from a specified category"
msgstr "Список повідомлень від зазначеної категорії"

#: include/ListCategoryPostsWidget.php:12
msgid "List Category Posts"
msgstr "Список Категорія Повідомлень"

#: include/lcp_widget_form.php:40
msgid "Title"
msgstr "Назва"

#: include/lcp_widget_form.php:47
msgid "Category"
msgstr "Категорія"

#: include/lcp_widget_form.php:65
msgid "Number of posts"
msgstr "Кількість повідомлень"

#: include/lcp_widget_form.php:72
msgid "Offset"
msgstr "Зсув"

#: include/lcp_widget_form.php:78
msgid "Order by"
msgstr "Сортувати по"

#: include/lcp_widget_form.php:81 include/lcp_widget_form.php:123
msgid "Date"
msgstr "Дата"

#: include/lcp_widget_form.php:82
msgid "Post title"
msgstr "Найменування посади"

#: include/lcp_widget_form.php:83 include/lcp_widget_form.php:127
msgid "Author"
msgstr "Автор"

#: include/lcp_widget_form.php:84
msgid "Random"
msgstr "Випадковий"

#: include/lcp_widget_form.php:88
msgid "Order"
msgstr "Порядок"

#: include/lcp_widget_form.php:91
msgid "Descending"
msgstr "Спадний"

#: include/lcp_widget_form.php:92
msgid "Ascending"
msgstr "Висхідний"

#: include/lcp_widget_form.php:96
msgid "Exclude categories (id's)"
msgstr "Виключіть категорії (ідентифікатори)"

#: include/lcp_widget_form.php:102
msgid "Exclude posts (id's)"
msgstr "Виключити повідомлення (ідентифікатори)"

#: include/lcp_widget_form.php:109
msgid "Show"
msgstr "Показати"

#: include/lcp_widget_form.php:112
msgid "Thumbnail - size"
msgstr "Зображення - розмір"

#: include/lcp_widget_form.php:131
msgid "Link to category"
msgstr "Посилання на категорії"

#: include/lcp_widget_form.php:135
msgid "Excerpt"
msgstr "Витримка"

#: include/lcp_widget_form.php:138
msgid "More link"
msgstr "Більш посилання"

#: list_cat_posts.php:102
msgid "How to use"
msgstr "Як використовувати"

#: list_cat_posts.php:103
msgid "Donate"
msgstr "Жертвувати"

#: list_cat_posts.php:104
msgid "Fork on Github"
msgstr "Вилка на Github"
57 changes: 29 additions & 28 deletions list_cat_posts.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
<?php
/*
Plugin Name: List category posts
Plugin URI: https://github.com/picandocodigo/List-Category-Posts
Description: List Category Posts allows you to list posts from a category into 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, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
Version: 0.46.4
Author: Fernando Briano
Author URI: http://picandocodigo.net/
Text Domain: list-category-posts
Domain Path: /languages/
*/

/* Copyright 2008-2014 Fernando Briano (email : fernando@picandocodigo.net)
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
*/
/*
Plugin Name: List category posts
Plugin URI: https://github.com/picandocodigo/List-Category-Posts
Description: List Category Posts allows you to list posts from a category into 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, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
Version: 0.46.4
Author: Fernando Briano
Author URI: http://picandocodigo.net/
Text Domain: list-category-posts
Domain Path: /languages/
Copyright 2008-2014 Fernando Briano (email : fernando@picandocodigo.net)
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
*/

load_plugin_textdomain( 'list-category-posts', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );

Expand Down Expand Up @@ -71,13 +70,15 @@ static function catlist_func($atts, $content = null) {
'content' => 'no',
'content_tag' => '',
'content_class' => '',
'display_id' => 'no',
'catlink' => 'no',
'catlink_string' => '',
'catlink_tag' =>'',
'catlink_class' => '',
'comments' => 'no',
'comments_tag' => '',
'comments_class' => '',
'starting_with' => '',
'thumbnail' => 'no',
'thumbnail_size' => 'thumbnail',
'thumbnail_class' => '',
Expand Down
23 changes: 21 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: fernandobt
Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/#support
Tags: list, categories, posts, cms
Requires at least: 3.3
Tested up to: 3.9
Stable tag: 0.46.4
Tested up to: 3.9.1
Stable tag: 0.47
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -158,6 +158,8 @@ update the plugin.
* **ASC** - Ascending (lowest to highest).
* **DESC** - Descending (highest to lowest). Ex: `[catlist name=mycategory orderby=title order=asc]`

* **starting_with** - Get posts whose title starts with a certain letter. Example: `[catlist starting_with="l"]` will list all posts whose title starts with L.

* **numberposts** - Number of posts to return. Set to 0 to use the max
number of posts per page. Set to -1 to remove the limit.
Ex: `[catlist name=mycategory numberposts=10]`
Expand Down Expand Up @@ -242,6 +244,8 @@ update the plugin.
WordPress
</a> Hello World </li>```

* **display_id** - Set it to yes to show the Post's ID next to the post title: `[catlist id=3 display_id=yes]`

* **class** - CSS class for the default UL generated by the plugin.

* **custom fields** - To use custom fields, you must specify two values: customfield_name and customfield_value. Using this only show posts that contain a custom field with this name and value. Both parameters must be defined, or neither will work.
Expand Down Expand Up @@ -292,6 +296,14 @@ Will print the value of the Custom Field "Mood" but not the text

* **link_target** - Select the `target` attribute for links to posts (target=_blank, _self, _parent, _top, *framename*). Example: `[catlink id=3 link_target=_blank]` will create: `<a href="http://localhost/wordpress/?p=45" title="Test post" target="_blank">Test post</a>`

== Widget ==

The widget is quite simple, and it doesn't implement all of the plugin's functionality. To use a shortcode in a widget add this code to your theme's functions.php file:

`add_filter('widget_text', 'do_shortcode');`

Then just add a new text widget to your blog and use the shortcode there as the widget's content.

== HTML & CSS Customization ==

You can customize what HTML tags different elements will be sorrounded with and a CSS class for this element, or just a CSS class which will wrap the element with a `span` tag.
Expand Down Expand Up @@ -386,6 +398,13 @@ Template system has changed. Custom templates should be stored in WordPress them

== Changelog ==

= 0.47 =

* Adds Ukranian translation by Michael Yunat [http://getvoip.com](http://getvoip.com/blog)
* Adds `display_id` parameter. Set it to yes to show the Post's ID next to the post title.
* Adds `starting_with` parameter. Gets posts whose title start with a given letter.


= 0.46.4 =
* Finally (hopefully) fix the excerpt issues.

Expand Down

0 comments on commit b0f7d5c

Please sign in to comment.