PageRenderTime 28ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/nextgen-gallery/admin/admin.php

https://bitbucket.org/antonyravel/cape-resorts
PHP | 576 lines | 421 code | 75 blank | 80 comment | 66 complexity | 4ac6627ffc17093b6af4ab727376657c MD5 | raw file
  1. <?php
  2. /**
  3. * nggAdminPanel - Admin Section for NextGEN Gallery
  4. *
  5. * @package NextGEN Gallery
  6. * @author Alex Rabe
  7. *
  8. * @since 1.0.0
  9. */
  10. class nggAdminPanel{
  11. // constructor
  12. function __construct() {
  13. // Add the admin menu
  14. add_action( 'admin_menu', array (&$this, 'add_menu') );
  15. add_action( 'admin_bar_menu', array(&$this, 'admin_bar_menu'), 99 );
  16. add_action( 'network_admin_menu', array (&$this, 'add_network_admin_menu') );
  17. // Add the script and style files
  18. add_action('admin_print_scripts', array(&$this, 'load_scripts') );
  19. add_action('admin_print_styles', array(&$this, 'load_styles') );
  20. // Try to detect plugins that embed their own jQuery and jQuery UI
  21. // libraries and load them in NGG's admin pages
  22. add_action('admin_enqueue_scripts', array(&$this, 'buffer_scripts'), 0);
  23. add_action('admin_print_scripts', array(&$this, 'output_scripts'), PHP_INT_MAX);
  24. //TODO: remove after release of Wordpress 3.3
  25. add_filter('contextual_help', array(&$this, 'show_help'), 10, 2);
  26. add_filter('current_screen', array(&$this, 'edit_current_screen'));
  27. // Add WPML hook to register description / alt text for translation
  28. add_action('ngg_image_updated', array('nggGallery', 'RegisterString') );
  29. }
  30. /**
  31. * If a NGG page is being requested, we buffer any rendering of <script>
  32. * tags to detect conflicts and remove them if need be
  33. */
  34. function buffer_scripts()
  35. {
  36. // Is this a NGG admin page?
  37. if (isset($_REQUEST['page']) && strpos($_REQUEST['page'] ,'nggallery') !== FALSE) {
  38. ob_start();
  39. }
  40. }
  41. function output_scripts()
  42. {
  43. // Is this a NGG admin page?
  44. if (isset($_REQUEST['page']) && strpos($_REQUEST['page'] ,'nggallery') !== FALSE) {
  45. $plugin_folder = NGGFOLDER;
  46. $skipjs_count = 0;
  47. $html = ob_get_contents();
  48. ob_end_clean();
  49. if (!defined('NGG_JQUERY_CONFLICT_DETECTION')) {
  50. define('NGG_JQUERY_CONFLICT_DETECTION', TRUE);
  51. }
  52. if (NGG_JQUERY_CONFLICT_DETECTION) {
  53. // Detect custom jQuery script
  54. if (preg_match_all("/<script.*wp-content.*jquery[-_\.](min\.)?js.*<\script>/", $html, $matches, PREG_SET_ORDER)) {
  55. foreach ($matches as $match) {
  56. $old_script = array_shift($match);
  57. if (strpos($old_script, NGGFOLDER) === FALSE)
  58. $html = str_replace($old_script, '', $html);
  59. }
  60. }
  61. // Detect custom jQuery UI script and remove
  62. if (preg_match_all("/<script.*wp-content.*jquery[-_\.]ui.*<\/script>/", $html, $matches, PREG_SET_ORDER)) {
  63. $detected_jquery_ui = TRUE;
  64. foreach ($matches as $match) {
  65. $old_script = array_shift($match);
  66. if (strpos($old_script, NGGFOLDER) === FALSE)
  67. $html = str_replace($old_script, '', $html);
  68. }
  69. }
  70. if (isset($_REQUEST['skipjs'])) {
  71. foreach ($_REQUEST['skipjs'] as $js) {
  72. $js = preg_quote($js);
  73. if (preg_match_all("#<script.*{$js}.*</script>#", $html, $matches, PREG_SET_ORDER)) {
  74. foreach ($matches as $match) {
  75. $old_script = array_shift($match);
  76. if (strpos($old_script, NGGFOLDER) === FALSE)
  77. $html = str_replace($old_script, '', $html);
  78. }
  79. }
  80. }
  81. $skipjs_count = count($_REQUEST['skipjs']);
  82. }
  83. // Use WordPress built-in version of jQuery
  84. $jquery_url = includes_url('js/jquery/jquery.js');
  85. $html = implode('', array(
  86. "<script type='text/javascript' src='{$jquery_url}'></script>\n",
  87. "<script type='text/javascript'>
  88. window.onerror = function(msg, url, line){
  89. if (url.match(/\.js$|\.js\?/)) {
  90. if (window.location.search.length > 0) {
  91. if (window.location.search.indexOf(url) == -1)
  92. window.location.search += '&skipjs[{$skipjs_count}]='+url;
  93. }
  94. else {
  95. window.location.search = '?skipjs[{$skipjs_count}]='+url;
  96. }
  97. }
  98. return true;
  99. };</script>\n",
  100. $html
  101. ));
  102. }
  103. echo $html;
  104. }
  105. }
  106. // integrate the menu
  107. function add_menu() {
  108. add_menu_page( _n( 'Gallery', 'Galleries', 1, 'nggallery' ), _n( 'Gallery', 'Galleries', 1, 'nggallery' ), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu'), path_join(NGGALLERY_URLPATH, 'admin/images/nextgen_16_color.png') );
  109. add_submenu_page( NGGFOLDER , __('Overview', 'nggallery'), __('Overview', 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu'));
  110. add_submenu_page( NGGFOLDER , __('Add Gallery / Images', 'nggallery'), __('Add Gallery / Images', 'nggallery'), 'NextGEN Upload images', 'nggallery-add-gallery', array (&$this, 'show_menu'));
  111. add_submenu_page( NGGFOLDER , __('Manage Gallery', 'nggallery'), __('Manage Gallery', 'nggallery'), 'NextGEN Manage gallery', 'nggallery-manage-gallery', array (&$this, 'show_menu'));
  112. add_submenu_page( NGGFOLDER , _n( 'Album', 'Albums', 1, 'nggallery' ), _n( 'Album', 'Albums', 1, 'nggallery' ), 'NextGEN Edit album', 'nggallery-manage-album', array (&$this, 'show_menu'));
  113. add_submenu_page( NGGFOLDER , __('Tags', 'nggallery'), __('Tags', 'nggallery'), 'NextGEN Manage tags', 'nggallery-tags', array (&$this, 'show_menu'));
  114. add_submenu_page( NGGFOLDER , __('Options', 'nggallery'), __('Options', 'nggallery'), 'NextGEN Change options', 'nggallery-options', array (&$this, 'show_menu'));
  115. if ( wpmu_enable_function('wpmuStyle') )
  116. add_submenu_page( NGGFOLDER , __('Style', 'nggallery'), __('Style', 'nggallery'), 'NextGEN Change style', 'nggallery-style', array (&$this, 'show_menu'));
  117. if ( wpmu_enable_function('wpmuRoles') || wpmu_site_admin() )
  118. add_submenu_page( NGGFOLDER , __('Roles', 'nggallery'), __('Roles', 'nggallery'), 'activate_plugins', 'nggallery-roles', array (&$this, 'show_menu'));
  119. add_submenu_page( NGGFOLDER , __('About this Gallery', 'nggallery'), __('About', 'nggallery'), 'NextGEN Gallery overview', 'nggallery-about', array (&$this, 'show_menu'));
  120. if ( !is_multisite() || wpmu_site_admin() )
  121. add_submenu_page( NGGFOLDER , __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array (&$this, 'show_menu'));
  122. //register the column fields
  123. $this->register_columns();
  124. }
  125. // integrate the network menu
  126. function add_network_admin_menu() {
  127. add_menu_page( _n( 'Gallery', 'Galleries', 1, 'nggallery' ), _n( 'Gallery', 'Galleries', 1, 'nggallery' ), 'nggallery-wpmu', NGGFOLDER, array (&$this, 'show_network_settings'), path_join(NGGALLERY_URLPATH, 'admin/images/nextgen_16_color.png') );
  128. add_submenu_page( NGGFOLDER , __('Network settings', 'nggallery'), __('Network settings', 'nggallery'), 'nggallery-wpmu', NGGFOLDER, array (&$this, 'show_network_settings'));
  129. add_submenu_page( NGGFOLDER , __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array (&$this, 'show_menu'));
  130. }
  131. /**
  132. * Adding NextGEN Gallery to the Admin bar
  133. *
  134. * @since 1.9.0
  135. *
  136. * @return void
  137. */
  138. function admin_bar_menu() {
  139. // If the current user can't write posts, this is all of no use, so let's not output an admin menu
  140. if ( !current_user_can('NextGEN Gallery overview') )
  141. return;
  142. global $wp_admin_bar;
  143. $wp_admin_bar->add_menu( array( 'id' => 'ngg-menu', 'title' => __( 'Gallery' ), 'href' => admin_url('admin.php?page='. NGGFOLDER) ) );
  144. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-overview', 'title' => __('Overview', 'nggallery'), 'href' => admin_url('admin.php?page='. NGGFOLDER) ) );
  145. if ( current_user_can('NextGEN Upload images') )
  146. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-add-gallery', 'title' => __('Add Gallery / Images', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-add-gallery') ) );
  147. if ( current_user_can('NextGEN Manage gallery') )
  148. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-manage-gallery', 'title' => __('Manage Gallery', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-manage-gallery') ) );
  149. if ( current_user_can('NextGEN Edit album') )
  150. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-manage-album', 'title' => _n( 'Album', 'Albums', 1, 'nggallery' ), 'href' => admin_url('admin.php?page=nggallery-manage-album') ) );
  151. if ( current_user_can('NextGEN Manage tags') )
  152. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-tags', 'title' => __('Tags', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-tags') ) );
  153. if ( current_user_can('NextGEN Change options') )
  154. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-options', 'title' => __('Options', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-options') ) );
  155. if ( wpmu_enable_function('wpmuStyle') && ( current_user_can('NextGEN Change style') ))
  156. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-style', 'title' => __('Style', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-style') ) );
  157. $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-about', 'title' => __('About', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-about') ) );
  158. }
  159. // show the network page
  160. function show_network_settings() {
  161. include_once ( dirname (__FILE__) . '/style.php' );
  162. include_once ( dirname (__FILE__) . '/wpmu.php' );
  163. nggallery_wpmu_setup();
  164. }
  165. // load the script for the defined page and load only this code
  166. function show_menu() {
  167. global $ngg;
  168. // Set installation date
  169. if( empty($ngg->options['installDate']) ) {
  170. $ngg->options['installDate'] = time();
  171. update_option('ngg_options', $ngg->options);
  172. }
  173. // Show donation message only one time.
  174. if (isset ( $_GET['hide_donation']) ) {
  175. $ngg->options['hideDonation'] = true;
  176. update_option('ngg_options', $ngg->options);
  177. }
  178. switch ($_GET['page']){
  179. case "nggallery-add-gallery" :
  180. include_once ( dirname (__FILE__) . '/functions.php' ); // admin functions
  181. include_once ( dirname (__FILE__) . '/addgallery.php' ); // nggallery_admin_add_gallery
  182. $ngg->addgallery_page = new nggAddGallery ();
  183. $ngg->addgallery_page->controller();
  184. break;
  185. case "nggallery-manage-gallery" :
  186. include_once ( dirname (__FILE__) . '/functions.php' ); // admin functions
  187. include_once ( dirname (__FILE__) . '/manage.php' ); // nggallery_admin_manage_gallery
  188. // Initate the Manage Gallery page
  189. $ngg->manage_page = new nggManageGallery ();
  190. // Render the output now, because you cannot access a object during the constructor is not finished
  191. $ngg->manage_page->controller();
  192. break;
  193. case "nggallery-manage-album" :
  194. include_once ( dirname (__FILE__) . '/album.php' ); // nggallery_admin_manage_album
  195. $ngg->manage_album = new nggManageAlbum ();
  196. $ngg->manage_album->controller();
  197. break;
  198. case "nggallery-options" :
  199. include_once ( dirname (__FILE__) . '/settings.php' ); // nggallery_admin_options
  200. $ngg->option_page = new nggOptions ();
  201. $ngg->option_page->controller();
  202. break;
  203. case "nggallery-tags" :
  204. include_once ( dirname (__FILE__) . '/tags.php' ); // nggallery_admin_tags
  205. break;
  206. case "nggallery-style" :
  207. include_once ( dirname (__FILE__) . '/style.php' ); // nggallery_admin_style
  208. nggallery_admin_style();
  209. break;
  210. case "nggallery-setup" :
  211. include_once ( dirname (__FILE__) . '/setup.php' ); // nggallery_admin_setup
  212. nggallery_admin_setup();
  213. break;
  214. case "nggallery-roles" :
  215. include_once ( dirname (__FILE__) . '/roles.php' ); // nggallery_admin_roles
  216. nggallery_admin_roles();
  217. break;
  218. case "nggallery-import" :
  219. include_once ( dirname (__FILE__) . '/myimport.php' ); // nggallery_admin_import
  220. nggallery_admin_import();
  221. break;
  222. case "nggallery-about" :
  223. include_once ( dirname (__FILE__) . '/about.php' ); // nggallery_admin_about
  224. nggallery_admin_about();
  225. break;
  226. case "nggallery" :
  227. default :
  228. include_once ( dirname (__FILE__) . '/overview.php' ); // nggallery_admin_overview
  229. nggallery_admin_overview();
  230. break;
  231. }
  232. }
  233. function load_scripts() {
  234. global $wp_version;
  235. // no need to go on if it's not a plugin page
  236. if( !isset($_GET['page']) )
  237. return;
  238. // If we're on a NextGen Page
  239. if (preg_match("/ngg|nextgen-gallery/", $_GET['page'])) {
  240. wp_register_script('ngg_social_media', path_join(
  241. NGGALLERY_URLPATH,
  242. 'admin/js/ngg_social_media.js'
  243. ), array('jquery'));
  244. wp_register_style('ngg_social_media', path_join(
  245. NGGALLERY_URLPATH,
  246. 'admin/css/ngg_social_media.css'
  247. ));
  248. wp_enqueue_style('ngg_social_media');
  249. wp_enqueue_script('ngg_social_media');
  250. }
  251. wp_register_script('ngg-ajax', NGGALLERY_URLPATH . 'admin/js/ngg.ajax.js', array('jquery'), '1.4.1');
  252. wp_localize_script('ngg-ajax', 'nggAjaxSetup', array(
  253. 'url' => admin_url('admin-ajax.php'),
  254. 'action' => 'ngg_ajax_operation',
  255. 'operation' => '',
  256. 'nonce' => wp_create_nonce( 'ngg-ajax' ),
  257. 'ids' => '',
  258. 'permission' => __('You do not have the correct permission', 'nggallery'),
  259. 'error' => __('Unexpected Error', 'nggallery'),
  260. 'failure' => __('A failure occurred', 'nggallery')
  261. ) );
  262. wp_register_script( 'ngg-plupload-handler', NGGALLERY_URLPATH .'admin/js/plupload.handler.js', array('plupload-all'), '0.0.1' );
  263. wp_localize_script( 'ngg-plupload-handler', 'pluploadL10n', array(
  264. 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
  265. 'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
  266. 'zero_byte_file' => __('This file is empty. Please try another.'),
  267. 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
  268. 'not_an_image' => __('This file is not an image. Please try another.'),
  269. 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
  270. 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
  271. 'default_error' => __('An error occurred in the upload. Please try again later.'),
  272. 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
  273. 'upload_limit_exceeded' => __('You may only upload 1 file.'),
  274. 'http_error' => __('HTTP error.'),
  275. 'upload_failed' => __('Upload failed.'),
  276. 'io_error' => __('IO error.'),
  277. 'security_error' => __('Security error.'),
  278. 'file_cancelled' => __('File canceled.'),
  279. 'upload_stopped' => __('Upload stopped.'),
  280. 'dismiss' => __('Dismiss'),
  281. 'crunching' => __('Crunching&hellip;'),
  282. 'deleted' => __('moved to the trash.'),
  283. 'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error')
  284. ) );
  285. wp_register_script('ngg-progressbar', NGGALLERY_URLPATH .'admin/js/ngg.progressbar.js', array('jquery'), '2.0.1');
  286. wp_register_script('jquery-ui-autocomplete', NGGALLERY_URLPATH .'admin/js/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.15');
  287. switch ($_GET['page']) {
  288. case NGGFOLDER :
  289. wp_enqueue_script( 'postbox' );
  290. add_thickbox();
  291. break;
  292. case "nggallery-manage-gallery" :
  293. wp_enqueue_script( 'postbox' );
  294. wp_enqueue_script( 'ngg-ajax' );
  295. wp_enqueue_script( 'ngg-progressbar' );
  296. wp_enqueue_script( 'jquery-ui-dialog' );
  297. wp_enqueue_script( 'jquery-ui-sortable' );
  298. wp_register_script('shutter', NGGALLERY_URLPATH .'shutter/shutter-reloaded.js', false ,'1.3.2');
  299. wp_localize_script('shutter', 'shutterSettings', array(
  300. 'msgLoading' => __('L O A D I N G', 'nggallery'),
  301. 'msgClose' => __('Click to Close', 'nggallery'),
  302. 'imageCount' => '1'
  303. ) );
  304. wp_enqueue_script( 'shutter' );
  305. break;
  306. case "nggallery-manage-album" :
  307. wp_enqueue_script( 'jquery-ui-autocomplete' );
  308. wp_enqueue_script( 'jquery-ui-dialog' );
  309. wp_enqueue_script( 'jquery-ui-sortable' );
  310. wp_enqueue_script( 'ngg-autocomplete', NGGALLERY_URLPATH .'admin/js/ngg.autocomplete.js', array('jquery-ui-autocomplete'), '1.0.1');
  311. break;
  312. case "nggallery-options" :
  313. wp_enqueue_script( 'jquery-ui-tabs' );
  314. //wp_enqueue_script( 'ngg-colorpicker', NGGALLERY_URLPATH .'admin/js/colorpicker/js/colorpicker.js', array('jquery'), '1.0');
  315. break;
  316. case "nggallery-add-gallery" :
  317. wp_enqueue_script( 'jquery-ui-tabs' );
  318. wp_enqueue_script( 'multifile', NGGALLERY_URLPATH .'admin/js/jquery.MultiFile.js', array('jquery'), '1.4.4' );
  319. if ( defined('IS_WP_3_3') )
  320. wp_enqueue_script( 'ngg-plupload-handler' );
  321. else
  322. wp_enqueue_script( 'ngg-swfupload-handler', NGGALLERY_URLPATH .'admin/js/swfupload.handler.js', array('jquery', 'swfupload'), '1.0.3' );
  323. wp_enqueue_script( 'ngg-ajax' );
  324. wp_enqueue_script( 'ngg-progressbar' );
  325. wp_enqueue_script( 'jquery-ui-dialog' );
  326. wp_enqueue_script( 'jqueryFileTree', NGGALLERY_URLPATH .'admin/js/jqueryFileTree/jqueryFileTree.js', array('jquery'), '1.0.1' );
  327. break;
  328. case "nggallery-style" :
  329. wp_enqueue_script( 'codepress' );
  330. wp_enqueue_script( 'ngg-colorpicker', NGGALLERY_URLPATH .'admin/js/colorpicker/js/colorpicker.js', array('jquery'), '1.0');
  331. break;
  332. }
  333. }
  334. function load_styles() {
  335. // load the icon for the navigation menu
  336. wp_enqueue_style( 'nggmenu', NGGALLERY_URLPATH .'admin/css/menu.css', array() );
  337. wp_register_style( 'nggadmin', NGGALLERY_URLPATH .'admin/css/nggadmin.css', false, '2.8.1', 'screen' );
  338. wp_register_style( 'ngg-jqueryui', NGGALLERY_URLPATH .'admin/css/jquery.ui.css', false, '1.8.5', 'screen' );
  339. // no need to go on if it's not a plugin page
  340. if( !isset($_GET['page']) )
  341. return;
  342. switch ($_GET['page']) {
  343. case NGGFOLDER :
  344. wp_enqueue_style( 'thickbox' );
  345. case "nggallery-about" :
  346. wp_enqueue_style( 'nggadmin' );
  347. //TODO:Remove after WP 3.3 release
  348. if ( !defined('IS_WP_3_3') )
  349. wp_admin_css( 'css/dashboard' );
  350. break;
  351. case "nggallery-add-gallery" :
  352. wp_enqueue_style( 'ngg-jqueryui' );
  353. wp_enqueue_style( 'jqueryFileTree', NGGALLERY_URLPATH .'admin/js/jqueryFileTree/jqueryFileTree.css', false, '1.0.1', 'screen' );
  354. case "nggallery-options" :
  355. wp_enqueue_style( 'nggtabs', NGGALLERY_URLPATH .'admin/css/jquery.ui.tabs.css', false, '2.5.0', 'screen' );
  356. wp_enqueue_style( 'nggadmin' );
  357. break;
  358. case "nggallery-manage-gallery" :
  359. wp_enqueue_style('shutter', NGGALLERY_URLPATH .'shutter/shutter-reloaded.css', false, '1.3.2', 'screen');
  360. case "nggallery-roles" :
  361. case "nggallery-manage-album" :
  362. wp_enqueue_style( 'ngg-jqueryui' );
  363. wp_enqueue_style( 'nggadmin' );
  364. break;
  365. case "nggallery-tags" :
  366. wp_enqueue_style( 'nggtags', NGGALLERY_URLPATH .'admin/css/tags-admin.css', false, '2.6.1', 'screen' );
  367. break;
  368. case "nggallery-style" :
  369. wp_admin_css( 'css/theme-editor' );
  370. wp_enqueue_style('nggcolorpicker', NGGALLERY_URLPATH.'admin/js/colorpicker/css/colorpicker.css', false, '1.0', 'screen');
  371. wp_enqueue_style('nggadmincp', NGGALLERY_URLPATH.'admin/css/nggColorPicker.css', false, '1.0', 'screen');
  372. break;
  373. }
  374. }
  375. function show_help($help, $screen) {
  376. // since WP3.0 it's an object
  377. if ( is_object($screen) )
  378. $screen = $screen->id;
  379. $link = '';
  380. // menu title is localized...
  381. $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'nggallery' ) );
  382. switch ($screen) {
  383. case 'toplevel_page_' . NGGFOLDER :
  384. $link = __('<a href="http://www.nextgen-gallery.com" target="_blank">Introduction</a>', 'nggallery');
  385. break;
  386. case "{$i18n}_page_nggallery-about" :
  387. $link = __('<a href="http://www.nextgen-gallery.com/languages" target="_blank">Languages</a>', 'nggallery');
  388. break;
  389. }
  390. if ( !empty($link) ) {
  391. $help = '<h5>' . __('Get help with NextGEN Gallery', 'nggallery') . '</h5>';
  392. $help .= '<div class="metabox-prefs">';
  393. $help .= $link;
  394. $help .= "</div>\n";
  395. $help .= '<h5>' . __('More Help & Info', 'nggallery') . '</h5>';
  396. $help .= '<div class="metabox-prefs">';
  397. $help .= __('<a href="http://wordpress.org/tags/nextgen-gallery?forum_id=10" target="_blank">Support Forums</a>', 'nggallery');
  398. $help .= ' | <a href="http://www.nextgen-gallery.com/faq/" target="_blank">' . __('FAQ', 'nggallery') . '</a>';
  399. $help .= ' | <a href="https://bitbucket.org/photocrati/nextgen-gallery/issues" target="_blank">' . __('Feature request', 'nggallery') . '</a>';
  400. $help .= ' | <a href="http://www.nextgen-gallery.com/languages" target="_blank">' . __('Get your language pack', 'nggallery') . '</a>';
  401. $help .= ' | <a href="https://bitbucket.org/photocrati/nextgen-gallery" target="_blank">' . __('Contribute development', 'nggallery') . '</a>';
  402. $help .= ' | <a href="http://wordpress.org/extend/plugins/nextgen-gallery" target="_blank">' . __('Download latest version', 'nggallery') . '</a>';
  403. $help .= "</div>\n";
  404. }
  405. return $help;
  406. }
  407. /**
  408. * New wrapper for WordPress 3.3, so contextual help will be added to the admin bar
  409. * Rework this see http://wpdevel.wordpress.com/2011/12/06/help-and-screen-api-changes-in-3-3/
  410. *
  411. * @since 1.9.0
  412. * @param object $screen
  413. * @return void
  414. */
  415. function add_contextual_help($screen) {
  416. $help = $this->show_help('', $screen);
  417. //add_contextual_help( $screen, $help );
  418. }
  419. /**
  420. * We need to manipulate the current_screen name so that we can show the correct column screen options
  421. *
  422. * @since 1.8.0
  423. * @param object $screen
  424. * @return object $screen
  425. */
  426. function edit_current_screen($screen) {
  427. if ( is_string($screen) )
  428. $screen = convert_to_screen($screen);
  429. // menu title is localized, so we need to change the toplevel name
  430. $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'nggallery' ) );
  431. switch ($screen->id) {
  432. case "{$i18n}_page_nggallery-manage-gallery" :
  433. // we would like to have screen option only at the manage images / gallery page
  434. if ( isset ($_POST['sortGallery']) )
  435. $screen = $screen;
  436. else if ( (isset($_GET['mode']) && $_GET['mode'] == 'edit') || isset ($_POST['backToGallery']) )
  437. $screen->base = $screen->id = 'nggallery-manage-images';
  438. else if ( (isset($_GET['mode']) && $_GET['mode'] == 'sort') )
  439. $screen = $screen;
  440. else
  441. $screen->base = $screen->id = 'nggallery-manage-gallery';
  442. break;
  443. }
  444. if ( defined('IS_WP_3_3') )
  445. $this->add_contextual_help($screen);
  446. return $screen;
  447. }
  448. /**
  449. * We need to register the columns at a very early point
  450. *
  451. * @return void
  452. */
  453. function register_columns() {
  454. include_once ( dirname (__FILE__) . '/manage-images.php' );
  455. $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
  456. include_once ( dirname (__FILE__) . '/manage-galleries.php' );
  457. $wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
  458. }
  459. /**
  460. * Read an array from a remote url
  461. *
  462. * @param string $url
  463. * @return array of the content
  464. */
  465. function get_remote_array($url) {
  466. if ( function_exists('wp_remote_request') ) {
  467. if ( false === ( $content = get_transient( 'ngg_request_' . md5($url) ) ) ) {
  468. $options = array();
  469. $options['headers'] = array(
  470. 'User-Agent' => 'NextGEN Gallery Information Reader V' . NGGVERSION . '; (' . get_bloginfo('url') .')'
  471. );
  472. $response = wp_remote_request($url, $options);
  473. if ( is_wp_error( $response ) )
  474. return false;
  475. if ( 200 != $response['response']['code'] )
  476. return false;
  477. $content = $response['body'];
  478. set_transient( 'ngg_request_' . md5($url), $content, 60*60*48 );
  479. }
  480. $content = unserialize($content);
  481. if (is_array($content))
  482. return $content;
  483. }
  484. return false;
  485. }
  486. }
  487. function wpmu_site_admin() {
  488. // Check for site admin
  489. if ( function_exists('is_super_admin') )
  490. if ( is_super_admin() )
  491. return true;
  492. return false;
  493. }
  494. function wpmu_enable_function($value) {
  495. if (is_multisite()) {
  496. $ngg_options = get_site_option('ngg_options');
  497. return $ngg_options[$value];
  498. }
  499. // if this is not WPMU, enable it !
  500. return true;
  501. }