NGG_Overview

Class to display the overview.

Defined (1)

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

/admin/class-ngg-overview.php  
  1. class NGG_Overview implements NGG_Displayable { 
  2.  
  3. public function __construct() { 
  4.  
  5. add_meta_box( 'overview', __( 'At a Glance', 'nggallery' ), array( 
  6. $this,  
  7. 'stats' 
  8. ), 'ngg_overview', 'normal', 'core' ); 
  9. add_meta_box( 'ngg_meta_box', __( 'Help me help YOU!', 'nggallery' ), array( 
  10. $this,  
  11. 'like_this' 
  12. ), 'ngg_overview', 'side', 'core' ); 
  13. add_meta_box( 'dashboard_primary', __( 'Latest News', 'nggallery' ), array( 
  14. $this,  
  15. 'js_loading' 
  16. ), 'ngg_overview', 'normal', 'core' ); 
  17. if ( ! is_multisite() || is_super_admin() ) { 
  18. add_meta_box( 'ngg_plugin_check', __( 'Plugin Check', 'nggallery' ), array( 
  19. $this,  
  20. 'ngg_plugin_check' 
  21. ), 'ngg_overview', 'side', 'core' ); 
  22. add_meta_box( 'ngg_server', __( 'Server Settings', 'nggallery' ), array( 
  23. $this,  
  24. 'ngg_overview_server' 
  25. ), 'ngg_overview', 'side', 'core' ); 
  26. add_meta_box( 'dashboard_plugins', __( 'Related plugins', 'nggallery' ), array( 
  27. $this,  
  28. 'js_loading' 
  29. ), 'ngg_overview', 'normal', 'core' ); 
  30. add_meta_box( 'dashboard_contributors', __( 'Contributors', 'nggallery' ), array( $this, 'contributors' ), 'ngg_overview', 'normal', 'core' ); 
  31.  
  32. /** 
  33. * Show a summary of the usage. 
  34. */ 
  35. public function stats() { 
  36. global $wpdb; 
  37. //TODO: Move to database. 
  38. $images = intval( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->nggpictures" ) ); 
  39. $galleries = intval( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->nggallery" ) ); 
  40. $albums = intval( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->nggalbum" ) ); 
  41. ?> 
  42. <div id="overview_right_now" class="main"> 
  43. <p><?php _e( 'Here you can control your images, galleries and albums.', 'nggallery' ) ?></p> 
  44. <ul> 
  45. <li class="image-count"><a href="admin.php?page=nggallery-add-gallery"> 
  46. <?php echo $images . ' ' . _n( 'Image', 'Images', $images, 'nggallery' ); ?></a> 
  47. </li> 
  48. <li class="gallery-count"><a href="admin.php?page=nggallery-manage"> 
  49. <?php echo $galleries . ' ' . _n( 'Gallery', 'Galleries', $galleries, 'nggallery' ); ?></a> 
  50. </li> 
  51. <li class="album-count"><a href="admin.php?page=nggallery-manage-album"> 
  52. <?php echo $albums . ' ' . _n( 'Album', 'Albums', $albums, 'nggallery' ); ?></a> 
  53. </li> 
  54. </ul> 
  55. </div> 
  56. <?php if ( current_user_can( 'NextGEN Upload images' ) ) { 
  57. echo '<a class="button button-primary" href="admin.php?page=nggallery-add-gallery">' . __( 'Add new pictures', 'nggallery' ) . '</a>'; 
  58. if ( is_multisite() ) { 
  59. $this->ngg_dashboard_quota(); 
  60.  
  61. /** 
  62. * Output the quote used. 
  63. */ 
  64. private function ngg_dashboard_quota() { 
  65.  
  66. if ( get_site_option( 'upload_space_check_disabled' || ! wpmu_enable_function( 'wpmuQuotaCheck' ) ) ) { 
  67. return; 
  68.  
  69. $quota = get_space_allowed(); 
  70. $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; 
  71.  
  72. if ( $used > $quota ) { 
  73. $percent_used = '100'; 
  74. } else { 
  75. $percent_used = ( $used / $quota ) * 100; 
  76. if ( $percent_used < 70 ) { 
  77. if ( $percent_used >= 40 ) { 
  78. $used_color = ( 'waiting' ); 
  79. } else { 
  80. $used_color = ( 'approved' ); 
  81. } else { 
  82. $used_color = 'spam'; 
  83. $used = round( $used, 2 ); 
  84. $percent_used = number_format( $percent_used ); 
  85.  
  86. ?> 
  87. <h4><?php _e( 'Storage Space' ); ?></h4> 
  88. <table> 
  89. <tr> 
  90. <td><?php _e( 'Allowed' ); ?></td> 
  91. <td><?php printf( __( '<a href="%1$s" title="Manage Uploads">%2$s MB</a>' ), esc_url( admin_url( 'admin.php?page=nggallery-manage' ) ), $quota ); ?></td> 
  92. </tr> 
  93. <tr> 
  94. <td class="<?php echo $used_color; ?>"><?php _e( 'Used' ); ?></td> 
  95. <td><?php printf( __( '<a href="%1$s" title="Manage Uploads">%2$s MB (%3$s%%)</a>' ), esc_url( admin_url( 'admin.php?page=nggallery-manage' ) ), $used, $percent_used ); ?></td> 
  96. </tr> 
  97. </table> 
  98. <?php 
  99.  
  100. /** 
  101. * Output the actual RSS news. 
  102. */ 
  103. static public function ngg_overview_news() { 
  104.  
  105. $rss = fetch_feed( 'http://wpgetready.com/feed/' ); 
  106.  
  107. if ( is_wp_error( $rss ) ) { 
  108. echo '<p>' . sprintf( __( 'The newsfeed could not be loaded. Check the <a href="%s">front page</a> to check for updates.', 'nggallery' ), 'http://www.wpgetready.com/' ) . '</p>'; 
  109. } else { 
  110. echo '<div class="rss-widget">'; 
  111. foreach ( $rss->get_items( 0, 3 ) as $item ) { 
  112. $link = $item->get_link(); 
  113. while ( stristr( $link, 'http' ) != $link ) { 
  114. $link = substr( $link, 1 ); 
  115. $link = esc_url( strip_tags( $link ) ); 
  116. $title = esc_attr( strip_tags( $item->get_title() ) ); 
  117. if ( empty( $title ) ) { 
  118. $title = __( 'Untitled' ); 
  119.  
  120. $desc = str_replace( array( 
  121. "\n",  
  122. "\r" 
  123. ), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ) ); 
  124. $desc = wp_html_excerpt( $desc, 360 ); 
  125.  
  126. // Append ellipsis. Change existing [...] to […]. 
  127. if ( '[...]' == substr( $desc, - 5 ) ) { 
  128. $desc = substr( $desc, 0, - 5 ) . '[…]'; 
  129. } elseif ( '[…]' != substr( $desc, - 10 ) ) { 
  130. $desc .= ' […]'; 
  131.  
  132. $desc = esc_html( $desc ); 
  133.  
  134. $date = $item->get_date(); 
  135. $diff = ''; 
  136.  
  137. if ( $date ) { 
  138.  
  139. $diff = human_time_diff( strtotime( $date, time() ) ); 
  140.  
  141. if ( $date_stamp = strtotime( $date ) ) { 
  142. $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>'; 
  143. } else { 
  144. $date = ''; 
  145. echo '<ul><li>'; 
  146. echo '<a class="rsswidget" target="_blank" href="' . $link . '" >' . $title . '</a>'; 
  147. echo '<span class="rss-date">' . $date . '</span>'; 
  148. echo '<div class="rssSummary"><strong>' . $diff . '</strong> - ' . $desc . '</div></li></ul>'; 
  149. echo '</div>'; 
  150.  
  151. /** 
  152. * Check for compatability. 
  153. */ 
  154. public function ngg_plugin_check() { 
  155.  
  156. global $ngg; 
  157. ?> 
  158. <script type="text/javascript"> 
  159. (function ($) { 
  160. nggPluginCheck = { 
  161.  
  162. settings: { 
  163. img_run: '<img src="<?php echo esc_url( admin_url( 'images/spinner.gif' ) ); ?>" class="icon" alt="started"/>',  
  164. img_ok: '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" class="icon" alt="ok"/>',  
  165. img_fail: '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" class="icon" alt="failed" />',  
  166. domain: '<?php echo esc_url( home_url('index.php', is_ssl() ? 'https' : 'http') ); ?>' 
  167. },  
  168.  
  169. run: function (index, state) { 
  170. ul = $('#plugin_check'); 
  171. s = this.settings; 
  172. var step = 1; 
  173. switch (index) { 
  174. case 1: 
  175. this.check1(); 
  176. break; 
  177. case 2: 
  178. this.check2(step); 
  179. break; 
  180. case 3: 
  181. this.check3(); 
  182. break; 
  183. },  
  184.  
  185. // this function check if the json API will work with your theme & plugins 
  186. check1: function () { 
  187. this.start(1); 
  188. var req = $.ajax({ 
  189. dataType: 'json',  
  190. url: s.domain,  
  191. data: 'callback=json&format=json&method=version',  
  192. cache: false,  
  193. timeout: 10000,  
  194. success: function (msg) { 
  195. if (msg.version == '<?php echo $ngg->version; ?>') 
  196. nggPluginCheck.success(1); 
  197. else 
  198. nggPluginCheck.failed(1); 
  199. },  
  200. error: function (msg) { 
  201. nggPluginCheck.failed(1); 
  202. },  
  203. complete: function () { 
  204. nggPluginCheck.run(2); 
  205. }); 
  206.  
  207. },  
  208.  
  209. // this function check if GD lib can create images & thumbnails 
  210. check2: function (step) { 
  211. if (step == 1) this.start(2); 
  212. var stop = false; 
  213. var req = $.ajax({ 
  214. type: "POST",  
  215. url: ajaxurl,  
  216. data: "action=ngg_image_check&step=" + step,  
  217. cache: false,  
  218. timeout: 10000,  
  219. success: function (msg) { 
  220. if (msg.stat == 'ok') { 
  221. nggPluginCheck.success(2, msg.message); 
  222. } else { 
  223. if (step == 1) 
  224. nggPluginCheck.failed(2); 
  225. stop = true; 
  226.  
  227. },  
  228. error: function (msg) { 
  229. if (step == 1) 
  230. nggPluginCheck.failed(2); 
  231. stop = true; 
  232. },  
  233. complete: function () { 
  234. step++; 
  235. if (step <= 11 && stop == false) 
  236. nggPluginCheck.check2(step); 
  237. else 
  238. nggPluginCheck.run(3); 
  239. }); 
  240. },  
  241.  
  242. // this function check if wp_head / wp_footer is avaiable 
  243. check3: function () { 
  244. this.start(3); 
  245. var req = $.ajax({ 
  246. type: "POST",  
  247. url: ajaxurl,  
  248. data: "action=ngg_test_head_footer",  
  249. cache: false,  
  250. timeout: 10000,  
  251. success: function (msg) { 
  252. if (msg == 'success') 
  253. nggPluginCheck.success(3); 
  254. else 
  255. nggPluginCheck.failed(3, msg); 
  256. },  
  257. error: function (msg) { 
  258. nggPluginCheck.failed(3); 
  259. }); 
  260. },  
  261.  
  262. start: function (id) { 
  263.  
  264. s = this.settings; 
  265. var field = "#check" + id; 
  266.  
  267. if (ul.find(field + " img").length == 0) 
  268. $(field).prepend(s.img_run); 
  269. else 
  270. $(field + " img").replaceWith(s.img_run); 
  271.  
  272. $(field + " .success").hide(); 
  273. $(field + " .failed").hide(); 
  274. $(field + " .default").replaceWith('<p class="default message"><?php echo esc_js( __('Running...', 'nggallery') ); ?></p> '); 
  275. },  
  276.  
  277. success: function (id, msg) { 
  278.  
  279. s = this.settings; 
  280. var field = "#check" + id; 
  281.  
  282. if (ul.find(field + " img").length == 0) 
  283. $(field).prepend(s.img_ok); 
  284. else 
  285. $(field + " img").replaceWith(s.img_ok); 
  286.  
  287. $(field + " .default").hide(); 
  288. if (msg) 
  289. $(field + " .success").replaceWith('<p class="success message">' + msg + ' </p> '); 
  290. else 
  291. $(field + " .success").show(); 
  292.  
  293. },  
  294.  
  295. failed: function (id, msg) { 
  296.  
  297. s = this.settings; 
  298. var field = "#check" + id; 
  299.  
  300. if (ul.find(field + " img").length == 0) 
  301. $(field).prepend(s.img_fail); 
  302. else 
  303. $(field + " img").replaceWith(s.img_fail); 
  304.  
  305. $(field + " .default").hide(); 
  306. if (msg) 
  307. $(field + " .failed").replaceWith('<p class="failed message">' + msg + ' </p> '); 
  308. else 
  309. $(field + " .failed").show(); 
  310.  
  311.  
  312. }; 
  313. })(jQuery); 
  314. </script> 
  315. <ul id="plugin_check" class="settings"> 
  316. <li id="check1"> 
  317. <strong><?php _e( 'Check plugin/theme conflict', 'nggallery' ); ?></strong> 
  318. <p class="default message"><?php _e( 'Not tested', 'nggallery' ); ?></p> 
  319. <p class="success message" style="display: none;"><?php _e( 'No conflict could be detected', 'nggallery' ); ?></p> 
  320. <p class="failed message" style="display: none;"><?php _e( 'Test failed, disable other plugins & switch to default theme', 'nggallery' ); ?></p> 
  321. </li> 
  322. <li id="check2"> 
  323. <strong><?php _e( 'Test image function', 'nggallery' ); ?></strong> 
  324. <p class="default message"><?php _e( 'Not tested', 'nggallery' ); ?></p> 
  325. <p class="success message" style="display: none;"><?php _e( 'The plugin could create images.', 'nggallery' ); ?></p> 
  326. <p class="failed message" style="display: none;"><?php _e( 'Could not create image, check your memory limit.', 'nggallery' ); ?></p> 
  327. </li> 
  328. <li id="check3"> 
  329. <strong><?php _e( 'Check theme compatibility', 'nggallery' ); ?></strong> 
  330. <p class="default message"><?php _e( 'Not tested', 'nggallery' ); ?></p> 
  331. <p class="success message" style="display: none;"><?php _e( 'Your theme should work fine with NextCellent Gallery', 'nggallery' ); ?></p> 
  332. <p class="failed message" style="display: none;"><?php _e( 'wp_head()/wp_footer() is missing, contact the theme author', 'nggallery' ); ?></p> 
  333. </li> 
  334. </ul> 
  335. <p class="textright"> 
  336. <input type="button" name="update" value="<?php _e( 'Check plugin', 'nggallery' ); ?>" onclick="nggPluginCheck.run(1);" class="button-secondary"/> 
  337. </p> 
  338. <?php 
  339.  
  340. /** 
  341. * Show the server settings. 
  342. */ 
  343. public function ngg_overview_server() { 
  344. ?> 
  345. <div id="dashboard_server_settings" class="dashboard-widget-holder wp_dashboard_empty"> 
  346. <div class="ngg-dashboard-widget"> 
  347. <div class="dashboard-widget-content"> 
  348. <ul class="settings"> 
  349. <?php $this->ngg_get_serverinfo(); ?> 
  350. </ul> 
  351. <p><strong><?php _e( 'Graphic Library', 'nggallery' ); ?></strong></p> 
  352. <ul class="settings"> 
  353. <?php $this->ngg_gd_info(); ?> 
  354. </ul> 
  355. </div> 
  356. </div> 
  357. </div> 
  358. <?php 
  359.  
  360. /** 
  361. * Show GD Library version information. 
  362. */ 
  363. private function ngg_gd_info() { 
  364.  
  365. if ( function_exists( "gd_info" ) ) { 
  366. $info = gd_info(); 
  367. $keys = array_keys( $info ); 
  368. for ( $i = 0; $i < count( $keys ); $i ++ ) { 
  369. if ( is_bool( $info[ $keys[ $i ] ] ) ) { 
  370. echo "<li> " . $keys[ $i ] . ": <span>" . $this->ngg_gd_yesNo( $info[ $keys[ $i ] ] ) . "</span></li>\n"; 
  371. } else { 
  372. echo "<li> " . $keys[ $i ] . ": <span>" . $info[ $keys[ $i ] ] . "</span></li>\n"; 
  373. } else { 
  374. _e( 'There is no GD support', 'nggallery' ); 
  375.  
  376. /** 
  377. * Return localized Yes or No. 
  378. * @param bool $bool 
  379. * @return string 'Yes'|'No' 
  380. */ 
  381. private function ngg_gd_yesNo( $bool ) { 
  382. if ( $bool ) { 
  383. return __( 'Yes', 'nggallery' ); 
  384. } else { 
  385. return __( 'No', 'nggallery' ); 
  386.  
  387. /** 
  388. * Show some server information. 
  389. * @see GamerZ (http://www.lesterchan.net) 
  390. */ 
  391. private function ngg_get_serverinfo() { 
  392.  
  393. global $wpdb, $ngg; 
  394. // Get MYSQL Version 
  395. $sqlversion = $wpdb->get_var( "SELECT VERSION() AS version" ); 
  396. // GET SQL Mode 
  397. $mysqlinfo = $wpdb->get_results( "SHOW VARIABLES LIKE 'sql_mode'" ); 
  398. if ( is_array( $mysqlinfo ) ) { 
  399. $sql_mode = $mysqlinfo[0]->Value; 
  400. if ( empty( $sql_mode ) ) { 
  401. $sql_mode = __( 'Not set', 'nggallery' ); 
  402. // Get PHP allow_url_fopen 
  403. if ( ini_get( 'allow_url_fopen' ) ) { 
  404. $allow_url_fopen = __( 'On', 'nggallery' ); 
  405. } else { 
  406. $allow_url_fopen = __( 'Off', 'nggallery' ); 
  407. // Get PHP Max Upload Size 
  408. if ( ini_get( 'upload_max_filesize' ) ) { 
  409. $upload_max = ini_get( 'upload_max_filesize' ); 
  410. } else { 
  411. $upload_max = __( 'N/A', 'nggallery' ); 
  412. // Get PHP Output buffer Size 
  413. if ( ini_get( 'pcre.backtrack_limit' ) ) { 
  414. $backtrack_limit = ini_get( 'pcre.backtrack_limit' ); 
  415. } else { 
  416. $backtrack_limit = __( 'N/A', 'nggallery' ); 
  417. // Get PHP Max Post Size 
  418. if ( ini_get( 'post_max_size' ) ) { 
  419. $post_max = ini_get( 'post_max_size' ); 
  420. } else { 
  421. $post_max = __( 'N/A', 'nggallery' ); 
  422. // Get PHP Max execution time 
  423. if ( ini_get( 'max_execution_time' ) ) { 
  424. $max_execute = ini_get( 'max_execution_time' ); 
  425. } else { 
  426. $max_execute = __( 'N/A', 'nggallery' ); 
  427. // Get PHP Memory Limit 
  428. if ( ini_get( 'memory_limit' ) ) { 
  429. $memory_limit = $ngg->memory_limit; 
  430. } else { 
  431. $memory_limit = __( 'N/A', 'nggallery' ); 
  432. // Get actual memory_get_usage 
  433. if ( function_exists( 'memory_get_usage' ) ) { 
  434. $memory_usage = round( memory_get_usage() / 1024 / 1024, 2 ) . __( ' MB', 'nggallery' ); 
  435. } else { 
  436. $memory_usage = __( 'N/A', 'nggallery' ); 
  437. // required for EXIF read 
  438. if ( is_callable( 'exif_read_data' ) ) { 
  439. $exif = __( 'Yes', 'nggallery' ) . " ( v" . substr( phpversion( 'exif' ), 0, 4 ) . ")"; 
  440. } else { 
  441. $exif = __( 'No', 'nggallery' ); 
  442. // required for meta data 
  443. if ( is_callable( 'iptcparse' ) ) { 
  444. $iptc = __( 'Yes', 'nggallery' ); 
  445. } else { 
  446. $iptc = __( 'No', 'nggallery' ); 
  447. // required for meta data 
  448. if ( is_callable( 'xml_parser_create' ) ) { 
  449. $xml = __( 'Yes', 'nggallery' ); 
  450. } else { 
  451. $xml = __( 'No', 'nggallery' ); 
  452.  
  453. ?> 
  454. <li><?php _e( 'Operating System', 'nggallery' ); ?>: <span><?php echo PHP_OS; ?> 
  455. (<?php echo( PHP_INT_SIZE * 8 ) ?> Bit)</span></li> 
  456. <li><?php _e( 'Server', 'nggallery' ); ?>: <span><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></span></li> 
  457. <li><?php _e( 'Memory Usage', 'nggallery' ); ?>: <span><?php echo $memory_usage; ?></span></li> 
  458. <li><?php _e( 'MYSQL Version', 'nggallery' ); ?>: <span><?php echo $sqlversion; ?></span></li> 
  459. <li><?php _e( 'SQL Mode', 'nggallery' ); ?>: <span><?php echo $sql_mode; ?></span></li> 
  460. <li><?php _e( 'PHP Version', 'nggallery' ); ?>: <span><?php echo PHP_VERSION; ?></span></li> 
  461. <li><?php _e( 'PHP Allow URL fopen', 'nggallery' ); ?>: <span><?php echo $allow_url_fopen; ?></span></li> 
  462. <li><?php _e( 'PHP Memory Limit', 'nggallery' ); ?>: <span><?php echo $memory_limit; ?></span></li> 
  463. <li><?php _e( 'PHP Max Upload Size', 'nggallery' ); ?>: <span><?php echo $upload_max; ?></span></li> 
  464. <li><?php _e( 'PHP Max Post Size', 'nggallery' ); ?>: <span><?php echo $post_max; ?></span></li> 
  465. <li><?php _e( 'PCRE Backtracking Limit', 'nggallery' ); ?>: <span><?php echo $backtrack_limit; ?></span></li> 
  466. <li><?php _e( 'PHP Max Script Execute Time', 'nggallery' ); ?>: <span><?php echo $max_execute; ?>s</span></li> 
  467. <li><?php _e( 'PHP EXIF Support', 'nggallery' ); ?>: <span><?php echo $exif; ?></span></li> 
  468. <li><?php _e( 'PHP IPTC Support', 'nggallery' ); ?>: <span><?php echo $iptc; ?></span></li> 
  469. <li><?php _e( 'PHP XML Support', 'nggallery' ); ?>: <span><?php echo $xml; ?></span></li> 
  470. <?php 
  471.  
  472. /** 
  473. * Show the JS loading spinner. 
  474. */ 
  475. public function js_loading() { 
  476. echo '<p class="widget-loading hide-if-no-js"><img style="vertical-align:middle; margin: 5px 10px 5px 5px;" src="' . admin_url( "images/spinner.gif" ) . '"/><span>' . __( 'Loading…' ) . '</span></p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; 
  477.  
  478. /** 
  479. * Show related plugins. 
  480. * Based on class-wp-plugin-install-list-table.php 
  481. */ 
  482. static public function ngg_related_plugins() { 
  483. include( ABSPATH . 'wp-admin/includes/plugin-install.php' ); 
  484.  
  485. //Check for the transient. 
  486. $plugins = (array) get_transient( 'ngg_related_plugins' ); 
  487. if ( !$plugins || count($plugins) <= 1 ) { 
  488.  
  489. // Additional info http://dd32.id.au/projects/wordpressorg-plugin-information-api-docs/ 
  490. if ( is_wp_error( $api = plugins_api( 'query_plugins', array( 'search' => 'nextgen' ) ) ) ) { 
  491. return; 
  492. $plugins = (array) $api->plugins; 
  493. shuffle( $plugins ); 
  494. //var_dump("ok"); 
  495. set_transient( 'ngg_related_plugins', $plugins, 60 * 60 * 24 ); //enable to check within a day. 
  496.  
  497. echo '<div class="error form-invalid"><p>'; 
  498. _e( '<strong>Note</strong>: third parties plugins that are compatible with NGG may not be 100% compatible with NextCellent Gallery!', 'nggallery' ); 
  499. echo '</p></div><div id="the-list" class="widefat" style="overflow: auto">'; 
  500.  
  501. //List of suppressed plugin on the list. 
  502. $blacklist = array( 'nextgen-gallery', 'nextcellent-gallery-nextgen-legacy' ); 
  503.  
  504. $plugins_allowedtags = array( 
  505. 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),  
  506. 'abbr' => array( 'title' => array() ),  
  507. 'acronym' => array( 'title' => array() ),  
  508. 'code' => array(),  
  509. 'pre' => array(),  
  510. 'em' => array(),  
  511. 'strong' => array(),  
  512. 'ul' => array(),  
  513. 'ol' => array(),  
  514. 'li' => array(),  
  515. 'p' => array(),  
  516. 'br' => array() 
  517. ); 
  518.  
  519. $displayed = 0; 
  520. for( $i = 0; $displayed < 3; $i++ ) { 
  521.  
  522. $plugin = (array) $plugins[ $i ]; 
  523.  
  524. if ( in_array( $plugin['slug'], $blacklist ) ) { 
  525. continue; 
  526. } else { 
  527. $displayed++; 
  528.  
  529. $title = wp_kses( $plugin['name'], $plugins_allowedtags ); 
  530.  
  531. // Remove any HTML from the description. 
  532. $description = strip_tags( $plugin['short_description'] ); 
  533. $version = wp_kses( $plugin['version'], $plugins_allowedtags ); 
  534.  
  535. $name = strip_tags( $title . ' ' . $version ); 
  536.  
  537. $author = wp_kses( $plugin['author'], $plugins_allowedtags ); 
  538. if ( ! empty( $author ) ) { 
  539. $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; 
  540.  
  541. $action_links = array(); 
  542.  
  543. if ( !is_multisite() && (current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' )) ) { 
  544. $status = install_plugin_install_status( $plugin ); 
  545.  
  546. switch ( $status['status'] ) { 
  547. case 'install': 
  548. if ( $status['url'] ) { 
  549. /** translators: 1: Plugin name and version. */ 
  550. $action_links[] = '<a class="install-now button" href="' . $status['url'] . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>'; 
  551.  
  552. break; 
  553. case 'update_available': 
  554. if ( $status['url'] ) { 
  555. /** translators: 1: Plugin name and version */ 
  556. $action_links[] = '<a class="button" href="' . $status['url'] . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '">' . __( 'Update Now' ) . '</a>'; 
  557.  
  558. break; 
  559. case 'latest_installed': 
  560. case 'newer_installed': 
  561. $installed = true; 
  562. $action_links[] = '<span class="button button-disabled" title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>'; 
  563. break; 
  564.  
  565. if( is_multisite() ) { 
  566. $details_link = "https://wordpress.org/plugins/" . $plugin['slug'] . "/"; 
  567. } else { 
  568. $details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . '&TB_iframe=true&width=600&height=550' ); 
  569.  
  570. /** translators: 1: Plugin name and version. */ 
  571. if( is_multisite() ) { 
  572. $action_links[] = '<a href="' . esc_url( $details_link ) . '" target="_blank" aria-label="' . esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '" data-title="' . esc_attr( $name ) . '">' . __( 'More Details' ) . '</a>'; 
  573. } else { 
  574. $action_links[] = '<a href="' . esc_url( $details_link ) . '" class="thickbox" aria-label="' . esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '" data-title="' . esc_attr( $name ) . '">' . __( 'More Details' ) . '</a>'; 
  575.  
  576.  
  577. ?> 
  578. <div class="plugin-card"> 
  579. <div class="plugin-card-top"> 
  580. <div class="name column-name"> 
  581. <h4> 
  582. <?php if( is_multisite() ) { 
  583. echo("<a href='" . esc_url( $details_link ) . "' target='_blank'>" . $title . "</a>"); 
  584. } else { 
  585. echo("<a href='" . esc_url( $details_link ) . "' class='thickbox'>" . $title . "</a>"); 
  586. } ?> 
  587. </h4> 
  588. </div> 
  589. <div class="action-links"> 
  590. <?php 
  591. if ( $action_links ) { 
  592. echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>'; 
  593. } ?> 
  594. </div> 
  595. <div class="desc column-description"> 
  596. <p><?php echo $description; ?></p> 
  597. <p class="authors"><?php echo $author; ?></p> 
  598. </div> 
  599. </div> 
  600. <div class="plugin-card-bottom"> 
  601. <div class="vers column-rating"> 
  602. <?php wp_star_rating( array( 
  603. 'rating' => $plugin['rating'],  
  604. 'type' => 'percent',  
  605. 'number' => $plugin['num_ratings'] 
  606. ) ); ?> 
  607. <span class="num-ratings">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> 
  608. </div> 
  609. <div class="column-compatibility"> 
  610. <?php 
  611. if ( ! empty( $plugin['tested'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) { 
  612. echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>'; 
  613. } elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) { 
  614. echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; 
  615. } else { 
  616. echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>'; 
  617. } ?> 
  618. </div> 
  619. </div> 
  620. </div> 
  621. <?php 
  622. ?> 
  623. </div> 
  624. <script type="text/javascript"> 
  625. var tb_position; 
  626. jQuery( document ).ready( function( $ ) { 
  627. tb_position = function() { 
  628. var tbWindow = $( '#TB_window' ),  
  629. width = $( window ).width(),  
  630. H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ),  
  631. W = ( 792 < width ) ? 772 : width - 20; 
  632.  
  633. if ( tbWindow.size() ) { 
  634. tbWindow.width( W ).height( H ); 
  635. $( '#TB_iframeContent' ).width( W ).height( H ); 
  636. tbWindow.css({ 
  637. 'margin-left': '-' + parseInt( ( W / 2 ), 10 ) + 'px' 
  638. }); 
  639. if ( typeof document.body.style.maxWidth !== 'undefined' ) { 
  640. tbWindow.css({ 
  641. 'top': '30px',  
  642. 'margin-top': '0' 
  643. }); 
  644.  
  645. return $( 'a.thickbox' ).each( function() { 
  646. var href = $( this ).attr( 'href' ); 
  647. if ( ! href ) { 
  648. return; 
  649. href = href.replace( /&width=[0-9]+/g, '' ); 
  650. href = href.replace( /&height=[0-9]+/g, '' ); 
  651. $(this).attr( 'href', href + '&width=' + W + '&height=' + ( H ) ); 
  652. }); 
  653. }; 
  654.  
  655. jQuery( window ).resize( function() { 
  656. tb_position(); 
  657. }); 
  658.  
  659. jQuery( '.install-now' ).click( function() { 
  660. return confirm( '" . __( "Are you sure you want to install this?", "nggallery" ) . "' ); 
  661. }); 
  662. }); 
  663.  
  664. </script> 
  665. <?php 
  666.  
  667. /** 
  668. * Like me! 
  669. */ 
  670. public function like_this() { 
  671.  
  672. ?> 
  673. <p> 
  674. <?php _e( 'This plugin is a branch from NextGen Gallery, version 1.9.13.', 'nggallery' ); ?><br> 
  675. <?php _e( 'Developed & maintained by <a href="http://www.wpgetready.com" target="_blank">WPGetReady.com</a>', 'nggallery' ); ?> 
  676. </p> 
  677. <table> 
  678. <tr> 
  679. <td><span class="dashicons dashicons-star-filled"></span></td> 
  680. <td><a href="http://www.wordpress.org/plugins/nextcellent-gallery-nextgen-legacy/" target="_blank"> 
  681. <?php _e( 'You can contribute by giving this plugin a good rating! Thanks a lot!', 'nggallery' ); ?></a> 
  682. </td> 
  683. </tr> 
  684. <tr> 
  685. <td><span class="dashicons dashicons-admin-home"></span></td> 
  686. <td><a href="http://www.wpgetready.com" target="_blank"><?php _e( "Visit the plugin homepage", 'nggallery' ); ?></a></td> 
  687. </tr> 
  688. </table> 
  689. <?php 
  690.  
  691. /** 
  692. * Display the page. 
  693. */ 
  694. public function display() { 
  695. ?> 
  696. <div class="wrap"> 
  697. <h2><?php _e( 'Welcome to NextCellent Gallery!', 'nggallery' ) ?></h2> 
  698.  
  699. <div id="poststuff"> 
  700. <div id="post-body" class="metabox-holder columns-2"> 
  701. <div class="postbox-container" id="postbox-container-2"> <!--style="width:75%;"--> 
  702. <?php do_meta_boxes( 'ngg_overview', 'normal', '' ); ?> 
  703. </div> 
  704. <div class="postbox-container" id="postbox-container-1"> <!--style="width:24%;"--> 
  705. <?php do_meta_boxes( 'ngg_overview', 'side', '' ); ?> 
  706. </div> 
  707. </div> 
  708. </div> 
  709. </div> 
  710. <script type="text/javascript"> 
  711. //<![CDATA[ 
  712. var ajaxWidgets, ajaxPopulateWidgets; 
  713.  
  714. jQuery(document).ready(function ($) { 
  715. // These widgets are sometimes populated via ajax 
  716. ajaxWidgets = [ 
  717. 'dashboard_primary',  
  718. 'dashboard_plugins' 
  719. ]; 
  720.  
  721. ajaxPopulateWidgets = function (el) { 
  722. show = function (id, i) { 
  723. var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading'); 
  724. if (e.length) { 
  725. p = e.parent(); 
  726. setTimeout(function () { 
  727. p.load('admin-ajax.php?action=ngg_dashboard&jax=' + id, '', function () { 
  728. p.hide().slideDown('normal', function () { 
  729. $(this).css('display', ''); 
  730. if ('dashboard_plugins' == id && $.isFunction(tb_init)) 
  731. tb_init('#dashboard_plugins a.thickbox'); 
  732. }); 
  733. }); 
  734. }, i * 500); 
  735. }; 
  736. if (el) { 
  737. el = el.toString(); 
  738. if ($.inArray(el, ajaxWidgets) != -1) 
  739. show(el, 0); 
  740. } else { 
  741. $.each(ajaxWidgets, function (i) { 
  742. show(this, i); 
  743. }); 
  744. }; 
  745. ajaxPopulateWidgets(); 
  746. }); 
  747.  
  748. jQuery(document).ready(function ($) { 
  749. // postboxes setup 
  750. postboxes.add_postbox_toggles('ngg-overview'); 
  751. }); 
  752. //]]> 
  753. </script> 
  754. <?php 
  755.  
  756. public function contributors() { 
  757. ?> 
  758. <div class="ngg-dashboard-widget"> 
  759. <p><?php _e( 'This plugin is made possible by the great work of a lot of people:', 'nggallery' ); ?></p> 
  760. <ul class="ngg-list"> 
  761. <li><?php _e('Alex Rabe and Photocrati for the original NextGen Gallery', 'nggallery')?></li> 
  762. <li><a href="http://wpgetready.com/" 
  763. target="_blank">WPGetReady</a> <?php _e( 'for maintaining this fork of NextGen Gallery', 'nggallery' ); ?> 
  764. </li> 
  765. <li><a href="https://plus.google.com/u/0/+NikoStrijbol/posts" target="_blank">Niko 
  766. Strijbol</a> <?php _e( 'for helping maintain the plugin', 'nggallery' ); ?></li> 
  767. <li><a href="https://bitbucket.org/leap_dev" target="_blank">Richard 
  768. Bale</a> <?php _e( 'for his implementation of changing file the upload date using jQuery', 'nggallery' ); ?> 
  769. </li> 
  770. <li><a href="http://howden.net.au/thowden/" target="_blank">Tony 
  771. Howden</a> <?php _e( 'for his his code suggestions regarding nggtags shortcodes', 'nggallery' ); ?> 
  772. </li> 
  773. <li><a href="http://gfxproductions.com/" target="_blank">Stefano 
  774. Sudati</a> <?php _e( 'for his his suggestions on templates', 'nggallery' ); ?></li> 
  775. <li><p><?php _e( 'Also a big thank you to the new translators: ', 'nggallery' ); ?> 
  776. <br><?php $this->list_contributors(); ?></p> 
  777. </li> 
  778. </ul> 
  779. </div> 
  780. <?php 
  781.  
  782. private function list_contributors() { 
  783.  
  784. $contributors = $this->new_contributors(); 
  785.  
  786. ksort( $contributors ); 
  787. $i = count( $contributors ); 
  788. foreach ( $contributors as $name => $data ) { 
  789. if ( $data[1] ) { 
  790. echo '<a href="' . $data[1] . '" target="_blank">' . $name . '</a> (' . $data[0] . ')'; 
  791. } else { 
  792. echo $name; 
  793. $i --; 
  794. if ( $i == 1 ) { 
  795. echo " & "; 
  796. } elseif ( $i ) { 
  797. echo ", "; 
  798.  
  799. /** New contributors. */ 
  800. private function new_contributors() { 
  801. return array( 
  802. 'Vladimir Vasilenko' => array( 'Russian translation', 'http://shumbely.com/' ),  
  803. 'Niko Strijbol' => array( 'Dutch translation', 'https://plus.google.com/u/0/+NikoStrijbol' ),  
  804. 'Vesa Tiirikainen' => array( 'Finnish translation', 'mailto:vesa@tiirikainen.fi' ),  
  805. 'Thomas Blomberg Hansen'=> array( 'Danish translation' , 'mailto:thomasdk81@gmail.com') 
  806. );