问题描述
我以新的短代码复制WPBackery画廊的元素,以将其打印在新的customa页面中。但是如何打印图像数组?
我怎么知道使用var_dump带来所有短代码的元素?
希望有人帮助我
编辑
我创建了一个新的Shortcode,以使其适应客户购买的模板。 但是在所说的简码中,我复制了wpbakery中默认存在的一种。 在我的短代码中,添加了对边栏,图片库和视频的选择,我想知道如何在与该短代码相对应的视图中打印该画廊和视频
这是我的简码
$bunch_sc['bunch_service_images_video'] = array(
"name" => __("Images and video",BUNCH_NAME),"base" => "bunch_service_images_video","class" => "","category" => __('Mega Corp',"icon" => 'fa-briefcase','description' => __('Show Images and video.',"params" => array(
array(
'type' => 'dropdown','heading' => esc_html__( 'Choose Sidebar',BUNCH_NAME ),"param_name" => 'sidebar_slug',"value" => megacorp_bunch_get_sidebars( true ),'description' => esc_html__( 'Choose Sidebar.',),array(
'group' => 'image product','type' => 'dropdown','heading' => esc_html__( 'gallery type','js_composer' ),'param_name' => 'type','value' => array(
esc_html__( 'Flex slider fade','js_composer' ) => 'flexslider_fade',esc_html__( 'Flex slider slide','js_composer' ) => 'flexslider_slide',esc_html__( 'Nivo slider','js_composer' ) => 'nivo',esc_html__( 'Image grid','js_composer' ) => 'image_grid','description' => esc_html__( 'Select gallery type.','heading' => esc_html__( 'Auto rotate','param_name' => 'interval','value' => array(
3,5,10,15,esc_html__( 'disable','js_composer' ) => 0,'description' => esc_html__( 'Auto rotate slides each X seconds.','dependency' => array(
'element' => 'type','value' => array(
'flexslider_fade','flexslider_slide','nivo','heading' => esc_html__( 'Image source','param_name' => 'source','value' => array(
esc_html__( 'Media library','js_composer' ) => 'media_library',esc_html__( 'External links','js_composer' ) => 'external_link','std' => 'media_library','description' => esc_html__( 'Select image source.','type' => 'attach_images','heading' => esc_html__( 'Images','param_name' => 'images','value' => '','description' => esc_html__( 'Select images from media library.','dependency' => array(
'element' => 'source','value' => 'media_library','type' => 'exploded_textarea_safe','heading' => esc_html__( 'External links','param_name' => 'custom_srcs','description' => esc_html__( 'Enter external link for each gallery image (Note: divide links with linebreaks (Enter)).','value' => 'external_link','type' => 'textfield','heading' => esc_html__( 'Image size','param_name' => 'img_size','value' => 'thumbnail','description' => esc_html__( 'Enter image size. Example: thumbnail,medium,large,full or other sizes defined by current theme. Alternatively enter image size in pixels: 200x100 (Width x Height). Leave empty to use "thumbnail" size.','param_name' => 'external_img_size','description' => esc_html__( 'Enter image size in pixels. Example: 200x100 (Width x Height).','heading' => esc_html__( 'On click action','param_name' => 'onclick','value' => array(
esc_html__( 'None','js_composer' ) => '',esc_html__( 'Link to large image','js_composer' ) => 'img_link_large',esc_html__( 'Open prettyPhoto','js_composer' ) => 'link_image',esc_html__( 'Open custom link','js_composer' ) => 'custom_link','description' => esc_html__( 'Select action for click action.','std' => 'link_image',array(
'group' => 'video','heading' => esc_html__( 'Widget title','param_name' => 'title','description' => esc_html__( 'Enter text used as widget title (Note: located above content element).','heading' => esc_html__( 'Video link','param_name' => 'link','value' => 'https://vimeo.com/51589652','admin_label' => true,'description' => sprintf( esc_html__( 'Enter link to video (Note: read more about available formats at wordpress %scodex page%s).','<a href="https://codex.wordpress.org/Embeds#Okay.2C_So_What_Sites_Can_I_Embed_From.3F" target="_blank">','</a>' ),'heading' => esc_html__( 'Video width','param_name' => 'el_width','value' => array(
'100%' => '100','90%' => '90','80%' => '80','70%' => '70','60%' => '60','50%' => '50','40%' => '40','30%' => '30','20%' => '20','10%' => '10','description' => esc_html__( 'Select video width (percentage).','heading' => esc_html__( 'Video aspect ration','param_name' => 'el_aspect','value' => array(
'16:9' => '169','4:3' => '43','2.35:1' => '235','description' => esc_html__( 'Select video aspect ratio.',array(
'group' => 'brand logo',)
)
),)
);
在我的service_images_video.PHP中,我想打印画廊和视频,但我想知道如何或需要使用变量。
<?PHP
ob_start() ;
?>
<!-- start service-singel-section -->
<section class="service-singel-section section-padding">
<div class="container">
<div class="row">
<div class="col col-md-8 col-md-push-4">
<div class="service-single-content">
<div>
<img src="<?PHP echo esc_url(wp_get_attachment_url($ser_img)); ?>" alt>
</div>
<div class="title">
<div class="download">
<a href="<?PHP echo esc_url($pdf_link); ?>"><i class="fa fa-file-pdf-o"></i> <?PHP echo wp_kses_post($pdf_title); ?></a>
</div>
</div>
<br>
<br>
<div class="details">
<p><?PHP echowp_get_attachment_image_src( $image_id,'full' );; ?></p>
</div>
</div> <!-- end service content -->
</div> <!-- end col -->
<div class="col col-md-4 col-md-pull-8">
<div class="service-single-sidebar">
<?PHP if ( is_active_sidebar( $sidebar_slug ) ) : ?>
<?PHP dynamic_sidebar( $sidebar_slug ); ?>
<?PHP endif; ?>
</div>
</div>
</div> <!-- end row -->
</div> <!-- end container -->
</section>
<!-- end service-single-section -->
<?PHP
$output = ob_get_contents();
ob_end_clean();
return $output ; ?>
解决方法
您需要安装kint debugging plugin,我建议您自己阅读article
然后使用它查看变量,例如:
function myshortcode($attrs,$content = null) {
d($attrs);
}
add_shortcode('myshortcode','myshortcode');
如果我创建此短代码:(我将插入页面并保存它)
[myshortcode test="1"]
然后我在客户端得到此信息: