Plugin Directory

Changeset 1255768

Timestamp:
09/29/2015 12:34:20 PM (9 years ago)
Author:
de-ce
Message:

Added wysiwyg field

Location:
admin-form-framework/trunk
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • admin-form-framework/trunk/aff.js

    r834287 r1255768  
    204204        });
    205205
     206
     207
     208
     209
     210
     211
     212
     213
    206214    });
    207215
  • admin-form-framework/trunk/class-aff.php

    r839188 r1255768  
    44 * Plugin URI: http://dreamproduction.com/wordpress/admin-form-framework
    55 * Description: Small framework for building Admin pages with forms. This plugin provides a wrapper for the WordPress Settings API that is a much easier, faster and extensible way of building your settings forms.
    6  * Version: 1.0.1
     6 * Version: 1.
    77 * Author: Dan Stefancu
    88 * Author URI: http://stefancu.ro/
     
    2626    var $menu_hook = 'admin_menu';
    2727    var $button_text = null;
     28
     29
     30
     31
     32
     33
     34
    2835
    2936    private $hook_suffix;
     
    3845    public function init() {
    3946
    40         $this->saved_options = get_option( $this->options_name );
     47        if ( class_exists( 'Sitepress' ) && $this->multilingual_options ) {
     48            global $sitepress;
     49
     50            if ( $sitepress->get_default_language() != $sitepress->get_current_language() ) {
     51                $this->options_name .= '-' . $sitepress->get_current_language();
     52            }
     53        }
     54
     55        if ( empty($this->saved_options) ) {
     56            if( $this->menu_hook == "network_admin_menu" ) {
     57                $this->saved_options = get_site_option( $this->options_name );
     58                add_action('update_wpmu_options', array( $this, 'update_site_options') );
     59            } else {
     60                $this->saved_options = get_option( $this->options_name );
     61            }
     62        }
    4163
    4264        add_action( $this->menu_hook, array( $this, 'add_page' ), 11 );
    4365
     66
    4467        add_action( 'admin_init', array( $this, 'sections_init' ), 11 );
    4568        add_action( 'admin_init', array( $this, 'options_init' ), 12 );
     
    82105                $this->page_slug        // page slug
    83106            );
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
    84145        }
    85146    }
     
    203264     */
    204265    function display_description( $text = '' ) {
    205         if ( $text ) {
    206             ?>
    207             <p class="description"><?php echo $text; ?></p>
    208         <?php
    209         }
     266        if ( ! $text ) {
     267            return;
     268        }
     269        include( 'views/description.php' );
    210270    }
    211271
     
    216276     */
    217277    function display_textarea( $field_name, $field_value, $extra = array() ) {
    218         ?>
    219         <textarea class="large-text" name="<?php echo $field_name; ?>"><?php echo esc_textarea( $field_value ); ?></textarea>
    220     <?php
     278        include( 'views/textarea.php' );
    221279    }
    222280
     
    227285     */
    228286    function display_checkbox( $field_name, $field_value, $extra = array() ) {
    229         ?>
    230         <input type="checkbox" name="<?php echo $field_name; ?>" value="1" <?php echo checked( 1, $field_value ); ?> />
    231     <?php
     287        include( 'views/checkbox.php' );
    232288    }
    233289
     
    238294     */
    239295    function display_text( $field_name, $field_value, $extra = array() ) {
    240         ?>
    241         <input type="text" class="regular-text" name="<?php echo $field_name; ?>" value="<?php echo esc_attr( $field_value ); ?>"/>
    242     <?php
     296        include ( 'views/text.php' );
    243297    }
    244298
     
    249303     */
    250304    function display_select( $field_name, $field_value, $extra = array() ) {
    251         if ( !isset( $extra['options'] ) ) {
     305        if ( !isset( $extra['options'] ) ) {
    252306            return;
    253307        }
    254         ?>
    255         <select name="<?php echo $field_name; ?>">
    256             <?php foreach ( $extra['options'] as $value => $title ): ?>
    257                 <option value="<?php echo $value; ?>" <?php selected( $field_value, $value ); ?>><?php echo $title; ?></option>
    258             <?php endforeach; ?>
    259         </select>
    260     <?php
     308        include( 'views/select.php' );
    261309    }
    262310
     
    270318            return;
    271319
    272         foreach ( $extra['options'] as $value => $title ) { ?>
    273             <label><input type="radio" name="<?php echo $field_name; ?>" value="<?php echo $value; ?>" <?php checked( $field_value, $value ); ?>/>
    274                 <?php echo $title; ?>
    275             </label><br/>
    276         <?php
    277         }
     320        include( 'views/radio.php' );
    278321    }
    279322
     
    284327     */
    285328    function display_image( $field_name, $field_value, $extra = array() ) {
    286         $button_name = $field_name . '_button';
    287         $type = 'image';
    288         $class = isset( $extra['class'] ) ? $extra['class'] : 'options-page-image';
    289         if ( $field_value ) {
    290             $attachment = get_post( $field_value );
    291             $filename = basename( $attachment->guid );
    292             $icon_src = wp_get_attachment_image_src( $attachment->ID, 'medium' );
    293             $icon_src = array_values( $icon_src );
    294             $icon_src = array_shift( $icon_src );
    295             $uploader_div = 'hidden';
    296             $display_div = '';
    297         } else {
    298             $uploader_div = '';
    299             $display_div = 'hidden';
    300             $filename = '';
    301             $icon_src = wp_mime_type_icon( $type );
    302         }
    303 
    304         ?>
    305 
    306         <div class="<?php echo $class; ?> dp-field" data-type="<?php echo $type; ?>">
    307             <input type="hidden" class="file-value" name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" value="<?php echo esc_attr( $field_value ); ?>"/>
    308 
    309             <div class="file-missing <?php echo $uploader_div; ?>">
    310                 <span><?php _e( 'No file selected.', 'dp' ); ?></span>
    311                 <button class="button file-add" name="<?php echo $button_name; ?>" id="<?php echo $button_name; ?>"><?php _e( 'Add file', 'dp' ) ?></button>
    312             </div>
    313             <div class="file-exists clearfix <?php echo $display_div; ?>">
    314                 <img class="file-icon" src="<?php echo $icon_src; ?>"/>
    315                 <br/>
    316                 <span class="file-name hidden"><?php echo $filename; ?></span>
    317                 <a class="file-remove button" href="#"><?php _e( 'Remove', 'dp' ); ?></a>
    318             </div>
    319         </div>
    320     <?php
    321     }
    322 
     329        ;
     330   
     331
     332   
     333   
     334   
     335   
     336   
     337   
     338        ;
     339   
     340
     341   
     342   
     343   
     344   
     345   
     346    function display_wysiwyg( $field_name, $field_value, $extra = array() ) {
     347       
     348    }
     349
     350   
     351     * Returns all used field types
     352   
     353   
     354   
     355   
     356       
     357
     358       
     359           
     360               
     361           
     362       
     363
     364   
     365    }
    323366    /**
    324367     * Display the options page
    325368     */
    326369    function render_page() {
    327         global $wp_version;
    328         ?>
    329         <div class="wrap">
    330             <?php if ( version_compare( $wp_version, '3.8', '<' ) ) { screen_icon(); } ?>
    331 
    332             <h2><?php echo $this->title; ?></h2>
    333 
    334             <form method="post" action="<?php echo admin_url( 'options.php' ); ?>">
    335                 <?php
    336                 settings_fields( $this->options_name );
    337                 do_settings_sections( $this->page_slug );
    338                 if ( $this->button_text !== false ) submit_button( $this->button_text );
    339                 ?>
    340             </form>
    341         </div><!-- .wrap -->
    342     <?php
     370        include( 'views/options-page.php' );
     371    }
     372
     373    /**
     374     * Update site options in case the form is a network admin menu
     375     * @return void
     376     */
     377    function update_site_options() {
     378
     379        if ( isset( $_POST[ $this->options_name ] ) ) {
     380            $value = stripslashes_deep( $_POST[ $this->options_name ] );
     381            update_site_option( $this->options_name, $value );
     382
     383            if( isset( $_POST['_wp_http_referer'] ) ) {
     384                wp_redirect( add_query_arg( 'updated', 'true', $_POST['_wp_http_referer'] ) );
     385                exit();
     386            }
     387        }
    343388    }
    344389
     
    365410        return home_url( trailingslashit( $path_from_root ) . $file );
    366411    }
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
    367430}
  • admin-form-framework/trunk/readme.txt

    r839188 r1255768  
    22Contributors: de-ce, dream-production
    33Tags: development, settings, options, custom, admin
    4 Requires at least: 3.5
    5 Tested up to: 3.8
    6 Stable tag: 1.0.1
     4Requires at least: 3.
     5Tested up to:
     6Stable tag:
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7171== Changelog ==
    7272
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
    7397= 1.0.1 =
    7498* Fixed example and readme.
Note: See TracChangeset for help on using the changeset viewer.