/** * get_urls * * Public method pull to gather all public URLs * * @since 7.3 * @access public * @author Kevin Pirnie * @package Kevin's Framework * * @return array Returns an array of URLs * */ public function get_urls( ) : array { // see if we've already got this in cache $_urls = wp_cache_get( "kfw_urls", "kfw_urls" ); // if we have it in our cache already if( $_urls ) { // return it return $_urls; // we don't } else { // hold our return array $_ret = array( ); // all we're interested in is publicly accessible posts/pages $_post_types = get_post_types( array( 'public' => true, ), 'names' ); // setup some arguments $_args = array( 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'fields' => 'ids', 'post_type' => $_post_types, 'posts_per_page' => -1, 'post_status' => 'publish', ); // our query for all public posts $_qry = new WP_Query( $_args ); // fire up the recordset $_rs = $_qry -> get_posts( ); // make sure we have a recordset if( $_rs ) { // loop and and populate the URL array with the posts permalinks foreach( $_rs as $_id ) { // add it to the return array $_ret[] = get_permalink( $_id ); } } // cache it for 1 hour wp_cache_add( "kfw_urls", $_ret, "kfw_urls", HOUR_IN_SECONDS ); // return the array return $_ret; } }