Commit eb81946e authored by Kevin Stover's avatar Kevin Stover

Merge pull request #91 from pippinsplugins/master

Improve field description position options for submit buttons
parents 220429a1 2ef5486e
<?php
add_action('init', 'ninja_forms_register_edit_field_desc');
function ninja_forms_register_edit_field_desc(){
add_action('ninja_forms_edit_field_after_registered', 'ninja_forms_edit_field_desc', 10);
add_action( 'init', 'ninja_forms_register_edit_field_desc' );
function ninja_forms_register_edit_field_desc() {
add_action( 'ninja_forms_edit_field_after_registered', 'ninja_forms_edit_field_desc', 10 );
}
function ninja_forms_edit_field_desc($field_id){
function ninja_forms_edit_field_desc( $field_id ) {
global $ninja_forms_fields;
$field_row = ninja_forms_get_field_by_id($field_id);
$field_row = ninja_forms_get_field_by_id( $field_id );
$field_type = $field_row['type'];
$field_data = $field_row['data'];
$reg_field = $ninja_forms_fields[$field_type];
......@@ -15,54 +15,57 @@ function ninja_forms_edit_field_desc($field_id){
} else {
$edit_desc = true;
}
if($edit_desc){
if(isset($field_data['desc_text'])){
if ( $edit_desc ) {
if ( isset( $field_data['desc_text'] ) ) {
$desc_text = $field_data['desc_text'];
}else{
} else {
$desc_text = '';
}
if(isset($field_data['show_desc'])){
if ( isset( $field_data['show_desc'] ) ) {
$show_desc = $field_data['show_desc'];
}else{
} else {
$show_desc = '';
}
if( $show_desc == 1 ){
if ( $show_desc == 1 ) {
$display_span = '';
}else{
} else {
$display_span = ' style="display:none;"';
}
if( !isset ( $desc_pos_options ) OR $desc_pos_options == '' ){
$options = array(
array('name' => __( 'None', 'ninja-forms' ), 'value' => 'none'),
array('name' => __( 'Before Everything', 'ninja-forms' ), 'value' => 'before_everything'),
array('name' => __( 'Before Label', 'ninja-forms' ), 'value' => 'before_label'),
array('name' => __( 'After Label', 'ninja-forms' ), 'value' => 'after_label'),
array('name' => __( 'After Everything', 'ninja-forms' ), 'value' => 'after_everything'),
);
}else{
if ( !isset ( $desc_pos_options ) or $desc_pos_options == '' ) {
$options = array();
$options[] = array( 'name' => __( 'None', 'ninja-forms' ), 'value' => 'none' );
$options[] = array( 'name' => __( 'Before Everything', 'ninja-forms' ), 'value' => 'before_everything' );
if ( '_submit' != $field_type ) {
$options[] = array( 'name' => __( 'Before Label', 'ninja-forms' ), 'value' => 'before_label' );
$options[] = array( 'name' => __( 'After Label', 'ninja-forms' ), 'value' => 'after_label' );
}
$options[] = array( 'name' => __( 'After Everything', 'ninja-forms' ), 'value' => 'after_everything' );
} else {
$options = $desc_pos_options;
}
$desc_desc = sprintf(__('If "desc text" is enabled, there will be a question mark %s placed next to the input field. Hovering over this question mark will show the desc text.', 'ninja-forms'), '<img src="'.NINJA_FORMS_URL.'/images/question-ico.gif">');
ninja_forms_edit_field_el_output($field_id, 'checkbox', __( 'Add Description', 'ninja-forms' ), 'show_desc', $show_desc, 'wide', '', 'ninja-forms-show-desc');
?>
$desc_desc = sprintf( __( 'If "desc text" is enabled, there will be a question mark %s placed next to the input field. Hovering over this question mark will show the desc text.', 'ninja-forms' ), '<img src="'.NINJA_FORMS_URL.'/images/question-ico.gif">' );
ninja_forms_edit_field_el_output( $field_id, 'checkbox', __( 'Add Description', 'ninja-forms' ), 'show_desc', $show_desc, 'wide', '', 'ninja-forms-show-desc' );
?>
<span id="ninja_forms_field_<?php echo $field_id;?>_desc_span" <?php echo $display_span;?>>
<?php
if(isset($field_data['desc_pos'])){
$desc_pos = $field_data['desc_pos'];
}else{
$desc_pos = '';
}
ninja_forms_edit_field_el_output($field_id, 'select', __( 'Description Position', 'ninja-forms' ), 'desc_pos', $desc_pos, 'wide', $options, 'wide');
ninja_forms_edit_field_el_output($field_id, 'rte', __( 'Description Content', 'ninja-forms' ), 'desc_text', $desc_text, 'wide', '', 'widefat');
if ( isset( $field_data['desc_pos'] ) ) {
$desc_pos = $field_data['desc_pos'];
} else {
$desc_pos = '';
}
ninja_forms_edit_field_el_output( $field_id, 'select', __( 'Description Position', 'ninja-forms' ), 'desc_pos', $desc_pos, 'wide', $options, 'wide' );
ninja_forms_edit_field_el_output( $field_id, 'rte', __( 'Description Content', 'ninja-forms' ), 'desc_text', $desc_text, 'wide', '', 'widefat' );
// ninja_forms_edit_field_el_output($field_id, 'desc', $desc_desc, 'desc_desc');
?>
// ninja_forms_edit_field_el_output($field_id, 'desc', $desc_desc, 'desc_desc');
?>
</span>
<?php
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment