first commit to repo

This commit is contained in:
jorge-vitrubio 2022-07-24 17:05:32 +02:00
commit 1ac90e03e3
22 changed files with 1665 additions and 0 deletions

94
README.md Normal file
View File

@ -0,0 +1,94 @@
=== Posts From Tag ===
Contributors: jorge-vitrubio
Tags: posts from tag, tag listing, post list from tag, widget, plugin, post listing widget, plugin to list posts, list posts from specific tag, post, sidebar, post from tag, list tag post, tag posts
Version: 1.0.0
Requires at least: 5.0
Tested up to: 6.0
Requires PHP: 5.6.20
Stable tag: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
== Description ==
This plugin is a fork of [Post From Category](https://wordpress.org/plugins/posts-from-category/) by [Manesh Timilsina](https://profiles.wordpress.org/maneshtimilsina/).
Plugin to display posts from specific tag. It comes with multiple layout option to display post list. Option to select tag or exclude post is available which provide advance filter to your requirement. You can enable or disable posted date, thumbnail, read more button and more easily from widget.
Following features are offered by plugin:
* Multiple layout options to list posts
* Title field for your listing
* Select tag from dropdown
* Order posts by author, title, id, date, number of comments, menu order or random
* Order posts in Ascending or Descending order
* Select number of posts to display
* Exclude posts from listing
* Change word length of excerpt
* Enable/Disable featured image
* Select size of featured image
* Enable/Disable publish date
* Enable/Disable read more button and its text
= Useage of Shortcode: =
You can use shortcode to display your posts in the content area of your website. It is supported by Gutenberg Block, Page Builders like Elementor and more.
<pre>[pft layout="layout-one" tag="0" order_by="date" order="DESC" post_number="5" length="10" readmore="Read More" show_date="true" show_image="true" image_size="full"]</pre>
Parameters supported by this plugin are explained below:
* <strong>layout: </strong> Supports 2 layouts (layout-one and layout-two)
* <strong>tag: </strong> Tag ID
* <strong>order_by: </strong> Order your posts by author, title, ID, date, menu_order, comment_count, rand
* <strong>order: </strong> DESC or ASC
* <strong>post_number: </strong> Number of posts to show
* <strong>length: </strong> Length of excerpt. Set 0 to hide excerpt
* <strong>readmore: </strong> Read More text
* <strong>show_date: </strong> true or false
* <strong>show_image: </strong> true or false
* <strong>image_size: </strong> Supports thumbnail, medium, large, full or any size defined by the theme
= Other Useful Plugins =
- [Post from Tag](https://wordpress.org/plugins/advanced-google-recaptcha/)
== Installation ==
1. Download the plugin from plugin directory
2. Extract the file contents
3. Upload the directory to your WordPress plugins' directory ( /wp-content/plugins/ )
4. Activate the plugin from the WordPress Dashboard
5. Go to Widgets, add 'Post From Tag' widget to your desire sidebar
6. Fill in the desired fields and we're good to go
== Frequently Asked Questions ==
= Does this plugin provide shortcode ? =
Yes, you can find PFT shortcode icon at the top bar of WP Editor. Click on it to insert shortcode.
= Can I use this plugin using Gutenberg block or Elementor widget ? =
Yes, you can use the shortcode block of Gutenberg (and shortcode in Elementor widget) to show your posts.
= Where can I find setting for plugin? =
This plugin do not have separate setting page. You can provide necessary details in widgets.
== Screenshots ==
1. Backend View
2. Frontend View
== Changelog ==
= 1.0.0 =
- First publicly distributable version

64
admin.php Normal file
View File

@ -0,0 +1,64 @@
<?php
//add admin page
add_action( 'admin_menu', 'pft_admin_menu' );
function pft_admin_menu() {
add_menu_page(
esc_html__( 'Posts From Tag', 'PFT' ),
esc_html__( 'Posts From Tag', 'PFT' ),
'manage_options',
'pft-options',
'pft_options_page',
'dashicons-editor-ul'
);
}
function pft_options_page(){
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'PFT' ) );
}
?>
<div class="wrap about-wrap theme-info-wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<div class="about-text">
<?php echo esc_html__( 'Plugin to display posts from a specific tag.', 'PFT' ); ?>
</div>
<p>
<a href="https://wordpress.org/support/plugin/posts-from-tag/" class="button button-primary" target="_blank"><?php echo esc_html__( 'Support', 'PFT' ); ?></a>
<a href="https://wordpress.org/support/plugin/posts-from-tag/reviews/" class="button" target="_blank"><?php echo esc_html__( 'Leave a Review', 'PFT' ); ?></a>
<a href="https://wphait.com/request-customization/" class="button" target="_blank"><?php echo esc_html__( 'Request Customization', 'PFT' ); ?></a>
</p>
<div class="feature-section has-2-columns alignleft">
<div class="card">
<h3><?php echo esc_html__( 'How to Use (Using Widget)', 'PFT' ); ?></h3>
<ol>
<li><?php echo esc_html__( 'Go to Appearance >> Widgets', 'PFT' ); ?></li>
<li><?php echo esc_html__( 'Find MT: Posts From Tag widget', 'PFT' ); ?></li>
<li><?php echo esc_html__( 'Add the widget to the sidebar you want to use', 'PFT' ); ?></li>
<li><?php echo esc_html__( 'Fill in the desired fields and we are good to go', 'PFT' ); ?></li>
</ol>
</div>
<div class="card">
<h3><?php echo esc_html__( 'How to Use (Using Shortcode)', 'PFT' ); ?></h3>
<code>[pft layout="layout-one" tag="0" order_by="date" order="DESC" post_number="5" length="10" readmore="Read More" show_date="true" show_image="true" image_size="full"]</code>
<p><a href="https://wordpress.org/plugins/posts-from-tag/" target="_blank"><?php echo esc_html__( 'Click here to see shortcode parameters', 'PFT' ); ?></a></p>
</div>
<div class="card">
<h3><?php echo esc_html__( 'Recommended Plugins', 'PFT' ); ?></h3>
<ol>
<li><a href="https://wordpress.org/plugins/post-from-category/" target="_blank"><?php echo esc_html__( 'Post From Category', 'PFT' ); ?></a></li>
</ol>
</div>
</div>
</div>
<?php
}

11
assets/images/index.html Normal file
View File

@ -0,0 +1,11 @@
<html><head><title> - Revision 2760784: /posts-from-tag/trunk/assets/images</title></head>
<body>
<h2> - Revision 2760784: /posts-from-tag/trunk/assets/images</h2>
<ul>
<li><a href="../">..</a></li>
<li><a href="layout-one.png">layout-one.png</a></li>
<li><a href="layout-two.png">layout-two.png</a></li>
<li><a href="tm-btn.png">tm-btn.png</a></li>
</ul>
<hr noshade><em>Powered by <a href="http://subversion.apache.org/">Apache Subversion</a> version 1.9.5 (r1770682).</em>
</body></html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
assets/images/tm-btn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

12
assets/index.html Normal file
View File

@ -0,0 +1,12 @@
<html><head><title> - Revision 2760784: /posts-from-tag/trunk/assets</title></head>
<body>
<h2> - Revision 2760784: /posts-from-tag/trunk/assets</h2>
<ul>
<li><a href="../">..</a></li>
<li><a href="images/">images/</a></li>
<li><a href="pft-custom.js">pft-custom.js</a></li>
<li><a href="pft-style.css">pft-style.css</a></li>
<li><a href="shortcode-PFT-btn.js">shortcode-PFT-btn.js</a></li>
</ul>
<hr noshade><em>Powered by <a href="http://subversion.apache.org/">Apache Subversion</a> version 1.9.5 (r1770682).</em>
</body></html>

21
assets/pft-custom.js Normal file
View File

@ -0,0 +1,21 @@
( function( $ ) {
$( document ).ready(function( $ ) {
$(".pft-posts-main .pft-post.layout-one").each(function(){
var thumbHeight = $(this).find('.news-thumb img').height();
var infoHeight = $(this).find('.news-text-wrap').height();
if( thumbHeight != null && infoHeight != null && thumbHeight > infoHeight ){
$(this).find('.news-text-wrap').css( 'min-height', thumbHeight+'px');
}
});
});
} )( jQuery );

88
assets/pft-style.css Normal file
View File

@ -0,0 +1,88 @@
/*
* Plugin Name: Posts From Tag
* Version: 1.0.0
* Plugin URI: http://wordpress.org/plugins/posts-from-tag/
* Description: Plugin to display posts from specific tag. It comes with multiple layout option to display post list. Option to select tag or exclude post is available wgich provide advance filter to your requirement. You can enable or disable posted date, thumbnail, read more button and more easily from widget.
* Author: Jorge - vitrubio.net
* Author URI: https://vitrubio.net/
* Original Author: Manesh Timilsina
* Original Author URI: https://wpmanesh.com/
* License: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
.pft-posts-main{
margin-bottom: 10px;
}
.pft-posts-main .pft-post {
float: none;
display: inline-block;
padding-right: 15px;
padding-left: 15px;
vertical-align: top;
margin-left: -3px;
position: relative;
margin-bottom: 20px;
}
.pft-posts-main .pft-post .news-text-wrap {
padding-top: 10px;
}
.pft-posts-main .pft-post .news-text-wrap h2 {
margin-bottom: 5px;
margin-top: 0;
padding-top: 0;
}
.pft-posts-main .pft-post {
margin-left: 0px;
padding-left: 0px;
padding-right: 0px;
width: 100%;
}
.pft-posts-main .pft-post .news-text-wrap p,
.pft-posts-main .news-text-wrap .read-more {
margin-bottom: 0px;
margin-top: 5px;
}
.pft-posts-main .news-text-wrap .posted-date,
.pft-posts-main .news-text-wrap .read-more{
display: inline-block;
width: 100%;
}
.pft-posts-main .pft-post:last-child {
margin-bottom: 0px;
}
.pft-posts-main .news-thumb a img {
max-width: 100%;
height: auto;
}
/* layout one css starts */
.pft-posts-main .pft-post.layout-one .news-thumb {
float: left;
width: 115px;
position: absolute;
}
.pft-posts-main .layout-one .news-text-wrap {
float: left;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 135px;
min-height: 80px;
}
.pft-posts-main .layout-one .news-text-wrap.info-without-space{
padding-left: 0px;
}
/* layout two css starts */
.pft-posts-main .pft-post.layout-two .news-thumb {
width: 100%;
}

108
assets/shortcode-PFT-btn.js Normal file
View File

@ -0,0 +1,108 @@
(function() {
tinymce.PluginManager.add('pftbutton', function( editor, url ) {
editor.addButton( 'pftbutton', {
text: tinyMCE_object_PFC.button_name,
title: tinyMCE_object_PFC.button_title,
icon: true,
image: url + '/images/tm-btn.png',
onclick: function() {
editor.windowManager.open( {
title: tinyMCE_object_PFC.button_title,
body: [
{
type : 'listbox',
name : 'layout',
label : 'Select Layout',
values : [
{ text: 'Layout One', value: 'layout-one' },
{ text: 'Layout Two', value: 'layout-two' },
],
value : 'layout-one' // Sets the default
},
{
type : 'listbox',
name : 'post_tag',
label : 'Select Tag',
values : tinyMCE_object_PFC.post_tag_list,
},
{
type : 'listbox',
name : 'orderby',
label : 'Order By',
values : [
{ text: 'Author', value: 'author' },
{ text: 'Post Title', value: 'title' },
{ text: 'Post ID', value: 'ID' },
{ text: 'Posted Date', value: 'date' },
{ text: 'Menu Order', value: 'menu_order' },
{ text: 'Comment Count', value: 'comment_count' },
{ text: 'Random', value: 'rand' },
],
value : 'date' // Sets the default
},
{
type : 'listbox',
name : 'order',
label : 'Order',
values : [
{ text: 'DESC', value: 'DESC' },
{ text: 'ASC', value: 'ASC' },
],
value : 'DESC' // Sets the default
},
{
type : 'textbox',
name : 'post_number',
label : 'Post Number',
tooltip: 'Use Numeric Value Only',
value : 5
},
{
type : 'textbox',
name : 'length',
label : 'Excerpt Length',
tooltip: 'Use Numeric Value Only. Leave empty to hide excerpt',
value : 10
},
{
type : 'textbox',
name : 'readmore',
label : 'Read More Text',
tooltip: 'Leave empty to hide read more button',
value : 'Read More'
},
{
type : 'checkbox',
name : 'show_date',
label : 'Show Posted Date',
checked : true
},
{
type : 'checkbox',
name : 'show_image',
label : 'Show Thumbnail Image',
checked : true
},
{
type : 'listbox',
name : 'image_size',
label : 'Select Image Size',
values : tinyMCE_object_PFC.image_sizes,
}
],
onsubmit: function( e ) {
editor.insertContent( '[pft layout="' + e.data.layout + '" tag="' + e.data.post_tag + '" order_by="' + e.data.orderby + '" order="' + e.data.order + '" post_number="' + e.data.post_number + '" length="' + e.data.length + '" readmore="' + e.data.readmore + '" show_date="' + e.data.show_date + '" show_image="' + e.data.show_image + '" image_size="' + e.data.image_size + '"]');
}
});
},
});
});
})();

