Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #15 from jaredcobb/1.0.6
Browse files Browse the repository at this point in the history
Dynamically load admin libraries in cron context
  • Loading branch information
jaredcobb committed Jun 14, 2018
2 parents e200eec + 12db67f commit ecc5312
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions includes/class-ccb-core-helpers.php
Expand Up @@ -207,6 +207,14 @@ public function send_non_blocking_json_success( $data = [] ) {
*/
public function download_image( $image_url, $filename = '', $post_id = 0 ) {

// When in a WP Cron context these helper functions may not be loaded.
if ( ! function_exists( 'download_url' ) ) {
include_once ABSPATH . 'wp-admin/includes/file.php';
}
if ( ! function_exists( 'media_handle_sideload' ) ) {
include_once ABSPATH . 'wp-admin/includes/media.php';
}

// Fetch the image and store temporarily.
$temp_file = download_url( $image_url );

Expand Down

0 comments on commit ecc5312

Please sign in to comment.