401 ) ); } $query->set( 'orderby', 'modified' ); } }); } function onepass_get_onepass_feed_url() { return site_url( 'feed/atom/1pass/' ); } function onepass_render_feed() { if( !headers_sent() ) { // don't send headers in tests header( 'Cache-Control: private, no-cache' ); header( 'Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true ); } $more = 1; echo ''; include( ONEPASS_PLUGIN_DIR . 'views/feed.php' ); } /** * Is the current query for an atom feed of 1Pass content? * * @return bool */ function onepass_is_onepass_feed() { return get_query_var( 'feed' ) == 'onepass'; } /** * Add pagination links to the atom feed in accordance with the Atom spec * * @return void */ function onepass_add_atom_pagination() { global $wp_query; $total_pages = $wp_query->max_num_pages; if( $total_pages === 1 ) { return; } $page_number = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; // get the self_link of the feed (WP will only print, not return this value, hence output buffer) ob_start(); self_link(); $self_link = ob_get_clean(); /** * x_query_arg should be escaped: * https://make.wordpress.org/plugins/2015/04/20/fixing-add_query_arg-and-remove_query_arg-usage/ * * self_link already calls it, though, so there's no need here. */ $feed_path = remove_query_arg( 'paged', $self_link ); echo "\n\t"; // link rel=first printf( '', add_query_arg( 'paged', 1, $feed_path ) ); echo "\n\t"; // link rel=last printf( '', add_query_arg( 'paged', $total_pages, $feed_path ) ); echo "\n\t"; // link rel=previous if( $page_number > 1 ) { printf( '', add_query_arg( 'paged', $page_number - 1, $feed_path ) ); echo "\n\t"; } // link rel=next if( $page_number < $total_pages ) { printf( '', add_query_arg( 'paged', $page_number + 1, $feed_path ) ); echo "\n\t"; } }