37
functions.php Normal file
View File

@ -0,0 +1,37 @@
<?php
if ( ! function_exists( 'pft_custom_limit_words' ) ) :
/**
* Returns post excerpt.
*
* @since 1.0.0
*
* @param int $length Excerpt length in words.
* @param WP_Post $post_object The post object.
* @return string Post excerpt.
*/
function pft_custom_limit_words( $length = 0, $post_object = null ) {
global $post;
if ( is_null( $post_object ) ) {
$post_object = $post;
}
$length = absint( $length );
if ( 0 === $length ) {
return;
}
$source_content = $post_object->post_content;
if ( ! empty( $post_object->post_excerpt ) ) {
$source_content = $post_object->post_excerpt;
}
$source_content = strip_shortcodes( $source_content );
$trimmed_content = wp_trim_words( $source_content, $length, '...' );
return $trimmed_content;
}
endif;

1
index.php Normal file
View File

@ -0,0 +1 @@
<?php // Silence is golden

BIN
languages/PFT-de_DE.mo Normal file

Binary file not shown.

137
languages/PFT-de_DE.po Normal file
View File

@ -0,0 +1,137 @@
msgid ""
msgstr ""
"Project-Id-Version: Posts From Tag\n"
"POT-Creation-Date: 2014-09-11 21:23+0100\n"
"PO-Revision-Date: 2014-09-11 21:34+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.9\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"
#: post-from-tag.php:31
msgid "Display posts from selected tag"
msgstr "Zeige Beiträge aus der gewählten Kategorie"
#: post-from-tag.php:34
msgid "Posts From Tag"
msgstr "Beiträge aus der Kategorie"
#: post-from-tag.php:93 post-from-tag.php:105
#: post-from-tag.php:123
msgid "Go to"
msgstr "Gehe zu"
#: post-from-tag.php:123
msgid "Read More"
msgstr "Weiterlesen"
#: post-from-tag.php:190
msgid "Title"
msgstr "Überschrift"
#: post-from-tag.php:196
msgid "Select Tag"
msgstr "Kategorie auswählen"
#: post-from-tag.php:198 post-from-tag.php:215
#: post-from-tag.php:240
msgid "Select"
msgstr "Auswählen"
#: post-from-tag.php:212
msgid "Order By"
msgstr "Sortieren nach"
#: post-from-tag.php:218
msgid "Author"
msgstr "Autor"
#: post-from-tag.php:219
msgid "Post Title"
msgstr "Beitragsüberschrift"
#: post-from-tag.php:220
msgid "Post ID"
msgstr "Beitrags ID"
#: post-from-tag.php:221
msgid "Date"
msgstr "Datum"
#: post-from-tag.php:222
msgid "Menu Order"
msgstr "Menü Reiehnfolge"
#: post-from-tag.php:223
msgid "Number of Comments"
msgstr "Anzahl der Kommentare"
#: post-from-tag.php:224
msgid "Random"
msgstr "Zufall"
#: post-from-tag.php:237
msgid "Order"
msgstr "Reihenfolge"
#: post-from-tag.php:243
msgid "Ascending"
msgstr "aufsteigend"
#: post-from-tag.php:244
msgid "Descending"
msgstr "absteigend"
#: post-from-tag.php:257
msgid "Number of Post"
msgstr "Anzahl der Beiträge"
#: post-from-tag.php:264
msgid "Exclude Posts"
msgstr "Beiträge ausschließen"
#: post-from-tag.php:266
msgid "Enter post id separated with comma to exclude multiple posts"
msgstr "Beitrags ID mit Komma trennen um mehrere auszuschließen"
#: post-from-tag.php:272
msgid "Words of Excerpt"
msgstr "Wörter im Textausschnitt"
#: post-from-tag.php:279
msgid "Display/Select Thumbnail"
msgstr "Vorschaubild zeigen"
#: post-from-tag.php:283
msgid "Thumbnail"
msgstr "Vorschaubild"
#: post-from-tag.php:284
msgid "Medium"
msgstr "Mittel"
#: post-from-tag.php:285
msgid "Large"
msgstr "Groß"
#: post-from-tag.php:286
msgid "Full"
msgstr "Voll"
#: post-from-tag.php:300
msgid "Display Post Date"
msgstr "Beitragsdatum anzeigen"
#: post-from-tag.php:305
msgid "Display Read More"
msgstr "Weiterlesen anzeigen"

BIN
languages/PFT-ro_RO.mo Normal file

Binary file not shown.

136
languages/PFT-ro_RO.po Normal file
View File

