Modifying Offload Media code in Wordpress

Hi - I am brand new to PHP and am trying to modify a small bit of code for the Offload Media plugin. The aim is to stop any media which has the work KEEP or KEEP. in its filename from being offloaded.

I have spent all day trying various methods and none work, although I am told it is possible easily. Any advise as to whats wrong with my code will be appreciated. This is the code snippet Offload Media says should do the job, which I have modified slightly.

function pre_upload_attachment( $abort, $post_id, $metadata ) {
			$file      = get_post_meta( $post_id, '_wp_attached_file', true );
	$filename = is_string( $file ) ? pathinfo( $file, PATHINFO_FILENAME ) : false;
	if ( is_string( $filename ) && in_array( $filename, array( 'KEEP' ) ) ) {
		$abort = true;
	}

First thing I would do, have the function just do the abort false statement. See if that prevents it. If it does then start testing out how to limit it to exclude that in the filename.

Sponsor our Newsletter | Privacy Policy | Terms of Service