PHP Class Amazon_S3_And_CloudFront, wp-amazon-s3-and-cloudfront

Inheritance: extends AWS_Plugin_Base
Afficher le fichier Open project: deliciousbrains/wp-amazon-s3-and-cloudfront Class Usage Examples

Méthodes publiques

Свойство Type Description
$filter_local AS3CF_Local_To_S3
$filter_s3 AS3CF_S3_To_Local
$hook_suffix string
$notices AS3CF_Notices
$plugin_compat AS3CF_Plugin_Compatibility

Protected Properties

Свойство Type Description
$admin_notices array
$buckets_check Store if each bucket, used by the plugin and addons, is writable
$default_tab string
$plugin_menu_title string
$plugin_page
$plugin_prefix string
$plugin_title string

Méthodes publiques

Méthode Description
__construct ( string $plugin_file_path, Amazon_Web_Services $aws, string | null $slug = null )
_exit ( integer | string $exit_code ) : void Helper function for terminating script execution. Easily testable.
_throw_error ( string $code, string $message = '', mixed $data = '' ) : WP_Error Throw error
add_media_row_actions ( array $actions = [], WP_Post | integer $post ) : array Conditionally adds copy, remove and download S3 action links for an attachment on the Media library list view
admin_menu ( Amazon_Web_Services $aws ) Add the settings menu item
ajax_check_bucket ( )
ajax_create_bucket ( ) Handler for AJAX callback to create a bucket in S3
ajax_get_attachment_s3_details ( ) Handle retieving the S3 details for attachment modals.
ajax_get_buckets ( ) AJAX handler for get_buckets()
ajax_get_diagnostic_info ( ) AJAX handler for get_diagnostic_info()
ajax_get_url_preview ( ) AJAX handler for get_url_preview()
ajax_save_bucket ( ) Handler for AJAX callback to save the selection of a bucket
apply_file_suffix ( string $file, string $suffix ) : string Helper to apply a suffix to a file path
attachment_s3_actions_meta_box ( ) Render the S3 attachment meta box
attachment_s3_meta_box ( ) Add the S3 meta box to the attachment screen
check_for_gd_imagick ( ) Check if PHP GD and Imagick is installed
check_write_permission ( string $bucket = null, string $region = null ) : boolean | WP_Error Checks the user has write permission for S3
clear_scheduled_event ( string $hook ) Wrapper for clearing scheduled events for a specific cron job
count_attachments ( string $prefix, null | boolean $uploaded_to_s3 = null ) : integer Count attachments on a site
create_bucket ( string $bucket_name, null | string $region = null ) : boolean | WP_Error Create an S3 bucket
dbrains_link ( string $url, string $text, string $hash = '', boolean $append_campaign = true ) : string Create a site link for given url, link text and optional anchor, usually with campaign.
decode_filename_in_path ( string $file ) : string Decode file name.
delete_attachment ( integer $post_id, boolean $force_new_s3_client = false ) Removes an attachment and intermediate image size files from S3
delete_s3_objects ( string $region, string $bucket, array $objects, boolean $log_error = false, boolean $return_on_error = false, boolean $force_new_s3_client = false ) : boolean Delete bulk objects from an S3 bucket
does_file_exist ( string $filename, string $time ) : boolean Does file exist
does_file_exist_local ( string $filename, string $time ) : boolean Does file exist local
does_file_exist_s3 ( string $filename, string $time ) : boolean Does file exist s3
encode_filename_in_path ( string $file ) : string Encode file names according to RFC 3986 when generating urls As per Amazon https://forums.aws.amazon.com/thread.jspa?threadID=55746#jive-message-244233
end_ajax ( array $return = [] ) Helper method for returning data to AJAX call
filter_input ( string $variable, integer $type = INPUT_GET, integer $filter = FILTER_DEFAULT, mixed $options = [] ) : mixed Helper function for filtering super globals. Easily testable.
filter_settings ( array $settings ) : array Filter in defined settings with sensible defaults.
gd_enabled ( ) : boolean Detect if PHP GD is enabled
generate_unique_filename ( string $name, string $ext, string $time ) : string Generate unique filename
get_access_denied_notice_message ( boolean $single = true ) : string Get the access denied bucket error notice message
get_acl_display_name ( string $acl ) : string Return human friendly ACL name
get_all_blog_table_prefixes ( array $exclude_blog_ids = [] ) : array Get all the table prefixes for the blogs in the site. MS compatible
get_allowed_mime_types ( ) : array Allowed mime types array that can be edited for specific S3 uploading
get_attached_file ( string $file, integer $attachment_id ) : string Return the S3 URL when the local file is missing unless we know the calling process is and we are happy to copy the file back to the server to be used
get_attachment_file_paths ( integer $attachment_id, boolean $exists_locally = true, array | boolean $meta = false, boolean $include_backups = true ) : array Get file paths for all attachment versions.
get_attachment_folder_time ( integer $post_id ) : integer | string Get the time of attachment upload.
get_attachment_local_url ( integer $post_id ) : string | false Get attachment local URL.
get_attachment_local_url_size ( integer $post_id, string | null $size = null ) : false | string Get attachment local URL size.
get_attachment_s3_info ( integer $post_id ) : mixed Get attachment s3 info
get_attachment_s3_url ( integer $post_id, array $s3object, null | integer $expires = null, null | string | array $size = null, null | array $meta = null, array $headers = [] ) : mixed | WP_Error Get the S3 URL for an attachment
get_attachment_url ( integer $post_id, integer | null $expires = null, string | null $size = null, array | null $meta = null, array $headers = [], boolean $skip_rewrite_check = false ) : boolean | mixed | void | WP_Error Get the url of the file from Amazon S3
get_aws_bucket_link ( string $bucket = '', string $prefix = '' ) : string Get the link to the bucket on the AWS console
get_aws_regions ( ) : array Get all AWS regions
get_blog_ids ( ) : false | array Get all the blog IDs for the multisite network used for table prefixes
get_bucket_region ( string $bucket ) : string | WP_Error Get the region of a bucket
get_buckets ( ) : array | WP_Error Get a list of buckets from S3
get_default_object_prefix ( ) : string Return the default object prefix
get_dynamic_prefix ( string $time = null ) : string Get the prefix path for the files. Ignores WP media library year month subdirectory setting and just uses S3 setting
get_file_prefix ( null | string $time = null ) : string Get the file prefix
get_folder_time_from_url ( string $url ) : null | string Get the upload folder time from given URL
get_formatted_s3_info ( integer $id, array | null $s3object = null ) : array Return a formatted S3 info with display friendly defaults
get_image_sizes_details ( ) : string Output image size names and dimensions to a string
get_media_action_strings ( null | string $string = null ) : array | string Get all strings or a specific string used for the media actions
get_memory_limit ( ) : integer Get memory limit
get_object_prefix ( string $toggle_setting = 'enable-object-prefix' ) : string Get the custom object prefix if enabled
get_object_version_string ( ) : string Get the object versioning string prefix
get_plugin_details ( string $plugin_path, string $suffix = '' ) : string Helper to display plugin details
get_plugin_page_title ( ) : string Get the plugin title to be used in page headings
get_plugin_page_url ( array $args = [], string $url_method = 'network', boolean $escape = true ) : string Helper method to return the settings page URL for the plugin
get_plugin_prefix_slug ( ) : string Get the plugin prefix in slug format, ie. replace underscores with hyphens
get_post_time ( integer $post_id ) : string Get post time
get_s3_url_domain ( string $bucket, string $region = '', integer $expires = null, array $args = [], boolean $preview = false ) : mixed | string | void Get the S3 url for the files
get_s3_url_prefix ( string $region = '', null | integer $expires = null ) : string Get the region specific prefix for S3 URL
get_s3_url_scheme ( boolean | null $use_ssl = null ) : string Return the scheme to be used in URLs
get_s3client ( boolean | string $region = false, boolean $force = false ) : Aws\S3\S3Client Get the S3 client
get_s3object_region ( array $s3object, integer $post_id = null ) : string | WP_Error Get the region of the bucket stored in the S3 metadata.
get_secure_attachment_url ( integer $post_id, integer | null $expires = null, string | null $size = null, array $headers = [], boolean $skip_rewrite_check = false ) : mixed | void | WP_Error Generate a link to download a file from Amazon S3 using query string authentication. This link is only valid for a limited amount of time.
get_setting ( string $key, mixed $default = '' ) : integer | mixed | string | WP_Error Accessor for a plugin setting with conditions to defaults and upgrades
get_setting_args ( string $key ) : array Gets arguements used to render a setting view.
get_setting_bucket ( string $key, string $value, string $constant = 'AS3CF_BUCKET' ) : string | false Get the bucket and if a constant save to database and clear region
get_setting_region ( array $settings, string $key, mixed $default ) : boolean | string | WP_Error Get the region setting
get_settings_nonce_key ( ) : string Get the nonce key for the settings form of the plugin
get_settings_tabs ( ) : array Get the tabs available for the plugin settings page
get_settings_whitelist ( ) : array Whitelist of settings allowed to be saved
get_skip_sanitize_settings ( ) : array List of settings that should skip full sanitize.
get_url_preview ( boolean $escape = true, string $suffix = 'photo.jpg' ) : string Generate a preview of the URL of files uploaded to S3
get_year_month_directory_name ( string $time = null ) : string Generate the year and month sub-directory from $time if provided, then POST time if available, otherwise use current time
handle_post_request ( ) Handle the saving of the settings page
http_prepare_download_log ( ) : void Check for as3cf-download-log and related nonce and if found begin the download of the diagnostic log
imagick_enabled ( ) : boolean Detect is Imagick is enabled
init ( string $plugin_file_path ) Abstract class constructor
is_attachment_served_by_s3 ( integer $attachment_id, boolean $skip_rewrite_check = false ) : boolean | array Is attachment served by S3.
is_current_blog ( integer $blog_id ) : boolean Is the current blog ID that specified in wp-config.php
is_plugin_setup ( ) : boolean Check the plugin is correctly setup
is_pro ( ) : boolean Check whether the pro addon is installed.
load_attachment_assets ( $hook_suffix ) Load the attachment assets only when editing an attachment
load_media_assets ( ) Load media assets.
make_acl_admin_notice ( array $s3object ) Make admin notice for when object ACL has changed
maybe_disable_save_button ( string $defined_settings = [] ) : string Disables the save button if all settings have been defined.
maybe_encode_get_image_tag ( string $html, integer $id, string $alt, string $title, string $align, string $size ) : string Maybe encode attachment URLs when retrieving the image tag
maybe_encode_image_get_intermediate_size ( array $data, integer $post_id, string | array $size ) : array Maybe encode URLs when retrieving intermediate sizes.
maybe_encode_wp_get_attachment_image_src ( array | boolean $image, integer $attachment_id, string | array $size, boolean $icon ) : array Maybe encode URLs for images that represent an attachment
maybe_encode_wp_prepare_attachment_for_js ( array $response, integer | object $attachment, array $meta ) : array Maybe encode URLs when outputting attachments in the media grid
maybe_remove_query_string ( string $url ) : string Maybe remove query string from URL.
maybe_update_cloudfront_path ( string $path ) : string Potentially update path for CloudFront URLs.
memory_exceeded ( null | string $filter_name = null ) : boolean Memory exceeded
more_info_link ( string $url, string $hash = '', boolean $append_campaign = true ) : string More info link
multisite_get_spaced_used ( $space_used ) : float | integer Used to give a realistic total of storage space used on a Multisite subsite, when there have been attachments uploaded to S3 but removed from server
on_off ( string $key ) : string Helper for displaying settings
open_ssl_enabled ( ) : boolean Detect if OpenSSL is enabled
output_diagnostic_info ( boolean $escape = true ) : string Diagnostic information for the support tab
plugin_deactivated_notice ( ) Display a notice after either lite or pro plugin has been auto deactivated
plugin_load ( )
pre_set_setting ( string $key, string $value ) Perform custom actions before the setting is saved
prepare_bucket_error ( WP_Error $object, boolean $single = true ) : array Prepare the bucket error before returning to JS
register_modal_assets ( ) Register modal scripts and styles so they can be enqueued later
remove_attachment_files_from_s3 ( integer $post_id, array $s3object, boolean $remove_backup_sizes = true, boolean $log_error = false, boolean $return_on_error = false, boolean $force_new_s3_client = false ) Removes an attachment's files from S3.
remove_local_files ( array $file_paths ) Remove files from the local site
remove_scheme ( string $url ) : string Remove scheme from URL.
remove_size_from_filename ( string $url, boolean $remove_extension = false ) : string Remove size from filename (image[-100x100].jpeg).
remove_wp_plugin_dir ( string $path ) : string Helper to remove the plugin directory from the plugin path
render_bucket_permission_errors ( ) Render error messages in a view for bucket permission and access issues
render_page ( ) Display the main settings page for the plugin
restore_current_blog ( ) Helper to restore to the current Multisite blog
sanitize_custom_domain ( string $domain ) : string Sanitize custom domain
save_bucket ( string $bucket_name, boolean $manual = false, null | string $region = null ) : string | boolean Save bucket and bucket's region
save_bucket_for_ajax ( string $bucket, boolean | false $manual_select = false, null | string $region = null, array $defaults = [] ) Wrapper method for saving a bucket when creating or selecting
schedule_event ( string $hook, null | string $interval = null, array $args = [] ) Wrapper for scheduling cron jobs
set_attachment_acl_on_s3 ( integer $post_id, array $s3object, string $acl ) : array | boolean | WP_Error Apply ACL to an attachment and associated files
set_client ( Aws\S3\S3Client $client ) Setter for S3 client
set_setting ( string $key, mixed $value ) Setter for a plugin setting with custom hooks
settings_more_info_link ( string $hash ) : string Settings more info link
show_deprecated_domain_setting ( null | string $domain = null ) : boolean Show the deprecated Domain option setting?
switch_to_blog ( integer | boolean $blog_id = false ) Helper to switch to a Multisite blog - If the site is MS - If the blog is not the current blog defined
translate_region ( $region ) : string Translate older bucket locations to newer S3 region names http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
update_attached_file ( string $file, integer $attachment_id ) : string Allow processes to update the file on S3 via update_attached_file()
update_site_option ( string $option, mixed $value, boolean $autoload = true ) : boolean Update site option.
upgrade_virtual_host ( ) : string Upgrade the 'virtual host' / 'bucket as domain' setting to the new CloudFront / Domain setting
upload_attachment_to_s3 ( integer $post_id, array | null $data = null, string | null $file_path = null, boolean $force_new_s3_client = false, boolean $remove_local_files = true ) : array | WP_Error Upload attachment to S3
use_ssl ( boolean | null $use_ssl = null ) : boolean Determine when to use https in URLS
verify_ajax_request ( )
verify_media_actions ( ) : boolean Check we can do the media actions
wp_get_attachment_url ( string $url, integer $post_id ) : boolean | mixed | void | WP_Error Get attachment url
wp_handle_upload_prefilter ( array $file ) : array Create unique names for file to be uploaded to AWS This only applies when the remove local file option is enabled
wp_update_attachment_metadata ( array $data, integer $post_id ) : array Handles the upload of the attachment to S3 when an attachment is updated using the 'wp_update_attachment_metadata' filter

Méthodes protégées

Méthode Description
convert_dimensions_to_size_name ( integer $attachment_id, array $dimensions ) : null | string Convert dimensions to size
diagnostic_media_counts ( ) : array Get the total attachment and total S3 attachment counts for the diagnostic log
get_acl_value_string ( array $acl ) : string Get ACL value string.
get_local_url_preview ( boolean $escape = true, string $suffix = 'photo.jpg' ) : string Get local URL preview.
get_mime_types_to_gzip ( boolean $media_library = false ) : array Get mime types to gzip
maybe_convert_size_to_string ( integer $attachment_id, mixed $size ) : null | string Maybe convert size to string
maybe_display_deprecated_http_notice ( ) Display a notice if using setting to force HTTP as url scheme, removed in 1.3.
maybe_sign_intermediate_size ( string $url, integer $attachment_id, string | array $size, boolean | array $s3object = false ) : mixed | WP_Error Sign intermediate size.
normalize_object_prefix ( string $prefix ) : string Normalize object prefix.
return_upload_error ( string $error_msg, array | null $return = null ) : array | WP_Error Helper to return meta data on upload error
should_gzip_file ( string $file_path, string $type ) : boolean Should gzip file

Private Methods

Méthode Description
more_info_campaign_url ( string $url ) : string Create a More Info campaign url for given url.

Method Details

__construct() public méthode

public __construct ( string $plugin_file_path, Amazon_Web_Services $aws, string | null $slug = null )
$plugin_file_path string
$aws Amazon_Web_Services
$slug string | null

_exit() public méthode

Helper function for terminating script execution. Easily testable.
public _exit ( integer | string $exit_code ) : void
$exit_code integer | string
Résultat void

_throw_error() public méthode

Throw error
public _throw_error ( string $code, string $message = '', mixed $data = '' ) : WP_Error
$code string
$message string
$data mixed
Résultat WP_Error

add_media_row_actions() public méthode

Conditionally adds copy, remove and download S3 action links for an attachment on the Media library list view
public add_media_row_actions ( array $actions = [], WP_Post | integer $post ) : array
$actions array
$post WP_Post | integer
Résultat array

admin_menu() public méthode

Add the settings menu item
public admin_menu ( Amazon_Web_Services $aws )
$aws Amazon_Web_Services

ajax_check_bucket() public méthode

public ajax_check_bucket ( )

ajax_create_bucket() public méthode

Handler for AJAX callback to create a bucket in S3
public ajax_create_bucket ( )

ajax_get_attachment_s3_details() public méthode

Handle retieving the S3 details for attachment modals.

ajax_get_buckets() public méthode

