rchive_link; } } $post = get_post( get_option( 'page_for_posts' ) ); if ( get_option( 'show_on_front' ) && $post ) { $urls[] = get_permalink( $post->ID ); } $urls = array_unique( $urls ); $urls_list = array(); // Duplicate every URL multiple times. This will be enough to generate all the files for most of the sites. $duplicate_count = apply_filters( 'wphb_minify_scan_url_duplicate_count', 3 ); for ( $i = 0; $i < $duplicate_count; $i++ ) { $urls_list = array_merge( $urls_list, $urls ); } sort( $urls_list ); return $urls_list; } /** * This function send a request to a URL in the site * that will trigger the files collection * * @param string $url URL. * * @return array */ public function scan_url( $url ) { $cookies = array(); foreach ( $_COOKIE as $name => $value ) { if ( strpos( $name, 'wordpress_' ) > -1 ) { $cookies[] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value, ) ); } } $result = array(); $args = array( 'timeout' => 0.01, 'cookies' => $cookies, 'blocking' => false, 'sslverify' => false, ); // Add support for basic auth in WPMU DEV staging. if ( isset( $_SERVER['WPMUDEV_HOSTING_ENV'] ) && 'staging' === $_SERVER['WPMUDEV_HOSTING_ENV'] && isset( $_SERVER['PHP_AUTH_USER'] ) ) { $args['headers'] = array( 'Authorization' => 'Basic ' . base64_encode( $_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW'] ), ); } $url = apply_filters( 'wphb_minify_scan_url', $url ); $result['cookie'] = wp_remote_get( $url, $args ); // One call logged out. $args = array( 'timeout' => 0.01, 'blocking ' => false, 'sslverify' => false, ); $result['no-cookie'] = wp_remote_get( $url, $args ); return $result; } }