Title: Document Gallery Button for elementor
Last modified: February 20, 2019

---

# Document Gallery Button for elementor

 *  [647np](https://wordpress.org/support/users/647np/)
 * (@647np)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/document-gallery-button-for-elementor/)
 * 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.

 * ![](https://ps.w.org/document-gallery/assets/icon.svg?rev=983329)
 * [Document Gallery](https://wordpress.org/plugins/document-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/document-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/document-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/document-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/document-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/document-gallery/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [647np](https://wordpress.org/support/users/647np/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/document-gallery-button-for-elementor/)
 * Status: not resolved