bekliyoruz hocam
1 saat içinde bu sayfada yayınlanması muhtemel...
ID, "alan1", true); ?>
add_action( 'admin_menu', 'mo_create_meta_box' );
add_action( 'save_post', 'mo_save_meta_data' );
function mo_create_meta_box() {
add_meta_box( 'post-meta-boxes', __('Başlık', 'momeralpi'), 'post_meta_boxes', 'post', 'normal', 'high' );
}
function mo_post_meta_boxes() {
if(get_option('momeralpi_seo_field') == 'On') {
$meta_boxes = array(
'alan1' => array( 'name' => 'alan1', 'title' => __('Alan 1:', 'momeralpi'), 'type' => 'text'),
);
} else {
$meta_boxes = array(
'alan1' => array( 'name' => 'alan1', 'title' => __('Alan 1:', 'momeralpi'), 'type' => 'text'),
);
}
return apply_filters( 'mo_post_meta_boxes', $meta_boxes );
}
function post_meta_boxes() {
global $post;
$meta_boxes = mo_post_meta_boxes();
?>
$value = get_post_meta( $post->ID, $meta['name'], true );
if ( $meta['type'] == 'text' )
get_meta_text_input( $meta, $value );
elseif ( $meta['type'] == 'textarea' )
get_meta_textarea( $meta, $value );
elseif ( $meta['type'] == 'select' )
get_meta_select( $meta, $value );
elseif ( $meta['type'] == 'momeralpiselect' )
get_meta_momeralpiselect( $meta, $value );
elseif ( $meta['type'] == 'selectadmin' )
get_meta_selectadmin( $meta, $value );
elseif ( $meta['type'] == 'checkbox' )
get_meta_checkbox( $meta, $value );
elseif ( $meta['type'] == 'selectdate' )
get_meta_selectgrup( $meta, $value );
endforeach; ?>
}
function page_meta_boxes() {
global $post;
$meta_boxes = mo_page_meta_boxes(); ?>
$value = stripslashes( get_post_meta( $post->ID, $meta['name'], true ) );
if ( $meta['type'] == 'text' )
get_meta_text_input( $meta, $value );
elseif ( $meta['type'] == 'textarea' )
get_meta_textarea( $meta, $value );
elseif ( $meta['type'] == 'select' )
get_meta_select( $meta, $value );
endforeach; ?>
}
function get_meta_text_input( $args = array(), $value = false ) {
extract( $args ); ?>
}
function get_meta_select( $args = array(), $value = false ) {
extract( $args ); ?>
}
function get_meta_textarea( $args = array(), $value = false ) {
extract( $args ); ?>
}
function get_meta_momeralpiselect( $args = array(), $value = false ) {
extract( $args ); ?>
----------------------------------------------------------------------------------------------
}
function mo_save_meta_data( $post_id ) {
global $post;
if ( 'page' == $_POST['post_type'] )
$meta_boxes = array_merge( mo_page_meta_boxes() );
else
$meta_boxes = array_merge( mo_post_meta_boxes() );
foreach ( $meta_boxes as $meta_box ) :
if ( !wp_verify_nonce( $_POST[$meta_box['name'] . '_noncename'], plugin_basename( __FILE__ ) ) )
return $post_id;
if ( 'page' == $_POST['post_type'] && !current_user_can( 'edit_page', $post_id ) )
return $post_id;
elseif ( 'post' == $_POST['post_type'] && !current_user_can( 'edit_post', $post_id ) )
return $post_id;
$data = stripslashes( $_POST[$meta_box['name']] );
if ( get_post_meta( $post_id, $meta_box['name'] ) == '' )
add_post_meta( $post_id, $meta_box['name'], $data, true );
elseif ( $data != get_post_meta( $post_id, $meta_box['name'], true ) )
update_post_meta( $post_id, $meta_box['name'], $data );
elseif ( $data == '' )
delete_post_meta( $post_id, $meta_box['name'], get_post_meta( $post_id, $meta_box['name'], true ) );
endforeach;
}
?>