| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Custom Metadata Manager |
| 4 |
* Plugin URI: https://wordpress.org/plugins/custom-metadata/ |
| 5 |
* Description: An easy way to add custom fields to your object types (posts, pages, custom post types, users, comments). |
| 6 |
* Version: 0.8.0 |
| 7 |
* Requires at least: 6.4 |
| 8 |
* Requires PHP: 7.4 |
| 9 |
* Author: Automattic, Stresslimit & Contributors |
| 10 |
* Author URI: https://github.com/Automattic/custom-metadata/ |
| 11 |
* Text Domain: custom-metadata |
| 12 |
* License: GPL-2.0-or-later |
| 13 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 14 |
* |
| 15 |
* @package Automattic\CustomMetadata |
| 16 |
*/ |
| 17 |
|
| 18 |
/* |
| 19 |
Copyright 2010-2013 The Contributors |
| 20 |
|
| 21 |
GNU General Public License, Free Software Foundation <http://creativecommons.org/licenses/GPL/2.0/> |
| 22 |
|
| 23 |
This program is free software; you can redistribute it and/or modify |
| 24 |
it under the terms of the GNU General Public License as published by |
| 25 |
the Free Software Foundation; either version 2 of the License, or |
| 26 |
(at your option) any later version. |
| 27 |
|
| 28 |
This program is distributed in the hope that it will be useful, |
| 29 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 |
GNU General Public License for more details. |
| 32 |
|
| 33 |
You should have received a copy of the GNU General Public License |
| 34 |
along with this program; if not, write to the Free Software |
| 35 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 36 |
|
| 37 |
*/ |
| 38 |
|
| 39 |
// Exit if accessed directly. |
| 40 |
if ( ! defined( 'ABSPATH' ) ) { |
| 41 |
exit; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Set this to true in your wp-config.php file to enable debug/test mode. |
| 46 |
*/ |
| 47 |
if ( ! defined( 'CUSTOM_METADATA_MANAGER_DEBUG' ) ) { |
| 48 |
define( 'CUSTOM_METADATA_MANAGER_DEBUG', false ); |
| 49 |
} |
| 50 |
|
| 51 |
if ( CUSTOM_METADATA_MANAGER_DEBUG ) { |
| 52 |
require_once 'custom_metadata_examples.php'; |
| 53 |
} |
| 54 |
|
| 55 |
require_once __DIR__ . '/includes/class-custom-metadata-manager.php'; |
| 56 |
|
| 57 |
global $custom_metadata_manager; // for backwards-compatibility we keep the global around, but it shouldn't be used. |
| 58 |
$custom_metadata_manager = custom_metadata_manager::instance(); |
| 59 |
|
| 60 |
/** |
| 61 |
* Registers a metadata field. |
| 62 |
* |
| 63 |
* @param string $slug Unique slug for the field. |
| 64 |
* @param array|string $object_types Object type(s) the field applies to. |
| 65 |
* @param array $args Field arguments. |
| 66 |
* @return void |
| 67 |
*/ |
| 68 |
function x_add_metadata_field( $slug, $object_types = 'post', $args = array() ) { |
| 69 |
custom_metadata_manager::instance()->add_metadata_field( $slug, $object_types, $args ); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Registers a multifield. |
| 74 |
* |
| 75 |
* @param string $slug Unique slug for the multifield. |
| 76 |
* @param array|string $object_types Object type(s) the multifield applies to. |
| 77 |
* @param array $args Multifield arguments. |
| 78 |
* @return void |
| 79 |
*/ |
| 80 |
function x_add_metadata_multifield( $slug, $object_types = 'post', $args = array() ) { |
| 81 |
custom_metadata_manager::instance()->add_multifield( $slug, $object_types, $args ); |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Registers a metadata group. |
| 86 |
* |
| 87 |
* @param string $slug Unique slug for the group. |
| 88 |
* @param array|string $object_types Object type(s) the group applies to. |
| 89 |
* @param array $args Group arguments. |
| 90 |
* @return void |
| 91 |
*/ |
| 92 |
function x_add_metadata_group( $slug, $object_types, $args = array() ) { |
| 93 |
custom_metadata_manager::instance()->add_metadata_group( $slug, $object_types, $args ); |
| 94 |
} |
| 95 |
|