'facebook',
'label' => esc_html__( 'Facebook', 'blockchain-lite' ),
'icon' => 'fa-facebook',
),
array(
'name' => 'twitter',
'label' => esc_html__( 'Twitter', 'blockchain-lite' ),
'icon' => 'fa-twitter',
),
array(
'name' => 'instagram',
'label' => esc_html__( 'Instagram', 'blockchain-lite' ),
'icon' => 'fa-instagram',
),
array(
'name' => 'snapchat',
'label' => esc_html__( 'Snapchat', 'blockchain-lite' ),
'icon' => 'fa-snapchat',
),
array(
'name' => 'bloglovin',
'label' => esc_html__( 'Bloglovin', 'blockchain-lite' ),
'icon' => 'fa-heart',
),
array(
'name' => 'pinterest',
'label' => esc_html__( 'Pinterest', 'blockchain-lite' ),
'icon' => 'fa-pinterest',
),
array(
'name' => 'youtube',
'label' => esc_html__( 'YouTube', 'blockchain-lite' ),
'icon' => 'fa-youtube',
),
array(
'name' => 'vimeo',
'label' => esc_html__( 'Vimeo', 'blockchain-lite' ),
'icon' => 'fa-vimeo',
),
array(
'name' => 'gplus',
'label' => esc_html__( 'Google Plus', 'blockchain-lite' ),
'icon' => 'fa-google-plus',
),
array(
'name' => 'linkedin',
'label' => esc_html__( 'LinkedIn', 'blockchain-lite' ),
'icon' => 'fa-linkedin',
),
array(
'name' => 'tumblr',
'label' => esc_html__( 'Tumblr', 'blockchain-lite' ),
'icon' => 'fa-tumblr',
),
array(
'name' => 'flickr',
'label' => esc_html__( 'Flickr', 'blockchain-lite' ),
'icon' => 'fa-flickr',
),
array(
'name' => 'dribbble',
'label' => esc_html__( 'Dribbble', 'blockchain-lite' ),
'icon' => 'fa-dribbble',
),
array(
'name' => 'wordpress',
'label' => esc_html__( 'WordPress', 'blockchain-lite' ),
'icon' => 'fa-wordpress',
),
array(
'name' => '500px',
'label' => esc_html__( '500px', 'blockchain-lite' ),
'icon' => 'fa-500px',
),
array(
'name' => 'soundcloud',
'label' => esc_html__( 'Soundcloud', 'blockchain-lite' ),
'icon' => 'fa-soundcloud',
),
array(
'name' => 'spotify',
'label' => esc_html__( 'Spotify', 'blockchain-lite' ),
'icon' => 'fa-spotify',
),
array(
'name' => 'vine',
'label' => esc_html__( 'Vine', 'blockchain-lite' ),
'icon' => 'fa-vine',
),
array(
'name' => 'tripadvisor',
'label' => esc_html__( 'Trip Advisor', 'blockchain-lite' ),
'icon' => 'fa-tripadvisor',
),
) );
}
function blockchain_lite_wp_link_pages_default_args() {
return apply_filters( 'blockchain_lite_wp_link_pages_default_args', array(
'before' => '
' . esc_html__( 'Pages:', 'blockchain-lite' ),
'after' => '
',
'link_before' => '',
'link_after' => '',
) );
}
function blockchain_lite_get_video_url_info( $url ) {
$is_vimeo = preg_match( '#(?:https?://)?(?:www\.)?vimeo\.com/([A-Za-z0-9\-_]+)#', $url, $vimeo_id );
$is_youtube = preg_match( '~
# Match non-linked youtube URL in the wild. (Rev:20111012)
https?:// # Required scheme. Either http or https.
(?:[0-9A-Z-]+\.)? # Optional subdomain.
(?: # Group host alternatives.
youtu\.be/ # Either youtu.be,
| youtube\.com # or youtube.com followed by
\S* # Allow anything up to VIDEO_ID,
[^\w\-\s] # but char before ID is non-ID char.
) # End host alternatives.
([\w\-]{11}) # $1: VIDEO_ID is exactly 11 chars.
(?=[^\w\-]|$) # Assert next char is non-ID or EOS.
(?! # Assert URL is not pre-linked.
[?=&+%\w]* # Allow URL (query) remainder.
(?: # Group pre-linked alternatives.
[\'"][^<>]*> # Either inside a start tag,
| # or inside element text contents.
) # End recognized pre-linked alts.
) # End negative lookahead assertion.
[?=&+%\w-]* # Consume any URL (query) remainder.
~ix',
$url, $youtube_id );
$info = array(
'supported' => false,
'provider' => '',
'video_id' => '',
);
if ( $is_youtube ) {
$info['supported'] = true;
$info['provider'] = 'youtube';
$info['video_id'] = $youtube_id[1];
} elseif ( $is_vimeo ) {
$info['supported'] = true;
$info['provider'] = 'vimeo';
$info['video_id'] = $vimeo_id[1];
}
return $info;
}
/**
* Returns a set of related posts, or the arguments needed for such a query.
*
* @uses wp_parse_args()
* @uses get_post_type()
* @uses get_post()
* @uses get_object_taxonomies()
* @uses get_the_terms()
* @uses wp_list_pluck()
*
* @param int $post_id A post ID to get related posts for.
* @param int $related_count The number of related posts to return.
* @param array $args Array of arguments to change the default behavior.
* @return object|array A WP_Query object with the results, or an array with the query arguments.
*/
function blockchain_lite_get_related_posts( $post_id, $related_count, $args = array() ) {
$args = wp_parse_args( (array) $args, array(
'orderby' => 'rand',
'return' => 'query', // Valid values are: 'query' (WP_Query object), 'array' (the arguments array)
) );
$post_type = get_post_type( $post_id );
$post = get_post( $post_id );
$tax_query = array();
$taxonomies = get_object_taxonomies( $post, 'names' );
foreach ( $taxonomies as $taxonomy ) {
$terms = get_the_terms( $post_id, $taxonomy );
if ( is_array( $terms ) && count( $terms ) > 0 ) {
$term_list = wp_list_pluck( $terms, 'slug' );
$term_list = array_values( $term_list );
if ( ! empty( $term_list ) ) {
$tax_query['tax_query'][] = array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $term_list,
);
}
}
}
if ( count( $taxonomies ) > 1 ) {
$tax_query['tax_query']['relation'] = 'OR';
}
$query_args = array(
'post_type' => $post_type,
'posts_per_page' => $related_count,
'post_status' => 'publish',
'post__not_in' => array( $post_id ),
'orderby' => $args['orderby'],
);
if ( 'query' === $args['return'] ) {
return new WP_Query( array_merge( $query_args, $tax_query ) );
} else {
return array_merge( $query_args, $tax_query );
}
}
/**
* Returns the appropriate page(d) query variable to use in custom loops (needed for pagination).
*
* @uses get_query_var()
*
* @param int $default_return The default page number to return, if no query vars are set.
* @return int The appropriate paged value if found, else 0.
*/
function blockchain_lite_get_page_var( $default_return = 0 ) {
$paged = get_query_var( 'paged', false );
$page = get_query_var( 'page', false );
if ( false === $paged && false === $page ) {
return $default_return;
}
return max( $paged, $page );
}
/**
* Retrieve or display list of posts as a dropdown (select list).
*
* @since 2.1.0
*
* @param array|string $args Optional. Override default arguments.
* @param string $name Optional. Name of the select box.
* @return string HTML content, if not displaying.
*/
function blockchain_lite_dropdown_posts( $args = '', $name = 'post_id' ) {
$defaults = array(
'depth' => 0,
'post_parent' => 0,
'selected' => 0,
'echo' => 1,
//'name' => 'page_id', // With this line, get_posts() doesn't work properly.
'id' => '',
'class' => '',
'show_option_none' => '',
'show_option_no_change' => '',
'option_none_value' => '',
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => false,
'numberposts' => -1,
'select_even_if_empty' => false, // If no posts are found, an empty