我有两个文件,雇员类和信息类。它应该打印出电话号码,食品地点名称,员工工作地点的地址。尽管我认为它正在打印出以下地址,但它并没有打印出地址:Address @ 4e25154f。我不确定为什么要这样做。
if ( ! class_exists( 'frontendAjaxDropdown' ) ):
class frontendAjaxDropdown
{
/**
* Loading WordPress hooks
*/
function __construct()
{
/**
* Add shortcode function
*/
add_shortcode( 'ajax-dropdown', array($this, 'init_shortocde') );
/**
* Register ajax action
*/
add_action( 'wp_ajax_get_subcat1', array($this, 'getSubCat1') );
/**
* Register ajax action for non loged in user
*/
add_action('wp_ajax_nopriv_get_subcat1', array($this, 'getSubCat1') );
add_action( 'wp_ajax_get_subcat2', array($this, 'getSubCat2') );
/**
* Register ajax action for non loged in user
*/
add_action('wp_ajax_nopriv_get_subcat2', array($this, 'getSubCat2') );
}
/**
* Show parent dropdown for wordpress category and loaded necessarry javascripts
*/
function init_shortocde()
{
wp_dropdown_categories(
'name=main_cat&selected=-1&hierarchical=1&depth=1&hide_empty=0&show_option_none=All Categories'
);
?>
<script type="text/javascript">
(function($){
$("#main_cat").change(function(){
$("#sub_cat1").empty();
$("#sub_cat2").empty();
$.ajax({
type: "post",
url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
data: { action: 'get_subcat1', cat_id1: $("#main_cat option:selected").val() },
beforeSend: function() {$("#loading").fadeIn('slow');},
success: function(data) {
$("#loading").fadeOut('slow');
$("#sub_cat1").append(data);
$("#sub_cat2").empty();
}
});
});
})(jQuery);
</script>
<div id="loading" style="display: none;">Loading...</div>
<div id="sub_cat1"></div>
<?php
}
/**
* AJAX action: Shows dropdown for selected parent
*/
function getSubCat1()
{
wp_dropdown_categories(
"name=sub_cat1&selected=-1&hierarchical=1&depth=1&hide_empty=0&child_of={$_POST['cat_id1']}"
);
}
}
?>
<script type="text/javascript">
(function($){
$("#sub_cat1").change(function(){
$("#sub_cat2").empty();
$.ajax({
type: "post",
url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
data: { action: 'get_subcat2', cat_id2: $("#sub_cat1 option:selected").val() },
beforeSend: function() {$("#loading").fadeIn('slow');},
success: function(data) {
$("#loading").fadeOut('slow');
$("#sub_cat2").append(data);
}
});
});
})(jQuery);
</script>
<div id="loading1" style="display: none;">Loading...</div>
<div id="sub_cat2"></div>
<?php
function getSubCat2()
{
wp_dropdown_categories(
"name=sub_cat2&selected=-1&hierarchical=1&depth=1&hide_empty=0&child_of={$_POST['cat_id1']}+{$_POST['cat_id2']}"
);
die();
}
endif;
new frontendAjaxDropdown();