AJAX handler for get_buckets()
public ajax_get_buckets ( )

ajax_get_diagnostic_info() public méthode

AJAX handler for get_diagnostic_info()

ajax_get_url_preview() public méthode

AJAX handler for get_url_preview()

ajax_save_bucket() public méthode

Handler for AJAX callback to save the selection of a bucket
public ajax_save_bucket ( )

apply_file_suffix() public méthode

Helper to apply a suffix to a file path
public apply_file_suffix ( string $file, string $suffix ) : string
$file string
$suffix string
Résultat string

attachment_s3_actions_meta_box() public méthode

Render the S3 attachment meta box

attachment_s3_meta_box() public méthode

Add the S3 meta box to the attachment screen

check_for_gd_imagick() public méthode

Check if PHP GD and Imagick is installed

check_write_permission() public méthode

Checks the user has write permission for S3
public check_write_permission ( string $bucket = null, string $region = null ) : boolean | WP_Error
$bucket string
$region string
Résultat boolean | WP_Error

clear_scheduled_event() public méthode

Wrapper for clearing scheduled events for a specific cron job
public clear_scheduled_event ( string $hook )
$hook string

convert_dimensions_to_size_name() protected méthode

Convert dimensions to size
protected convert_dimensions_to_size_name ( integer $attachment_id, array $dimensions ) : null | string
$attachment_id integer
$dimensions array
Résultat null | string

count_attachments() public méthode

Count attachments on a site
public count_attachments ( string $prefix, null | boolean $uploaded_to_s3 = null ) : integer
$prefix string
$uploaded_to_s3 null | boolean null - All attachments true - Attachments only uploaded to S3 false - Attachments not uploaded to S3
Résultat integer

create_bucket() public méthode

Create an S3 bucket
public create_bucket ( string $bucket_name, null | string $region = null ) : boolean | WP_Error
$bucket_name string
$region null | string option location constraint
Résultat boolean | WP_Error

decode_filename_in_path() public méthode

Decode file name.
public decode_filename_in_path ( string $file ) : string
$file string
Résultat string

delete_attachment() public méthode

Removes an attachment and intermediate image size files from S3
public delete_attachment ( integer $post_id, boolean $force_new_s3_client = false )
$post_id integer
$force_new_s3_client boolean if we are deleting in bulk, force new S3 client to cope with possible different regions

delete_s3_objects() public méthode

Delete bulk objects from an S3 bucket
public delete_s3_objects ( string $region, string $bucket, array $objects, boolean $log_error = false, boolean $return_on_error = false, boolean $force_new_s3_client = false ) : boolean
$region string
$bucket string
$objects array
$log_error boolean
$return_on_error boolean
$force_new_s3_client boolean if we are deleting in bulk, force new S3 client to cope with possible different regions
Résultat boolean

diagnostic_media_counts() protected méthode

Get the total attachment and total S3 attachment counts for the diagnostic log
protected diagnostic_media_counts ( ) : array
Résultat array

does_file_exist() public méthode

Does file exist
public does_file_exist ( string $filename, string $time ) : boolean
$filename string
$time string
Résultat boolean

does_file_exist_local() public méthode

Does file exist local
public does_file_exist_local ( string $filename, string $time ) : boolean
$filename string
$time string
Résultat boolean

does_file_exist_s3() public méthode

Does file exist s3
public does_file_exist_s3 ( string $filename, string $time ) : boolean
$filename string
$time string
Résultat boolean

encode_filename_in_path() public méthode

Encode file names according to RFC 3986 when generating urls As per Amazon https://forums.aws.amazon.com/thread.jspa?threadID=55746#jive-message-244233
public encode_filename_in_path ( string $file ) : string
$file string
Résultat string Encoded filename

end_ajax() public méthode

Helper method for returning data to AJAX call
public end_ajax ( array $return = [] )
$return array

filter_input() public méthode

Helper function for filtering super globals. Easily testable.
public filter_input ( string $variable, integer $type = INPUT_GET, integer $filter = FILTER_DEFAULT, mixed $options = [] ) : mixed
$variable string
$type integer
$filter integer
$options mixed
Résultat mixed

filter_settings() public méthode

Filter in defined settings with sensible defaults.
public filter_settings ( array $settings ) : array
$settings array
Résultat array $settings

gd_enabled() public méthode

Detect if PHP GD is enabled
public gd_enabled ( ) : boolean
Résultat boolean

generate_unique_filename() public méthode

Generate unique filename
public generate_unique_filename ( string $name, string $ext, string $time ) : string
$name string
$ext string
$time string
Résultat string

get_access_denied_notice_message() public méthode

Get the access denied bucket error notice message
public get_access_denied_notice_message ( boolean $single = true ) : string
$single boolean
Résultat string

get_acl_display_name() public méthode

Return human friendly ACL name
public get_acl_display_name ( string $acl ) : string
$acl string
Résultat string

get_acl_value_string() protected méthode

Get ACL value string.
protected get_acl_value_string ( array $acl ) : string
$acl array
Résultat string

get_all_blog_table_prefixes() public méthode

