<?php

if( !defined( 'ABSPATH' ) ) {
    die('You cannot be here');
}

use Carbon_Fields\Container;
use Carbon_Fields\Field;

add_action('after_setup_theme', 'eprc_load_carbon_fields');
add_action('carbon_fields_register_fields', 'eprc_create_options_page');

function eprc_load_carbon_fields() {
      \Carbon_Fields\Carbon_Fields::boot();
}

// note there's a lot more fields - https://docs.carbonfields.net/learn/fields/media-gallery.html#config-methods
function eprc_create_options_page() {
    Container::make( 'theme_options', __( 'Easy Pricing' ) )
        ->set_page_menu_position(30)
        ->set_icon( 'dashicons-media-text' )
        ->add_fields( array(
            Field::make( 'checkbox', 'easy_pricing_plugin_active', __( 'Activate Plugin' ) )
                ->set_help_text( 'This enables the plugin' ),

            Field::make( 'complex', 'pricing_plans' )
                ->add_fields( 'plan', array(
                    Field::make( 'text', 'title')
                        ->set_help_text( 'Add the title of this plan e.g. Basic/Pro/Enterprise' ),
                    Field::make( 'text', 'price')
                        ->set_help_text( 'Add the currency and price of this plan e.g. $45 or £30' ),
                    Field::make( 'text', 'description')
                        ->set_help_text( 'Add a small description of the plan that will appear just below the pricing' ),
                    Field::make( 'text', 'redirect_url' , __( 'Redirect URL' ))
                        ->set_help_text( 'Add the redirect URL of the buy now button. This is where your users will be navigated to for a purchase' ),
                    Field::make( 'complex', 'bullet_points' )
                        ->add_fields( 'bullet_point', array(
                            Field::make( 'text', 'bullet_point' ),
                        ) )
                        ->set_help_text( 'Type all the bullet points you want to appear for the pricing plan' ),
                ) )
                ->set_help_text( 'Add a pricing plan. We recommend a total of 3.' ),
        ) );
}
