php VC-的Instagram,block.php
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php VC-的Instagram,block.php相关的知识,希望对你有一定的参考价值。
<?php
<?php
add_shortcode( 'rsp_media_instagram', 'rsp_media_instagram_func' );
function rsp_media_instagram_func( $atts, $content = null )
{
ob_start();
$url_to_check = "";
preg_match_all('!https?://\S+!', $content, $matches);
$all_urls = $matches[0];
if(!empty( $all_urls ) ) {
$url_to_check = str_replace('"','',$all_urls[0]);
}
$url_to_check = str_replace( '–', '--', $url_to_check );
$url_to_check = str_replace( '—', '--', $url_to_check );
$content = str_replace( '–', '--', $content );
$content = str_replace( '—', '--', $content );
$content = remove_query_arg( 'tagged', $content );
$headers_varcode = base64_encode( $url_to_check );
if ( false === ( $header_code = get_transient( 'vc_block_instagram_headers_' . $headers_varcode ) ) ) {
$header_code = $url_to_check[0];
$header_code = get_headers( $url_to_check );
$header_code = $header_code[0];
set_transient( 'vc_block_instagram_headers_' . $headers_varcode, $header_code, 24 * 1 * HOUR_IN_SECONDS );
}
if ( 1 /*$header_code == 'HTTP/1.1 200 OK'*/ ) {
$varcode = base64_encode( $content );
if ( false === ( $htmlcode = get_transient( 'vc_block_instagram_' . $varcode ) ) ) {
$htmlcode = wp_oembed_get( $content );
set_transient( 'vc_block_instagram_' . $varcode, $htmlcode, 24 * 1 * HOUR_IN_SECONDS );
}
?>
<div class="rsp_row">
<div class="EmbedCode">
<blockquote class="instagram-media" data-instgrm-permalink="<?php echo $content; ?>"
data-instgrm-version="8"
style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);">
<div style="padding:8px;">
<div style=" background:#F8F8F8; line-height:0; margin-top:40px; padding:62.5% 0; text-align:center; width:100%;">
<div style=" background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAMUExURczMzPf399fX1+bm5mzY9AMAAADiSURBVDjLvZXbEsMgCES5/P8/t9FuRVCRmU73JWlzosgSIIZURCjo/ad+EQJJB4Hv8BFt+IDpQoCx1wjOSBFhh2XssxEIYn3ulI/6MNReE07UIWJEv8UEOWDS88LY97kqyTliJKKtuYBbruAyVh5wOHiXmpi5we58Ek028czwyuQdLKPG1Bkb4NnM+VeAnfHqn1k4+GPT6uGQcvu2h2OVuIf/gWUFyy8OWEpdyZSa3aVCqpVoVvzZZ2VTnn2wU8qzVjDDetO90GSy9mVLqtgYSy231MxrY6I2gGqjrTY0L8fxCxfCBbhWrsYYAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;"></div>
</div>
<p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;">
<a href="<?php echo $content; ?>"
style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;"
target="_blank"></a></p>
</div>
</blockquote>
</div>
<script async defer src="//www.instagram.com/embed.js"></script>
</div>
<?php
}
$output = ob_get_contents();
ob_end_clean();
return $output;
}
vc_map( array(
'name' => __( 'Блок INSTAGRAM', 'js_composer' ),
'base' => 'rsp_media_instagram',
'icon' => get_template_directory_uri() . '/vc_blocks/icons/instagram.png',
'wrapper_class' => 'clearfix',
'category' => __( 'Roomble blocks', 'js_composer' ),
'description' => __( 'блок для вставки Instagram публикации', 'js_composer' ),
'params' => array(
array(
'type' => 'textarea_html',
'holder' => 'div',
'heading' => __( 'Текстовое содержание', 'js_composer' ),
"param_name" => "content",
"value" => "",
'description' => 'Введите ссылку на пост, например: http://instagram.com/p/zSiMuPnyTM/'
)
)
) );
以上是关于php VC-的Instagram,block.php的主要内容,如果未能解决你的问题,请参考以下文章