From 8e34af7ec831697b8a0161f1b354e89b32f1df3b Mon Sep 17 00:00:00 2001 From: azett Date: Sat, 2 Feb 2019 17:10:57 +0100 Subject: [PATCH] Plugin Readmore is now localized --- fp-plugins/readmore/lang/lang.de-de.php | 4 + fp-plugins/readmore/lang/lang.en-us.php | 4 + fp-plugins/readmore/plugin.readmore.php | 119 +++++++++++------------- 3 files changed, 62 insertions(+), 65 deletions(-) create mode 100644 fp-plugins/readmore/lang/lang.de-de.php create mode 100644 fp-plugins/readmore/lang/lang.en-us.php diff --git a/fp-plugins/readmore/lang/lang.de-de.php b/fp-plugins/readmore/lang/lang.de-de.php new file mode 100644 index 0000000..5783532 --- /dev/null +++ b/fp-plugins/readmore/lang/lang.de-de.php @@ -0,0 +1,4 @@ + '[Weiterlesen...]' +); diff --git a/fp-plugins/readmore/lang/lang.en-us.php b/fp-plugins/readmore/lang/lang.en-us.php new file mode 100644 index 0000000..b090dba --- /dev/null +++ b/fp-plugins/readmore/lang/lang.en-us.php @@ -0,0 +1,4 @@ + '[Read more...]' +); diff --git a/fp-plugins/readmore/plugin.readmore.php b/fp-plugins/readmore/plugin.readmore.php index 8b1441e..4008cc8 100755 --- a/fp-plugins/readmore/plugin.readmore.php +++ b/fp-plugins/readmore/plugin.readmore.php @@ -1,91 +1,80 @@ getQuery(); - - - if (($q && !$q->single) && !isset($_GET['page'])) { + + $lang = lang_load('plugin:readmore'); + $readmoreString = $lang ['plugin'] ['readmore'] ['readmore']; + + global $fpdb; + $q = & $fpdb->getQuery(); + + if (($q && !$q->single) && !isset($_GET ['page'])) { if ($q) - list($id) = $q->getLastEntry(); - else - $id =''; - - if ($MODE == 'auto' || $MODE == 'semiauto' ) { + list ($id) = $q->getLastEntry(); + else + $id = ''; + + if ($MODE == 'auto' || $MODE == 'semiauto') { if (strlen($string) > $CHOP_AT) { - - return substr($string, 0, $CHOP_AT). - "… [Read More...]"; + + return substr($string, 0, $CHOP_AT) . "… " . $readmoreString . ""; } - } - - if ($MODE == 'manual' || $MODE == 'semiauto' ) { - if (($p = strpos($string, '[more]'))!==false){ - return substr($string, 0, $p). - "[Read More...]"; + } + + if ($MODE == 'manual' || $MODE == 'semiauto') { + if (($p = strpos($string, '[more]')) !== false) { + return substr($string, 0, $p) . "" . $readmoreString . ""; } } elseif ($MODE == 'sentence') { $matches = array(); - if ($v=preg_match_all('|[.!?]\s|', $string, $matches, PREG_OFFSET_CAPTURE)) { - - if (count($matches[0]) > $CHOP_AT) { - $string = substr($string, 0, $matches[0][$CHOP_AT-1][1]). - ". [Read More...]"; + if ($v = preg_match_all('|[.!?]\s|', $string, $matches, PREG_OFFSET_CAPTURE)) { + if (count($matches [0]) > $CHOP_AT) { + $string = substr($string, 0, $matches [0] [$CHOP_AT - 1] [1]) . ". " . $readmoreString . ""; } } } - } - - if (($q && $q->single) || isset($fp_params['entry'])) { + + if (($q && $q->single) || isset($fp_params ['entry'])) { $string = str_replace('[more]', "", $string); } - + return $string; } add_filter('the_content', 'plugin_readmore_main', 1); - ?>