PHP Класс Amazon_S3_And_CloudFront, wp-amazon-s3-and-cloudfront

Наследование: extends AWS_Plugin_Base
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$filter_local AS3CF_Local_To_S3
$filter_s3 AS3CF_S3_To_Local
$hook_suffix string
$notices AS3CF_Notices
$plugin_compat AS3CF_Plugin_Compatibility

Защищенные свойства (Protected)

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
more_info_campaign_url ( string $url ) : string Create a More Info campaign url for given url.

Описание методов

__construct() публичный Метод

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() публичный Метод

Helper function for terminating script execution. Easily testable.
public _exit ( integer | string $exit_code ) : void
$exit_code integer | string
Результат void

_throw_error() публичный Метод

Throw error
public _throw_error ( string $code, string $message = '', mixed $data = '' ) : WP_Error
$code string
$message string
$data mixed
Результат WP_Error

add_media_row_actions() публичный Метод

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
Результат array

admin_menu() публичный Метод

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

ajax_check_bucket() публичный Метод

public ajax_check_bucket ( )

ajax_create_bucket() публичный Метод

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

ajax_get_attachment_s3_details() публичный Метод

Handle retieving the S3 details for attachment modals.

ajax_get_buckets() публичный Метод

AJAX handler for get_buckets()
public ajax_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
public ajax_save_bucket ( )

apply_file_suffix() публичный Метод

Helper to apply a suffix to a file path
public apply_file_suffix ( string $file, string $suffix ) : string
$file string
$suffix string
Результат string

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() публичный Метод

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
Результат boolean | WP_Error

clear_scheduled_event() публичный Метод

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

convert_dimensions_to_size_name() защищенный Метод

Convert dimensions to size
protected convert_dimensions_to_size_name ( integer $attachment_id, array $dimensions ) : null | string
$attachment_id integer
$dimensions array
Результат null | string

count_attachments() публичный Метод

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
Результат integer

create_bucket() публичный Метод

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
Результат boolean | WP_Error

decode_filename_in_path() публичный Метод

Decode file name.
public decode_filename_in_path ( string $file ) : string
$file string
Результат string

delete_attachment() публичный Метод

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() публичный Метод

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
Результат boolean

diagnostic_media_counts() защищенный Метод

Get the total attachment and total S3 attachment counts for the diagnostic log
protected diagnostic_media_counts ( ) : array
Результат array

does_file_exist() публичный Метод

Does file exist
public does_file_exist ( string $filename, string $time ) : boolean
$filename string
$time string
Результат boolean

does_file_exist_local() публичный Метод

Does file exist local
public does_file_exist_local ( string $filename, string $time ) : boolean
$filename string
$time string
Результат boolean

does_file_exist_s3() публичный Метод

Does file exist s3
public does_file_exist_s3 ( string $filename, string $time ) : boolean
$filename string
$time string
Результат boolean

encode_filename_in_path() публичный Метод

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
Результат string Encoded filename

end_ajax() публичный Метод

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

filter_input() публичный Метод

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
Результат mixed

filter_settings() публичный Метод

Filter in defined settings with sensible defaults.
public filter_settings ( array $settings ) : array
$settings array
Результат array $settings

gd_enabled() публичный Метод

Detect if PHP GD is enabled
public gd_enabled ( ) : boolean
Результат boolean

generate_unique_filename() публичный Метод

Generate unique filename
public generate_unique_filename ( string $name, string $ext, string $time ) : string
$name string
$ext string
$time string
Результат string

get_access_denied_notice_message() публичный Метод

Get the access denied bucket error notice message
public get_access_denied_notice_message ( boolean $single = true ) : string
$single boolean
Результат string

get_acl_display_name() публичный Метод

Return human friendly ACL name
public get_acl_display_name ( string $acl ) : string
$acl string
Результат string

get_acl_value_string() защищенный Метод

Get ACL value string.
protected get_acl_value_string ( array $acl ) : string
$acl array
Результат string

get_all_blog_table_prefixes() публичный Метод

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
Результат array associative array with blog ID as key, prefix as value

get_allowed_mime_types() публичный Метод

Allowed mime types array that can be edited for specific S3 uploading
public get_allowed_mime_types ( ) : array
Результат array

get_attached_file() публичный Метод

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
Результат string

