"". __('General', 'basic') ."",
"id" => "general",
"type" => "section"),
array( "name" => __("Main color", 'basic'),
"desc" => __("Choose main color", 'basic'),
"id" => "maincolor",
"std" => "#936",
"type" => "color",
),
array( "name" => __("Default layout", 'basic'),
"desc" => __("Default layout for all pages", 'basic'),
"id" => "layout_default",
"std" => "rightbar",
"type" => "select",
"options" => array( 'rightbar' => __("Rightbar", 'basic'),
'leftbar' => __("Leftbar", 'basic'),
'full' => __("Fullwidth Content", 'basic'),
'center' => __("Centered Content", 'basic')
)
),
array( "name" => __("Home layout", 'basic'),
"desc" => "",
"id" => "layout_home",
"std" => "rightbar",
"type" => "select",
"options" => array( 'rightbar' => __("Rightbar", 'basic'),
'leftbar' => __("Leftbar", 'basic'),
'full' => __("Fullwidth Content", 'basic'),
'center' => __("Centered Content", 'basic')
)
),
array( "name" => __("Post layout", 'basic'),
"desc" => "",
"id" => "layout_post",
"std" => "rightbar",
"type" => "select",
"options" => array( 'rightbar' => __("Rightbar", 'basic'),
'leftbar' => __("Leftbar", 'basic'),
'full' => __("Fullwidth Content", 'basic'),
'center' => __("Centered Content", 'basic')
)
),
array( "name" => __("Pages layout", 'basic'),
"desc" => "",
"id" => "layout_page",
"std" => "center",
"type" => "select",
"options" => array( 'rightbar' => __("Rightbar", 'basic'),
'leftbar' => __("Leftbar", 'basic'),
'full' => __("Fullwidth Content", 'basic'),
'center' => __("Centered Content", 'basic')
)
),
// CODE
// .........................................................................
array( "name" => "". __('Code', 'basic') ."",
"id" => "code",
"type" => "section"),
array( "name" => __("Scripts in header", 'basic'),
"desc" => __("HTML code in <head> tag", 'basic'),
"id" => "head_scripts",
"std" => "",
"type" => "textarea",
),
array( "name" => __("Scripts in site footer", 'basic'),
"desc" => __("HTML code before </body> tag", 'basic'),
"id" => "footer_scripts",
"std" => "",
"type" => "textarea",
),
array( "name" => __("Custom styles", 'basic'),
"desc" => __("Add your custom CSS styles", 'basic'),
"id" => "custom_styles",
"std" => "",
"type" => "textarea",
),
// SOCIAL
// .........................................................................
array( "name" => "". __('Social', 'basic') ."",
"id" => "social",
"type" => "section"),
array( "name" => __("Social data", 'basic'),
"desc" => __("Add Open Graph tags to <head>", 'basic'),
"id" => "add_social_meta",
"std" => 0,
"type" => "checkbox",
),
array( "name" => __("Social share buttons", 'basic'),
"desc" => __("Select option to show or hide social share buttons after post", 'basic'),
"id" => "social_share",
"std" => 'hide',
"type" => "select",
"options" => array(
'hide' => __("Hide", 'basic'),
'custom' => __("Custom theme buttons", 'basic'),
'share42' => __("Share42 Buttons", 'basic'),
'yandex' => __("Yandex Buttons", 'basic'),
),
),
// SOCIAL
// .........................................................................
array( "name" => "". __('Structured Data', 'basic') ."",
"id" => "structureddata",
"type" => "section"),
array( "name" => __("Schema.org Mark up", 'basic'),
"desc" => __("Schema.org mark up according Creative Work->Article and Comment", 'basic'),
"id" => "schema_mark",
"std" => "0",
"type" => "checkbox",
),
array( "name" => __("Publisher logo", 'basic'),
"desc" => __("use in https://schema.org/Organization", 'basic'),
"id" => "markup_logo",
"std" => get_template_directory_uri() .'/img/logo.jpg',
"type" => "text",
),
array( "name" => __("Adress", 'basic'),
"desc" => __("use in https://schema.org/Organization", 'basic'),
"id" => "markup_adress",
"std" => "Russia",
"type" => "text",
),
array( "name" => __("Phone", 'basic'),
"desc" => __("use in https://schema.org/Organization", 'basic'),
"id" => "markup_telephone",
"std" => "+7 (000) 000-000-00",
"type" => "text",
),
);
/* ============================================================================= */
/* =============================================================================
* load settings in admin console only
* ============================================================================= */
if ( is_admin() ) :
// create defaults array
$defaults = array();
foreach ( $avd_options as $val ){
if( is_array($val) && isset($val['std']) )
$defaults[ $val['id'] ] = $val['std'];
}
// create option in database
add_option( $optionname, $defaults, '', 'yes' );
/* -----------------------------------------------------------------------------
* register options and callback function
* ----------------------------------------------------------------------------- */
function basic_register_settings() {
global $avd_options, $themename, $optionname;
// options register
register_setting( $optionname, $optionname); //, 'basic_validate_options' );
$current_section = '';
foreach ($avd_options as $opt) {
switch ( $opt['type'] ) {
// new section
case "section":
add_settings_section( 'basic_'.$opt['id'].'_section', $opt['name'], 'basic_display_section', 'basic_options_page' );
$current_section = 'basic_'.$opt['id'].'_section';
break;
// new filelds
case "text":
case "textarea":
case "checkbox":
$field_args = array(
'type' => $opt['type'],
'id' => $opt['id'],
'name' => $opt['id'],
'desc' => $opt['desc'],
'std' => $opt['std'],
'label_for' => $opt['id'],
'class' => 'avd_input avd_text',
);
add_settings_field( $opt['id'].'_textbox', $opt['name'], 'basic_display_setting', 'basic_options_page', $current_section, $field_args );
break;
// selects
case "select":
case "check_select":
case "multiple_select":
case "radiogroup":
$field_args = array(
'type' => $opt['type'],
'id' => $opt['id'],
'name' => $opt['id'],
'desc' => $opt['desc'],
'std' => $opt['std'],
'label_for' => $opt['id'],
'class' => 'avd_input avd_select',
'options_list' => $opt['options']
);
add_settings_field( $opt['id'].'_select', $opt['name'], 'basic_display_setting', 'basic_options_page', $current_section, $field_args );
break;
// colorbox
case "color":
$field_args = array(
'type' => $opt['type'],
'id' => $opt['id'],
'name' => $opt['id'],
'desc' => $opt['desc'],
'std' => $opt['std'],
'label_for' => $opt['id'],
'class' => 'avd_input avd_color',
);
add_settings_field( $opt['id'].'_color', $opt['name'], 'basic_display_setting', 'basic_options_page', $current_section, $field_args );
break;
}
}
}
add_action( 'admin_init', 'basic_register_settings' );
/* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* display all options
* ----------------------------------------------------------------------------- */
function basic_display_setting($args) {
global $optionname;
extract( $args );
$options = get_option( $optionname );
switch ( $type ) {
case 'text':
$options[$id] = ( isset($options[$id]) ) ? esc_attr(stripslashes($options[$id])) : $std;
echo "";
echo ($desc != '') ? "
$desc" : "";
break;
case 'textarea':
$options[$id] = ( isset($options[$id]) ) ? esc_attr(stripslashes($options[$id])) : $std;
echo "";
echo ($desc != '') ? "
$desc" : "";
break;
case 'select':
$options[$id] = ( isset($options[$id]) ) ? esc_attr(stripslashes($options[$id])) : $std;
echo "";
foreach ( $options_list as $val => $title ) {
$sel = ( $val == $options[$id] ) ? " selected='selected'" : "";
echo "";
}
echo "";
echo ($desc != '') ? "
$desc" : "";
break;
case 'multiple_select':
$options[$id] = ( isset($options[$id]) ) ? $options[$id] : $std;
echo "";
foreach ( $options_list as $val => $title ) {
$sel = ( in_array($val, $options[$id]) ) ? " selected='selected'" : "";
echo "";
}
echo "";
echo ($desc != '') ? "
$desc" : "";
break;
case 'checkbox':
$options[$id] = ( isset($options[$id]) ) ? esc_attr(stripslashes($options[$id])) : $std;
$checked = ( $options[$id] ) ? "checked='checked'" : "";
echo "";
break;
case 'check_select':
$options[$id] = ( isset($options[$id]) ) ? $options[$id] : $std;
echo "
'. __( 'Options saved', 'basic' ) .'