在我的函数中激活插件我添加到插件表默认行:$args = array( "setting_name" => 'first', "setting_value" => 'value' ); $args2 = array( "setting_name" => 'second', "setting_value" => 'value' ); $args3 = array( "setting_name" => 'third', "setting_value" => 'value' ); $wpdb->insert($wpdb->prefix."x", $args); $wpdb->insert($wpdb->prefix."y", $args2); $wpdb->insert($wpdb->prefix."z", $args2);如何缩短此代码?谢谢!
1 回答
SMILET
TA贡献1796条经验 获得超4个赞
$settings = array('x' => array(
"setting_name" => 'first',
"setting_value" => 'value'
),
'y' => array(
"setting_name" => 'second',
"setting_value" => 'value'
),
'z' => array(
"setting_name" => 'third',
"setting_value" => 'value'
)
);
foreach($settings as $table => $args){
$wpdb->insert($wpdb->prefix.$table, $args);
}
- 1 回答
- 0 关注
- 78 浏览
添加回答
举报
0/150
提交
取消