Support » Plugin: Document Gallery » Creating document gallery button beside “add media button”

  • Resolved architecb33

    (@architecb33)


    Is it possible to create “add document gallery” button in post editor, right beside the “add media” button?

    I think it will be more convenient to access this great plugin that way πŸ™‚

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi! Any reply yet? πŸ™‚

    Plugin Author demur

    (@demur)

    Hi architecb33!

    Sorry it took so long for You to get a reply; was hoping to finish development of the feature enhancement prior to answer, but was too busy.

    There is an Add Media button/dialog in WordPress Edit Post interface we’ve been lucky to integrate into. It’s working for both Text and Visual modes of the editor, additionally there is ability using same tools to edit Document Galleries while working in Visual mode.
    For the moment there are following constraints: those tools are not suitable for adding (and editing in Visual mode) plain [dg] (this is the enhancement in progress), sophisticated shortcodes with categories, relation, include/exclude, mime_types and id (the parent post) options also not supported now.

    What were Your thoughts on this issue? What were You looking for? What should that button of Yours do on click?

    thx for the response!

    right now, to access document gallery, the steps are following:
    click “Add Media” button > click “Insert Document Gallery” > select images

    i just wondering if we can create new button located right beside the “Add Media” button, so the steps will be:
    click “Insert Document Gallery” button > select images

    Plugin Author demur

    (@demur)

    Hi architecb33!

    Sounds like You are using DG a lot if one additional click matters to You that much πŸ˜‰ Main idea behind current design was not to overload users with excessive controls and not to increase (typical for software world) multitude of possible ways to accomplish same task.
    We’ll look into Your request, maybe we would introduce it like an option (to activate under advanced settings) for users with extensive usage of DG.

    For now we can suggest You to play around and test this mod.
    To use this code You should paste it to the functions.php file of Your active WordPress theme, this can be done either using Dashboard -> Appearance -> Editor -> Theme Functions (for the active theme), or through FTP.

    function dg_specific_button_js() { ?>
    <script type="text/javascript">
        function open_dg_tab() {
            if ( this.frame === undefined ) {
                if ( wp.media.frame !== undefined && jQuery.inArray(wp.media.frame.state().id, ['dg', 'dg-edit', 'dg-library'])<0 ) {
                    wp.media.frame.setState('dg');
                }
                var options = {
                    frame: 'post',
                    state: 'dg',
                    title: DGl10n.dgMenuTitle,
                    multiple: true
                };
                this.frame = wp.media.editor.open(null, options);
            } else {
                if ( jQuery.inArray(this.frame.state().id, ['dg', 'dg-edit', 'dg-library'])<0 ) {
                    this.frame.setState('dg');
                }
                this.frame.open();
            }
            return false;
        }
        jQuery(document).ready( function() {
            if ( typeof wp.media.collection !== 'function' ) return;
    	jQuery('#dg-specific-button').removeAttr('disabled').click(open_dg_tab);
        } );
    </script>
    <?php }
    function dg_check_page_type( $hook ) {
        if ( in_array( $hook, array( 'post.php', 'post-new.php' ), true ) ) {
            function dg_add_specific_button() {
                echo '<button id="dg-specific-button" class="button" disabled>'.__( 'Create Document Gallery', 'document-gallery' ).'</button>';
            }
            add_action('media_buttons', 'dg_add_specific_button');
            add_action('admin_print_footer_scripts', 'dg_specific_button_js');
        }
    }
    add_action('admin_enqueue_scripts', 'dg_check_page_type');

    Hope this will bring the wanted performance.
    Please don’t hesitate to let us know if You run into any further issues and feel free to give us some feedback πŸ˜‰

    you guys are just awesome!
    and yes, i am a heavy user of your plugin :p

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Creating document gallery button beside “add media button”’ is closed to new replies.