Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Wordpress Modifica plugin Options framework

    alve,
    ho scaricato un tema free nel quale vi è la pagina personalizzata del menu nella quale vi è una sola scheda (tab). In pratica chi ha fatto il tema ha utilizzato il plugin framework plugin. Tale plugin però non risulta nella lista degli installati. Ora io vorrei aggiungere un altra scheda e dei campi di testo.
    Sono riuscito a creare la scheda aggiungendo nel file option.php il codice
    codice:
    $options[] = array(
    		'name' => 'Impostazioni visite',   'type' => 'heading');
    Vorrei capire come inserire campi nella scheda appena creataGrazie
    Carpe diem
    Preferisco tentare che rinunziare

  2. #2
    allora...
    questo è il file che stampa a video:
    codice:
    if ( !function_exists( 'optionsframework_page' ) ) :function optionsframework_page() {
        settings_errors(); ?>
    
    
        <div id="optionsframework-wrap" class="wrap">
        <?php screen_icon( 'themes' ); ?>
        <h2 class="nav-tab-wrapper">
           <?php echo optionsframework_tabs(); ?>
        </h2>
    
    
        <div id="optionsframework-metabox" class="metabox-holder">
            <div id="optionsframework" class="postbox">
                <form action="options.php" method="post">
                <?php settings_fields('optionsframework'); ?>
                <?php optionsframework_fields(); /* Settings */ ?>
                <div id="optionsframework-submit">
                    <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options', 'options_framework_theme' ); ?>" />
                    <input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'options_framework_theme' ); ?>" onclick="return confirm( '<?php print esc_js(  'Click OK to reset. Any theme settings will be lost!'  ); ?>' );" />
                    <div class="clear"></div>
                </div>
                </form>
            </div> <!-- / #container -->
        </div>
        <?php do_action('optionsframework_after'); ?>
        </div> <!-- / .wrap -->
    che richiama questa funzione:
    codice:
    function optionsframework_options() {
    
        add_filter( 'wp_default_editor', create_function('', 'return "html";') );
    
    
    
    
    
    
        $options[] = array(
            'name' => 'Impostazioni visite',
            'type' => 'heading');
    
            // questo ho aggiunto io per creare nuova scheda
        $options[] = array(
            'name' => 'Impostazioni home page',  tab
            'type' => 'heading');
    
    
        $options[] = array(
            'desc' => '<div class="infohead"><span class="donation">If you like this FREEE Theme You can consider for a small Donation to us. Your Donation will be spent for the Disadvantaged Children and Students. You can visit our <a href="http://d5creation.com/donate/" target="_blank"><strong>DONATION PAGE</strong></a> and Take your decision.</span><br /><br /><span class="donation"> Need More Features and Options including Exciting Slide and 100+ Advanced Features? Try <a href="http://d5creation.com/theme/travel/" target="_blank"><strong>Travel Extend</strong></a>.</span><br /> <br /><span class="donation"> You can Visit the Travel Extend Demo <a href="http://demo.d5creation.com/wp/themes/travel/" target="_blank"><strong>Here</strong></a>.</span></div>',
            'type' => 'info');
    
    
        $options[] = array(
            'name' => 'testo marco',
            'desc' => 'Collegamento a marco.',
            'id' => 'marco',
            'std' => '#',
            'type' => 'text');
    
    
            $options[] = array(
            'name' => 'Front Page Heading',
            'desc' => 'Front Page Heading',
            'id' => 'fpheading',
            'std' => 'Test Place, Sample Country',
            'type' => 'text');
    
    
        $options[] = array(
            'name' => 'Post Featured Image Background',
            'desc' => 'Upload an image for the Common Background of Featured/ Thumbnail Image on every Post. 600px X 200px image is recommended. If your post has no featured image attached, this background will be displayed. Otherwise your post featured image will be displayed. You are recommended to attach the Featured Image during new Post Creation or Editing.',
            'id' => 'ft-back',
            'std' => get_template_directory_uri() . '/images/thumb-back.jpg',
            'type' => 'upload');
    
    
        $options[] = array(
            'name' => 'Use Responsive Layout',
            'desc' => 'Check the Box if you want the Responsive Layout of your Website',
            'id' => 'responsive',
            'std' => '1',
            'type' => 'checkbox');
    
    
        $fposttype = array( '1' => 'Do nor Show any Post or Page in the Front Page.', '2' => 'Show Posts or Page in the Front Page as Per WordPress Reading Settings.' );
    
    
        $options[] = array(
            'name' => 'Front Page Post/Page Visibility',
            'desc' => 'Select Option how you want to show or do not show Posts/Pages in the Front Page',
            'id' => 'fpostex',
            'std' => '1',
            'type' => 'radio',
            'options' => $fposttype);
    
    
        // Social Contacts
    
    
        $options[] = array(
            'desc' => '<span class="featured-area-title">Social Links</span>',
            'type' => 'info');
    
    
        $options[] = array(
            'name' => 'Google Plus Link',
            'desc' => 'Collegamento a facebook.',
            'id' => 'gplus-link',
            'std' => '#',
            'type' => 'text');
    
    
        $options[] = array(
            'name' => 'My Contact Link',
            'desc' => 'Input your Contact URL here.',
            'id' => 'con-link',
            'std' => '#',
            'type' => 'text');
    
    
    // Front Page Fearured Images
    
    
        $options[] = array(
            'desc' => '<span class="featured-area-title">Featured Boxes</span>',
            'type' => 'info');
    
    
        foreach (range(1, 3 ) as $fbsinumber) {
    
    
        $options[] = array(
            'desc' => '<span class="featured-area-title">' . 'Front Page Featured Image: ' . $fbsinumber . '</span>',
            'type' => 'info');
    
    
        $options[] = array(
            'name' => 'Featured Image',
            'desc' => 'Upload an image for the Featured Box. 270px X 200px image is recommended. If you do not want to show anything here leave the box blank.',
            'id' => 'featured-image' . $fbsinumber,
            'std' => get_template_directory_uri() . '/images/featured-image' . $fbsinumber . '.jpg',
            'type' => 'upload');
    
    
        $options[] = array(
            'name' => 'Featured Title',
            'desc' => 'Input the First Part of Featured Title here. Please limit it within 10 Letters. If you do not want to show anything here leave the box blank.',
            'id' => 'featured01-title' . $fbsinumber,
            'std' => 'Featured',
            'type' => 'text',
            'class' => 'mini');
    
    
        $options[] = array(
            'desc' => 'Input the Second Part of Featured Title here. Please limit it within 10 Letters. If you do not want to show anything here leave the box blank.',
            'id' => 'featured02-title' . $fbsinumber,
            'std' => 'Image',
            'type' => 'text',
            'class' => 'mini');
    
    
        //aggiungo al database link articolo in prima pagina MARCO
        $options[] = array(
            'desc' => 'Inserisci il link dell articolo a cui fai riferimento',
            'id' => 'featured03-link' . $fbsinumber,
            'std' => '',
            'type' => 'text' );
    
    
        $options[] = array(
            'name' => 'Description',
            'desc' => 'Input the description of Featured Areas. Please limit the words within 30 so that the layout should be clean and attractive. You can also input any HTML, Videos or iframe here. But Please keep in mind about the limitation of Width of the box.',
            'id' => 'featured-description' . $fbsinumber,
            'std' => 'A Smart way of Natural Presence. This is a Test Description and you can change it from the Theme Options.',
            'type' => 'textarea' );
    
    
        }
    
    
    // Front Page Fearured Contents
    
    
        $options[] = array(
            'desc' => '<span class="featured-area-title">Featured Contents</span>',
            'type' => 'info');
    
    
        foreach (range(1, 3 ) as $fbsinumberd) {
    
    
        $options[] = array(
            'desc' => '<span class="featured-area-title">' . 'Front Page Featured Content: 0' . $fbsinumberd . '</span>',
            'type' => 'info');
    
    
        $options[] = array(
            'name' => 'Featured Title',
            'desc' => 'Input the First Part of Featured Title here. Plese limit it within 10 Letters. If you do not want to show anything here leave the box blank.',
            'id' => 'fcontent01-title' . $fbsinumberd,
            'std' => 'Travel',
            'type' => 'text',
            'class' => 'mini');
    
    
        $options[] = array(
            'desc' => 'Input the Second Part of Featured Title here. Plese limit it within 10 Letters. If you do not want to show anything here leave the box blank.',
            'id' => 'fcontent02-title' . $fbsinumberd,
            'std' => 'Content',
            'type' => 'text',
            'class' => 'mini');
    
    
        //aggiungo al database link articolo in prima pagina MARCO
        $options[] = array(
            'desc' => 'Inserisci il link dell articolo a cui fai riferimento',
            'id' => 'fcontent03-link' . $fbsinumberd,
            'std' => '',
            'type' => 'text' );
    
    
        $options[] = array(
            'name' => 'Featured Image',
            'desc' => 'Upload an image for the Featured Box. 270px X 200px image is recommended. If you do not want to show anything here leave the box blank.',
            'id' => 'fcontent-image' . $fbsinumberd,
            'std' => get_template_directory_uri() . '/images/fcontent-image' . $fbsinumberd . '.jpg',
            'type' => 'upload');
    
    
        $options[] = array(
            'name' => 'Featured Description',
            'desc' => 'Input the description of Featured Areas. Please limit the words within 30 so that the layout should be clean and attractive. You can also input any HTML, Videos or iframe here. But Please keep in mind about the limitation of Width of the box.',
            'id' => 'fcontent-description' . $fbsinumberd,
            'std' => '<b>A Smart way of Natural Presence</b><p>A Smart way of Natural Presence. This is a Test Content and you can change it from the Theme Options.</p>',
            'type' => 'textarea' );
    
    
        }
    
    
    
    
        return $options;
    }
    ...segue nel post successivo...
    Carpe diem
    Preferisco tentare che rinunziare

  3. #3
    mentre questo è il file che formatta:
    codice:
    function optionsframework_fields() {
    
        global $allowedtags;
        $optionsframework_settings = get_option('optionsframework');
    
    
        // Gets the unique option id
        if ( isset( $optionsframework_settings['id'] ) ) {
            $option_name = $optionsframework_settings['id'];
        }
        else {
            $option_name = 'options_framework_theme';
        };
    
    
        $settings = get_option($option_name);
        
        $options = optionsframework_options();
        $counter = 0;
        $menu = '';
    
    
        foreach ( $options as $value ) {
    
    
            $val = '';
            $select_value = '';
            $checked = '';
            $output = '';
    
    
            // Wrap all options
            
            if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
    
    
                // Keep all ids lowercase with no spaces
                $value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['id']) );
    
    
                $id = 'section-' . $value['id'];
    
    
                $class = 'section';
                if ( isset( $value['type'] ) ) {
                    $class .= ' section-' . $value['type'];
                }
                if ( isset( $value['class'] ) ) {
                    $class .= ' ' . $value['class'];
                }
    
    
                $output .= '<div id="' . esc_attr( $id ) .'" class="' . esc_attr( $class ) . '">'."\n";
                if ( isset( $value['name'] ) ) {
                    $output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
                }
                if ( $value['type'] != 'editor' ) {
                    $output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
                }
                else {
                    $output .= '<div class="option">' . "\n" . '<div>' . "\n";
                }
            }
    
    
            // Set default value to $val
            if ( isset( $value['std'] ) ) {
                $val = $value['std'];
            }
    
    
            // If the option is already saved, ovveride $val
            if ( ( $value['type'] != 'heading' ) && ( $value['type'] != 'info') ) {
                if ( isset( $settings[($value['id'])]) ) {
                    $val = $settings[($value['id'])];
                    // Striping slashes of non-array options
                    if ( !is_array($val) ) {
                        $val = stripslashes( $val );
                    }
                }
            }
    
    
            // If there is a description save it for labels
            $explain_value = '';
            if ( isset( $value['desc'] ) ) {
                $explain_value = $value['desc'];
            }
    
    
            switch ( $value['type'] ) {
    
    
    
    
            // Basic text input
            case 'text':
                $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '" />';
                break;
    
    
            // Password input
            case 'password':
                $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="password" value="' . esc_attr( $val ) . '" />';
                break;
    
    
            // Textarea
            case 'textarea':
                $rows = '8';
    
    
                if ( isset( $value['settings']['rows'] ) ) {
                    $custom_rows = $value['settings']['rows'];
                    if ( is_numeric( $custom_rows ) ) {
                        $rows = $custom_rows;
                    }
                }
    
    
                $val = stripslashes( $val );
                $output .= '<textarea id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" rows="' . $rows . '">' . esc_textarea( $val ) . '</textarea>';
                break;
    
    
            // Select Box
            case 'select':
                $output .= '<select class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
    
    
                foreach ($value['options'] as $key => $option ) {
                    $selected = '';
                    if ( $val != '' ) {
                        if ( $val == $key) { $selected = ' selected="selected"';}
                    }
                    $output .= '<option'. $selected .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
                }
                $output .= '</select>';
                break;
    
    
    
    
            // Radio Box
            case "radio":
                $name = $option_name .'['. $value['id'] .']';
                foreach ($value['options'] as $key => $option) {
                    $id = $option_name . '-' . $value['id'] .'-'. $key;
                    $output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" '. checked( $val, $key, false) .' /><label for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label>';
                }
                break;
    
    
            // Image Selectors
            case "images":
                $name = $option_name .'['. $value['id'] .']';
                foreach ( $value['options'] as $key => $option ) {
                    $selected = '';
                    $checked = '';
                    if ( $val != '' ) {
                        if ( $val == $key ) {
                            $selected = ' of-radio-img-selected';
                            $checked = ' checked="checked"';
                        }
                    }
                    $output .= '<input type="radio" id="' . esc_attr( $value['id'] .'_'. $key) . '" class="of-radio-img-radio" value="' . esc_attr( $key ) . '" name="' . esc_attr( $name ) . '" '. $checked .' />';
                    $output .= '<div class="of-radio-img-label">' . esc_html( $key ) . '</div>';
                    $output .= '<img src="' . esc_url( $option ) . '" alt="' . $option .'" class="of-radio-img-img' . $selected .'" onclick="document.getElementById(\''. esc_attr($value['id'] .'_'. $key) .'\').checked=true;" />';
                }
                break;
    
    
            // Checkbox
            case "checkbox":
                $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" '. checked( $val, 1, false) .' />';
                $output .= '<label class="explain" for="' . esc_attr( $value['id'] ) . '">' . wp_kses( $explain_value, $allowedtags) . '</label>';
                break;
    
    
      
    
             // Uploader
            case "upload":
                $output .= optionsframework_uploader( $value['id'], $val, null );
    
    
                break;
    
    
            // Typography
            case 'typography':
    
    
                unset( $font_size, $font_style, $font_face, $font_color );
    
    
                $typography_defaults = array(
                    'size' => '',
                    'face' => '',
                    'style' => '',
                    'color' => ''
                );
    
    
                $typography_stored = wp_parse_args( $val, $typography_defaults );
    
    
                $typography_options = array(
                    'sizes' => of_recognized_font_sizes(),
                    'faces' => of_recognized_font_faces(),
                    'styles' => of_recognized_font_styles(),
                    'color' => true
                );
    
    
                if ( isset( $value['options'] ) ) {
                    $typography_options = wp_parse_args( $value['options'], $typography_options );
                }
    
    
                // Font Size
                if ( $typography_options['sizes'] ) {
                    $font_size = '<select class="of-typography of-typography-size" name="' . esc_attr( $option_name . '[' . $value['id'] . '][size]' ) . '" id="' . esc_attr( $value['id'] . '_size' ) . '">';
                    $sizes = $typography_options['sizes'];
                    foreach ( $sizes as $i ) {
                        $size = $i . 'px';
                        $font_size .= '<option value="' . esc_attr( $size ) . '" ' . selected( $typography_stored['size'], $size, false ) . '>' . esc_html( $size ) . '</option>';
                    }
                    $font_size .= '</select>';
                }
    
    
           // Background
            case 'background':
    
    
                $background = $val;
    
    
                // Background Color
                $default_color = '';
                if ( isset($value['std']['color']) ) {
                    if ( $val !=  $value['std']['color'] )
                        $default_color = ' data-default-color="' .$value['std']['color'] . '" ';
                }
                $output .= '<input name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" class="of-color of-background-color"  type="text" value="' . esc_attr( $background['color'] ) . '"' . $default_color .' />';
    
    
                // Background Image
                if (!isset($background['image'])) {
                    $background['image'] = '';
                }
    
    
                $output .= optionsframework_uploader( $value['id'], $background['image'], null, esc_attr( $option_name . '[' . $value['id'] . '][image]' ) );
    
    
                $class = 'of-background-properties';
                if ( '' == $background['image'] ) {
                    $class .= ' hide';
                }
                $output .= '<div class="' . esc_attr( $class ) . '">';
    
    
                // Background Repeat
                $output .= '<select class="of-background of-background-repeat" name="' . esc_attr( $option_name . '[' . $value['id'] . '][repeat]'  ) . '" id="' . esc_attr( $value['id'] . '_repeat' ) . '">';
                $repeats = of_recognized_background_repeat();
    
    
                foreach ($repeats as $key => $repeat) {
                    $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['repeat'], $key, false ) . '>'. esc_html( $repeat ) . '</option>';
                }
                $output .= '</select>';
    
    
                // Background Position
                $output .= '<select class="of-background of-background-position" name="' . esc_attr( $option_name . '[' . $value['id'] . '][position]' ) . '" id="' . esc_attr( $value['id'] . '_position' ) . '">';
                $positions = of_recognized_background_position();
    
    
                foreach ($positions as $key=>$position) {
                    $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['position'], $key, false ) . '>'. esc_html( $position ) . '</option>';
                }
                $output .= '</select>';
    
    
    
    
    
            // Editor
            case 'editor':
                $output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags) . '</div>'."\n";
                echo $output;
                $textarea_name = esc_attr( $option_name . '[' . $value['id'] . ']' );
                $default_editor_settings = array(
                    'textarea_name' => $textarea_name,
                    'media_buttons' => false,
                    'tinymce' => array( 'plugins' => 'wordpress' )
                );
                $editor_settings = array();
                if ( isset( $value['settings'] ) ) {
                    $editor_settings = $value['settings'];
                }
                $editor_settings = array_merge($editor_settings, $default_editor_settings);
                wp_editor( $val, $value['id'], $editor_settings );
                $output = '';
                break;
    
    
     
                $output .= '<div ' . $id . 'class="' . esc_attr( $class ) . '">' . "\n";
                if ( isset($value['name']) ) {
                    $output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
                }
                if ( $value['desc'] ) {
                    $output .= apply_filters('of_sanitize_info', $value['desc'] ) . "\n";
                }
                $output .= '</div>' . "\n";
                break;
    
    
            // Heading for Navigation
            case "heading":
                $counter++;
                
                if ($counter >= 2) {
                    $output .= '</div>'."\n";
                }
                $class = '';
                $class = ! empty( $value['id'] ) ? $value['id'] : $value['name'];
                $class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class) );
                $output .= '<div id="options-group-' . $counter . '" class="group ' . $class . '">';
                $output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
                break;
            }    
        if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
                $output .= '</div>';
                if ( ( $value['type'] != "checkbox" ) && ( $value['type'] != "editor" ) ) {
                    $output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags) . '</div>'."\n";
                }
                $output .= '</div></div>'."\n";
            }
    
    
            echo $output;
    come metto i campi di testo che mi interessano nella scheda "impostazioni visite".
    Grazie
    Carpe diem
    Preferisco tentare che rinunziare

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.