/wp-content/plugins/osm/osm-sc-info.php

https://github.com/livinglab/openlab · PHP · 71 lines · 50 code · 5 blank · 16 comment · 10 complexity · c0a065c8672f6d98994b8d857c7e3a88 MD5 · raw file

  1. <?php
  2. /* (c) Copyright 2014 Michael Kang (wp-osm-plugin.HanBlog.Net)
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. echo '<p><img src="'.OSM_PLUGIN_URL.'/WP_OSM_Plugin_Logo.png" alt="Osm Logo"></p>';
  16. echo '<h2>OpenStreetMap Plugin '.PLUGIN_VER.' </h2>';
  17. global $post;
  18. $post_org = $post;
  19. $Counter = 0;
  20. $CustomFieldName = get_option('osm_custom_field','OSM_geo_data');
  21. $recentPosts = new WP_Query();
  22. $starttime = microtime(true);
  23. $recentPosts->query('meta_key='.$CustomFieldName.'&post_status=publish &showposts=-1 &post_type=post');
  24. while ($recentPosts->have_posts()) : $recentPosts->the_post();
  25. list($temp_lat, $temp_lon) = explode(',', get_post_meta($post->ID, $CustomFieldName, true));
  26. if ($temp_lat != '' && $temp_lon != '') {
  27. list($temp_lat, $temp_lon) = $this->checkLatLongRange('$marker_all_posts',$temp_lat, $temp_lon);
  28. $Counter += 1;
  29. }
  30. endwhile;
  31. $diff = microtime(true) - $starttime;
  32. $sec = intval($diff);
  33. $micro = $diff - $sec;
  34. $final = strftime('%T', mktime(0, 0, $sec)) . str_replace('0.', '.', sprintf('%.3f', $micro));
  35. $Counter = sprintf("%03d",$Counter);
  36. $count_posts = wp_count_posts('post');
  37. $published_posts = $count_posts->publish;
  38. echo "published posts: ".$published_posts."<br>";
  39. echo " geo tagged:".$Counter."; DB request took: ".$final."<br>";
  40. $post = $post_org;
  41. $post_org = $post;
  42. $Counter = 0;
  43. $starttime = microtime(true);
  44. $recentPosts = new WP_Query();
  45. $recentPosts->query('meta_key='.$CustomFieldName.'&post_status=publish'.'&showposts=-1'.'&post_type=page');
  46. while ($recentPosts->have_posts()) : $recentPosts->the_post();
  47. list($temp_lat, $temp_lon) = explode(',', get_post_meta($post->ID, $CustomFieldName, true));
  48. if ($temp_lat != '' && $temp_lon != '') {
  49. list($temp_lat, $temp_lon) = $this->checkLatLongRange('$marker_all_posts',$temp_lat, $temp_lon);
  50. $Counter += 1;
  51. }
  52. endwhile;
  53. $diff = microtime(true) - $starttime;
  54. $sec = intval($diff);
  55. $micro = $diff - $sec;
  56. $final = strftime('%T', mktime(0, 0, $sec)) . str_replace('0.', '.', sprintf('%.3f', $micro));
  57. $Counter = sprintf("%03d",$Counter);
  58. $count_pages = wp_count_posts('page');
  59. $published_pages = $count_pages->publish;
  60. echo "published pages: ".$published_pages."<br>";
  61. echo " geo tagged:".$Counter."; DB request took: ".$final."<br>";
  62. $post = $post_org;
  63. ?>