web/wp-content/plugins/slideshow-jquery-image-gallery/classes/SlideshowPluginUpload.php
changeset 194 32102edaa81b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
       
     1 <?php
       
     2 /**
       
     3  * Class SlideshowPluginUpload provides the code for an upload button that can be used
       
     4  * anywhere on a website.
       
     5  *
       
     6  * @author: Stefan Boonstra
       
     7  * @version: 15-09-12
       
     8  */
       
     9 class SlideshowPluginUpload {
       
    10 
       
    11 	/**
       
    12 	 * Returns the html for showing the upload button.
       
    13 	 * Enqueues scripts unless $enqueueFiles is set to false.
       
    14 	 *
       
    15 	 * @param boolean $enqueueFiles
       
    16 	 * @return String $button
       
    17 	 */
       
    18 	static function getUploadButton($enqueueFiles = true){
       
    19 		if($enqueueFiles)
       
    20 			self::enqueueFiles();
       
    21 
       
    22 		// Return button html
       
    23 		ob_start();
       
    24 		include(SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/upload-button.php');
       
    25 		return ob_get_clean();
       
    26 	}
       
    27 
       
    28 	/**
       
    29 	 * Enqueues styles and scripts necessary for the media upload button.
       
    30 	 */
       
    31 	static function enqueueFiles(){
       
    32 		// Enqueue styles
       
    33 		wp_enqueue_style('thickbox');
       
    34 
       
    35 		// Enqueue Wordpress scripts
       
    36 		wp_enqueue_script('media-upload', false, array(), false, true);
       
    37 		wp_enqueue_script('thickbox', false, array(), false, true);
       
    38 
       
    39 		// Enqueue slideshow upload button script
       
    40 		wp_enqueue_script(
       
    41 			'slideshow-upload-button',
       
    42 			SlideshowPluginMain::getPluginUrl() . '/js/' . __CLASS__ . '/upload-button.js',
       
    43 			array(
       
    44 				'jquery',
       
    45 				'media-upload',
       
    46 				'thickbox'),
       
    47 			false,
       
    48 			true
       
    49 		);
       
    50 	}
       
    51 }