Extra “uploads” added in path

Resolved in a completely different way. Googled this, so technically not my own answer, but does the job: // ACF upload prefilter function gist_acf_upload_dir_prefilter($errors, $file, $field) { // This filter changes directory just for item being uploaded add_filter(‘upload_dir’, ‘gist_acf_upload_dir’); } // ACF hook, set to field key of your file upload field add_filter(‘acf/upload_prefilter/key=field_5b2b0326ea0e1’, ‘gist_acf_upload_dir_prefilter’); // … Read more

Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically

You can use sanitize_file_name hook for this. function my_sanitize_file_name( $filename ) { $chars_table = array( ‘ ‘ => ‘_’, ‘-‘ => ‘_’, ); $friendly_filename = preg_replace( array_keys( $chars_table ), array_values( $chars_table ), $filename ); return strtolower( $friendly_filename ); } add_filter( ‘sanitize_file_name’, ‘my_sanitize_file_name’, 10 ); It will also convert letters to lowercase to avoid conflicts on … Read more

Remove upload file types filter for admin

This is example for only doc file for admin. You are also add another file to avoid restriction for admin. add_filter( ‘wp_check_filetype_and_ext’, ‘file_and_ext_allow_for_user’, 10, 4 ); function file_and_ext_allow_for_user( $types, $file, $filename, $mimes ) { if( is_admin() ){ if( false !== strpos( $filename, ‘.doc’ ) ) { $types[‘ext’] = ‘doc’; $types[‘type’] = ‘application/msword’; } } return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)