Get all the table prefixes for the blogs in the site. MS compatible
public get_all_blog_table_prefixes ( array $exclude_blog_ids = [] ) : array
$exclude_blog_ids array blog ids to exclude
Résultat array associative array with blog ID as key, prefix as value

get_allowed_mime_types() public méthode

Allowed mime types array that can be edited for specific S3 uploading
public get_allowed_mime_types ( ) : array
Résultat array

get_attached_file() public méthode

Return the S3 URL when the local file is missing unless we know the calling process is and we are happy to copy the file back to the server to be used
public get_attached_file ( string $file, integer $attachment_id ) : string
$file string
$attachment_id integer
Résultat string

get_attachment_file_paths() public méthode

Get file paths for all attachment versions.
public get_attachment_file_paths ( integer $attachment_id, boolean $exists_locally = true, array | boolean $meta = false, boolean $include_backups = true ) : array
$attachment_id integer
$exists_locally boolean
$meta array | boolean
$include_backups boolean
Résultat array

get_attachment_folder_time() public méthode

Use post datetime if attached.
public get_attachment_folder_time ( integer $post_id ) : integer | string
$post_id integer
Résultat integer | string

get_attachment_local_url() public méthode

This is a direct copy of wp_get_attachment_url() from /wp-includes/post.php as we filter the URL in AS3CF and can't remove this filter using the current implementation of globals for class instances.
public get_attachment_local_url ( integer $post_id ) : string | false
$post_id integer
Résultat string | false Attachment URL, otherwise false.

get_attachment_local_url_size() public méthode

Get attachment local URL size.
public get_attachment_local_url_size ( integer $post_id, string | null $size = null ) : false | string
$post_id integer
$size string | null
Résultat false | string

get_attachment_s3_info() public méthode

Get attachment s3 info
public get_attachment_s3_info ( integer $post_id ) : mixed
$post_id integer
Résultat mixed

get_attachment_s3_url() public méthode

Get the S3 URL for an attachment
public get_attachment_s3_url ( integer $post_id, array $s3object, null | integer $expires = null, null | string | array $size = null, null | array $meta = null, array $headers = [] ) : mixed | WP_Error
$post_id integer
$s3object array
$expires null | integer
$size null | string | array
$meta null | array
$headers array
Résultat mixed | WP_Error

get_attachment_url() public méthode

Get the url of the file from Amazon S3
public get_attachment_url ( integer $post_id, integer | null $expires = null, string | null $size = null, array | null $meta = null, array $headers = [], boolean $skip_rewrite_check = false ) : boolean | mixed | void | WP_Error
$post_id integer Post ID of the attachment
$expires integer | null Seconds for the link to live
$size string | null Size of the image to get
$meta array | null Pre retrieved _wp_attachment_metadata for the attachment
$headers array Header overrides for request
$skip_rewrite_check boolean Always return the URL regardless of the 'Rewrite File URLs' setting. Useful for the EDD and Woo addons to not break download URLs when the option is disabled.
Résultat boolean | mixed | void | WP_Error

get_aws_regions() public méthode

Get all AWS regions
public get_aws_regions ( ) : array
Résultat array

get_blog_ids() public méthode

Get all the blog IDs for the multisite network used for table prefixes
public get_blog_ids ( ) : false | array
Résultat false | array

get_bucket_region() public méthode

Get the region of a bucket
public get_bucket_region ( string $bucket ) : string | WP_Error
$bucket string
Résultat string | WP_Error

get_buckets() public méthode

Get a list of buckets from S3
public get_buckets ( ) : array | WP_Error
Résultat array | WP_Error - list of buckets

get_default_object_prefix() public méthode

Return the default object prefix
public get_default_object_prefix ( ) : string
Résultat string

get_dynamic_prefix() public méthode

Get the prefix path for the files. Ignores WP media library year month subdirectory setting and just uses S3 setting
public get_dynamic_prefix ( string $time = null ) : string
$time string
Résultat string

get_file_prefix() public méthode

Get the file prefix
public get_file_prefix ( null | string $time = null ) : string
$time null | string
Résultat string

get_folder_time_from_url() public méthode

Get the upload folder time from given URL
public get_folder_time_from_url ( string $url ) : null | string
$url string
Résultat null | string

get_formatted_s3_info() public méthode

Return a formatted S3 info with display friendly defaults
public get_formatted_s3_info ( integer $id, array | null $s3object = null ) : array
$id integer
$s3object array | null
Résultat array

get_image_sizes_details() public méthode

Output image size names and dimensions to a string
public get_image_sizes_details ( ) : string
Résultat string

get_local_url_preview() protected méthode

Get local URL preview.
protected get_local_url_preview ( boolean $escape = true, string $suffix = 'photo.jpg' ) : string
$escape boolean
$suffix string
Résultat string

get_media_action_strings() public méthode

Get all strings or a specific string used for the media actions
public get_media_action_strings ( null | string $string = null ) : array | string
$string null | string
Résultat array | string

get_memory_limit() public méthode

Get memory limit
public get_memory_limit ( ) : integer
Résultat integer

get_mime_types_to_gzip() protected méthode

Get mime types to gzip
protected get_mime_types_to_gzip ( boolean $media_library = false ) : array
$media_library boolean
Résultat array

get_object_prefix() public méthode

Get the custom object prefix if enabled
public get_object_prefix ( string $toggle_setting = 'enable-object-prefix' ) : string
$toggle_setting string
Résultat string

get_object_version_string() public méthode

Get the object versioning string prefix
public get_object_version_string ( ) : string
Résultat string

get_plugin_details() public méthode

Helper to display plugin details
public get_plugin_details ( string $plugin_path, string $suffix = '' ) : string
$plugin_path string
$suffix string
Résultat string

get_plugin_page_title() public méthode

