首页 > 解决方案 > 未定义的偏移量:Wordpress 中的 1

问题描述

我在 PHP 中收到以下错误

8 未定义的偏移量:1/Applications/MAMP/htdocs/wordpress/wp-content/plugins/wp-plugin/core.php 2178

这是导致它的PHP代码:

if (isset ( $attachements_to_attach ) && count ( $attachements_to_attach ) > 0) {
            
            require_once (ABSPATH . 'wp-admin/includes/image.php');
            
            foreach ( $attachements_to_attach as $attachements_to_attach_single ) {
                
                $file = $attachements_to_attach_single [0];
                $attachment = $attachements_to_attach_single [1];
                $post_id = $id;
                
                if (! function_exists ( 'wp_plugin_filter_image_sizes' )) {
                    function wp_plugin_filter_image_sizes($sizes) {
                        $sizes = array ();
                        return $sizes;
                    }
                }
                
                if (! in_array ( 'OPT_FEED_MEDIA_ALL', $camp_opt )) {
                    add_filter ( 'intermediate_image_sizes_advanced', 'wp_plugin_filter_image_sizes' );
                }
                
                $attach_id = wp_insert_attachment ( $attachment, $file, $post_id );
                $attach_data = wp_generate_attachment_metadata ( $attach_id, $file );
                wp_update_attachment_metadata ( $attach_id, $attach_data );

            } <!-- error in this line
            
            // remove sizes filter
            remove_filter ( 'intermediate_image_sizes_advanced', 'wp_plugin_filter_image_sizes' );
        }

标签: phpwordpressundefinedoffset

解决方案


推荐阅读