';
}
// Sporcuları listele
global $wpdb;
$table_name = $wpdb->prefix . 'tmpk_sportspage';
$sports = $wpdb->get_results("SELECT * FROM $table_name order by sira asc");
if ($sports) {
echo '
';
}
}
function turkticaret_about_page()
{
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Process the form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
error_reporting(E_ALL);
ini_set('display_errors', 1);
$content = wp_kses_post($_POST['about_content']);
// Save to the database
global $wpdb;
$table_name = $wpdb->prefix . 'tmpk_aboutpage';
// Update existing content or insert new
if ($wpdb->get_var("SELECT COUNT(*) FROM $table_name WHERE id = 1") > 0) {
$wpdb->update($table_name, array('content' => $content), array('id' => 1));
} else {
$wpdb->insert($table_name, array('content' => $content));
}
echo '
Hakkında sayfası güncellendi.
';
}
?>
Hakkında
prefix . 'tmpk_sportspage';
$sport_id = intval($_GET['sport_id']);
// Silme işlemini yap
$wpdb->delete($table_name, array('id' => $sport_id));
// Başarı mesajı
wp_redirect(admin_url('admin.php?page=tmpk_sportspage'));
exit;
}
add_action('admin_post_delete_sport', 'turkticaret_delete_sport');
// Sporcu düzenleme işlemini yönet
function turkticaret_edit_sport()
{
global $wpdb;
// Check for nonce and validate the request
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'edit_sport')) {
wp_die('Güvenlik kontrolü başarısız!');
}
// Validate and sanitize input data
$sport_id = isset($_POST['sport_id']) ? intval($_POST['sport_id']) : 0;
$name = sanitize_text_field($_POST['sport_name']);
$gender = intval($_POST['sport_gender']);
$baglanti = sanitize_text_field($_POST['sport_baglanti']);
$sira = sanitize_text_field($_POST['sport_sira']);
// Initialize image path
$image_path = '';
// Handle image upload if a new image is provided
if (!empty($_FILES['sport_image']['name'])) {
$image = $_FILES['sport_image'];
// Define the target directory for uploads
$upload_dir = wp_upload_dir();
$target_dir = plugin_dir_path(__FILE__) . 'assets/uploads/';
// Create the directory if it doesn't exist
if (!file_exists($target_dir)) {
mkdir($target_dir, 0755, true);
}
// Move the uploaded file to the target directory
$target_file = $target_dir . basename($image['name']);
move_uploaded_file($image['tmp_name'], $target_file);
// Adjust the file path to be relative to the wp-content directory
$split_path = explode('/wp-content', $target_file, 2);
if (isset($split_path[1])) {
$image_path = 'wp-content' . $split_path[1];
}
} else {
// If no new image is uploaded, retain the current image path
$table_name = $wpdb->prefix . 'tmpk_sportspage';
$current_image = $wpdb->get_var($wpdb->prepare("SELECT image FROM $table_name WHERE id = %d", $sport_id));
$image_path = $current_image;
}
// Update the database record
$table_name = $wpdb->prefix . 'tmpk_sportspage';
$wpdb->update(
$table_name,
array(
'name' => $name,
'image' => $image_path,
'gender' => $gender,
'baglanti' => $baglanti,
'sira' => $sira
),
array('id' => $sport_id)
);
// Redirect back to the sports list page
wp_redirect(admin_url('admin.php?page=tmpk_sportspage'));
exit;
}
add_action('admin_post_edit_sport', 'turkticaret_edit_sport');
function show_edit_sport_form()
{
global $wpdb;
$sport_id = isset($_GET['sport_id']) ? intval($_GET['sport_id']) : 0;
$table_name = $wpdb->prefix . 'tmpk_sportspage';
$sport = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE id = %d", $sport_id));
if ($sport) {
?>
Sporcuyu Düzenle
Sporcu bulunamadı.';
}
}
add_action('admin_menu', function () {
add_submenu_page(null, 'Sporcuyu Düzenle', 'Sporcuyu Düzenle', 'manage_options', 'edit_sport', 'show_edit_sport_form');
});
// Tesis silme işlemini yönet
function turkticaret_delete_facility()
{
if (!isset($_GET['facility_id']) || !current_user_can('manage_options')) {
wp_die('Yetkisiz işlem');
}
global $wpdb;
$table_name = $wpdb->prefix . 'tmpk_tesisler';
$facility_id = intval($_GET['facility_id']);
// Silme işlemini yap
$wpdb->delete($table_name, array('id' => $facility_id));
// Başarı mesajı
wp_redirect(admin_url('admin.php?page=tmpk_tesisler'));
exit;
}
add_action('admin_post_delete_sport', 'turkticaret_delete_sport');
// Tesis düzenleme işlemini yönet
function turkticaret_edit_facility()
{
global $wpdb;
// Check for nonce and validate the request
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'edit_facility')) {
wp_die('Güvenlik kontrolü başarısız!');
}
// Validate and sanitize input data
$facility_id = isset($_POST['facility_id']) ? intval($_POST['facility_id']) : 0;
$image = sanitize_text_field($_POST['facility_image']);
$name = sanitize_text_field($_POST['facility_name']);
$baglanti = sanitize_text_field($_POST['facility_baglanti']);
$sira = sanitize_text_field($_POST['facility_sira']);
// Initialize image path
// $image_path = '';
// // Handle image upload if a new image is provided
// if (!empty($_FILES['facility_image']['name'])) {
// $image = $_FILES['facility_image'];
// // Define the target directory for uploads
// $upload_dir = wp_upload_dir();
// $target_dir = plugin_dir_path(__FILE__) . 'assets/uploads/';
// // Create the directory if it doesn't exist
// if (!file_exists($target_dir)) {
// mkdir($target_dir, 0755, true);
// }
// // Move the uploaded file to the target directory
// $target_file = $target_dir . basename($image['name']);
// move_uploaded_file($image['tmp_name'], $target_file);
// // Adjust the file path to be relative to the wp-content directory
// $split_path = explode('/wp-content', $target_file, 2);
// if (isset($split_path[1])) {
// $image_path = 'wp-content' . $split_path[1];
// }
// } else {
// // If no new image is uploaded, retain the current image path
// $table_name = $wpdb->prefix . 'tmpk_facilityspage';
// $current_image = $wpdb->get_var($wpdb->prepare("SELECT image FROM $table_name WHERE id = %d", $facility_id));
// $image_path = $current_image;
// }
// Update the database record
$table_name = $wpdb->prefix . 'tmpk_tesisler';
$wpdb->update(
$table_name,
array(
'name' => $name,
// 'image' => $image_path,
'image' => $image,
'baglanti' => $baglanti,
'sira' => $sira
),
array('id' => $facility_id)
);
// Redirect back to the facilitys list page
wp_redirect(admin_url('admin.php?page=tmpk_tesislerpage'));
exit;
}
add_action('admin_post_edit_facility', 'turkticaret_edit_facility');
function show_edit_facility_form()
{
global $wpdb;
$facility_id = isset($_GET['facility_id']) ? intval($_GET['facility_id']) : 0;
$table_name = $wpdb->prefix . 'tmpk_tesisler';
$facility = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE id = %d", $facility_id));
if ($facility) {
?>
Tesisi Düzenle
Tesis bulunamadı.';
}
}
add_action('admin_menu', function () {
add_submenu_page(null, 'Tesisi Düzenle', 'Tesisi Düzenle', 'manage_options', 'edit_facility', 'show_edit_facility_form');
});
// Plugin etkinleştirildiğinde burası çalışacaktır
function turkticaret_paris_plugin_activate()
{
global $wpdb;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
// Sporcuları sekmesi
$table_name = $wpdb->prefix . 'tmpk_sportspage';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
image varchar(255) NOT NULL,
baglanti varchar(255),
sira int,
gender int NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
dbDelta($sql);
// Hakkında sekmesi
$table_name = $wpdb->prefix . 'tmpk_aboutpage';
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
content TEXT NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
dbDelta($sql);
// Tesisler sekmesi
$table_name = $wpdb->prefix . 'tmpk_tesisler';
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
image varchar(255) NOT NULL,
glink varchar(255) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
dbDelta($sql);
}
register_activation_hook(__FILE__, 'turkticaret_paris_plugin_activate');
// Plugin devredışı bırakılınca yapılan işlemler
function turkticaret_paris_plugin_deactivate()
{
global $wpdb;
// Sporcuları tablosunu sil
// $table_name = $wpdb->prefix . 'tmpk_sportspage';
// $sql = "DROP TABLE IF EXISTS $table_name;";
// $wpdb->query($sql);
// Hakkında tablosunu sil
$table_name = $wpdb->prefix . 'tmpk_aboutpage';
$sql = "DROP TABLE IF EXISTS $table_name;";
$wpdb->query($sql);
// Tesisler tablosunu sil
// $table_name = $wpdb->prefix . 'tmpk_tesisler';
// $sql = "DROP TABLE IF EXISTS $table_name;";
// $wpdb->query($sql);
flush_rewrite_rules();
}
register_deactivation_hook(__FILE__, 'turkticaret_paris_plugin_deactivate');
?>