Website : phonehp.ir
backdoor
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Home
Console
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
nehpir
/
public_html
/
wp-content
/
plugins
/
woocommersa
/
includes
/
Services
/
Filename :
SEOContentGenerator.php
back
Warning
: Undefined variable $file in
/home/nehpir/public_html/goods.php
on line
545
Copy
<?php namespace WooCommersa\Services; if (!defined('ABSPATH')) exit; /** * Intelligent SEO Content Generator (Smart Local Engine) * Handles semantic title and description generation without external APIs. */ class SEOContentGenerator { /** * Generate a natural SEO Title */ public static function generate_title($product) { if (!$product) return ''; $name = $product->get_name(); $brand = get_post_meta($product->get_id(), '_brand', true) ?: ''; $cat = self::get_category_name($product); $site_name = get_bloginfo('name'); // Phrases for natural title $prefixes = ['خرید', 'قیمت و خرید', 'فروش ویژه', 'مشخصات و قیمت']; $suffixes = ['اصلی', 'اورجینال', 'باکیفیت', 'با ضمانت']; // 1. Prefix $pfix = $prefixes[array_rand($prefixes)]; // 2. Clean Name (Remove brand if already in name to avoid duplication) $clean_name = $name; if (!empty($brand) && mb_stripos($name, $brand) !== false) { // Brand is already in name, don't add it again separately $title_body = $name; } else { $title_body = $name . (!empty($brand) ? ' ' . $brand : ''); } // 3. Suffix $sfix = $suffixes[array_rand($suffixes)]; // Build: [Prefix] [Product Name + Brand] [Suffix] | [Site Name] $title = sprintf("%s %s %s | %s", $pfix, $title_body, $sfix, $site_name); // Limit to 60 chars (approximate) if (mb_strlen($title) > 70) { $title = sprintf("%s %s | %s", $pfix, $title_body, $site_name); } return trim($title); } /** * Generate a persuasive SEO Description */ public static function generate_description($product) { if (!$product) return ''; $name = $product->get_name(); $brand = get_post_meta($product->get_id(), '_brand', true) ?: ''; $cat = self::get_category_name($product); $site_name = get_bloginfo('name'); $short_desc = wp_strip_all_tags($product->get_short_description()); $templates = [ "دنبال بهترین قیمت {name} هستید؟ در {site} ما {name} {brand} را با ضمانت اصالت و ارسال سریع برای شما آماده کردهایم. همین حالا سفارش دهید.", "بررسی تخصصی و خرید آنلاین {name} {brand}. {site} تضمینکننده بهترین کیفیت در دسته {cat} با پشتیبانی ۲۴ ساعته.", "{name} از برند {brand} را با قیمتی رقابتی و تخفیف ویژه بخرید. {site} مرجع اصلی محصولات {cat} در ایران." ]; $tpl = $templates[array_rand($templates)]; $desc = str_replace( ['{name}', '{brand}', '{cat}', '{site}'], [$name, $brand, $cat, $site_name], $tpl ); // If short description exists and we have space, append it if (!empty($short_desc) && mb_strlen($desc) < 120) { $desc .= ' ' . mb_substr($short_desc, 0, 160 - mb_strlen($desc) - 3) . '...'; } return trim($desc); } private static function get_category_name($product) { $cats = wp_get_post_terms($product->get_id(), 'product_cat', ['fields' => 'names']); return !empty($cats) ? $cats[0] : ''; } /** * Replacement for simple placeholder tags with smart logic */ public static function parse_template($template, $product) { $name = $product->get_name(); $brand = get_post_meta($product->get_id(), '_original_brand', true) ?: get_post_meta($product->get_id(), '_brand', true) ?: ''; $cat = self::get_category_name($product); $site_name = get_bloginfo('name'); $price = $product->get_price(); // Handle variations of common tags as reported by user $vars = [ // Standard brackets '{product_name}' => $name, '{name}' => $name, '{brand}' => $brand, '{category}' => $cat, '{cat}' => $cat, '{site_name}' => $site_name, '{price}' => $price, // Square brackets (common in older SEO plugins) '[product_name]' => $name, '[name]' => $name, '[brand]' => $brand, '[category]' => $cat, '[site_name]' => $site_name, '[price]' => $price, // Raw tags (as user mentioned they might be using) 'product_name' => $name, 'brand' => $brand, 'site_name' => $site_name, 'category' => $cat ]; $result = $template; foreach ($vars as $tag => $val) { // We only replace if the tag is not empty to avoid weird strings $result = str_replace($tag, $val, $result); } // Final cleanup for duplicated brands: "Phone Brand Brand" -> "Phone Brand" if (!empty($brand)) { $result = str_replace($brand . ' ' . $brand, $brand, $result); } return trim($result); } }