Get the plugin title to be used in page headings
public get_plugin_page_title ( ) : string
Résultat string

get_plugin_page_url() public méthode

Helper method to return the settings page URL for the plugin
public get_plugin_page_url ( array $args = [], string $url_method = 'network', boolean $escape = true ) : string
$args array
$url_method string To prepend to admin_url()
$escape boolean Should we escape the URL
Résultat string

get_plugin_prefix_slug() public méthode

Get the plugin prefix in slug format, ie. replace underscores with hyphens
public get_plugin_prefix_slug ( ) : string
Résultat string

get_post_time() public méthode

Get post time
public get_post_time ( integer $post_id ) : string
$post_id integer
Résultat string

get_s3_url_domain() public méthode

Get the S3 url for the files
public get_s3_url_domain ( string $bucket, string $region = '', integer $expires = null, array $args = [], boolean $preview = false ) : mixed | string | void
$bucket string
$region string
$expires integer
$args array Allows you to specify custom URL settings
$preview boolean When generating the URL preview sanitize certain output
Résultat mixed | string | void

get_s3_url_prefix() public méthode

Get the region specific prefix for S3 URL
public get_s3_url_prefix ( string $region = '', null | integer $expires = null ) : string
$region string
$expires null | integer
Résultat string

get_s3_url_scheme() public méthode

Return the scheme to be used in URLs
public get_s3_url_scheme ( boolean | null $use_ssl = null ) : string
$use_ssl boolean | null
Résultat string

get_s3client() public méthode

Get the S3 client
public get_s3client ( boolean | string $region = false, boolean $force = false ) : Aws\S3\S3Client
$region boolean | string specify region to client for signature
$force boolean force return of new S3 client when swapping regions
Résultat Aws\S3\S3Client

get_s3object_region() public méthode

Get the region of the bucket stored in the S3 metadata.
public get_s3object_region ( array $s3object, integer $post_id = null ) : string | WP_Error
$s3object array
$post_id integer - if supplied will update the s3 meta if no region found
Résultat string | WP_Error - region name

get_secure_attachment_url() public méthode

Generate a link to download a file from Amazon S3 using query string authentication. This link is only valid for a limited amount of time.
public get_secure_attachment_url ( integer $post_id, integer | null $expires = null, string | null $size = null, array $headers = [], boolean $skip_rewrite_check = false ) : mixed | void | WP_Error
$post_id integer Post ID of the attachment
$expires integer | null Seconds for the link to live
$size string | null Size of the image to get
$headers array Header overrides for request
$skip_rewrite_check boolean
Résultat mixed | void | WP_Error

get_setting() public méthode

Accessor for a plugin setting with conditions to defaults and upgrades
public get_setting ( string $key, mixed $default = '' ) : integer | mixed | string | WP_Error
$key string
$default mixed
Résultat integer | mixed | string | WP_Error

get_setting_args() public méthode

Gets arguements used to render a setting view.
public get_setting_args ( string $key ) : array
$key string
Résultat array

get_setting_bucket() public méthode

Get the bucket and if a constant save to database and clear region
public get_setting_bucket ( string $key, string $value, string $constant = 'AS3CF_BUCKET' ) : string | false
$key string
$value string
$constant string
Résultat string | false

get_setting_region() public méthode

Get the region setting
public get_setting_region ( array $settings, string $key, mixed $default ) : boolean | string | WP_Error
$settings array
$key string
$default mixed
Résultat boolean | string | WP_Error

get_settings_nonce_key() public méthode

Get the nonce key for the settings form of the plugin
public get_settings_nonce_key ( ) : string
Résultat string

get_settings_tabs() public méthode

Get the tabs available for the plugin settings page
public get_settings_tabs ( ) : array
Résultat array

get_settings_whitelist() public méthode

Whitelist of settings allowed to be saved
public get_settings_whitelist ( ) : array
Résultat array

get_skip_sanitize_settings() public méthode

List of settings that should skip full sanitize.
public get_skip_sanitize_settings ( ) : array
Résultat array

get_url_preview() public méthode

Generate a preview of the URL of files uploaded to S3
public get_url_preview ( boolean $escape = true, string $suffix = 'photo.jpg' ) : string
$escape boolean
$suffix string
Résultat string

get_year_month_directory_name() public méthode

Generate the year and month sub-directory from $time if provided, then POST time if available, otherwise use current time
public get_year_month_directory_name ( string $time = null ) : string
$time string
Résultat string

handle_post_request() public méthode

Handle the saving of the settings page
public handle_post_request ( )

http_prepare_download_log() public méthode

Check for as3cf-download-log and related nonce and if found begin the download of the diagnostic log
public http_prepare_download_log ( ) : void
Résultat void

imagick_enabled() public méthode

Detect is Imagick is enabled
public imagick_enabled ( ) : boolean
Résultat boolean

init() public méthode

Abstract class constructor
public init ( string $plugin_file_path )
$plugin_file_path string

is_attachment_served_by_s3() public méthode

Is attachment served by S3.
public is_attachment_served_by_s3 ( integer $attachment_id, boolean $skip_rewrite_check = false ) : boolean | array
$attachment_id integer
$skip_rewrite_check boolean
Résultat boolean | array

is_current_blog() public méthode

Is the current blog ID that specified in wp-config.php
public is_current_blog ( integer $blog_id ) : boolean
$blog_id integer
Résultat boolean

is_plugin_setup() public méthode

Check the plugin is correctly setup
public is_plugin_setup ( ) : boolean
Résultat boolean

is_pro() public méthode

Check whether the pro addon is installed.
public is_pro ( ) : boolean
Résultat boolean

load_attachment_assets() public méthode

Load the attachment assets only when editing an attachment
public load_attachment_assets ( $hook_suffix )
$hook_suffix

load_media_assets() public méthode

