"
.".compat-attachment-fields tr.compat-field-twojs_gallery_line,"
.".compat-attachment-fields tr.compat-field-twojs_gallery_type_link,"
.".compat-attachment-fields tr.compat-field-twojs_style,"
.".compat-attachment-fields tr.compat-field-twojs_opacity,"
.".compat-attachment-fields tr.compat-field-twojs_padding,"
.".compat-attachment-fields tr.compat-field-twojs_position,"
.".compat-attachment-fields tr.compat-field-twojs_size,"
.".compat-attachment-fields tr.compat-field-twojs_gallery_link{display:none; }";
}
add_action('admin_head', 'twoj_hide_attachment_field');
if( !function_exists('twojGetMediaOptions') ){
function twojGetMediaOptions( $listSelect, $selectOption = ''){
$optionsHtml = '';
if(count($listSelect))
foreach($listSelect as $key => $value) $optionsHtml .= '';
return $optionsHtml;
}
}
function twoj_slideshow_attachment_field_credit( $form_fields, $post ) {
$form_fields[TWOJ_SLIDESHOW_PREFIX.'gallery_line'] = array(
'label' => '',
'input' => 'html',
'html' => '
'.__('2J Slideshow', 'twoj_slideshow').'
'
);
$form_fields[TWOJ_SLIDESHOW_PREFIX.'gallery_link'] = array(
'label' => __('Link\Video'),
'input' => 'text',
'value' => get_post_meta( $post->ID, TWOJ_SLIDESHOW_PREFIX.'gallery_link', true ),
);
$value = get_post_meta( $post->ID, TWOJ_SLIDESHOW_PREFIX.'gallery_type_link', true );
$selectBox =
"";
$form_fields[TWOJ_SLIDESHOW_PREFIX.'gallery_type_link'] = array(
'label' => __('Type Slide'),
'input' => 'html',
'default' => 'link',
'value' => $value,
'html' => $selectBox
);
$value = get_post_meta( $post->ID, TWOJ_SLIDESHOW_PREFIX.'style', true );
$listSelect = array(
'light' => __( 'light' , 'cmb' ),
'dark' => __( 'dark' , 'cmb' ),
'purple' => __( 'purple' , 'cmb' ),
'blue' => __( 'blue' , 'cmb' ),
'darkblue' => __( 'dark blue' ,'cmb' ),
'red' => __( 'red' , 'cmb' ),
'yellow' => __( 'yellow' , 'cmb' ),
'green' => __( 'green' , 'cmb' ),
'orange' => __( 'orange' , 'cmb' ),
'violet' => __( 'violet' , 'cmb' ),
'pink' => __( 'pink' , 'cmb' ),
'brown' => __( 'brown' , 'cmb' ),
'coral' => __( 'coral' , 'cmb' ),
'redviolet'=> __( 'redviolet' ,'cmb' ),
'salmon' => __( 'salmon' , 'cmb' ),
'rosepink' => __( 'rosepink' , 'cmb' ),
'redorange' => __( 'redorange' , 'cmb' ),
'carmine' => __( 'carmine' , 'cmb' ),
'maroon' => __( 'maroon' , 'cmb' ),
);
$selectBox = "';
$form_fields[TWOJ_SLIDESHOW_PREFIX.'style'] = array(
'label' => __('Style'),
'input' => 'html',
'default' => 'light',
'value' => $value,
'html' => $selectBox
);
/* 10 20 30 40 50 60 70 80 90 */
$value = get_post_meta( $post->ID, TWOJ_SLIDESHOW_PREFIX.'opacity', true );
$listSelect = array(
'' => __( 'off' , 'cmb' ),
'10' => '10%',
'20' => '20%',
'30' => '30%',
'40' => '40%',
'50' => '50%',
'60' => '60%',
'70' => '70%',
'80' => '80%',
'90' => '90%',
);
$selectBox = "';
$form_fields[TWOJ_SLIDESHOW_PREFIX.'opacity'] = array(
'label' => __('Opacity'),
'input' => 'html',
'default' => '70%',
'value' => $value,
'html' => $selectBox
);
/* padding 10 20 30 40 50 60 70 80 90 1p 2p 3p 5p 7p 10p 20p */
$value = get_post_meta( $post->ID, TWOJ_SLIDESHOW_PREFIX.'padding', true );
$listSelect = array(
'' => __( 'off' , 'cmb' ),
'10' => '10',
'20' => '20',
'30' => '30',
'40' => '40',
'50' => '50',
'60' => '60',
'70' => '70',
'80' => '80',
'90' => '90',
'1p' => '1%',
'2p' => '2%',
'3p' => '3%',
'5p' => '5%',
'7p' => '7%',
'10p' => '10%',
'20p' => '20%',
);
$selectBox = "';
$form_fields[TWOJ_SLIDESHOW_PREFIX.'padding'] = array(
'label' => __('Padding'),
'input' => 'html',
'default' => '20',
'value' => $value,
'html' => $selectBox
);
/* left bottom right top | 30 40 50 60 70 100 */
$value = get_post_meta( $post->ID, TWOJ_SLIDESHOW_PREFIX.'position', true );
$listSelect = array(
'left' => __( 'left' , 'cmb' ),
'bottom' => __( 'bottom' , 'cmb' ),
'right' => __( 'right' , 'cmb' ),
'top' => __( 'top' , 'cmb' ),
);
$selectBox = "';
$form_fields[TWOJ_SLIDESHOW_PREFIX.'position'] = array(
'label' => __('Position'),
'input' => 'html',
'default' => 'bottom',
'value' => $value,
'html' => $selectBox
);
/* left bottom right top | 30 40 50 60 70 100 */
$value = get_post_meta( $post->ID, TWOJ_SLIDESHOW_PREFIX.'size', true );
$listSelect = array(
'5' => '5%',
'10' => '10%',
'15' => '15%',
'20' => '20%',
'30' => '30%',
'40' => '40%',
'50' => '50%',
'60' => '60%',
'70' => '70%',
'100' => '100%',
);
$selectBox = "';
$form_fields[TWOJ_SLIDESHOW_PREFIX.'size'] = array(
'label' => __('Size'),
'input' => 'html',
'default' => '40',
'value' => $value,
'html' => $selectBox
);
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'twoj_slideshow_attachment_field_credit', 10, 2 );
function twoj_slideshow_attachment_field_credit_save( $post, $attachment ) {
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'gallery_video_link'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'gallery_video_link', esc_url( $attachment[TWOJ_SLIDESHOW_PREFIX.'gallery_video_link'] ) );
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'gallery_link'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'gallery_link', esc_url( $attachment[TWOJ_SLIDESHOW_PREFIX.'gallery_link'] ) );
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'gallery_type_link'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'gallery_type_link', $attachment[TWOJ_SLIDESHOW_PREFIX.'gallery_type_link'] );
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'style'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'style', $attachment[TWOJ_SLIDESHOW_PREFIX.'style'] );
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'opacity'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'opacity', $attachment[TWOJ_SLIDESHOW_PREFIX.'opacity'] );
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'padding'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'padding', $attachment[TWOJ_SLIDESHOW_PREFIX.'padding'] );
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'position'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'position', $attachment[TWOJ_SLIDESHOW_PREFIX.'position'] );
if( isset( $attachment[TWOJ_SLIDESHOW_PREFIX.'size'] ) )
update_post_meta( $post['ID'], TWOJ_SLIDESHOW_PREFIX.'size', $attachment[TWOJ_SLIDESHOW_PREFIX.'size'] );
return $post;
}
add_filter( 'attachment_fields_to_save', 'twoj_slideshow_attachment_field_credit_save', 10, 2 );