@ -0,0 +1,136 @@
msgid ""
msgstr ""
"Project-Id-Version: post-from-tag\n"
"POT-Creation-Date: 2015-08-28 11:04+0300\n"
"PO-Revision-Date: 2015-08-28 11:28+0300\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.4\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
"X-Poedit-Basepath: .\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n"
"Language: ro\n"
"X-Poedit-SearchPath-0: ../../post-from-tag\n"
#: ../../post-from-tag/post-from-tag.php:31
msgid "Display posts from selected tag"
msgstr "Afișeaza articolele din categoria selectată"
#: ../../post-from-tag/post-from-tag.php:34
msgid "Posts From Tag"
msgstr "Articole din categoria"
#: ../../post-from-tag/post-from-tag.php:93
#: ../../post-from-tag/post-from-tag.php:105
#: ../../post-from-tag/post-from-tag.php:119
msgid "Go to"
msgstr "Mergeți la"
#: ../../post-from-tag/post-from-tag.php:119
msgid "Read More"
msgstr "Citește mai multe"
#: ../../post-from-tag/post-from-tag.php:186
msgid "Title"
msgstr "Titlu"
#: ../../post-from-tag/post-from-tag.php:193
msgid "Select Tag"
msgstr "Alegeți categoria"
#: ../../post-from-tag/post-from-tag.php:195
#: ../../post-from-tag/post-from-tag.php:212
#: ../../post-from-tag/post-from-tag.php:237
msgid "Select"
msgstr "Alegeți"
#: ../../post-from-tag/post-from-tag.php:209
msgid "Order By"
msgstr "Sorteaza după"
#: ../../post-from-tag/post-from-tag.php:215
msgid "Author"
msgstr "Autor"
#: ../../post-from-tag/post-from-tag.php:216
msgid "Post Title"
msgstr "Titlul articolului"
#: ../../post-from-tag/post-from-tag.php:217
msgid "Post ID"
msgstr "ID articolului"
#: ../../post-from-tag/post-from-tag.php:218
msgid "Date"
msgstr "Data"
#: ../../post-from-tag/post-from-tag.php:219
msgid "Menu Order"
msgstr "Ordinea meniului"
#: ../../post-from-tag/post-from-tag.php:220
msgid "Number of Comments"
msgstr "Numărul comentariilor"
#: ../../post-from-tag/post-from-tag.php:221
msgid "Random"
msgstr "Aleatoriu"
#: ../../post-from-tag/post-from-tag.php:234
msgid "Order"
msgstr "Ordinea"
#: ../../post-from-tag/post-from-tag.php:240
msgid "Ascending"
msgstr "Crescător"
#: ../../post-from-tag/post-from-tag.php:241
msgid "Descending"
msgstr "Descrescător"
#: ../../post-from-tag/post-from-tag.php:254
msgid "Number of Post"
msgstr "Numărul articolului"
#: ../../post-from-tag/post-from-tag.php:261
msgid "Exclude Posts"
msgstr "Excludeți articolul"
#: ../../post-from-tag/post-from-tag.php:263
msgid "Enter post id separated with comma to exclude multiple posts"
msgstr "Introduceți id-ul articolului separat prin virgulă pentru a exclude articole multiple"
#: ../../post-from-tag/post-from-tag.php:269
msgid "Words of Excerpt"
msgstr "Cuvintele rezumatului"
#: ../../post-from-tag/post-from-tag.php:276
msgid "Display/Select Thumbnail"
msgstr "Afișeaza/Selectați pictograma"
#: ../../post-from-tag/post-from-tag.php:280
msgid "Thumbnail"
msgstr "Pictograma"
#: ../../post-from-tag/post-from-tag.php:281
msgid "Medium"
msgstr "Mediu"
#: ../../post-from-tag/post-from-tag.php:282
msgid "Large"
msgstr "Mare"
#: ../../post-from-tag/post-from-tag.php:283
msgid "Full"
msgstr "Plin"
#: ../../post-from-tag/post-from-tag.php:297
msgid "Display Post Date"
msgstr "Afișați data articolului"
#: ../../post-from-tag/post-from-tag.php:302
msgid "Display Read More"
msgstr "Afișează Citește mai mult"

BIN
languages/PFT.mo Normal file

Binary file not shown.

135
languages/PFT.pot Normal file
View File

@ -0,0 +1,135 @@
msgid ""
msgstr ""
"Project-Id-Version: post-from-tag\n"
"POT-Creation-Date: 2014-05-29 12:31+0545\n"
"PO-Revision-Date: 2014-05-29 12:31+0545\n"
"Last-Translator: Manesh Timilsina <smanesh2004@gmail.com>\n"
"Language-Team: \n"
"Language: ne_NP\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.5\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: ../../post-from-tag\n"
#: ../../post-from-tag/post-from-tag.php:31
msgid "Display posts from selected tag"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:34
msgid "Posts From Tag"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:93
#: ../../post-from-tag/post-from-tag.php:105
#: ../../post-from-tag/post-from-tag.php:119
msgid "Go to"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:119
msgid "Read More"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:186
msgid "Title"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:193
msgid "Select Tag"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:195
#: ../../post-from-tag/post-from-tag.php:212
#: ../../post-from-tag/post-from-tag.php:237
msgid "Select"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:209
msgid "Order By"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:215
msgid "Author"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:216
msgid "Post Title"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:217
msgid "Post ID"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:218
msgid "Date"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:219
msgid "Menu Order"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:220
msgid "Number of Comments"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:221
msgid "Random"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:234
msgid "Order"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:240
msgid "Ascending"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:241
msgid "Descending"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:254
msgid "Number of Post"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:261
msgid "Exclude Posts"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:263
msgid "Enter post id separated with comma to exclude multiple posts"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:269
msgid "Words of Excerpt"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:276
msgid "Display/Select Thumbnail"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:280
msgid "Thumbnail"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:281
msgid "Medium"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:282
msgid "Large"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:283
msgid "Full"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:297
msgid "Display Post Date"
msgstr ""
#: ../../post-from-tag/post-from-tag.php:302
msgid "Display Read More"
msgstr ""

15
languages/index.html Normal file
View File

@ -0,0 +1,15 @@
<html><head><title> - Revision 2760784: /posts-from-tag/trunk/languages</title></head>
<body>
<h2> - Revision 2760784: /posts-from-tag/trunk/languages</h2>
<ul>
<li><a href="../">..</a></li>
<li><a href="PFT-de_DE.mo">PFT-de_DE.mo</a></li>
<li><a href="PFT-de_DE.po">PFT-de_DE.po</a></li>
<li><a href="PFT-ro_RO.mo">PFT-ro_RO.mo</a></li>
<li><a href="PFT-ro_RO.po">PFT-ro_RO.po</a></li>
<li><a href="PFT.mo">PFT.mo</a></li>
<li><a href="PFT.pot">PFT.pot</a></li>
<li><a href="index.php">index.php</a></li>
</ul>
<hr noshade><em>Powered by <a href="http://subversion.apache.org/">Apache Subversion</a> version 1.9.5 (r1770682).</em>
</body></html>

