Wrong upload folder
-
With Block Editor Colors plugin active, when we upload to the media library the file is being put in an old folder (2023/03, current date is 2024/06). This is because get_post(0) is returning the first block_editor_color likely due to global $post polution. We determined this was caused by the WP_Query in CustomColorsService.php set_colors. I see the wp_reset_postdata() after the loop, but for some reason it’s not reseting it. Can you change the WP_Query to get_posts to avoid this issue?
private function set_colors() {
$args = array(
'post_type' => $this->color_cpt_slug,
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => -1
);
$posts = get_posts( $args );
$colors = [];
$disabled_colors = [];
foreach($posts as $post) {
if ( $post->post_status === 'publish' ) {
$colors[ $post->ID ] = [
'name' => $post->post_title,
'slug' => get_post_meta( $post->ID, 'slug', true ),
'color' => get_post_meta( $post->ID, 'color', true ),
];
} else {
$disabled_colors[ $post->ID ] = [
'name' => $post->post_title,
'slug' => get_post_meta( $post->ID, 'slug', true ),
'color' => get_post_meta( $post->ID, 'color', true ),
];
}
}
$this->custom_colors = $colors;
$this->disabled_custom_colors = $disabled_colors;
}
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.