Primary

GFA_Shortcodes

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 file
  • visibility : 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 attributes
  • string $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 file
  • visibility : can_access or always see GFA_Shortcodes::groups_file_url()
  • group : group name or ID – will list files for the given group sorted by name
  • description : defaults to noyes shows description for each entry (only group)
  • order : ASC or DESC sort order (only for group)
  • 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: accesskeyaltcharsetcoordsclassdirhreflangidlangnamerelrevshapestyletabindextarget

Parameters:

  • array $atts attributes
  • string $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 the file_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 the file_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; alwayswill return $content disregarding whether the user is allowed to access the file

Attributes:

  • file_id : id of the file
  • visibility : can_access (default) or always
  • show : namedescriptioncountmax_countremainingfile_id

Parameters:

  • array $atts attributes – must provide the file_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 the visibility with allowed values alwayscan_access
  • string $content not used