| 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: 3.2 |
| 9 |
Author: Dan Rossiter |
| 10 |
Author URI: http://danrossiter.org/ |
| 11 |
License: GPLv2 |
| 12 |
Text Domain: document-gallery |
| 13 |
*/ |
| 14 |
|
| 15 |
define('DG_VERSION', '3.2'); |
| 16 |
|
| 17 |
// define helper paths & URLs |
| 18 |
define('DG_BASENAME', plugin_basename(__FILE__)); |
| 19 |
define('DG_URL', plugin_dir_url(__FILE__)); |
| 20 |
define('DG_PATH', plugin_dir_path(__FILE__)); |
| 21 |
define('DG_WPINC_PATH', ABSPATH . WPINC . '/'); |
| 22 |
define('DG_WPADMIN_PATH', ABSPATH . 'wp-admin/'); |
| 23 |
|
| 24 |
// init DG options for use throughout plugin |
| 25 |
global $dg_options; |
| 26 |
define('DG_OPTION_NAME', 'document_gallery'); |
| 27 |
$dg_options = get_option(DG_OPTION_NAME, null); |
| 28 |
|
| 29 |
// core functionality |
| 30 |
include_once DG_PATH . 'inc/class-document-gallery.php'; |
| 31 |
|
| 32 |
// DG general utility functions |
| 33 |
include_once DG_PATH . 'inc/class-util.php'; |
| 34 |
|
| 35 |
// logging functionality |
| 36 |
include_once DG_PATH . 'inc/class-logger.php'; |
| 37 |
add_action(DG_Logger::PurgeLogsAction, array('DG_Logger', 'purgeExpiredEntries')); |
| 38 |
|
| 39 |
// handle activation, updates, and uninstallation |
| 40 |
include_once DG_PATH . 'inc/class-setup.php'; |
| 41 |
register_activation_hook(__FILE__, array('DG_Setup', 'activate')); |
| 42 |
add_action('wpmu_new_blog', array('DG_Setup','activateNewBlog')); |
| 43 |
register_uninstall_hook(__FILE__, array('DG_Setup', 'uninstall')); |
| 44 |
DG_Setup::maybeUpdate(); |
| 45 |
|
| 46 |
// validate options if desired |
| 47 |
if ($dg_options['validation']) { |
| 48 |
add_action('init', array('DocumentGallery', 'addValidation')); |
| 49 |
} |
| 50 |
|
| 51 |
// I18n |
| 52 |
add_action('plugins_loaded', array('DocumentGallery', 'loadTextDomain')); |
| 53 |
|
| 54 |
// cleanup cached data when thumbed attachment deleted |
| 55 |
include_once DG_PATH . 'inc/class-thumber.php'; |
| 56 |
add_action('delete_attachment', array('DG_Thumber', 'deleteThumbMeta')); |
| 57 |
|
| 58 |
if (is_admin()) { |
| 59 |
// admin house keeping |
| 60 |
include_once DG_PATH . 'admin/class-admin.php'; |
| 61 |
|
| 62 |
// add links to plugin index |
| 63 |
add_filter('plugin_action_links_' . DG_BASENAME, array('DG_Admin', 'addSettingsLink')); |
| 64 |
add_filter('plugin_row_meta', array('DG_Admin', 'addDonateLink'), 10, 2); |
| 65 |
|
| 66 |
// build options page |
| 67 |
add_action('admin_menu', array('DG_Admin', 'addAdminPage')); |
| 68 |
|
| 69 |
// add meta box for managing thumbnail generation to attachment Edit Media page |
| 70 |
add_action('add_meta_boxes', array('DG_Admin', 'addMetaBox')); |
| 71 |
add_action('wp_ajax_dg_upload_thumb', array('DG_Admin', 'saveMetaBox')); |
| 72 |
|
| 73 |
// Media Manager integration |
| 74 |
add_action('admin_print_footer_scripts', array('DG_Admin', 'loadCustomTemplates')); //wp_print_scripts || wp_footer |
| 75 |
|
| 76 |
if (DG_Admin::doRegisterSettings()) { |
| 77 |
add_action('admin_init', array('DG_Admin', 'registerSettings')); |
| 78 |
} |
| 79 |
} else { |
| 80 |
// styling for gallery |
| 81 |
if (apply_filters('dg_use_default_gallery_style', true )) { |
| 82 |
add_action('wp_enqueue_scripts', array('DocumentGallery', 'enqueueGalleryStyle')); |
| 83 |
} |
| 84 |
add_action('wp_print_scripts', array('DocumentGallery', 'printCustomStyle')); |
| 85 |
} |
| 86 |
|
| 87 |
// adds 'dg' shortcode |
| 88 |
add_shortcode('dg', array('DocumentGallery', 'doShortcode')); |
| 89 |
|
| 90 |
// public API for developers |
| 91 |
include_once DG_PATH . 'inc/class-api.php'; |
| 92 |
|