moved control home to hangar plugin, menu "Hangar Options"

This commit is contained in:
jorge-vitrubio 2022-07-24 11:42:11 +02:00
parent c03a5f4b94
commit ceef565edd
1 changed files with 63 additions and 61 deletions

View File

@ -136,68 +136,70 @@ function has_subcategories($catt)
endif;
}
// commented on 2022/08/24 moved code to hangar-wp-plugin
//
//construim un panell de control a l'administració per a que vegin les que estan marcades per a sortir a la home
function menu_control_home(){
add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 );
}
function control_home(){
global $wpdb;
$querystr = "
SELECT wposts.post_name,wposts.ID, users.user_login, m1.meta_value as inicio, m2.meta_value as orden
FROM $wpdb->posts wposts
INNER JOIN $wpdb->postmeta m1 ON wposts.ID = m1.post_id
INNER JOIN $wpdb->postmeta m2 ON wposts.ID = m2.post_id
INNER JOIN $wpdb->users users ON wposts.post_author = users.ID
WHERE (wposts.post_type = 'post' OR wposts.post_type = 'page')
AND m1.meta_key = 'Inici'
AND m1.meta_value = '1'
AND m2.meta_key = 'Ordre_inici'
GROUP BY ID
ORDER BY inicio DESC, CAST(orden AS SIGNED) ASC
";
echo' <div id="wpbody-content">
<div class="wrap"><h2>Control Home</h2><br/></div>';
$pageposts = $wpdb->get_results($querystr, OBJECT);
if ($pageposts):
global $post;
echo "<table class=\"wp-list-table widefat fixed posts\" cellspacing=\"0\">
<thead>
<tr>
<th scope='col' width='150' class='manage-column column-slug sortable desc'>Nombre Post</th>
<th scope='col' class='manage-column column-slug sortable desc'>Id</th>
<th scope='col' class='manage-column column-slug sortable desc'>Autor Post</th>
<th scope='col' class='manage-column column-slug sortable desc'>Inicio</th>
<th scope='col' class='manage-column column-slug sortable desc'>Orden</th>
</tr>
</thead>
<tbody id=\"the-list\">";
foreach ($pageposts as $post):
$nom = $post->post_name;
$id = $post->ID;
$autor = $post->user_login;
$inici = $post->inicio;
$ordre = $post->orden;
echo "<tr>
<td><a href='post.php?post=$id&action=edit' class=\"row-tittle\">$nom</a></td>
<td>$id</td>
<td>$autor</td>
<td>$inici</td>
<td>$ordre</td>
</tr>";
endforeach;
echo "</tbody></table></div>";
endif;
}
add_action("admin_menu","menu_control_home");
// function menu_control_home(){
// add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 );
// }
//
// function control_home(){
//
// global $wpdb;
// $querystr = "
// SELECT wposts.post_name,wposts.ID, users.user_login, m1.meta_value as inicio, m2.meta_value as orden
// FROM $wpdb->posts wposts
// INNER JOIN $wpdb->postmeta m1 ON wposts.ID = m1.post_id
// INNER JOIN $wpdb->postmeta m2 ON wposts.ID = m2.post_id
// INNER JOIN $wpdb->users users ON wposts.post_author = users.ID
// WHERE (wposts.post_type = 'post' OR wposts.post_type = 'page')
// AND m1.meta_key = 'Inici'
// AND m1.meta_value = '1'
// AND m2.meta_key = 'Ordre_inici'
// GROUP BY ID
// ORDER BY inicio DESC, CAST(orden AS SIGNED) ASC
// ";
//
// echo' <div id="wpbody-content">
// <div class="wrap"><h2>Control Home</h2><br/></div>';
//
// $pageposts = $wpdb->get_results($querystr, OBJECT);
// if ($pageposts):
// global $post;
//
//
// echo "<table class=\"wp-list-table widefat fixed posts\" cellspacing=\"0\">
// <thead>
// <tr>
// <th scope='col' width='150' class='manage-column column-slug sortable desc'>Nombre Post</th>
// <th scope='col' class='manage-column column-slug sortable desc'>Id</th>
// <th scope='col' class='manage-column column-slug sortable desc'>Autor Post</th>
// <th scope='col' class='manage-column column-slug sortable desc'>Inicio</th>
// <th scope='col' class='manage-column column-slug sortable desc'>Orden</th>
// </tr>
// </thead>
// <tbody id=\"the-list\">";
//
// foreach ($pageposts as $post):
// $nom = $post->post_name;
// $id = $post->ID;
// $autor = $post->user_login;
// $inici = $post->inicio;
// $ordre = $post->orden;
// echo "<tr>
// <td><a href='post.php?post=$id&action=edit' class=\"row-tittle\">$nom</a></td>
// <td>$id</td>
// <td>$autor</td>
// <td>$inici</td>
// <td>$ordre</td>
// </tr>";
// endforeach;
// echo "</tbody></table></div>";
// endif;
//
// }
//
// add_action("admin_menu","menu_control_home");
// Filtre que modifica la funcio que mostra els menús, per poder seleccionar mitjançant el camp title, quines seràn links i quines no.
// title= no_link -> no es un link