// إضافة هذا الكود لملف functions.php في الثيم
// إنشاء Custom Taxonomies للغرف والخامات
function create_coccaro_taxonomies() {
// تصنيف الغرف
register_taxonomy(
'room_category',
'product',
array(
'label' => 'Room Categories',
'labels' => array(
'name' => 'Room Categories',
'singular_name' => 'Room Category',
'menu_name' => 'Rooms',
'all_items' => 'All Rooms',
'edit_item' => 'Edit Room',
'view_item' => 'View Room',
'update_item' => 'Update Room',
'add_new_item' => 'Add New Room',
'new_item_name' => 'New Room Name',
'search_items' => 'Search Rooms',
'not_found' => 'No rooms found'
),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'room'),
'show_in_rest' => true
)
);
// تصنيف الخامات
register_taxonomy(
'material_category',
'product',
array(
'label' => 'Material Categories',
'labels' => array(
'name' => 'Material Categories',
'singular_name' => 'Material Category',
'menu_name' => 'Materials',
'all_items' => 'All Materials',
'edit_item' => 'Edit Material',
'view_item' => 'View Material',
'update_item' => 'Update Material',
'add_new_item' => 'Add New Material',
'new_item_name' => 'New Material Name',
'search_items' => 'Search Materials',
'not_found' => 'No materials found'
),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'material'),
'show_in_rest' => true
)
);
}
add_action('init', 'create_coccaro_taxonomies');
// دالة إنشاء جميع الفئات
function create_all_coccaro_categories() {
echo "
";
echo "
🏠 إنشاء فئات Coccaro Home
";
// ======================
// 1. فئات المنتجات (Product Categories)
// ======================
echo "
📦 إنشاء فئات المنتجات...
";
$product_categories = array(
array(
'name' => 'Cushions & Pillows',
'slug' => 'cushions-pillows',
'description' => 'Comfortable and stylish cushions and pillows for your home'
),
array(
'name' => 'Throws & Blankets',
'slug' => 'throws-blankets',
'description' => 'Cozy throws and blankets for warmth and style'
),
array(
'name' => 'Rugs',
'slug' => 'rugs',
'description' => 'Beautiful rugs and carpets for every room'
),
array(
'name' => 'Candles',
'slug' => 'candles',
'description' => 'Scented and decorative candles for ambiance'
),
array(
'name' => 'Pots & Planters',
'slug' => 'pots-planters',
'description' => 'Stylish pots and planters for your plants'
),
array(
'name' => 'Runners & Placemats',
'slug' => 'runners-placemats',
'description' => 'Table runners and placemats for elegant dining'
),
array(
'name' => 'Trays & Servers',
'slug' => 'trays-servers',
'description' => 'Serving trays and food servers for entertaining'
),
array(
'name' => 'Mugs',
'slug' => 'mugs',
'description' => 'Coffee mugs and cups for your daily beverages'
),
array(
'name' => 'Vases',
'slug' => 'vases',
'description' => 'Decorative vases for flowers and home decor'
),
array(
'name' => 'Wall Decor',
'slug' => 'wall-decor',
'description' => 'Wall art, frames and decorative wall items'
),
array(
'name' => 'Artificial Plants',
'slug' => 'artificial-plants',
'description' => 'Beautiful artificial plants and greenery'
),
array(
'name' => 'Tissue Boxes',
'slug' => 'tissue-boxes',
'description' => 'Decorative tissue box holders and covers'
),
array(
'name' => 'Storage & Baskets',
'slug' => 'storage-baskets',
'description' => 'Storage solutions and decorative baskets'
),
array(
'name' => 'Poufs',
'slug' => 'poufs',
'description' => 'Ottoman poufs and floor seating options'
),
array(
'name' => 'Stools',
'slug' => 'stools',
'description' => 'Bar stools and counter seating'
),
array(
'name' => 'Benches',
'slug' => 'benches',
'description' => 'Seating benches for home and garden'
),
array(
'name' => 'Swings',
'slug' => 'swings',
'description' => 'Hanging swings and outdoor seating'
),
array(
'name' => 'Umbrellas',
'slug' => 'umbrellas',
'description' => 'Garden and patio umbrellas for shade'
)
);
foreach ($product_categories as $category) {
$existing = term_exists($category['slug'], 'product_cat');
if (!$existing) {
$result = wp_insert_term(
$category['name'],
'product_cat',
array(
'slug' => $category['slug'],
'description' => $category['description']
)
);
if (!is_wp_error($result)) {
echo "
✅ تم إنشاء فئة المنتج: " . $category['name'] . "";
} else {
echo "
❌ خطأ في إنشاء: " . $category['name'] . " - " . $result->get_error_message() . "";
}
} else {
echo "
⚠️ فئة المنتج موجودة: " . $category['name'] . "";
}
}
// ======================
// 2. فئات الغرف (Room Categories)
// ======================
echo "
🏠 إنشاء فئات الغرف...
";
$room_categories = array(
array(
'name' => 'Living Room',
'slug' => 'living-room',
'description' => 'Living room decor, furniture and accessories'
),
array(
'name' => 'Bedroom',
'slug' => 'bedroom',
'description' => 'Bedroom accessories, decor and comfort items'
),
array(
'name' => 'Dining Room',
'slug' => 'dining-room',
'description' => 'Dining room essentials and table accessories'
),
array(
'name' => 'Kitchen',
'slug' => 'kitchen',
'description' => 'Kitchen accessories, storage and decor items'
),
array(
'name' => 'Bathroom',
'slug' => 'bathroom',
'description' => 'Bathroom accessories and organizational items'
),
array(
'name' => 'Outdoor',
'slug' => 'outdoor',
'description' => 'Garden, patio and outdoor living accessories'
)
);
foreach ($room_categories as $room) {
$existing = term_exists($room['slug'], 'room_category');
if (!$existing) {
$result = wp_insert_term(
$room['name'],
'room_category',
array(
'slug' => $room['slug'],
'description' => $room['description']
)
);
if (!is_wp_error($result)) {
echo "
✅ تم إنشاء فئة الغرفة: " . $room['name'] . "";
} else {
echo "
❌ خطأ في إنشاء: " . $room['name'] . " - " . $result->get_error_message() . "";
}
} else {
echo "
⚠️ فئة الغرفة موجودة: " . $room['name'] . "";
}
}
// ======================
// 3. فئات الخامات (Material Categories)
// ======================
echo "
🧵 إنشاء فئات الخامات...
";
$material_categories = array(
array(
'name' => 'Halfa',
'slug' => 'halfa',
'description' => 'Natural halfa grass products and accessories'
),
array(
'name' => 'Wood',
'slug' => 'wood',
'description' => 'Wooden furniture and decorative items'
),
array(
'name' => 'Pottery',
'slug' => 'pottery',
'description' => 'Ceramic and clay pottery items'
),
array(
'name' => 'Decoupage',
'slug' => 'decoupage',
'description' => 'Decoupage art and decorative pieces'
),
array(
'name' => 'Cotton',
'slug' => 'cotton',
'description' => 'Cotton textiles and soft furnishings'
),
array(
'name' => 'Macrame',
'slug' => 'macrame',
'description' => 'Macrame wall hangings and decorative items'
),
array(
'name' => 'Jute',
'slug' => 'jute',
'description' => 'Natural jute fiber products and accessories'
),
array(
'name' => 'Fabric',
'slug' => 'fabric',
'description' => 'Various fabric textiles and upholstery'
),
array(
'name' => 'Leather',
'slug' => 'leather',
'description' => 'Premium leather goods and accessories'
),
array(
'name' => 'Plastic',
'slug' => 'plastic',
'description' => 'Durable plastic and polymer products'
)
);
foreach ($material_categories as $material) {
$existing = term_exists($material['slug'], 'material_category');
if (!$existing) {
$result = wp_insert_term(
$material['name'],
'material_category',
array(
'slug' => $material['slug'],
'description' => $material['description']
)
);
if (!is_wp_error($result)) {
echo "
✅ تم إنشاء فئة الخامة: " . $material['name'] . "";
} else {
echo "
❌ خطأ في إنشاء: " . $material['name'] . " - " . $result->get_error_message() . "";
}
} else {
echo "
⚠️ فئة الخامة موجودة: " . $material['name'] . "";
}
}
// ======================
// ملخص العملية
// ======================
echo "
";
echo "
🎉 تم الانتهاء من العملية!
";
echo "
✅ 18 فئة منتج
";
echo "
🏠 6 فئات غرف
";
echo "
🧵 10 فئات خامات
";
echo "
المجموع: 34 فئة
";
echo "
يمكنك الآن زيارة لوحة التحكم لرؤية جميع الفئات المنشأة.
";
echo "
";
echo "
";
// تحديث Rewrite Rules
flush_rewrite_rules();
}
// تشغيل الدالة عند زيارة الرابط مع البارامتر
if (isset($_GET['create_coccaro_categories']) && $_GET['create_coccaro_categories'] == '1' && current_user_can('manage_options')) {
add_action('wp_loaded', 'create_all_coccaro_categories');
}
?>
Reviews
Clear filtersThere are no reviews yet.