WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Insert media into post does not work

[Resolved] Insert media into post does not work

  • Plugin does add watermark, tho having it installed prevents from adding (completely cannot add any image from existing media library) images to posts. Symptoms: images do display in the media library, but after selecting and clicing “insert into post” the popup dissapears and does nothing. Cannot put images into post!

    https://wordpress.org/plugins/smart-watermark/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I also had such problem. But I have figured out how to fix this.
    You need to find file smart-watermark.php, open it, locate ‘options_enqueue_scripts’ public function.
    Then this:

    public function options_enqueue_scripts() {
            wp_register_script(
                                'smart-watermark-settings-general',
                                plugins_url('js/smart-watermark-settings-general.js', __FILE__),
                                array('jquery', 'media-upload', 'thickbox')
                              );
            wp_register_script(
                                'smart-watermark-settings-bulk',
                                plugins_url('js/smart-watermark-settings-bulk.js', __FILE__),
                                array('jquery', 'media-upload', 'thickbox')
                              );
            switch ($this->_get_current_settings_tab()) {
                case self::SETTINGS_KEY_GENERAL:
                    wp_enqueue_script('jquery');
                    wp_enqueue_script('thickbox');
                    wp_enqueue_style('thickbox');
                    wp_enqueue_script('media-upload');
                    wp_enqueue_script('smart-watermark-settings-general');
                    break;
                case self::SETTINGS_KEY_BULK:
                    wp_enqueue_script('jquery');
                    wp_enqueue_script('smart-watermark-settings-bulk');
                    wp_localize_script('jquery', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
                    break;
            }
        }

    replace with this:

    public function options_enqueue_scripts( $hook ) {
            if( 'settings_page_smart_watermark_options' != $hook )
                return;
    
            wp_register_script(
                                'smart-watermark-settings-general',
                                plugins_url('js/smart-watermark-settings-general.js', __FILE__),
                                array('jquery', 'media-upload', 'thickbox')
                              );
            wp_register_script(
                                'smart-watermark-settings-bulk',
                                plugins_url('js/smart-watermark-settings-bulk.js', __FILE__),
                                array('jquery', 'media-upload', 'thickbox')
                              );
            switch ($this->_get_current_settings_tab()) {
                case self::SETTINGS_KEY_GENERAL:
                    wp_enqueue_script('jquery');
                    wp_enqueue_script('thickbox');
                    wp_enqueue_style('thickbox');
                    wp_enqueue_script('media-upload');
                    wp_enqueue_script('smart-watermark-settings-general');
                    break;
                case self::SETTINGS_KEY_BULK:
                    wp_enqueue_script('jquery');
                    wp_enqueue_script('smart-watermark-settings-bulk');
                    wp_localize_script('jquery', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
                    break;
            }
        }

    You are done!)

    It is a very simple fix. All I want to do is to target scripts enqueue to certain admin page (in this case just for plugin’s admin page but not for entire admin area).

    Plugin Author belfisher

    @belfisher

    Thanks for the solution. I’ll add this to the next release.

    Plugin Author belfisher

    @belfisher

    Fixed in 2.0.0

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Insert media into post does not work’ is closed to new replies.