Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
text=auto eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.code-workspace
42 changes: 23 additions & 19 deletions display-posts-pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,79 @@
* Version: 1.0.0
* Author: Bill Erickson
* Author URI: https://www.billerickson.net
* Domain Path: /languages
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume
* that you can use any other version of the GPL.
*
* 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.
*
*/

/**
* Display Posts - Pagination Links
*
*/
function be_dps_pagination_links( $output, $atts, $listing ) {
if( empty( $atts['pagination'] ) || !empty( $atts['offset'] ) )
if ( empty( $atts['pagination'] ) || ! empty( $atts['offset'] ) ) {
return $output;
}

global $wp;
$base = home_url( $wp->request );

$format = 'dps_paged';
if( intval( $atts['pagination'] ) > 1 )
if ( intval( $atts['pagination'] ) > 1 ) {
$format .= '_' . intval( $atts['pagination'] );
}
$format = '?' . $format . '=%#%';

$current = !empty( $listing->query['paged'] ) ? $listing->query['paged'] : 1;
$current = ! empty( $listing->query['paged'] ) ? $listing->query['paged'] : 1;

$args = array(
'base' => trailingslashit( $base ) . $format,
'base' => trailingslashit( $base ) . $format,
'format' => $format,
'current' => $current,
'total' => $listing->max_num_pages,
'prev_text' => 'Previous',
'next_text' => 'Next',
'prev_text' => __( 'Previous' ),
'next_text' => __( 'Next' ),
);

$nav_output = '';
$navigation = paginate_links( apply_filters( 'display_posts_shortcode_paginate_links', $args, $atts ) );
if( $navigation ) {
$nav_output .= '<nav class="display-posts-pagination" role="navigation">';
$nav_output .= '<h2 class="screen-reader-text">Navigation</h2>';
$nav_output .= '<div class="nav-links">' . $navigation . '</div>';
$nav_output .= '</nav>';
if ( $navigation ) {
$nav_output .= '<nav class="display-posts-pagination" role="navigation">';
$nav_output .= '<h2 class="screen-reader-text">Navigation</h2>';
$nav_output .= '<div class="nav-links">' . $navigation . '</div>';
$nav_output .= '</nav>';
}

if( !empty( $atts['pagination_inside'] ) && filter_var( $atts['pagination_inside'], FILTER_VALIDATE_BOOLEAN ) )
if ( ! empty( $atts['pagination_inside'] ) && filter_var( $atts['pagination_inside'], FILTER_VALIDATE_BOOLEAN ) ) {
$output = $nav_output . $output;
else
} else {
$output .= $nav_output;
}

return $output;
}
add_filter( 'display_posts_shortcode_wrapper_close', 'be_dps_pagination_links', 10, 3 );

/**
* Display Posts - Pagination Args
*
*/
function be_dps_pagination_args( $args, $atts ) {
if( empty( $atts['pagination'] ) )
if ( empty( $atts['pagination'] ) ) {
return $args;
}

$format = 'dps_paged';
if( intval( $atts['pagination'] ) > 1 )
if ( intval( $atts['pagination'] ) > 1 ) {
$format .= '_' . intval( $atts['pagination'] );
}

if( ! empty( $_GET[ $format ] ) )
if ( ! empty( $_GET[ $format ] ) ) {
$args['paged'] = intval( $_GET[ $format ] );
}

return $args;
}
Expand Down
Binary file added languages/de_DE.mo
Binary file not shown.
27 changes: 27 additions & 0 deletions languages/de_DE.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
msgid ""
msgstr ""
"Project-Id-Version: Display Posts Pagination v1.0.0\n"
"Report-Msgid-Bugs-To: Translator Name <translations@example.com>\n"
"POT-Creation-Date: 2023-01-21 18:08+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Jay Trees <github.jay@grandel.anonaddy.me>\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"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
"X-Poedit-Basepath: ..\n"
"X-Generator: Poedit 3.2\n"
"X-Poedit-SearchPath-0: .\n"

#: display-posts-pagination.php:42
msgid "Previous"
msgstr "Zurück"

#: display-posts-pagination.php:43
msgid "Next"
msgstr "Weiter"
54 changes: 54 additions & 0 deletions languages/display-posts-pagination.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: "
"Display Posts Pagination "
"v1.0.0\n"
"Report-Msgid-Bugs-To: "
"Translator Name "
"<translations@example."
"com>\n"
"POT-Creation-Date: "
"2023-01-21 18:08+0100\n"
"PO-Revision-Date: \n"
"Last-Translator: Your "
"Name <you@example.com>\n"
"Language-Team: \n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/"
"plain; charset=UTF-8\n"
"Content-Transfer-"
"Encoding: 8bit\n"
"Plural-Forms: "
"nplurals=2; plural=n != "
"1;\n"
"X-Textdomain-Support: "
"yesX-Generator: Poedit "
"1.6.4\n"
"X-Poedit-SourceCharset: "
"UTF-8\n"
"X-Poedit-KeywordsList: "
"__;_e;esc_html_e;"
"esc_html_x:1,2c;"
"esc_html__;esc_attr_e;"
"esc_attr_x:1,2c;"
"esc_attr__;_ex:1,2c;"
"_nx:4c,1,2;"
"_nx_noop:4c,1,2;_x:1,2c;"
"_n:1,2;_n_noop:1,2;"
"__ngettext:1,2;"
"__ngettext_noop:1,2;_c,"
"_nc:4c,1,2\n"
"X-Poedit-Basepath: ..\n"
"X-Generator: Poedit 3.2\n"
"X-Poedit-"
"SearchPath-0: .\n"

#: display-posts-pagination.php:42
msgid "Previous"
msgstr ""

#: display-posts-pagination.php:43
msgid "Next"
msgstr ""