test like
"portfolio_image", "title" => "Madia for portfolio posts", "description" => "You can put here your image or video links which, like youtube, vimeo etc. ", "type" => "rttheme_upload", "scope" => array( "post" ), "capability" => "edit_post" ), array( "name" => "portfolio_thumb_image", "title" => "Thumbnail image for portfolio posts", "description" => "Write url of an image if you want to use different thumbnail image for the portfolio item. If you are putting this post as image on porfolio item, you don't have to provide thumbnail link beacause it will create automaticly from link above.", "type" => "rttheme_upload", "scope" => array( "post" ), "capability" => "edit_post" ), array( "name" => "portfolio_desc", "title" => "Short description for portfolio posts", "description" => "", "type" => "textarea", "scope" => array( "post" ), "capability" => "edit_post" ), ); /** * PHP 4 Compatible Constructor */ function rt_custom_fields() { $this->__construct(); } /** * PHP 5 Constructor */ function __construct() { add_action( 'admin_menu', array( &$this, 'createCustomFields' ) ); add_action( 'save_post', array( &$this, 'saveCustomFields' ) ); // Comment this line out if you want to keep default custom fields meta box //add_action( 'do_meta_boxes', array( &$this, 'removeDefaultCustomFields' ), 10, 3 ); } /** * Remove the default Custom Fields meta box */ function removeDefaultCustomFields( $type, $context, $post ) { foreach ( array( 'normal', 'advanced', 'side' ) as $context ) { remove_meta_box( 'postcustom', 'post', $context ); remove_meta_box( 'pagecustomdiv', 'page', $context ); } } /** * Create the new Custom Fields meta box */ function createCustomFields() { if ( function_exists( 'add_meta_box' ) ) { add_meta_box( 'rt_custom_fields', 'RT-Theme Portfolio Fields', array( &$this, 'displayCustomFields' ), 'portfolio', 'normal', 'high' ); } } /** * Display the new Custom Fields meta box */ function displayCustomFields() { global $post; ?>
customFields as $customField ) { // Check scope $scope = $customField[ 'scope' ]; $output = false; foreach ( $scope as $scopeItem ) { switch ( $scopeItem ) { case "post": { // Output on any post screen if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="post-new.php" || $post->post_type=="post" || $post->post_type=="portfolio" ) $output = true; break; } case "page": { // Output on any page screen if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="page-new.php" || $post->post_type=="page" || $post->post_type=="portfolio" ) $output = true; break; } } if ( $output ) break; } // Check capability if ( !current_user_can( $customField['capability'], $post->ID ) ) $output = false; // Output if allowed if ($output) { ?>
prefix . $customField[ 'name' ] .'" style="display:inline;">' . $customField[ 'title' ] . '  '; if ( $customField[ 'description' ] ) echo '

' . $customField[ 'description' ] . '

'; echo 'ID, $this->prefix . $customField['name'], true ) == "yes" ) echo ' checked="checked"'; echo '" style="width: auto;" />'; break; } case "textarea": { // Text area echo ''; if ( $customField[ 'description' ] ) echo '

' . $customField[ 'description' ] . '

'; echo ''; break; } case "rttheme_upload": { // rt-upload button echo ''; if ( $customField[ 'description' ] ) echo '

' . $customField[ 'description' ] . '

'; echo ''; break; } default: { // Plain text field echo ''; if ( $customField[ 'description' ] ) echo '

' . $customField[ 'description' ] . '

'; echo ''; break; } } ?>
customFields as $customField ) { if ( current_user_can( $customField['capability'], $post_id ) ) { if ( isset( $_POST[ $this->prefix . $customField['name'] ] ) && trim( $_POST[ $this->prefix . $customField['name'] ] ) ) { update_post_meta( $post_id, $this->prefix . $customField[ 'name' ], $_POST[ $this->prefix . $customField['name'] ] ); } else { delete_post_meta( $post_id, $this->prefix . $customField[ 'name' ] ); } } } } } // End Class } // End if class exists statement $rt_custom_fields_var = new rt_custom_fields();
 
Advertisement

CDI בפייסבוק


שתף חברים בפייסבוק בדף זה

הצטרפות לניוזלטר