我正在使用以下两个函数添加和显示插件中自定义帖子的列内容
add_filter("manage_{$this->post_slug}_posts_columns", array($this, \'browseColumns\'));
add_action("manage_{$this->post_slug}_posts_custom_column", array($this, \'browseCustomColumns\'), 10, 2);
public function browseColumns($columns) {
$new = array();
foreach ($columns as $key => $title) {
if ($key == \'date\') {
$new[\'wp_type\'] = __(\'Type\', self::$lang_slug);
$new[\'wp_cost\'] = __(\'Cost\', self::$lang_slug);
}
$new[$key] = $title;
}
return $new;
}
public function browseCustomColumns($column, $post_id) {
switch ($column) {
case \'wp_type\' :
$type = get_post_meta($post_id, \'_wp_type\', true);
echo empty($type) ? \'-\' : (int) $type;
break;
case \'wp_cost\' :
$cost = PluginClass::getCost($post_id);
echo empty($cost) ? \'-\' : (int) $cost;
break;
}
}
下面是为自定义插件添加仪表板小部件的代码/*
*
* Add a widget to the dashboard.
*
* This function is hooked into the \'add_dashboard_setup\' action below.
*/
add_action(\'wp_dashboard_setup\', array($this, \'add_dashboard_widget\'));
public function add_dashboard_widget() {
add_meta_box(\'idx_dashboard_widget\', \'WP WebinarSystem\', array($this, \'compile_dashboard_widget\'), \'dashboard\', \'normal\', \'high\' );
}
/*
*
* Function to output the contents of our Dashboard Widget.
*
*/
public function compile_dashboard_widget()
{
echo $this->dashboard_widget_html();
$this->loadPluginScripts();
$this->loadFrontScripts();
}
public function dashboard_widget_html()
{
}
我想在Dashboard小部件中显示自定义帖子的类型和成本列。我想知道是否有任何可用的挂钩可以重用,或者我应该继续编写html吗?