ralfhortt / wp-meta-box-contact
A WordPress meta box for contact data
4.1
2020-11-23 20:07 UTC
Requires
This package is auto-updated.
Last update: 2024-10-24 04:38:19 UTC
README
Installation
composer require ralfhortt/wp-meta-box-contact
Usage
new MetaBoxContact( array $screen = [], string $context = 'advanced', string $priority = 'default' )
Serviceloader
use RalfHortt\MetaBoxContact\MetaBoxContact; PluginFactory::create() ->addService(MetaBoxContact::class, ['page'], 'advanced', 'default') ->boot();
Standalone
use RalfHortt\MetaBoxContact\MetaBoxContact; (new MetaBoxContact(['page'], 'advanced', 'default' ))->register();
Fields
- Phone
- Fax
- Mobile
- URL
<?php $phone = get_post_meta( $post->ID, 'contact-phone', TRUE ); $fax = get_post_meta( $post->ID, 'contact-fax', TRUE ); $mobile = get_post_meta( $post->ID, 'contact-mobile', TRUE ); $email = get_post_meta( $post->ID, 'contact-email', TRUE ); $url = get_post_meta( $post->ID, 'contact-url', TRUE );
Hooks
Filter
wp-meta-box-contact/identifier
- Change meta box idwp-meta-box-contact/label
- Change meta box labelwp-meta-box-contact/phone-{$postType}
- Hide phone field for $postTypewp-meta-box-contact/fax-{$postType}
- Hide fax field for $postTypewp-meta-box-contact/mobile-{$postType}
- Hide mobile field for $postTypewp-meta-box-contact/email-{$postType}
- Hide email field for $postTypewp-meta-box-contact/url-{$postType}
- Hide url field for $postType
Example
<?php (new MetaBoxContact(['page'], 'advanced', 'default' ))->register(); add_filter('wp-meta-box-contact-url-page', '__return_false');
Action
wp-meta-contact/before
- Add fields before the phone fieldwp-meta-contact/after
- Add fields after the url fieldwp-meta-contact/save
- Save custom fields
Changelog
v4.1 - 2020-11-23
- Update dependency
v4.0 - 2020-11-06
- Update dependency
- Added translation
v3.0 - 2020-11-02
- Updated dependency
v.2.0.0 - 2020-01-15
- Changed: Namespac ed hooks
- Changed: Removed redundant hooks
- Fixed: Broke URL field
v1.0.0 - 2020-01-14
- Initial release