Tuesday, August 2, 2022
HomeWordPress Developmenthooks - Is there any cause for the nested filters to be...

hooks – Is there any cause for the nested filters to be utilized on the primary case and never in the second?


// This Works -> Filters are utilized

add_action( 'current_screen', operate(){
    $kind = get_current_screen()->post_type;
    
    if(is_admin()){ // "true"
        add_filter('upload_dir', operate($uploads){
            $uploads['path'] = $uploads['basedir'] . "/ordenanzas";
            $uploads['url'] = $uploads['baseurl'] . "/ordenanzas";
            return $uploads;
        });
        add_filter('wp_handle_upload_prefilter', operate($file){       
            $file['name'] = "ORD-" . $file['name'];
            return $file;
        });
    }
});

// This Would not Works -> Filters aren’t utilized

add_action( 'current_screen', operate(){
    $kind = get_current_screen()->post_type;
    
    if(is_admin() && $kind == 'ordenanzas'){ // when is "true" filters don't work
        add_filter('upload_dir', operate($uploads){
            $uploads['path'] = $uploads['basedir'] . "/ordenanzas";
            $uploads['url'] = $uploads['baseurl'] . "/ordenanzas";
            return $uploads;
        });
        add_filter('wp_handle_upload_prefilter', operate($file){       
            $file['name'] = "ORD-" . $file['name'];
            return $file;
        });
    }
});

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments