<?php /* Plugin Name: AMAZING FINDS AI Studio Description: All-in-one eCommerce + Funnel + SEO + AI Studio (images, video, chat, automation) for free. Author: You Version: 1.0 */ // ============================ // 1. Auto-install free plugins // ============================ register_activation_hook(__FILE__, function(){ include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); $plugins = [ 'woocommerce/woocommerce.php' => 'https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip', 'cartflows/cartflows.php' => 'https://downloads.wordpress.org/plugin/cartflows.latest-stable.zip', 'seo-by-rank-math/rank-math.php' => 'https://downloads.wordpress.org/plugin/seo-by-rank-math.latest-stable.zip' ]; foreach($plugins as $slug => $url){ if(!is_plugin_active($slug)){ $zip = download_url($url); $result = unzip_file($zip, WP_PLUGIN_DIR);
@unlink
($zip); } } }); // ============================ // 2. Set store name // ============================ add_action('init', function(){ update_option('blogname', 'AMAZING FINDS'); }); // ============================ // 3. Add default funnel pages // ============================ register_activation_hook(__FILE__, function(){ $landing = wp_insert_post([ 'post_title' => 'AMAZING FINDS Landing', 'post_content' => '<h2>Welcome to AMAZING FINDS!</h2><p>Special Offer β [add_to_cart id="1"]</p>', 'post_status' => 'publish', 'post_type' => 'page' ]); $thankyou = wp_insert_post([ 'post_title' => 'AMAZING FINDS Thank You', 'post_content' => '<h2>Thanks for your order!</h2><p>Check your email for details.</p>', 'post_status' => 'publish', 'post_type' => 'page' ]); update_option('funnel_landing_id', $landing); update_option('funnel_thankyou_id', $thankyou); }); // ============================ // 4. Add SEO schema // ============================ add_action('wp_head', function(){ if(is_product()){ global $product; echo '<script type="application/ld+json">'.json_encode([ "@context" => "https://schema.org/", "@type" => "Product", "name" => $product->get_name(), "image" => wp_get_attachment_url($product->get_image_id()), "description" => wp_strip_all_tags($product->get_short_description()), "sku" => $product->get_sku(), "brand" => "AMAZING FINDS", "offers" => [ "@type" => "Offer", "priceCurrency" => get_woocommerce_currency(), "price" => $product->get_price(), "availability" => "https://schema.org/InStock" ] ], JSON_UNESCAPED_SLASHES).'</script>'; } }); // ============================ // 5. Chatbot + AI Agent // ============================ add_action('wp_footer', function(){ ?> <script> (function(d,t) { var BASE_URL="https://app.chatwoot.com"; var g=d.createElement(t),s=d.getElementsByTagName(t)[0]; g.src=BASE_URL+"/packs/js/sdk.js"; s.parentNode.insertBefore(g,s); g.onload=function(){ window.chatwootSDK.run({websiteToken: "YOUR_CHATWOOT_TOKEN", baseUrl: BASE_URL}) } })(document,"script"); </script> <?php }); // ============================ // 6. Webhooks for automation (social posting) // ============================ add_action('publish_product', function($post_id){ $product = wc_get_product($post_id); $data = [ 'title' => get_the_title($post_id), 'url' => get_permalink($post_id), 'image' => wp_get_attachment_url($product->get_image_id()), 'price' => $product->get_price() ]; $social_hooks = [ 'https://your-n8n-instance/webhook/post-youtube', 'https://your-n8n-instance/webhook/post-instagram', 'https://your-n8n-instance/webhook/post-facebook', 'https://your-n8n-instance/webhook/post-twitter', 'https://your-n8n-instance/webhook/post-tiktok', 'https://your-n8n-instance/webhook/post-linkedin', 'https://your-n8n-instance/webhook/post-snapchat', 'https://your-n8n-instance/webhook/post-amazon' ]; foreach($social_hooks as $hook){ wp_remote_post($hook, ['body' => $data]); } }); // ============================ // 7. AI Studio Menu // ============================ add_action('admin_menu', function(){ add_menu_page('AMAZING FINDS AI Studio', 'AI Studio', 'manage_options', 'amazing-finds-ai-studio', 'af_ai_studio_page', 'dashicons-admin-multisite', 6); }); function af_ai_studio_page(){ ?> <h1>AMAZING FINDS AI Studio</h1> <p>Welcome to your AI Studio: edit images, create videos, and generate product content.</p> <h2>Image Editor</h2> <p>Upload or select product images to enhance, remove background, add text/watermark, or generate AI images.</p> <h2>Video Editor</h2> <p>Create short promo videos for products, add text/logo overlays, resize for social media, and auto-publish.</p> <h2>AI Content</h2> <p>Generate product descriptions, blog posts, and social captions with one click.</p> <p>All media can be automatically posted to your social channels and saved in WooCommerce.</p> <?php } ?> - Initial Deployment
4bbdc99
verified