get_attachment_file_paths() публичный Метод

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
Результат array

get_attachment_folder_time() публичный Метод

Use post datetime if attached.
public get_attachment_folder_time ( integer $post_id ) : integer | string
$post_id integer
Результат integer | string

get_attachment_local_url() публичный Метод

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
Результат string | false Attachment URL, otherwise false.

get_attachment_local_url_size() публичный Метод

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
Результат false | string

get_attachment_s3_info() публичный Метод

Get attachment s3 info
public get_attachment_s3_info ( integer $post_id ) : mixed
$post_id integer
Результат mixed

get_attachment_s3_url() публичный Метод

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
Результат mixed | WP_Error

get_attachment_url() публичный Метод

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.
Результат boolean | mixed | void | WP_Error

get_aws_regions() публичный Метод

Get all AWS regions
public get_aws_regions ( ) : array
Результат array

get_blog_ids() публичный Метод

Get all the blog IDs for the multisite network used for table prefixes
public get_blog_ids ( ) : false | array
Результат false | array

get_bucket_region() публичный Метод

Get the region of a bucket
public get_bucket_region ( string $bucket ) : string | WP_Error
$bucket string
Результат string | WP_Error

get_buckets() публичный Метод

Get a list of buckets from S3
public get_buckets ( ) : array | WP_Error
Результат array | WP_Error - list of buckets

get_default_object_prefix() публичный Метод

Return the default object prefix
public get_default_object_prefix ( ) : string
Результат string

get_dynamic_prefix() публичный Метод

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
Результат string

get_file_prefix() публичный Метод

Get the file prefix
public get_file_prefix ( null | string $time = null ) : string
$time null | string
Результат string

get_folder_time_from_url() публичный Метод

Get the upload folder time from given URL
public get_folder_time_from_url ( string $url ) : null | string
$url string
Результат null | string

get_formatted_s3_info() публичный Метод

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
Результат array

get_image_sizes_details() публичный Метод

Output image size names and dimensions to a string
public get_image_sizes_details ( ) : string
Результат string

get_local_url_preview() защищенный Метод

Get local URL preview.
protected get_local_url_preview ( boolean $escape = true, string $suffix = 'photo.jpg' ) : string
$escape boolean
$suffix string
Результат string

get_media_action_strings() публичный Метод

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
Результат array | string

get_memory_limit() публичный Метод

Get memory limit
public get_memory_limit ( ) : integer
Результат integer

get_mime_types_to_gzip() защищенный Метод

Get mime types to gzip
protected get_mime_types_to_gzip ( boolean $media_library = false ) : array
$media_library boolean
Результат array

get_object_prefix() публичный Метод

Get the custom object prefix if enabled
public get_object_prefix ( string $toggle_setting = 'enable-object-prefix' ) : string
$toggle_setting string
Результат string

get_object_version_string() публичный Метод

Get the object versioning string prefix
public get_object_version_string ( ) : string
Результат string

get_plugin_details() публичный Метод

Helper to display plugin details
public get_plugin_details ( string $plugin_path, string $suffix = '' ) : string
$plugin_path string
$suffix string
Результат string

get_plugin_page_title() публичный Метод

Get the plugin title to be used in page headings
public get_plugin_page_title ( ) : string
Результат string

get_plugin_page_url() публичный Метод

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
Результат string

get_plugin_prefix_slug() публичный Метод

Get the plugin prefix in slug format, ie. replace underscores with hyphens
public get_plugin_prefix_slug ( ) : string
Результат string

get_post_time() публичный Метод

Get post time
public get_post_time ( integer $post_id ) : string
$post_id integer
Результат string

get_s3_url_domain() публичный Метод

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
Результат mixed | string | void

get_s3_url_prefix() публичный Метод

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
Результат string

get_s3_url_scheme() публичный Метод

Return the scheme to be used in URLs
public get_s3_url_scheme ( boolean | null $use_ssl = null ) : string
$use_ssl boolean | null
Результат string

get_s3client() публичный Метод

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
Результат Aws\S3\S3Client

get_s3object_region() публичный Метод

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
Результат string | WP_Error - region name

get_secure_attachment_url() публичный Метод

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
Результат mixed | void | WP_Error

get_setting() публичный Метод

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
Результат integer | mixed | string | WP_Error

get_setting_args() публичный Метод

