• Hi!

    Thank you for such an awesome plugin.

    I was wondering if there is way to add the “Create Document Gallery” button in one of the widgets in elementor.

    In one of the previous thread, you had suggested to add the following lines of code in functions.php file in the theme being used. Thanks for that and it worked perfectly. But I wanted to have the same feature, not just in the theme’s classic editor, but in elementor widget’s editor( to be specific “Essential Addons for Elementor plugin’s EA Advanced Accordion widget” as well.

    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');

    Would you please help me with this. I don’t know the location where I can insert this code so that the button appears in the elementor widget. Thank you and sorry for the trouble. Have a good day!

  • The topic ‘Document Gallery Button for elementor’ is closed to new replies.