Load media assets.
public load_media_assets ( )

make_acl_admin_notice() public méthode

Make admin notice for when object ACL has changed
public make_acl_admin_notice ( array $s3object )
$s3object array

maybe_convert_size_to_string() protected méthode

Maybe convert size to string
protected maybe_convert_size_to_string ( integer $attachment_id, mixed $size ) : null | string
$attachment_id integer
$size mixed
Résultat null | string

maybe_disable_save_button() public méthode

Disables the save button if all settings have been defined.
public maybe_disable_save_button ( string $defined_settings = [] ) : string
$defined_settings string
Résultat string

maybe_display_deprecated_http_notice() protected méthode

Display a notice if using setting to force HTTP as url scheme, removed in 1.3.

maybe_encode_get_image_tag() public méthode

Maybe encode attachment URLs when retrieving the image tag
public maybe_encode_get_image_tag ( string $html, integer $id, string $alt, string $title, string $align, string $size ) : string
$html string
$id integer
$alt string
$title string
$align string
$size string
Résultat string

maybe_encode_image_get_intermediate_size() public méthode

Maybe encode URLs when retrieving intermediate sizes.
public maybe_encode_image_get_intermediate_size ( array $data, integer $post_id, string | array $size ) : array
$data array
$post_id integer
$size string | array
Résultat array

maybe_encode_wp_get_attachment_image_src() public méthode

Maybe encode URLs for images that represent an attachment
public maybe_encode_wp_get_attachment_image_src ( array | boolean $image, integer $attachment_id, string | array $size, boolean $icon ) : array
$image array | boolean
$attachment_id integer
$size string | array
$icon boolean
Résultat array

maybe_encode_wp_prepare_attachment_for_js() public méthode

Maybe encode URLs when outputting attachments in the media grid
public maybe_encode_wp_prepare_attachment_for_js ( array $response, integer | object $attachment, array $meta ) : array
$response array
$attachment integer | object
$meta array
Résultat array

maybe_remove_query_string() public méthode

Maybe remove query string from URL.
public maybe_remove_query_string ( string $url ) : string
$url string
Résultat string

maybe_sign_intermediate_size() protected méthode

Sign intermediate size.
protected maybe_sign_intermediate_size ( string $url, integer $attachment_id, string | array $size, boolean | array $s3object = false ) : mixed | WP_Error
$url string
$attachment_id integer
$size string | array
$s3object boolean | array
Résultat mixed | WP_Error

maybe_update_cloudfront_path() public méthode

Potentially update path for CloudFront URLs.
public maybe_update_cloudfront_path ( string $path ) : string
$path string
Résultat string

memory_exceeded() public méthode

Ensures the a process never exceeds 90% of the maximum WordPress memory.
public memory_exceeded ( null | string $filter_name = null ) : boolean
$filter_name null | string Name of filter to apply to the return
Résultat boolean

multisite_get_spaced_used() public méthode

Used to give a realistic total of storage space used on a Multisite subsite, when there have been attachments uploaded to S3 but removed from server
public multisite_get_spaced_used ( $space_used ) : float | integer
$space_used bool
Résultat float | integer

normalize_object_prefix() protected méthode

Normalize object prefix.
protected normalize_object_prefix ( string $prefix ) : string
$prefix string
Résultat string

on_off() public méthode

Helper for displaying settings
public on_off ( string $key ) : string
$key string setting key
Résultat string

open_ssl_enabled() public méthode

Detect if OpenSSL is enabled
public open_ssl_enabled ( ) : boolean
Résultat boolean

output_diagnostic_info() public méthode

Diagnostic information for the support tab
public output_diagnostic_info ( boolean $escape = true ) : string
$escape boolean
Résultat string

plugin_deactivated_notice() public méthode

Display a notice after either lite or pro plugin has been auto deactivated

plugin_load() public méthode

public plugin_load ( )

pre_set_setting() public méthode

Perform custom actions before the setting is saved
public pre_set_setting ( string $key, string $value )
$key string
$value string

prepare_bucket_error() public méthode

Prepare the bucket error before returning to JS
public prepare_bucket_error ( WP_Error $object, boolean $single = true ) : array
$object WP_Error
$single boolean Are we dealing with a single bucket?
Résultat array

register_modal_assets() public méthode

Register modal scripts and styles so they can be enqueued later

remove_attachment_files_from_s3() public méthode

Removes an attachment's files from S3.
public remove_attachment_files_from_s3 ( integer $post_id, array $s3object, boolean $remove_backup_sizes = true, boolean $log_error = false, boolean $return_on_error = false, boolean $force_new_s3_client = false )
$post_id integer
$s3object array
$remove_backup_sizes boolean remove previous edited image versions
$log_error boolean
$return_on_error boolean
$force_new_s3_client boolean if we are deleting in bulk, force new S3 client to cope with possible different regions

remove_local_files() public méthode

Remove files from the local site
public remove_local_files ( array $file_paths )
$file_paths array array of files to remove

remove_scheme() public méthode

Remove scheme from URL.
public remove_scheme ( string $url ) : string
$url string
Résultat string

remove_size_from_filename() public méthode

Remove size from filename (image[-100x100].jpeg).
public remove_size_from_filename ( string $url, boolean $remove_extension = false ) : string
$url string
$remove_extension boolean
Résultat string

remove_wp_plugin_dir() public méthode

Helper to remove the plugin directory from the plugin path
public remove_wp_plugin_dir ( string $path ) : string
$path string
Résultat string

render_bucket_permission_errors() public méthode

Render error messages in a view for bucket permission and access issues

render_page() public méthode

Display the main settings page for the plugin
public render_page ( )

restore_current_blog() public méthode

Helper to restore to the current Multisite blog

return_upload_error() protected méthode

Helper to return meta data on upload error
protected return_upload_error ( string $error_msg, array | null $return = null ) : array | WP_Error
$error_msg string
$return array | null
Résultat array | WP_Error

sanitize_custom_domain() public méthode

Sanitize custom domain
public sanitize_custom_domain ( string $domain ) : string
$domain string
Résultat string

save_bucket() public méthode

Save bucket and bucket's region
public save_bucket ( string $bucket_name, boolean $manual = false, null | string $region = null ) : string | boolean
$bucket_name string
$manual boolean if we are entering the bucket via the manual input form
$region null | string
Résultat string | boolean region on success

save_bucket_for_ajax() public méthode

Wrapper method for saving a bucket when creating or selecting
public save_bucket_for_ajax ( string $bucket, boolean | false $manual_select = false, null | string $region = null, array $defaults = [] )
$bucket string
$manual_select boolean | false
$region null | string
$defaults array

schedule_event() public méthode

Wrapper for scheduling cron jobs
public schedule_event ( string $hook, null | string $interval = null, array $args = [] )
$hook string
$interval null | string Defaults to hook if not supplied
$args array

set_attachment_acl_on_s3() public méthode

Apply ACL to an attachment and associated files
public set_attachment_acl_on_s3 ( integer $post_id, array $s3object, string $acl ) : array | boolean | WP_Error
$post_id integer
$s3object array
$acl string
Résultat array | boolean | WP_Error

set_client() public méthode

Setter for S3 client
public set_client ( Aws\S3\S3Client $client )
$client Aws\S3\S3Client

set_setting() public méthode

Setter for a plugin setting with custom hooks
public set_setting ( string $key, mixed $value )
$key string
$value mixed

should_gzip_file() protected méthode

Should gzip file
protected should_gzip_file ( string $file_path, string $type ) : boolean
$file_path string
$type string
Résultat boolean

show_deprecated_domain_setting() public méthode

Show the deprecated Domain option setting?
public show_deprecated_domain_setting ( null | string $domain = null ) : boolean
$domain null | string
Résultat boolean

switch_to_blog() public méthode

Helper to switch to a Multisite blog - If the site is MS - If the blog is not the current blog defined
public switch_to_blog ( integer | boolean $blog_id = false )
$blog_id integer | boolean

translate_region() public méthode

Translate older bucket locations to newer S3 region names http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
public translate_region ( $region ) : string
$region
Résultat string

update_attached_file() public méthode

Allow processes to update the file on S3 via update_attached_file()
public update_attached_file ( string $file, integer $attachment_id ) : string
$file string
$attachment_id integer
Résultat string

update_site_option() public méthode

Update site option.
public update_site_option ( string $option, mixed $value, boolean $autoload = true ) : boolean
$option string
$value mixed
$autoload boolean
Résultat boolean

upgrade_virtual_host() public méthode

Upgrade the 'virtual host' / 'bucket as domain' setting to the new CloudFront / Domain setting
public upgrade_virtual_host ( ) : string
Résultat string

upload_attachment_to_s3() public méthode

Upload attachment to S3
public upload_attachment_to_s3 ( integer $post_id, array | null $data = null, string | null $file_path = null, boolean $force_new_s3_client = false, boolean $remove_local_files = true ) : array | WP_Error
$post_id integer
$data array | null
$file_path string | null
$force_new_s3_client boolean if we are uploading in bulk, force new S3 client to cope with possible different regions
$remove_local_files boolean
Résultat array | WP_Error $s3object|$meta If meta is supplied, return it. Else return S3 meta

use_ssl() public méthode

Determine when to use https in URLS
public use_ssl ( boolean | null $use_ssl = null ) : boolean
$use_ssl boolean | null
Résultat boolean

verify_ajax_request() public méthode

public verify_ajax_request ( )

verify_media_actions() public méthode

Check we can do the media actions
public verify_media_actions ( ) : boolean
Résultat boolean

wp_get_attachment_url() public méthode

Get attachment url
public wp_get_attachment_url ( string $url, integer $post_id ) : boolean | mixed | void | WP_Error
$url string
$post_id integer
Résultat boolean | mixed | void | WP_Error

wp_handle_upload_prefilter() public méthode

Create unique names for file to be uploaded to AWS This only applies when the remove local file option is enabled
public wp_handle_upload_prefilter ( array $file ) : array
$file array An array of data for a single file.
Résultat array $file The altered file array with AWS unique filename.

wp_update_attachment_metadata() public méthode

Handles the upload of the attachment to S3 when an attachment is updated using the 'wp_update_attachment_metadata' filter
public wp_update_attachment_metadata ( array $data, integer $post_id ) : array
$data array meta data for attachment
$post_id integer
Résultat array

Property Details

$admin_notices protected_oe static_oe property

protected static array $admin_notices
Résultat array

$buckets_check protected_oe static_oe property

Store if each bucket, used by the plugin and addons, is writable
protected static $buckets_check

$default_tab protected_oe property

protected string $default_tab
Résultat string

$filter_local public_oe property

public AS3CF_Local_To_S3 $filter_local
Résultat AS3CF_Local_To_S3

$filter_s3 public_oe property

public AS3CF_S3_To_Local $filter_s3
Résultat AS3CF_S3_To_Local

$hook_suffix public_oe property

public string $hook_suffix
Résultat string

$notices public_oe property

public AS3CF_Notices $notices
Résultat AS3CF_Notices

$plugin_compat public_oe property

public AS3CF_Plugin_Compatibility $plugin_compat
Résultat AS3CF_Plugin_Compatibility

$plugin_menu_title protected_oe property

protected string $plugin_menu_title
Résultat string

$plugin_page protected_oe static_oe property

protected static $plugin_page

$plugin_prefix protected_oe property

protected string $plugin_prefix
Résultat string

$plugin_title protected_oe property

protected string $plugin_title
Résultat string