Skip to content

Instantly share code, notes, and snippets.

@yahilmadakiya
Last active November 9, 2016 13:18
Show Gist options
  • Save yahilmadakiya/b25d331e53159a877da7140f05fe4dc0 to your computer and use it in GitHub Desktop.
Save yahilmadakiya/b25d331e53159a877da7140f05fe4dc0 to your computer and use it in GitHub Desktop.
Allows to upload particular filetypes in particular page using rtmedia_uploader source code
function rtmedia_media_uploader_attributes_shortcode( $attr ) {
global $rtmedia;
$allowed_media_type = $rtmedia->allowed_types;
/* page id */
$page_id = '95';
/* File extension */
$extn = 'doc';
if ( get_the_ID() == $page_id ) {
$extn = explode( ',', $extn );
if ( isset( $attr['media_type'] ) ) {
if ( isset( $allowed_media_type[ $attr['media_type'] ] ) ) {
$allowed_media_type[ $attr['media_type'] ]['extn'] = $extn;
wp_localize_script( 'rtmedia-backbone', 'rtmedia_upload_type_filter', $allowed_media_type[ $attr['media_type'] ]['extn'] );
}
}
}
return $attr;
}
add_filter( 'rtmedia_media_uploader_attributes', 'rtmedia_media_uploader_attributes_shortcode', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment