-1, 'orderby' => 'modified', 'post_type' => array('post', 'page', 'product', 'attachment'), 'post_status' => 'publish', 'order' => 'DESC')); $aio_sitemap .= ''; $aio_sitemap .= "\n" . '' . "\n"; $aio_sitemap .= "\t" . '' . "\n" . "\t\t" . '' . esc_url(home_url('/')) . '' . "\n\t\t" . '' . date("Y-m-d\TH:i:s", current_time('timestamp', 0)) . $get_offset . '' . "\n\t\t" . 'hourly' . "\n\t\t" . '1.0' . "\n\t" . '' . "\n"; foreach ($postsForAllinoneSitemap as $aiopost) { setup_postdata($aiopost); $postdate = explode(" ", $aiopost -> post_modified); $aio_sitemap .= "\t" . '' . "\n" . "\t\t" . '' . get_permalink($aiopost -> ID) . '' . "\n\t\t" . '' . $postdate[0] . 'T' . $postdate[1] . $get_offset . '' . "\n\t\t" . 'Weekly' . "\n\t\t" . '0.5' . "\n\t" . '' . "\n"; } $aio_sitemap .= ''; $filepath = fopen(ABSPATH . "allinonesitemap.xml", 'w'); fwrite($filepath, $aio_sitemap); fclose($filepath); $url .= "VIEW SITEMAP URL IN XML FORMAT" . 'Click Here
'; echo $url; } function create_txt_aiositemap() { global $siteurl , $siteurl; $filepath = get_site_url(); $sitemaplines = $filepath.'/allinonesitemap.xml'; $allsitemapMatches = array(); foreach ($allsitemapMatches as $line_number => $url_line ) { $url_line = trim($url_line); preg_match_all('/(?<=\)(.*?)(?=\<\/loc\>)/U', $url_line, $matches,PREG_SET_ORDER); if($matches){ if ( $matches[0][0] != '' ) { $allsitemapMatches[] = $matches[0][0]; }; }; }; $list = ''; foreach ( $allsitemapMatches as $sitemaplines ) { $list .= $sitemaplines."\n"; }; $fh = fopen('allurllist.txt', "w+"); fwrite($fh, $list); fclose($fh); $siteurl .= "View URL IN .txt FORMAT" . 'Click Here
' ; echo $siteurl; } // function to read robots.txt function aiositemap_read_robots_file() { $aiositemap_path = get_home_path(); $aiorobots_file = $aiositemap_path .'/robots.txt'; $robotsfilecontent = array(); if($robotsfile = fopen($aiorobots_file, "r")){ while (($robotsgetcontent = fgets($robotsfile)) !== false) { array_push( $robotsfilecontent, $robotsgetcontent ); } fclose($robotsfile); } foreach($robotsfilecontent as $robots_file_line) echo $robots_file_line; echo ''; } //function to write content in robots.txt function aiositemap_write_robots_file($content_to_write = '') { $aiositemap_path = get_home_path(); $aiorobots_file = $aiositemap_path .'/robots.txt'; if (is_writable($aiorobots_file)) { if (!$openfile = fopen($aiorobots_file, 'w')) echo "robots.txt can not open"; if (fwrite($openfile, $content_to_write) === FALSE) echo "Something goes wrong."; echo "Your robots file has been updated succesfully
"; fclose($openfile); } else { echo "The file robots.txt is not writable"; } } //function to ping google automatically function ping_to_google() { $aiositemapUrl = get_site_url() .'/allinonesitemap.xml'; $aiositemap_ping_url = ''; $aiositemap_ping_url = "http://www.google.com/webmasters/tools/ping?sitemap=" .$aiositemapUrl; $aiositemap_response = wp_remote_get( $aiositemap_ping_url ); if($aiositemap_response['response']['code']=200) echo "Pinged google succesfully"; else echo "Failed to Pinged google"; } ?>