PluginProbe
Document Gallery / 3.5.3
Document Gallery v3.5.3
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
← All changes | document-gallery.php +24 -83 trunk3.5.3 View file →
@@ -1,40 +1,24 @@
1 1 <?php
2 2 defined( 'WPINC' ) OR exit;
3 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.
8 - * Version: 5.1.1
9 - * Requires at least: 6.1
10 - * Requires PHP: 5.6
11 - * Author: Dan Rossiter
12 - * Author URI: https://www.linkedin.com/in/danrossiter/
13 - * License: GPLv3
14 - * License URI: https://www.gnu.org/licenses/gpl-3.0.html
15 - * Text Domain: document-gallery
16 - *
17 - * @package create-block
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.5.3
9 + Author: Dan Rossiter
10 + Author URI: http://danrossiter.org/
11 + License: GPLv2
12 + Text Domain: document-gallery
18 13 */
19 14
20 -define( 'DG_VERSION', '5.1.1' );
15 +define( 'DG_VERSION', '3.5.3' );
21 16
22 -if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
23 - add_action( 'admin_notices', 'dg_php_lt_five_six' );
24 - function dg_php_lt_five_six() { ?>
25 - <div class="error"><p>
26 - <?php printf( __( 'Document Gallery requires PHP &ge; 5.6. Your server is running version %s.', 'document-gallery' ), PHP_VERSION ); ?>
27 - </p></div>
28 - <?php }
29 -
30 - return;
31 -}
32 -
33 17 // define helper paths & URLs
34 18 define( 'DG_BASENAME', plugin_basename( __FILE__ ) );
35 -define( 'DG_URL', plugin_dir_url( __FILE__ ) . 'src/' );
36 -define( 'DG_PATH', plugin_dir_path( __FILE__ ) . 'src/' );
19 +define( 'DG_URL', plugin_dir_url( __FILE__ ) );
20 +define( 'DG_PATH', plugin_dir_path( __FILE__ ) );
37 21 define( 'DG_WPINC_PATH', ABSPATH . WPINC . '/' );
38 22 define( 'DG_WPADMIN_PATH', ABSPATH . 'wp-admin/' );
39 23
40 24 // init DG options for use throughout plugin
@@ -43,9 +27,10 @@
43 27 $dg_options = get_option( DG_OPTION_NAME, null );
44 28
45 29 // core functionality
46 30 include_once DG_PATH . 'inc/class-document-gallery.php';
47 -include_once DG_PATH . 'inc/class-thumb.php';
31 +
32 +// DG general utility functions
48 33 include_once DG_PATH . 'inc/class-util.php';
49 34
50 35 // logging functionality
51 36 include_once DG_PATH . 'inc/class-logger.php';
@@ -63,28 +48,16 @@
63 48
64 49 // I18n
65 50 add_action( 'plugins_loaded', array( 'DocumentGallery', 'loadTextDomain' ) );
66 51
67 -if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
68 - add_action( ( is_admin() ? 'admin' : 'wp' ) . '_footer', 'dg_debug_data' );
69 - function dg_debug_data() {
70 - echo '<!-- ' . PHP_EOL;
71 - echo 'Document Gallery Count: ' . ( class_exists( 'DG_Gallery' ) ? count( DG_Gallery::getGalleries() ) : 0 ) . PHP_EOL;
72 - echo ' -->' . PHP_EOL;
73 - }
74 -}
75 -
76 52 // cleanup cached data when thumbed attachment deleted
77 53 include_once DG_PATH . 'inc/class-thumber.php';
78 -add_action( 'delete_attachment', array( 'DG_Thumb', 'cleanupAttachmentMeta' ) );
54 +add_action( 'delete_attachment', array( 'DG_Thumber', 'deleteThumbMeta' ) );
79 55
80 56 if ( is_admin() ) {
81 57 // admin house keeping
82 58 include_once DG_PATH . 'admin/class-admin.php';
83 59
84 - // AJAX handling
85 - include_once DG_PATH . 'admin/class-ajax-handler.php';
86 -
87 60 // add links to plugin index
88 61 add_filter( 'plugin_action_links_' . DG_BASENAME, array( 'DG_Admin', 'addSettingsLink' ) );
89 62 add_filter( 'plugin_row_meta', array( 'DG_Admin', 'addDonateLink' ), 10, 2 );
90 63
@@ -94,11 +67,20 @@
94 67 // add meta box for managing thumbnail generation to attachment Edit Media page
95 68 add_action( 'add_meta_boxes', array( 'DG_Admin', 'addMetaBox' ) );
96 69 add_action( 'wp_ajax_dg_upload_thumb', array( 'DG_Admin', 'saveMetaBox' ) );
97 70
71 + // Media Manager integration
72 + add_action( 'admin_print_footer_scripts', array(
73 + 'DG_Admin',
74 + 'loadCustomTemplates'
75 + ) ); //wp_print_scripts || wp_footer
76 +
98 77 if ( DG_Admin::doRegisterSettings() ) {
99 78 add_action( 'admin_init', array( 'DG_Admin', 'registerSettings' ) );
100 79 }
80 +
81 + add_action( 'wp_ajax_dg_generate_icons', array( 'DocumentGallery', 'ajaxGenerateIcons' ) );
82 + add_action( 'wp_ajax_nopriv_dg_generate_icons', array( 'DocumentGallery', 'ajaxGenerateIcons' ) );
101 83 } else {
102 84 // styling for gallery
103 85 if ( apply_filters( 'dg_use_default_gallery_style', true ) ) {
104 86 add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryStyle' ) );
@@ -105,49 +87,8 @@
105 87 }
106 88 add_action( 'wp_print_scripts', array( 'DocumentGallery', 'printCustomStyle' ) );
107 89
108 90 add_action( 'wp_enqueue_scripts', array( 'DocumentGallery', 'enqueueGalleryScript' ) );
109 -}
110 -
111 -/**
112 - * Registers the block using the metadata loaded from the `block.json` file.
113 - * Behind the scenes, it registers also all assets so they can be enqueued
114 - * through the block editor in the corresponding context.
115 - *
116 - * @see https://developer.wordpress.org/reference/functions/register_block_type/
117 - */
118 -function document_gallery_block_init() {
119 - register_block_type(
120 - __DIR__ . '/build/block',
121 - array( 'render_callback' => 'document_gallery_block_render_callback' )
122 - );
123 -}
124 -add_action( 'init', 'document_gallery_block_init' );
125 -
126 -/**
127 - * Pass default options to block editor script.
128 - */
129 -function document_gallery_block_localize() {
130 - global $dg_options;
131 -
132 - // Script handle is auto-generated: {namespace}-{block-name}-editor-script
133 - wp_localize_script(
134 - 'document-gallery-document-gallery-block-editor-script',
135 - 'dgBlockConfig',
136 - array( 'dgDefaults' => $dg_options['gallery'] )
137 - );
138 -}
139 -add_action( 'enqueue_block_editor_assets', 'document_gallery_block_localize' );
140 -
141 -/**
142 - * This function is called when the block is being rendered on the front end of the site
143 - *
144 - * @param array $attributes The array of attributes for this block.
145 - * @param string $content Rendered block output. ie. <InnerBlocks.Content />.
146 - * @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
147 - */
148 -function document_gallery_block_render_callback( $attributes, $content, $block_instance ) {
149 - return DocumentGallery::doShortcode( $attributes );
150 91 }
151 92
152 93 // adds 'dg' shortcode
153 94 add_shortcode( 'dg', array( 'DocumentGallery', 'doShortcode' ) );