Created
February 8, 2014 01:58
-
-
Save michaeluno/8875513 to your computer and use it in GitHub Desktop.
Testing the image field type with the attritbute_to_store key.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Plugin Name: Admin Page Framework - Test Image Attributes in Meta Box */ | |
if ( ! class_exists( 'AdminPageFramework' ) ) { | |
include_once( dirname( dirname( __FILE__ ) ) . '/admin-page-framework/development/admin-page-framework.php' ); | |
// include_once( dirname( __FILE__ ) . '/library/admin-page-framework.min.php' ); | |
} | |
class APF_MetaBox_TestImageAttributes extends AdminPageFramework_MetaBox { | |
public function setUp() { | |
$this->addSettingFields( | |
array( | |
'field_id' => 'image_with_attributes', | |
'type' => 'image', | |
'attributes_to_store' => array( 'alt', 'id', 'title', 'caption', 'width', 'height', 'align', 'link' ), | |
'title' => __( 'Image with Attributes', 'admin-page-framework-demo' ), | |
) | |
); | |
} | |
public function do_APF_MetaBox_TestImageAttributes() { | |
$iPostID = $GLOBALS['post']->ID; | |
$aPostData = array(); | |
foreach( ( array ) get_post_custom_keys( $iPostID ) as $sKey ) // This way, array will be unserialized; easier to view. | |
$aPostData[ $sKey ] = get_post_meta( $iPostID, $sKey, true ); | |
$this->oDebug->dumpArray( $aPostData ); | |
} | |
} | |
new APF_MetaBox_TestImageAttributes( | |
'test_metabox_image_attributes', // meta box ID | |
__( 'Test Meta Box to Test Image Attributes', 'admin-page-framework-demo' ), // title | |
array( 'post' ), // post type slugs: post, page, etc. | |
'normal', // context (what kind of metabox this is) | |
'default' // priority | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment