inc/helpers.php

largo_fb_url_to_username()

Returns a Facebook username or ID from the URL

Parameters:
  • $url (string) – a Facebook url
Returns:

string $he Facebook username or id extracted from the input string

Since:

0.4

clean_user_fb_username()

Cleans a Facebook url to the bare username or id when the user is edited

Edits $_POST directly because there’s no other way to save the corrected username from this callback. The action hooks this is used for run before edit_user in wp-admin/user-edit.php, which overwrites the user’s contact methods. edit_user reads from $_POST.

Parameters:
  • $user_id (object) – the WP_User object being edited
  • $_POST (array) –
Since:

0.4

Uses:

largo_fb_url_to_username

Link:

https://codex.wordpress.org/Plugin_API/Action_Reference/edit_user_profile_update

Link:

https://codex.wordpress.org/Plugin_API/Action_Reference/personal_options_update

validate_fb_username()

Checks that the Facebook URL submitted is valid and the user is followable and causes an error if not

Uses:

largo_fb_url_to_username

Parameters:
  • $he ($errors) – error object
  • $update (bool) – whether this is a user update
  • $user (object) – a WP_User object
Link:

https://codex.wordpress.org/Plugin_API/Action_Reference/user_profile_update_errors

Since:

0.4

largo_twitter_url_to_username()

Returns a Twitter username (without the @ symbol)

Parameters:
  • $url (string) – a twitter url
Returns:

string $he twitter username extracted from the input string

Since:

0.3

clean_user_twitter_username()

Cleans a Twitter url or an @username to the bare username when the user is edited

Edits $_POST directly because there’s no other way to save the corrected username from this callback. The action hooks this is used for run before edit_user in wp-admin/user-edit.php, which overwrites the user’s contact methods. edit_user reads from $_POST.

Parameters:
  • $user_id (object) – the WP_User object being edited
  • $_POST (array) –
Since:

0.4

Uses:

largo_twitter_url_to_username

Link:

https://codex.wordpress.org/Plugin_API/Action_Reference/edit_user_profile_update

Link:

https://codex.wordpress.org/Plugin_API/Action_Reference/personal_options_update

validate_twitter_username()

Checks that the Twitter URL is composed of valid characters [a-zA-Z0-9_] and causes an error if there is not.

Parameters:
  • $he ($errors) – error object
  • $update (bool) – whether this is a user update
  • $user (object) – a WP_User object
Uses:

largo_twitter_url_to_username

Link:

https://codex.wordpress.org/Plugin_API/Action_Reference/user_profile_update_errors

Since:

0.4

largo_youtube_url_to_ID()

Give it a YouTube URL, it’ll give you just the video ID

Parameters:
Returns:

string $ust the video ID (e.g. - i5vfw5f1CZo)

Since:

0.4

largo_youtube_iframe_from_url()

For a given YouTube URL, return an iframe to embed

Parameters:
Returns:

string $ standard YouTube iframe embed code

Uses:

largo_youtube_url_to_ID

Since:

0.4

largo_youtube_image_from_url()

For a given YouTube URL, return the image url for various thumbnail sizes

Parameters:
  • $url (string) – a YouTube URL (e.g. - https://www.youtube.com/watch?v=i5vfw5f1CZo)
  • $he (string) – image size you’d like (options are: thumb | small | medium | large)
  • $echo (bool) – return or echo the output
Returns:

string $ youtube image url

Uses:

largo_youtube_url_to_ID

Since:

0.4

largo_make_slug()

Transform user-entered text into WP-compatible slugs

Parameters:
  • $string (string) – the string to turn into a slug
  • $maxLength (string) – the max length for the slug in characters
Since:

0.4

largo_get_current_url()

Get the current URL, including the protocol and host

Since:0.5
largo_first_thumbnail_in_post_array()

Return the first featured image thumbnail found in a given array of WP_Posts

Useful if you want to create a thumbnail for a given taxonomy

Parameters:
  • $n (array) – array of WP_Post objects to iterate over
Returns:

str|false $he HTML for the image, or false if no images were found.

Since:

0.5.3

Uses:

largo_has_featured_media

largo_first_headline_in_post_array()

Return the first headline link for an array of WP_Posts

Useful if you want to link to an example post in a series.

Parameters:
  • $n (array) – array of WP_Post objects to iterate over
Returns:

str $he HTML for the link

Since:

0.5.3