PHP 클래스 WPAS_File_Upload

저자: Julien Liabeuf ([email protected])
파일 보기 프로젝트 열기: awesome-support/awesome-support 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$error_message Store the potential error messages.
$index
$instance object Instance of this class.
$parent_id
$post_id

공개 메소드들

메소드 설명
__construct ( )
add_form_enctype ( $post )
add_wrapper_class_admin ( array $classes, array $field ) : array Add a custom class to the upload field wrapper in the admin
attachment_endpoint ( ) : void Add a new rewrite endpoint.
attachment_query_var ( WP_Query $query ) : void Add the attachment query var to the $query object.
can_attach_files ( ) : boolean Check if the current user can attach a file.
create_upload_dir ( string $dir ) : boolean Create the upload directory for a ticket.
custom_mime_types ( array $mimes ) : array Add the custom file types to the WordPress whitelist
delete_attachments ( integer $post_id ) : void Delete post attachments.
filter_attachments_out ( array $clauses, WP_Query $wp_query ) : array Filter out tickets and ticket replies attachments
get_allowed_filetypes ( )
get_attachments ( integer $post_id ) : array Get post attachments.
get_instance ( ) : object Return an instance of this class.
has_attachments ( integer $post_id ) : boolean Check if post has attachments.
human_filesize ( integer $bytes, integer $decimals = 2 ) : string Human readable filesize.
individualize_files ( ) : boolean Individualize uploaded files.
limit_upload ( array $file ) : array Limit upload filetypes.
new_reply_attachment ( integer $reply_id ) : void Process upload on new reply creation.
new_reply_backend_attachment ( integer $reply_id ) : void Process upload on new reply creation.
new_ticket_attachment ( integer $ticket_id ) : void Process upload on new ticket creation.
process_upload ( ) : boolean Process the upload.
redirect_error ( string $location ) : string Change the redirection URL.
set_upload_dir ( array $upload ) : string Set upload directory.
show_attachments ( integer $post_id ) : void Show ticket attachments.
upload_field ( ) : void Add dropzone markup.
view_attachment ( ) : void Display the attachment.

보호된 메소드들

메소드 설명
protect_upload_dir ( string $dir ) : void Protects an upload directory by adding an .htaccess file

메소드 상세

__construct() 공개 메소드

public __construct ( )

add_form_enctype() 공개 메소드

public add_form_enctype ( $post )

add_wrapper_class_admin() 공개 메소드

Add a custom class to the upload field wrapper in the admin
부터: 3.2.10
public add_wrapper_class_admin ( array $classes, array $field ) : array
$classes array Field wrapper classes
$field array Field parameters
리턴 array

attachment_endpoint() 공개 메소드

Add a new rewrite endpoint.
부터: 3.2.0
public attachment_endpoint ( ) : void
리턴 void

attachment_query_var() 공개 메소드

This is used as a fallback for when pretty permalinks are not enabled.
부터: 3.2.0
public attachment_query_var ( WP_Query $query ) : void
$query WP_Query The WordPress main query
리턴 void

can_attach_files() 공개 메소드

Check if the current user can attach a file.
부터: 3.0.0
public can_attach_files ( ) : boolean
리턴 boolean True if the user has the capability, false otherwise

create_upload_dir() 공개 메소드

Create the upload directory for a ticket.
부터: 3.1.7
public create_upload_dir ( string $dir ) : boolean
$dir string Upload directory
리턴 boolean Whether or not the directory was created

custom_mime_types() 공개 메소드

Add the custom file types to the WordPress whitelist
부터: 3.2
public custom_mime_types ( array $mimes ) : array
$mimes array Allowed mime types
리턴 array Our custom mime types list

delete_attachments() 공개 메소드

Delete all post attachments if a ticket is deleted.
부터: 3.0.0
public delete_attachments ( integer $post_id ) : void
$post_id integer ID of the post to be deleted
리턴 void

filter_attachments_out() 공개 메소드

Tickets attachments don't have their place in the media library. The library can quickly become a huge mess and it becomes impossible to work with actual post attachments.
부터: 3.3
public filter_attachments_out ( array $clauses, WP_Query $wp_query ) : array
$clauses array SQL query clauses
$wp_query WP_Query WordPress query object
리턴 array

