Share
extends Social
in package
Share post to social media.
Allows post or page sharing without needing scripts to be loaded. Uses URL links. Link is shown as an outlined button.
Tags
Table of Contents
Constants
- CONTAINER_DEFAULTS = array('aria-label' => '', 'classes' => array('pnet-social-list', 'pnet-social-list-share'))
- Default container settings.
- FACEBOOK_URL = 'https://www.facebook.com/sharer/sharer.php'
- Facebook sharing url.
- LINKEDIN_URL = 'https://www.linkedin.com/shareArticle'
- LinkedIn sharing url.
- PINTEREST_URL = 'https://pinterest.com/pin/create/button/'
- Pinterest sharing url.
- TWITTER_URL = 'https://twitter.com/intent/tweet'
- Twitter sharing url.
Properties
- $container_atts : array<string|int, mixed>
- Social list container attributes.
- $icons : Icons
- The instance of the SVG icon handler.
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
- $item_atts : array<string|int, mixed>
- Social list item attributes.
- $renderer : Link_List
- The instance of class to render the social links list.
- $settings : array<string|int, mixed>
- Site settings.
Methods
- get_instance() : object
- Creates and/or returns the instance of this class.
- render() : void
- Render the social list of links.
- __construct() : void
- Initialise the class.
- get_page_thumbnail() : string
- Get page or post thumbnail.
- get_page_title() : string
- Get page or post title.
- get_page_url() : string
- Get page or post url.
- get_twitter_name() : string
- Get page or post author twitter name if it exists.
- set_list_container() : void
- Set social list container definitions.
- set_list_items() : void
- Set social list item definitions.
- set_renderer() : void
- Set the class to render the social list.
Constants
CONTAINER_DEFAULTS
Default container settings.
protected
array<string|int, mixed>
CONTAINER_DEFAULTS
= array('aria-label' => '', 'classes' => array('pnet-social-list', 'pnet-social-list-share'))
CONTAINER_DEFAULTS { Definition of the social menu container. @type string $aria_label The text for the nav element ARIA label. @type string[] $classes The array of classes for the links list container. }
Tags
FACEBOOK_URL
Facebook sharing url.
protected
string
FACEBOOK_URL
= 'https://www.facebook.com/sharer/sharer.php'
Tags
LINKEDIN_URL
LinkedIn sharing url.
protected
string
LINKEDIN_URL
= 'https://www.linkedin.com/shareArticle'
Tags
PINTEREST_URL
Pinterest sharing url.
protected
string
PINTEREST_URL
= 'https://pinterest.com/pin/create/button/'
Tags
TWITTER_URL
Twitter sharing url.
protected
string
TWITTER_URL
= 'https://twitter.com/intent/tweet'
Tags
Properties
$container_atts
Social list container attributes.
protected
array<string|int, mixed>
$container_atts
= array()
{ Social list container attributes. @type string[] $classes The container CSS classes. @type int $author_id The id of the post or page author. }
Tags
$icons
The instance of the SVG icon handler.
protected
Icons
$icons
Tags
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
$item_atts
Social list item attributes.
protected
array<string|int, mixed>
$item_atts
= array()
{ Social list item attributes. @type string $service Service name. @type string $text Text to display on the button. @type string $url The URL the button points to. @type string $title The title attribute of the button. $type bool $new_tab Use new tab flag. }
Tags
$renderer
The instance of class to render the social links list.
protected
Link_List
$renderer
Tags
$settings
Site settings.
protected
array<string|int, mixed>
$settings
= array()
Tags
Methods
get_instance()
Creates and/or returns the instance of this class.
public
static get_instance() : object
Tags
Return values
object —The instance of this class.
render()
Render the social list of links.
public
render([array<string|int, mixed> $args = array() ]) : void
Parameters
- $args : array<string|int, mixed> = array()
-
Array of display attributes.
Tags
__construct()
Initialise the class.
protected
__construct() : void
Set the class to render links in the "use" declaration.
Tags
get_page_thumbnail()
Get page or post thumbnail.
protected
get_page_thumbnail() : string
Tags
Return values
string —The current page thumbnail url.
get_page_title()
Get page or post title.
protected
get_page_title() : string
Tags
Return values
string —The current page title.
get_page_url()
Get page or post url.
protected
get_page_url() : string
Tags
Return values
string —The url of current page.
get_twitter_name()
Get page or post author twitter name if it exists.
protected
get_twitter_name([int $author_id = 0 ]) : string
Parameters
- $author_id : int = 0
-
User id of the post author.
Tags
Return values
stringset_list_container()
Set social list container definitions.
protected
set_list_container(array<string|int, mixed> $args) : void
Override this in subclass to set list container properties.
Parameters
- $args : array<string|int, mixed>
-
Array of display attributes.
Tags
set_list_items()
Set social list item definitions.
protected
set_list_items() : void
Tags
set_renderer()
Set the class to render the social list.
protected
set_renderer() : void