/** * Register Term Meta. * * This function should only be invoked through the 'admin_init' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } * @param string|array $taxonomies Array of taxonomies for which the term meta should be registered. * @param string $section A section id to define the group of fields. * * @return bool True on success, false on failure. */ function beans_register_term_meta(array $fields, $taxonomies, $section) { /** * Filter the term meta fields. * * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. * * @since 1.0.0 * * @param array $fields An array of term meta fields. */ $fields = apply_filters("beans_term_meta_fields_{$section}", _beans_pre_standardize_fields($fields)); /** * Filter the taxonomies used to define whether the fields set should be displayed or not. * * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. * * @since 1.0.0 * * @param string|array $taxonomies Taxonomies used to define whether the fields set should be displayed or not. */ $taxonomies = apply_filters("beans_term_meta_taxonomies_{$section}", (array) $taxonomies); // Stop here if the current page isn't concerned. if (!_beans_is_admin_term($taxonomies) || !is_admin()) { return; } // Stop here if the field can't be registered. if (!beans_register_fields($fields, 'term_meta', $section)) { return false; } // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_PATH . 'term-meta/class.php'; new _Beans_Term_Meta($section); }
/** * Register WP Customize Options. * * This function should only be invoked through the 'init' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similary to the * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } * @param string $section The WP customize section to which the fields should be added. Add a unique id * to create a new section. * @param array $args { * Optional. Array of arguments used to register the fields. * * @type string $title The visible name of a controller section. * @type int $priority This controls the order in which this section appears * in the Theme Customizer sidebar. Default 30. * @type string $description This optional argument can add additional descriptive * text to the section. Default false. * } * * @return bool True on success, false on failure. */ function beans_register_wp_customize_options(array $fields, $section, $args = array()) { $fields = apply_filters("beans_wp_customize_fields_{$section}", _beans_pre_standardize_fields($fields)); // Stop here if the current page isn't concerned. if (!class_exists('WP_Customize_Manager')) { return; } // Stop here if the field can't be registered. if (!beans_register_fields($fields, 'wp_customize', $section)) { return false; } // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_COMPONENTS_PATH . 'wp-customize/class.php'; new _Beans_WP_Customize($section, $args); }
/** * Register Term Meta. * * This function should only be invoked through the 'admin_init' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for the 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } * @param array $taxonomies Array of taxonomies for which the term meta should be registered. * @param string $section A section id to define the group of fields. * * @return bool True on success, false on failure. */ function beans_register_term_meta(array $fields, $taxonomies, $section) { $fields = apply_filters("beans_term_meta_fields_{$section}", _beans_pre_standardize_fields($fields)); $taxonomies = apply_filters("beans_term_meta_taxonomies_{$section}", $taxonomies); // Stop here if the current page isn't concerned. if (!_beans_is_admin_term($taxonomies) || !is_admin()) { return; } // Stop here if the field can't be registered. if (!beans_register_fields($fields, 'term_meta', $section)) { return false; } // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_COMPONENTS_PATH . 'term-meta/class.php'; new _Beans_Term_Meta($section); }
/** * Register options. * * This function should only be invoked through the 'admin_init' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field types. Defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } * @param string $menu_slug The menu slug used by fields. * @param string $section A section id to define the group of fields. * @param array $args { * Optional. Array of arguments used to register the fields. * * @type string $title The metabox Title. Default 'Undefined'. * @type string $context Where on the page where the metabox should be shown * ('normal', 'column'). Default 'normal'. * } * * @return bool True on success, false on failure. */ function beans_register_options(array $fields, $menu_slug, $section, $args = array()) { $fields = apply_filters("beans_options_fields_{$section}", _beans_pre_standardize_fields($fields)); $menu_slug = apply_filters("beans_options_menu_slug_{$section}", $menu_slug); // Stop here if the page isn't concerned. if (beans_get('page') !== $menu_slug || !is_admin()) { return; } // Stop here if the field can't be registered. if (!beans_register_fields($fields, 'option', $section)) { return false; } // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_COMPONENTS_PATH . 'options/class.php'; $class = new _Beans_Options(); $class->register($section, $args); return true; }
/** * Register Post Meta. * * This function should only be invoked through the 'admin_init' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. Defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } * @param string|array $conditions Array of 'post types id(s)', 'post id(s)' or 'page template slug(s)' for which the post meta should be registered. * 'page template slug(s)' must include '.php' file extention. Set to true to display everywhere. * @param string $section A section id to define the group of fields. * @param array $args { * Optional. Array of arguments used to register the fields. * * @type string $title The metabox Title. Default 'Undefined'. * @type string $context Where on the page the metabox should be shown * ('normal', 'advanced', or 'side'). Default 'normal'. * @type int $priority The priority within the context where the boxes should show * ('high', 'core', 'default' or 'low'). Default 'high'. * } * * @return bool True on success, false on failure. */ function beans_register_post_meta(array $fields, $conditions, $section, $args = array()) { global $_beans_post_meta_conditions; /** * Filter the post meta fields. * * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. * * @since 1.0.0 * * @param array $fields An array of post meta fields. */ $fields = apply_filters("beans_post_meta_fields_{$section}", _beans_pre_standardize_fields($fields)); /** * Filter the conditions used to define whether the fields set should be displayed or not. * * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. * * @since 1.0.0 * * @param string|array $conditions Conditions used to define whether the fields set should be displayed or not. */ $conditions = apply_filters("beans_post_meta_post_types_{$section}", $conditions); $_beans_post_meta_conditions = array_merge($_beans_post_meta_conditions, (array) $conditions); // Stop here if the current page isn't concerned. if (!_beans_is_post_meta_conditions($conditions) || !is_admin()) { return; } // Stop here if the field can't be registered. if (!beans_register_fields($fields, 'post_meta', $section)) { return false; } // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_PATH . 'post-meta/class.php'; new _Beans_Post_Meta($section, $args); }
/** * Register options. * * This function should only be invoked through the 'admin_init' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similar to the * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field types. Defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } * @param string $menu_slug The menu slug used by fields. * @param string $section A section id to define the group of fields. * @param array $args { * Optional. Array of arguments used to register the fields. * * @type string $title The metabox Title. Default 'Undefined'. * @type string $context Where on the page where the metabox should be shown * ('normal', 'column'). Default 'normal'. * } * * @return bool True on success, false on failure. */ function beans_register_options(array $fields, $menu_slug, $section, $args = array()) { /** * Filter the options fields. * * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. * * @since 1.0.0 * * @param array $fields An array of options fields. */ $fields = apply_filters("beans_options_fields_{$section}", _beans_pre_standardize_fields($fields)); /** * Filter the options fields menu slug. * * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. * * @since 1.0.0 * * @param array $menu_slug The menu slug. */ $menu_slug = apply_filters("beans_options_menu_slug_{$section}", $menu_slug); // Stop here if the page isn't concerned. if (beans_get('page') !== $menu_slug || !is_admin()) { return; } // Stop here if the field can't be registered. if (!beans_register_fields($fields, 'option', $section)) { return false; } // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_PATH . 'options/class.php'; $class = new _Beans_Options(); $class->register($section, $args); return true; }
/** * Register WP Customize Options. * * This function should only be invoked through the 'customize_register' action. * * @since 1.0.0 * * @param array $fields { * Array of fields to register. * * @type string $id A unique id used for the field. This id will also be used to save the value in * the database. * @type string $type The type of field to use. Please refer to the Beans core field types for more * information. Custom field types are accepted here. * @type string $label The field label. Default false. * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * @type array $attributes An array of attributes to add to the field. The array key defines the * attribute name and the array value defines the attribute value. Default array. * @type mixed $default The default field value. Default false. * @type array $fields Must only be used for 'group' field type. The array arguments are similary to the * {@see beans_register_fields()} $fields arguments. * @type bool $db_group Must only be used for 'group' field type. It defines whether the group of fields * registered should be saved as a group in the database or as individual * entries. Default false. * } * @param string $section The WP customize section to which the fields should be added. Add a unique id * to create a new section. * @param array $args { * Optional. Array of arguments used to register the fields. * * @type string $title The visible name of a controller section. * @type int $priority This controls the order in which this section appears * in the Theme Customizer sidebar. Default 30. * @type string $description This optional argument can add additional descriptive * text to the section. Default false. * } * * @return bool True on success, false on failure. */ function beans_register_wp_customize_options(array $fields, $section, $args = array()) { /** * Filter the customizer fields. * * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. * * @since 1.0.0 * * @param array $fields An array of customizer fields. */ $fields = apply_filters("beans_wp_customize_fields_{$section}", _beans_pre_standardize_fields($fields)); // Stop here if the current page isn't concerned. if (!is_customize_preview()) { return; } // Stop here if the field can't be registered. if (!beans_register_fields($fields, 'wp_customize', $section)) { return false; } // Load the class only if this function is called to prevent unnecessary memory usage. require_once BEANS_API_PATH . 'wp-customize/class.php'; new _Beans_WP_Customize($section, $args); }
/** * Standardize fields. * * @ignore */ function _beans_pre_standardize_fields($fields) { $_fields = array(); foreach ($fields as $field) { $_fields[$field['id']] = $field; if (beans_get('type', $field) === 'group') { $_fields[$field['id']]['fields'] = _beans_pre_standardize_fields($field['fields']); } } return $_fields; }