<?php

class MBPostsSelection extends MBComponentBase {
  protected function init_options($options) {
    $options->enabled = true;
    $options->id = "inoby-posts-selection";
    $options->title = __("Výber článkov", "inoby");
    $options->icon = "format-aside";
    $options->render_template = get_theme_file_path("components/posts-selection/template.php");
    $options->fields = [
      [
        "name" => __("Nadpis", "inoby"),
        "id" => "posts_selection_headline",
        "type" => "text",
        "sanitize_callback" => "none",
      ],
      [
        "name" => __("Počet stĺpcov", "inoby"),
        "id" => "posts_selection_columns",
        "type" => "select",
        "multiple" => false,
        "select_all_none" => true,
        "options" => [
          "col-12" => "1",
          "col-6" => "2",
          "col-4" => "3",
          "col-3" => "4",
          "col-2" => "6",
        ],
        "visible" => ["posts_selection_slider_check", "=", 0],
      ],
      [
        "name" => __("Zobraziť ako slider", "inoby"),
        "id" => "posts_selection_slider_check",
        "type" => "checkbox",
        "std" => 0,
      ],
      [
        "type" => "number",
        "id" => "posts_selection_slider_posts",
        "std" => 1,
        "name" => __("Počet článkov za slide", "inoby"),
        "visible" => ["posts_selection_slider_check", "=", 1],
      ],
      [
        "type" => "number",
        "id" => "posts_selection_slider_spacing",
        "std" => 1,
        "name" => __("Rozostupy medzi slidami", "inoby"),
        "visible" => ["posts_selection_slider_check", "=", 1],
      ],
      [
        "type" => "checkbox",
        "id" => "posts_selection_slider_infinite",
        "name" => __("Je slider nekonečný?", "inoby"),
        "visible" => ["posts_selection_slider_check", "=", 1],
      ],
      [
        "type" => "checkbox",
        "id" => "posts_selection_slider_auto",
        "name" => __("Automaticky", "inoby"),
        "visible" => ["posts_selection_slider_check", "=", 1],
      ],
      [
        "type" => "checkbox",
        "id" => "posts_selection_slider_arrows",
        "name" => __("Zobraziť šípky", "inoby"),
        "visible" => ["posts_selection_slider_check", "=", 1],
      ],
      [
        "type" => "divider",
      ],
      [
        "name" => __("Text tlačidla", "inoby"),
        "id" => "posts_selection_btn",
        "type" => "text",
      ],
      [
        "name" => __("Odkaz tlačidla", "inoby"),
        "id" => "posts_selection_url",
        "type" => "text",
      ],
      [
        "type" => "divider",
      ],
      [
        "group_title" => __("Článok - {post}", "inoby"),
        "id" => "posts_selection",
        "type" => "group",
        "clone" => true,
        "collapsible" => true,
        "sort_clone" => true,
        "add_button" => __("Pridať ďalší článok", "inoby"),
        "fields" => [
          [
            "id" => "post",
            "title" => __("Článok", "inoby"),
            "type" => "post",
            "post_type" => "post",
            "field_type" => "select_advanced",
            "placeholder" => "Vyberte článok",
            "query_args" => [
              "post_status" => "publish",
              "posts_per_page" => -1,
            ],
          ],
        ],
      ],
    ];
  }
}
