JPKCom FA inline SVG shortcode

Documentation

Table of Contents

Packages

JPKComFaSvgPlugin
JPKComFaSvgPluginGitUpdate

Namespaces

JPKComFaSvgPluginGitUpdate

Constants

JPKCOM_FASVG_PATH  : mixed = \jpkcom_fasvg_path()
JPKCOM_FASVG_PLUGIN_PATH  : mixed = \plugin_dir_path(__FILE__)
JPKCOM_FASVG_PLUGIN_URL  : mixed = \plugin_dir_url(__FILE__)
JPKCOM_FASVG_URL  : mixed = \jpkcom_fasvg_url()
JPKCOM_FASVG_VERSION  : mixed = '2.0.16'

Functions

jpkcom_fasvg_path()  : string
Filesystem base for the Font Awesome CSS and SVGs.
jpkcom_fasvg_url()  : string
URL base for the Font Awesome CSS and SVGs.
jpkcom_fasvg_register_style()  : void
jpkcom_fasvg_enqueue_files()  : void
jpkcom_fasvg_enqueue_gutenberg_files()  : void
jpkcom_fasvg_navigation_fa()  : array<string|int, mixed>
jpkcom_fasvg_shortcode()  : string
Render the [jsvg] shortcode as an inline Font Awesome SVG.
jsvg_code()  : string
Deprecated alias of {@see jpkcom_fasvg_shortcode()}.

Constants

JPKCOM_FASVG_PLUGIN_PATH

public mixed JPKCOM_FASVG_PLUGIN_PATH = \plugin_dir_path(__FILE__)

JPKCOM_FASVG_PLUGIN_URL

public mixed JPKCOM_FASVG_PLUGIN_URL = \plugin_dir_url(__FILE__)

Functions

jpkcom_fasvg_path()

Filesystem base for the Font Awesome CSS and SVGs.

jpkcom_fasvg_path() : string

Resolved on every call rather than once at load time. The plugin can be network-activated, and on multisite each site has its own upload directory: a value captured while the file was included would keep pointing at the site that happened to be active then, which is wrong for anything rendered after switch_to_blog().

Uses wp_get_upload_dir(), i.e. wp_upload_dir( null, false ) — the variant that does not try to create the directory. Reading icons never needs that side effect. Both are statically cached, so the per-call cost is a fraction of a microsecond.

Tags
since
2.0.16
Return values
string

Absolute path with a trailing slash.

jpkcom_fasvg_url()

URL base for the Font Awesome CSS and SVGs.

jpkcom_fasvg_url() : string

Same reasoning as jpkcom_fasvg_path().

Tags
since
2.0.16
Return values
string

URL with a trailing slash.

jpkcom_fasvg_navigation_fa()

jpkcom_fasvg_navigation_fa(array<string|int, mixed> $menu_items) : array<string|int, mixed>
Parameters
$menu_items : array<string|int, mixed>
Return values
array<string|int, mixed>

jpkcom_fasvg_shortcode()

Render the [jsvg] shortcode as an inline Font Awesome SVG.

jpkcom_fasvg_shortcode(array<string, string>|string $atts) : string

Supported attributes:

  • type: Font Awesome style folder (fas, fal, far, fad, fab). Default 'fas'.
  • name: Icon file name without extension. Default 'square-full'.
  • class: Additional CSS classes for the element.
  • style: Inline CSS for the element.
  • title: Accessible title; sets aria-labelledby and a <title> element.

The file name is reduced to a flat name with basename() and sanitize_file_name(), and .svg is always appended, so no path outside <uploads>/jpkcom_fasvg/svgs/<style>/ can be reached. The style folder is whitelisted. The raw file contents are returned inline — the trust boundary is that directory, so only vetted Font Awesome SVGs belong there.

Parameters
$atts : array<string, string>|string

Shortcode attributes ( empty string when none are supplied ).

Tags
since
1.0.0
2.0.16

Renamed from the unprefixed jsvg_code() and wrapped in a function_exists() guard, matching every other function in this file. jsvg_code() remains as a deprecated shim.

Return values
string

The inline SVG markup.

jsvg_code()

Deprecated alias of {@see jpkcom_fasvg_shortcode()}.

Use jpkcom_fasvg_shortcode() instead.

jsvg_code(array<string, string>|string $atts) : string

The original name carried no vendor prefix and no function_exists() guard, so any theme or plugin declaring jsvg_code produced a fatal redeclare error on load. Kept as a shim for code calling it directly.

Parameters
$atts : array<string, string>|string

Shortcode attributes.

Tags
since
1.0.0
Return values
string

The inline SVG markup.

Search results