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

This commit is contained in:
jorge 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; 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 //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(){ // function menu_control_home(){
add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 ); // add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 );
} // }
//
function control_home(){ // function control_home(){
//
global $wpdb; // global $wpdb;
$querystr = " // $querystr = "
SELECT wposts.post_name,wposts.ID, users.user_login, m1.meta_value as inicio, m2.meta_value as orden // SELECT wposts.post_name,wposts.ID, users.user_login, m1.meta_value as inicio, m2.meta_value as orden
FROM $wpdb->posts wposts // FROM $wpdb->posts wposts
INNER JOIN $wpdb->postmeta m1 ON wposts.ID = m1.post_id // 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->postmeta m2 ON wposts.ID = m2.post_id
INNER JOIN $wpdb->users users ON wposts.post_author = users.ID // INNER JOIN $wpdb->users users ON wposts.post_author = users.ID
WHERE (wposts.post_type = 'post' OR wposts.post_type = 'page') // WHERE (wposts.post_type = 'post' OR wposts.post_type = 'page')
AND m1.meta_key = 'Inici' // AND m1.meta_key = 'Inici'
AND m1.meta_value = '1' // AND m1.meta_value = '1'
AND m2.meta_key = 'Ordre_inici' // AND m2.meta_key = 'Ordre_inici'
GROUP BY ID // GROUP BY ID
ORDER BY inicio DESC, CAST(orden AS SIGNED) ASC // ORDER BY inicio DESC, CAST(orden AS SIGNED) ASC
"; // ";
//
echo' <div id="wpbody-content"> // echo' <div id="wpbody-content">
<div class="wrap"><h2>Control Home</h2><br/></div>'; // <div class="wrap"><h2>Control Home</h2><br/></div>';
//
$pageposts = $wpdb->get_results($querystr, OBJECT); // $pageposts = $wpdb->get_results($querystr, OBJECT);
if ($pageposts): // if ($pageposts):
global $post; // global $post;
//
//
echo "<table class=\"wp-list-table widefat fixed posts\" cellspacing=\"0\"> // echo "<table class=\"wp-list-table widefat fixed posts\" cellspacing=\"0\">
<thead> // <thead>
<tr> // <tr>
<th scope='col' width='150' class='manage-column column-slug sortable desc'>Nombre Post</th> // <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'>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'>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'>Inicio</th>
<th scope='col' class='manage-column column-slug sortable desc'>Orden</th> // <th scope='col' class='manage-column column-slug sortable desc'>Orden</th>
</tr> // </tr>
</thead> // </thead>
<tbody id=\"the-list\">"; // <tbody id=\"the-list\">";
//
foreach ($pageposts as $post): // foreach ($pageposts as $post):
$nom = $post->post_name; // $nom = $post->post_name;
$id = $post->ID; // $id = $post->ID;
$autor = $post->user_login; // $autor = $post->user_login;
$inici = $post->inicio; // $inici = $post->inicio;
$ordre = $post->orden; // $ordre = $post->orden;
echo "<tr> // echo "<tr>
<td><a href='post.php?post=$id&action=edit' class=\"row-tittle\">$nom</a></td> // <td><a href='post.php?post=$id&action=edit' class=\"row-tittle\">$nom</a></td>
<td>$id</td> // <td>$id</td>
<td>$autor</td> // <td>$autor</td>
<td>$inici</td> // <td>$inici</td>
<td>$ordre</td> // <td>$ordre</td>
</tr>"; // </tr>";
endforeach; // endforeach;
echo "</tbody></table></div>"; // echo "</tbody></table></div>";
endif; // endif;
//
} // }
//
add_action("admin_menu","menu_control_home"); // 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. // 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 // title= no_link -> no es un link