Wildcard allow on upload types (not download types) #657

Closed
chriscct7 opened this Issue Dec 26, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@chriscct7
Member

chriscct7 commented Dec 26, 2012

I know why we have to list the download types, but on the allowed upload types can we not just feed a wildcard in to allow all upload types. Given we don't want to restrict what they can upload is this a viable option?

@pippinsplugins

This comment has been minimized.

Show comment
Hide comment
@pippinsplugins

pippinsplugins Dec 26, 2012

Member

I don't think WordPress permits a wildcard in that filter.

Member

pippinsplugins commented Dec 26, 2012

I don't think WordPress permits a wildcard in that filter.

@chriscct7

This comment has been minimized.

Show comment
Hide comment
@chriscct7

chriscct7 Dec 26, 2012

Member

I've got a better way I think:
Since we're making roles for the staff, we can use a different filter:

/*
* For WP's over 3.4
* For this, see: wp-includes/capabilities.php > map_meta_cap()
*/
function unrestricted_upload_filter($caps, $cap) {
  if ($cap == 'unfiltered_upload') {
    $caps = array();
    $caps[] = $cap;
  }

  return $caps;
}
add_filter('map_meta_cap', 'unrestricted_upload_filter', 0, 2);
/*
* For WP's under 3.4
*/
add_filter( 'user_has_cap', 'unfiltered_upload' );

function unfiltered_upload( $caps )
{
    $caps['unfiltered_upload'] = 1;
    return $caps;
}
Member

chriscct7 commented Dec 26, 2012

I've got a better way I think:
Since we're making roles for the staff, we can use a different filter:

/*
* For WP's over 3.4
* For this, see: wp-includes/capabilities.php > map_meta_cap()
*/
function unrestricted_upload_filter($caps, $cap) {
  if ($cap == 'unfiltered_upload') {
    $caps = array();
    $caps[] = $cap;
  }

  return $caps;
}
add_filter('map_meta_cap', 'unrestricted_upload_filter', 0, 2);
/*
* For WP's under 3.4
*/
add_filter( 'user_has_cap', 'unfiltered_upload' );

function unfiltered_upload( $caps )
{
    $caps['unfiltered_upload'] = 1;
    return $caps;
}
@chriscct7

This comment has been minimized.

Show comment
Hide comment
@chriscct7

chriscct7 Dec 26, 2012

Member

Double updated, source: WPSE

Member

chriscct7 commented Dec 26, 2012

Double updated, source: WPSE

@pippinsplugins

This comment has been minimized.

Show comment
Hide comment
@pippinsplugins

pippinsplugins Jan 24, 2013

Member

I don't like the idea of setting this capability globally, but setting it for the new EDD roles we're creating later in #604 sounds like a great idea. Since we're not doing the actual roles for another couple of releases, I'm pushing this back to 1.4.4.

Member

pippinsplugins commented Jan 24, 2013

I don't like the idea of setting this capability globally, but setting it for the new EDD roles we're creating later in #604 sounds like a great idea. Since we're not doing the actual roles for another couple of releases, I'm pushing this back to 1.4.4.

@pippinsplugins

This comment has been minimized.

Show comment
Hide comment
@pippinsplugins

pippinsplugins Feb 7, 2013

Member

I think we can close this now since the shop_manager roles have been given unfiltered upload caps.

Member

pippinsplugins commented Feb 7, 2013

I think we can close this now since the shop_manager roles have been given unfiltered upload caps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment