• Resolved cmiabs

    (@cmiabs)


    So I have a plugin that was developed circa WP 3.4.x with an “Add Media” button that worked. I recently uncovered the site this was on and found a need to update it.

    Long story short, everything in the plugin works fine EXCEPT the “Add Media” button which does absolutely nothing… Checking the JS console and it’s not throwing any errors or messages, nor are there any in the Apache error logs…

    So here’s the code I’m using to invoke the editor:

    <?php wp_editor( $post->post_content, 'content', array(
                    'dfw' => true,
                    'drag_drop_upload' => true,
                    'tabfocus_elements' => 'insert-media-button,save-post',
                    'editor_height' => 360,
                    'tinymce' => array(
                              'resize' => false,
                              'add_unload_trigger' => false,
                              ),
            ) ); ?>

    I’m calling an enqueue at the top, but that may be where I am wrong… Here’s that code:

    add_action('admin_init', 'editor_admin_init');
                    add_action('admin_head', 'editor_admin_head');
    
                    function editor_admin_init() {
                            wp_enqueue_script('word-count');
                            wp_enqueue_script('post');
                            wp_enqueue_script('editor');
                            wp_enqueue_script('media-upload');
                            wp_enqueue_media( array( 'post' => $post_ID ) );
    
                    }
    
                    function editor_admin_head() {
                            wp_tiny_mce();
                    }

    I’m generally a pretty handy web programmer, but it’s been a while since I’ve messed with PHP and WordPress which seems to be it’s own monster. I generally work in JS/Ember/Angular.

    Thanks in advance for your help!

Viewing 1 replies (of 1 total)
  • Thread Starter cmiabs

    (@cmiabs)

    Scratch that, I fixed it. I was using an older jQuery library that was causing the problem, but WP was suppressing the errors. All good now!

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Custom] Add Media button not working in custom plugin.’ is closed to new replies.