wordpress/wp-content/themes/basic/themify/themify-metabox/includes/themify-field-types.php
/**
 * Returns a PLUPLOAD instance. If it's a multisite, checks user quota and shows message if it's not enough to continue upload files.
 *
 * @param string $id
 * @param array $params $label = '', $thumbs = false, $filelist = false, $multiple = false, $message = '', $fallback = ''
 *
 * @return string
 */
Returns a PLUPLOAD instance. If it's a multisite, checks user quota and shows message if it's not enough to continue upload files.

@return string
Returns a PLUPLOAD instance . If it ' s a multisite checks user quota and shows message if it ' s not enough to continue upload files . @return string
function themify_get_uploader( $id = '', $args = array() ){
	$defaults = array(
		'label'		=> __('Upload', 'themify'),
		'preset'	=> false,
		'preview'   => false,
		'tomedia'	=> false,
		'topost'	=> '',
		'fields'	=> '',
		'featured'	=> '',
		'message'	=> '',
		'fallback'	=> '',
		'dragfiles' => false,
		'confirm'	=> '',
		'medialib'	=> false,
		'formats'	=> 'jpg,jpeg,gif,png,ico,zip,txt,svg',
		'type'		=> 'image',
		'action'    => 'themify_plupload',
		'button_class' => '',
	);
	$args = wp_parse_args($args, $defaults);
	$upload_visible = false;
	if ( is_multisite() && !is_upload_space_available() ) {
		if( '' != $args['message'] ){
			$html = $args['message'];
		} else {
			$html = '<small>' . sprintf( __( 'Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify' ), get_space_allowed() ) . '</small>';
		}
	} else {
		if( '' != $args['fallback'] )
			$html = $args['fallback'];
		else {
			ob_start();
			?>
			<!--<input type="hidden" name="<?php echo esc_attr( $id ); ?>" id="<?php echo esc_attr( $id ); ?>" value="" />-->
			<?php if( $args['dragfiles'] ){ ?>
				<div id="<?php echo esc_attr( $id . 'drag-drop-area' ); ?>" class="plupload-drag-drop-area">
			<?php } ?>
				<?php
				$classes = '';
				if($args['preset']) $classes .= 'add-preset ';
				if($args['preview']) $classes .= 'add-preview ';
				if($args['tomedia']) $classes .= 'add-to-media ';
				$datas = array();
				if('' != $args['topost']) $datas[] = 'data-postid="' . esc_attr( $args['topost'] ) . '"';
				if('' != $args['fields']) $datas[] = 'data-fields="' . esc_attr( $args['fields'] ) . '"';
				if('' != $args['confirm']) $datas[] = 'data-confirm="' . esc_attr( $args['confirm'] ) . '"';
				if('' != $args['featured']) $datas[] = 'data-featured="' . esc_attr( $args['featured'] ) . '"';
				if('' != $args['formats']) $datas[] = 'data-formats="' . esc_attr( $args['formats'] ) . '"';
				$datas[] = 'data-action="' . esc_attr( $args['action'] ) . '"';
				?>
				<div class="plupload-upload-uic hide-if-no-js <?php echo esc_attr( $classes ); ?>" <?php echo implode( ' ', $datas ); ?> id="<?php echo esc_attr( $id ); ?>plupload-upload-ui">
					<input id="<?php echo esc_attr( $id ); ?>plupload-browse-button" type="button" value="<?php echo esc_attr( $args['label'] ); ?>" class="button plupload-button <?php echo esc_attr( 'plupload-' . $id . ' ' . $args['button_class'] ); ?>" />
					<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'themify-plupload'); ?>"></span>
				</div>
			<?php if( $args['dragfiles'] ){ ?>
					<small><?php _e(' or drag files here.', 'themify'); ?></small>
				</div>
			<?php } else { ?>
				<span id="<?php echo esc_attr( $id . 'drag-drop-area' ); ?>" style="display: none;"></span>
			<?php }
			$html = ob_get_contents();
			ob_end_clean();
		}
		$upload_visible = true;
	}
	if( $args['medialib'] ) {
		ob_start();
		?>
		<?php
			if ( 'audio' == $args['type'] ) {
				$data_uploader_title = __( 'Browse Audio', 'themify' );
				$medialib_btn_text = __('Insert Audio', 'themify');
			} elseif ( 'video' == $args['type'] ) {
				$data_uploader_title = __( 'Browse Video', 'themify' );
				$medialib_btn_text = __('Insert Video', 'themify');
			} elseif ( in_array($args['formats'],array('woff','woff2','eot','ttf','svg')) ) {
				$data_uploader_title = __( 'Browse Font', 'themify' );
				$medialib_btn_text = __('Insert Font', 'themify');
			}else {
				$data_uploader_title = __( 'Browse Image', 'themify' );
				$medialib_btn_text = __('Insert Image', 'themify');
			}
			$medialib_datas = array(
				'action' => 'themify_metabox_media_lib_browse',
				'media_lib_nonce' => wp_create_nonce( 'media_lib_nonce' ),
				'featured' => ($args['featured'] != '') ? 1 : 0,
				'field_name' => $args['fields'],
				'post_id' => $args['topost']
			);
		?>
		<div class="themify_medialib_wrapper">
			<?php if($upload_visible): echo '&nbsp;<em>' . __( 'or', 'themify' ) . '</em>'; endif; ?>&nbsp;
			<a href="#" class="themify-media-lib-browse" data-submit='<?php echo json_encode( $medialib_datas ); ?>' data-uploader-title="<?php echo esc_attr( $data_uploader_title ) ?>" data-uploader-button-text="<?php echo esc_attr( $medialib_btn_text ); ?>" data-fields="<?php echo esc_attr( $args['fields'] ); ?>" data-type="<?php echo esc_attr( $args['type'] ); ?>"><?php _e( 'Browse Library', 'themify' ) ?></a>
		</div>
		<?php
		$html .= ob_get_contents();
		ob_end_clean();
	}
	return $html;
}
function themify_get_uploader ( $ id = '' , $ args = array ( ) ) { $ defaults = array ( 'label' => __ ( 'Upload' , 'themify' ) , 'preset' => false , 'preview' => false , 'tomedia' => false , 'topost' => '' , 'fields' => '' , 'featured' => '' , 'message' => '' , 'fallback' => '' , 'dragfiles' => false , 'confirm' => '' , 'medialib' => false , 'formats' => 'jpg,jpeg,gif,png,ico,zip,txt,svg' , 'type' => 'image' , 'action' => 'themify_plupload' , 'button_class' => '' , ) ; $ args = wp_parse_args ( $ args , $ defaults ) ; $ upload_visible = false ; if ( is_multisite ( ) && ! is_upload_space_available ( ) ) { if ( '' != $ args [ 'message' ] ) { $ html = $ args [ 'message' ] ; } else { $ html = '<small>' . sprintf ( __ ( 'Sorry, you have filled your %s MB storage quota so uploading has been disabled.' , 'themify' ) , get_space_allowed ( ) ) . '</small>' ; } } else { if ( '' != $ args [ 'fallback' ] ) $ html = $ args [ 'fallback' ] ; else { ob_start ( ) ; ?> <!--<input type="hidden" name=" <?php echo esc_attr ( $ id ) ; ?> " id=" <?php echo esc_attr ( $ id ) ; ?> " value="" />-->
			 <?php if ( $ args [ 'dragfiles' ] ) { ?> <div id=" <?php echo esc_attr ( $ id . 'drag-drop-area' ) ; ?> " class="plupload-drag-drop-area">
			 <?php } ?> <?php $ classes = '' ; if ( $ args [ 'preset' ] ) $ classes .= 'add-preset ' ; if ( $ args [ 'preview' ] ) $ classes .= 'add-preview ' ; if ( $ args [ 'tomedia' ] ) $ classes .= 'add-to-media ' ; $ datas = array ( ) ; if ( '' != $ args [ 'topost' ] ) $ datas [ ] = 'data-postid="' . esc_attr ( $ args [ 'topost' ] ) . '"' ; if ( '' != $ args [ 'fields' ] ) $ datas [ ] = 'data-fields="' . esc_attr ( $ args [ 'fields' ] ) . '"' ; if ( '' != $ args [ 'confirm' ] ) $ datas [ ] = 'data-confirm="' . esc_attr ( $ args [ 'confirm' ] ) . '"' ; if ( '' != $ args [ 'featured' ] ) $ datas [ ] = 'data-featured="' . esc_attr ( $ args [ 'featured' ] ) . '"' ; if ( '' != $ args [ 'formats' ] ) $ datas [ ] = 'data-formats="' . esc_attr ( $ args [ 'formats' ] ) . '"' ; $ datas [ ] = 'data-action="' . esc_attr ( $ args [ 'action' ] ) . '"' ; ?> <div class="plupload-upload-uic hide-if-no-js  <?php echo esc_attr ( $ classes ) ; ?> "  <?php echo implode ( ' ' , $ datas ) ; ?> id=" <?php echo esc_attr ( $ id ) ; ?> plupload-upload-ui">

					<input id=" <?php echo esc_attr ( $ id ) ; ?> plupload-browse-button" type="button" value=" <?php echo esc_attr ( $ args [ 'label' ] ) ; ?> " class="button plupload-button  <?php echo esc_attr ( 'plupload-' . $ id . ' ' . $ args [ 'button_class' ] ) ; ?> " />

					<span class="ajaxnonceplu" id="ajaxnonceplu <?php echo wp_create_nonce ( $ id . 'themify-plupload' ) ; ?> "></span>

				</div>

			 <?php if ( $ args [ 'dragfiles' ] ) { ?> <small> <?php _e ( ' or drag files here.' , 'themify' ) ; ?> </small>
				</div>
			 <?php } else { ?> <span id=" <?php echo esc_attr ( $ id . 'drag-drop-area' ) ; ?> " style="display: none;"></span>
			 <?php } $ html = ob_get_contents ( ) ; ob_end_clean ( ) ; } $ upload_visible = true ; } if ( $ args [ 'medialib' ] ) { ob_start ( ) ; ?> <?php if ( 'audio' == $ args [ 'type' ] ) { $ data_uploader_title = __ ( 'Browse Audio' , 'themify' ) ; $ medialib_btn_text = __ ( 'Insert Audio' , 'themify' ) ; } elseif ( 'video' == $ args [ 'type' ] ) { $ data_uploader_title = __ ( 'Browse Video' , 'themify' ) ; $ medialib_btn_text = __ ( 'Insert Video' , 'themify' ) ; } elseif ( in_array ( $ args [ 'formats' ] , array ( 'woff' , 'woff2' , 'eot' , 'ttf' , 'svg' ) ) ) { $ data_uploader_title = __ ( 'Browse Font' , 'themify' ) ; $ medialib_btn_text = __ ( 'Insert Font' , 'themify' ) ; } else { $ data_uploader_title = __ ( 'Browse Image' , 'themify' ) ; $ medialib_btn_text = __ ( 'Insert Image' , 'themify' ) ; } $ medialib_datas = array ( 'action' => 'themify_metabox_media_lib_browse' , 'media_lib_nonce' => wp_create_nonce ( 'media_lib_nonce' ) , 'featured' => ( $ args [ 'featured' ] != '' ) ? 1 : 0 , 'field_name' => $ args [ 'fields' ] , 'post_id' => $ args [ 'topost' ] ) ; ?> <div class="themify_medialib_wrapper">
			 <?php if ( $ upload_visible ) : echo '&nbsp;<em>' . __ ( 'or' , 'themify' ) . '</em>' ; endif ; ?> &nbsp;
			<a href="#" class="themify-media-lib-browse" data-submit=' <?php echo json_encode ( $ medialib_datas ) ; ?> ' data-uploader-title=" <?php echo esc_attr ( $ data_uploader_title ) ?> " data-uploader-button-text=" <?php echo esc_attr ( $ medialib_btn_text ) ; ?> " data-fields=" <?php echo esc_attr ( $ args [ 'fields' ] ) ; ?> " data-type=" <?php echo esc_attr ( $ args [ 'type' ] ) ; ?> "> <?php _e ( 'Browse Library' , 'themify' ) ?> </a>
		</div>
		 <?php $ html .= ob_get_contents ( ) ; ob_end_clean ( ) ; } return $ html ; }
Returns a PLUPLOAD instance.
Returns a PLUPLOAD instance .
// Extract $label, $preset, $thumbs, $filelist, $multiple, $message, $fallback, $confirm // $id is the name of form field. File urls will be submitted in $_POST using this key. // If $id == "file" then $_POST["file"] will have all the file urls