我发现我的函数有一种奇怪的行为。
我想把身份证从display_rows()
到column_cb()
, 但问题是程序只传递第一个数字。有什么提示吗?
column_cb()
:
function column_cb($item) {
return sprintf(\'<input type="checkbox" name="id[]" value="%s" />\', $item[\'id\']);
}
display_rows()
:
function display_rows() {
$records = $this->items;
list( $columns, $hidden ) = $this->get_column_info();
if(!empty($records)){
foreach($records as $rec) {
echo \'<tr id="record_\'.$rec->id.\'">\';
foreach ( $columns as $column_name => $column_display_name ) {
$class = "class=\'$column_name column-$column_name\'";
$style = "";
if ( in_array( $column_name, $hidden ) ) $style = \'style="display:none;"\';
$attributes = $class . $style;
$editlink = \'/wp-admin/link.php?action=edit&id=\'.(int)$rec->id;
//Display the cell
switch ( $column_name ) {
case "cb": echo \'<th scope="row" class="check-column">\'.$this->column_cb(stripslashes($rec->id)).\'</th>\'; break;
case "col_name": echo \'<td \'.$attributes.\'><strong>\'.$this->column_title(stripslashes($rec->product_name_name)).\'</strong></td>\'; break;
}
}
echo\'</tr>\';
}
}
}
如果我尝试将值名称传递给
column_title()
.
column_title()
:
function column_title($item){
$actions = array(
\'edit\' => sprintf(\'<a href="?page=%s&action=%s&product=%s">Edit</a>\',$_REQUEST[\'page\'],\'edit\',$item[\'ID\']),
\'delete\' => sprintf(\'<a href="?page=%s&action=%s&product=%s">Delete</a>\',$_REQUEST[\'page\'],\'delete\',$item[\'ID\']),
);
//Return the title contents
return sprintf(\'<a href="#"><b>%1$s</b></a> %3$s\',
/*$1%s*/ $item[\'product_name\'],
/*$2%s*/ $item[\'id\'],
/*$3%s*/ $this->row_actions($actions)
);
}