WordPress.org

Forums

Smart Watermark
[resolved] Insert media into post does not work (4 posts)

  1. yelon
    Member
    Posted 1 year ago #

    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/

  2. mr.psiho
    Member
    Posted 1 year ago #

    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).

  3. belfisher
    Member
    Plugin Author

    Posted 1 year ago #

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

  4. belfisher
    Member
    Plugin Author

    Posted 1 year ago #

    Fixed in 2.0.0

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Smart Watermark
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic