401 ) ); } $query->set( 'orderby', 'modified' ); add_action( 'atom_entry', function() { global $post; echo ''. str_word_count( strip_tags( $post->post_content ) ). ''; } ); } }); } /** * Is the current query for an atom feed of 1Pass content? * * @return bool */ function onepass_is_onepass_feed() { return get_query_var( '1pass' ) == '1pass' && get_query_var( 'feed' ) == 'atom'; } /** * 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"; } }