### Interactive Program Startup Notice Example Source: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/license.txt Illustrates how an interactive program should display a short notice upon startup, informing users about its version, copyright, warranty status, and how to access redistribution conditions. ```text Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Run Fieldmanager Tests Source: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/tests/php/README.txt Execute the Fieldmanager plugin tests using PHPUnit. This requires setting the WP_TESTS_DIR environment variable to the root directory of your WordPress test toolkit installation. ```shell WP_TESTS_DIR=/path/to/wp-unit-test phpunit ``` -------------------------------- ### Check Box Field Example Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Provides an example of creating a Fieldmanager_Checkbox field. This snippet shows the basic setup for a checkbox input, including its label and name. ```php new Fieldmanager_Checkbox( array( 'label' => __('Sample Check Box'), 'name' => 'sample-check-box', ) ) ?> ``` -------------------------------- ### Generate Fieldmanager API Documentation Source: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/README.md Command to generate the API documentation for Fieldmanager using the apigen tool. This process requires apigen to be installed and configured via apigen.neon. ```Bash apigen -c apigen.neon ``` -------------------------------- ### Free Software Copyright Notice Example Source: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/license.txt Provides a standard format for copyright notices and license attribution when distributing free software under the GNU General Public License. This includes essential information like the copyright holder, year, and a pointer to the full license text. ```text Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ``` -------------------------------- ### Fieldmanager QUnit Test Suite Setup Source: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/tests/js/index.html This script configures the QUnit test suite for Fieldmanager. It dynamically loads jQuery and its UI components (sortable, draggable, droppable) from WordPress core SVN, along with the Fieldmanager loader and main script. It also includes the specific test file 'test-fieldmanager.js'. The script allows testing against different WordPress versions by modifying the SVN path. ```javascript var scripts = []; var svn = 'https://core.svn.wordpress.org/trunk'; /* Test against trunk by default; include '?wp=X.Y' in the URL to test against the scripts in WordPress X.Y. */ var versionMatch = /wp=(\d\.\d)/.exec( window.location.href ); var isTrunk = versionMatch && versionMatch[1]; if ( isTrunk ) { svn = 'https://core.svn.wordpress.org/tags/' + versionMatch[1]; } scripts = [ svn + '/wp-includes/js/jquery/jquery.js', svn + '/wp-includes/js/jquery/ui/core.min.js', svn + '/wp-includes/js/jquery/ui/mouse.min.js', svn + '/wp-includes/js/jquery/ui/sortable.min.js', svn + '/wp-includes/js/jquery/ui/draggable.min.js', svn + '/wp-includes/js/jquery/ui/droppable.min.js', ]; if ( ! isTrunk ) { scripts.push( svn + '/wp-includes/js/jquery/ui/widget.min.js' ); } // Provide the fmLoadModule function to fieldmanager.js. scripts.push( '../../js/fieldmanager-loader.js' ); // Fieldmanager. scripts.push( '../../js/fieldmanager.js' ); // Tests. scripts.push( 'test-fieldmanager.js' ); scripts.forEach(function( src ) { var script = document.createElement( 'script' ); script.src = src; script.async = false; var node = document.getElementsByTagName( 'script' )[0]; node.parentNode.insertBefore( script, null ); }); ``` -------------------------------- ### Group Fields Example Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Illustrates how to group multiple fields together using Fieldmanager_Group. This example shows grouping text fields and a select box within a single meta box section. ```php new Fieldmanager_Group( array( 'name' => 'some-group', 'label' => null, 'children' => array( 'text-group1' => new Fieldmanager_Textfield( array( 'label' => __('Text Group 1'), 'name' => 'text-group1', ) ), 'text-group2' => new Fieldmanager_Textfield( array( 'label' => __('Text Group 2'), 'name' => 'text-group2', ) ), 'sample-select' => new Fieldmanager_Select( array( 'first_element' => array( '', '' ), 'label' => null, 'name' => 'sample-select', 'taxonomy' => 'category', 'taxonomy_args' => array( 'orderby' => 'name', 'hide_empty' => false ) ) ), ) ) ) ); ?> ``` -------------------------------- ### PHP: Create Single-Level Group Field with Fieldmanager Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Storing-data-unserialized Shows how to create a basic group field where child fields are added directly without a group prefix. Each child field gets its own key. ```php $fm = new Fieldmanager_Group( array( 'name' => 'meta_fields', 'serialize_data' => false, 'children' => array( 'text' => new Fieldmanager_Textfield( 'Text Field' ), 'textarea' => new Fieldmanager_TextArea( 'TextArea' ), 'checkbox' => new Fieldmanager_Checkbox( 'Checkbox' ), ) ) ); $fm->add_meta_box( 'Single-Level Group', 'post' ); ``` -------------------------------- ### Text Area Field Example Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Shows how to instantiate a Fieldmanager_TextArea field. It includes configuration for label, name, and HTML attributes like cols and rows for the textarea element. ```php new Fieldmanager_TextArea( array( 'label' => __('Some Label'), 'name' => 'sample-text-area', 'attributes' => array( 'cols' => 80, 'rows' => 5 ) ) ) ?> ``` -------------------------------- ### Setup Custom Meta Box Context (PHP) Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-After-the-Title-(Above-Main-WP-Content-Editor) This PHP function hooks into 'edit_form_after_title' to render meta boxes in a custom context ('ai_after_title') and then unsets that context from the global meta box registry. It prepares the WordPress environment to accept meta boxes in a non-standard location. ```PHP function ai_edit_form_after_title() { // get globals vars global $post, $wp_meta_boxes; // render the FM meta box in 'ai_after_title' context do_meta_boxes( get_current_screen(), 'ai_after_title', $post ); // unset 'ai_after_title' context from the post's meta boxes unset( $wp_meta_boxes['post']['ai_after_title'] ); } add_action( 'edit_form_after_title', 'ai_edit_form_after_title' ); ``` -------------------------------- ### Draggable Dynamic Group Example Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Shows how to create a Fieldmanager_Group that is sortable and collapsible, allowing users to reorder items and add new ones dynamically. This is useful for repeatable field sets. ```php new Fieldmanager_Group( array( 'name' => 'some-name', 'label' => 'Custom Draggable Dynamic Group', 'limit' => 0, 'starting_count' => 0, 'add_more_label' => 'Add more', 'sortable' => True, 'collapsible' => True, 'children' => array( 'text-group1' => new Fieldmanager_Textfield( array( 'label' => __('Text Group 1'), 'name' => 'text-group1', ) ), ) ) ) ?> ``` -------------------------------- ### PHP: Create Group Field without Prefix using Fieldmanager Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Storing-data-unserialized Illustrates creating a group field with `add_to_prefix` set to `false`, ensuring child fields do not inherit the group's name prefix. Each child field gets its own key. ```php $fm = new Fieldmanager_Group( array( 'name' => 'meta_fields', 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'text' => new Fieldmanager_Textfield( 'Text Field' ), 'textarea' => new Fieldmanager_TextArea( 'TextArea' ), 'checkbox' => new Fieldmanager_Checkbox( 'Checkbox' ), ) ) ); $fm->add_meta_box( 'Single-Level Group', 'post' ); ``` -------------------------------- ### Copyright Disclaimer Sample Source: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/license.txt A sample copyright disclaimer that an employer or institution might sign to disclaim copyright interest in a program written by an individual. ```text Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice ``` -------------------------------- ### WordPress Source Code URL Source: https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/license.txt Provides the official URL where users can obtain the source code for WordPress programs and compressed scripts. ```text http://wordpress.org/download/source/ ``` -------------------------------- ### PHP: Create Tabbed Group Field with Fieldmanager Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Storing-data-unserialized Demonstrates creating a tabbed group structure using Fieldmanager. Fields within tabs are organized and presented separately, with each field retaining its own key. ```php $fm = new Fieldmanager_Group( array( 'name' => 'tabbed_meta_fields', 'tabbed' => true, 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'tab-1' => new Fieldmanager_Group( array( 'label' => 'Tab One', 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'text' => new Fieldmanager_Textfield( 'Text Field' ), ) ) ), 'tab-2' => new Fieldmanager_Group( array( 'label' => 'Tab Two', 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'textarea' => new Fieldmanager_TextArea( 'TextArea' ), 'media' => new Fieldmanager_Media( 'Media File' ), ) ) ), ) ) ); $fm->add_meta_box( 'Tabbed Group', 'post' ); ``` -------------------------------- ### PHP: Create Multi-Level Group with Serialized Subgroup using Fieldmanager Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Storing-data-unserialized Shows a group containing a simple field and a nested subgroup. The subgroup is configured to serialize its data, resulting in distinct meta keys for the top-level field and the serialized subgroup. ```php $fm = new Fieldmanager_Group( array( 'name' => 'meta_fields', 'serialize_data' => false, 'children' => array( 'text' => new Fieldmanager_Textfield( 'Text Field' ), 'subgroup' => new Fieldmanager_Group( array( 'children' => array( 'text' => new Fieldmanager_Textfield( 'Text Field' ), 'textarea' => new Fieldmanager_TextArea( 'TextArea' ), 'checkbox' => new Fieldmanager_Checkbox( 'Checkbox' ), ), ) ), ), ) ); $fm->add_meta_box( 'Multi-Level Groups', 'post' ); ``` -------------------------------- ### PHP: Create Repeating Text Field with Fieldmanager Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Storing-data-unserialized Demonstrates creating a standalone repeating text field using Fieldmanager. Allows for multiple iterations of the field, each with its own key. ```php $fm = new Fieldmanager_Textfield( array( 'name' => 'repeating_text_field', 'limit' => 0, 'serialize_data' => false, ) ); $fm->add_meta_box( 'Repeating Standalone Text Field', 'post' ); ``` -------------------------------- ### PHP: Create Tabbed Subgroup with Fieldmanager Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Storing-data-unserialized Demonstrates nesting a tabbed group within another group. All fields within the structure are saved to individual meta keys, ignoring group serialization for presentation. ```php $fm = new Fieldmanager_Group( array( 'name' => 'base_group', 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'title' => new Fieldmanager_TextField( 'Title' ), 'tabs' => new Fieldmanager_Group( array( 'tabbed' => true, 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'tab-1' => new Fieldmanager_Group( array( 'label' => 'Tab One', 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'text' => new Fieldmanager_Textfield( 'Text Field' ), ) ) ), 'tab-2' => new Fieldmanager_Group( array( 'label' => 'Tab Two', 'serialize_data' => false, 'add_to_prefix' => false, 'children' => array( 'textarea' => new Fieldmanager_TextArea( 'TextArea' ), 'media' => new Fieldmanager_Media( 'Media File' ), ) ) ), ) ) ) ) ) ); $fm->add_meta_box( 'Tabbed Subgroup', 'post' ); ``` -------------------------------- ### Declare Fieldmanager Fields Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Illustrates how to define and return an array of Fieldmanager fields within a PHP function. This is typically used to set up the fields for a meta box. ```php new Fieldmanager_Textfield( array( 'label' => __('Text Sample'), 'name' => 'sample-text', ) ) ); } ?> ``` -------------------------------- ### Define and Add FM Fields to Custom Context (PHP) Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-After-the-Title-(Above-Main-WP-Content-Editor) This PHP function defines a Fieldmanager group with text and link fields and adds it to the custom 'ai_after_title' context for the 'post' post type. It utilizes the Fieldmanager library to create and register the meta box. ```PHP function ai_after_title_fm_fields() { $fm = new Fieldmanager_Group( array( 'name' => 'after_title_fm_fields', 'children' => array( 'After Title Text' => new Fieldmanager_TextField( __( 'After Title Text', 'alleyinteractive' ) ), 'After Title Link' => new Fieldmanager_Link( __( 'After Title Link', 'alleyinteractive' ) ), ), ) ); $fm->add_meta_box( __( 'AI After Title', 'alleyinteractive' ), array( 'post' ), 'ai_after_title', 'high' ); } add_action( 'fm_post_post', 'ai_after_title_fm_fields' ); ``` -------------------------------- ### Select Box from Taxonomy Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Demonstrates how to create a Fieldmanager_Select field populated with data from a WordPress taxonomy, specifically 'category'. It includes options for ordering and hiding empty terms. ```php new Fieldmanager_Select( array( 'first_element' => array( '', '' ), 'label' => null, 'name' => 'sample-select', 'taxonomy' => 'category', 'taxonomy_args' => array( 'orderby' => 'name', 'hide_empty' => false ) ) ) ?> ``` -------------------------------- ### Add Meta Box to Post Type Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Demonstrates how to add a meta box to a WordPress post type using Fieldmanager. It shows the basic structure for registering a meta box with a specific field and rendering it in the admin area. ```php ``` -------------------------------- ### Select Box from Custom Data Source: https://github.com/alleyinteractive/wordpress-fieldmanager/wiki/Adding-Fields-with-Fieldmanager Shows how to populate a Fieldmanager_Select field with custom data returned by a PHP function. The function must return a keyed array where each item has 'name' and 'value' keys. ```php new Fieldmanager_Select( array( 'first_element' => array( '', '' ), 'label' => null, 'name' => 'sample-select', 'data' => some_custom_data_function(), ) ), function some_custom_data_function() { return array( '0' => array('name' => 'some-name', 'value'=>'some-value'), ); } ?> ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.