只是想知道我目前的引擎盖使用情况如何?
例如,我试图在单个产品页面产品描述后输出我的html。然而没有任何显示我很确定我从参考文献中得到了正确的钩子。
由于
function plugin_output() {
loadAssets();
$html = '
<div id="product-configurator">
<div id="configurator-menu-items">
<div id="appLogo">
<img src="'.plugins_url("/product-configurator/app_logo.png").'" alt="Shades By Us" />
</div>
<div id="configurator-tab1" class="configurator-tab" data-page="configurator-panel1">Shape</div>
<div id="configurator-tab2" class="configurator-tab" data-page="configurator-panel2">Size</div>
<div id="configurator-tab3" class="configurator-tab" data-page="configurator-panel3">Color</div>
<div id="configurator-variables" class="variables-current">
<p class="variables-title">Your Selection</p>
<ul>
<li class="configurator-variables">Shape: <span id="current_model"></span></li>
<li class="configurator-variables">Colors: </li>
<li class="configurator-variables">Size: </li>
<li class="configurator-variables">Quantity: </li>
<li class="configurator-variables">Total Price: </li>
</ul>
</div>
</div>
<div id="configurator-panels">
<div class="configurator-panel" id="configurator-panel1">
<canvas class="product-canvas"></canvas>
<div id="defaultModels">
<div class="modelBtn modelBtn1" id="model1"></div>
<div class="modelBtn modelBtn2" id="model2"></div>
<div class="modelBtn modelBtn3" id="model3"></div>
<div class="modelBtn modelBtn4" id="model4"></div>
</div>
</div>
<div class="configurator-panel" id="configurator-panel2">
<canvas class="product-canvas"></canvas>
<div id="sizeSelection">
<div class="sizeSelector" id="selectorSize1">
<ul>
<li class="sizeSelectTitle">Bottom</li>
<li class="sizeSelect sizeBottom" id="size1">T 30 / 8 40</li>
<li class="sizeSelect sizeBottom" id="size2">T 40 / 8 50</li>
<li class="sizeSelect sizeBottom" id="size3">T 50 / 8 60</li>
<li class="sizeSelect sizeBottom" id="size4">T 70 / 8 80</li>
</ul>
</div>
<div class="sizeSelector" id="selectorSize2">
<ul>
<li class="sizeSelectTitle">Height</li>
<li class="sizeSelect sizeHeight" id="size5">30 cm</li>
<li class="sizeSelect sizeHeight" id="size6">40 cm</li>
<li class="sizeSelect sizeHeight" id="size7">50 cm</li>
<li class="sizeSelect sizeHeight" id="size8">70 cm</li>
</ul>
</div>
</div>
</div>
<div class="configurator-panel" id="configurator-panel3">
<canvas class="product-canvas"></canvas>
</div>
<a id="next-btn-configurator" onclick="">Move On</a>
</div>
</div>
';
return $html;
}
add_shortcode("product-configurator", "plugin_handler");
do_action( 'woocommerce_after_single_product_summary', 'plugin_output' );
答案 0 :(得分:0)
你需要这样做:
function plugin_output() {
loadAssets();
$html = 'content here...';
echo $html;
}
add_action('woocommerce_after_single_product_summary', 'plugin_output');
注意使用add_action()而不是do_action()。
这同样适用于过滤器挂钩,除了您将从处理程序返回值:
function my_handler($value) {
// Do something with $value here...
return $value;
}
add_filter('some_filter_hook', 'my_handler');