diff --git a/wp-content/wpalchemy/MediaAccess.php b/wp-content/wpalchemy/MediaAccess.php index 6748ad1..ee44012 100644 --- a/wp-content/wpalchemy/MediaAccess.php +++ b/wp-content/wpalchemy/MediaAccess.php @@ -79,10 +79,45 @@ public function __construct(array $a = array()) if ( ! defined('WPALCHEMY_SEND_TO_EDITOR_ENABLED')) { + // Ensure the media upload scripts and styles are added + add_action( "admin_print_scripts", array( $this, "enqueueAdminScripts") ); + // Ensure send to editor button is added. + add_filter( "get_media_item_args", array( $this, "getMediaItemArgs" ) ); + // Initialize the footer script add_action('admin_footer', array($this, 'init')); define('WPALCHEMY_SEND_TO_EDITOR_ENABLED', true); } + + + } + + /** + * Used to ensure the Insert button is added to media upload panel + * in case the editor isn't present on the screen. + * + * @since 0.2.1 + * @access public + * @param array $args Arguments for media upload + * @return $args + */ + function getMediaItemArgs( $args ) { + $args['send'] = true; + return $args; + } + + /** + * Used to enqueue media upload scripts + * in case the editor isn't present on the screen. + * + * @since 0.2.1 + * @access public + */ + public function enqueueAdminScripts() + { + wp_enqueue_style('thickbox'); + wp_enqueue_script('media-upload'); + wp_enqueue_script('thickbox'); } /** @@ -259,12 +294,12 @@ public function getButton(array $attr = array()) ( 'label' => 'Add Media', 'href' => $this->getButtonLink($tab), - 'class' => $this->getButtonClass($groupname) . ' button', + 'class' => $this->getButtonClass($groupname) . ' button' ); if (isset($this->insert_button_label)) { - $attr_default['class'] .= " {label:'" . $this->insert_button_label . "'}"; + $attr_default['data-button-label'] = $this->insert_button_label; } ### @@ -314,36 +349,42 @@ public function init() ?>