This plugin will:
- Register a widget that will display a list of icons that when clicked will navigate to the relevant social network.
- Provide the functionality to add social sharing links to your website.
Definition: Within this plugin a context is a way to indicate what data is needed and the use of that data.
There are two contexts available:
profile
- If you need links to a users pages you would request the profile context.share
- If you are going to do something involving sharing a post/page.
The registered_profiles
array contains the currently registered social profiles.
Each key of the registered_profiles
array should be a unique id for a social profile containing an array of data about that social profile.
For example:
$registered_profiles = array(
'facebook' => array(
'name' => 'Facebook',
'icon' => 'https://example.com/facebook-icon.png',
// Font awesome icon
'fa_icon' => 'facebook',
'profile_link' => 'https://facebook.com/your-page-link',
// Valid sprintf format - expect args = name, link, media, referrer
'share_link_format' => 'https://www.facebook.com/sharer/sharer.php?u=%2$s',
),
// ...other registered profiles
);
The active_page_profiles
array will hold a list of profile id's that are active in the context of page
. For example, there may be 6 registered profiles in the registered_profiles
array but there may only be 3 profiles that are active in the context of page. The reasoning behind this is that the user may only want to show links to three of their social pages but still wants to give the option to share to all 6 registered profiles.
$active_page_profiles = array('facebook', 'twitter');
The same as active_page_profiles
except active_share_profiles
contains id's of profiles active in the share
context.
$active_share_profiles = array('pinterest', 'linkedin', 'twitter');
// TODO: Add display settings
All functions exist in the RelativeMarketing\RelativeSharer
namespace make sure you include the namespace before using any of the below functions.
use RelativeMarketing\Sharer;
Returns all currently registered profiles.
return array
- An array of registered profiles or an empty array if no profiles are registered
Checks if a profile with a given id is registered.
return boolean
- True if the profile is registered or false
Checks if a profile is active in a given context.
return boolean
- True if the profile is active or false
Returns all active profile ids for a given content
return array
- If no active profiles exist an empty array will be returned
Returns all active profiles for a given content
return array
- If no active profiles exist an empty array will be returned
Registers a profile. The profile array may contain the following:
id
- The id of the profilename
- The nicename for the profilelink_to_profile
- The link to the users dedicated page on the social network you are addingicon
- A custom icon for the social networkfa_icon
- The font awesome icon name to use for this profile e.g 'facebook'share_link_format
- A valid sprintf string that will be used to contruct the share url. Arguments for this string will be name, link, media, referrer in that order.
return boolean|WP_Error
- True if the profile was registered or WP_Error on failure
Works in a similar fashion to register_profile
but expects the given $id
to exists. $data
should be any valid profile data you would like to update.
return boolean|WP_Error
- True if the profile was updated or WP_Error on failure
Will activate the given profile in the given content
return boolean|WP_Error
- true
on activation (or if the profile is already active), WP_Error if the profile doesn't exist
Will deactivate the given profile in the given content
return boolean|WP_Error
- true
on deactivation (or if the profile is already deactive), WP_Error if the profile doesn't exist
Will register and activate a given profile and activate it for the given contents
return boolean|WP_Error
- true on success, error on failure
Will delete a profile from the registered_profiles
array.
return boolean|WP_Error
- true on sucess, error on failure.
Will return HTML output for all active_page_profiles
A wrapper for get_page_share_icons()
will echo instead of returning
Will return HTML output for active_share_profiles
A wrapper for get_share_icons()
will echo instead of returning
@TODO: functions for widget, shortcode, block registration
@TODO: functions/docs for user options
@TODO: functions styling
@TODO: actions and filters docs