| Server IP : 167.235.67.158 / Your IP : 216.73.216.95 Web Server : Apache System : Linux ubuntu-8gb-nbg1-1 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : upstairsbar.co.uk ( 982) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/vinfinity.co.uk/wp-content/themes/dine/inc/ |
Upload File : |
<?php
if ( ! function_exists( 'dine_err' ) ) :
/**
* function to return errors nicely
* @since 3.1
*/
function dine_err( $msg ) {
return sprintf( '<div class="dine-error">%s</div>', $msg );
}
endif;
if ( ! function_exists( 'dine_format' ) ) :
/**
* format things as python
* @since 3.1
*/
function dine_format( $msg, $vars ) {
$vars = (array)$vars;
$msg = preg_replace_callback('#\{\}#', function($r){
static $i = 0;
return '{'.($i++).'}';
}, $msg);
return str_replace(
array_map(function($k) {
return '{'.$k.'}';
}, array_keys($vars)),
array_values($vars),
$msg
);
}
endif;
if ( ! function_exists( 'dine_word_substr' ) ) :
/**
* Same as PHP substr but word-base
*
* @since 1.0
*/
function dine_word_substr( $str, $start = 0, $length = -1 ) {
$chunks = explode( ' ', $str );
$chunks = array_slice( $chunks, $start, $length );
return join( ' ', $chunks );
}
endif;
if ( !function_exists('dine_allowed_html') ) :
/**
* Allowed HTML tags for wp_kses function
*
* @since 1.0
*/
function dine_allowed_html(){
return array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
'class' => array(),
'onclick' => array(),
'rel' => array(),
'nofollow' => array(),
),
'br' => array(),
'em' => array(
'class' => array(),
'title' => array(),
),
'strong' => array(
'class' => array(),
'title' => array(),
),
'span' => array(
'class' => array(),
'title' => array(),
),
'i' => array(
'class' => array(),
'title' => array(),
),
'b' => array(
'class' => array(),
'title' => array(),
),
'hr' => array(
'class' => array(),
'title' => array(),
),
'ul' => array(
'class' => array(),
'title' => array(),
),
'ol' => array(
'class' => array(),
'title' => array(),
),
'li' => array(
'class' => array(),
'title' => array(),
),
'img' => array(
'src' => array(),
'title' => array(),
'class' => array(),
'width' => array(),
'height' => array(),
'alt' => array(),
),
);
}
endif;
if ( ! function_exists( 'dine_get_instagram_photos' ) ) :
/**
* retrieve instagram photos
*
* @since 1.0
*/
function dine_get_instagram_photos( $username, $number, $cache_time ) {
global $wp_version;
$proxies = array(
'https://boomproxy.com/browse.php?u=',
'https://us.hidester.com/proxy.php?u=',
'https://proxy-us1.toolur.com/browse.php?u=',
'https://proxy-fr1.toolur.com/browse.php?u=',
);
/**
* Get Instagram Photos
*
* @Scott Evans
*/
$username = trim( strtolower( $username ) );
$number = absint( $number );
$cache_time = absint( $cache_time );
if ( ! $username ) return;
if ( $number < 1 || $number > 12 ) $number = 6;
if ( false === ( $instagram = get_transient( 'dine-instagram-' . sanitize_title_with_dashes( $username . '-' . $number ) ) ) ) {
switch ( substr( $username, 0, 1 ) ) {
case '#':
$url = 'https://instagram.com/explore/tags/' . str_replace( '#', '', $username );
$transient_prefix = 'h';
break;
default:
$url = 'https://instagram.com/' . str_replace( '@', '', $username );
$transient_prefix = 'u';
break;
}
if ( $proxy = apply_filters( 'wpiw_proxy', false ) ) {
$url = $proxies[ array_rand( $proxies ) ] . urlencode( $url );
}
if ( false === ( $instagram = get_transient( 'insta-a10-' . $transient_prefix . '-' . sanitize_title_with_dashes( $username ) ) ) ) {
$remote = wp_remote_get( $url, array(
'user-agent' => 'Instagram/' . $wp_version . '; ' . home_url()
) );
if ( is_wp_error( $remote ) ) {
return new WP_Error( 'site_down', esc_html__( 'Unable to communicate with Instagram.', 'dine' ) );
}
if ( 200 !== wp_remote_retrieve_response_code( $remote ) ) {
return new WP_Error( 'invalid_response', esc_html__( 'Instagram did not return a 200.', 'dine' ) );
}
$shards = explode( 'window._sharedData = ', $remote['body'] );
$insta_json = explode( ';</script>', $shards[1] );
$insta_array = json_decode( $insta_json[0], true );
if ( ! $insta_array ) {
return new WP_Error( 'bad_json', esc_html__( 'Instagram has returned invalid data.', 'dine' ) );
}
if ( isset( $insta_array['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'] ) ) {
$images = $insta_array['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges'];
} elseif ( isset( $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'] ) ) {
$images = $insta_array['entry_data']['TagPage'][0]['graphql']['hashtag']['edge_hashtag_to_media']['edges'];
} else {
return new WP_Error( 'bad_json_2', esc_html__( 'Instagram has returned invalid data.', 'dine' ) );
}
if ( ! is_array( $images ) ) {
return new WP_Error( 'bad_array', esc_html__( 'Instagram has returned invalid data.', 'dine' ) );
}
$instagram = array();
foreach ( $images as $image ) {
if ( true === $image['node']['is_video'] ) {
$type = 'video';
} else {
$type = 'image';
}
$caption = __( 'Instagram Image', 'dine' );
if ( ! empty( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'] ) ) {
$caption = wp_kses( $image['node']['edge_media_to_caption']['edges'][0]['node']['text'], array() );
}
$instagram[] = array(
'description' => $caption,
'link' => trailingslashit( '//instagram.com/p/' . $image['node']['shortcode'] ),
'time' => $image['node']['taken_at_timestamp'],
'comments' => $image['node']['edge_media_to_comment']['count'],
'likes' => $image['node']['edge_liked_by']['count'],
'thumbnail' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ),
'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ),
'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ),
'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ),
'type' => $type,
);
} // End foreach().
// do not set an empty transient - should help catch private or empty accounts.
if ( ! empty( $instagram ) ) {
$instagram = base64_encode( serialize( $instagram ) );
set_transient( 'insta-a10-' . $transient_prefix . '-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'null_instagram_cache_time', $cache_time ) );
}
}
if ( ! empty( $instagram ) ) {
$instagram = unserialize( base64_decode( $instagram ) );
} else {
return new WP_Error( 'no_images', esc_html__( 'Instagram did not return any images.', 'dine' ) );
}
}
if ( ! empty( $instagram ) ) {
return array_slice( $instagram, 0, $number );
} else {
return new WP_Error( 'no_images', esc_html__( 'Instagram did not return any images.', 'dine' ) );
}
}
endif;
if ( ! function_exists( 'dine_get_video_thumbnail' ) ) :
/**
* returns video url of youtube/vimeo video and store it by transient
*
* @since 1.0
*/
function dine_get_video_thumbnail( $video_url = '' ) {
if ( ! $video_url ) return;
if ( false === ( $video_thumbnail_url = get_transient( 'dine-video-thumbnail-' . sanitize_title_with_dashes( $video_url ) ) ) ) {
// check the embed case
if ( stripos($video_url,'<' . 'iframe') > -1) {
preg_match('/src="([^"]+)"/', $video_url, $match);
$video_url = $match[1];
$video_url = preg_replace('/\?.*/', '', $video_url);
}
// Props to @rzen for lending his massive brain smarts to help with the regex
$do_video_thumbnail = (
preg_match( '/\/\/(www\.)?youtube\.com\/(watch|embed)\/?(\?v=)?([a-zA-Z0-9\-\_]+)/', $video_url, $youtube_matches ) ||
preg_match( '#https?://(.+\.)?vimeo\.com/.*#i', $video_url, $vimeo_matches )
);
if ( ! $do_video_thumbnail ) {
return false;
}
$youtube_id = ! empty( $youtube_matches ) ? $youtube_matches[4] : '';
$vimeo_id = ! empty( $vimeo_matches ) ? preg_replace( "/[^0-9]/", "", $vimeo_matches[0] ) : '';
if ( $youtube_id ) {
// Check to see if our max-res image exists
$file_headers = get_headers( 'http://img.youtube.com/vi/' . $youtube_id . '/maxresdefault.jpg' );
$video_thumbnail_url = $file_headers[0] !== 'HTTP/1.0 404 Not Found' ? 'http://img.youtube.com/vi/' . $youtube_id . '/maxresdefault.jpg' : 'http://img.youtube.com/vi/' . $youtube_id . '/hqdefault.jpg';
} elseif ( $vimeo_id ) {
$vimeo_data = wp_remote_get( 'http://www.vimeo.com/api/v2/video/' . intval( $vimeo_id ) . '.php' );
if ( isset( $vimeo_data['response']['code'] ) && '200' == $vimeo_data['response']['code'] ){
$response = unserialize( $vimeo_data['body'] );
$video_thumbnail_url = isset( $response[0]['thumbnail_large'] ) ? $response[0]['thumbnail_large'] : false;
}
$video_thumbnail_url_1280 = str_replace( '_640', '_1280', $video_thumbnail_url );
if ( $video_thumbnail_url_1280 ) {
// Check to see if 1280px image exists
$file_headers = get_headers( $video_thumbnail_url_1280 );
if ( $file_headers[0] !== 'HTTP/1.0 404 Not Found' ) $video_thumbnail_url = $video_thumbnail_url_1280;
}
}
// do not set an empty transient - should help catch private or empty accounts
if ( ! empty( $video_thumbnail_url ) ) {
set_transient( 'dine-video-thumbnail-'.sanitize_title_with_dashes( $video_url ), $video_thumbnail_url, WEEK_IN_SECONDS );
}
}
return $video_thumbnail_url;
}
endif;
if ( ! function_exists( 'dine_checkbox_option' ) ) :
/**
* Get multicheckbox options while values are separated by commas.
*
* @since 1.0
*/
function dine_checkbox_option( $option_id, $default = null ) {
if ( null === $default ) {
$return = trim( get_theme_mod( $option_id ) );
} else {
$return = trim( get_theme_mod( $option_id, $default ) );
}
$return = explode( ',' , $return );
$return = array_map( 'trim', $return );
return $return;
}
endif;
if ( ! function_exists( 'dine_border_style' ) ):
/**
* Border Style
*
* @since 1.0
*/
function dine_border_style() {
return array(
'none' => esc_html__( 'None', 'dine' ),
'solid' => esc_html__( 'Solid', 'dine' ),
'dotted' => esc_html__( 'Dotted', 'dine' ),
'dashed' => esc_html__( 'Dashed', 'dine' ),
'double' => esc_html__( 'Double', 'dine' ),
);
}
endif;
if ( ! function_exists( 'dine_background_size' ) ):
/**
* Background Size
*
* @since 1.0
*/
function dine_background_size() {
return array(
'cover' => esc_html__( 'Cover', 'dine' ),
'contain' => esc_html__( 'Contain', 'dine' ),
'100% auto' => esc_html__( '100% Width', 'dine' ),
'auto 100%' => esc_html__( '100% Height', 'dine' ),
'auto' => esc_html__( 'Auto', 'dine' ),
);
}
endif;
if ( ! function_exists( 'dine_background_position' ) ):
/**
* Background Position
*
* @since 1.0
*/
function dine_background_position() {
return array(
'left top' => esc_html__( 'Left Top', 'dine' ),
'center top' => esc_html__( 'Center Top', 'dine' ),
'right top' => esc_html__( 'Right Top', 'dine' ),
'left center' => esc_html__( 'Left Middle', 'dine' ),
'center center' => esc_html__( 'Center Middle', 'dine' ),
'right center' => esc_html__( 'Right Middle', 'dine' ),
'left bottom' => esc_html__( 'Left Bottom', 'dine' ),
'center bottom' => esc_html__( 'Center Bottom', 'dine' ),
'right bottom' => esc_html__( 'Right Bottom', 'dine' ),
);
}
endif;
if ( ! function_exists( 'dine_background_repeat' ) ):
/**
* Background Repeat
*
* @since 1.0
*/
function dine_background_repeat() {
return array(
'no-repeat' => esc_html__( 'No Repeat', 'dine' ),
'repeat' => esc_html__( 'Repeat', 'dine' ),
'repeat-x' => esc_html__( 'Repeat X', 'dine' ),
'repeat-y' => esc_html__( 'Repeat Y', 'dine' ),
);
}
endif;
if ( ! function_exists( 'dine_background_attachment' ) ):
/**
* Background Attachment
*
* @since 1.0
*/
function dine_background_attachment() {
return array(
'scroll' => esc_html__( 'Scroll', 'dine' ),
'fixed' => esc_html__( 'Fixed', 'dine' ),
);
}
endif;
if ( ! function_exists( 'dine_pageid' ) ) :
/**
* Normally get post id returns current singular id but it doesn't apply for blog posts page
*
* This function covers that case
*
* @since 1.0
*/
function dine_pageid() {
if ( is_singular() ) {
return get_the_ID();
} elseif ( is_home() && get_option( 'show_on_front' ) == 'page' ) {
return get_option( 'page_for_posts' );
}
return apply_filters( 'dine_pageid', false );
}
endif;
/* text to screen number
* since 3.3
------------------------------------------------------------------------------------ */
function dine_get_screen_from_text( $screen ) {
if ( 'ipad1' == $screen ) return 1023;
if ( 'ipad2' == $screen ) return 767;
if ( 'iphone1' == $screen ) return 567;
if ( 'iphone2' == $screen ) return 479;
return 1919;
}
/* since 4.0
* since 3.3
------------------------------------------------------------------------------------ */
function dine_get_query_screen_string_from_text( $screen ) {
return "@media only screen and (max-width: " . dine_get_screen_from_text( $screen ) . "px)";
}