The GFA_Shortcodes
class provides class methods that can be used to render links and information about files handled by the Groups File Access plugin.
GFA_Shortcodes::groups_file_url( $atts, $content = null )
Renders a file URL.
Attributes are passed through $atts
:
file_id
: id of the filevisibility
: This option determines whether the file URL will be returned for the current user or not.can_access
will only return the file URL if the current user is allowed to access the file;always
will return the file URL disregarding whether the user is allowed to access the file.
Parameters
array $atts
attributesstring $content
– not used
Returns:
string
rendered URL
GFA_Shortcodes::groups_file_link( $atts, $content = null )
Renders a link to a file based on settings passed through $atts
.
Required attributes are either file_id
or group
.
Basic attributes:
file_id
: id of the filevisibility
:can_access
oralways
seeGFA_Shortcodes::groups_file_url()
group
: group name or ID – will list files for the given group sorted by namedescription
: defaults tono
,yes
shows description for each entry (onlygroup
)order
:ASC
orDESC
sort order (only forgroup
)list_prefix
: defaults to<ul>
list_suffix
: defaults to</ul>
item_prefix
: defaults to<li>
item_suffix
: defaults to</li>
Note that the prefixes and suffixes are very limited due to filters applied.
Allowed link attributes that are applied to the rendered a
tag: accesskey
, alt
, charset
, coords
, class
, dir
, hreflang
, id
, lang
, name
, rel
, rev
, shape
, style
, tabindex
, target
Parameters:
array $atts
attributesstring $content
not used
Returns:
string
rendered link
GFA_Shortcodes::groups_can_access_file( $atts, $content = null )
Returns $content
if the current user can access the file.
Parameters:
array $atts
attributes – must provide thefile_id
string $content
content to render
Returns:
string $content
or empty string
GFA_Shortcodes::groups_can_not_access_file( $atts, $content = null )
Returns $content
if the current user can not access the file.
Parameters:
array $atts
attributes – must provide thefile_id
string $content
content to render
Returns:
string $content
or empty string
GFA_Shortcodes::groups_file_info( $atts, $content = null )
Renders file information.
The visibility
parameter determines whether the $content
will be returned for the current user or not:
can_access
will only return $content
if the current user is allowed to access the file; always
will return $content
disregarding whether the user is allowed to access the file
Attributes:
file_id
: id of the filevisibility
:can_access
(default) oralways
show
:name
,description
,count
,max_count
,remaining
,file_id
Parameters:
array $atts
attributes – must provide thefile_id
string $content
content to render
Returns:
string $content
or empty string
GFA_Shortcodes::groups_visibility( $atts, $content = null )
Allows to switch the default visibility setting for shortcodes handled by GFA_Shortcodes
.
Parameters:
array $atts
attributes must specify thevisibility
with allowed valuesalways
,can_access
string $content
not used