',
esc_attr( $current_section ),
esc_attr( $key )
);
foreach( $options_array as $option) {
$current_option_name = '';
$hint_output = '';
if ( isset( $option[ 'name' ] ) ) {
if ( '' !== $sub_array ) {
$current_option_name = $option[ 'name' ];
} else {
$current_option_name = $options_prefix . '_' . $option[ 'name' ];
}
}
if ( '' !== $sub_array ) {
$current_option_value = isset( $dashboard_options[$sub_array][$current_option_name] ) ? $dashboard_options[$sub_array][$current_option_name] : '';
if ( ! isset( $dashboard_options[$sub_array][$current_option_name] ) && isset( $option[ 'default' ] ) ) {
$current_option_value = isset( $option[ 'default_' . $current_location ] ) ? $option[ 'default_' . $current_location ] : $option[ 'default' ];
}
} else {
$current_option_value = isset( $dashboard_options[ $current_option_name ] ) ? $dashboard_options[ $current_option_name ] : '';
if ( ! isset( $dashboard_options[ $current_option_name ] ) && isset( $option[ 'default' ] ) ) {
$current_option_value = isset( $option[ 'default_' . $current_location ] ) ? $option[ 'default_' . $current_location ] : $option[ 'default' ];
}
}
if ( isset( $option[ 'hint_text' ] ) ) {
$escape = isset( $option[ 'hint_text_with_links' ] ) ? (bool) true : (bool) false;
$hint_output = $this->generate_hint( $option[ 'hint_text' ], $escape );
}
$current_option_value = apply_filters( 'et_' . $this->plugin_name . '_option_value', $current_option_value, $option );
switch( $option[ 'type' ] ) {
case 'select_shape' :
printf(
'
%1$s
',
esc_html( $option[ 'title' ] ),
isset( $option[ 'display_if' ] ) ? ' et_dashboard_hidden_option' : '',
isset( $option[ 'display_if' ] ) ? ' data-condition="' . esc_attr( $option[ 'display_if' ] ) . '"': '',
isset( $option[ 'class' ] ) ? ' ' . esc_attr( $option[ 'class' ] ) : '',
isset( $option[ 'display_if' ] ) ? ' data-triggers_count="0"': '' //#5
);
foreach ( $option[ 'value' ] as $shape ){
printf(
'
',
$shape === $current_option_value ? 'et_dashboard_selected' : '',
esc_attr( $shape ),
esc_attr( $current_option_name ),
checked( $current_option_value, $shape, false )
);
}
echo '
';
break;
case 'select' :
$current_option_list = isset( $option[ 'value_'. $current_location ] ) ? $option[ 'value_'. $current_location ] : $option[ 'value' ];
if ( isset( $option[ 'filter'] ) ) {
$current_option_list = apply_filters( $option[ 'filter'], $current_option_list );
}
printf(
'
%1$s
';
echo $hint_output;
echo '
';
break;
case 'checkbox' :
$checkbox_value = isset( $option[ 'value' ] ) ? $option[ 'value' ] : '1';
if ( false === $current_option_value && isset( $option[ 'default'] ) ) {
$current_option_value = $option[ 'default'];
}
printf( '
%1$s
',
isset( $option['title_' . $current_location] ) ? esc_html( $option['title_' . $current_location] ) : esc_html( $option['title'] ),
esc_attr( $current_option_name ),
checked( $current_option_value, $checkbox_value, false ),
( isset( $option[ 'conditional' ] )
? sprintf( ' data-enables="%1$s"', '' !== $sub_array
? esc_attr( $option[ 'conditional' ] )
: esc_attr( $options_prefix . '_' . $option[ 'conditional' ] )
)
: ''
),
isset( $option[ 'conditional' ] ) ? ' et_dashboard_conditional' : '',
isset( $option[ 'display_if' ] ) ? ' et_dashboard_hidden_option et_dashboard_triggered_option' : '',
isset( $option[ 'display_if' ] ) ? ' data-condition="' . esc_attr( $option[ 'display_if' ] ) . '"': '',
isset( $option[ 'display_if' ] ) ? ' data-triggers_count="0"': '',
isset( $option[ 'class' ] ) ? ' ' . esc_attr( $option[ 'class' ] ) : '', //#9
esc_attr($checkbox_value)
);
echo $hint_output;
echo '
';
break;
case 'checkbox_set' :
$checkboxes_array = isset( $option[ 'value' ] ) ? $option[ 'value' ] : array();
$current_option_value = isset( $current_option_value ) ? $current_option_value : array();
if ( ! empty( $checkboxes_array ) ) {
$i = 0;
foreach ( $checkboxes_array as $value => $label ) {
printf( '
%5$s
',
esc_attr( $current_option_name ),
checked( in_array( $value, $current_option_value ), true, false ),
esc_attr( $value ),
esc_attr( $i ),
esc_attr( $label ), //#5
isset( $option[ 'conditional' ][$value] ) ? ' et_dashboard_conditional' : '',
( isset( $option[ 'conditional' ][$value] )
? sprintf( ' data-enables="%1$s"', esc_attr( $option[ 'conditional' ][$value] ) )
: ''
),
isset( $option[ 'class' ] )
? ' ' . esc_attr( $option[ 'class' ] ) . ' ' . esc_attr( $option[ 'class' ] ) . '_' . esc_attr( $value )
: '' //#8
);
$i++;
}
}
break;
case 'input_field' :
printf(
'
%1$s
',
isset( $option['title_' . $current_location] )
? esc_html( $option['title_' . $current_location] )
: esc_html( $option['title'] ),
esc_attr( $current_option_name ),
esc_attr( $current_option_value ),
isset( $option[ 'display_if' ] ) ? ' et_dashboard_hidden_option' : '',
isset( $option[ 'display_if' ] ) ? ' data-condition="' . esc_attr( $option[ 'display_if' ] ) . '"': '', //#5
'number' == $option[ 'subtype' ] ? '0' : $option[ 'placeholder' ],
'text' == $option[ 'subtype' ] ? ' et_dashboard_longinput' : '',
( isset( $option['class'] )
? sprintf( ' class="%1$s"', esc_attr( $option['class'] ) )
: ''
),
( isset( $option['hide_contents'] )
? 'password'
: 'text'
),
isset( $option[ 'display_if' ] ) ? ' data-triggers_count="0"': '' //#10
);
echo $hint_output;
echo '
';
break;
case 'checkbox_posts' :
echo '
';
$i = 0;
$current_option_value = '' == $current_option_value ? array() : $current_option_value;
$current_option_cats = $current_option_value;
// remove unneeded items from categories array
unset( $current_option_cats['auto_select'] );
unset( $current_option_cats['previously_saved'] );
$checkbox_array = 'post_types' === $option['subtype'] ? $dashboard_post_types : $dashboard_categories['post'];
$post_types = ! empty( $option['value'] ) ? $option['value'] : $checkbox_array;
$array_of_saved_cats = isset( $current_option_value['previously_saved'] ) ? explode( ',', $current_option_value['previously_saved'] ) : array();
foreach ( $post_types as $post_type => $id ){
$is_checked = false;
if ( 'post_cats' === $option['subtype'] ) {
if ( ! isset( $current_option_value['previously_saved'] ) ) {
$is_checked = true;
} else {
if ( isset( $current_option_value['auto_select'] ) && '1' === $current_option_value['auto_select'] ) {
$is_checked = !in_array( $post_type, $array_of_saved_cats ) ? true : in_array( $post_type, $current_option_cats );
} else {
$is_checked = in_array( $post_type, $current_option_cats );
}
}
}
$conditional_class = '';
$conditional_data = '';
if ( 'post_types' === $option['subtype'] ) {
if ( isset( $option[ 'conditional' ]['any_post'] ) && 'page' !== $id ) {
$conditional_class = ' et_dashboard_conditional';
$conditional_data = sprintf( ' data-enables="%1$s"', esc_attr( $option['conditional']['any_post'] ) );
}
$conditional_class = isset( $option['conditional'][$id] ) ? ' et_dashboard_conditional' : $conditional_class;
$conditional_data = isset( $option['conditional'][$id] )
? sprintf( ' data-enables="%1$s"', esc_attr( $option['conditional'][$id] ) )
: $conditional_data;
}
printf( '
-
%5$s
',
esc_attr( $current_option_name ),
'post_types' === $option['subtype']
? checked( in_array( $id, $current_option_cats ), true, false )
: checked( $is_checked, true, false ),
'post_types' === $option['subtype'] ? esc_attr( $id ) : esc_attr( $post_type ),
esc_attr( $i ),
( 'post_cats' === $option['subtype'] && isset( $option['include_custom'] ) )
? esc_attr( $id ) . esc_html__( ' ( post )', 'et_dashboard' )
: esc_attr( $id ),
esc_attr( $conditional_class ),
$conditional_data
);
$i++;
}
if ( isset( $option['include_custom'] ) && 'post_cats' === $option['subtype'] ) {
foreach ( $dashboard_post_types as $post_type ) {
if ( 'post' != $post_type && 'page' != $post_type ) {
if ( ! empty( $dashboard_categories[$post_type] ) ) {
foreach ( $dashboard_categories[$post_type] as $cat_id => $cat_name ) {
$is_checked = false;
if ( ! isset( $current_option_value['previously_saved'] ) ) {
$is_checked = true;
} else {
if ( isset( $current_option_value['auto_select'] ) && '1' === $current_option_value['auto_select'] ) {
$is_checked = ! in_array( $cat_id, $array_of_saved_cats ) ? true : in_array( $cat_id, $current_option_cats );
} else {
$is_checked = in_array( $cat_id, $current_option_cats );
}
}
printf( '
-
%5$s
',
esc_attr( $current_option_name ),
checked( $is_checked, true, false ),
esc_attr( $cat_id ),
esc_attr( $i ),
esc_html( $cat_name ) . ' ( ' . $post_type . ' )',
esc_attr( $conditional_class ),
$conditional_data
);
$i++;
}
}
}
}
}
if ( 'post_cats' === $option['subtype'] ) {
$current_option_value['auto_select'] = isset( $current_option_value['auto_select'] ) ? $current_option_value['auto_select'] : 0;
$current_option_value['auto_select'] = ! isset( $current_option_value['previously_saved'] ) ? 1 : $current_option_value['auto_select'];
$cat_id_array = array();
printf( '
-
%3$s
',
esc_attr( $current_option_name ),
checked( $current_option_value['auto_select'], 1, false ),
esc_html__( 'Automatically check categories created in future', 'et_dashboard' )
);
foreach ( $checkbox_array as $id => $name ) {
$cat_id_array[] = $id;
}
if ( isset( $option['include_custom'] ) ) {
foreach ( $dashboard_post_types as $post_type ) {
if ( 'post' != $post_type && 'page' != $post_type ) {
if ( ! empty( $dashboard_categories[$post_type] ) ) {
foreach ( $dashboard_categories[$post_type] as $cat_id => $cat_name ) {
$cat_id_array[] = $cat_id;
}
}
}
}
}
$current_option_value['previously_saved'] = implode( ',', $cat_id_array );
printf( '
-
',
esc_attr( $current_option_name ),
esc_attr( $current_option_value['previously_saved'] )
);
}
echo '
';
break;
case 'section_start' :
printf(
'%5$s
%1$s',
( isset( $option[ 'sub_section' ] ) && true == $option[ 'sub_section' ] ) ? '' : ''
);
break;
case 'text' :
printf(
'
%9$s
',
esc_attr( $option[ 'placeholder' ] ),
esc_attr( $option[ 'rows' ] ),
esc_html( $current_option_value ),
esc_attr( $current_option_name ),
( isset( $option['class'] )
? sprintf( ' class="%1$s"', esc_attr( $option['class'] ) )
: ''
), //#5
isset( $option[ 'display_if' ] ) ? ' et_dashboard_hidden_option' : '',
isset( $option[ 'display_if' ] ) ? ' data-condition="' . esc_attr( $option[ 'display_if' ] ) . '"': '',
isset( $option[ 'display_if' ] ) ? ' data-triggers_count="0"': '',
! empty( $option[ 'title' ] ) ? sprintf( '
%1$s
', esc_html( $option[ 'title' ] ) ) : '',
! empty( $option[ 'title' ] ) ? ' et_dashboard_text_with_title' : '' //#10
);
break;
case 'main_title' :
printf(
'
%1$s
%2$s
',
esc_html( $option[ 'title' ] ),
isset( $option[ 'subtitle' ] )
? sprintf('
%1$s
', esc_html( $option[ 'subtitle' ] ) )
: '',
isset( $option[ 'class' ] ) ? ' ' . esc_attr( $option[ 'class' ] ) : ''
);
break;
case 'note' :
printf(
'
',
esc_html__( 'Note:', 'et_dashboard' ),
esc_html( $option[ 'text' ] )
);
break;
case 'color_picker' :
printf(
'
%4$s
',
esc_attr( $option[ 'placeholder' ] ),
esc_attr( $current_option_name ),
esc_attr( $current_option_value ),
esc_html( $option[ 'title' ] ),
isset( $option[ 'display_if' ] ) ? ' et_dashboard_hidden_option' : '', // #5
isset( $option[ 'display_if' ] ) ? ' data-condition="' . esc_attr( $option[ 'display_if' ] ) . '"': '',
isset( $option[ 'display_if' ] ) ? ' data-triggers_count="0"' : '',
isset( $option[ 'class' ] ) ? ' ' . esc_attr( $option[ 'class' ] ) : '' //#8
);
break;
case 'live_search' :
if ( '' === $current_option_value ) {
$current_option_value_array = array();
} else {
$current_option_value_array = is_array( $current_option_value ) ? $current_option_value : explode( ',', $current_option_value );
}
$selected_posts_list = '';
if ( ! empty( $current_option_value_array ) ) {
$selected_posts = get_posts( array(
'post__in' => $current_option_value_array,
'post_type' => 'any',
'posts_per_page' => -1,
)
);
if ( ! empty( $selected_posts ) ) {
foreach( $selected_posts as $single_post ) {
$selected_posts_list .= sprintf( '
[%1$s] - %2$s',
esc_html( $single_post->post_type ),
esc_html( $single_post->post_title ),
esc_attr( $single_post->ID )
);
}
}
}
printf( '
%1$s
',
$selected_posts_list,
esc_attr( $current_option_name ),
is_array( $current_option_value ) ? esc_attr( implode( ',', $current_option_value ) ) : esc_attr( $current_option_value ),
esc_attr( $option[ 'placeholder' ] ),
esc_attr( $option[ 'post_type' ] ) // supported post types: any, only_pages, only_posts,
);
break;
case 'image_upload' :
printf( '
%6$s
',
esc_attr( $current_option_name ),
isset( $current_option_value['url'] ) ? esc_attr( $current_option_value['url'] ) : '',
esc_attr( $option['button_text'] ),
esc_attr( $option['wp_media_title'] ),
esc_attr( $option['wp_media_button'] ), //#5
isset( $option['title_' . $current_location] ) ? esc_html( $option['title_' . $current_location] ) : esc_html( $option['title'] ),
isset( $option[ 'display_if' ] ) ? ' et_dashboard_hidden_option' : '',
isset( $option[ 'display_if' ] ) ? ' data-condition="' . esc_attr( $option[ 'display_if' ] ) . '"': '',
isset( $option[ 'display_if' ] ) ? ' data-triggers_count="0"': '',
isset( $current_option_value['id'] ) ? esc_attr( $current_option_value['id'] ) : '' //#10
);
break;
case 'hidden_option' :
if ( 'array' == $option[ 'subtype' ] ) {
$current_option_value = '' == $current_option_value ? array() : $current_option_value;
foreach ( $current_option_value as $single_value ) {
printf( '',
esc_attr( $current_option_name ),
esc_attr( $single_value )
);
}
} else {
printf( '',
esc_attr( $current_option_name ),
esc_attr( $current_option_value )
);
}
break;
case 'button' :
printf(
'<%4$s class="et_dashboard_action_button">
%3$s
%5$s>
%6$s',
esc_url( $option[ 'link' ] ),
esc_html( $option[ 'class' ] ),
( true == $option[ 'authorize' ] && $this->api_is_network_authorized( $option[ 'action' ] ) )
? esc_html__( 'Re-Authorize', 'et_dashboard' ) :
esc_html( $option[ 'title' ] ),
isset( $option['is_after_element'] ) ? 'div' : 'li',
isset( $option['is_after_element'] ) ? 'div' : 'li',
isset( $option['is_after_element'] ) ? '' : ''
);
break;
case 'font_select' :
$fonts_class = ET_Dashboard_v2::load_fonts_class();
$current_option_list = $fonts_class->et_get_google_fonts();
if ( isset( $option[ 'filter'] ) ) {
$current_option_list = apply_filters( $option[ 'filter'], $current_option_list );
}
printf(
'
%1$s
';
echo $hint_output;
echo '';
break;
case 'yes_no_button' :
$yes_no_button_option_classname = isset( $option['no_clearfix'] ) ? '' : ' clearfix';
$is_hidden_yes_no_input = isset( $option['hide_input'] ) && $option['hide_input'];
if ( $is_hidden_yes_no_input ) {
$yes_no_button_option_classname .= ' et_dashboard_hidden_input';
}
printf(
'
%2$s
%9$s
%10$s',
$yes_no_button_option_classname,
isset( $option[ 'title_' . $current_location ] ) ? esc_html( $option[ 'title_' . $current_location ] ) : esc_html( $option['title'] ),
esc_attr( $current_option_name ),
esc_html( $option['label'] ),
isset( $option['values'] ) ? esc_html( $option['values']['yes'] ) : esc_html__( 'Enabled', 'et_dashboard' ),
isset( $option['values'] ) ? esc_html( $option['values']['no'] ) : esc_html__( 'Disabled', 'et_dashboard' ), //#6
selected( $current_option_value, 'on', false ),
selected( $current_option_value, 'off', false ),
$hint_output,
isset( $option['after'] ) ? '' : '', //#10,
$is_hidden_yes_no_input ? ' disabled' : '',
$is_hidden_yes_no_input && isset( $option['hide_input_message'] ) ? sprintf( '%1$s
', esc_html( $option['hide_input_message'] ) ) : ''
);
break;
} // end switch
do_action( 'et_' . $this->plugin_name . '_after_main_options', $option, $current_option_value );
} // end foreach( $options_array as $option)
echo ' ';
} // end foreach( $value['contents'] as $key => $value )
} // end if ( $key !== 'header')
} // end foreach ( $dashboard_sections as $key => $value )
} // end if ( isset( $dashboard_sections ) )
printf(
'