Version Description
Download this release
Release Info
Developer | marynixie |
Plugin | Related Posts Thumbnails Plugin for WordPress |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- img/default.png +0 -0
- locale/related-posts-thumbnails-ru_RU.mo +0 -0
- locale/related-posts-thumbnails-ru_RU.po +132 -0
- readme.txt +64 -0
- related-posts-thumbnails.php +313 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
img/default.png
ADDED
Binary file
|
locale/related-posts-thumbnails-ru_RU.mo
ADDED
Binary file
|
locale/related-posts-thumbnails-ru_RU.po
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Russian translation of Related-Posts-Thubmnails plugin
|
2 |
+
# Copyright (C) 2010 M.I.Shaldybina
|
3 |
+
# This file is distributed under the same license as the Related-Posts-Thubmnails package.
|
4 |
+
# Maria Shaldybina <mary@shaldybina.com>, 2010
|
5 |
+
msgid ""
|
6 |
+
msgstr ""
|
7 |
+
"Project-Id-Version: Related Posts Thubmnails 1.0\n"
|
8 |
+
"Report-Msgid-Bugs-To: \n"
|
9 |
+
"POT-Creation-Date: 2010-05-19 17:17-0700\n"
|
10 |
+
"PO-Revision-Date: 2010-05-19 17:38-0700\n"
|
11 |
+
"Last-Translator: M.Shaldybina <mary@shaldybina.com>\n"
|
12 |
+
"Language-Team: ru_RU <mary@shaldybina.com>\n"
|
13 |
+
"Language: ru_RU\n"
|
14 |
+
"MIME-Version: 1.0\n"
|
15 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
16 |
+
"Content-Transfer-Encoding: 8bit\n"
|
17 |
+
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
18 |
+
"X-Poedit-Language: Russian\n"
|
19 |
+
"X-Poedit-Country: RUSSIA\n"
|
20 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
21 |
+
|
22 |
+
#: related-posts-thumbnails.php:148
|
23 |
+
msgid "Related Posts Thumbnails"
|
24 |
+
msgstr "Миниатюры похожих записей"
|
25 |
+
|
26 |
+
#: related-posts-thumbnails.php:148
|
27 |
+
msgid "Related Posts Thumbs"
|
28 |
+
msgstr "Похожие записи"
|
29 |
+
|
30 |
+
#: related-posts-thumbnails.php:154
|
31 |
+
msgid "No access"
|
32 |
+
msgstr "Нет доступа"
|
33 |
+
|
34 |
+
#: related-posts-thumbnails.php:170
|
35 |
+
msgid "Settings updated"
|
36 |
+
msgstr "Настройки обновлены"
|
37 |
+
|
38 |
+
#: related-posts-thumbnails.php:182
|
39 |
+
msgid "Related Posts Thumbnails Settings"
|
40 |
+
msgstr "Настройки миниатюр похожих записей"
|
41 |
+
|
42 |
+
#: related-posts-thumbnails.php:188
|
43 |
+
msgid "General Display Options"
|
44 |
+
msgstr "Общие свойства отображения"
|
45 |
+
|
46 |
+
#: related-posts-thumbnails.php:191
|
47 |
+
msgid "Display options"
|
48 |
+
msgstr "Параметр отображения"
|
49 |
+
|
50 |
+
#: related-posts-thumbnails.php:194
|
51 |
+
msgid "Show on single posts only"
|
52 |
+
msgstr "Показывать только на отдельной странице"
|
53 |
+
|
54 |
+
#: related-posts-thumbnails.php:198
|
55 |
+
msgid "Top text"
|
56 |
+
msgstr "Верхний текст"
|
57 |
+
|
58 |
+
#: related-posts-thumbnails.php:204
|
59 |
+
msgid "Number of similar posts to display"
|
60 |
+
msgstr "Количество похожих записей для отображения"
|
61 |
+
|
62 |
+
#: related-posts-thumbnails.php:212
|
63 |
+
msgid "Style options"
|
64 |
+
msgstr "Опции стиля"
|
65 |
+
|
66 |
+
#: related-posts-thumbnails.php:215
|
67 |
+
msgid "Background color"
|
68 |
+
msgstr "Цвет заднего фона"
|
69 |
+
|
70 |
+
#: related-posts-thumbnails.php:221
|
71 |
+
msgid "Background color on mouse over"
|
72 |
+
msgstr "Цвет заднего фона при наведении курсора"
|
73 |
+
|
74 |
+
#: related-posts-thumbnails.php:227
|
75 |
+
msgid "Border color"
|
76 |
+
msgstr "Цвет границы"
|
77 |
+
|
78 |
+
#: related-posts-thumbnails.php:233
|
79 |
+
msgid "Font color"
|
80 |
+
msgstr "Цвет шрифта"
|
81 |
+
|
82 |
+
#: related-posts-thumbnails.php:239
|
83 |
+
msgid "Font family"
|
84 |
+
msgstr "Стиль шрифта"
|
85 |
+
|
86 |
+
#: related-posts-thumbnails.php:245
|
87 |
+
msgid "Font size"
|
88 |
+
msgstr "Размер шрифта"
|
89 |
+
|
90 |
+
#: related-posts-thumbnails.php:251
|
91 |
+
msgid "Text maximum length"
|
92 |
+
msgstr "Максимальная длина текста"
|
93 |
+
|
94 |
+
#: related-posts-thumbnails.php:259
|
95 |
+
msgid "Relation Builder Options"
|
96 |
+
msgstr "Настройки связей"
|
97 |
+
|
98 |
+
#: related-posts-thumbnails.php:262
|
99 |
+
msgid "Relation based on"
|
100 |
+
msgstr "Связи расчитываются на основе"
|
101 |
+
|
102 |
+
#: related-posts-thumbnails.php:265
|
103 |
+
msgid "Categories"
|
104 |
+
msgstr "Категорий"
|
105 |
+
|
106 |
+
#: related-posts-thumbnails.php:267
|
107 |
+
msgid "Tags"
|
108 |
+
msgstr "Меток"
|
109 |
+
|
110 |
+
#: related-posts-thumbnails.php:269
|
111 |
+
msgid "Categories and Tags"
|
112 |
+
msgstr "Категорий и меток"
|
113 |
+
|
114 |
+
#: related-posts-thumbnails.php:275
|
115 |
+
msgid "Thumbnails options"
|
116 |
+
msgstr "Настройки миниатюр"
|
117 |
+
|
118 |
+
#: related-posts-thumbnails.php:278
|
119 |
+
msgid "Post-thumbnails name"
|
120 |
+
msgstr "Название миниатюры"
|
121 |
+
|
122 |
+
#: related-posts-thumbnails.php:286
|
123 |
+
msgid "Your theme has to support post-thumbnails to have more choices"
|
124 |
+
msgstr "Для более широкого выбора размеров, ваша тема должна поддерживать post-thumbnails"
|
125 |
+
|
126 |
+
#: related-posts-thumbnails.php:291
|
127 |
+
msgid "Default image URL"
|
128 |
+
msgstr "Ссылка на картинку по умолчанию, в случае, если нет миниатюры"
|
129 |
+
|
130 |
+
#: related-posts-thumbnails.php:299
|
131 |
+
msgid "Save Changes"
|
132 |
+
msgstr "Сохранить изменения"
|
readme.txt
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Related Posts Thumbnails ===
|
2 |
+
Contributors: marynixie
|
3 |
+
Donate link: http://wordpress.shaldybina.com/donate
|
4 |
+
Tags: related, posts, thumbnail
|
5 |
+
Requires at least: 2.9
|
6 |
+
Tested up to: 2.9.2
|
7 |
+
Stable tag: 0.1
|
8 |
+
|
9 |
+
Customizable plugin, that nicely displays related posts thumbnails under the post.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
This plugin will add related posts thumbnails after the post. Plugin allows to customize thumbnail sizes, display settings and type of relation.
|
14 |
+
|
15 |
+
By default it uses generated by Wordpress thumbnail for the first image appeared in the post, that was uploaded on the server with sizes as set in Media settings. You can select between 'thumbnail' and 'medium' size options. In addition if your theme supports Post Thumbnails feature introduced in Wordpress 2.9 you can specify custom thumbnail size.
|
16 |
+
|
17 |
+
Thumbnails are arranged in columns under the post with related posts title under each post thumbnail. Colors of background, border, text, text sizes and background on mouse over can be customized. See screenshot.
|
18 |
+
|
19 |
+
You can specify number of related posts to display, top text, style settings, default image URL. You can select type of relation - categories, tags or categories and tags. You can specify to show related thumbnails on the main page or only on single page.
|
20 |
+
|
21 |
+
Related Links:
|
22 |
+
|
23 |
+
* <a href="http://wordpress.shaldybina.com/plugins/related-posts-thumbnails/" title="Related Posts Thumbnails Plugin for WordPress">Plugin Homepage</a>
|
24 |
+
* <a href="http://codex.wordpress.org/Post_Thumbnails" title="Wordpress page about Post Thumbnails feature">Wordpress Post Thumbnails feature page</a>
|
25 |
+
* <a href="http://wordpress.org/extend/plugins/regenerate-thumbnails/" title="Regenerate Thumbnails plugin">Regenerate Thumbnails</a> - plugin for regenerating images after changing Media settings or theme post thumbnails support options
|
26 |
+
* <a href="http://wordpress.shaldybina.com/plugins/generate-post-thumbnails/" title="Generate Post Thumbnails Plugin for WordPress">Generate Post Thumbnails Plugin</a> - plugin for assigning post thumbnails for existing posts
|
27 |
+
* <a href="http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/" title="New in WordPress 2.9: Post Thumbnail Images - Mark on WordPress">New in WordPress 2.9: Post Thumbnail Images « Mark on WordPress</a>
|
28 |
+
|
29 |
+
== Installation ==
|
30 |
+
|
31 |
+
1. Extract zip in the /wp-content/plugins/ directory.
|
32 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
33 |
+
1. Customize plugin settings under Settings -> Related Posts Thumbs
|
34 |
+
|
35 |
+
== Frequently Asked Questions ==
|
36 |
+
|
37 |
+
= How does this plugin decide which image to use as post thumbnail? =
|
38 |
+
|
39 |
+
If your theme supports Wordpress Posts Thumbnail feature and post has a specified Post Thumbnail as seen on Edit Post page, when this image will be used as a post thumbnail in related posts. The size of the image is determined by plugin setting 'Post-thumbnails name'.
|
40 |
+
|
41 |
+
If your theme does not support Post Thumbnail feature or post has no assigned thumbnail, when the first image on the post will be used as a thumbnail.
|
42 |
+
|
43 |
+
= Does plugin support external images, e.g. uploaded on Flickr? =
|
44 |
+
|
45 |
+
There is no such support in the current version of the plugin.
|
46 |
+
|
47 |
+
= What is default image URL? =
|
48 |
+
|
49 |
+
If there are no images of the specified size in the post, or file does not exist on the server the default image will be used as a post thumbnail. You can upload your image on server and specify its URL in plugin settings.
|
50 |
+
|
51 |
+
== Screenshots ==
|
52 |
+
|
53 |
+
1. Plugin in action
|
54 |
+
1. Plugin settings page
|
55 |
+
|
56 |
+
== Changelog ==
|
57 |
+
|
58 |
+
= 0.1 =
|
59 |
+
* Released plugin initial version
|
60 |
+
|
61 |
+
== Upgrade Notice ==
|
62 |
+
|
63 |
+
= 0.1 =
|
64 |
+
The first released version
|
related-posts-thumbnails.php
ADDED
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php /*
|
2 |
+
Plugin Name: Related Posts Thumbnails
|
3 |
+
Plugin URI: http://wordpress.shaldybina.com/plugins/related-posts-thumbnails/
|
4 |
+
Description: Showing related posts thumbnails under the post.
|
5 |
+
Version: 1.0
|
6 |
+
Author: Maria Shaldybina
|
7 |
+
Author URI: http://shaldybina.com/
|
8 |
+
*/
|
9 |
+
/* Copyright 2010 Maria I Shaldybina
|
10 |
+
|
11 |
+
This program is free software; you can redistribute it and/or modify
|
12 |
+
it under the terms of the GNU General Public License as published by
|
13 |
+
the Free Software Foundation; either version 2 of the License, or
|
14 |
+
(at your option) any later version.
|
15 |
+
|
16 |
+
This program is distributed in the hope that it will be useful,
|
17 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
+
GNU General Public License for more details.
|
20 |
+
*/
|
21 |
+
class RelatedPostsThumbnails {
|
22 |
+
|
23 |
+
/* Default values */
|
24 |
+
public $single_only = '1';
|
25 |
+
public $top_text = '<h3>Related posts:</h3>';
|
26 |
+
public $number = 3;
|
27 |
+
public $relation = 'categories';
|
28 |
+
public $default_image;
|
29 |
+
public $poststh_name = 'thumbnail';
|
30 |
+
public $background = '#FFFFFF';
|
31 |
+
public $hoverbackground = '#EEEEEF';
|
32 |
+
public $border_color = '#DDDDDD';
|
33 |
+
public $font_color = '#333333';
|
34 |
+
public $font_family = 'Arial';
|
35 |
+
public $font_size = '12';
|
36 |
+
public $text_length = '100';
|
37 |
+
|
38 |
+
function RelatedPostsThumbnails() { // initialization
|
39 |
+
load_plugin_textdomain( 'related-posts-thumbnails', false, basename( dirname( __FILE__ ) ) . '/locale' );
|
40 |
+
$this->default_image = WP_PLUGIN_URL . '/related-posts-thumbnails/img/default.png';
|
41 |
+
add_filter( 'the_content', array( $this, 'relpoststh_show' ) );
|
42 |
+
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
function relpoststh_show($content) { // Displaying related posts on the site
|
46 |
+
if ( $this->is_relpoststh_show() ) {
|
47 |
+
$content .= get_option( 'relpoststh_top_text', $this->top_text );
|
48 |
+
$content .= $this->relpoststh_get();
|
49 |
+
}
|
50 |
+
return $content;
|
51 |
+
}
|
52 |
+
|
53 |
+
function relpoststh_get() { // Retrieve Related Posts HTML for output
|
54 |
+
$id = get_the_ID();
|
55 |
+
$relation = get_option( 'relpoststh_relation', $this->relation );
|
56 |
+
$posts_number = get_option( 'relpoststh_number', $this->number );
|
57 |
+
$poststhname = get_option( 'relpoststh_poststhname', $this->poststhname );
|
58 |
+
$text_length = get_option( 'relpoststh_textlength', $this->text_length );
|
59 |
+
|
60 |
+
$args = array( 'orderby' => 'rand',
|
61 |
+
'caller_get_posts' => true,
|
62 |
+
'posts_per_page' => $posts_number,
|
63 |
+
'post__not_in' => array( $id ) );
|
64 |
+
|
65 |
+
$posts = array();
|
66 |
+
$q = new WP_Query;
|
67 |
+
|
68 |
+
if ( $poststhname == 'thumbnail' || $poststhname == 'medium' || $poststhname == 'large' ) { // get thumbnail size for basic sizes
|
69 |
+
$width = get_option( "{$poststhname}_size_w" );
|
70 |
+
$height = get_option( "{$poststhname}_size_h" );
|
71 |
+
}
|
72 |
+
elseif ( current_theme_supports( 'post-thumbnails' ) ) { // get sizes for theme supported thumbnails
|
73 |
+
global $_wp_additional_image_sizes;
|
74 |
+
$width = $_wp_additional_image_sizes[ $poststhname ][ 'width' ];
|
75 |
+
$height = $_wp_additional_image_sizes[ $poststhname ][ 'height' ];
|
76 |
+
}
|
77 |
+
|
78 |
+
/* Getting posts by relation */
|
79 |
+
if ( $relation == 'categories' || $relation == 'both' ) {
|
80 |
+
$query_args = array( 'tag__in' => wp_get_object_terms( $id, array( 'post_tag' ), array( 'fields' => 'ids' ) ) );
|
81 |
+
$posts = array_merge( $posts, $q->query( array_merge( $args, $query_args ) ) );
|
82 |
+
}
|
83 |
+
|
84 |
+
if ( $relation == 'tags' || $relation == 'both' ) {
|
85 |
+
$query_args = array( 'category__in' => wp_get_object_terms( $id, array( 'category' ), array( 'fields' => 'ids' ) ) );
|
86 |
+
$posts = array_merge( $posts, $q->query( array_merge( $args, $query_args ) ) );
|
87 |
+
}
|
88 |
+
|
89 |
+
if ( $relation == 'both' ) {
|
90 |
+
foreach ( $posts as $post ) {
|
91 |
+
$posts_unique[ $post->ID ] = $post;
|
92 |
+
}
|
93 |
+
shuffle( $posts_unique );
|
94 |
+
$posts = array_slice( $posts_unique, 0, $posts_number );
|
95 |
+
}
|
96 |
+
|
97 |
+
if ( count( $posts ) ) { // rendering related posts HTML
|
98 |
+
$output = '<div style="clear: both"></div><div style="border: 0pt none ; margin: 0pt; padding: 0pt;">';
|
99 |
+
foreach( $posts as $post ) {
|
100 |
+
$image = '';
|
101 |
+
$url = '';
|
102 |
+
if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) { // using built in Wordpress feature
|
103 |
+
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
|
104 |
+
if ( $post_thumbnail_id ) {
|
105 |
+
$image = wp_get_attachment_image_src( $post_thumbnail_id, $poststhname );
|
106 |
+
$url = $image[0];
|
107 |
+
}
|
108 |
+
}
|
109 |
+
else { // Theme does not support post-thumbnails, or post does not have assigned thumbnail
|
110 |
+
$wud = wp_upload_dir();
|
111 |
+
preg_match_all( '|<img.*?src=[\'"](' . $wud['baseurl'] . '.*?)[\'"].*?>|i', $post->post_content, $matches ); // searching for the first uploaded image in text
|
112 |
+
if ( isset( $matches ) ) $image = $matches[1][0];
|
113 |
+
if ( strlen( trim( $image ) ) > 0 ) {
|
114 |
+
$image_sizes = getimagesize( $image );
|
115 |
+
if ( $image_sizes[0] == $width ) { // if this image is the same size as we need
|
116 |
+
$url = $image;
|
117 |
+
}
|
118 |
+
else { // if not, search for resized thumbnail according to Wordpress thumbnails naming function
|
119 |
+
$url = preg_replace( '/(-[0-9]+x[0-9]+)?(\.[^\.]*)$/', '-' . $width . 'x' . $height . '$2', $image );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
if ( empty( $url ) || false === file( $url ) ) { // using default image if no image was found or no such file on server
|
124 |
+
$url = get_option( 'relpoststh_default_image', $this->default_image );
|
125 |
+
}
|
126 |
+
$title = ( strlen( $post->post_title ) > $text_length ) ? substr( $post->post_title, 0, $text_length) . '...' : $post->post_title;
|
127 |
+
$output .= '<a onmouseout="this.style.backgroundColor=\'' . get_option( 'relpoststh_background', $this->background ) . '\'" onmouseover="this.style.backgroundColor=\'' . get_option( 'relpoststh_hoverbackground', $this->hoverbackground ) . '\'" style="border-right: 1px solid ' . get_option( 'relpoststh_bordercolor', $this->border_color ) . '; border-bottom: medium none; margin: 0pt; padding: 6px; display: block; float: left; text-decoration: none; text-align: left; cursor: pointer;" href="' . get_permalink( $post->ID ) . '">';
|
128 |
+
$output .= '<div style="border: 0pt none ; margin: 0pt; padding: 0pt; width: ' . $width . 'px; height: ' . ( $height + 75 ) . 'px;">';
|
129 |
+
$output .= '<div style="border: 0pt none ; margin: 0pt; padding: 0pt; background: transparent url(' . $url . ') no-repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: ' . $width . 'px; height: ' . $height . 'px;"></div>';
|
130 |
+
$output .= '<div style="border: 0pt none; margin: 3px 0pt 0pt; padding: 0pt; font-family: ' . get_option( 'relpoststh_fontfamily', $this->font_family ) . '; font-style: normal; font-variant: normal; font-weight: normal; font-size: ' . get_option( 'relpoststh_fontsize', $this->font_size ) . 'px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: ' . get_option( 'relpoststh_fontcolor', $this->font_color ) . ';">' . $title . '</div>';
|
131 |
+
$output .= '</div>';
|
132 |
+
$output .= '</a>';
|
133 |
+
|
134 |
+
} // end foreach
|
135 |
+
$output .= '</div><div style="clear: both"></div>';
|
136 |
+
} // end if found posts
|
137 |
+
return $output;
|
138 |
+
}
|
139 |
+
|
140 |
+
function is_relpoststh_show() { // Checking display options
|
141 |
+
return ( is_single() || ! get_option( 'relpoststh_single_only', $this->single_only ) );
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Related Posts Thumbnails
|
146 |
+
*/
|
147 |
+
function admin_menu() {
|
148 |
+
$page = add_options_page( __( 'Related Posts Thumbnails', 'related-posts-thumbnails' ), __( 'Related Posts Thumbs', 'related-posts-thumbnails' ), 'administrator', 'related-posts-thumbnails', array( $this, 'admin_interface' ) );
|
149 |
+
}
|
150 |
+
|
151 |
+
function admin_interface() { // Admin interface
|
152 |
+
if ( $_POST['action'] == 'update' ) {
|
153 |
+
if ( !current_user_can( 'manage_options' ) ) {
|
154 |
+
wp_die( __( 'No access', 'related-posts-thumbnails' ) );
|
155 |
+
}
|
156 |
+
check_admin_referer( 'related-posts-thumbnails' );
|
157 |
+
update_option( 'relpoststh_single_only', $_POST['relpoststh_single_only'] );
|
158 |
+
update_option( 'relpoststh_top_text', $_POST['relpoststh_top_text'] );
|
159 |
+
update_option( 'relpoststh_number', $_POST['relpoststh_number'] );
|
160 |
+
update_option( 'relpoststh_relation', $_POST['relpoststh_relation'] );
|
161 |
+
update_option( 'relpoststh_default_image', $_POST['relpoststh_default_image'] );
|
162 |
+
update_option( 'relpoststh_poststhname', $_POST['relpoststh_poststhname'] );
|
163 |
+
update_option( 'relpoststh_background', $_POST['relpoststh_background'] );
|
164 |
+
update_option( 'relpoststh_hoverbackground', $_POST['relpoststh_hoverbackground'] );
|
165 |
+
update_option( 'relpoststh_bordercolor', $_POST['relpoststh_bordercolor'] );
|
166 |
+
update_option( 'relpoststh_fontcolor', $_POST['relpoststh_fontcolor'] );
|
167 |
+
update_option( 'relpoststh_fontsize', $_POST['relpoststh_fontsize'] );
|
168 |
+
update_option( 'relpoststh_fontfamily', $_POST['relpoststh_fontfamily'] );
|
169 |
+
update_option( 'relpoststh_textlength', $_POST['relpoststh_textlength'] );
|
170 |
+
echo "<div class='updated fade'><p>" . __( 'Settings updated', 'related-posts-thumbnails' ) ."</p></div>";
|
171 |
+
}
|
172 |
+
$available_sizes = array( 'thumbnail' => 'thumbnail', 'medium' => 'medium' );
|
173 |
+
if ( current_theme_supports( 'post-thumbnails' ) ) {
|
174 |
+
global $_wp_additional_image_sizes;
|
175 |
+
$available_sizes = array_merge( $available_sizes, $_wp_additional_image_sizes );
|
176 |
+
}
|
177 |
+
$relpoststh_single_only = get_option( 'relpoststh_single_only', $this->single_only );
|
178 |
+
$relpoststh_relation = get_option( 'relpoststh_relation', $this->relation );
|
179 |
+
?>
|
180 |
+
<div class="wrap">
|
181 |
+
<div class="icon32" id="icon-options-general"><br></div>
|
182 |
+
<h2><?php _e( 'Related Posts Thumbnails Settings', 'related-posts-thumbnails' ); ?></h2>
|
183 |
+
<form action="?page=related-posts-thumbnails" method="POST">
|
184 |
+
<input type="hidden" name="action" value="update" />
|
185 |
+
<?php wp_nonce_field( 'related-posts-thumbnails' ); ?>
|
186 |
+
<div class="metabox-holder">
|
187 |
+
<div class="postbox">
|
188 |
+
<h3><?php _e( 'General Display Options', 'related-posts-thumbnails' ); ?>:</h3>
|
189 |
+
<table class="form-table">
|
190 |
+
<tr valign="top">
|
191 |
+
<th scope="row"><?php _e( 'Display options', 'related-posts-thumbnails' ); ?>:</th>
|
192 |
+
<td>
|
193 |
+
<input type="checkbox" name="relpoststh_single_only" id="relpoststh_single_only" value="1" <?php if ( $relpoststh_single_only ) echo 'checked="checked"'; ?>/>
|
194 |
+
<label for="relpoststh_single_only"><?php _e( 'Show on single posts only', 'related-posts-thumbnails' ); ?></label><br />
|
195 |
+
</td>
|
196 |
+
</tr>
|
197 |
+
<tr>
|
198 |
+
<th scope="row"><?php _e( 'Top text', 'related-posts-thumbnails' ); ?>:</th>
|
199 |
+
<td>
|
200 |
+
<input type="text" name="relpoststh_top_text" value="<?php echo get_option( 'relpoststh_top_text', $this->top_text ); ?>" size="50"/>
|
201 |
+
</td>
|
202 |
+
</tr>
|
203 |
+
<tr>
|
204 |
+
<th scope="row"><?php _e( 'Number of similar posts to display', 'related-posts-thumbnails' ); ?>:</th>
|
205 |
+
<td>
|
206 |
+
<input type="text" name="relpoststh_number" value="<?php echo get_option( 'relpoststh_number', $this->number ); ?>" size="2"/>
|
207 |
+
</td>
|
208 |
+
</tr>
|
209 |
+
</table>
|
210 |
+
</div>
|
211 |
+
<div class="postbox">
|
212 |
+
<h3><?php _e( 'Style options', 'related-posts-thumbnails' ); ?>:</h3>
|
213 |
+
<table class="form-table">
|
214 |
+
<tr valign="top">
|
215 |
+
<th scope="row"><?php _e( 'Background color', 'related-posts-thumbnails' ); ?>:</th>
|
216 |
+
<td>
|
217 |
+
<input type="text" name="relpoststh_background" value="<?php echo get_option( 'relpoststh_background', $this->background ); ?>" size="7"/>
|
218 |
+
</td>
|
219 |
+
</tr>
|
220 |
+
<tr valign="top">
|
221 |
+
<th scope="row"><?php _e( 'Background color on mouse over', 'related-posts-thumbnails' ); ?>:</th>
|
222 |
+
<td>
|
223 |
+
<input type="text" name="relpoststh_hoverbackground" value="<?php echo get_option( 'relpoststh_hoverbackground', $this->hoverbackground ); ?>" size="7"/>
|
224 |
+
</td>
|
225 |
+
</tr>
|
226 |
+
<tr valign="top">
|
227 |
+
<th scope="row"><?php _e( 'Border color', 'related-posts-thumbnails' ); ?>:</th>
|
228 |
+
<td>
|
229 |
+
<input type="text" name="relpoststh_bordercolor" value="<?php echo get_option( 'relpoststh_bordercolor', $this->border_color )?>" size="7"/>
|
230 |
+
</td>
|
231 |
+
</tr>
|
232 |
+
<tr valign="top">
|
233 |
+
<th scope="row"><?php _e( 'Font color', 'related-posts-thumbnails' ); ?>:</th>
|
234 |
+
<td>
|
235 |
+
<input type="text" name="relpoststh_fontcolor" value="<?php echo get_option( 'relpoststh_fontcolor', $this->font_color ); ?>" size="7"/>
|
236 |
+
</td>
|
237 |
+
</tr>
|
238 |
+
<tr valign="top">
|
239 |
+
<th scope="row"><?php _e( 'Font family', 'related-posts-thumbnails' ); ?>:</th>
|
240 |
+
<td>
|
241 |
+
<input type="text" name="relpoststh_fontfamily" value="<?php echo get_option( 'relpoststh_fontfamily', $this->font_family )?>" size="50"/>
|
242 |
+
</td>
|
243 |
+
</tr>
|
244 |
+
<tr valign="top">
|
245 |
+
<th scope="row"><?php _e( 'Font size', 'related-posts-thumbnails' ); ?>:</th>
|
246 |
+
<td>
|
247 |
+
<input type="text" name="relpoststh_fontsize" value="<?php echo get_option( 'relpoststh_fontsize', $this->font_size )?>" size="7"/>
|
248 |
+
</td>
|
249 |
+
</tr>
|
250 |
+
<tr valign="top">
|
251 |
+
<th scope="row"><?php _e( 'Text maximum length', 'related-posts-thumbnails' ); ?>:</th>
|
252 |
+
<td>
|
253 |
+
<input type="text" name="relpoststh_textlength" value="<?php echo get_option( 'relpoststh_textlength', $this->text_length )?>" size="7"/>
|
254 |
+
</td>
|
255 |
+
</tr>
|
256 |
+
</table>
|
257 |
+
</div>
|
258 |
+
<div class="postbox">
|
259 |
+
<h3><?php _e( 'Relation Builder Options', 'related-posts-thumbnails' ); ?>:</h3>
|
260 |
+
<table class="form-table">
|
261 |
+
<tr valign="top">
|
262 |
+
<th scope="row"><?php _e( 'Relation based on', 'related-posts-thumbnails' ); ?>:</th>
|
263 |
+
<td>
|
264 |
+
<input type="radio" name="relpoststh_relation" id="relpoststh_relation_categories" value="categories" <?php if ( $relpoststh_relation == 'categories' ) echo 'checked="checked"'; ?>/>
|
265 |
+
<label for="relpoststh_relation_categories"><?php _e( 'Categories', 'related-posts-thumbnails' ); ?></label><br />
|
266 |
+
<input type="radio" name="relpoststh_relation" id="relpoststh_relation_tags" value="tags" <?php if ( $relpoststh_relation == 'tags' ) echo 'checked="checked"'; ?>/>
|
267 |
+
<label for="relpoststh_relation_tags"><?php _e( 'Tags', 'related-posts-thumbnails' ); ?></label><br />
|
268 |
+
<input type="radio" name="relpoststh_relation" id="relpoststh_relation_both" value="both" <?php if ( $relpoststh_relation == 'both' ) echo 'checked="checked"'; ?>/>
|
269 |
+
<label for="relpoststh_relation_both"><?php _e( 'Categories and Tags', 'related-posts-thumbnails' ); ?></label><br />
|
270 |
+
</td>
|
271 |
+
</tr>
|
272 |
+
</table>
|
273 |
+
</div>
|
274 |
+
<div class="postbox">
|
275 |
+
<h3><?php _e( 'Thumbnails options', 'related-posts-thumbnails' ); ?>:</h3>
|
276 |
+
<table class="form-table">
|
277 |
+
<tr valign="top">
|
278 |
+
<th scope="row"><?php _e( 'Post-thumbnails name', 'related-posts-thumbnails' ); ?>:</th>
|
279 |
+
<td>
|
280 |
+
<select name="relpoststh_poststhname">
|
281 |
+
<?php foreach ( $available_sizes as $size_name => $size ) : ?>
|
282 |
+
<option <?php if ( $size_name == get_option('relpoststh_poststhname', $this->poststhname) ) echo 'selected'; ?>><?php echo $size_name; ?></option>
|
283 |
+
<?php endforeach; ?>
|
284 |
+
</select>
|
285 |
+
<?php if ( !current_theme_supports( 'post-thumbnails' ) ) : ?>
|
286 |
+
(<?php _e( 'Your theme has to support post-thumbnails to have more choices', 'related-posts-thumbnails' ); ?>)
|
287 |
+
<?php endif; ?>
|
288 |
+
</td>
|
289 |
+
</tr>
|
290 |
+
<tr>
|
291 |
+
<th scope="row"><?php _e( 'Default image URL', 'related-posts-thumbnails' ); ?>:</th>
|
292 |
+
<td>
|
293 |
+
<input type="text" name="relpoststh_default_image" value="<?php echo get_option('relpoststh_default_image', $this->default_image );?>" size="50"/>
|
294 |
+
</td>
|
295 |
+
</tr>
|
296 |
+
</table>
|
297 |
+
</div>
|
298 |
+
|
299 |
+
<input name="Submit" value="<?php _e( 'Save Changes', 'related-posts-thumbnails' ); ?>" type="submit">
|
300 |
+
</div>
|
301 |
+
</form>
|
302 |
+
</div>
|
303 |
+
<?php
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
add_action( 'init', 'related_posts_thumbnails' );
|
308 |
+
|
309 |
+
function related_posts_thumbnails() {
|
310 |
+
global $related_posts_thumbnails;
|
311 |
+
$related_posts_thumbnails = new RelatedPostsThumbnails();
|
312 |
+
}
|
313 |
+
?>
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|