# Biznes Ogłoszenia Core

Skopiuj poniższe pliki do katalogu `wp-content/plugins/biznes-ogloszenia-core/`, a potem spakuj folder `biznes-ogloszenia-core` do ZIP albo wgraj go przez FTP.

## 1) `biznes-ogloszenia-core.php`

```php
<?php
/*
Plugin Name: Biznes Ogłoszenia Core
Description: Kategorie biznesowe, podstawowe atrybuty HivePress i premium UI dla ListingHive/HivePress.
Version: 1.0.0
Author: OpenAI
*/

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

define( 'BOC_VERSION', '1.0.0' );
define( 'BOC_PLUGIN_FILE', __FILE__ );
define( 'BOC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

add_action( 'admin_menu', function() {
	add_menu_page(
		'Biznes Ogłoszenia',
		'Biznes Ogłoszenia',
		'manage_options',
		'boc-dashboard',
		'boc_render_dashboard',
		'dashicons-building',
		58
	);
} );

function boc_render_dashboard() {
	if ( ! current_user_can( 'manage_options' ) ) {
		return;
	}

	if ( isset( $_POST['boc_import'] ) && check_admin_referer( 'boc_import_action', 'boc_nonce' ) ) {
		$result = boc_import_categories();
		echo '<div class="notice notice-success"><p>Zaimportowano lub zaktualizowano kategorie: ' . intval( $result['created'] ) . '. Pominięto istniejące: ' . intval( $result['skipped'] ) . '.</p></div>';
	}

	if ( isset( $_POST['boc_remove_demo'] ) && check_admin_referer( 'boc_import_action', 'boc_nonce' ) ) {
		$removed = boc_remove_demo_categories();
		echo '<div class="notice notice-success"><p>Usunięto demo-kategorie: ' . intval( $removed ) . '.</p></div>';
	}

	$categories = boc_get_categories_structure();
	?>
	<div class="wrap">
		<h1>Biznes Ogłoszenia Core</h1>
		<p>Jedna wtyczka do uruchomienia darmowego serwisu ogłoszeń biznesowych na HivePress / ListingHive.</p>

		<form method="post" style="margin:20px 0;">
			<?php wp_nonce_field( 'boc_import_action', 'boc_nonce' ); ?>
			<p>
				<input type="submit" name="boc_import" class="button button-primary" value="Importuj kategorie biznesowe">
				<input type="submit" name="boc_remove_demo" class="button" value="Usuń demo-kategorie ListingHive" onclick="return confirm('Na pewno usunąć demo-kategorie?');">
			</p>
		</form>

		<h2>Importowane kategorie</h2>
		<ul style="list-style:disc;padding-left:20px;">
			<?php foreach ( $categories as $parent => $children ) : ?>
				<li>
					<strong><?php echo esc_html( $parent ); ?></strong>
					<?php if ( ! empty( $children ) ) : ?>
						<ul style="list-style:circle;padding-left:20px;">
							<?php foreach ( $children as $child ) : ?>
								<li><?php echo esc_html( $child ); ?></li>
							<?php endforeach; ?>
						</ul>
					<?php endif; ?>
				</li>
			<?php endforeach; ?>
		</ul>

		<h2>Dodawane atrybuty</h2>
		<p>Atrybuty są dodawane programowo i od razu działają na formularzu ogłoszeń.</p>
		<ul style="list-style:disc;padding-left:20px;">
			<li>Cena (liczba)</li>
			<li>Lokalizacja (tekst)</li>
			<li>Branża (wybór)</li>
			<li>Forma transakcji (wybór)</li>
			<li>Etap biznesu (wybór)</li>
			<li>Przychód miesięczny (liczba)</li>
			<li>Liczba pracowników (liczba)</li>
			<li>Rok założenia (liczba)</li>
			<li>Strona WWW (URL)</li>
			<li>Poufne / po NDA (checkbox)</li>
		</ul>

		<h2>Co robi premium UI</h2>
		<ul style="list-style:disc;padding-left:20px;">
			<li>jaśniejsze tło i bardziej biznesowy wygląd,</li>
			<li>białe karty z miękkimi cieniami,</li>
			<li>ciemny granatowy akcent,</li>
			<li>bardziej eleganckie przyciski i kafelki kategorii.</li>
		</ul>
	</div>
	<?php
}

function boc_get_categories_structure() {
	return [
		'Sprzedaż firm' => [
			'Firmy usługowe',
			'Sklepy internetowe',
			'Firmy produkcyjne',
			'Startupy',
		],
		'Franczyza' => [
			'Gastronomia',
			'Handel',
			'Usługi',
			'Beauty & wellness',
		],
		'Inwestorzy i finansowanie' => [
			'Szukam inwestora',
			'Inwestor szuka projektu',
			'Pożyczki biznesowe',
			'Crowdfunding',
		],
		'Nieruchomości komercyjne' => [
			'Biura',
			'Lokale handlowe',
			'Hale i magazyny',
			'Grunty inwestycyjne',
		],
		'Maszyny i wyposażenie' => [
			'Maszyny produkcyjne',
			'Wyposażenie sklepów',
			'Sprzęt gastronomiczny',
			'Sprzęt biurowy',
		],
		'Usługi dla biznesu' => [
			'Marketing',
			'IT',
			'Księgowość',
			'Prawo',
			'HR',
		],
		'Partnerstwa biznesowe' => [
			'Wspólnik do firmy',
			'Joint venture',
			'Partner handlowy',
			'Dystrybutorzy',
		],
		'Biznesy online' => [
			'Sklepy internetowe',
			'Serwisy internetowe',
			'SaaS',
			'Aplikacje',
		],
	];
}

function boc_import_categories() {
	$taxonomy = 'hp_listing_category';
	$created  = 0;
	$skipped  = 0;

	if ( ! taxonomy_exists( $taxonomy ) ) {
		return [ 'created' => 0, 'skipped' => 0 ];
	}

	foreach ( boc_get_categories_structure() as $parent_name => $children ) {
		$parent = term_exists( $parent_name, $taxonomy );

		if ( ! $parent ) {
			$parent = wp_insert_term( $parent_name, $taxonomy );
			if ( ! is_wp_error( $parent ) ) {
				$created++;
			}
		} else {
			$skipped++;
		}

		$parent_id = is_array( $parent ) && isset( $parent['term_id'] ) ? (int) $parent['term_id'] : 0;

		foreach ( $children as $child_name ) {
			$child = term_exists( $child_name, $taxonomy, $parent_id );

			if ( ! $child ) {
				$child = wp_insert_term( $child_name, $taxonomy, [ 'parent' => $parent_id ] );
				if ( ! is_wp_error( $child ) ) {
					$created++;
				}
			} else {
				$skipped++;
			}
		}
	}

	return [ 'created' => $created, 'skipped' => $skipped ];
}

function boc_remove_demo_categories() {
	$taxonomy = 'hp_listing_category';
	$removed  = 0;
	$terms    = [ 'Real Estate', 'Services', 'For Sale' ];

	if ( ! taxonomy_exists( $taxonomy ) ) {
		return $removed;
	}

	foreach ( $terms as $name ) {
		$term = get_term_by( 'name', $name, $taxonomy );
		if ( $term && ! is_wp_error( $term ) ) {
			$result = wp_delete_term( (int) $term->term_id, $taxonomy );
			if ( ! is_wp_error( $result ) ) {
				$removed++;
			}
		}
	}

	return $removed;
}

add_filter( 'hivepress/v1/models/listing/attributes', function( $attributes ) {

	$attributes['boc_price'] = [
		'label'  => 'Cena',
		'type'   => 'number',
		'_order' => 10,
	];

	$attributes['boc_location'] = [
		'label'  => 'Lokalizacja',
		'type'   => 'text',
		'_order' => 20,
	];

	$attributes['boc_industry'] = [
		'label'   => 'Branża',
		'type'    => 'select',
		'options' => [
			'handel'        => 'Handel',
			'uslugi'        => 'Usługi',
			'produkcja'     => 'Produkcja',
			'technologia'   => 'Technologia',
			'nieruchomosci' => 'Nieruchomości',
			'gastronomia'   => 'Gastronomia',
			'medycyna'      => 'Medycyna i zdrowie',
			'transport'     => 'Transport i logistyka',
			'inne'          => 'Inne',
		],
		'_order' => 30,
	];

	$attributes['boc_transaction_type'] = [
		'label'   => 'Forma transakcji',
		'type'    => 'select',
		'options' => [
			'sprzedaz'    => 'Sprzedaż',
			'franczyza'   => 'Franczyza',
			'inwestycja'  => 'Inwestycja',
			'partnerstwo' => 'Partnerstwo',
			'wynajem'     => 'Wynajem',
		],
		'_order' => 40,
	];

	$attributes['boc_stage'] = [
		'label'   => 'Etap biznesu',
		'type'    => 'select',
		'options' => [
			'pomysl'           => 'Pomysł / koncepcja',
			'startup'          => 'Startup',
			'dzialajacy'       => 'Działający biznes',
			'skalowanie'       => 'Skalowanie',
			'restrukturyzacja' => 'Restrukturyzacja',
		],
		'_order' => 50,
	];

	$attributes['boc_monthly_revenue'] = [
		'label'  => 'Przychód miesięczny',
		'type'   => 'number',
		'_order' => 60,
	];

	$attributes['boc_employees'] = [
		'label'  => 'Liczba pracowników',
		'type'   => 'number',
		'_order' => 70,

/* Biznes Ogłoszenia Core — premium B2B UI */

body {
	background: #f5f7fb;
}

.hp-page__title,
h1, h2, h3, h4 {
	letter-spacing: -0.02em;
}

.hp-listing-category,
.hp-listing--view-block,
.hp-vendor--view-block,
.hp-testimonial {
	background: #ffffff;
	border: 1px solid rgba(15, 23, 42, 0.06);
	border-radius: 16px;
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
	transition: transform .2s ease, box-shadow .2s ease;
}

.hp-listing-category:hover,
.hp-listing--view-block:hover {
	transform: translateY(-3px);
	box-shadow: 0 18px 40px rgba(15, 23, 42, 0.10);
}

.hp-listing-category {
	padding: 20px;
}

.hp-listing-category__name,
.hp-listing__title a,
.hp-vendor__name a {
	color: #0f172a;
	font-weight: 600;
}

.hp-listing-category__count {
	color: #475569;
}

.button,
button,
input[type="submit"],
.hp-form .button,
.hp-menu .button {
	background: #0f172a;
	border-color: #0f172a;
	color: #fff;
	border-radius: 10px;
	box-shadow: none;
}

.button:hover,
button:hover,
input[type="submit"]:hover,
.hp-form .button:hover,
.hp-menu .button:hover {
	background: #111827;
	border-color: #111827;
	color: #fff;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="search"],
select,
textarea {
	border: 1px solid #dbe3ee;
	border-radius: 10px;
	background: #fff;
	box-shadow: none;
}

.hp-form,
.hp-widget {
	background: #fff;
	border: 1px solid rgba(15, 23, 42, 0.06);
	border-radius: 16px;
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
	padding: 18px;
}

.site-header,
.header-navbar {
	box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

.hp-section--hero {
	position: relative;
	overflow: hidden;
	border-radius: 22px;
}

.hp-section--hero .hp-page__title {
	font-size: clamp(2rem, 4vw, 3.2rem);
	font-weight: 700;
}

.hp-listing__attributes,
.hp-listing__details {
	color: #334155;
}
