$result = mysqli_multi_query($mysqli_new_final, $query);
add_action( 'wp_ajax_del_old_img_', 'del_old_img_' );
function del_old_img_($id){
set_time_limit(0);
$product_id = (int)$id;
$product = new WC_product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $id )
{
$res = wp_delete_attachment( $id, true );
//удаляем из галереи
}
$post_thumbnail_id = get_post_thumbnail_id( $product_id );
$res = wp_delete_attachment( $post_thumbnail_id, true );
//и из самого поста.
return false;
}
add_action( 'wp_ajax_del_old_img_', 'del_old_img_' );
function del_old_img_(){
set_time_limit(0);
$product_id = (int)'27923';
$product = new WC_product($product_id);
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $id )
{
$res = wp_delete_attachment( $id, true );
//удаляем из галереи
}
$post_thumbnail_id = get_post_thumbnail_id( $product_id );
$res = wp_delete_attachment( $post_thumbnail_id, true );
//и из самого поста.
return false;
}
function post_media( $post_id ) {
$args = array(
'post_parent' => $post_id,
'post_type' => 'attachment',
'post_status' => 'any',
'post_mime_type' => 'image',
'posts_per_page' => -1,
);
if ( $attachments = get_children( $args ) ) {
return $attachments;
}
return [];
}
( ! ) Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until thewp_enqueue_scripts
,admin_enqueue_scripts
, orlogin_enqueue_scripts
hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in C:\Users\Victor\Desktop\WP\apps\wordpress\htdocs\wp-includes\functions.php on line 4137
(user переименовал в login)