Skip to content

Instantly share code, notes, and snippets.

@michaeluno
Created February 8, 2014 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeluno/8875513 to your computer and use it in GitHub Desktop.
Save michaeluno/8875513 to your computer and use it in GitHub Desktop.
Testing the image field type with the attritbute_to_store key.
<?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