added shortcode for posts update
This commit is contained in:
@@ -103,16 +103,16 @@ function mp_ljdp_map() {
|
||||
*/
|
||||
|
||||
$events = mp_get_published_events();
|
||||
//mp_console_log("php events:");
|
||||
//mp_console_log($events);
|
||||
mp_console_log("php events:");
|
||||
mp_console_log($events);
|
||||
|
||||
$locations = mp_sort_events($events);
|
||||
//mp_console_log("php locations:");
|
||||
//mp_console_log($locations);
|
||||
mp_console_log("php locations:");
|
||||
mp_console_log($locations);
|
||||
|
||||
$filters = mp_get_filters($events);
|
||||
//mp_console_log("php filters:");
|
||||
//mp_console_log($filters);
|
||||
mp_console_log("php filters:");
|
||||
mp_console_log($filters);
|
||||
|
||||
$to_add = array(
|
||||
"locations" => $locations,
|
||||
@@ -147,6 +147,48 @@ add_shortcode('lejourduprof_map', 'mp_ljdp_map');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* re-publish posts
|
||||
*/
|
||||
|
||||
function mp_update_publish() {
|
||||
$post_args = array(
|
||||
'numberposts' => 1,
|
||||
//'post_status' => 'draft',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'post',
|
||||
);
|
||||
$post_list = get_posts($post_args);
|
||||
foreach ($post_list as $post) {
|
||||
wp_update_post(array(
|
||||
'ID' => $post->ID,
|
||||
//'post_status' => 'draft',
|
||||
'post_status' => 'publish',
|
||||
));
|
||||
};
|
||||
}
|
||||
add_action( 'admin_post_update_publish', 'mp_update_publish' );
|
||||
add_action( 'admin_post_nopriv_update_publish', 'mp_update_publish' );
|
||||
// https://developer.wordpress.org/reference/hooks/admin_post_action/
|
||||
// https://wordpress.stackexchange.com/questions/309440/wordpress-plugin-how-to-run-function-when-button-is-clicked
|
||||
function mp_add_update_button() {
|
||||
$content = '
|
||||
<br />
|
||||
<p>cliquez sur ce bouton pour mettre a jour toutes les publications<p>
|
||||
<p>une nouvelle page vide va s\'ouvrir dans un nouvel onglet, vous pouvez la fermer<p>
|
||||
<form action="'.admin_url('admin-post.php').'" method="post" target="_blank">
|
||||
<input type="hidden" name="action" value="update_publish">
|
||||
<input type="submit" value="mettre a jour">
|
||||
</form>
|
||||
<br />
|
||||
';
|
||||
return $content;
|
||||
}
|
||||
add_shortcode('ljdp_update_publish', 'mp_add_update_button');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* errors map
|
||||
*/
|
||||
@@ -172,6 +214,9 @@ function post_published_coordinates($id, $post) {
|
||||
if ( ! add_post_meta( $id, 'location', $location, true ) )
|
||||
update_post_meta( $id, 'location', $location );
|
||||
|
||||
if ( ! add_post_meta( $id, 'test', "ok", true ) )
|
||||
update_post_meta( $id, 'test', "ok" );
|
||||
|
||||
}
|
||||
add_action( 'publish_post', 'post_published_coordinates', 10, 2 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user