Gets arguements used to render a setting view.
public get_setting_args ( string $key ) : array
$key string
Результат array

get_setting_bucket() публичный Метод

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
Результат string | false

get_setting_region() публичный Метод

Get the region setting
public get_setting_region ( array $settings, string $key, mixed $default ) : boolean | string | WP_Error
$settings array
$key string
$default mixed
Результат boolean | string | WP_Error

get_settings_nonce_key() публичный Метод

Get the nonce key for the settings form of the plugin
public get_settings_nonce_key ( ) : string
Результат string

get_settings_tabs() публичный Метод

Get the tabs available for the plugin settings page
public get_settings_tabs ( ) : array
Результат array

get_settings_whitelist() публичный Метод

Whitelist of settings allowed to be saved
public get_settings_whitelist ( ) : array
Результат array

get_skip_sanitize_settings() публичный Метод

List of settings that should skip full sanitize.
public get_skip_sanitize_settings ( ) : array
Результат array

get_url_preview() публичный Метод

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
Результат string

get_year_month_directory_name() публичный Метод

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
Результат string

handle_post_request() публичный Метод

Handle the saving of the settings page
public handle_post_request ( )

http_prepare_download_log() публичный Метод

Check for as3cf-download-log and related nonce and if found begin the download of the diagnostic log
public http_prepare_download_log ( ) : void
Результат void

imagick_enabled() публичный Метод

Detect is Imagick is enabled
public imagick_enabled ( ) : boolean
Результат boolean

init() публичный Метод

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

is_attachment_served_by_s3() публичный Метод

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
Результат boolean | array

is_current_blog() публичный Метод

Is the current blog ID that specified in wp-config.php
public is_current_blog ( integer $blog_id ) : boolean
$blog_id integer
Результат boolean

is_plugin_setup() публичный Метод

Check the plugin is correctly setup
public is_plugin_setup ( ) : boolean
Результат boolean

is_pro() публичный Метод

Check whether the pro addon is installed.
public is_pro ( ) : boolean
Результат boolean

load_attachment_assets() публичный Метод

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

load_media_assets() публичный Метод

Load media assets.
public load_media_assets ( )

make_acl_admin_notice() публичный Метод

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

maybe_convert_size_to_string() защищенный Метод

Maybe convert size to string
protected maybe_convert_size_to_string ( integer $attachment_id, mixed $size ) : null | string
$attachment_id integer
$size mixed
Результат null | string

maybe_disable_save_button() публичный Метод

Disables the save button if all settings have been defined.
public maybe_disable_save_button ( string $defined_settings = [] ) : string
$defined_settings string
Результат string

maybe_display_deprecated_http_notice() защищенный Метод

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

maybe_encode_get_image_tag() публичный Метод

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
Результат string

maybe_encode_image_get_intermediate_size() публичный Метод

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
Результат array

maybe_encode_wp_get_attachment_image_src() публичный Метод

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
Результат array

maybe_encode_wp_prepare_attachment_for_js() публичный Метод

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
Результат array

maybe_remove_query_string() публичный Метод

Maybe remove query string from URL.
public maybe_remove_query_string ( string $url ) : string
$url string
Результат string

maybe_sign_intermediate_size() защищенный Метод

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
Результат mixed | WP_Error

maybe_update_cloudfront_path() публичный Метод

Potentially update path for CloudFront URLs.
public maybe_update_cloudfront_path ( string $path ) : string
$path string
Результат string

memory_exceeded() публичный Метод

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
Результат boolean

multisite_get_spaced_used() публичный Метод

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
Результат float | integer

normalize_object_prefix() защищенный Метод

Normalize object prefix.
protected normalize_object_prefix ( string $prefix ) : string
$prefix string
Результат string

on_off() публичный Метод

Helper for displaying settings
public on_off ( string $key ) : string
$key string setting key
Результат string

open_ssl_enabled() публичный Метод

Detect if OpenSSL is enabled
public open_ssl_enabled ( ) : boolean
Результат boolean

output_diagnostic_info() публичный Метод

Diagnostic information for the support tab
public output_diagnostic_info ( boolean $escape = true ) : string
$escape boolean
Результат string

plugin_deactivated_notice() публичный Метод

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

plugin_load() публичный Метод

public plugin_load ( )

pre_set_setting() публичный Метод

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

prepare_bucket_error() публичный Метод

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?
Результат array

register_modal_assets() публичный Метод

Register modal scripts and styles so they can be enqueued later

remove_attachment_files_from_s3() публичный Метод

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() публичный Метод

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

remove_scheme() публичный Метод

Remove scheme from URL.
public remove_scheme ( string $url ) : string
$url string
Результат string

remove_size_from_filename() публичный Метод

Remove size from filename (image[-100x100].jpeg).
public remove_size_from_filename ( string $url, boolean $remove_extension = false ) : string
$url string
$remove_extension boolean
Результат string

remove_wp_plugin_dir() публичный Метод

Helper to remove the plugin directory from the plugin path
public remove_wp_plugin_dir ( string $path ) : string
$path string
Результат string

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
public render_page ( )

restore_current_blog() публичный Метод

Helper to restore to the current Multisite blog

return_upload_error() защищенный Метод

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
Результат array | WP_Error

sanitize_custom_domain() публичный Метод

Sanitize custom domain
public sanitize_custom_domain ( string $domain ) : string
$domain string
Результат string

save_bucket() публичный Метод

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
Результат string | boolean region on success

save_bucket_for_ajax() публичный Метод

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() публичный Метод

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() публичный Метод

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
Результат array | boolean | WP_Error

set_client() публичный Метод

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

set_setting() публичный Метод

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

should_gzip_file() защищенный Метод

Should gzip file
protected should_gzip_file ( string $file_path, string $type ) : boolean
$file_path string
$type string
Результат boolean

show_deprecated_domain_setting() публичный Метод

Show the deprecated Domain option setting?
public show_deprecated_domain_setting ( null | string $domain = null ) : boolean
$domain null | string
Результат boolean

switch_to_blog() публичный Метод

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() публичный Метод

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
Результат string

update_attached_file() публичный Метод

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
Результат string

update_site_option() публичный Метод

Update site option.
public update_site_option ( string $option, mixed $value, boolean $autoload = true ) : boolean
$option string
$value mixed
$autoload boolean
Результат boolean

upgrade_virtual_host() публичный Метод

Upgrade the 'virtual host' / 'bucket as domain' setting to the new CloudFront / Domain setting
public upgrade_virtual_host ( ) : string
Результат string

upload_attachment_to_s3() публичный Метод

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
Результат array | WP_Error $s3object|$meta If meta is supplied, return it. Else return S3 meta

use_ssl() публичный Метод

Determine when to use https in URLS
public use_ssl ( boolean | null $use_ssl = null ) : boolean
$use_ssl boolean | null
Результат boolean

verify_ajax_request() публичный Метод

public verify_ajax_request ( )

verify_media_actions() публичный Метод

Check we can do the media actions
public verify_media_actions ( ) : boolean
Результат boolean

wp_get_attachment_url() публичный Метод

Get attachment url
public wp_get_attachment_url ( string $url, integer $post_id ) : boolean | mixed | void | WP_Error
$url string
$post_id integer
Результат boolean | mixed | void | WP_Error

wp_handle_upload_prefilter() публичный Метод

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.
Результат array $file The altered file array with AWS unique filename.

wp_update_attachment_metadata() публичный Метод

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
Результат array

Описание свойств

$admin_notices защищенное статическое свойство

protected static array $admin_notices
Результат array

$buckets_check защищенное статическое свойство

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

$default_tab защищенное свойство

protected string $default_tab
Результат string

$filter_local публичное свойство

public AS3CF_Local_To_S3 $filter_local
Результат AS3CF_Local_To_S3

$filter_s3 публичное свойство

public AS3CF_S3_To_Local $filter_s3
Результат AS3CF_S3_To_Local

$hook_suffix публичное свойство

public string $hook_suffix
Результат string

$notices публичное свойство

public AS3CF_Notices $notices
Результат AS3CF_Notices

$plugin_compat публичное свойство

public AS3CF_Plugin_Compatibility $plugin_compat
Результат AS3CF_Plugin_Compatibility

$plugin_menu_title защищенное свойство

protected string $plugin_menu_title
Результат string

$plugin_page защищенное статическое свойство

protected static $plugin_page

$plugin_prefix защищенное свойство

protected string $plugin_prefix
Результат string

$plugin_title защищенное свойство

protected string $plugin_title
Результат string