1 . sayfa (Toplam 1 sayfa)
öne çıkan görseli olmayan yazıları listeler
Gönderilme zamanı: Sal Şub 18, 2025 6:15 pm
gönderen muratca61
wordpress için bir uygulama yapalım. bu uygulama öne çıkan görseli olmayan yazıları listelesin. listeleme adetini kullanıcı admin panelinden girebilsin. silme seçeneği ve yeni sekmede düzenleme linki eklensin
Kod:Tümünü seç Kopyala
<?php
/*
Plugin Name: Öne Çıkan Görseli Olmayan Yazılar
Description: Öne çıkan görseli olmayan yazıları listeler, özelleştirilebilir liste adedi ve yönetim seçenekleri sunar.
Version: 1.0
Author: Your Name
*/
// Eklenti ayarlarını oluştur
register_activation_hook(__FILE__, 'fgo_create_settings');
function fgo_create_settings() {
add_option('fgo_post_count', 10);
}
// Admin menü ekle
add_action('admin_menu', 'fgo_add_admin_menu');
function fgo_add_admin_menu() {
add_submenu_page(
'tools.php',
'Öne Çıkan Görseli Olmayan Yazılar',
'Eksik Görsel Yazılar',
'manage_options',
'featuredless-posts',
'fgo_render_admin_page'
);
}
// Admin sayfası içeriği
function fgo_render_admin_page() {
?>
<div class="wrap">
<h1>Öne Çıkan Görseli Olmayan Yazılar</h1>
<!-- Ayarlar Formu -->
<form method="post" action="options.php">
<?php
settings_fields('fgo_settings_group');
do_settings_sections('fgo_settings_group');
?>
<table class="form-table">
<tr valign="top">
<th scope="row">Gösterilecek Yazı Sayısı</th>
<td>
<input type="number" name="fgo_post_count" value="<?php echo esc_attr(get_option('fgo_post_count')); ?>" />
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
<!-- Yazı Listesi -->
<h2>Yazılar</h2>
<?php fgo_display_posts_without_featured(); ?>
</div>
<?php
}
// Ayarları kaydet
add_action('admin_init', 'fgo_register_settings');
function fgo_register_settings() {
register_setting('fgo_settings_group', 'fgo_post_count', 'absint');
}
// Öne çıkan görseli olmayan yazıları göster
function fgo_display_posts_without_featured() {
$post_count = get_option('fgo_post_count', 10);
$args = array(
'post_type' => 'post',
'posts_per_page' => $post_count,
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'NOT EXISTS'
)
)
);
$query = new WP_Query($args);
if ($query->have_posts()) {
echo '<table class="wp-list-table widefat fixed striped">';
echo '<thead>
<tr>
<th>Başlık</th>
<th>Yazar</th>
<th>Tarih</th>
<th>İşlemler</th>
</tr>
</thead>
<tbody>';
while ($query->have_posts()) {
$query->the_post();
echo '<tr>';
echo '<td>' . get_the_title() . '</td>';
echo '<td>' . get_the_author() . '</td>';
echo '<td>' . get_the_date() . '</td>';
echo '<td>';
// Düzenleme linki
echo '<a href="' . get_edit_post_link(get_the_ID()) . '" target="_blank" class="button">Düzenle</a> ';
// Silme butonu
echo '<a href="' . wp_nonce_url(admin_url('tools.php?page=featuredless-posts&delete_post=' . get_the_ID()), 'delete_post_' . get_the_ID()) . '" class="button button-danger">Sil</a>';
echo '</td>';
echo '</tr>';
}
echo '</tbody></table>';
wp_reset_postdata();
} else {
echo '<p>Öne çıkan görseli olmayan yazı bulunamadı.</p>';
}
}
// Silme işlemini işle
add_action('admin_init', 'fgo_handle_post_deletion');
function fgo_handle_post_deletion() {
if (isset($_GET['delete_post']) {
$post_id = intval($_GET['delete_post']);
if (wp_verify_nonce($_REQUEST['_wpnonce'], 'delete_post_' . $post_id) && current_user_can('delete_posts')) {
wp_delete_post($post_id, true);
wp_redirect(admin_url('tools.php?page=featuredless-posts'));
exit;
}
}
}
// Admin stil ve scriptleri
add_action('admin_head', 'fgo_admin_styles');
function fgo_admin_styles() {
echo '<style>
.button-danger {
background: #dc3545;
border-color: #dc3545;
color: white !important;
}
.button-danger:hover {
background: #bb2d3b;
border-color: #bb2d3b;
}
</style>';
}
?>
Re: öne çıkan görseli olmayan yazıları listeler
Gönderilme zamanı: Sal Şub 18, 2025 6:42 pm
gönderen muratca61
Eklenti, ciddi bir hataya neden olduğundan etkinleştirilemedi.
Kod:Tümünü seç Kopyala
<?php
/*
Plugin Name: Öne Çıkan Görseli Olmayan Yazılar
Description: Öne çıkan görseli olmayan yazıları listeler, özelleştirilebilir liste adedi ve yönetim seçenekleri sunar.
Version: 1.1
Author: Your Name
*/
// Eklenti ayarlarını oluştur
register_activation_hook(__FILE__, 'fgo_create_settings');
function fgo_create_settings() {
add_option('fgo_post_count', 10);
}
// Admin menü ekle
add_action('admin_menu', 'fgo_add_admin_menu');
function fgo_add_admin_menu() {
add_submenu_page(
'tools.php',
'Öne Çıkan Görseli Olmayan Yazılar',
'Eksik Görsel Yazılar',
'manage_options',
'featuredless-posts',
'fgo_render_admin_page'
);
}
// Admin sayfası içeriği
function fgo_render_admin_page() {
?>
<div class="wrap">
<h1>Öne Çıkan Görseli Olmayan Yazılar</h1>
<!-- Ayarlar Formu -->
<form method="post" action="options.php">
<?php
settings_fields('fgo_settings_group');
do_settings_sections('fgo_settings_group');
?>
<table class="form-table">
<tr valign="top">
<th scope="row">Gösterilecek Yazı Sayısı</th>
<td>
<input type="number" name="fgo_post_count" value="<?php echo esc_attr(get_option('fgo_post_count')); ?>" />
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
<!-- Yazı Listesi -->
<h2>Yazılar</h2>
<?php fgo_display_posts_without_featured(); ?>
</div>
<?php
}
// Ayarları kaydet
add_action('admin_init', 'fgo_register_settings');
function fgo_register_settings() {
register_setting('fgo_settings_group', 'fgo_post_count', array(
'sanitize_callback' => 'absint',
'default' => 10
));
}
// Öne çıkan görseli olmayan yazıları göster
function fgo_display_posts_without_featured() {
$post_count = get_option('fgo_post_count', 10);
$args = array(
'post_type' => 'post',
'posts_per_page' => $post_count,
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'NOT EXISTS'
)
)
);
$query = new WP_Query($args);
if ($query->have_posts()) {
echo '<table class="wp-list-table widefat fixed striped">';
echo '<thead>
<tr>
<th>Başlık</th>
<th>Yazar</th>
<th>Tarih</th>
<th>İşlemler</th>
</tr>
</thead>
<tbody>';
while ($query->have_posts()) {
$query->the_post();
echo '<tr>';
echo '<td>' . get_the_title() . '</td>';
echo '<td>' . get_the_author() . '</td>';
echo '<td>' . get_the_date() . '</td>';
echo '<td>';
// Düzenleme linki
echo '<a href="' . get_edit_post_link(get_the_ID()) . '" target="_blank" class="button">Düzenle</a> ';
// Silme butonu
echo '<a href="' . wp_nonce_url(admin_url('tools.php?page=featuredless-posts&delete_post=' . get_the_ID()), 'delete_post_' . get_the_ID()) . '" class="button button-danger" onclick="return confirm(\'Bu yazıyı kalıcı olarak silmek istediğinize emin misiniz?\')">Sil</a>';
echo '</td>';
echo '</tr>';
}
echo '</tbody></table>';
wp_reset_postdata();
} else {
echo '<p>Öne çıkan görseli olmayan yazı bulunamadı.</p>';
}
}
// Silme işlemini işle (DÜZELTİLMİŞ KISIM)
add_action('admin_init', 'fgo_handle_post_deletion');
function fgo_handle_post_deletion() {
if (isset($_GET['delete_post'])) { // Parantez hatası düzeltildi
$post_id = intval($_GET['delete_post']);
if (isset($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'delete_post_' . $post_id) && current_user_can('delete_posts')) {
wp_delete_post($post_id, true);
wp_safe_redirect(admin_url('tools.php?page=featuredless-posts'));
exit;
}
}
}
// Admin stil ve scriptleri
add_action('admin_head', 'fgo_admin_styles');
function fgo_admin_styles() {
echo '<style>
.button-danger {
background: #dc3545;
border-color: #dc3545;
color: white !important;
}
.button-danger:hover {
background: #bb2d3b;
border-color: #bb2d3b;
}
</style>';
}
?>
Re: öne çıkan görseli olmayan yazıları listeler
Gönderilme zamanı: Sal Şub 18, 2025 6:50 pm
gönderen muratca61
sil tuşu onay almaksın çöpe taşısın
Kod:Tümünü seç Kopyala
<?php
/*
Plugin Name: Öne Çıkan Görseli Olmayan Yazılar
Description: Öne çıkan görseli olmayan yazıları listeler, özelleştirilebilir liste adedi ve yönetim seçenekleri sunar.
Version: 1.2
Author: Your Name
*/
// Eklenti ayarlarını oluştur
register_activation_hook(__FILE__, 'fgo_create_settings');
function fgo_create_settings() {
add_option('fgo_post_count', 10);
}
// Admin menü ekle
add_action('admin_menu', 'fgo_add_admin_menu');
function fgo_add_admin_menu() {
add_submenu_page(
'tools.php',
'Öne Çıkan Görseli Olmayan Yazılar',
'Eksik Görsel Yazılar',
'manage_options',
'featuredless-posts',
'fgo_render_admin_page'
);
}
// Admin sayfası içeriği
function fgo_render_admin_page() {
?>
<div class="wrap">
<h1>Öne Çıkan Görseli Olmayan Yazılar</h1>
<!-- Ayarlar Formu -->
<form method="post" action="options.php">
<?php
settings_fields('fgo_settings_group');
do_settings_sections('fgo_settings_group');
?>
<table class="form-table">
<tr valign="top">
<th scope="row">Gösterilecek Yazı Sayısı</th>
<td>
<input type="number" name="fgo_post_count" value="<?php echo esc_attr(get_option('fgo_post_count')); ?>" />
</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
<!-- Yazı Listesi -->
<h2>Yazılar</h2>
<?php fgo_display_posts_without_featured(); ?>
</div>
<?php
}
// Ayarları kaydet
add_action('admin_init', 'fgo_register_settings');
function fgo_register_settings() {
register_setting('fgo_settings_group', 'fgo_post_count', array(
'sanitize_callback' => 'absint',
'default' => 10
));
}
// Öne çıkan görseli olmayan yazıları göster
function fgo_display_posts_without_featured() {
$post_count = get_option('fgo_post_count', 10);
$args = array(
'post_type' => 'post',
'posts_per_page' => $post_count,
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'NOT EXISTS'
)
)
);
$query = new WP_Query($args);
if ($query->have_posts()) {
echo '<table class="wp-list-table widefat fixed striped">';
echo '<thead>
<tr>
<th>Başlık</th>
<th>Yazar</th>
<th>Tarih</th>
<th>İşlemler</th>
</tr>
</thead>
<tbody>';
while ($query->have_posts()) {
$query->the_post();
echo '<tr>';
echo '<td>' . get_the_title() . '</td>';
echo '<td>' . get_the_author() . '</td>';
echo '<td>' . get_the_date() . '</td>';
echo '<td>';
// Düzenleme linki
echo '<a href="' . get_edit_post_link(get_the_ID()) . '" target="_blank" class="button">Düzenle</a> ';
// Çöp Kutusuna Taşıma butonu (GÜNCELLENDİ)
echo '<a href="' . wp_nonce_url(admin_url('tools.php?page=featuredless-posts&trash_post=' . get_the_ID()), 'trash_post_' . get_the_ID()) . '" class="button button-danger">Çöpe Taşı</a>';
echo '</td>';
echo '</tr>';
}
echo '</tbody></table>';
wp_reset_postdata();
} else {
echo '<p>Öne çıkan görseli olmayan yazı bulunamadı.</p>';
}
}
// Çöp kutusuna taşıma işlemi (GÜNCELLENDİ)
add_action('admin_init', 'fgo_handle_post_trash');
function fgo_handle_post_trash() {
if (isset($_GET['trash_post'])) {
$post_id = intval($_GET['trash_post']);
if (isset($_REQUEST['_wpnonce']) &&
wp_verify_nonce($_REQUEST['_wpnonce'], 'trash_post_' . $post_id) &&
current_user_can('delete_posts')) {
// Çöp kutusuna taşı
wp_trash_post($post_id);
// Yönlendirme
wp_safe_redirect(admin_url('tools.php?page=featuredless-posts'));
exit;
}
}
}
// Admin stil ve scriptleri
add_action('admin_head', 'fgo_admin_styles');
function fgo_admin_styles() {
echo '<style>
.button-danger {
background: #dc3545;
border-color: #dc3545;
color: white !important;
}
.button-danger:hover {
background: #bb2d3b;
border-color: #bb2d3b;
}
</style>';
}
?>
Re: öne çıkan görseli olmayan yazıları listeler
Gönderilme zamanı: Sal Şub 18, 2025 6:53 pm
gönderen muratca61
uygulama Araçlar menüsü altında
Re: öne çıkan görseli olmayan yazıları listeler
Gönderilme zamanı: Sal Şub 18, 2025 6:56 pm
gönderen muratca61
tamamını silme tuşu
Kod:Tümünü seç Kopyala
<?php
/*
Plugin Name: Öne Çıkan Görseli Olmayan Yazılar
Description: Öne çıkan görseli olmayan yazıları listeler ve toplu yönetim sağlar.
Version: 1.3
Author: Your Name
*/
// Eklenti ayarlarını oluştur
register_activation_hook(__FILE__, 'fgo_create_settings');
function fgo_create_settings() {
add_option('fgo_post_count', 10);
}
// Admin menü ekle
add_action('admin_menu', 'fgo_add_admin_menu');
function fgo_add_admin_menu() {
add_submenu_page(
'tools.php',
'Öne Çıkan Görseli Olmayan Yazılar',
'Eksik Görsel Yazılar',
'manage_options',
'featuredless-posts',
'fgo_render_admin_page'
);
}
// Admin sayfası içeriği
function fgo_render_admin_page() {
?>
<div class="wrap">
<h1>Öne Çıkan Görseli Olmayan Yazılar</h1>
<!-- Toplu İşlem Formu -->
<form method="post" action="<?php echo admin_url('tools.php?page=featuredless-posts'); ?>">
<?php wp_nonce_field('bulk_trash_posts', 'bulk_trash_nonce'); ?>
<input type="hidden" name="bulk_action" value="trash_all">
<?php submit_button('Tüm Listelenenleri Çöpe Taşı', 'delete', 'submit', false); ?>
</form>
<!-- Ayarlar Formu -->
<form method="post" action="options.php">
<?php
settings_fields('fgo_settings_group');
do_settings_sections('fgo_settings_group');
?>
<table class="form-table">
<tr valign="top">
<th scope="row">Gösterilecek Yazı Sayısı</th>
<td>
<input type="number" name="fgo_post_count" value="<?php echo esc_attr(get_option('fgo_post_count')); ?>" />
</td>
</tr>
</table>
<?php submit_button('Ayarları Kaydet'); ?>
</form>
<!-- Yazı Listesi -->
<h2>Yazılar</h2>
<?php fgo_display_posts_without_featured(); ?>
</div>
<?php
}
// Ayarları kaydet
add_action('admin_init', 'fgo_register_settings');
function fgo_register_settings() {
register_setting('fgo_settings_group', 'fgo_post_count', array(
'sanitize_callback' => 'absint',
'default' => 10
));
}
// Öne çıkan görseli olmayan yazıları göster
function fgo_display_posts_without_featured() {
$post_count = get_option('fgo_post_count', 10);
$args = array(
'post_type' => 'post',
'posts_per_page' => $post_count,
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'NOT EXISTS'
)
)
);
$query = new WP_Query($args);
if ($query->have_posts()) {
echo '<table class="wp-list-table widefat fixed striped">';
echo '<thead>
<tr>
<th>Başlık</th>
<th>Yazar</th>
<th>Tarih</th>
<th>İşlemler</th>
</tr>
</thead>
<tbody>';
while ($query->have_posts()) {
$query->the_post();
echo '<tr>';
echo '<td>' . get_the_title() . '</td>';
echo '<td>' . get_the_author() . '</td>';
echo '<td>' . get_the_date() . '</td>';
echo '<td>';
echo '<a href="' . get_edit_post_link(get_the_ID()) . '" target="_blank" class="button">Düzenle</a> ';
echo '<a href="' . wp_nonce_url(admin_url('tools.php?page=featuredless-posts&trash_post=' . get_the_ID()), 'trash_post_' . get_the_ID()) . '" class="button button-danger">Çöpe Taşı</a>';
echo '</td>';
echo '</tr>';
}
echo '</tbody></table>';
wp_reset_postdata();
} else {
echo '<p>Öne çıkan görseli olmayan yazı bulunamadı.</p>';
}
}
// Toplu çöp kutusuna taşıma işlemi
add_action('admin_init', 'fgo_handle_bulk_trash');
function fgo_handle_bulk_trash() {
if (isset($_POST['bulk_action']) && $_POST['bulk_action'] === 'trash_all') {
if (
!isset($_POST['bulk_trash_nonce']) ||
!wp_verify_nonce($_POST['bulk_trash_nonce'], 'bulk_trash_posts') ||
!current_user_can('delete_posts')
) {
wp_die('Yetkiniz yok!');
}
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'fields' => 'ids',
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'NOT EXISTS'
)
)
);
$posts = get_posts($args);
$trashed_count = 0;
foreach ($posts as $post_id) {
if (wp_trash_post($post_id)) {
$trashed_count++;
}
}
add_action('admin_notices', function() use ($trashed_count) {
echo '<div class="notice notice-success is-dismissible">
<p>' . sprintf(_n('%d yazı çöpe taşındı.', '%d yazı çöpe taşındı.', $trashed_count), $trashed_count) . '</p>
</div>';
});
}
}
// Tekil çöp kutusuna taşıma işlemi
add_action('admin_init', 'fgo_handle_post_trash');
function fgo_handle_post_trash() {
if (isset($_GET['trash_post'])) {
$post_id = intval($_GET['trash_post']);
if (
isset($_REQUEST['_wpnonce']) &&
wp_verify_nonce($_REQUEST['_wpnonce'], 'trash_post_' . $post_id) &&
current_user_can('delete_posts')
) {
wp_trash_post($post_id);
wp_safe_redirect(admin_url('tools.php?page=featuredless-posts'));
exit;
}
}
}
// Admin stil ve scriptleri
add_action('admin_head', 'fgo_admin_styles');
function fgo_admin_styles() {
echo '<style>
.button-danger {
background: #dc3545;
border-color: #dc3545;
color: white !important;
}
.button-danger:hover {
background: #bb2d3b;
border-color: #bb2d3b;
}
</style>';
}
?>