سلام وقت بخیر
داخل عکسی که آپلود کردم نوشته خط 31مشکل داری
<?php
add_action('admin_menu', 'wp_apis_register_menus');
function wp_apis_register_menus()
{
add_menu_page(
'پلاگین سفارشی',
'پلاگین سفارشی',
'manage_options',
'wp-menu-admin',
'wp_apis_main_menu_handler'
);
add_submenu_page(
'wp-menu-admin',
'تنظیمات',
'تنظیمات',
'manage_options',
'wp_apis_general',
'wp_apis_general_page'
);
}
function wp_apis_main_menu_handler()
{
global $wpdb;
$action = $_GET['action'];
if ($action == "delete") {
$item = intval($_GET['item']);
if ($item > 0) {
$wpdb->delete($wpdb->prefix.'sample', ['id' => $item]);
}
}
if ($action == "add") {
if (isset($_post['saveData'])) {
var_dump($_post);
$wpdb->insert($wpdb->prefix . 'sample', [
'firstName' => $_post['firstName'],
'lastName' => $_post['lastName'],
'mobile' => $_post['mobile']
]);
}
include WP_APIS_TPL . 'admin/menus/add.php';
} else {
$samples = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}sample");
include WP_APIS_TPL . 'admin/menus/main.php';
}
}
function wp_apis_general_page()
{
if (isset($_POST['savesetting'])) {
// $is_plugin_active = isset($_POST['is_plugin_active']) ? 1 : 0;
// add_option('wp_apis_is_actiove',$is_plugin_active);
if (isset($_POST['is_plugin_active'])) {
update_option('wp_apis_is_active', 1);
} else {
delete_option('wp_apis_is_active', 0);
}
}
$current_plugin_status = get_option('wp_apis_is_active', 0);
include WP_APIS_TPL . 'admin/menus/general.php';
}
<div class="wrap">
<h1>لیست اطلاعات</h1>
<a href=" <?php echo add_query_arg(['action' =>'add']); ?> ">ثبت داده جدید</a>
<table class="widefat">
<tr>
<th>شناسه</th>
<th>نام</th>
<th>نام خانوادگی</th>
<th>موبایل</th>
<th>عملیات</th>
</tr>
<Tbody>
<?php foreach($samples as $sample): ?>
<tr>
<td> <?php echo $sample->id; ?> </td>
<td> <?php echo $sample->firstName; ?> </td>
<td> <?php echo $sample->lastName; ?> </td>
<td> <?php echo $sample->mobile; ?> </td>
<td>
<a href="<?php echo add_query_arg(['action'=>'delete','item' => $sample->id ]) ?>">حدف کردن</a>
</td>
<?php endforeach;?>
</tr>
</Tbody>
</table>
</div>
<div class="wrap">
<h1> اضافه کردن آیتم جدید </h1>
<form method="POST">
<table class="form-table">
<tr valign="top">
<th scope="row">نام </th>
<td>
<input type="text" name="firstName"/>
</td>
</tr>
<tr valign="top">
<th scope="row">نام خانوادگی </th>
<td>
<input type="text" name="lastName"/>
</td>
</tr>
<tr valign="top">
<th scope="row">شماره همراه </th>
<td>
<input type="text" name="mobile"/>
</td>
</tr>
<tr valign="top">
<th scope="row"> </th>
<td>
<input type="submit" class="button" name="saveData" value="ذخیره سازی"/>
</td>
</tr>
</table>
</form>
</div>
ممنون میشم راهنمایی بفرمایید