get_allowed_filetypes() 공개 메소드

get_attachments() 공개 메소드

Get the attachments for a specific ticket or reply.
부터: 3.0.0
public get_attachments ( integer $post_id ) : array
$post_id integer ID of the post to get attachment for
리턴 array Array of attachments or empty array if no attachments are found

get_instance() 공개 정적인 메소드

Return an instance of this class.
부터: 1.0.0
public static get_instance ( ) : object
리턴 object A single instance of this class.

has_attachments() 공개 메소드

Check if a specific ticket or reply has attachments. This method is based on get_attachments() and only returns a boolean value based on the returned array being empty or not.
부터: 3.0.0
public has_attachments ( integer $post_id ) : boolean
$post_id integer ID of the post to get attachment for
리턴 boolean True if the ticket has attachments, false otherwise

human_filesize() 공개 메소드

Transform the file size into a readable format including the size unit.
public human_filesize ( integer $bytes, integer $decimals = 2 ) : string
$bytes integer Filesize in bytes
$decimals integer Number of decimals to show
리턴 string Human readable filesize

individualize_files() 공개 메소드

If multiple files were uploaded we need to separate each file in a separate array in the $_FILE array in order to let WordPress process them one by one.
부터: 3.0.0
public individualize_files ( ) : boolean
리턴 boolean Whether or not files were individualized

limit_upload() 공개 메소드

Gets the list of allowed file extensions from the plugin settings and compare the processed file. If the extension is not in the list we simply return an error message to prevent uploading it.
부터: 3.0.0
public limit_upload ( array $file ) : array
$file array Currently processed file details
리턴 array File details with a possible error message

new_reply_attachment() 공개 메소드

Process upload on new reply creation.
부터: 3.0.0
public new_reply_attachment ( integer $reply_id ) : void
$reply_id integer New reply ID
리턴 void

new_reply_backend_attachment() 공개 메소드

Process upload on new reply creation.
부터: 3.0.0
public new_reply_backend_attachment ( integer $reply_id ) : void
$reply_id integer New reply ID
리턴 void

new_ticket_attachment() 공개 메소드

Process upload on new ticket creation.
부터: 3.0.0
public new_ticket_attachment ( integer $ticket_id ) : void
$ticket_id integer New ticket ID
리턴 void

process_upload() 공개 메소드

We delegate the upload process to WordPress. Why reinvent the wheel? The only thing we do change is the upload path. For the rest it's all standard.
부터: 3.0.0
public process_upload ( ) : boolean
리턴 boolean Whether or not the upload has been processed

protect_upload_dir() 보호된 메소드

Protects an upload directory by adding an .htaccess file
부터: 3.1.7
protected protect_upload_dir ( string $dir ) : void
$dir string Upload directory
리턴 void

redirect_error() 공개 메소드

In case the upload fails we want to notify the user. We change the redirection URL and integrate a custom message encoded in base64 that will be interpreted by the notification class.
부터: 3.0.0
public redirect_error ( string $location ) : string
$location string Original redirection URL
리턴 string New redirection URL

set_upload_dir() 공개 메소드

Set a custom upload directory in order to properly separate WordPress uploads and tickets attachments.
부터: 3.0.0
public set_upload_dir ( array $upload ) : string
$upload array Initial upload directory
리턴 string Upload directory

show_attachments() 공개 메소드

Displays a ticket or reply attachments.
부터: 3.0.0
public show_attachments ( integer $post_id ) : void
$post_id integer ID of the post to get attachment for
리턴 void

upload_field() 공개 메소드

Add dropzone markup.
public upload_field ( ) : void
리턴 void

view_attachment() 공개 메소드

Uses the new rewrite endpoint to get an attachment ID and display the attachment if the currently logged in user has the authorization to.
부터: 3.2.0
public view_attachment ( ) : void
리턴 void

프로퍼티 상세

$error_message 보호되어 있는 프로퍼티

Store the potential error messages.
protected $error_message

$index 보호되어 있는 프로퍼티

protected $index

$instance 보호되어 있는 정적으로 프로퍼티

Instance of this class.
부터: 1.0.0
protected static object $instance
리턴 object

$parent_id 보호되어 있는 프로퍼티

protected $parent_id

$post_id 보호되어 있는 프로퍼티

protected $post_id