Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
Please provide me the php code required to create a WordPress plugin that would…
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
Please provide me the php code required to create a WordPress plugin that would aromatically convert any Amazon.com links into links that use my affiliate code link and describe how I would implement it.
- Assistant
Here is an example of a PHP code for a WordPress plugin that would automatically convert any Amazon.com links into links that use your affiliate code:
<?php /* Plugin Name: Amazon Affiliate Link Converter Description: Automatically converts Amazon links to affiliate links using your affiliate code. */ function convert_amazon_links($content) { $amazon_url_pattern = "/https?:\/\/(www\.)?amazon\.com\/([a-zA-Z0-9\/\-]+)(\?[a-zA-Z0-9&=\+\%\.\-\_]+)?/i"; $affiliate_url = "https://www.amazon.com/gp/product/%product_id%/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=%product_id%&linkCode=as2&tag=%affiliate_id%"; preg_match_all($amazon_url_pattern, $content, $matches); if (count($matches[0]) > 0) { foreach ($matches[0] as $match) { $product_id_pattern = "/\/dp\/([A-Za-z0-9]+)/i"; preg_match($product_id_pattern, $match, $product_id_match); $product_id = $product_id_match[1]; $affiliate_link = str_replace("%product_id%", $product_id, $affiliate_url); $affiliate_link = str_replace("%affiliate_id%", "your-affiliate-id", $affiliate_link); $content = str_replace($match, $affiliate_link, $content); } } return $content; } add_filter('the_content', 'convert_amazon_links'); ?>
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)