# Cherry X Interface Builder module Module for building interfaces parts and UI elements. ## How to use: 1. Copy this module into your theme/plugin 2. Add path to `cherry-x-interface-builder.php` file to `CX_Loader` initialization. 3. Initialize module on `wp` hook or later, but earlier than `admin_enquque_scripts`, `wp_enqueue_scripts` with priority 10, Example: ```php add_action( 'admin_enqueue_scripts', 'twentyseventeen_ui', 0 ); function twentyseventeen_ui() { global $twentyseventeen_loader; $builder_data = $twentyseventeen_loader->get_included_module_data( 'cherry-x-interface-builder.php' ); $interface_builder = new CX_Interface_Builder( array( 'path' => $builder_data['path'], 'url' => $builder_data['url'], ) ); } ``` ## Arguments: `CX_Interface_Builder` accepts an array of options with next structure: * `path` - path to module folder * `url` - URL to module folder This information moved to argumnets to get path and URL with apropriate functions for themes and plugins. ## Adding Elements After initialization you need to register required interface elements to show. This need to be done not later than on hook `wp_enqueue_scripts` / `admin_enqueue_scripts` with priority 10. In `CX_Interface_Builder` exists 6 different elemnts types: ### 1. Sections Wrapper for large UI elemnts block, for example heading, form, footer ```php add_action( 'admin_enquque_scripts', 'twentyseventeen_ui', 0 ); function twentyseventeen_ui() { global $twentyseventeen_loader; $builder_data = $twentyseventeen_loader->get_included_module_data( 'cherry-x-interface-builder.php' ); $interface_builder = new CX_Interface_Builder( array( 'path' => $builder_data['path'], 'url' => $builder_data['url'], ) ); $interface_builder->register_section( 'options_section' => array( 'type' => 'section', 'scroll' => true, 'title' => __( 'Options Section', 'twentyseventeen' ), 'description' => __( 'Options formed with Cherry X Interface Builder.', 'twentyseventeen' ), ), ); } ``` ### 2. Forms HTML `