$ref) { echo " - Image " . ($index + 1) . ": $ref\n"; // Check if it's a relative path if (strpos($ref, 'http') !== 0) { echo " ✓ This is a relative path\n"; // Resolve relative path $base_url = dirname($test_url) . '/'; $full_url = $base_url . ltrim($ref, '/'); echo " ✓ Resolved to: $full_url\n"; // Check if URL is accessible $headers = get_headers($full_url); if (strpos($headers[0], '200') !== false) { echo " ✓ Image is accessible\n"; } else { echo " ✗ Image is not accessible\n"; } } else { echo " ✓ This is an absolute path\n"; } } } else { echo "✗ No image references found in markdown content\n"; } } } } catch (Exception $e) { echo "✗ Error: " . $e->getMessage() . "\n"; } echo "\n"; // Test 2: Verify BlocksConverter code for handling relative image paths echo "Test 2: Verifying BlocksConverter code for handling relative image paths\n"; // Check if the BlocksConverter class has the necessary code $blocks_converter_file = file_get_contents(__DIR__ . '/src/BlocksConverter.php'); if ($blocks_converter_file === false) { echo "✗ Failed to read BlocksConverter.php\n"; } else { echo "✓ Successfully read BlocksConverter.php\n"; // Check if convert_markdown_to_blocks accepts original_url parameter if (strpos($blocks_converter_file, 'convert_markdown_to_blocks($markdown, $import_images = true, $original_url = \'\')') !== false) { echo "✓ convert_markdown_to_blocks method accepts original_url parameter\n"; } else { echo "✗ convert_markdown_to_blocks method does not accept original_url parameter\n"; } // Check if process_images_in_html handles relative paths if (strpos($blocks_converter_file, 'process_images_in_html($html, $original_url = \'\')') !== false) { echo "✓ process_images_in_html method accepts original_url parameter\n"; } else { echo "✗ process_images_in_html method does not accept original_url parameter\n"; } // Check for relative path handling code if (strpos($blocks_converter_file, 'if (!filter_var($src, FILTER_VALIDATE_URL) && !empty($original_url))') !== false) { echo "✓ Code for handling relative paths is present\n"; } else { echo "✗ Code for handling relative paths is not present\n"; } } echo "\n"; // Test 3: Verify PostCreator code for passing original_url to BlocksConverter echo "Test 3: Verifying PostCreator code for passing original_url to BlocksConverter\n"; // Check if the PostCreator class has the necessary code $post_creator_file = file_get_contents(__DIR__ . '/src/PostCreator.php'); if ($post_creator_file === false) { echo "✗ Failed to read PostCreator.php\n"; } else { echo "✓ Successfully read PostCreator.php\n"; // Check if create_post_from_data passes original_url to BlocksConverter if (strpos($post_creator_file, '$options[\'original_url\']') !== false) { echo "✓ create_post_from_data method stores original_url in options\n"; } else { echo "✗ create_post_from_data method does not store original_url in options\n"; } // Check if BlocksConverter is called with original_url if (strpos($post_creator_file, 'BlocksConverter::convert_markdown_to_blocks( $markdown_content, $options[\'import_images\'], $options[\'original_url\']') !== false) { echo "✓ BlocksConverter is called with original_url parameter\n"; } else { echo "✗ BlocksConverter is not called with original_url parameter\n"; } } echo "\n"; // Test 4: Verify Admin code for field mapping configuration UI echo "Test 4: Verifying Admin code for field mapping configuration UI\n"; // Check if the Admin class has the necessary code $admin_file = file_get_contents(__DIR__ . '/src/Admin.php'); if ($admin_file === false) { echo "✗ Failed to read Admin.php\n"; } else { echo "✓ Successfully read Admin.php\n"; // Check for field mapping UI if (strpos($admin_file, '
') !== false) { echo "✓ Field mapping UI is present in Admin.php\n"; } else { echo "✗ Field mapping UI is not present in Admin.php\n"; } // Check for AJAX handler for field mapping preview if (strpos($admin_file, 'ajax_get_field_mapping_preview') !== false) { echo "✓ AJAX handler for field mapping preview is present\n"; } else { echo "✗ AJAX handler for field mapping preview is not present\n"; } // Check if field mapping is passed to PostCreator if (strpos($admin_file, '$options[\'field_mapping\'] = $field_mapping;') !== false) { echo "✓ Field mapping is passed to PostCreator\n"; } else { echo "✗ Field mapping is not passed to PostCreator\n"; } } echo "\n"; echo "All tests completed.\n";