$remote = wp_remote_get('http://instagram.com/'.trim($username));
if (is_wp_error($remote))
return new WP_Error('site_down', __('Unable to communicate with Instagram.', 'thevoux'));
if ( 200 != wp_remote_retrieve_response_code( $remote ) )
return new WP_Error('invalid_response', __('Instagram did not return a 200.', 'thevoux'));
$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', __('Instagram has returned invalid data.', 'thevoux'));
$images = $insta_array['entry_data']['ProfilePage'][0]['user']['media']['nodes'];
$instagram = array();
foreach ($images as $image) {
$image['link'] = $image['code'];
$image['display_src'] = $image['display_src'];
$instagram[] = array(
'link' => $image['link'],
'large' => $image['display_src']
);
}
$instagram = thb_encode( serialize( $instagram ) );
set_transient('instagram-media-'.sanitize_title_with_dashes($username), $instagram, apply_filters('null_instagram_cache_time', HOUR_IN_SECONDS*2));
}
$instagram = unserialize( thb_decode( $instagram ) );
$media_array = array_slice($instagram, 0, $number);
?>
<div class="row <?php echo esc_attr($nopadding.' '.$lowpadding); ?> instagram-row"><?php
foreach ($media_array as $item) {
echo '<div class="small-12 '.$col.' columns cf"><figure style="background-image:url('. esc_url($item['large']) .')">';
$remote = wp_remote_get('http://instagram.com/'.trim($username));
if (is_wp_error($remote))
return new WP_Error('site_down', __('Unable to communicate with Instagram.', 'thevoux'));
if ( 200 != wp_remote_retrieve_response_code( $remote ) )
return new WP_Error('invalid_response', __('Instagram did not return a 200.', 'thevoux'));
$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', __('Instagram has returned invalid data.', 'thevoux'));
$images = $insta_array['entry_data']['ProfilePage'][0]['user']['media']['nodes'];
$instagram = array();
foreach ($images as $image) {
$image['link'] = $image['code'];
$image['display_src'] = $image['display_src'];
$instagram[] = array(
'link' => $image['link'],
'large' => $image['display_src']
);
}
$instagram = thb_encode( serialize( $instagram ) );
set_transient('instagram-media-'.sanitize_title_with_dashes($username), $instagram, apply_filters('null_instagram_cache_time', HOUR_IN_SECONDS*2));
}
$instagram = unserialize( thb_decode( $instagram ) );
$media_array = array_slice($instagram, 0, $number);
?>
<div class="row <?php echo esc_attr($nopadding.' '.$lowpadding); ?> instagram-row"><?php
foreach ($media_array as $item) {
echo '<div class="small-12 '.$col.' columns cf"><figure style="background-image:url('. esc_url($item['large']) .')">';
* Filters whether to call a shortcode callback.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortcode generation process, returning that value instead.
*
* @since 4.7.0
*
* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
if ( false !== $return ) {
return $return;
}
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
/**
* Filters the output created by a shortcode callback.
*
* @since 4.7.0
*
* @param string $output Shortcode output.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
}
/**
* Search only inside HTML elements for shortcodes and process them.
*
* Any [ or ] characters remaining inside elements will be HTML encoded
* to prevent interference with shortcodes that are outside the elements.
* Assumes $content processed by KSES already. Users with unfiltered_html
* Filters whether to call a shortcode callback.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortcode generation process, returning that value instead.
*
* @since 4.7.0
*
* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
if ( false !== $return ) {
return $return;
}
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
/**
* Filters the output created by a shortcode callback.
*
* @since 4.7.0
*
* @param string $output Shortcode output.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
}
/**
* Search only inside HTML elements for shortcodes and process them.
*
* Any [ or ] characters remaining inside elements will be HTML encoded
* to prevent interference with shortcodes that are outside the elements.
* Assumes $content processed by KSES already. Users with unfiltered_html
if ( false === strpos( $content, '[' ) ) {
return $content;
}
if (empty($shortcode_tags) || !is_array($shortcode_tags))
return $content;
// Find all registered tag names in $content.
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
if ( empty( $tagnames ) ) {
return $content;
}
$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames );
$pattern = get_shortcode_regex( $tagnames );
$content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content );
// Always restore square braces so we don't break things like <!--[if IE ]>
$content = unescape_invalid_shortcodes( $content );
return $content;
}
/**
* Retrieve the shortcode regular expression for searching.
*
* The regular expression combines the shortcode tags in the regular expression
* in a regex class.
*
* The regular expression contains 6 different sub matches to help with parsing.
*
* 1 - An extra [ to allow for escaping shortcodes with double [[]]
* 2 - The shortcode name
* 3 - The shortcode argument list
* 4 - The self closing /
* 5 - The content of a shortcode when it wraps some content.
}
}
return $width;
}
/**
* @param $content
* @param bool $autop
*
* @since 4.2
* @return string
*/
function wpb_js_remove_wpautop( $content, $autop = false ) {
if ( $autop ) { // Possible to use !preg_match('('.WPBMap::getTagsRegexp().')', $content)
$content = wpautop( preg_replace( '/<\/?p\>/', "\n", $content ) . "\n" );
}
return do_shortcode( shortcode_unautop( $content ) );
}
if ( ! function_exists( 'shortcode_exists' ) ) {
/**
* Check if a shortcode is registered in WordPress.
*
* Examples: shortcode_exists( 'caption' ) - will return true.
* shortcode_exists( 'blah' ) - will return false.
*
* @param bool $shortcode
*
* @since 4.2
* @return bool
*/
function shortcode_exists( $shortcode = false ) {
global $shortcode_tags;
if ( ! $shortcode ) {
return false;
}
$el_class .= ' '.$animation;
$style = $this->buildStyle( $font_color );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $width . $el_class . vc_shortcode_custom_css_class( $css, ' ' ), $this->settings['base'], $atts );
$data_skrollr = ($skrollr ? ' data-top-bottom="transform: translateY(-'.$skrollr_speed.'px);" data-bottom-top="transform: translateY('.$skrollr_speed.'px);"' : '');
// Parallax
if ( $enable_parallax ) {
if ( $parallax_speed == '' ) {
$parallax_speed = 0.2;
}
$parallax_class = ' parallax_bg';
$data = ' data-stellar-background-ratio="'.$parallax_speed.'"';
}
$output .= "\n\t".'<div class="'.$css_class. $parallax_class. $height.'"'.$style.$data_skrollr.' '.$data.'>';
if($fixed == 'true') {
$output .= "\n\t".'<div class="fixed-me">';
}
//$output .= "\n\t\t".'<div class="wpb_wrapper">';
$output .= "\n\t\t\t".wpb_js_remove_wpautop($content);
//$output .= "\n\t\t".'</div> '.$this->endBlockComment('.wpb_wrapper');
if($fixed == 'true') {
$output .= "\n\t".'</div>';
}
$output .= "\n\t".'</div> '.$this->endBlockComment($el_class) . "\n";
echo $output;
}
/**
* @param $atts
* @param null $content
*
* vc_filter: vc_shortcode_content_filter - hook to edit template content
* vc_filter: vc_shortcode_content_filter_after - hook after template is loaded to override output
*
* @return mixed|void
*/
protected function loadTemplate( $atts, $content = null ) {
$output = '';
if ( ! is_null( $content ) ) {
$content = apply_filters( 'vc_shortcode_content_filter', $content, $this->shortcode );
}
$this->findShortcodeTemplate();
if ( $this->html_template ) {
ob_start();
include( $this->html_template );
$output = ob_get_contents();
ob_end_clean();
} else {
trigger_error( sprintf( __( 'Template file is missing for `%s` shortcode. Make sure you have `%s` file in your theme folder.', 'js_composer' ), $this->shortcode, 'wp-content/themes/your_theme/vc_templates/' . $this->shortcode . '.php' ) );
}
return apply_filters( 'vc_shortcode_content_filter_after', $output, $this->shortcode );
}
/**
* @param $atts
* @param $content
*
* @return string
*/
public function contentAdmin( $atts, $content = null ) {
$output = $custom_markup = $width = $el_position = '';
if ( null !== $content ) {
$content = wpautop( stripslashes( $content ) );
}
return $this->setTemplate( $user_template );
}
// Check default place
$default_dir = vc_manager()->getDefaultShortcodesTemplatesDir() . '/';
if ( is_file( $default_dir . $this->getFileName() . '.php' ) ) {
return $this->setTemplate( $default_dir . $this->getFileName() . '.php' );
}
return '';
}
/**
* @param $atts
* @param null $content
*
* @return mixed|void
*/
protected function content( $atts, $content = null ) {
return $this->loadTemplate( $atts, $content );
}
/**
* @param $atts
* @param null $content
*
* vc_filter: vc_shortcode_content_filter - hook to edit template content
* vc_filter: vc_shortcode_content_filter_after - hook after template is loaded to override output
*
* @return mixed|void
*/
protected function loadTemplate( $atts, $content = null ) {
$output = '';
if ( ! is_null( $content ) ) {
$content = apply_filters( 'vc_shortcode_content_filter', $content, $this->shortcode );
}
$this->findShortcodeTemplate();
if ( $this->html_template ) {
ob_start();
include( $this->html_template );
$content = empty( $content ) && ! empty( $atts['content'] ) ? $atts['content'] : $content;
if ( ( $this->isInline() || vc_is_page_editable() ) && method_exists( $this, 'contentInline' ) ) {
$output .= $this->contentInline( $this->atts, $content );
} else {
$this->enqueueDefaultScripts();
$custom_output = VC_SHORTCODE_CUSTOMIZE_PREFIX . $this->shortcode;
$custom_output_before = VC_SHORTCODE_BEFORE_CUSTOMIZE_PREFIX . $this->shortcode; // before shortcode function hook
$custom_output_after = VC_SHORTCODE_AFTER_CUSTOMIZE_PREFIX . $this->shortcode; // after shortcode function hook
// Before shortcode
if ( function_exists( $custom_output_before ) ) {
$output .= $custom_output_before( $this->atts, $content );
} else {
$output .= $this->beforeShortcode( $this->atts, $content );
}
// Shortcode content
if ( function_exists( $custom_output ) ) {
$output .= $custom_output( $this->atts, $content );
} else {
$output .= $this->content( $this->atts, $content );
}
// After shortcode
if ( function_exists( $custom_output_after ) ) {
$output .= $custom_output_after( $this->atts, $content );
} else {
$output .= $this->afterShortcode( $this->atts, $content );
}
}
// Filter for overriding outputs
$output = apply_filters( 'vc_shortcode_output', $output, $this, $this->atts );
return $output;
}
public function enqueueDefaultScripts() {
if ( false === self::$default_scripts_enqueued ) {
wp_enqueue_script( 'wpb_composer_front_js' );
wp_enqueue_style( 'js_composer_front' );
self::$default_scripts_enqueued = true;
}
* @since 4.2
* @return int
*/
function vc_get_initerface_version() {
_deprecated_function( 'vc_get_initerface_version', '4.2 (will be removed in 5.1)' );
return vc_get_interface_version();
}
/**
* Do shortcode single render point
*
* @param $atts
* @param null $content
* @param null $tag
*
* @return string
*/
function vc_do_shortcode( $atts, $content = null, $tag = null ) {
return Vc_Shortcodes_Manager::getInstance()->getElementClass( $tag )->output( $atts, $content );
}
/**
* Return random string
*
* @param int $length
*
* @return string
*/
function vc_random_string( $length = 10 ) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$len = strlen( $characters );
$str = '';
for ( $i = 0; $i < $length; $i ++ ) {
$str .= $characters[ rand( 0, $len - 1 ) ];
}
return $str;
}
* Filters whether to call a shortcode callback.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortcode generation process, returning that value instead.
*
* @since 4.7.0
*
* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
if ( false !== $return ) {
return $return;
}
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
/**
* Filters the output created by a shortcode callback.
*
* @since 4.7.0
*
* @param string $output Shortcode output.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
}
/**
* Search only inside HTML elements for shortcodes and process them.
*
* Any [ or ] characters remaining inside elements will be HTML encoded
* to prevent interference with shortcodes that are outside the elements.
* Assumes $content processed by KSES already. Users with unfiltered_html
* Filters whether to call a shortcode callback.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortcode generation process, returning that value instead.
*
* @since 4.7.0
*
* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
if ( false !== $return ) {
return $return;
}
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
/**
* Filters the output created by a shortcode callback.
*
* @since 4.7.0
*
* @param string $output Shortcode output.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
}
/**
* Search only inside HTML elements for shortcodes and process them.
*
* Any [ or ] characters remaining inside elements will be HTML encoded
* to prevent interference with shortcodes that are outside the elements.
* Assumes $content processed by KSES already. Users with unfiltered_html
if ( false === strpos( $content, '[' ) ) {
return $content;
}
if (empty($shortcode_tags) || !is_array($shortcode_tags))
return $content;
// Find all registered tag names in $content.
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
if ( empty( $tagnames ) ) {
return $content;
}
$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames );
$pattern = get_shortcode_regex( $tagnames );
$content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content );
// Always restore square braces so we don't break things like <!--[if IE ]>
$content = unescape_invalid_shortcodes( $content );
return $content;
}
/**
* Retrieve the shortcode regular expression for searching.
*
* The regular expression combines the shortcode tags in the regular expression
* in a regex class.
*
* The regular expression contains 6 different sub matches to help with parsing.
*
* 1 - An extra [ to allow for escaping shortcodes with double [[]]
* 2 - The shortcode name
* 3 - The shortcode argument list
* 4 - The self closing /
* 5 - The content of a shortcode when it wraps some content.
}
}
return $width;
}
/**
* @param $content
* @param bool $autop
*
* @since 4.2
* @return string
*/
function wpb_js_remove_wpautop( $content, $autop = false ) {
if ( $autop ) { // Possible to use !preg_match('('.WPBMap::getTagsRegexp().')', $content)
$content = wpautop( preg_replace( '/<\/?p\>/', "\n", $content ) . "\n" );
}
return do_shortcode( shortcode_unautop( $content ) );
}
if ( ! function_exists( 'shortcode_exists' ) ) {
/**
* Check if a shortcode is registered in WordPress.
*
* Examples: shortcode_exists( 'caption' ) - will return true.
* shortcode_exists( 'blah' ) - will return false.
*
* @param bool $shortcode
*
* @since 4.2
* @return bool
*/
function shortcode_exists( $shortcode = false ) {
global $shortcode_tags;
if ( ! $shortcode ) {
return false;
}
if ( $has_video_bg ) {
$parallax_image_src = $parallax_image;
} else {
$parallax_image_id = preg_replace( '/[^\d]/', '', $parallax_image );
$parallax_image_src = wp_get_attachment_image_src( $parallax_image_id, 'full' );
if ( ! empty( $parallax_image_src[0] ) ) {
$parallax_image_src = $parallax_image_src[0];
}
}
$wrapper_attributes[] = 'data-vc-parallax-image="' . esc_attr( $parallax_image_src ) . '"';
}
if ( ! $parallax && $has_video_bg ) {
$wrapper_attributes[] = 'data-vc-video-bg="' . esc_attr( $video_bg_url ) . '"';
}
$css_classes[] = 'g-grid';
$css_class = preg_replace( '/\s+/', ' ', apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, implode( ' ', array_filter( $css_classes ) ), $this->settings['base'], $atts ) );
$wrapper_attributes[] = 'class="' . esc_attr( trim( $css_class ) ) . '"';
$output .= '<div ' . implode( ' ', $wrapper_attributes ) . '>';
$output .= wpb_js_remove_wpautop( $content );
$output .= '</div>';
$output .= $after_output;
echo $output;
}
/**
* @param $atts
* @param null $content
*
* vc_filter: vc_shortcode_content_filter - hook to edit template content
* vc_filter: vc_shortcode_content_filter_after - hook after template is loaded to override output
*
* @return mixed|void
*/
protected function loadTemplate( $atts, $content = null ) {
$output = '';
if ( ! is_null( $content ) ) {
$content = apply_filters( 'vc_shortcode_content_filter', $content, $this->shortcode );
}
$this->findShortcodeTemplate();
if ( $this->html_template ) {
ob_start();
include( $this->html_template );
$output = ob_get_contents();
ob_end_clean();
} else {
trigger_error( sprintf( __( 'Template file is missing for `%s` shortcode. Make sure you have `%s` file in your theme folder.', 'js_composer' ), $this->shortcode, 'wp-content/themes/your_theme/vc_templates/' . $this->shortcode . '.php' ) );
}
return apply_filters( 'vc_shortcode_content_filter_after', $output, $this->shortcode );
}
/**
* @param $atts
* @param $content
*
* @return string
*/
public function contentAdmin( $atts, $content = null ) {
$output = $custom_markup = $width = $el_position = '';
if ( null !== $content ) {
$content = wpautop( stripslashes( $content ) );
}
public $nonDraggableClass = 'vc-non-draggable-row';
/**
* @param $settings
*/
public function __construct( $settings ) {
parent::__construct( $settings );
$this->shortcodeScripts();
}
protected function shortcodeScripts() {
wp_register_script( 'vc_jquery_skrollr_js', vc_asset_url( 'lib/bower/skrollr/dist/skrollr.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
wp_register_script( 'vc_youtube_iframe_api_js', '//www.youtube.com/iframe_api', array(), WPB_VC_VERSION, true );
}
protected function content( $atts, $content = null ) {
$prefix = '';
return $prefix . $this->loadTemplate( $atts, $content );
}
/**
* This returs block controls
*/
public function getLayoutsControl() {
global $vc_row_layouts;
$controls_layout = '<span class="vc_row_layouts vc_control">';
foreach ( $vc_row_layouts as $layout ) {
$controls_layout .= '<a class="vc_control-set-column set_columns" data-cells="' . $layout['cells'] . '" data-cells-mask="' . $layout['mask'] . '" title="' . $layout['title'] . '"><i class="vc-composer-icon vc-c-icon-' . $layout['icon_class'] . '"></i></a> ';
}
$controls_layout .= '<br/><a class="vc_control-set-column set_columns custom_columns" data-cells="custom" data-cells-mask="custom" title="' . __( 'Custom layout', 'js_composer' ) . '">' . __( 'Custom', 'js_composer' ) . '</a> ';
$controls_layout .= '</span>';
return $controls_layout;
}
public function getColumnControls( $controls, $extended_css = '' ) {
$output = '<div class="vc_controls vc_controls-row controls_row vc_clearfix">';
$controls_end = '</div>';
$content = empty( $content ) && ! empty( $atts['content'] ) ? $atts['content'] : $content;
if ( ( $this->isInline() || vc_is_page_editable() ) && method_exists( $this, 'contentInline' ) ) {
$output .= $this->contentInline( $this->atts, $content );
} else {
$this->enqueueDefaultScripts();
$custom_output = VC_SHORTCODE_CUSTOMIZE_PREFIX . $this->shortcode;
$custom_output_before = VC_SHORTCODE_BEFORE_CUSTOMIZE_PREFIX . $this->shortcode; // before shortcode function hook
$custom_output_after = VC_SHORTCODE_AFTER_CUSTOMIZE_PREFIX . $this->shortcode; // after shortcode function hook
// Before shortcode
if ( function_exists( $custom_output_before ) ) {
$output .= $custom_output_before( $this->atts, $content );
} else {
$output .= $this->beforeShortcode( $this->atts, $content );
}
// Shortcode content
if ( function_exists( $custom_output ) ) {
$output .= $custom_output( $this->atts, $content );
} else {
$output .= $this->content( $this->atts, $content );
}
// After shortcode
if ( function_exists( $custom_output_after ) ) {
$output .= $custom_output_after( $this->atts, $content );
} else {
$output .= $this->afterShortcode( $this->atts, $content );
}
}
// Filter for overriding outputs
$output = apply_filters( 'vc_shortcode_output', $output, $this, $this->atts );
return $output;
}
public function enqueueDefaultScripts() {
if ( false === self::$default_scripts_enqueued ) {
wp_enqueue_script( 'wpb_composer_front_js' );
wp_enqueue_style( 'js_composer_front' );
self::$default_scripts_enqueued = true;
}
* @since 4.2
* @return int
*/
function vc_get_initerface_version() {
_deprecated_function( 'vc_get_initerface_version', '4.2 (will be removed in 5.1)' );
return vc_get_interface_version();
}
/**
* Do shortcode single render point
*
* @param $atts
* @param null $content
* @param null $tag
*
* @return string
*/
function vc_do_shortcode( $atts, $content = null, $tag = null ) {
return Vc_Shortcodes_Manager::getInstance()->getElementClass( $tag )->output( $atts, $content );
}
/**
* Return random string
*
* @param int $length
*
* @return string
*/
function vc_random_string( $length = 10 ) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$len = strlen( $characters );
$str = '';
for ( $i = 0; $i < $length; $i ++ ) {
$str .= $characters[ rand( 0, $len - 1 ) ];
}
return $str;
}
* Filters whether to call a shortcode callback.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortcode generation process, returning that value instead.
*
* @since 4.7.0
*
* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
if ( false !== $return ) {
return $return;
}
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
/**
* Filters the output created by a shortcode callback.
*
* @since 4.7.0
*
* @param string $output Shortcode output.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
}
/**
* Search only inside HTML elements for shortcodes and process them.
*
* Any [ or ] characters remaining inside elements will be HTML encoded
* to prevent interference with shortcodes that are outside the elements.
* Assumes $content processed by KSES already. Users with unfiltered_html
* Filters whether to call a shortcode callback.
*
* Passing a truthy value to the filter will effectively short-circuit the
* shortcode generation process, returning that value instead.
*
* @since 4.7.0
*
* @param bool|string $return Short-circuit return value. Either false or the value to replace the shortcode with.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
$return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m );
if ( false !== $return ) {
return $return;
}
$content = isset( $m[5] ) ? $m[5] : null;
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
/**
* Filters the output created by a shortcode callback.
*
* @since 4.7.0
*
* @param string $output Shortcode output.
* @param string $tag Shortcode name.
* @param array|string $attr Shortcode attributes array or empty string.
* @param array $m Regular expression match array.
*/
return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m );
}
/**
* Search only inside HTML elements for shortcodes and process them.
*
* Any [ or ] characters remaining inside elements will be HTML encoded
* to prevent interference with shortcodes that are outside the elements.
* Assumes $content processed by KSES already. Users with unfiltered_html
if ( false === strpos( $content, '[' ) ) {
return $content;
}
if (empty($shortcode_tags) || !is_array($shortcode_tags))
return $content;
// Find all registered tag names in $content.
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches );
$tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] );
if ( empty( $tagnames ) ) {
return $content;
}
$content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames );
$pattern = get_shortcode_regex( $tagnames );
$content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content );
// Always restore square braces so we don't break things like <!--[if IE ]>
$content = unescape_invalid_shortcodes( $content );
return $content;
}
/**
* Retrieve the shortcode regular expression for searching.
*
* The regular expression combines the shortcode tags in the regular expression
* in a regex class.
*
* The regular expression contains 6 different sub matches to help with parsing.
*
* 1 - An extra [ to allow for escaping shortcodes with double [[]]
* 2 - The shortcode name
* 3 - The shortcode argument list
* 4 - The self closing /
* 5 - The content of a shortcode when it wraps some content.
}
$nesting_level = $this->nesting_level++;
$this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
$num_args = count( $args );
do {
$this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] );
foreach ( $this->callbacks[ $priority ] as $the_ ) {
if( ! $this->doing_action ) {
$args[ 0 ] = $value;
}
// Avoid the array_slice if possible.
if ( $the_['accepted_args'] == 0 ) {
$value = call_user_func_array( $the_['function'], array() );
} elseif ( $the_['accepted_args'] >= $num_args ) {
$value = call_user_func_array( $the_['function'], $args );
} else {
$value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) );
}
}
} while ( false !== next( $this->iterations[ $nesting_level ] ) );
unset( $this->iterations[ $nesting_level ] );
unset( $this->current_priority[ $nesting_level ] );
$this->nesting_level--;
return $value;
}
/**
* Executes the callback functions hooked on a specific action hook.
*
* @since 4.7.0
*
* @param mixed $args Arguments to pass to the hook callbacks.
}
$nesting_level = $this->nesting_level++;
$this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
$num_args = count( $args );
do {
$this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] );
foreach ( $this->callbacks[ $priority ] as $the_ ) {
if( ! $this->doing_action ) {
$args[ 0 ] = $value;
}
// Avoid the array_slice if possible.
if ( $the_['accepted_args'] == 0 ) {
$value = call_user_func_array( $the_['function'], array() );
} elseif ( $the_['accepted_args'] >= $num_args ) {
$value = call_user_func_array( $the_['function'], $args );
} else {
$value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) );
}
}
} while ( false !== next( $this->iterations[ $nesting_level ] ) );
unset( $this->iterations[ $nesting_level ] );
unset( $this->current_priority[ $nesting_level ] );
$this->nesting_level--;
return $value;
}
/**
* Executes the callback functions hooked on a specific action hook.
*
* @since 4.7.0
*
* @param mixed $args Arguments to pass to the hook callbacks.
$args = func_get_args();
_wp_call_all_hook($args);
}
if ( !isset($wp_filter[$tag]) ) {
if ( isset($wp_filter['all']) )
array_pop($wp_current_filter);
return $value;
}
if ( !isset($wp_filter['all']) )
$wp_current_filter[] = $tag;
if ( empty($args) )
$args = func_get_args();
// don't pass the tag name to WP_Hook
array_shift( $args );
$filtered = $wp_filter[ $tag ]->apply_filters( $value, $args );
array_pop( $wp_current_filter );
return $filtered;
}
/**
* Execute functions hooked on a specific filter hook, specifying arguments in an array.
*
* @since 3.0.0
*
* @see apply_filters() This function is identical, but the arguments passed to the
* functions hooked to `$tag` are supplied using an array.
*
* @global array $wp_filter Stores all of the filters
* @global array $wp_current_filter Stores the list of current filters with the current one last
*
* @param string $tag The name of the filter hook.
* @param array $args The arguments supplied to the functions hooked to $tag.
* @return mixed The filtered value after all hooked functions are applied to it.
}
else {
$template .= '[vc_widget_sidebar sidebar_id="single"]';
}
$template .= '[thb_postvideogrid columns="1" max_items="4" cat="0" style="load-more" items_per_page="4" title="More From Channel"]';
$template .= '[/vc_column]';
$template .= '[/vc_row]';
$child = get_category($cat_id);
//from your child category, grab parent ID
$parent = $child->parent;
//Timber::render(['single-' . $post->ID . '.html.twig', 'single-' . $post->post_type . '.html.twig', 'single.html.twig'], $context);
?>
<?php get_header(); ?>
<?php echo apply_filters('the_content', $template); ?>
<?php get_footer(); ?>
elseif ( is_single() && $template = get_single_template() ) :
elseif ( is_page() && $template = get_page_template() ) :
elseif ( is_singular() && $template = get_singular_template() ) :
elseif ( is_category() && $template = get_category_template() ) :
elseif ( is_tag() && $template = get_tag_template() ) :
elseif ( is_author() && $template = get_author_template() ) :
elseif ( is_date() && $template = get_date_template() ) :
elseif ( is_archive() && $template = get_archive_template() ) :
else :
$template = get_index_template();
endif;
/**
* Filters the path of the current template before including it.
*
* @since 3.0.0
*
* @param string $template The path of the template to include.
*/
if ( $template = apply_filters( 'template_include', $template ) ) {
include( $template );
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
endif;
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once( dirname(__FILE__) . '/wp-load.php' );
// Set up the WordPress query.
wp();
// Load the theme template.
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );