$production_site_url
$production_site_url : string
The url of the production system.
Provide information about and functions to interact with the environment in which this plugin is running.
Provide methods to obtain information about and functions to interact with the environment in which this plugin is running.
unique_filename_callback(string $dir, string $filename, string $ext)
Returns a filename that is unique in the given directory.
This fuction is based on wp_unique_filename() from https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/functions.php#L0 but it treats .tar.gz as a single extension.
string | $dir | Directory. |
string | $filename | Base Filename including the extension. |
string | $ext | Desired extension, e.g., '.txt', '.pdf', or '.tar.gz'. |
disable_real_mime_check_for_selected_extensions(array $data, string $file, string $filename, array $mimes) : array
Works around a bug in WP that disallows upload of files to the media library even if they are marked as allowed via the 'upload_mimes' filter.
To be added to the 'wp_check_filetype_and_ext' filter.
array | $data | File data array containing 'ext', 'type', and 'proper_filename' keys. |
string | $file | Full path to the file. |
string | $filename | The name of the file (may differ from $file due to $file being in a tmp directory). |
array | $mimes | Key is the file extension with value as the mime type. |
Values for the extension, MIME, and filename.
download_to_media_library(string $url, string $filename, string $extension, string $mime_type, integer $parent_post_id, integer $timeout_seconds = 40)
Download a file to the WordPress media library.
$mime_type and $extension are optional, if set to something empty() they are guessed form the download file, where the extension is guessed based on the mime type. If the mime type is provided and the downloaded file does not actually have that mime type, an error is returned.
string | $url | Url to download from. |
string | $filename | Fielname under which to save the download. |
string | $extension | Extension of the file under which to save the download. |
string | $mime_type | Expected mime type of the download. |
integer | $parent_post_id | Id of post to which to link the download. |
integer | $timeout_seconds | Timeout of the download. |
save_recursive_remove_dir(string $path, string $root)
Recursively remove a directory.
PHP itself does not offer a reasonable way to recursively remove directories. This is a subtle issue as links and nasty file names can be inlolved. We don't want to be hackble by uploading a malicious manuscript source to the arXiv, don't we? This is the best I could come up with after looking at many different implementations that can be found on the internet.
string | $path | Path to file/folder to delete. |
string | $root | Root folder to which to restric the deleting. |
file_get_contents_utf8(string $path)
PHP seems to have problems correctly detecting utf-8 encoding of some .tex files when they are read with the standard file_get_contents() functinon (is this expected?). The following has turned out to work in all cases I have tested.
string | $path | Path to the file to get. |
get_feature_image_path(integer $post_id)
Get the path of a feature image of a post
Returns the path of the feature image, insired by https://stackoverflow.com/questions/27306882/actual-file-location-of-a-wordpress-featured-image
integer | $post_id | Id of the post. |