WordPress
- 20 ответов
- 0 вопросов
2
Вклад в тег
<?php
woocommerce_template_single_add_to_cart();
?>
<?php
add_filter('bulk_actions-edit-post', function($bulk_actions) {
$bulk_actions['change-to-published'] = __('Change to published', 'txtdomain');
return $bulk_actions;
});
add_filter('handle_bulk_actions-edit-post', function($redirect_url, $action, $post_ids) {
if ($action == 'change-to-published') {
foreach ($post_ids as $post_id) {
wp_update_post([
'ID' => $post_id,
'post_status' => 'publish'
]);
}
$redirect_url = add_query_arg('changed-to-published', count($post_ids), $redirect_url);
}
return $redirect_url;
}, 10, 3);
add_action('admin_notices', function() {
if (!empty($_REQUEST['changed-to-published'])) {
$num_changed = (int) $_REQUEST['changed-to-published'];
printf('<div id="message" class="updated notice is-dismissable"><p>' . __('Published %d posts.', 'txtdomain') . '</p></div>', $num_changed);
}
});
add_filter('handle_bulk_actions-edit-post', function($redirect_url, $action, $post_ids) {
if ($action == 'mark-as-verified') {
foreach ($post_ids as $post_id) {
update_post_meta($post_id, 'verified', '1');
}
$redirect_url = add_query_arg('mark-as-verified', count($post_ids), $redirect_url);
}
return $redirect_url;
}, 10, 3);