"" . __( 'General', 'basic' ) . "", "id" => "general", "type" => "section" ), array( "name" => __( "Main color", 'basic' ), "desc" => __( "Choose main color", 'basic' ), "id" => "maincolor", "std" => "#936", "type" => "color", ), array( "name" => __( "Sidebar", 'basic' ), "desc" => __( "Show sidebar on mobile", 'basic' ), "id" => "show_sidebar", "std" => 0, "type" => "checkbox", ), 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", ), array( "name" => __( "Before content", 'basic' ), "desc" => __( "Code before single post content", 'basic' ), "id" => "before_content", "std" => "", "type" => "textarea", ), array( "name" => __( "After content", 'basic' ), "desc" => __( "Code after single post content", 'basic' ), "id" => "after_content", "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", ), ); // create defaults array $defaults = array(); foreach ( $avd_options as $val ){ if( is_array($val) && isset($val['std']) ) $defaults[ $val['id'] ] = $val['std']; } add_option( BASIC_OPTION_NAME, $defaults, '', 'yes' ); return $avd_options; } /* ============================================================================= */ /* ============================================================================= * 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() { $avd_options = basic_get_options_list(); // options register register_setting( BASIC_OPTION_NAME, BASIC_OPTION_NAME ); //, '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) { extract( $args ); $options = get_option( BASIC_OPTION_NAME ); 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 ""; echo ($desc != '') ? "
$desc" : ""; break; case 'multiple_select': $options[$id] = ( isset($options[$id]) ) ? $options[$id] : $std; 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 "
"; $cnt = 1; foreach ( $options_list as $val => $title ) { $checked = ( in_array($val, $options[$id]) ) ? "checked='checked'" : ""; echo ""; $cnt++; } echo "
"; echo ($desc != '') ? "$desc" : ""; break; case 'radiogroup': $options[$id] = ( isset($options[$id]) ) ? esc_attr(stripslashes($options[$id])) : $std; echo "
"; $cnt = 1; foreach ( $options_list as $val => $title ) { $checked = ( $val == $options[$id] ) ? "checked='checked'" : ""; echo ""; $cnt++; } echo "
"; echo ($desc != '') ? "$desc" : ""; break; case 'color': $options[$id] = ( isset($options[$id]) ) ? esc_attr(stripslashes($options[$id])) : $std; echo "
"; echo ""; echo "
"; echo ($desc != '') ? "
$desc
" : ""; break; } } /* ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * section description * ----------------------------------------------------------------------------- */ function basic_display_section($section){ echo ''; } /* ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * add options page in console * ----------------------------------------------------------------------------- */ function basic_options_menu() { $hook_suffix = add_theme_page( __("Theme options", 'basic'), __("Theme options", 'basic'), 'manage_options', 'basic_options_page', 'basic_options_func' ); add_action( "admin_print_scripts-$hook_suffix", 'basic_admin_print_scripts' ); add_action( "admin_footer-$hook_suffix", 'basic_admin_print_postboxes' ); } add_action( 'admin_menu', 'basic_options_menu' ); function basic_admin_print_postboxes(){ echo ''; } /* ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * load scripts & styles in options page * ----------------------------------------------------------------------------- */ function basic_admin_print_scripts(){ $dir = get_template_directory_uri(); wp_enqueue_style( 'farbtastic' ); wp_enqueue_style( 'basic-style', get_template_directory_uri() . '/inc/admin/themeoptions.css' ); wp_enqueue_script( 'postbox' ); wp_enqueue_script( 'farbtastic' ); wp_enqueue_script( 'media-upload' ); wp_enqueue_script( 'basic-script', get_template_directory_uri() . '/inc/admin/themeoptions.js', array('jquery', 'farbtastic', 'media-upload')); } /* ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- * create option page * ----------------------------------------------------------------------------- */ function basic_options_func() { // $opt = get_option( BASIC_OPTION_NAME ); ?>

'. __( 'Options saved', 'basic' ) .'

'; endif; ?>
$val) { $newinput[$key] = trim($val); // Check the input is a letter or a number if ( !preg_match('/^[A-Z0-9 _]*$/i', $val) ) { $newinput[$key] = ''; } } return $newinput; */ //$settings = get_option( 'avd_options', $def_options ); // We strip all tags from the text field, to avoid vulnerablilties like XSS /*foreach ($avd_options as $value) { switch ( $value['type'] ) { case "text": $input[ $value['id'] ] = wp_filter_nohtml_kses( $value['id'] ); //$links = $links . '' . $value['name'] . ''; break; } } */ /*$input['slide_posts'] = wp_filter_nohtml_kses( $input['slide_posts'] ); $input['related_posts'] = wp_filter_nohtml_kses( $input['related_posts'] ); $input['rss'] = wp_filter_nohtml_kses( $input['rss'] ); $input['tw'] = wp_filter_nohtml_kses( $input['tw'] ); $input['fb'] = wp_filter_nohtml_kses( $input['fb'] ); $input['gp'] = wp_filter_nohtml_kses( $input['gp'] ); $input['vk'] = wp_filter_nohtml_kses( $input['vk'] ); */ // We strip all tags from the text field, to avoid vulnerablilties like XSS /*$input['ad_code'] = wp_filter_post_kses( $input['ad_code'] );*/ /* // We select the previous value of the field, to restore it in case an invalid entry has been given $prev = $settings['featured_cat']; // We verify if the given value exists in the categories array if ( !array_key_exists( $input['featured_cat'], $avd_categories ) ) $input['featured_cat'] = $prev; // We select the previous value of the field, to restore it in case an invalid entry has been given $prev = $settings['layout_view']; // We verify if the given value exists in the layouts array if ( !array_key_exists( $input['layout_view'], $avd_layouts ) ) $input['layout_view'] = $prev; // If the checkbox has not been checked, we void it if ( ! isset( $input['author_credits'] ) ) $input['author_credits'] = basic; // We verify if the input is a boolean value $input['author_credits'] = ( $input['author_credits'] == 1 ? 1 : 0 ); */ //return $input; } // ----------------------------------------------------------------------------- /* ============================================================================= */ //endif;