Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index on 404 page #7

Open
freakimkaefig opened this issue Feb 26, 2019 · 0 comments
Open

Undefined index on 404 page #7

freakimkaefig opened this issue Feb 26, 2019 · 0 comments

Comments

@freakimkaefig
Copy link

freakimkaefig commented Feb 26, 2019

The plugin produces errors on the 404 page:
Notice: Undefined index: in /some/path/pico/plugins/PicoPlacing/PicoPlacing.php on line 134
Notice: Undefined index: in /some/path/pico/plugins/PicoPlacing/PicoPlacing.php on line 135

Can be hotfixed by checking for $currentPage in onPagesLoaded:

if ( isset( $currentPage ) ) {
    $curr = $currentPage['placing'];
    
    $keys = array_keys($sorted_pages);
    $keyIndexes = array_flip( $keys );
    
    $prev = ( isset( $keys[ $keyIndexes[ $curr ] - 1 ] ) ) ? $prev = $keys[ $keyIndexes[ $curr ] - 1 ] : FALSE;
    $next = ( isset( $keys[ $keyIndexes[ $curr ] + 1 ] ) ) ? $next = $keys[ $keyIndexes[ $curr ] + 1 ] : FALSE;
    
    $nextPage = ( $next ) ? $sorted_pages[$next] : null;
    $previousPage = ( $prev ) ? $sorted_pages[$prev] : null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant