PluginProbe
Document Gallery / 4.4
Document Gallery v4.4
trunk 0.8 0.8.5 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 2.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 94 releases
document-gallery / document-gallery.php

document-gallery.php in Document Gallery 4.4, at document-gallery.php

111 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'WPINC' ) OR exit;
3
4 /*
5 Plugin Name: Document Gallery
6 Plugin URI: https://wordpress.org/plugins/document-gallery/
7 Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8 Version: 4.4
9 Author: Dan Rossiter
10 Author URI: http://danrossiter.org/
11 License: GPLv3
12 Text Domain: document-gallery
13 */
14
15 define( 'DG_VERSION', '4.4' );
16
17 if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
18 add_action( 'admin_notices', 'dg_php_lt_three' );
19 function dg_php_lt_three() { ?>
20 <div class="error"><p>
21 <?php printf( __( 'Document Gallery requires PHP &ge; 5.3. Your server is running version %s.', 'document-gallery' ), PHP_VERSION ); ?>
22 </p></div>
23 <?php }
24
25 return;
26 }
27
28 // define helper paths & URLs
29 define( 'DG_BASENAME', plugin_basename( __FILE__ ) );
30 define( 'DG_URL', plugin_dir_url( __FILE__ ) );
31 define( 'DG_PATH', plugin_dir_path( __FILE__ ) );
32 define( 'DG_WPINC_PATH', ABSPATH . WPINC . '/' );
33 define( 'DG_WPADMIN_PATH', ABSPATH . 'wp-admin/' );
34
35 // init DG options for use throughout plugin
36 global $dg_options;
37 define( 'DG_OPTION_NAME', 'document_gallery' );
38 $dg_options = get_option( DG_OPTION_NAME, null );
39
40 // core functionality
41 include_once DG_PATH . 'inc/class-document-gallery.php';
42 include_once DG_PATH . 'inc/class-thumb.php';
43 include_once DG_PATH . 'inc/class-util.php';
44
45 // logging functionality
46 include_once DG_PATH . 'inc/class-logger.php';
47 add_action( DG_Logger::PurgeLogsAction, array( 'DG_Logger', 'purgeExpiredEntries' ) );
48
49 // handle activation, updates, and uninstallation
50 include_once DG_PATH . 'inc/class-setup.php';
51 register_activation_hook( __FILE__, array( 'DG_Setup', 'activate' ) );
52 add_action( 'wpmu_new_blog', array( 'DG_Setup', 'activateNewBlog' ) );
53 register_uninstall_hook( __FILE__, array( 'DG_Setup', 'uninstall' ) );
54 DG_Setup::maybeUpdate();
55
56 // ensure we don't allow invalid option structure
57 add_action( 'init', array( 'DocumentGallery', 'addValidation' ) );
58
59 // I18n
60 add_action( 'plugins_loaded', array( 'DocumentGallery', 'loadTextDomain' ) );
61
62 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
63 add_action( ( is_admin() ? 'admin' : 'wp' ) . '_footer', 'dg_debug_data' );
64 function dg_debug_data() {
65 echo '<!-- ' . PHP_EOL;
66 echo 'Document Gallery Count: ' . ( class_exists( 'DG_Gallery' ) ? count( DG_Gallery::getGalleries() ) : 0 ) . PHP_EOL;
67 echo ' -->' . PHP_EOL;
68 }
69 }
70
71 // cleanup cached data when thumbed attachment deleted
72 include_once DG_PATH . 'inc/class-thumber.php';
73 add_action( 'delete_attachment', array( 'DG_Thumb', 'cleanupAttachmentMeta' ) );
74
75 if ( is_admin() ) {
76 // admin house keeping
77 include_once DG_PATH . 'admin/class-admin.php';
78
79 // AJAX handling
80 include_once DG_PATH . 'admin/class-ajax-handler.php';
81
82 // add links to plugin index
83 add_filter( 'plugin_action_links_' . DG_BASENAME, array( 'DG_Admin', 'addSettingsLink' ) );
84 add_filter( 'plugin_row_meta', array( 'DG_Admin', 'addDonateLink' ), 10, 2 );
85
86 // build options page
87 add_action( 'admin_menu', array( 'DG_Admin', 'addAdminPage' ) );
88
89 // add meta box for managing thumbnail generation to attachment Edit Media page
90 add_action( 'add_meta_boxes', array( 'DG_Admin', 'addMetaBox' ) );
91 add_action( 'wp_ajax_dg_upload_thumb', array( 'DG_Admin', 'saveMetaBox' ) );
92
93 if ( DG_Admin::doRegisterSettings() ) {
94 add_action( 'admin_init', array( 'DG_Admin', 'registerSettings' ) );
95 }
96 } else {
97 // styling for gallery
98 if ( apply_filters( 'dg_use_default_gallery_style', true ) ) {
99 add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryStyle' ) );
100 }
101 add_action( 'wp_print_scripts', array( 'DocumentGallery', 'printCustomStyle' ) );
102
103 add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryScript' ) );
104 }
105
106 // adds 'dg' shortcode
107 add_shortcode( 'dg', array( 'DocumentGallery', 'doShortcode' ) );
108
109 // public API for developers
110 include_once DG_PATH . 'inc/class-api.php';
111