1
languages/index.php Normal file
View File

@ -0,0 +1 @@
<?php // Silence is golden

711
post-from-tag.php Normal file
View File

@ -0,0 +1,711 @@
<?php
/*
* Plugin Name: Posts From Tag
* Version: 1.0.0
* Plugin URI: http://wordpress.org/plugins/posts-from-tag/
* Description: Plugin to display posts from specific tag. It comes with multiple layout option to display post list. Option to select tag or exclude post is available wgich provide advance filter to your requirement. You can enable or disable posted date, thumbnail, read more button and more easily from widget.
* Author: Jorge - vitrubio.net
* Author URI: https://vitrubio.net/
* Original Author: Manesh Timilsina
* Original Author URI: https://wpmanesh.com/
* License: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
define( 'PFT_DIR', rtrim( plugin_dir_path( __FILE__ ), '/' ) );
require_once PFT_DIR . '/functions.php';
require_once PFT_DIR . '/admin.php';
class PFTWidget extends WP_Widget {
/**
* Declares the PFTWidget class.
*
*/
public function __construct() {
global $control_ops, $post_tag, $post_num, $post_length;
load_plugin_textdomain( 'PFT', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
add_action( 'wp_enqueue_scripts', array( $this, 'pft_load_frontend_scripts' ), 5 );
$widget_ops = array(
'classname' => 'pft-widget',
'description' => esc_html__( 'Display posts from selected tag', 'PFT')
);
parent::__construct('PFTWidget', esc_html__( 'MT: Posts From Tag', 'PFT' ), $widget_ops, $control_ops);
$this->alt_option_name = 'widget_pft';
}
function pft_load_frontend_scripts() {
wp_enqueue_style( 'pft-style', rtrim( plugin_dir_url( __FILE__ ), '/' ) . '/assets/pft-style.css' );
wp_enqueue_script( 'pft-custom', rtrim( plugin_dir_url( __FILE__ ), '/' ) . '/assets/pft-custom.js', array( 'jquery' ), '5.0.1' );
}
/**
* Displays the Widget
*
*/
function widget($args, $instance){
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
$layout = ! empty( $instance['layout'] ) ? $instance['layout'] : '';
$post_tag = ! empty( $instance['post_tag'] ) ? $instance['post_tag'] : 0;
$post_order_by = ! empty( $instance['post_order_by'] ) ? $instance['post_order_by'] : '';
$post_order = ! empty( $instance['post_order'] ) ? $instance['post_order'] : '';
$post_num = ! empty( $instance['post_num'] ) ? $instance['post_num'] : 5;
$post_exclude = ! empty( $instance['post_exclude'] ) ? $instance['post_exclude'] : '';
$post_length = !empty( $instance['post_length'] ) ? $instance['post_length'] : '';
$readmore_text = ! empty( $instance['readmore_text'] ) ? $instance['readmore_text'] : '';
// $show_posttitle = ! empty( $instance['show_posttitle'] ) ? $instance['show_posttitle'] : true;
$date = ! empty( $instance['date'] ) ? $instance['date'] : false;
$thumbnail = ! empty( $instance['thumbnail'] ) ? $instance['thumbnail'] : false;
$post_thumbs = ! empty( $instance['post_thumbs'] ) ? $instance['post_thumbs'] : '';
echo $args['before_widget']; ?>
<div class="pft-posts-wrap">
<?php
if ( ! empty( $title ) ) {
echo $args['before_title'] . esc_html( $title ). $args['after_title'];
} ?>
<div class="pft-posts-inner">
<?php
pft_call_shortcode_details( $layout, $post_tag, $post_order_by, $post_order, $post_num, $post_exclude, $post_length, $readmore_text, $date, $thumbnail, $post_thumbs );
// pft_call_shortcode_details( $layout, $post_tag, $post_order_by, $post_order, $post_num, $post_exclude, $post_length, $readmore_text, $date, $thumbnail, $post_thumbs, $show_posttitle );
?>
</div>
</div>
<?php
echo $args['after_widget'];
}
/**
* Saves the widgets settings.
*
*/
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['layout'] = sanitize_text_field( $new_instance['layout'] );
$instance['post_tag'] = absint( $new_instance['post_tag'] );
$instance['post_order_by'] = sanitize_text_field( $new_instance['post_order_by'] );
$instance['post_order'] = sanitize_text_field( $new_instance['post_order'] );
$instance['post_num'] = absint( $new_instance['post_num'] );
$instance['post_exclude'] = sanitize_text_field( $new_instance['post_exclude'] );
$instance['post_length'] = absint( $new_instance['post_length'] );
$instance['readmore_text'] = sanitize_text_field( $new_instance['readmore_text'] );
// $instance['show_posttitle'] = (bool) $new_instance['show_posttitle'] ? true : false;
$instance['date'] = (bool) $new_instance['date'] ? true : false;
$instance['thumbnail'] = (bool) $new_instance['thumbnail'] ? true : false;
$instance['post_thumbs'] = sanitize_text_field( $new_instance['post_thumbs'] );
return $instance;
}
/**
* Creates the edit form for the widget.
*
*/
function form($instance){
$instance = wp_parse_args( (array) $instance, array(
'title' => '',
'layout' => 'layout-one',
'post_tag' => '',
'post_order_by' => 'date',
'post_order' => 'DESC',
'post_num' => 5,
'post_exclude' => '',
'post_length' => 10,
'readmore_text' => esc_html__( 'Read More', 'PFT' ),
// 'show_posttitle' => true,
'date' => true,
'thumbnail' => true,
'post_thumbs' => 'thumbnail',
)
);
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'PFT' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'layout' ) ); ?>"><?php esc_html_e( 'Select Layout:', 'PFT' ); ?></label>
</p>
<p>
<input type="radio" <?php checked( $instance[ 'layout' ], 'layout-one' ); ?> id="<?php echo $this->get_field_id( 'layout-one' ); ?>" name="<?php echo $this->get_field_name('layout'); ?>" value="layout-one" />
<label for="<?php echo $this->get_field_id( 'layout-one' ); ?>"><img src="<?php echo plugins_url( 'assets/images/layout-one.png', __FILE__ ); ?>" class="layout-one"></label>
<input type="radio" <?php checked( $instance[ 'layout' ], 'layout-two' ); ?> id="<?php echo $this->get_field_id( 'layout-two' ); ?>" name="<?php echo $this->get_field_name('layout'); ?>" value="layout-two" />
<label for="<?php echo $this->get_field_id( 'layout-two' ); ?>"><img src="<?php echo plugins_url( 'assets/images/layout-two.png', __FILE__ ); ?>" class="layout-two"></label>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'post_tag' ) ); ?>"><?php esc_html_e( 'Select Tag:', 'PFT' ); ?></label>
<?php
$cat_args = array(
'orderby' => 'name',
'hide_empty' => 1,
'class' => 'widefat',
'taxonomy' => 'post_tag',
'name' => $this->get_field_name( 'post_tag' ),
'id' => $this->get_field_id( 'post_tag' ),
'selected' => absint( $instance['post_tag'] ),
'show_option_all' => esc_html__( 'All Categories','PFT' ),
);
wp_dropdown_categories( $cat_args );
?>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'post_order_by' ) ); ?>"><?php esc_html_e( 'Order By:', 'PFT' ); ?></label>
<?php
$this->dropdown_post_order_by( array(
'id' => $this->get_field_id( 'post_order_by' ),
'name' => $this->get_field_name( 'post_order_by' ),
'selected' => esc_attr( $instance['post_order_by'] ),
)
);
?>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'post_order' ) ); ?>"><?php esc_html_e( 'Order:', 'PFT' ); ?></label>
<?php
$this->dropdown_post_order( array(
'id' => $this->get_field_id( 'post_order' ),
'name' => $this->get_field_name( 'post_order' ),
'selected' => esc_attr( $instance['post_order'] ),
)
);
?>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'post_num' ) ); ?>"><?php esc_html_e( 'Number of Posts:', 'PFT' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'post_num' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'post_num' ) ); ?>" type="number" value="<?php echo absint( $instance['post_num'] ); ?>" />
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'post_exclude' ) ); ?>"><?php esc_html_e( 'Exclude Posts:', 'PFT' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'post_exclude' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'post_exclude' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['post_exclude'] ); ?>" />
<small><?php esc_html_e( 'Enter post id separated with comma to exclude multiple posts', 'PFT' ); ?></small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_name('post_length') ); ?>">
<?php esc_html_e('Excerpt Length:', 'PFT'); ?>
</label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id('post_length') ); ?>" name="<?php echo esc_attr( $this->get_field_name('post_length') ); ?>" type="number" value="<?php echo absint( $instance['post_length'] ); ?>" />
<small><?php esc_html_e( 'Use 0 to hide Excerpt/Desc', 'PFT' ); ?></small>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'readmore_text' ) ); ?>"><?php esc_html_e( 'Read More Text:', 'PFT' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'readmore_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'readmore_text' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['readmore_text'] ); ?>" />
<small><?php esc_html_e( 'Leave this field empty to hide read more button', 'PFT' ); ?></small>
</p>
<!--
<p>
<input class="checkbox" type="checkbox" <?php //checked( $instance['show_posttitle'] ); ?> id="<?php //echo esc_attr( $this->get_field_id( 'show_posttitle' ) ); ?>" name="<?php //echo esc_attr( $this->get_field_name( 'show_posttitle' ) ); ?>" />
<label for="<?php //echo esc_attr( $this->get_field_id( 'show_posttitle' ) ); ?>"><?php //esc_html_e( 'Show Post Title', 'PFT' ); ?></label>
</p>
-->
<p>
<input class="checkbox" type="checkbox" <?php checked( $instance['date'] ); ?> id="<?php echo esc_attr( $this->get_field_id( 'date' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'date' ) ); ?>" />
<label for="<?php echo esc_attr( $this->get_field_id( 'date' ) ); ?>"><?php esc_html_e( 'Show Posted Date', 'PFT' ); ?></label>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked( $instance['thumbnail'] ); ?> id="<?php echo esc_attr( $this->get_field_id( 'thumbnail' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'thumbnail' ) ); ?>" />
<label for="<?php echo esc_attr( $this->get_field_id( 'thumbnail' ) ); ?>"><?php esc_html_e( 'Display/Select Thumbnail', 'PFT' ); ?></label>
</p>
<p>
<?php
$this->dropdown_post_thumbnail( array(
'id' => $this->get_field_id( 'post_thumbs' ),
'name' => $this->get_field_name( 'post_thumbs' ),
'selected' => esc_attr( $instance['post_thumbs'] ),
)
);
?>
</p>
<?php
} //end of form
function dropdown_post_order_by( $args ) {
$defaults = array(
'id' => '',
'class' => 'widefat',
'name' => '',
'selected' => 0,
);
$r = wp_parse_args( $args, $defaults );
$output = '';
$choices = array(
'author' => esc_html__('Author', 'PFT'),
'title' => esc_html__('Post Title', 'PFT'),
'ID' => esc_html__('Post ID', 'PFT'),
'date' => esc_html__('Date', 'PFT'),
'menu_order' => esc_html__('Menu Order', 'PFT'),
'comment_count' => esc_html__('Number of Comments', 'PFT'),
'rand' => esc_html__('Random', 'PFT')
);
if ( ! empty( $choices ) ) {
$output = "<select name='" . esc_attr( $r['name'] ) . "' id='" . esc_attr( $r['id'] ) . "' class='" . esc_attr( $r['class'] ) . "'>\n";
foreach ( $choices as $key => $choice ) {
$output .= '<option value="' . esc_attr( $key ) . '" ';
$output .= selected( $r['selected'], $key, false );
$output .= '>' . esc_html( $choice ) . '</option>\n';
}
$output .= "</select>\n";
}
echo $output;
}
function dropdown_post_order( $args ) {
$defaults = array(
'id' => '',
'class' => 'widefat',
'name' => '',
'selected' => 0,
);
$r = wp_parse_args( $args, $defaults );
$output = '';
$choices = array(
'ASC' => esc_html__('Ascending', 'PFT'),
'DESC' => esc_html__('Descending', 'PFT')
);
if ( ! empty( $choices ) ) {
$output = "<select name='" . esc_attr( $r['name'] ) . "' id='" . esc_attr( $r['id'] ) . "' class='" . esc_attr( $r['class'] ) . "'>\n";
foreach ( $choices as $key => $choice ) {
$output .= '<option value="' . esc_attr( $key ) . '" ';
$output .= selected( $r['selected'], $key, false );
$output .= '>' . esc_html( $choice ) . '</option>\n';
}
$output .= "</select>\n";
}
echo $output;
}
function dropdown_post_thumbnail( $args ) {
$defaults = array(
'id' => '',
'class' => 'widefat',
'name' => '',
'selected' => 0,
);
$r = wp_parse_args( $args, $defaults );
$output = '';
global $_wp_additional_image_sizes;
$get_intermediate_image_sizes = get_intermediate_image_sizes();
$choices = array(
'thumbnail' => esc_html__('Thumbnail', 'PFT'),
'medium' => esc_html__('Medium', 'PFT'),
'large' => esc_html__('Large', 'PFT'),
'full' => esc_html__('Full (Original)', 'PFT')
);
$show_dimension = true;
if ( true === $show_dimension ) {
foreach ( array( 'thumbnail', 'medium', 'large' ) as $key => $_size ) {
$choices[ $_size ] = $choices[ $_size ] . ' (' . get_option( $_size . '_size_w' ) . 'x' . get_option( $_size . '_size_h' ) . ')';
}
}
if ( ! empty( $_wp_additional_image_sizes ) && is_array( $_wp_additional_image_sizes ) ) {
foreach ( $_wp_additional_image_sizes as $key => $size ) {
$choices[ $key ] = $key;
if ( true === $show_dimension ) {
$choices[ $key ] .= ' (' . $size['width'] . 'x' . $size['height'] . ')';
}
}
}
if ( ! empty( $allowed ) ) {
foreach ( $choices as $key => $value ) {
if ( ! in_array( $key, $allowed ) ) {
unset( $choices[ $key ] );
}
}
}
if ( ! empty( $choices ) ) {
$output = "<select name='" . esc_attr( $r['name'] ) . "' id='" . esc_attr( $r['id'] ) . "' class='" . esc_attr( $r['class'] ) . "'>\n";
foreach ( $choices as $key => $choices ) {
$output .= '<option value="' . esc_attr( $key ) . '" ';
$output .= selected( $r['selected'], $key, false );
$output .= '>' . esc_html( $choices ) . '</option>\n';
}
$output .= "</select>\n";
}
echo $output;
}
}// END class
/**
* Register widget.
*
* Calls 'widgets_init' action after widget has been registered.
*/
function pftwidget_init() {
register_widget('PFTWidget');
}
add_action('widgets_init', 'pftwidget_init');
// Shortcode added
function pft_init_shortcode( $atts ) {
extract( shortcode_atts(
array(
'layout' => 'layout-one',
'cat' => '',
'order_by' => 'date',
'order' => 'DESC',
'post_number' => 5,
'exclude' => '',
'length' => 10,
'readmore' => esc_html__('Read More', 'PFT'),
'show_date' => true,
'show_image' => true,
'image_size' => 'thumbnail',
),
$atts
));
ob_start();
pft_call_shortcode_details( $layout, $cat, $order_by, $order, $post_number, $exclude, $length, $readmore, $show_date, $show_image, $image_size );
return ob_get_clean();
}
add_shortcode( 'pft', 'pft_init_shortcode' );
// Shortcode function details
function pft_call_shortcode_details( $layout, $post_tag, $order_by, $order, $post_num, $exclude, $desc_length, $readmore_text, $show_date, $show_thumbnail, $thumb_size ){
if( 'layout-one' == $layout ){
$layout_class = 'layout-one';
}else{
$layout_class = 'layout-two';
}
$exclude_id = explode(',', $exclude);
$p_args = array(
'orderby' => $order_by,
'order' => $order,
'no_found_rows' => true,
'post__not_in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => true,
'post_status' => 'publish',
'posts_per_page' => absint( $post_num ),
'post__not_in' => $exclude_id
);
if ( absint( $post_tag ) > 0 ) {
$p_args['cat'] = absint( $post_tag );
}
$p_query = new WP_Query( $p_args );
if($p_query->have_posts()){ ?>
<div class="pft-posts-main">
<?php
while($p_query->have_posts()){
$p_query->the_post(); ?>
<div class="pft-post <?php echo $layout_class; ?>">
<?php
if( 'true' == $show_thumbnail && has_post_thumbnail() ){ ?>
<div class="news-thumb">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( $thumb_size ); ?></a>
</div>
<?php
}
if( 'true' == $show_thumbnail && has_post_thumbnail() ){
$align_class = 'info-with-space';
}else{
$align_class = 'info-without-space';
} ?>
<div class="news-text-wrap <?php echo $align_class; ?>">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php
if( 'true' == $show_date ){ ?>
<span class="posted-date"><?php echo esc_html( get_the_date() ); ?></span>
<?php
}
if( 0 != absint( $desc_length ) ){
$desc_content = pft_custom_limit_words( absint($desc_length) );
echo wp_kses_post($desc_content) ? wpautop( wp_kses_post($desc_content) ) : '';
}
if( !empty( $readmore_text ) ){ ?>
<a href="<?php the_permalink(); ?>" class="read-more"><?php echo esc_html( $readmore_text ); ?></a>
<?php }
?>
</div><!-- .news-text-wrap -->
</div>
<?php
}
wp_reset_postdata(); ?>
</div>
<?php
}
}
// Add cutome button to editor
add_action( 'init', 'pft_init_editor_button_add' );
if ( ! function_exists( 'pft_init_editor_button_add' ) ) {
function pft_init_editor_button_add() {
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
return;
}
if ( get_user_option( 'rich_editing' ) !== 'true' ) {
return;
}
add_filter( 'mce_external_plugins', 'pft_add_custom_editor_button' );
add_filter( 'mce_buttons', 'pft_register_custom_editor_button' );
}
}
if ( ! function_exists( 'pft_add_custom_editor_button' ) ) {
function pft_add_custom_editor_button( $plugin_array ) {
$plugin_array['pftbutton'] = rtrim( plugin_dir_url( __FILE__ ), '/' ) . '/assets/shortcode-PFT-btn.js';
return $plugin_array;
}
}
if ( ! function_exists( 'pft_register_custom_editor_button' ) ) {
function pft_register_custom_editor_button( $buttons ) {
array_push( $buttons, 'pftbutton' );
return $buttons;
}
}
add_action ( 'after_wp_tiny_mce', 'pft_tinymce_custom_vars' );
if ( !function_exists( 'pft_tinymce_custom_vars' ) ) {
function pft_tinymce_custom_vars() {
$cat_args = array(
'orderby' => 'name',
'hide_empty' => 1,
'taxonomy' => 'post_tag',
);
$cat_count = 1;
$cat_params[0] = array(
'text' => esc_html__( 'Select Tag', 'PFT' ),
'value' => 0
);
$post_tags = get_categories( $cat_args );
foreach ( $post_tags as $cat ) {
$cat_params[$cat_count]['text'] = $cat->name;
$cat_params[$cat_count]['value'] = $cat->term_id;
$cat_count++;
}
//For image sizes
$image_size[0] = array(
'text' => esc_html__( 'Select Image Size', 'PFT' ),
'value' => ''
);
global $_wp_additional_image_sizes;
$get_intermediate_image_sizes = get_intermediate_image_sizes();
$choices = array(
'thumbnail' => esc_html__('Thumbnail', 'PFT'),
'medium' => esc_html__('Medium', 'PFT'),
'large' => esc_html__('Large', 'PFT'),
'full' => esc_html__('Full (Original)', 'PFT')
);
$show_dimension = true;
if ( true === $show_dimension ) {
foreach ( array( 'thumbnail', 'medium', 'large' ) as $key => $_size ) {
$choices[ $_size ] = $choices[ $_size ] . ' (' . get_option( $_size . '_size_w' ) . 'x' . get_option( $_size . '_size_h' ) . ')';
}
}
if ( ! empty( $_wp_additional_image_sizes ) && is_array( $_wp_additional_image_sizes ) ) {
foreach ( $_wp_additional_image_sizes as $key => $size ) {
$choices[ $key ] = $key;
if ( true === $show_dimension ) {
$choices[ $key ] .= ' (' . $size['width'] . 'x' . $size['height'] . ')';
}
}
}
if ( ! empty( $allowed ) ) {
foreach ( $choices as $key => $value ) {
if ( ! in_array( $key, $allowed ) ) {
unset( $choices[ $key ] );
}
}
}
if ( ! empty( $choices ) ) {
$img_count = 1;
foreach ( $choices as $key => $value ) {
$image_size[$img_count]['text'] = $value;
$image_size[$img_count]['value'] = $key;
$img_count++;
}
} ?>
<script type="text/javascript">
var tinyMCE_object_PFC = <?php echo json_encode(
array(
'button_name' => esc_html__(' PFT ', 'PFT'),
'button_title' => esc_html__('Posts From Tag', 'PFT'),
'post_tag_list' => $cat_params,
'image_sizes' => $image_size,
)
);
?>;
</script><?php
}
}

