| 1 |
<?php |
| 2 |
defined( 'WPINC' ) OR exit; |
| 3 |
|
| 4 |
/* |
| 5 |
Plugin Name: Document Gallery |
| 6 |
Plugin URI: http://wordpress.org/extend/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.1.12 |
| 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.1.12' ); |
| 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 ≥ 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 |
// cleanup cached data when thumbed attachment deleted |
| 63 |
include_once DG_PATH . 'inc/class-thumber.php'; |
| 64 |
add_action( 'delete_attachment', array( 'DG_Thumb', 'cleanupAttachmentMeta' ) ); |
| 65 |
|
| 66 |
if ( is_admin() ) { |
| 67 |
// admin house keeping |
| 68 |
include_once DG_PATH . 'admin/class-admin.php'; |
| 69 |
|
| 70 |
// AJAX handling |
| 71 |
include_once DG_PATH . 'admin/class-ajax-handler.php'; |
| 72 |
|
| 73 |
// add links to plugin index |
| 74 |
add_filter( 'plugin_action_links_' . DG_BASENAME, array( 'DG_Admin', 'addSettingsLink' ) ); |
| 75 |
add_filter( 'plugin_row_meta', array( 'DG_Admin', 'addDonateLink' ), 10, 2 ); |
| 76 |
|
| 77 |
// build options page |
| 78 |
add_action( 'admin_menu', array( 'DG_Admin', 'addAdminPage' ) ); |
| 79 |
|
| 80 |
// add meta box for managing thumbnail generation to attachment Edit Media page |
| 81 |
add_action( 'add_meta_boxes', array( 'DG_Admin', 'addMetaBox' ) ); |
| 82 |
add_action( 'wp_ajax_dg_upload_thumb', array( 'DG_Admin', 'saveMetaBox' ) ); |
| 83 |
|
| 84 |
if ( DG_Admin::doRegisterSettings() ) { |
| 85 |
add_action( 'admin_init', array( 'DG_Admin', 'registerSettings' ) ); |
| 86 |
} |
| 87 |
} else { |
| 88 |
// styling for gallery |
| 89 |
if ( apply_filters( 'dg_use_default_gallery_style', true ) ) { |
| 90 |
add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryStyle' ) ); |
| 91 |
} |
| 92 |
add_action( 'wp_print_scripts', array( 'DocumentGallery', 'printCustomStyle' ) ); |
| 93 |
|
| 94 |
add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryScript' ) ); |
| 95 |
} |
| 96 |
|
| 97 |
// adds 'dg' shortcode |
| 98 |
add_shortcode( 'dg', array( 'DocumentGallery', 'doShortcode' ) ); |
| 99 |
|
| 100 |
// public API for developers |
| 101 |
include_once DG_PATH . 'inc/class-api.php'; |
| 102 |
|