prefix . 'tmpk_sportspage'; //$results = $wpdb->get_results("SELECT COUNT(*) as cnt FROM $table_name;"); $sum_sporcu[] = 94; //$sum_sporcu[] = $results[0]->cnt; // Kadın sporcu sayısı //$table_name = $wpdb->prefix . 'tmpk_sportspage'; //$results = $wpdb->get_results("SELECT COUNT(*) as cnt FROM $table_name WHERE gender=0;"); $sum_sporcu[] = 48; //$sum_sporcu[] = $results[0]->cnt; // Erkek sporcu sayısı // = $wpdb->prefix . 'tmpk_sportspage'; //$results = $wpdb->get_results("SELECT COUNT(*) as cnt FROM $table_name WHERE gender=1;"); $sum_sporcu[] = 46; //$sum_sporcu[] = $results[0]->cnt; $table_name = $wpdb->prefix . 'tmpk_sportspage'; $sporcular = $wpdb->get_results("SELECT * FROM $table_name"); $table_name = $wpdb->prefix . 'tmpk_tesisler'; $tesisler = $wpdb->get_results("SELECT * FROM $table_name"); // Hakkında sayfası $table_name = $wpdb->prefix . 'tmpk_aboutpage'; $about_page = $wpdb->get_row("SELECT * FROM $table_name WHERE id = 1"); $about_content = $about_page ? $about_page->content : ''; if($path=='blog'){ echo 'BURASI ANASAYFA'; } include($file); exit; // Sayfa çıktıktan sonra WordPress akışını durdurun } else { wp_die('404 Not Found'); } } } add_action('template_redirect', 'turkticaret_custom_page_template'); function tmpk_add_admin_menu() { // Ana menüyü ekle add_menu_page( 'Paris 2024', 'Paris 2024', 'manage_options', 'tmpk_plugin', 'turkticaret_plugin_page', 'dashicons-admin-generic', 20 ); // Alt menüyü ekle add_submenu_page( 'tmpk_plugin', 'Sporcular', 'Sporcular', 'manage_options', 'tmpk_sportspage', 'turkticaret_sports_page' ); // Alt menüyü ekle add_submenu_page( 'tmpk_plugin', 'Tesisler', 'Tesisler', 'manage_options', 'tmpk_tesislerpage', 'turkticaret_tesisler_page' ); // Alt menüyü ekle add_submenu_page( 'tmpk_plugin', 'Hakkında', 'Hakkında', 'manage_options', 'tmpk_aboutpage', 'turkticaret_about_page' ); } add_action('admin_menu', 'tmpk_add_admin_menu'); // Ana menü sayfasının içeriğini göster function turkticaret_plugin_page() { ?>

TMPK Plugin Ana Sayfa

Burada TMPK Plugin ile ilgili genel bilgiler yer alacak.

Sporcular

Sporcu Resmi
Adı Soyadı
Bağlantı Linki
Cinsiyet
Sıra
prefix . 'tmpk_sportspage'; $wpdb->insert($table_name, array( 'name' => $name, 'image' => $target_file, 'gender' => $gender, 'baglanti' => $baglanti, 'sira' => $sira )); echo '

Sporcu eklendi.

'; } // 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 '

Sporcular

'; echo ''; echo ''; echo ''; foreach ($sports as $sport) { $gender_text = $sport->gender == 0 ? 'Kadın' : 'Erkek'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; echo '
ResimAdı SoyadıBağlantıCinsiyetSıraSilDüzenle
' . esc_html($sport->name) . '' . esc_html($sport->baglanti) . '' . esc_html($gender_text) . '' . esc_html($sport->sira) . 'SilDüzenle
'; } } // Tesisler // Tesisler ekleme sayfası ve işlemleri function turkticaret_tesisler_page() { global $turkticaret_prefix; ?>

Tesisler

Görsel Linki
Adı
Bağlantı
Sıra
prefix . 'tmpk_tesisler'; $wpdb->insert($table_name, array( 'name' => $name, // 'image' => $target_file, 'image' => $image, 'glink' => $glink, 'sira' => $sira )); echo '

Tesis eklendi.

'; } // Tesisleri listele global $wpdb; $table_name = $wpdb->prefix . 'tmpk_tesisler'; $facilities = $wpdb->get_results("SELECT * FROM $table_name"); if ($facilities) { echo '

Tesisler

'; echo ''; echo ''; echo ''; foreach ($facilities as $facility) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; echo '
GörselAdıBağlantıSıraSilDüzenle
' . esc_html($facility->name) . 'Bağlantı' . esc_html($facility->sira) . 'SilDüzenle
'; } } function turkticaret_about_page() { global $turkticaret_prefix; wp_enqueue_script('tab-lib', 'https://atakanargn.github.io/prodseen-tab-library/js/prs-tab.min.js', array('jquery'), null, true); // Process the form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { $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_aboutpage'; $about_page = $wpdb->get_row("SELECT * FROM $table_name WHERE id = 1"); $content = $about_page ? $about_page->content : ''; ?>
  • Editor
  • Resim yükle

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

Mevcut Sporcu Resmi image): ?>

Resim yüklenmemiş.

Yeni Sporcu Resmi

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

Mevcut Tesis Resmi image): ?>

Resim yüklenmemiş.

Yeni Tesis Resmi

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'); ?>