Plugin Readmore is now localized
This commit is contained in:
parent
3fa488455b
commit
8e34af7ec8
4
fp-plugins/readmore/lang/lang.de-de.php
Normal file
4
fp-plugins/readmore/lang/lang.de-de.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
$lang ['plugin'] ['readmore'] = array(
|
||||||
|
'readmore' => '[Weiterlesen...]'
|
||||||
|
);
|
4
fp-plugins/readmore/lang/lang.en-us.php
Normal file
4
fp-plugins/readmore/lang/lang.en-us.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
$lang ['plugin'] ['readmore'] = array(
|
||||||
|
'readmore' => '[Read more...]'
|
||||||
|
);
|
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
Plugin Name: ReadMore
|
|
||||||
Plugin URI: http://www.nowhereland.it/
|
|
||||||
Description: ReadMore plugin. Chops a lengthy entry and appends a "read more" link :)
|
|
||||||
Author: NoWhereMan
|
|
||||||
Version: 0.703
|
|
||||||
Author URI: http://www.nowhereland.it/
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Plugin Name: ReadMore
|
||||||
|
* Plugin URI: http://www.nowhereland.it/
|
||||||
|
* Description: ReadMore plugin. Chops a lengthy entry and appends a "read more" link :)
|
||||||
|
* Author: NoWhereMan
|
||||||
|
* Version: 0.703
|
||||||
|
* Author URI: http://www.nowhereland.it/
|
||||||
|
*/
|
||||||
|
|
||||||
// $MODE specifies when you want to chop your entry
|
// $MODE specifies when you want to chop your entry
|
||||||
|
|
||||||
@ -28,21 +28,19 @@ Author URI: http://www.nowhereland.it/
|
|||||||
// feel free and then let us know :) )
|
// feel free and then let us know :) )
|
||||||
|
|
||||||
// we recommend using $MODE = 'manual' (SPB legacy behaviour :) )
|
// we recommend using $MODE = 'manual' (SPB legacy behaviour :) )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function plugin_readmore_main($string) {
|
function plugin_readmore_main($string) {
|
||||||
|
|
||||||
global $fp_params;
|
global $fp_params;
|
||||||
|
|
||||||
$MODE = 'manual';
|
$MODE = 'manual';
|
||||||
|
|
||||||
$CHOP_AT = 4; // characters or sentences
|
$CHOP_AT = 4; // characters or sentences
|
||||||
|
|
||||||
|
$lang = lang_load('plugin:readmore');
|
||||||
|
$readmoreString = $lang ['plugin'] ['readmore'] ['readmore'];
|
||||||
|
|
||||||
global $fpdb;
|
global $fpdb;
|
||||||
$q = & $fpdb->getQuery();
|
$q = & $fpdb->getQuery();
|
||||||
|
|
||||||
|
|
||||||
if (($q && !$q->single) && !isset($_GET ['page'])) {
|
if (($q && !$q->single) && !isset($_GET ['page'])) {
|
||||||
if ($q)
|
if ($q)
|
||||||
list ($id) = $q->getLastEntry();
|
list ($id) = $q->getLastEntry();
|
||||||
@ -52,30 +50,22 @@ function plugin_readmore_main($string) {
|
|||||||
if ($MODE == 'auto' || $MODE == 'semiauto') {
|
if ($MODE == 'auto' || $MODE == 'semiauto') {
|
||||||
if (strlen($string) > $CHOP_AT) {
|
if (strlen($string) > $CHOP_AT) {
|
||||||
|
|
||||||
return substr($string, 0, $CHOP_AT).
|
return substr($string, 0, $CHOP_AT) . "… <span class=\"readmore\"><a href=\"" . get_permalink($id) . "#readmore-{$id}\">" . $readmoreString . "</a></span>";
|
||||||
"… <span class=\"readmore\"><a href=\"".
|
|
||||||
get_permalink($id)."#readmore-{$id}\">[Read More...]</a></span>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($MODE == 'manual' || $MODE == 'semiauto') {
|
if ($MODE == 'manual' || $MODE == 'semiauto') {
|
||||||
if (($p = strpos($string, '[more]')) !== false) {
|
if (($p = strpos($string, '[more]')) !== false) {
|
||||||
return substr($string, 0, $p).
|
return substr($string, 0, $p) . "<span class=\"readmore\"><a href=\"" . get_permalink($id) . "#readmore-{$id}\">" . $readmoreString . "</a></span>";
|
||||||
"<span class=\"readmore\"><a href=\""
|
|
||||||
.get_permalink($id)."#readmore-{$id}\">[Read More...]</a></span>";
|
|
||||||
}
|
}
|
||||||
} elseif ($MODE == 'sentence') {
|
} elseif ($MODE == 'sentence') {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
if ($v = preg_match_all('|[.!?]\s|', $string, $matches, PREG_OFFSET_CAPTURE)) {
|
if ($v = preg_match_all('|[.!?]\s|', $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||||
|
|
||||||
if (count($matches [0]) > $CHOP_AT) {
|
if (count($matches [0]) > $CHOP_AT) {
|
||||||
$string = substr($string, 0, $matches[0][$CHOP_AT-1][1]).
|
$string = substr($string, 0, $matches [0] [$CHOP_AT - 1] [1]) . ". <span class=\"readmore\"><a href=\"" . get_permalink($id) . "#readmore-{$id}\">" . $readmoreString . "</a></span>";
|
||||||
". <span class=\"readmore\"><a href=\""
|
|
||||||
.get_permalink($id)."#readmore-{$id}\">[Read More...]</a></span>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($q && $q->single) || isset($fp_params ['entry'])) {
|
if (($q && $q->single) || isset($fp_params ['entry'])) {
|
||||||
@ -87,5 +77,4 @@ function plugin_readmore_main($string) {
|
|||||||
|
|
||||||
add_filter('the_content', 'plugin_readmore_main', 1);
|
add_filter('the_content', 'plugin_readmore_main', 1);
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user