94
readme.txt Normal file
View File

@ -0,0 +1,94 @@
=== Posts From Tag ===
Contributors: jorge-vitrubio
Tags: posts from tag, tag listing, post list from tag, widget, plugin, post listing widget, plugin to list posts, list posts from specific tag, post, sidebar, post from tag, list tag post, tag posts
Version: 1.0.0
Requires at least: 5.0
Tested up to: 6.0
Requires PHP: 5.6.20
Stable tag: 1.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
== Description ==
This plugin is a fork of [Post From Category](https://wordpress.org/plugins/posts-from-category/) by [Manesh Timilsina](https://profiles.wordpress.org/maneshtimilsina/).
Plugin to display posts from specific tag. It comes with multiple layout option to display post list. Option to select tag or exclude post is available which provide advance filter to your requirement. You can enable or disable posted date, thumbnail, read more button and more easily from widget.
Following features are offered by plugin:
* Multiple layout options to list posts
* Title field for your listing
* Select tag from dropdown
* Order posts by author, title, id, date, number of comments, menu order or random
* Order posts in Ascending or Descending order
* Select number of posts to display
* Exclude posts from listing
* Change word length of excerpt
* Enable/Disable featured image
* Select size of featured image
* Enable/Disable publish date
* Enable/Disable read more button and its text
= Useage of Shortcode: =
You can use shortcode to display your posts in the content area of your website. It is supported by Gutenberg Block, Page Builders like Elementor and more.
<pre>[pft layout="layout-one" tag="0" order_by="date" order="DESC" post_number="5" length="10" readmore="Read More" show_date="true" show_image="true" image_size="full"]</pre>
Parameters supported by this plugin are explained below:
* <strong>layout: </strong> Supports 2 layouts (layout-one and layout-two)
* <strong>tag: </strong> Tag ID
* <strong>order_by: </strong> Order your posts by author, title, ID, date, menu_order, comment_count, rand
* <strong>order: </strong> DESC or ASC
* <strong>post_number: </strong> Number of posts to show
* <strong>length: </strong> Length of excerpt. Set 0 to hide excerpt
* <strong>readmore: </strong> Read More text
* <strong>show_date: </strong> true or false
* <strong>show_image: </strong> true or false
* <strong>image_size: </strong> Supports thumbnail, medium, large, full or any size defined by the theme
= Other Useful Plugins =
- [Post from Tag](https://wordpress.org/plugins/advanced-google-recaptcha/)
== Installation ==
1. Download the plugin from plugin directory
2. Extract the file contents
3. Upload the directory to your WordPress plugins' directory ( /wp-content/plugins/ )
4. Activate the plugin from the WordPress Dashboard
5. Go to Widgets, add 'Post From Tag' widget to your desire sidebar
6. Fill in the desired fields and we're good to go
== Frequently Asked Questions ==
= Does this plugin provide shortcode ? =
Yes, you can find PFT shortcode icon at the top bar of WP Editor. Click on it to insert shortcode.
= Can I use this plugin using Gutenberg block or Elementor widget ? =
Yes, you can use the shortcode block of Gutenberg (and shortcode in Elementor widget) to show your posts.
= Where can I find setting for plugin? =
This plugin do not have separate setting page. You can provide necessary details in widgets.
== Screenshots ==
1. Backend View
2. Frontend View
== Changelog ==
= 1.0.0 =
- First publicly distributable version