pressmodo/carbon-fields-custom-options-container

This package is abandoned and no longer maintained. No replacement package was suggested.

A Carbon fields custom options container modified to support custom files for rendering pages.

0.1.0 2018-12-24 16:50 UTC

This package is auto-updated.

Last update: 2020-08-30 01:47:48 UTC


README

This custom container for Carbon Fields provides the ability to overwrite the default template file used to render options panels through a filter.

Requirements

  • Carbon fields
  • Composer

Installation

  1. Install the package via composer by running the command:

composer require pressmodo/carbon-fields-custom-options-container

  1. Create an options panel and set the container type to custom_options instead of theme_options. It's required that you set a page file too.
Container::make( 'custom_options', 'Theme Options' )
	->set_page_file( 'my-options' )
	->add_fields(
		array(
			Field::make( 'text', 'crb_facebook_url' ),
			Field::make( 'textarea', 'crb_footer_text' ),
		)
	);

Usage

In order to setup a custom file to render options pages you'll need to use the filter: "cb_theme_options_{$page_file}_container_file" where {$page_file} is the string set with the set_page_file method mentioned above ("cb_theme_options_my-options_container_file").

Through the filter, you need to return the custom file that'll be loaded to render pages. You can use Carbon Field's existing file as a starting point.

add_filter( 'cb_theme_options_my-options_container_file', function () {
    return 'path/to/custom-file.php';
});