presstrends_NextGEN_Galleryview_plugin

The NextGEN Galleryview presstrends NextGEN Galleryview plugin function.

Description

presstrends_NextGEN_Galleryview_plugin(); 

Usage

  1. if ( !function_exists( 'presstrends_NextGEN_Galleryview_plugin' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-galleryview/nggGalleryview.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = presstrends_NextGEN_Galleryview_plugin(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/nggGalleryview.php  
  1. function presstrends_NextGEN_Galleryview_plugin() { 
  2.  
  3. // PressTrends Account API Key 
  4. $api_key = 'l325qf6uap6dnjrrutams299ajr5zsts8wgr'; 
  5. $auth = 'x4c8n8lypba98pee90wdct12lnnyja238'; 
  6.  
  7. // Start of Metrics 
  8. global $wpdb; 
  9. $data = get_transient( 'presstrends_cache_data' ); 
  10. if ( !$data || $data == '' ) { 
  11. $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/'; 
  12. $url = $api_base . $auth . '/api/' . $api_key . '/'; 
  13.  
  14. $count_posts = wp_count_posts(); 
  15. $count_pages = wp_count_posts( 'page' ); 
  16. $comments_count = wp_count_comments(); 
  17.  
  18. // wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now. 
  19. if ( function_exists( 'wp_get_theme' ) ) { 
  20. $theme_data = wp_get_theme(); 
  21. $theme_name = urlencode( $theme_data->Name ); 
  22. } else { 
  23. $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' ); 
  24. $theme_name = $theme_data['Name']; 
  25.  
  26. $plugin_name = '&'; 
  27. foreach ( get_plugins() as $plugin_info ) { 
  28. $plugin_name .= $plugin_info['Name'] . '&'; 
  29. // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE 
  30. $plugin_data = get_plugin_data( __FILE__ ); 
  31. $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" ); 
  32. $data = array( 
  33. 'url' => stripslashes( str_replace( array( 'http://', '/', ':' ), '', site_url() ) ),  
  34. 'posts' => $count_posts->publish,  
  35. 'pages' => $count_pages->publish,  
  36. 'comments' => $comments_count->total_comments,  
  37. 'approved' => $comments_count->approved,  
  38. 'spam' => $comments_count->spam,  
  39. 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),  
  40. 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,  
  41. 'theme_version' => $plugin_data['Version'],  
  42. 'theme_name' => $theme_name,  
  43. 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),  
  44. 'plugins' => count( get_option( 'active_plugins' ) ),  
  45. 'plugin' => urlencode( $plugin_name ),  
  46. 'wpversion' => get_bloginfo( 'version' ),  
  47. ); 
  48.  
  49. foreach ( $data as $k => $v ) { 
  50. $url .= $k . '/' . $v . '/'; 
  51. wp_remote_get( $url ); 
  52. set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );