WordPress.org

Plugin Directory

Changeset 1667369


Ignore:
Timestamp:
05/31/17 00:05:17 (6 months ago)
Author:
cbutlerjr
Message:

3.1.8 release

Location:
wp-members/trunk
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • wp-members/trunk/admin/admin.php

    r1628757 r1667369  
    2626 * - wpmem_admin_enqueue_scripts 
    2727 */ 
    28  
    29 /** 
    30  * Calls the function to reorder fields. 
    31  * 
    32  * @since 2.8.0 
    33  */ 
    34 function wpmem_a_do_field_reorder() { 
    35     // Reorder registration fields. 
    36     wpmem_a_field_reorder(); 
    37 } 
    3828 
    3929 
     
    158148        wpmem_a_build_options(); 
    159149        break; 
    160     case 'fields' : 
    161         wpmem_a_build_fields(); 
    162         break; 
    163150    case 'dialogs' : 
    164151        wpmem_a_build_dialogs(); 
     
    205192    case 'update_cpts': 
    206193        $did_update = ( 'update_cpts' == $action ) ? wpmem_update_cpts() : wpmem_update_options(); 
    207         break; 
    208  
    209     case 'update_fields': 
    210     case 'add_field':  
    211     case 'edit_field': 
    212         $did_update = wpmem_update_fields( $action ); 
    213194        break; 
    214195 
  • wp-members/trunk/admin/css/admin.css

    r1531322 r1667369  
    66 * This file is part of the WP-Members plugin by Chad Butler 
    77 * You can find out more about this plugin at http://rocketgeek.com 
    8  * Copyright (c) 2006-2015 Chad Butler 
     8 * Copyright (c) 2006-2017 Chad Butler 
    99 * WP-Members(tm) is a trademark of butlerblog.com 
    1010 * 
     
    1212 * @subpackage WP-Members 
    1313 * @author Chad Butler  
    14  * @copyright 2006-2015 
     14 * @copyright 2006-2017 
    1515 */ 
    1616 
     
    5252    color: #f00; 
    5353} 
     54 
     55#the-list { 
     56    cursor: move; 
     57} 
     58#sort { 
     59    width: 24px; 
     60} 
  • wp-members/trunk/admin/includes/api.php

    r1628757 r1667369  
    8484    return add_query_arg( 'user_id', $user_id, admin_url( 'user-edit.php' ) ); 
    8585} 
     86 
     87/** 
     88 * Wrapper for form_post_url(). 
     89 * 
     90 * @since 3.1.8 
     91 * 
     92 * @global object $wpmem The WP_Members Object. 
     93 * @param  string $tab   The plugin tab being displayed. 
     94 * @param  mixed  $args  Array of additional arguments|boolean. Default: false. 
     95 * @return string $url 
     96 */ 
     97function wpmem_admin_form_post_url( $args = false ) { 
     98    global $wpmem; 
     99    return $wpmem->admin->form_post_url( $args ); 
     100} 
  • wp-members/trunk/admin/includes/class-wp-members-admin-api.php

    r1628757 r1667369  
    6868     */ 
    6969    function load_dependencies() { 
    70         if ( is_multisite() && current_user_can( 'edit_theme_options' ) ) { 
     70         
     71        // Default permissions for loading admin dependencies. 
     72        $defaults = array(  
     73            'main'    => 'edit_theme_options', 
     74            'users'   => 'list_users', 
     75            'options' => 'manage_options', 
     76            'posts'   => 'edit_posts', 
     77        ); 
     78        /** 
     79         * Filter permission defaults. 
     80         * 
     81         * @since 3.1.8 
     82         * 
     83         * @param  array $defaults 
     84         * 
     85         * @todo Still needs final evaluation. 
     86         */ 
     87        $permissions = apply_filters( 'wpmem_load_admin_permissions', $defaults ); 
     88         
     89        if ( current_user_can( $permissions['main'] ) ) { 
    7190            require_once(  WPMEM_PATH . 'admin/admin.php' ); 
    7291        } 
    73         if ( current_user_can( 'edit_users' ) ) {  
    74             require_once( WPMEM_PATH . 'admin/admin.php' ); 
     92        if ( current_user_can( $permissions['users'] ) ) {  
     93            require_once( WPMEM_PATH . 'admin/users.php' ); 
    7594            require_once( WPMEM_PATH . 'admin/user-profile.php' ); 
    7695        } 
    77         if ( current_user_can( 'manage_options' ) ) { 
     96        if ( current_user_can( $permissions['options'] ) ) { 
    7897            require_once( WPMEM_PATH . 'admin/tab-options.php' ); 
    7998            require_once( WPMEM_PATH . 'admin/tab-fields.php' ); 
     
    81100            require_once( WPMEM_PATH . 'admin/tab-captcha.php' ); 
    82101            require_once( WPMEM_PATH . 'admin/tab-about.php' ); 
     102            require_once( WPMEM_PATH . 'admin/tab-dialogs.php' ); 
    83103            require_once( WPMEM_PATH . 'admin/dialogs.php' ); 
    84104        } 
    85         if ( current_user_can( 'edit_posts' ) ) { 
     105        if ( current_user_can( $permissions['posts'] ) ) { 
    86106            require_once( WPMEM_PATH . 'admin/post.php' ); 
    87107        } 
    88         require_once( WPMEM_PATH . 'admin/tab-dialogs.php' ); 
    89         require_once( WPMEM_PATH . 'inc/users.php' ); 
    90         require_once( WPMEM_PATH . 'admin/users.php' ); 
    91108        require_once( WPMEM_PATH . 'admin/includes/api.php' ); 
    92109        include_once( WPMEM_PATH . 'inc/wp-registration.php' ); 
     
    110127         
    111128        // If user has a role that cannot edit users, set profile actions for non-admins. 
    112         if ( ! current_user_can( 'edit_users' ) ) {      
     129        if ( ! current_user_can( 'edit_users' ) ) { 
    113130            // User actions and filters. 
     131            add_action( 'user_edit_form_tag',         'wpmem_user_profile_multipart' ); 
    114132            add_action( 'show_user_profile',          'wpmem_user_profile'   ); 
    115133            add_action( 'edit_user_profile',          'wpmem_user_profile'   ); 
    116134            add_action( 'profile_update',             'wpmem_profile_update' ); 
    117135        } else { 
     136            add_action( 'user_edit_form_tag',         'wpmem_user_profile_multipart' ); 
    118137            add_action( 'show_user_profile',          'wpmem_admin_fields' ); 
    119138            add_action( 'edit_user_profile',          'wpmem_admin_fields' ); 
     
    463482    } 
    464483     
     484    /** 
     485     * Build admin panel form action url. 
     486     * 
     487     * @since 3.1.8 
     488     * 
     489     * @global string $pagenow 
     490     * @global string $plugin_page 
     491     * @global object $wpmem         The WP_Members Object. 
     492     * @param  mixed  $args          Array of additional arguments|boolean. Default: false. 
     493     * @return string $url 
     494     */ 
     495    function form_post_url( $args = false ) { 
     496        global $pagenow, $plugin_page, $wpmem; 
     497        $tab = wpmem_get( 'tab', false, 'get' ); 
     498        $params = array( 'page' => $plugin_page ); 
     499        if ( $tab ) { 
     500            $params['tab'] = $tab; 
     501        } 
     502        if ( $args ) { 
     503            foreach( $args as $key => $val ) { 
     504                $params[ $key ] = $val; 
     505            } 
     506        } 
     507        $url = add_query_arg( $params, admin_url( $pagenow ) ); 
     508        return $url; 
     509    } 
     510     
    465511} // End of WP_Members_Admin_API class. 
    466512 
  • wp-members/trunk/admin/js/admin.js

    r1531322 r1667369  
    66 * This file is part of the WP-Members plugin by Chad Butler 
    77 * You can find out more about this plugin at http://rocketgeek.com 
    8  * Copyright (c) 2006-2015  Chad Butler 
     8 * Copyright (c) 2006-2017  Chad Butler 
    99 * WP-Members(tm) is a trademark of butlerblog.com 
    1010 * 
    11  * TableDnD plugin for jQuery : 
    12  * Copyright (c) Denis Howlett <denish@isocra.com> 
    13  * Licensed like jQuery, see http://docs.jquery.com/License. 
    14  * 
    15  * table.add.row plugin for jQuery : 
    16  * Copyright (c) C.F.Wong <cloudgen@ymail.com> 
    17  * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php 
    18  * 
    19  * @package WordPress 
    20  * @subpackage WP-Members 
     11 * @package WP-Members 
    2112 * @author Chad Butler  
    22  * @copyright 2006-2015 
     13 * @copyright 2006-2017 
    2314 */ 
    24  
    25  
    26 /** 
    27  * JS for field table DnD  
    28  * 
    29  * @since 2.6 
    30  */ 
    31 (function($) { 
    32     $(document).ready(function() { 
    33      
    34         $("#wpmem-fields").tableDnD({ 
    35             onDragClass: "wpmem_tbl_drag", 
    36              
    37             onDrop: function(table, row) { 
    38                 var data = {  
    39                     action: 'wpmem_a_field_reorder', 
    40                     orderstring: $.tableDnD.serialize() 
    41                 } 
    42                  
    43                 $.post( ajaxurl, data, function(response) {  
    44                     // alert(response); 
    45                 }) 
    46             } 
    47         }); 
    48     }); 
    49 })(jQuery); 
    50  
    51  
    52 /** 
    53  * TableDnD plug-in for JQuery, allows you to drag and drop table rows 
    54  * You can set up various options to control how the system will work 
    55  * Copyright (c) Denis Howlett <denish@isocra.com> 
    56  * Licensed like jQuery, see http://docs.jquery.com/License. 
    57  */ 
    58 jQuery.tableDnD = { 
    59     /** Keep hold of the current table being dragged */ 
    60     currentTable : null, 
    61     /** Keep hold of the current drag object if any */ 
    62     dragObject: null, 
    63     /** The current mouse offset */ 
    64     mouseOffset: null, 
    65     /** Remember the old value of Y so that we don't do too much processing */ 
    66     oldY: 0, 
    67  
    68     /** Actually build the structure */ 
    69     build: function(options) { 
    70         // Set up the defaults if any 
    71  
    72         this.each(function() { 
    73             // This is bound to each matching table, set up the defaults and override with user options 
    74             this.tableDnDConfig = jQuery.extend({ 
    75                 onDragStyle: null, 
    76                 onDropStyle: null, 
    77                 // Add in the default class for whileDragging 
    78                 onDragClass: "tDnD_whileDrag", 
    79                 onDrop: null, 
    80                 onDragStart: null, 
    81                 scrollAmount: 5, 
    82                 serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs 
    83                 serializeParamName: null, // If you want to specify another parameter name instead of the table ID 
    84                 dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable 
    85             }, options || {}); 
    86             // Now make the rows draggable 
    87             jQuery.tableDnD.makeDraggable(this); 
    88         }); 
    89  
    90         // Now we need to capture the mouse up and mouse move event 
    91         // We can use bind so that we don't interfere with other event handlers 
    92         jQuery(document) 
    93             .bind('mousemove', jQuery.tableDnD.mousemove) 
    94             .bind('mouseup', jQuery.tableDnD.mouseup); 
    95  
    96         // Don't break the chain 
    97         return this; 
    98     }, 
    99  
    100     /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */ 
    101     makeDraggable: function(table) { 
    102         var config = table.tableDnDConfig; 
    103         if (table.tableDnDConfig.dragHandle) { 
    104             // We only need to add the event to the specified cells 
    105             var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table); 
    106             cells.each(function() { 
    107                 // The cell is bound to "this" 
    108                 jQuery(this).mousedown(function(ev) { 
    109                     jQuery.tableDnD.dragObject = this.parentNode; 
    110                     jQuery.tableDnD.currentTable = table; 
    111                     jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev); 
    112                     if (config.onDragStart) { 
    113                         // Call the onDrop method if there is one 
    114                         config.onDragStart(table, this); 
    115                     } 
    116                     return false; 
    117                 }); 
    118             }) 
    119         } else { 
    120             // For backwards compatibility, we add the event to the whole row 
    121             var rows = jQuery("tr", table); // get all the rows as a wrapped set 
    122             rows.each(function() { 
    123                 // Iterate through each row, the row is bound to "this" 
    124                 var row = jQuery(this); 
    125                 if (! row.hasClass("nodrag")) { 
    126                     row.mousedown(function(ev) { 
    127                         if (ev.target.tagName == "TD") { 
    128                             jQuery.tableDnD.dragObject = this; 
    129                             jQuery.tableDnD.currentTable = table; 
    130                             jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev); 
    131                             if (config.onDragStart) { 
    132                                 // Call the onDrop method if there is one 
    133                                 config.onDragStart(table, this); 
    134                             } 
    135                             return false; 
    136                         } 
    137                     }).css("cursor", "move"); // Store the tableDnD object 
    138                 } 
     15  
     16  
     17 /** 
     18  * JS for forms field table drag-and-drop. 
     19  * 
     20  * @since 3.1.2 
     21  */ 
     22 jQuery(document).ready(function($) { 
     23    $("#the-list").sortable({ 
     24        items: '.list_item', 
     25        opacity: 0.6, 
     26        cursor: 'move', 
     27        axis: 'y', 
     28        update: function() { 
     29            var order = $(this).sortable('serialize') + '&action=wpmem_a_field_reorder'; 
     30            $.post(ajaxurl, order, function(response) { 
     31                alert(response); 
     32            }); 
     33            $('.list_item').each(function(i) {  
     34                $(this).data('id', i + 1); // updates the data object 
     35                $(this).attr('list_item', i + 1); // updates the attribute 
    13936            }); 
    14037        } 
    141     }, 
    142  
    143     updateTables: function() { 
    144         this.each(function() { 
    145             // this is now bound to each matching table 
    146             if (this.tableDnDConfig) { 
    147                 jQuery.tableDnD.makeDraggable(this); 
    148             } 
    149         }) 
    150     }, 
    151  
    152     /** Get the mouse coordinates from the event (allowing for browser differences) */ 
    153     mouseCoords: function(ev){ 
    154         if(ev.pageX || ev.pageY){ 
    155             return {x:ev.pageX, y:ev.pageY}; 
    156         } 
    157         return { 
    158             x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 
    159             y:ev.clientY + document.body.scrollTop  - document.body.clientTop 
    160         }; 
    161     }, 
    162  
    163     /** Given a target element and a mouse event, get the mouse offset from that element. 
    164         To do this we need the element's position and the mouse position */ 
    165     getMouseOffset: function(target, ev) { 
    166         ev = ev || window.event; 
    167  
    168         var docPos    = this.getPosition(target); 
    169         var mousePos  = this.mouseCoords(ev); 
    170         return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y}; 
    171     }, 
    172  
    173     /** Get the position of an element by going up the DOM tree and adding up all the offsets */ 
    174     getPosition: function(e){ 
    175         var left = 0; 
    176         var top  = 0; 
    177         /** Safari fix -- thanks to Luis Chato for this! */ 
    178         if (e.offsetHeight == 0) { 
    179             /** Safari 2 doesn't correctly grab the offsetTop of a table row 
    180             this is detailed here: 
    181             http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/ 
    182             the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild. 
    183             note that firefox will return a text node as a first child, so designing a more thorough 
    184             solution may need to take that into account, for now this seems to work in firefox, safari, ie */ 
    185             e = e.firstChild; // a table cell 
    186         } 
    187  
    188         while (e.offsetParent){ 
    189             left += e.offsetLeft; 
    190             top  += e.offsetTop; 
    191             e     = e.offsetParent; 
    192         } 
    193  
    194         left += e.offsetLeft; 
    195         top  += e.offsetTop; 
    196  
    197         return {x:left, y:top}; 
    198     }, 
    199  
    200     mousemove: function(ev) { 
    201         if (jQuery.tableDnD.dragObject == null) { 
    202             return; 
    203         } 
    204  
    205         var dragObj = jQuery(jQuery.tableDnD.dragObject); 
    206         var config = jQuery.tableDnD.currentTable.tableDnDConfig; 
    207         var mousePos = jQuery.tableDnD.mouseCoords(ev); 
    208         var y = mousePos.y - jQuery.tableDnD.mouseOffset.y; 
    209         //auto scroll the window 
    210         var yOffset = window.pageYOffset; 
    211         if (document.all) { 
    212             // Windows version 
    213             //yOffset=document.body.scrollTop; 
    214             if (typeof document.compatMode != 'undefined' && 
    215                  document.compatMode != 'BackCompat') { 
    216                yOffset = document.documentElement.scrollTop; 
    217             } 
    218             else if (typeof document.body != 'undefined') { 
    219                yOffset=document.body.scrollTop; 
    220             } 
    221  
    222         } 
    223              
    224         if (mousePos.y-yOffset < config.scrollAmount) { 
    225             window.scrollBy(0, -config.scrollAmount); 
    226         } else { 
    227             var windowHeight = window.innerHeight ? window.innerHeight 
    228                     : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight; 
    229             if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) { 
    230                 window.scrollBy(0, config.scrollAmount); 
    231             } 
    232         } 
    233  
    234  
    235         if (y != jQuery.tableDnD.oldY) { 
    236             // work out if we're going up or down... 
    237             var movingDown = y > jQuery.tableDnD.oldY; 
    238             // update the old value 
    239             jQuery.tableDnD.oldY = y; 
    240             // update the style to show we're dragging 
    241             if (config.onDragClass) { 
    242                 dragObj.addClass(config.onDragClass); 
    243             } else { 
    244                 dragObj.css(config.onDragStyle); 
    245             } 
    246             // If we're over a row then move the dragged row to there so that the user sees the 
    247             // effect dynamically 
    248             var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y); 
    249             if (currentRow) { 
    250                 // TODO worry about what happens when there are multiple TBODIES 
    251                 if (movingDown && jQuery.tableDnD.dragObject != currentRow) { 
    252                     jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling); 
    253                 } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) { 
    254                     jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow); 
    255                 } 
    256             } 
    257         } 
    258  
    259         return false; 
    260     }, 
    261  
    262     /** We're only worried about the y position really, because we can only move rows up and down */ 
    263     findDropTargetRow: function(draggedRow, y) { 
    264         var rows = jQuery.tableDnD.currentTable.rows; 
    265         for (var i=0; i<rows.length; i++) { 
    266             var row = rows[i]; 
    267             var rowY    = this.getPosition(row).y; 
    268             var rowHeight = parseInt(row.offsetHeight)/2; 
    269             if (row.offsetHeight == 0) { 
    270                 rowY = this.getPosition(row.firstChild).y; 
    271                 rowHeight = parseInt(row.firstChild.offsetHeight)/2; 
    272             } 
    273             // Because we always have to insert before, we need to offset the height a bit 
    274             if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) { 
    275                 // that's the row we're over 
    276                 // If it's the same as the current row, ignore it 
    277                 if (row == draggedRow) {return null;} 
    278                 var config = jQuery.tableDnD.currentTable.tableDnDConfig; 
    279                 if (config.onAllowDrop) { 
    280                     if (config.onAllowDrop(draggedRow, row)) { 
    281                         return row; 
    282                     } else { 
    283                         return null; 
    284                     } 
    285                 } else { 
    286                     // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic) 
    287                     var nodrop = jQuery(row).hasClass("nodrop"); 
    288                     if (! nodrop) { 
    289                         return row; 
    290                     } else { 
    291                         return null; 
    292                     } 
    293                 } 
    294                 return row; 
    295             } 
    296         } 
    297         return null; 
    298     }, 
    299  
    300     mouseup: function(e) { 
    301         if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) { 
    302             var droppedRow = jQuery.tableDnD.dragObject; 
    303             var config = jQuery.tableDnD.currentTable.tableDnDConfig; 
    304             // If we have a dragObject, then we need to release it, 
    305             // The row will already have been moved to the right place so we just reset stuff 
    306             if (config.onDragClass) { 
    307                 jQuery(droppedRow).removeClass(config.onDragClass); 
    308             } else { 
    309                 jQuery(droppedRow).css(config.onDropStyle); 
    310             } 
    311             jQuery.tableDnD.dragObject   = null; 
    312             if (config.onDrop) { 
    313                 // Call the onDrop method if there is one 
    314                 config.onDrop(jQuery.tableDnD.currentTable, droppedRow); 
    315             } 
    316             jQuery.tableDnD.currentTable = null; // let go of the table too 
    317         } 
    318     }, 
    319  
    320     serialize: function() { 
    321         if (jQuery.tableDnD.currentTable) { 
    322             return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable); 
    323         } else { 
    324             return "Error: No Table id set, you need to set an id on your table and every row"; 
    325         } 
    326     }, 
    327  
    328     serializeTable: function(table) { 
    329         var result = ""; 
    330         var tableId = table.id; 
    331         var rows = table.rows; 
    332         for (var i=0; i<rows.length; i++) { 
    333             if (result.length > 0) result += "&"; 
    334             var rowId = rows[i].id; 
    335             if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) { 
    336                 rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0]; 
    337             } 
    338  
    339             result += tableId + '[]=' + rowId; 
    340         } 
    341         return result; 
    342     }, 
    343  
    344     serializeTables: function() { 
    345         var result = ""; 
    346         this.each(function() { 
    347             // this is now bound to each matching table 
    348             result += jQuery.tableDnD.serializeTable(this); 
    349         }); 
    350         return result; 
    351     } 
    352  
    353 } 
    354  
    355 jQuery.fn.extend( 
    356     { 
    357         tableDnD : jQuery.tableDnD.build, 
    358         tableDnDUpdate : jQuery.tableDnD.updateTables, 
    359         tableDnDSerialize: jQuery.tableDnD.serializeTables 
    360     } 
    361 ); 
    362  
    363 /** END TableDnD plugin */ 
     38    }); 
     39}); 
    36440 
    36541 
    36642/** 
    36743 * JS for displaying custom url for: 
    368  * * Profile page 
    369  * * Register page 
    370  * * Custom stylesheet 
     44 * - Profile page 
     45 * - Register page 
     46 * - Custom stylesheet 
    37147 * 
    37248 * @since 2.9.6 
     
    425101(function($) { 
    426102    $(document).ready(function() { 
     103        $("#wpmem_allowhtml").hide(); 
     104        $("#wpmem_min_max").hide(); 
    427105        $("#wpmem_checkbox_info").hide(); 
    428106        $("#wpmem_dropdown_info").hide(); 
     
    433111    $(document).ready(function() { 
    434112        $("#wpmem_field_type_select").change(function() { 
     113            if ($("#wpmem_field_type_select").val() == 'text' 
     114                || $("#wpmem_field_type_select").val() == 'password'  
     115                || $("#wpmem_field_type_select").val() == 'email'  
     116                || $("#wpmem_field_type_select").val() == 'url' 
     117                || $("#wpmem_field_type_select").val() == 'number'  
     118                || $("#wpmem_field_type_select").val() == 'date' 
     119                || $("#wpmem_field_type_select").val() == 'textarea' ) 
     120                $("#wpmem_placeholder").show(); 
     121            else 
     122                $("#wpmem_placeholder").hide(); 
     123            if ($("#wpmem_field_type_select").val() == 'text' 
     124                || $("#wpmem_field_type_select").val() == 'password'  
     125                || $("#wpmem_field_type_select").val() == 'email'  
     126                || $("#wpmem_field_type_select").val() == 'url' 
     127                || $("#wpmem_field_type_select").val() == 'number'  
     128                || $("#wpmem_field_type_select").val() == 'date' ) { 
     129                $("#wpmem_pattern").show(); 
     130                $("#wpmem_title").show(); 
     131            } else { 
     132                $("#wpmem_pattern").hide(); 
     133                $("#wpmem_title").hide(); 
     134            } 
     135            if ($("#wpmem_field_type_select").val() == 'textarea' ) 
     136                $("#wpmem_allowhtml").show(); 
     137            else 
     138                $("#wpmem_allowhtml").hide(); 
     139            if ($("#wpmem_field_type_select").val() == 'number' || $("#wpmem_field_type_select").val() == 'date' ) 
     140                $("#wpmem_min_max").show(); 
     141            else 
     142                $("#wpmem_min_max").hide(); 
    435143            if ($("#wpmem_field_type_select").val() == 'checkbox') 
    436144                $("#wpmem_checkbox_info").show(); 
  • wp-members/trunk/admin/js/shortcodes_tinymce_4.js

    r1498490 r1667369  
    5555                                } 
    5656                            }, 
    57                             /*{ 
     57                            { 
    5858                                text: "registration + redirect", 
    5959                                onclick: function(){ 
    6060                                    editor.insertContent('[wpmem_form register redirect_to="http://mysite.com/my-page/"]'); 
    6161                                } 
    62                             },*/ 
     62                            }, 
    6363                            { 
    6464                                text: "registration + logged in content", 
     
    6767                                } 
    6868                            }, 
    69                             /*{ 
     69                            { 
    7070                                text: "registration + redirect + content", 
    7171                                onclick: function(){ 
    7272                                    editor.insertContent('[wpmem_form register redirect_to="http://mysite.com/my-page/"]<br />This displays when logged in<br />[/wpmem_form]'); 
    7373                                } 
    74                             },*/ 
    75                         ] 
    76                     }, 
    77                     { 
    78                         text: 'Other Forms', 
     74                            }, 
     75                        ] 
     76                    }, 
     77                    { 
     78                        text: 'User Profile', 
    7979                        menu: [ 
    8080                            { 
     
    134134                    }, 
    135135                    { 
    136                         text: 'Login / Logout Links', 
     136                        text: 'Links', 
    137137                        menu: [ 
    138138                            { 
     
    154154                                } 
    155155                            }, 
     156                            { 
     157                                text: "log in link", 
     158                                onclick: function(){ 
     159                                    editor.insertContent('[wpmem_login_link]'); 
     160                                } 
     161                            }, 
     162                            { 
     163                                text: "log in link + custom link text", 
     164                                onclick: function(){ 
     165                                    editor.insertContent('[wpmem_login_link]Link Text[/wpmem_login_link]'); 
     166                                } 
     167                            }, 
     168                            { 
     169                                text: "register link", 
     170                                onclick: function(){ 
     171                                    editor.insertContent('[wpmem_reg_link]'); 
     172                                } 
     173                            }, 
     174                            { 
     175                                text: "register link + custom link text", 
     176                                onclick: function(){ 
     177                                    editor.insertContent('[wpmem_reg_link]Link Text[/wpmem_reg_link]'); 
     178                                } 
     179                            } 
    156180                        ] 
    157181                    }, 
     
    166190                        onclick: function(){ 
    167191                            editor.insertContent('[wpmem_show_count label="Active Users: " key=active value=1]'); 
     192                        } 
     193                    }, 
     194                    { 
     195                        text: 'User Avatar', 
     196                        onclick: function(){ 
     197                            editor.insertContent('[wpmem_avatar]'); 
    168198                        } 
    169199                    }, 
  • wp-members/trunk/admin/tab-captcha.php

    r1628757 r1667369  
    5353                    <h3><?php _e( 'Manage reCAPTCHA Options', 'wp-members' ); ?></h3> 
    5454                    <div class="inside"> 
    55                         <form name="updatecaptchaform" id="updatecaptchaform" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>"> 
     55                        <form name="updatecaptchaform" id="updatecaptchaform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>"> 
    5656                        <?php wp_nonce_field( 'wpmem-update-captcha' ); ?> 
    5757                            <table class="form-table"> 
  • wp-members/trunk/admin/tab-dialogs.php

    r1628757 r1667369  
    4747                    <div class="inside"> 
    4848                        <p><?php printf( __( 'You can customize the text for dialogs and error messages. Simple HTML is allowed %s etc.', 'wp-members' ), '- &lt;p&gt;, &lt;b&gt;, &lt;i&gt;,' ); ?></p> 
    49                         <form name="updatedialogform" id="updatedialogform" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">  
     49                        <form name="updatedialogform" id="updatedialogform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">  
    5050                        <?php wp_nonce_field( 'wpmem-update-dialogs' ); ?> 
    5151                            <table class="form-table"> 
  • wp-members/trunk/admin/tab-emails.php

    r1628757 r1667369  
    4343                        </p> 
    4444                        <hr /> 
    45                         <form name="updateemailform" id="updateemailform" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">  
     45                        <form name="updateemailform" id="updateemailform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">  
    4646                        <?php wp_nonce_field( 'wpmem-update-emails' ); ?> 
    4747                            <table class="form-table">  
  • wp-members/trunk/admin/tab-fields.php

    r1628757 r1667369  
    1515 */ 
    1616 
    17  
    18 /** 
    19  * Builds the fields panel. 
    20  * 
    21  * @since 2.2.2 
    22  * 
    23  * @param  string $wpmem_fields deprecated in 2.8.0 
    24  * @global string $add_field_err_msg The fields error message 
    25  */ 
    26 function wpmem_a_build_fields() { 
    27  
    28     global $wpmem, $add_field_err_msg; 
    29     $add_toggle = ( isset( $_GET['edit'] ) ) ? $_GET['edit'] : false; 
    30     $wpmem_fields = wpmem_fields(); 
    31     ?> 
    32     <div class="metabox-holder"> 
    33  
    34         <div id="post-body"> 
    35             <div id="post-body-content"> 
    36             <?php if ( $add_toggle && ( isset( $_POST['wpmem_admin_a'] ) != 'edit_field' ) ) { 
    37                 wpmem_a_field_edit( 'edit', $wpmem_fields, $add_toggle ); 
    38              } else { 
    39                 if ( ! $add_field_err_msg ) {  
    40                     wpmem_a_field_table( $wpmem_fields ); 
     17/** 
     18 * Load WP_Members_Fields_Table object 
     19 */ 
     20if( ! class_exists( 'WP_List_Table' ) ) { 
     21    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); 
     22} 
     23 
     24/** 
     25 * Filters and Actions. 
     26 */ 
     27add_action( 'wpmem_admin_do_tab',            'wpmem_a_fields_tab', 99, 1  ); 
     28add_action( 'wpmem_after_admin_init',        'wpmem_admin_fields_update'  ); 
     29add_action( 'admin_print_styles',            'wpmem_a_fields_tab_scripts' ); 
     30add_action( 'wp_ajax_wpmem_a_field_reorder', 'wpmem_a_do_field_reorder'  ); 
     31 
     32/** 
     33 * Calls the function to reorder fields. 
     34 * 
     35 * @since 2.8.0 
     36 */ 
     37function wpmem_a_do_field_reorder() { 
     38    // Reorder registration fields. 
     39    wpmem_a_field_reorder(); 
     40} 
     41 
     42/** 
     43 * Creates the fields tab. 
     44 * 
     45 * @since 3.0.1 
     46 * 
     47 * @param  string      $tab The admin tab being displayed. 
     48 * @return string|bool      The fields tab, otherwise false. 
     49 */ 
     50function wpmem_a_fields_tab( $tab ) { 
     51    if ( $tab == 'fields' ) { 
     52        // Render the fields tab. 
     53        wpmem_a_render_fields_tab(); 
     54        return; 
     55    } 
     56} 
     57 
     58/** 
     59 * Scripts needed for the fields tab. 
     60 * 
     61 * @since 3.1.8 
     62 */ 
     63function wpmem_a_fields_tab_scripts() { 
     64    wp_enqueue_script( 'jquery-ui-sortable' ); 
     65} 
     66 
     67/** 
     68 * Function to write the field edit link. 
     69 * 
     70 * @since 2.8 
     71 * 
     72 * @param string $field_id The option name of the field to be edited 
     73 */ 
     74function wpmem_fields_edit_link( $field_id ) { 
     75    $link_args = array( 
     76        'page'  => 'wpmem-settings', 
     77        'tab'   => 'fields', 
     78        'mode'  => 'edit', 
     79        'edit'  => 'field', 
     80        'field' => $field_id, 
     81    ); 
     82    $link = add_query_arg( $link_args, admin_url( 'options-general.php' ) ); 
     83    return '<a href="' . $link . '">' . __( 'Edit' ) . '</a>'; 
     84} 
     85 
     86/** 
     87 * Renders the content of the fields tab. 
     88 * 
     89 * @since 3.1.8 
     90 * 
     91 * @global object $wpmem         The WP_Members Object. 
     92 * @global string $did_update 
     93 * @global string $delete_action 
     94 */ 
     95function wpmem_a_render_fields_tab() { 
     96 
     97    global $wpmem, $did_update, $delete_action; 
     98    $wpmem_fields  = wpmem_fields(); 
     99    $edit_meta     = wpmem_get( 'field', false, 'get' ); 
     100    $add_meta      = wpmem_get( 'add_field', false ); 
     101     
     102    if ( 'delete' == $delete_action ) { 
     103        $delete_fields = wpmem_get( 'delete' ); ?> 
     104         
     105        <p><?php _e( 'Are you sure you want to delete the following fields?', 'wp-members' ); ?></p> 
     106         
     107        <?php foreach ( $delete_fields as $meta ) { 
     108            echo $wpmem->fields[ $meta ]['label'] . ' (meta key: ' . $meta . ')<br />'; 
     109        } ?> 
     110        <form name="<?php echo $delete_action; ?>" id="<?php echo $delete_action; ?>" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>"> 
     111            <?php // wp_nonce_field( 'wpmem-delete-fields' ); ?> 
     112            <input type="hidden" name="delete_fields" value="<?php echo implode( ",", $delete_fields ); ?>" /> 
     113            <input type="hidden" name="dodelete" value="delete_confirmed" /> 
     114            <?php submit_button( 'Delete Fields' ); ?> 
     115        </form><?php 
     116 
     117    } else { 
     118         
     119        if ( 'delete_confirmed' == wpmem_get( 'dodelete' ) ) { 
     120            // validate wpmem-delete-fields nonce 
     121 
     122            $delete_fields = explode( ",", wpmem_get( 'delete_fields', array() ) ); 
     123            $wpmem_new_fields = array(); 
     124            foreach ( $wpmem_fields as $field ) { 
     125                if ( ! in_array( $field[2], $delete_fields ) ) { 
     126                    $wpmem_new_fields[] = $field; 
    41127                } 
    42                 wpmem_a_field_edit( 'add' ); 
     128            } 
     129            update_option( 'wpmembers_fields', $wpmem_new_fields ); 
     130            $did_update = __( 'Fields deleted', 'wp-members' ); 
     131        } 
     132     
     133        if ( $did_update ) { ?> 
     134            <div id="message" class="updated fade"><p><strong><?php echo $did_update; ?></strong></p></div> 
     135        <?php }  
     136        if ( $edit_meta || $add_meta ) { 
     137            $mode = ( $edit_meta ) ? wpmem_get( 'mode', false, 'get' ) : 'add'; 
     138            wpmem_a_render_fields_tab_field_edit( $mode, $wpmem_fields, $edit_meta ); 
     139        } else { 
     140            wpmem_a_render_fields_tab_field_table(); 
     141        } ?> 
     142        <h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3> 
     143        <div class="inside"> 
     144            <strong><i><a href="http://rocketgeek.com/plugins/wp-members/docs/plugin-settings/fields/" target="_blank"><?php _e( 'Field Manager Documentation', 'wp-members' ); ?></a></i></strong> 
     145        </div> 
     146        <?php 
     147    } 
     148} 
     149 
     150/** 
     151 * Function to dispay the add/edit field form. 
     152 * 
     153 * @since 2.8 
     154 * @since 3.1.8 Changed name from wpmem_a_field_edit(). 
     155 * 
     156 * @global object      $wpmem        The WP_Members Object. 
     157 * @param  string      $mode         The mode for the function (edit|add) 
     158 * @param  array|null  $wpmem_fields The array of fields 
     159 * @param  string|null $field        The field being edited 
     160 */ 
     161function wpmem_a_render_fields_tab_field_edit( $mode, $wpmem_fields, $meta_key ) { 
     162    global $wpmem; 
     163    $fields = wpmem_fields(); 
     164    if ( $mode == 'edit' ) { 
     165        $field = $fields[ $meta_key ];   
     166    } 
     167    $form_action = ( $mode == 'edit' ) ? 'editfieldform' : 'addfieldform';  
     168    $span_optional = '<span class="description">' . __( '(optional)', 'wp-members' ) . '</span>'; 
     169    $span_required = '<span class="req">' . __( '(required)', 'wp-members' ) . '</span>';  
     170    $form_submit = array( 'mode' => $mode );  
     171    if ( isset( $_GET['field'] ) ) { 
     172        $form_submit['field'] = $meta_key;  
     173    } ?> 
     174    <h3 class="title"><?php ( $mode == 'edit' ) ? _e( 'Edit Field', 'wp-members' ) : _e( 'Add a Field', 'wp-members' ); ?></h3> 
     175    <form name="<?php echo $form_action; ?>" id="<?php echo $form_action; ?>" method="post" action="<?php echo wpmem_admin_form_post_url( $form_submit ); ?>"> 
     176        <?php wp_nonce_field( 'wpmem-add-fields' ); ?> 
     177        <ul> 
     178            <li> 
     179                <label><?php _e( 'Field Label', 'wp-members' ); ?> <?php echo $span_required; ?></label> 
     180                <input type="text" name="add_name" value="<?php echo ( $mode == 'edit' ) ? $field['label'] : false; ?>" /> 
     181                <?php _e( 'The name of the field as it will be displayed to the user.', 'wp-members' ); ?> 
     182            </li> 
     183            <li> 
     184                <label><?php _e( 'Meta Key', 'wp-members' ); ?> <?php echo $span_required; ?></label> 
     185                <?php if ( $mode == 'edit' ) {  
     186                    echo "<span>$meta_key</span>"; ?> 
     187                    <input type="hidden" name="add_option" value="<?php echo $meta_key; ?>" />  
     188                <?php } else { ?> 
     189                    <input type="text" name="add_option" value="" /> 
     190                    <?php _e( 'The database meta value for the field. It must be unique and contain no spaces (underscores are ok).', 'wp-members' ); ?> 
     191                <?php } ?> 
     192            </li> 
     193            <li> 
     194                <label><?php _e( 'Field Type', 'wp-members' ); ?></label> 
     195                <?php if ( $mode == 'edit' ) { 
     196                    echo '<span>' . $field['type'] . '</span>'; ?> 
     197                    <input type="hidden" name="add_type" value="<?php echo $field['type']; ?>" />                            
     198                <?php } else { ?> 
     199                    <select name="add_type" id="wpmem_field_type_select"> 
     200                        <option value="text"><?php          _e( 'text',              'wp-members' ); ?></option> 
     201                        <option value="email"><?php         _e( 'email',             'wp-members' ); ?></option> 
     202                        <option value="textarea"><?php      _e( 'textarea',          'wp-members' ); ?></option> 
     203                        <option value="checkbox"><?php      _e( 'checkbox',          'wp-members' ); ?></option> 
     204                        <option value="multicheckbox"><?php _e( 'multiple checkbox', 'wp-members' ); ?></option> 
     205                        <option value="select"><?php        _e( 'select (dropdown)', 'wp-members' ); ?></option> 
     206                        <option value="multiselect"><?php   _e( 'multiple select',   'wp-members' ); ?></option> 
     207                        <option value="radio"><?php         _e( 'radio group',       'wp-members' ); ?></option> 
     208                        <option value="password"><?php      _e( 'password',          'wp-members' ); ?></option> 
     209                        <option value="image"><?php         _e( 'image',             'wp-members' ); ?></option> 
     210                        <option value="file"><?php          _e( 'file',              'wp-members' ); ?></option> 
     211                        <option value="url"><?php           _e( 'url',               'wp-members' ); ?></option> 
     212                        <option value="number"><?php        _e( 'number',            'wp-members' ); ?></option> 
     213                        <option value="date"><?php          _e( 'date',              'wp-members' ); ?></option> 
     214                        <option value="hidden"><?php        _e( 'hidden',            'wp-members' ); ?></option> 
     215                    </select> 
     216                <?php } ?> 
     217            </li> 
     218            <li> 
     219                <label><?php _e( 'Display?', 'wp-members' ); ?></label> 
     220                <input type="checkbox" name="add_display" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['register'] ) : false; ?> /> 
     221            </li> 
     222            <li> 
     223                <label><?php _e( 'Required?', 'wp-members' ); ?></label> 
     224                <input type="checkbox" name="add_required" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['required'] ) : false; ?> /> 
     225            </li> 
     226            <!--<div id="wpmem_allowhtml"> 
     227            <li> 
     228                <label><?php _e( 'Allow HTML?', 'wp-members' ); ?></label> 
     229                <input type="checkbox" name="add_html" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['html'] ) : false; ?> /> 
     230            </li> 
     231            </div>--> 
     232        <?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'text', 'password', 'email', 'url', 'number', 'date', 'textarea' ) ) ) ) ) { ?> 
     233        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_placeholder">' : ''; ?> 
     234            <li> 
     235                <label><?php _e( 'Placeholder', 'wp-members' ); ?></label> 
     236                <input type="text" name="add_placeholder" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['placeholder'] ) ? $field['placeholder'] : false ) : false; ?>" /> <?php echo $span_optional; ?> 
     237            </li> 
     238        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     239        <?php } ?> 
     240        <?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'text', 'password', 'email', 'url', 'number', 'date' ) ) ) ) ) { ?> 
     241        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_pattern">' : ''; ?> 
     242            <li> 
     243                <label><?php _e( 'Pattern', 'wp-members' ); ?></label> 
     244                <input type="text" name="add_pattern" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['pattern'] ) ? $field['pattern'] : false ) : false; ?>" /> <?php echo $span_optional; ?> 
     245            </li> 
     246        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     247        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_title">' : ''; ?> 
     248            <li> 
     249                <label><?php _e( 'Title', 'wp-members' ); ?></label> 
     250                <input type="text" name="add_title" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['title'] ) ? $field['title'] : false ) : false; ?>" /> <?php echo $span_optional; ?> 
     251            </li> 
     252        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     253        <?php } ?> 
     254 
     255        <?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'number', 'date' ) ) ) ) ) { ?> 
     256        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_min_max">' : ''; ?> 
     257            <li> 
     258                <label><?php _e( 'Minimum Value', 'wp-members' ); ?></label> 
     259                <input type="text" name="add_min" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['min'] ) ? $field['min'] : false ) : false; ?>" /> <?php echo $span_optional; ?> 
     260            </li> 
     261            <li> 
     262                <label><?php _e( 'Maximum Value', 'wp-members' ); ?></label> 
     263                <input type="text" name="add_max" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['max'] ) ? $field['max'] : false ) : false; ?>" /> <?php echo $span_optional; ?> 
     264            </li> 
     265        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     266        <?php } ?> 
     267        <?php if ( $mode == 'add' || ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ) { ?> 
     268        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_file_info">' : ''; ?> 
     269            <li> 
     270                <label><?php _e( 'Accepted file types:', 'wp-members' ); ?></label> 
     271                <input type="text" name="add_file_value" value="<?php echo ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ? $field['file_types'] : false; ?>" /> 
     272            </li> 
     273            <li> 
     274                <label>&nbsp;</label> 
     275                <span class="description"><?php _e( 'Accepted file types should be set like this: jpg|jpeg|png|gif', 'wp-members' ); ?></span> 
     276            </li> 
     277        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     278        <?php } ?> 
     279        <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'checkbox' ) ) { ?> 
     280        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_checkbox_info">' : ''; ?> 
     281            <li> 
     282                <label><?php _e( 'Checked by default?', 'wp-members' ); ?></label> 
     283                <input type="checkbox" name="add_checked_default" value="y" <?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? checked( true, $field['checked_default'] ) : false; ?> /> 
     284            </li> 
     285            <li> 
     286                <label><?php _e( 'Stored value if checked:', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label> 
     287                <input type="text" name="add_checked_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? $field['checked_value'] : false; ?>" class="small-text" /> 
     288            </li> 
     289        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     290        <?php }  
     291 
     292        if ( isset( $field['type'] ) ) { 
     293            $additional_settings = ( $field['type'] == 'select' || $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' || $field['type'] == 'radio' ) ? true : false; 
     294            $delimiter_settings  = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? true : false; 
     295        } 
     296        if ( $mode == 'add' || ( $mode == 'edit' && $additional_settings ) ) { ?> 
     297        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_dropdown_info">' : ''; ?> 
     298            <?php if ( $mode == 'add' || ( $mode == 'edit' && $delimiter_settings ) ) { 
     299            echo ( $mode == 'add' ) ? '<div id="wpmem_delimiter_info">' : '';  
     300            if ( isset( $field['delimiter'] ) && ( "|" == $field['delimiter'] || "," == $field['delimiter'] ) ) { 
     301                $delimiter = $field['delimiter']; 
     302            } else { 
     303                $delimiter = "|"; 
     304            } 
     305            ?> 
     306            <li> 
     307                <label><?php _e( 'Stored values delimiter:', 'wp-members' ); ?></label> 
     308                <select name = "add_delimiter_value"> 
     309                    <option value="|" <?php selected( '|', $delimiter ); ?>>pipe "|"</option> 
     310                    <option value="," <?php selected( ',', $delimiter ); ?>>comma ","</option> 
     311                </select> 
     312            </li> 
     313            <?php echo ( $mode == 'add' ) ? '</div>' : ''; 
    43314            } ?> 
    44  
    45                 <div class="postbox"> 
    46                     <h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3> 
    47                     <div class="inside"> 
    48                         <strong><i>See the <a href="http://rocketgeek.com/plugins/wp-members/users-guide/plugin-settings/fields/" target="_blank">Users Guide on the field manager</a>.</i></strong> 
    49                     </div> 
    50                 </div> 
    51             </div><!-- #post-body-content --> 
    52         </div><!-- #post-body --> 
    53  
    54     </div><!-- .metabox-holder --> 
    55     <?php 
    56 } 
    57  
    58  
    59 /** 
    60  * reorders the fields on DnD 
    61  * 
    62  * @since 2.5.1 
    63  */ 
    64 function wpmem_a_field_reorder() { 
    65  
    66     // Start fresh. 
    67     $new_order = $wpmem_old_fields = $wpmem_new_fields = $key = $row = ''; 
    68  
    69     $new_order = $_REQUEST['orderstring']; 
    70     $new_order = explode( "&", $new_order ); 
    71      
    72     // Loop through $new_order to create new field array. 
    73     $wpmem_old_fields = get_option( 'wpmembers_fields' ); 
    74     for ( $row = 0; $row < count( $new_order ); $row++ )  { 
    75         if ( $row > 0 ) { 
    76             $key = $new_order[ $row ]; 
    77             $key = substr( $key, 15 ); 
    78             if ( $key ) { 
    79                 for ( $x = 0; $x < count( $wpmem_old_fields ); $x++ ) { 
    80                     if ( $wpmem_old_fields[ $x ][2] == $key ) { 
    81                         $wpmem_new_fields[ $row - 1 ] = $wpmem_old_fields[ $x ]; 
    82                     } 
    83                 } 
    84             } 
    85         } 
    86     } 
    87  
    88     update_option( 'wpmembers_fields', $wpmem_new_fields );  
    89  
    90     die(); // This is required to return a proper result. 
    91  
    92 } 
    93  
    94  
    95 /** 
    96  * Updates fields. 
    97  * 
    98  * @since 2.8 
    99  * 
    100  * @param  string $action The field update action (update_fields|add|edit) 
    101  * @global string $add_field_err_msg The add field error message 
    102  * @return string $did_update The fields update message 
    103  * 
    104  * @todo   apply some additional form validation to the add/update process 
    105  */ 
    106 function wpmem_update_fields( $action ) { 
    107  
    108     // Get the current fields. 
    109     $wpmem_fields    = get_option( 'wpmembers_fields' ); 
    110     $wpmem_ut_fields = get_option( 'wpmembers_utfields' ); 
    111  
    112     if ( $action == 'update_fields' ) { 
    113  
    114         // Check nonce. 
    115         check_admin_referer( 'wpmem-update-fields' ); 
    116  
    117         // @todo - need some additional form validation here 
    118          
    119         // Update user table fields. 
    120         $arr = ( isset( $_POST['ut_fields'] ) ) ? $_POST['ut_fields'] : ''; 
    121         update_option( 'wpmembers_utfields', $arr ); 
    122  
    123         // Rebuild the array, don't touch user_email - it's always mandatory. 
    124         $nrow = 0; 
    125         foreach ( $wpmem_fields as $field ) { 
    126              
    127             $meta_key = $field[2]; 
    128  
    129             // Check to see if the field is checked for deletion, and if not, add it to the new array. 
    130             $delete_field = "del_" . $meta_key; 
    131             $delete_field = ( isset( $_POST[ $delete_field ] ) ) ? $_POST[ $delete_field ] : false;  
    132             if ( $delete_field != "delete" ) { 
    133  
    134                 for ( $i = 0; $i < 4; $i++ ) { 
    135                     $wpmem_newfields[ $nrow ][ $i ] = $field[ $i ]; 
    136                 } 
    137  
    138                 $wpmem_newfields[ $nrow ][0] = $nrow + 1; 
    139  
    140                 $display_field = $meta_key . "_display";  
    141                 $require_field = $meta_key . "_required"; 
    142                 $checked_field = $meta_key . "_checked"; 
    143  
    144                 if ( $field[2] != 'user_email' ){ 
    145                     $wpmem_newfields[ $nrow ][4] = ( isset( $_POST[ $display_field ] ) ) ? 'y' : ''; 
    146                     $wpmem_newfields[ $nrow ][5] = ( isset( $_POST[ $require_field ] ) ) ? 'y' : ''; 
    147                 } else { 
    148                     $wpmem_newfields[ $nrow ][4] = 'y'; 
    149                     $wpmem_newfields[ $nrow ][5] = 'y'; 
    150                 } 
    151                  
    152                 $wpmem_newfields[ $nrow ][6] = $field[6]; 
    153                 $wpmem_newfields[ $nrow ][7] = ( isset( $field[7] ) ) ? $field[7] : ''; 
    154                 if ( $field[3] == 'checkbox' ) {  
    155                     if ( isset( $_POST[ $checked_field ] ) && $_POST[ $checked_field ] == 'y' ) { 
    156                         $wpmem_newfields[ $nrow ][8] = 'y'; 
    157                     } else { 
    158                         $wpmem_newfields[ $nrow ][8] = 'n'; 
    159                     } 
    160                 } 
    161  
    162                 $nrow = $nrow + 1; 
    163             } 
    164  
    165         } 
    166          
    167         update_option( 'wpmembers_fields', $wpmem_newfields ); 
    168         $did_update = __( 'WP-Members fields were updated', 'wp-members' ); 
    169  
    170     } elseif ( $action == 'add_field' || 'edit_field' ) { 
    171  
    172         // Check nonce. 
    173         check_admin_referer( 'wpmem-add-fields' ); 
    174  
    175         global $add_field_err_msg; 
    176  
    177         $add_field_err_msg = false; 
    178  
    179         // Error check that field label and option name are included and unique. 
    180         $add_field_err_msg = ( $_POST['add_name']   == '' ) ? __( 'Field Label is required for adding a new field. Nothing was updated.', 'wp-members' ) : $add_field_err_msg; 
    181         $add_field_err_msg = ( $_POST['add_option'] == '' ) ? __( 'Option Name is required for adding a new field. Nothing was updated.', 'wp-members' ) : $add_field_err_msg; 
    182  
    183         $add_field_err_msg = ( !preg_match("/^[A-Za-z0-9_]*$/", $_POST['add_option'] ) ) ? __( 'Option Name must contain only letters, numbers, and underscores', 'wp-members' ) : $add_field_err_msg; 
    184  
    185         // Check for duplicate field names. 
    186         $chk_fields = array(); 
    187         foreach ( $wpmem_fields as $field ) { 
    188             $chk_fields[] = $field[2]; 
    189         } 
    190         $add_field_err_msg = ( in_array( $_POST['add_option'], $chk_fields ) ) ? __( 'A field with that option name already exists', 'wp-members' ) : $add_field_err_msg; 
    191          
    192         // Error check for reserved terms. 
    193         $reserved_terms = wpmem_wp_reserved_terms(); 
    194         $submitted_meta = $_POST['add_option']; 
    195         if ( in_array( strtolower( $submitted_meta ), $reserved_terms ) ) { 
    196             $add_field_err_msg = sprintf( __( 'Sorry, "%s" is a <a href="https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms" target="_blank">reserved term</a>. Field was not added.', 'wp-members' ), $submitted_term ); 
    197         } 
    198  
    199         // Error check option name for spaces and replace with underscores. 
    200         $us_option = preg_replace( "/ /", '_', $submitted_meta ); 
    201  
    202         $arr = array(); 
    203          
    204         $type = $_POST['add_type']; 
    205  
    206         $arr[0] = ( $action == 'add_field' ) ? ( count( $wpmem_fields ) ) + 2 : false; 
    207         $arr[1] = stripslashes( $_POST['add_name'] ); 
    208         $arr[2] = $us_option; 
    209         $arr[3] = $type; 
    210         $arr[4] = ( isset( $_POST['add_display'] ) )  ? $_POST['add_display']  : 'n'; 
    211         $arr[5] = ( isset( $_POST['add_required'] ) ) ? $_POST['add_required'] : 'n'; 
    212         $arr[6] = ( $us_option == 'user_nicename' || $us_option == 'display_name' || $us_option == 'nickname' ) ? 'y' : 'n'; 
    213  
    214         if ( $type == 'checkbox' ) {  
    215             $add_field_err_msg = ( ! $_POST['add_checked_value'] ) ? __( 'Checked value is required for checkboxes. Nothing was updated.', 'wp-members' ) : $add_field_err_msg; 
    216             $arr[7] = ( isset( $_POST['add_checked_value'] ) )   ? $_POST['add_checked_value']   : false; 
    217             $arr[8] = ( isset( $_POST['add_checked_default'] ) ) ? $_POST['add_checked_default'] : 'n'; 
    218         } 
    219  
    220         if (   $type == 'select'  
    221             || $type == 'multiselect'  
    222             || $type == 'radio' 
    223             || $type == 'multicheckbox'  
    224         ) { 
    225             // Get the values. 
    226             $str = stripslashes( $_POST['add_dropdown_value'] ); 
    227             // Remove linebreaks. 
    228             $str = trim( str_replace( array("\r", "\r\n", "\n"), '', $str ) ); 
    229             // Create array. 
    230             if ( ! function_exists( 'str_getcsv' ) ) { 
    231                 $arr[7] = explode( ',', $str ); 
    232             } else { 
    233                 $arr[7] = str_getcsv( $str, ',', '"' ); 
    234             } 
    235             // If multiselect or multicheckbox, set delimiter. 
    236             if ( 'multiselect' == $type || 'multicheckbox' == $type ) { 
    237                 $arr[8] = ( isset( $_POST['add_delimiter_value'] ) ) ? $_POST['add_delimiter_value'] : '|'; 
    238             } 
    239         } 
    240          
    241         if ( $type == 'file' || $type == 'image' ) { 
    242             $arr[7] = stripslashes( $_POST['add_file_value'] ); 
    243         } 
    244          
    245         if ( $_POST['add_type'] == 'hidden' ) {  
    246             $add_field_err_msg = ( ! $_POST['add_hidden_value'] ) ? __( 'A value is required for hidden fields. Nothing was updated.', 'wp-members' ) : $add_field_err_msg; 
    247             $arr[7] = ( isset( $_POST['add_hidden_value'] ) )   ? stripslashes( $_POST['add_hidden_value'] ) : ''; 
    248         } 
    249  
    250         if ( $action == 'add_field' ) { 
    251             if ( ! $add_field_err_msg ) { 
    252                 array_push( $wpmem_fields, $arr ); 
    253                 update_option( 'wpmembers_fields', $wpmem_fields ); 
    254                 $did_update = $_POST['add_name'] . ' ' . __( 'field was added', 'wp-members' ); 
    255             } else { 
    256                 $did_update = $add_field_err_msg; 
    257             } 
    258         } else { 
    259  
    260             for ( $row = 0; $row < count( $wpmem_fields ); $row++ ) { 
    261                 if ( $wpmem_fields[ $row ][2] == $_GET['edit'] ) { 
    262                     $arr[0] = $wpmem_fields[ $row ][0]; 
    263                     //$x = ( $arr[3] == 'checkbox' ) ? 8 : ( ( $arr[3] == 'select' || $arr[3] == 'file' ) ? 7 : 6 ); 
    264                     for ( $r = 0; $r < count( $arr ); $r++ ) { 
    265                         $wpmem_fields[ $row ][ $r ] = $arr[ $r ]; 
    266                     } 
    267                 } 
    268             } 
    269  
    270             update_option( 'wpmembers_fields', $wpmem_fields ); 
    271              
    272             $did_update = $_POST['add_name'] . ' ' . __( 'field was updated', 'wp-members' ); 
    273              
    274         } 
    275     } 
    276  
    277     if ( WPMEM_DEBUG == true && isset( $arr ) ) { echo "<pre>"; print_r($arr); echo "</pre>"; } 
    278  
    279     global $wpmem; 
    280     $wpmem->load_fields(); 
    281      
    282     return $did_update; 
    283 } 
    284  
    285  
    286 /** 
    287  * Function to write the field edit link. 
    288  * 
    289  * @since 2.8 
    290  * 
    291  * @param string $field_id The option name of the field to be edited 
    292  */ 
    293 function wpmem_fields_edit_link( $field_id ) { 
    294     return '<a href="' . add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields', 'edit' => $field_id ), get_admin_url() . 'options-general.php' ) . '">' . __( 'Edit' ) . '</a>'; 
    295 } 
    296  
    297  
    298 /** 
    299  * Function to dispay the add/edit field form. 
    300  * 
    301  * @since 2.8 
    302  * 
    303  * @param string      $mode The mode for the function (edit|add) 
    304  * @param array|null  $wpmem_fields the array of fields 
    305  * @param string|null $field the field being edited 
    306  */ 
    307 function wpmem_a_field_edit( $mode, $wpmem_fields = null, $meta_key = null ) { 
    308  
    309     global $wpmem; 
    310  
    311     if ( $mode == 'edit' ) { 
    312         $fields = wpmem_fields(); 
    313         $field  = $fields[ $meta_key ];  
    314     } 
    315  
    316     $form_action = ( $mode == 'edit' ) ? 'editfieldform' : 'addfieldform'; 
    317  
    318 ?> 
    319     <div class="postbox"> 
    320         <h3 class="title"><?php ( $mode == 'edit' ) ? _e( 'Edit Field', 'wp-members' ) : _e( 'Add a Field', 'wp-members' ); ?></h3> 
    321         <div class="inside"> 
    322             <form name="<?php echo $form_action; ?>" id="<?php echo $form_action; ?>" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>"> 
    323                 <?php wp_nonce_field( 'wpmem-add-fields' ); ?> 
    324                 <ul> 
    325                     <li> 
    326                         <label><?php _e( 'Field Label', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label> 
    327                         <input type="text" name="add_name" value="<?php echo ( $mode == 'edit' ) ? $field['label'] : false; ?>" /> 
    328                         <?php _e( 'The name of the field as it will be displayed to the user.', 'wp-members' ); ?> 
    329                     </li> 
    330                     <li> 
    331                         <label><?php _e( 'Meta Key', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label> 
    332                         <?php if ( $mode == 'edit' ) {  
    333                             echo $meta_key; ?> 
    334                             <input type="hidden" name="add_option" value="<?php echo $meta_key; ?>" />  
    335                         <?php } else { ?> 
    336                             <input type="text" name="add_option" value="" /> 
    337                             <?php _e( 'The database meta value for the field. It must be unique and contain no spaces (underscores are ok).', 'wp-members' ); ?> 
    338                         <?php } ?> 
    339                     </li> 
    340                     <li> 
    341                         <label><?php _e( 'Field Type', 'wp-members' ); ?></label> 
    342                         <?php if ( $mode == 'edit' ) { 
    343                             echo $field['type']; ?> 
    344                             <input type="hidden" name="add_type" value="<?php echo $field['type']; ?>" />                            
    345                         <?php } else { ?> 
    346                             <select name="add_type" id="wpmem_field_type_select"> 
    347                                 <option value="text"><?php     _e( 'text',        'wp-members' ); ?></option> 
    348                                 <option value="email"><?php    _e( 'email',       'wp-members' ); ?></option> 
    349                                 <option value="textarea"><?php _e( 'textarea',    'wp-members' ); ?></option> 
    350                                 <option value="checkbox"><?php _e( 'checkbox',    'wp-members' ); ?></option> 
    351                                 <option value="multicheckbox"><?php _e( 'multiple checkbox', 'wp-members' ); ?></option> 
    352                                 <option value="select"><?php   _e( 'select (dropdown)',    'wp-members' ); ?></option> 
    353                                 <option value="multiselect"><?php   _e( 'multiple select', 'wp-members' ); ?></option> 
    354                                 <option value="radio"><?php    _e( 'radio group', 'wp-members' ); ?></option> 
    355                                 <option value="password"><?php _e( 'password',    'wp-members' ); ?></option> 
    356                                 <option value="image"><?php    _e( 'image',       'wp-members' ); ?></option> 
    357                                 <option value="file"><?php     _e( 'file',        'wp-members' ); ?></option> 
    358                                 <option value="url"><?php      _e( 'url',         'wp-members' ); ?></option> 
    359                                 <option value="hidden"><?php   _e( 'hidden',      'wp-members' ); ?></option> 
    360                             </select> 
    361                         <?php } ?> 
    362                     </li> 
    363                     <li> 
    364                         <label><?php _e( 'Display?', 'wp-members' ); ?></label> 
    365                         <input type="checkbox" name="add_display" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['register'] ) : false; ?> /> 
    366                     </li> 
    367                     <li> 
    368                         <label><?php _e( 'Required?', 'wp-members' ); ?></label> 
    369                         <input type="checkbox" name="add_required" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['required'] ) : false; ?> /> 
    370                     </li> 
    371                 <?php if ( $mode == 'add' || ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ) { ?> 
    372                 <?php echo ( $mode == 'add' ) ? '<div id="wpmem_file_info">' : ''; ?> 
    373                     <li> 
    374                         <strong><?php _e( 'Additional information for field upload fields', 'wp-members' ); ?></strong> 
    375                     </li> 
    376                     <li> 
    377                         <label><?php _e( 'Accepted file types:', 'wp-members' ); ?></label> 
    378                         <input type="text" name="add_file_value" value="<?php echo ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ? $field['file_types'] : false; ?>" /> 
    379                     </li> 
    380                     <li> 
    381                         <label>&nbsp;</label> 
    382                         <span class="description"><?php _e( 'Accepted file types should be set like this: jpg|jpeg|png|gif', 'wp-members' ); ?></span> 
    383                     </li> 
    384                 <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
    385                 <?php } ?> 
    386                 <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'checkbox' ) ) { ?> 
    387                 <?php echo ( $mode == 'add' ) ? '<div id="wpmem_checkbox_info">' : ''; ?> 
    388                     <li> 
    389                         <label><?php _e( 'Checked by default?', 'wp-members' ); ?></label> 
    390                         <input type="checkbox" name="add_checked_default" value="y" <?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? checked( true, $field['checked_default'] ) : false; ?> /> 
    391                     </li> 
    392                     <li> 
    393                         <label><?php _e( 'Stored value if checked:', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label> 
    394                         <input type="text" name="add_checked_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? $field['checked_value'] : false; ?>" class="small-text" /> 
    395                     </li> 
    396                 <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
    397                 <?php }  
    398                  
    399                 if ( isset( $field['type'] ) ) { 
    400                     $additional_settings = ( $field['type'] == 'select' || $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' || $field['type'] == 'radio' ) ? true : false; 
    401                     $delimiter_settings  = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? true : false; 
    402                 } 
    403                 if ( $mode == 'add' || ( $mode == 'edit' && $additional_settings ) ) { ?> 
    404                 <?php echo ( $mode == 'add' ) ? '<div id="wpmem_dropdown_info">' : ''; ?> 
    405                     <?php if ( $mode == 'add' || ( $mode == 'edit' && $delimiter_settings ) ) { 
    406                     echo ( $mode == 'add' ) ? '<div id="wpmem_delimiter_info">' : '';  
    407                     if ( isset( $field['delimiter'] ) && ( "|" == $field['delimiter'] || "," == $field['delimiter'] ) ) { 
    408                         $delimiter = $field['delimiter']; 
    409                     } else { 
    410                         $delimiter = "|"; 
    411                     } 
    412                     ?> 
    413                     <li> 
    414                         <label><?php _e( 'Stored values delimiter:', 'wp-members' ); ?></label> 
    415                         <select name = "add_delimiter_value"> 
    416                             <option value="|" <?php selected( '|', $delimiter ); ?>>pipe "|"</option> 
    417                             <option value="," <?php selected( ',', $delimiter ); ?>>comma ","</option> 
    418                         </select> 
    419                     </li> 
    420                     <?php echo ( $mode == 'add' ) ? '</div>' : ''; 
    421                     } ?> 
    422                     <li> 
    423                         <label style="vertical-align:top"><?php _e( 'Values (Displayed|Stored):', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label> 
    424                         <textarea name="add_dropdown_value" rows="5" cols="40"><?php 
     315            <li> 
     316                <label style="vertical-align:top"><?php _e( 'Values (Displayed|Stored):', 'wp-members' ); ?> <?php echo $span_required; ?></label> 
     317                <textarea name="add_dropdown_value" rows="5" cols="40"><?php 
    425318// Accomodate editing the current dropdown values or create dropdown value example. 
    426319if ( $mode == 'edit' ) { 
     
    432325echo $field['values'][ $row ]; echo ( $row == count( $field['values'] )- 1  ) ? "" : ",\n"; 
    433326} } 
    434                         } else { 
    435                             if (version_compare(PHP_VERSION, '5.3.0') >= 0) { ?> 
     327                } else { 
     328                    if (version_compare(PHP_VERSION, '5.3.0') >= 0) { ?> 
    436329<---- Select One ---->|, 
    437330Choice One|choice_one, 
     
    443336Choice 2|choice_two, 
    444337Last Row|last_row<?php } } ?></textarea> 
    445                     </li> 
    446                     <li> 
    447                         <label>&nbsp;</label> 
    448                         <span class="description"><?php _e( 'Options should be Option Name|option_value,', 'wp-members' ); ?></span> 
    449                     </li> 
    450                     <li> 
    451                         <label>&nbsp;</label> 
    452                         <span class="description"><a href="http://rocketgeek.com/plugins/wp-members/users-guide/registration/choosing-fields/" target="_blank"><?php _e( 'Visit plugin site for more information', 'wp-members' ); ?></a></span> 
    453                     </li> 
    454                 <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
    455                 <?php } ?> 
    456                 <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'hidden' ) ) { ?> 
    457                 <?php echo ( $mode == 'add' ) ? '<div id="wpmem_hidden_info">' : ''; ?> 
    458                     <li> 
    459                         <label><?php _e( 'Value', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label> 
    460                         <input type="text" name="add_hidden_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'hidden' ) ? $field['value'] : ''; ?>" /> 
    461                     </li> 
    462                 <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
    463                 <?php } ?> 
    464                 </ul><br /> 
    465                 <?php if ( $mode == 'edit' ) { ?><input type="hidden" name="field_arr" value="<?php echo $meta_key; ?>" /><?php } ?> 
    466                 <input type="hidden" name="wpmem_admin_a" value="<?php echo ( $mode == 'edit' ) ? 'edit_field' : 'add_field'; ?>" /> 
    467                 <?php $text = ( $mode == 'edit' ) ? __( 'Edit Field', 'wp-members' ) : __( 'Add Field', 'wp-members' ); ?> 
    468                 <?php submit_button( $text ); ?> 
    469             </form> 
    470         </div> 
    471     </div> 
    472 <?php 
    473 } 
    474  
    475  
     338            </li> 
     339            <li> 
     340                <label>&nbsp;</label> 
     341                <span class="description"><?php _e( 'Options should be Option Name|option_value,', 'wp-members' ); ?></span> 
     342            </li> 
     343            <li> 
     344                <label>&nbsp;</label> 
     345                <span class="description"><a href="http://rocketgeek.com/plugins/wp-members/users-guide/registration/choosing-fields/" target="_blank"><?php _e( 'Visit plugin site for more information', 'wp-members' ); ?></a></span> 
     346            </li> 
     347        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     348        <?php } ?> 
     349        <?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'hidden' ) ) { ?> 
     350        <?php echo ( $mode == 'add' ) ? '<div id="wpmem_hidden_info">' : ''; ?> 
     351            <li> 
     352                <label><?php _e( 'Value', 'wp-members' ); ?> <?php echo $span_required; ?></label> 
     353                <input type="text" name="add_hidden_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'hidden' ) ? $field['value'] : ''; ?>" /> 
     354            </li> 
     355        <?php echo ( $mode == 'add' ) ? '</div>' : ''; ?> 
     356        <?php } ?> 
     357        </ul><br /> 
     358        <?php if ( $mode == 'edit' ) { ?><input type="hidden" name="field_arr" value="<?php echo $meta_key; ?>" /><?php } ?> 
     359        <?php if ( 'add' == $mode ) { 
     360                $ids = array(); 
     361                foreach ( $fields as $f ) { 
     362                    $ids[] = $f[0]; 
     363                } 
     364                sort( $ids ); 
     365                $field_order_id = end( $ids ) + 1; 
     366            } else { 
     367                $field_order_id = $field[0]; 
     368            } ?> 
     369        <input type="hidden" name="add_order_id" value="<?php echo $field_order_id; ?>" /> 
     370        <input type="hidden" name="wpmem_admin_a" value="<?php echo ( $mode == 'edit' ) ? 'edit_field' : 'add_field'; ?>" /> 
     371        <?php $text = ( $mode == 'edit' ) ? __( 'Edit Field', 'wp-members' ) : __( 'Add Field', 'wp-members' ); ?> 
     372        <?php submit_button( $text ); ?> 
     373        <p><a href="<?php echo add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields' ), get_admin_url() . 'options-general.php' ); ?>">&laquo; <?php _e( 'Return to Fields Table', 'wp-members' ); ?></a></p> 
     374    </form><?php 
     375} 
    476376 
    477377/** 
     
    479379 *  
    480380 * @since 2.8.0 
     381 * @since 3.1.8 Changed name from wpmem_a_field_table(). 
    481382 * 
    482383 * @global object $wpmem 
    483  * @param  array  $wpmem_fields The array of fields. 
    484  */ 
    485 function wpmem_a_field_table( $wpmem_fields ) { 
    486  
    487     global $wpmem; ?> 
    488     <div class="postbox"> 
    489         <h3 class="title"><?php _e( 'Manage Fields', 'wp-members' ); ?></h3> 
    490         <div class="inside"> 
    491             <p><?php _e( 'Determine which fields will display and which are required.  This includes all fields, both native WP fields and WP-Members custom fields.', 'wp-members' ); ?> 
    492                 <br /><strong><?php _e( '(Note: Email is always mandatory and cannot be changed.)', 'wp-members' ); ?></strong></p> 
    493             <form name="updatefieldform" id="updatefieldform" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>"> 
    494             <?php wp_nonce_field( 'wpmem-update-fields' ); ?> 
    495                 <table class="widefat" id="wpmem-fields"> 
    496                     <thead><tr class="head"> 
    497                         <th scope="col"><?php _e( 'Add/Delete',   'wp-members' ); ?></th> 
    498                         <th scope="col"><?php _e( 'Field Label',  'wp-members' ); ?></th> 
    499                         <th scope="col"><?php _e( 'Meta Key',     'wp-members' ); ?></th> 
    500                         <th scope="col"><?php _e( 'Field Type',   'wp-members' ); ?></th> 
    501                         <th scope="col"><?php _e( 'Display?',     'wp-members' ); ?></th> 
    502                         <th scope="col"><?php _e( 'Required?',    'wp-members' ); ?></th> 
    503                         <th scope="col"><?php _e( 'Checked?',     'wp-members' ); ?></th> 
    504                         <th scope="col"><?php _e( 'Edit'                       ); ?></th> 
    505                         <th scope="col"><?php _e( 'Users Screen', 'wp-members' ); ?></th> 
    506                     </tr></thead> 
    507                 <?php 
    508                 // Get the user table fields array. 
    509                 $wpmem_ut_fields = get_option( 'wpmembers_utfields' ); 
    510                 // Order, label, optionname, input type, display, required, native. 
    511                 $class = ''; 
    512                 // for ( $row = 0; $row < count($wpmem_fields); $row++ ) { 
    513                 $row = 0; 
    514                 foreach ( $wpmem_fields as $meta_key => $field ) { 
    515                     $class = ( $class == 'alternate' ) ? '' : 'alternate'; ?> 
    516                     <tr class="<?php echo $class; ?>" valign="top" id="<?php echo $meta_key;?>"> 
    517                         <td width="10%"><?php  
    518                         $can_delete = ( $meta_key == 'user_nicename' || $meta_key == 'display_name' || $meta_key == 'nickname' ) ? true : false; 
    519                             if ( ( $can_delete ) || ! $field['native'] ) {  ?><input type="checkbox" name="<?php echo "del_" . $meta_key; ?>" value="delete" /> <?php _e( 'Delete', 'wp-members' ); } ?></td> 
    520                         <td width="15%"><?php  
    521                             _e( $field['label'], 'wp-members' ); 
    522                             echo ( $field['required'] ) ? '<span class="req">*</span>' : ''; ?> 
    523                         </td> 
    524                         <td width="15%"><?php echo $meta_key; ?></td> 
    525                         <td width="10%"><?php echo $field['type']; ?></td> 
    526                       <?php if ( $meta_key != 'user_email' ) { ?> 
    527                         <td width="10%"><?php echo wpmem_create_formfield( $meta_key . "_display",  'checkbox', true, $field['register'] ); ?></td> 
    528                         <td width="10%"><?php echo wpmem_create_formfield( $meta_key . "_required", 'checkbox', true, $field['required'] ); ?></td> 
    529                       <?php } else { ?> 
    530                         <td colspan="2" width="20%"><small><i><?php _e( '(Email cannot be removed)', 'wp-members' ); ?></i></small></td> 
    531                       <?php } ?> 
    532                         <td align="center" width="10%"><?php if ( $field['type'] == 'checkbox' ) {  
    533                             echo wpmem_create_formfield( $meta_key . "_checked", 'checkbox', true, $field['checked_default'] ); } ?> 
    534                         </td> 
    535                         <td width="10%"><?php echo ( $field['native'] ) ? 'native' : wpmem_fields_edit_link( $meta_key ); ?></td> 
    536  
    537                         <td align="center" width="10%"> 
    538                         <?php 
    539                         $wpmem_ut_fields_skip = array( 'user_email', 'confirm_email', 'password', 'confirm_password' ); 
    540                         if ( ! in_array( $meta_key, $wpmem_ut_fields_skip ) ) { ?> 
    541                             <input type="checkbox" name="ut_fields[<?php echo $meta_key; ?>]"  
    542                             value="<?php echo $field['label']; ?>"  
    543                             <?php echo ( ( $wpmem_ut_fields ) && ( in_array( $field['label'], $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> /> 
    544                         <?php } ?> 
    545                         </td> 
    546                     </tr><?php 
    547                 } ?> 
    548                     <tr class="nodrag nodrop"> 
    549                         <td>&nbsp;</td> 
    550                         <td><i><?php _e( 'Registration Date', 'wp-members' ); ?></i></td> 
    551                         <td><i>user_registered</i></td> 
    552                         <td colspan="4">&nbsp;</td> 
    553                         <td><?php _e( 'native', 'wp-members' ); ?></td> 
    554                         <td align="center"> 
    555                             <input type="checkbox" name="ut_fields[user_registered]"  
    556                                 value="Registration Date"  
    557                                 <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Registration Date', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> /> 
    558                         </td> 
    559                     </tr> 
    560                 <?php if ( $wpmem->mod_reg == 1 ) { ?> 
    561                     <tr class="nodrag nodrop"> 
    562                         <td>&nbsp;</td> 
    563                         <td><i><?php _e( 'Active', 'wp-members' ); ?></i></td> 
    564                         <td><i>active</i></td> 
    565                         <td colspan="5">&nbsp;</td> 
    566                         <td align="center"> 
    567                             <input type="checkbox" name="ut_fields[active]"  
    568                                 value="Active"  
    569                                 <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Active', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> /> 
    570                         </td> 
    571                     </tr> 
    572                 <?php } ?> 
    573                     <tr class="nodrag nodrop"> 
    574                         <td>&nbsp;</td> 
    575                         <td><i><?php _e( 'Registration IP', 'wp-members' ); ?></i></td> 
    576                         <td><i>wpmem_reg_ip</i></td> 
    577                         <td colspan="5">&nbsp;</td> 
    578                         <td align="center"> 
    579                             <input type="checkbox" name="ut_fields[wpmem_reg_ip]"  
    580                                 value="Registration IP"  
    581                                 <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Registration IP', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> /> 
    582                         </td> 
    583                     </tr> 
    584                 <?php if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) { ?> 
    585                     <tr class="nodrag nodrop"> 
    586                         <td>&nbsp;</td> 
    587                         <td><i>Subscription Type</i></td> 
    588                         <td><i>exp_type</i></td> 
    589                         <td colspan="5">&nbsp;</td> 
    590                         <td align="center"> 
    591                             <input type="checkbox" name="ut_fields[exp_type]"  
    592                                 value="Subscription Type"  
    593                                 <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Subscription Type', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> /> 
    594                         </td> 
    595                     </tr> 
    596                     <tr class="nodrag nodrop"> 
    597                         <td>&nbsp;</td> 
    598                         <td><i>Expires</i></td> 
    599                         <td><i>expires</i></td> 
    600                         <td colspan="5">&nbsp;</td> 
    601                         <td align="center"> 
    602                             <input type="checkbox" name="ut_fields[expires]"  
    603                                 value="Expires"  
    604                                 <?php echo ( ( $wpmem_ut_fields ) && ( in_array( 'Expires', $wpmem_ut_fields ) ) ) ? 'checked' : false; ?> /> 
    605                         </td> 
    606                     </tr> 
    607                 <?php } ?> 
    608                 </table><br /> 
    609                 <input type="hidden" name="wpmem_admin_a" value="update_fields" /> 
    610                 <?php submit_button( __( 'Update Fields', 'wp-members' ) ); ?> 
    611             </form> 
    612         </div><!-- .inside --> 
    613     </div>   
    614     <?php 
     384 */ 
     385function wpmem_a_render_fields_tab_field_table() { 
     386    global $wpmem;  
     387 
     388    $wpmem_ut_fields_skip = array( 'user_email', 'confirm_email', 'password', 'confirm_password' );  
     389    $wpmem_ut_fields = get_option( 'wpmembers_utfields' ); 
     390 
     391    $wpmem_fields = get_option( 'wpmembers_fields', array() ); 
     392    foreach ( $wpmem_fields as $key => $field ) { 
     393         
     394        // @todo - transitional until new array keys 
     395        if ( is_numeric( $key ) ) { 
     396             
     397            $meta = $field[2]; 
     398             
     399            $ut_checked = ( ( $wpmem_ut_fields ) && ( in_array( $field[1], $wpmem_ut_fields ) ) ) ? $field[1] : ''; 
     400            $field_items[] = array( 
     401                'order'    => $field[0], 
     402                'label'    => $field[1], 
     403                'meta'     => $meta, 
     404                'type'     => $field[3], 
     405                'display'  => ( $meta != 'user_email' ) ? wpmem_create_formfield( $meta . "_display",  'checkbox', 'y', $field[4] ) : '', 
     406                'req'      => ( $meta != 'user_email' ) ? wpmem_create_formfield( $meta . "_required", 'checkbox', 'y', $field[5] ) : '', 
     407                //'profile'  => ( $meta != 'user_email' ) ? wpmem_create_formfield( $meta . "_profile",  'checkbox', true, $field[6] ) : '', 
     408                'edit'     => wpmem_fields_edit_link( $meta ), 
     409                'userscrn' => ( ! in_array( $meta, $wpmem_ut_fields_skip ) ) ? wpmem_create_formfield( 'ut_fields[' . $meta . ']', 'checkbox', $field[1], $ut_checked ) : '',             
     410                'sort'     => '<span class="ui-icon ui-icon-grip-dotted-horizontal" title="' . __( 'Drag and drop to reorder fields', 'wp-members' ) . '"></span>', 
     411            ); 
     412        } 
     413    } 
     414     
     415    $extra_user_screen_items = array(  
     416        'user_registered' => 'Registration Date', 
     417        'active' => 'Active', 
     418        'wpmem_reg_ip' => 'Registration IP', 
     419        'exp_type' => 'Subscription Type', 
     420        'expires' => 'Expires', 
     421    ); 
     422     
     423    foreach ( $extra_user_screen_items as $key => $item ) { 
     424        $ut_checked = ( ( $wpmem_ut_fields ) && ( in_array( $item, $wpmem_ut_fields ) ) ) ? $item : ''; 
     425        if ( 'user_registered' == $key || ( 'active' == $key && 1 == $wpmem->mod_reg ) || 'wpmem_reg_ip' == $key || defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 && ( 'exp_type' == $key || 'expires' == $key ) ) { 
     426            $user_screen_items[ $key ] = array( 'label' => __( $item, 'wp-members' ), 'meta' => $key, 
     427                'userscrn' => wpmem_create_formfield( "ut_fields[{$key}]", 'checkbox', $item, $ut_checked ), 
     428            ); 
     429        } 
     430    } 
     431     
     432    foreach ( $user_screen_items as $screen_item ) { 
     433        $field_items[] = array( 
     434            'label' => $screen_item['label'], 
     435            'meta'  => $screen_item['meta'], 
     436            'type'  => '', 
     437            'display' => '', 
     438            'req' => '', 
     439            'profile' => '', 
     440            'edit' => '', 
     441            'userscrn' => $screen_item['userscrn'], 
     442            'sort' => '', 
     443        ); 
     444    } 
     445 
     446    $table = new WP_Members_Fields_Table(); 
     447 
     448    $heading     = __( 'Manage Fields', 'wp-members' ); 
     449    //$description = __( 'Displaying fields for:', 'wp-members' ); 
     450    //$which_form  = $wpmem->form_tags[ $wpmem->admin->current_form ]; 
     451 
     452    echo '<div class="wrap">'; 
     453    printf( '<h3 class="title">%s</h3>', $heading ); 
     454    //printf( '<p>%s <strong>%s</strong></p>', $description, $which_form ); 
     455    printf( '<form name="updatefieldform" id="updatefieldform" method="post" action="%s">', wpmem_admin_form_post_url() ); 
     456 
     457    $table->items = $field_items; 
     458    $table->prepare_items();  
     459    $table->display();  
     460    echo '</form>'; 
     461    echo '</div>';  
     462} 
     463 
     464/** 
     465 * Extends the WP_List_Table to create a table of form fields. 
     466 * 
     467 * @since 3.1.8 
     468 */ 
     469class WP_Members_Fields_Table extends WP_List_Table { 
     470     
     471    private $excludes = array( 'user_registered', 'active', 'wpmem_reg_ip', 'exp_type', 'expires' ); 
     472     
     473    private $no_delete = array( 'user_email', 'first_name', 'last_name', 'user_url' ); 
     474     
     475    /** 
     476     * Checkbox at start of row. 
     477     * 
     478     * @since 3.1.8 
     479     * 
     480     * @param $item 
     481     * @return string The checkbox. 
     482     */ 
     483    function column_cb( $item ) { 
     484        if ( in_array( $item['meta'], $this->no_delete ) || in_array( $item['meta'], $this->excludes ) ) { 
     485            return; 
     486        } else { 
     487            return sprintf( '<input type="checkbox" name="delete[]" value="%s" title="%s" />', $item['meta'], __( 'delete', 'wp-members' ) ); 
     488        } 
     489    } 
     490 
     491    /** 
     492     * Returns table columns. 
     493     * 
     494     * @since 3.1.8 
     495     * 
     496     * @return array 
     497     */ 
     498    function get_columns() { 
     499        return array( 
     500            'cb'   =>  '<input type="checkbox" />', 
     501            'label'    => __( 'Display Label', 'wp-members' ), 
     502            'meta'     => __( 'Meta Key',      'wp-members' ), 
     503            'type'     => __( 'Field Type',    'wp-members' ), 
     504            'display'  => __( 'Display?',      'wp-members' ), 
     505            'req'      => __( 'Required?',     'wp-members' ), 
     506            //'profile'  => __( 'Profile Only',  'wp-members' ), 
     507            'edit'     => __( 'Edit',          'wp-members' ), 
     508            'userscrn' => __( 'Users Screen',  'wp-members' ), 
     509            'sort'     => '', 
     510        ); 
     511    } 
     512 
     513    /** 
     514     * Set up table columns. 
     515     * 
     516     * @since 3.1.8 
     517     */ 
     518    function prepare_items() { 
     519        $columns  = $this->get_columns(); 
     520        $hidden   = array(); 
     521        $sortable = array(); 
     522        $this->_column_headers = array( $columns, $hidden, $sortable ); 
     523    } 
     524 
     525    /** 
     526     * Iterates through the columns 
     527     * 
     528     * @since 3.1.8 
     529     * 
     530     * @param  array  $item 
     531     * @param  string $column_name 
     532     * @return string $item[ $column_name ] 
     533     */ 
     534    function column_default( $item, $column_name ) { 
     535        switch( $column_name ) { 
     536            default: 
     537                return $item[ $column_name ]; 
     538        } 
     539    } 
     540 
     541    /** 
     542     * Sets actions in the bulk menu. 
     543     * 
     544     * @since 3.1.8 
     545     * 
     546     * @return array $actions 
     547     */ 
     548    function get_bulk_actions() { 
     549        $actions = array( 
     550            'delete' => __( 'Delete Selected', 'wp-members' ), 
     551            'save'   => __( 'Save Settings', 'wp-members' ), 
     552        ); 
     553        return $actions; 
     554    } 
     555 
     556    /** 
     557     * Handles "delete" column - checkbox 
     558     * 
     559     * @since 3.1.8 
     560     * 
     561     * @param  array  $item 
     562     * @return string  
     563     */ 
     564    function column_delete( $item ) { 
     565        $can_delete = ( $item['meta_key'] == 'user_nicename' || $item['meta_key'] == 'display_name' || $item['meta_key'] == 'nickname' ) ? true : false; 
     566        return ( ( $can_delete ) || $item['native'] != true ) ? sprintf( '<input type="checkbox" name="field[%s]" value="delete" />', $item['meta'] ) : ''; 
     567    } 
     568     
     569    /** 
     570     * Sets rows so that they have field IDs in the id. 
     571     * 
     572     * @since 3.1.8 
     573     * 
     574     * @global wpmem 
     575     * @param  array $columns 
     576     */ 
     577    function single_row( $columns ) { 
     578        if ( in_array( $columns['meta'], $this->excludes ) ) { 
     579            echo '<tr id="' . $columns['meta'] . '" class="nodrag nodrop">'; 
     580            echo $this->single_row_columns( $columns ); 
     581            echo "</tr>\n"; 
     582        } else { 
     583            echo '<tr id="list_items_' . $columns['order'] . '" class="list_item" list_item="' . $columns['order'] . '">'; 
     584            echo $this->single_row_columns( $columns ); 
     585            echo "</tr>\n"; 
     586        } 
     587    } 
     588     
     589    public function process_bulk_action() { 
     590 
     591    //nonce validations,etc 
     592     
     593        $action = $this->current_action(); 
     594     
     595        switch ( $action ) { 
     596     
     597            case 'delete': 
     598     
     599                // Do whatever you want 
     600                wp_redirect( esc_url( add_query_arg() ) ); 
     601                break; 
     602     
     603            default: 
     604                // do nothing or something else 
     605                return; 
     606                break; 
     607        } 
     608        return; 
     609    } 
     610     
     611} 
     612 
     613/**  
     614 * Javascript to ID the fields table and add curser style to rows. 
     615 * 
     616 * @since 3.1.8 
     617 */  
     618add_action( 'admin_footer', 'wpmem_bulk_fields_action'   ); 
     619function wpmem_bulk_fields_action() {  
     620    // if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'fields' ) {  
     621    if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'fields' ) {  
     622    ?><script type="text/javascript"> 
     623        (function($) { 
     624            $(document).ready(function() { 
     625                $("table").attr("id", "wpmem-fields"); 
     626                /**$("tr").attr('style', 'cursor:move;');**/ 
     627            }); 
     628        })(jQuery); 
     629        jQuery('<input id="add_field" name="add_field" class="button action" type="submit" value="<?php _e( 'Add Field', 'wp-members' ); ?>" />').appendTo(".top .bulkactions"); 
     630        jQuery('<input id="add_field" name="add_field" class="button action" type="submit" value="<?php _e( 'Add Field', 'wp-members' ); ?>" />').appendTo(".bottom .bulkactions"); 
     631    </script><?php 
     632    } 
     633} 
     634 
     635/** 
     636 * Updates fields. 
     637 * 
     638 * Derived from wpmem_update_fields() 
     639 * 
     640 * @since 3.1.8 
     641 * 
     642 * @global object $wpmem 
     643 * @global string $did_update 
     644 * @global string $add_field_err_msg  The add field error message 
     645 */ 
     646function wpmem_admin_fields_update() { 
     647     
     648    global $wpmem, $did_update, $delete_action; 
     649 
     650    if ( isset( $_GET['tab'] ) && $_GET['tab'] == 'fields' ) { 
     651        // Get the current fields. 
     652        $wpmem_fields    = get_option( 'wpmembers_fields' ); 
     653 
     654        $action = wpmem_get( 'action', false ); 
     655        $action = ( -1 == $action ) ? wpmem_get( 'action2' ) : $action; 
     656         
     657        $delete_action = false; 
     658 
     659        if ( 'save' == $action ) { 
     660 
     661            // Check nonce. 
     662            //check_admin_referer( 'wpmem-update-fields' ); 
     663             
     664            // Update user table fields. 
     665            $arr = ( isset( $_POST['ut_fields'] ) ) ? $_POST['ut_fields'] : ''; 
     666            update_option( 'wpmembers_utfields', $arr ); 
     667 
     668            // Update display/required settings 
     669            foreach ( $wpmem_fields as $key => $field ) { 
     670                $meta_key = $field[2]; 
     671                if ( 'user_email' == $meta_key ) { 
     672                    $wpmem_fields[ $key ][4] = 'y'; 
     673                    $wpmem_fields[ $key ][5] = 'y'; 
     674                } else { 
     675                    $wpmem_fields[ $key ][4] = ( wpmem_get( $meta_key . "_display"  ) ) ? 'y' : ''; 
     676                    $wpmem_fields[ $key ][5] = ( wpmem_get( $meta_key . "_required" ) ) ? 'y' : ''; 
     677                } 
     678            } 
     679            update_option( 'wpmembers_fields', $wpmem_fields ); 
     680            $wpmem->load_fields(); 
     681            $did_update = __( 'WP-Members fields were updated', 'wp-members' ); 
     682            return $did_update; 
     683             
     684        } elseif ( 'delete' == $action ) { 
     685             
     686            $delete_action = 'delete'; 
     687 
     688        } elseif ( 'add_field' == wpmem_get( 'wpmem_admin_a' ) || 'edit_field' == wpmem_get( 'wpmem_admin_a' ) ) { 
     689             
     690            // Set action. 
     691            $action = wpmem_get( 'wpmem_admin_a' ); 
     692 
     693            // Check nonce. 
     694            //check_admin_referer( 'wpmem-add-fields' ); 
     695 
     696            global $add_field_err_msg; 
     697 
     698            $add_field_err_msg = false; 
     699            $add_name = wpmem_get( 'add_name' ); 
     700            $add_option = wpmem_get( 'add_option' ); 
     701 
     702            // Error check that field label and option name are included and unique. 
     703            $add_field_err_msg = ( ! $add_name   ) ? __( 'Field Label is required. Nothing was updated.', 'wp-members' ) : $add_field_err_msg; 
     704            $add_field_err_msg = ( ! $add_option ) ? __( 'Meta Key is required. Nothing was updated.',    'wp-members' ) : $add_field_err_msg; 
     705 
     706            $add_field_err_msg = ( ! preg_match("/^[A-Za-z0-9_]*$/", $add_option ) ) ? __( 'Meta Key must contain only letters, numbers, and underscores', 'wp-members' ) : $add_field_err_msg; 
     707 
     708            // Check for duplicate field names. 
     709            $chk_fields = array(); 
     710            foreach ( $wpmem_fields as $field ) { 
     711                $chk_fields[] = $field[2]; 
     712            } 
     713            $add_field_err_msg = ( in_array( $add_option, $chk_fields ) ) ? __( 'A field with that meta key already exists', 'wp-members' ) : $add_field_err_msg; 
     714 
     715            // Error check for reserved terms. 
     716            $reserved_terms = wpmem_wp_reserved_terms(); 
     717            if ( in_array( strtolower( $add_option ), $reserved_terms ) ) { 
     718                $add_field_err_msg = sprintf( __( 'Sorry, "%s" is a <a href="https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms" target="_blank">reserved term</a>. Field was not added.', 'wp-members' ), $submitted_term ); 
     719            } 
     720 
     721            // Error check option name for spaces and replace with underscores. 
     722            $us_option = preg_replace( "/ /", '_', $add_option ); 
     723 
     724            $arr = array(); 
     725 
     726            $type =  wpmem_get( 'add_type' ); 
     727 
     728            $arr[0] = wpmem_get( 'add_order_id' ); 
     729            $arr[1] = stripslashes( wpmem_get( 'add_name' ) ); 
     730            $arr[2] = $us_option; 
     731            $arr[3] = $type; 
     732            $arr[4] = wpmem_get( 'add_display', 'n' ); 
     733            $arr[5] = wpmem_get( 'add_required', 'n' ); 
     734            $arr[6] = ( $us_option == 'user_nicename' || $us_option == 'display_name' || $us_option == 'nickname' ) ? 'y' : 'n'; 
     735 
     736            if ( 'text' == $type || 'email' == $type || 'textarea' == $type || 'password' == $type || 'url' == $type || 'number' == $type || 'date' == $type ) { 
     737                $arr['placeholder'] = wpmem_get( 'add_placeholder' ); 
     738            } 
     739 
     740            if ( 'text' == $type || 'email' == $type || 'password' == $type || 'url' == $type || 'number' == $type || 'date' == $type ) { 
     741                $arr['pattern'] = wpmem_get( 'add_pattern' ); 
     742                $arr['title']   = wpmem_get( 'add_title' ); 
     743            } 
     744 
     745            if ( 'number' == $type || 'date' == $type ) { 
     746                $arr['min'] = wpmem_get( 'add_min' ); 
     747                $arr['max'] = wpmem_get( 'add_max' ); 
     748            } 
     749 
     750            if ( $type == 'checkbox' ) { 
     751                $add_field_err_msg = ( ! $_POST['add_checked_value'] ) ? __( 'Checked value is required for checkboxes. Nothing was updated.', 'wp-members' ) : $add_field_err_msg; 
     752                $arr[7] = wpmem_get( 'add_checked_value', false ); 
     753                $arr[8] = wpmem_get( 'add_checked_default', 'n' ); 
     754            } 
     755 
     756            if (   $type == 'select'  
     757                || $type == 'multiselect'  
     758                || $type == 'radio' 
     759                || $type == 'multicheckbox'  
     760            ) { 
     761                // Get the values. 
     762                $str = stripslashes( $_POST['add_dropdown_value'] ); 
     763                // Remove linebreaks. 
     764                $str = trim( str_replace( array("\r", "\r\n", "\n"), '', $str ) ); 
     765                // Create array. 
     766                if ( ! function_exists( 'str_getcsv' ) ) { 
     767                    $arr[7] = explode( ',', $str ); 
     768                } else { 
     769                    $arr[7] = str_getcsv( $str, ',', '"' ); 
     770                } 
     771                // If multiselect or multicheckbox, set delimiter. 
     772                if ( 'multiselect' == $type || 'multicheckbox' == $type ) { 
     773                    $arr[8] = ( isset( $_POST['add_delimiter_value'] ) ) ? $_POST['add_delimiter_value'] : '|'; 
     774                } 
     775            } 
     776 
     777            if ( $type == 'file' || $type == 'image' ) { 
     778                $arr[7] = stripslashes( $_POST['add_file_value'] ); 
     779            } 
     780 
     781            if ( wpmem_get( 'add_type' ) == 'hidden' ) {  
     782                $add_field_err_msg = ( ! $_POST['add_hidden_value'] ) ? __( 'A value is required for hidden fields. Nothing was updated.', 'wp-members' ) : $add_field_err_msg; 
     783                $arr[7] = ( isset( $_POST['add_hidden_value'] ) )   ? stripslashes( $_POST['add_hidden_value'] ) : ''; 
     784            } 
     785 
     786            if ( $action == 'add_field' ) { 
     787                if ( ! $add_field_err_msg ) { 
     788                    array_push( $wpmem_fields, $arr ); 
     789                    $did_update = sprintf( __( '%s was added', 'wp-members' ), $_POST['add_name'] ); 
     790                } else { 
     791                    $did_update = $add_field_err_msg; 
     792                } 
     793            } else { 
     794                for ( $row = 0; $row < count( $wpmem_fields ); $row++ ) { 
     795                    if ( $wpmem_fields[ $row ][2] == wpmem_get( 'field', false, 'get' ) ) { 
     796                        $arr[0] = $wpmem_fields[ $row ][0]; 
     797                        foreach ( $arr as $key => $value ) { 
     798                            $wpmem_fields[ $row ][ $key ] = $arr[ $key ]; 
     799                        } 
     800                    } 
     801                } 
     802                $did_update =  sprintf( __( '%s was updated', 'wp-members' ), $add_name ); 
     803                $did_update.= '<p><a href="' . add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields' ), get_admin_url() . 'options-general.php' ) . '">&laquo; ' . __( 'Return to Fields Table', 'wp-members' ) . '</a></p>'; 
     804            } 
     805 
     806            $wpmem_newfields = $wpmem_fields; 
     807 
     808            update_option( 'wpmembers_fields', $wpmem_newfields ); 
     809            $wpmem->load_fields(); 
     810            return $did_update;      
     811        } 
     812    } 
     813} 
     814 
     815/** 
     816 * Reorders form fields. 
     817 * 
     818 * @since 2.5.1 
     819 * @since 3.1.8 Rebuilt for new List Table. 
     820 */ 
     821function wpmem_a_field_reorder() { 
     822 
     823    // Start fresh. 
     824    $new_order = $wpmem_fields = $field = $key = $wpmem_new_fields = $id = $k = ''; 
     825    $wpmem_fields = get_option( 'wpmembers_fields' ); 
     826     
     827    // Get the list items 
     828    $new_order = $_POST; 
     829     
     830    // Put fields in the proper order for the current form. 
     831    $wpmem_new_fields = array(); 
     832    foreach ( $new_order['list_items'] as $id ) { 
     833        foreach( $wpmem_fields as $val ) { 
     834            if ( $val[0] == $id ) { 
     835                $wpmem_new_fields[] = $val; 
     836            } 
     837        } 
     838    } 
     839 
     840    // Save fields array with new current form field order. 
     841    update_option( 'wpmembers_fields', $wpmem_new_fields );  
     842 
     843    // Indicate successful transaction. 
     844    _e( 'Form field order updated.', 'wp-members' ); 
     845     
     846    die(); // This is required to return a proper result. 
     847 
    615848} 
    616849 
  • wp-members/trunk/admin/tab-options.php

    r1628757 r1667369  
    7171                    <h3><span><?php _e( 'Manage Options', 'wp-members' ); ?></span></h3> 
    7272                    <div class="inside"> 
    73                         <form name="updatesettings" id="updatesettings" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>"> 
     73                        <form name="updatesettings" id="updatesettings" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>"> 
    7474                        <?php wp_nonce_field( 'wpmem-update-settings' ); ?> 
    7575                            <h3><?php _e( 'Content', 'wp-members' ); ?></h3> 
     
    247247                    <h3><span><?php _e( 'Custom Post Types', 'wp-members' ); ?></span></h3> 
    248248                    <div class="inside"> 
    249                         <form name="updatecpts" id="updatecpts" method="post" action="<?php echo $_SERVER['REQUEST_URI']?>"> 
     249                        <form name="updatecpts" id="updatecpts" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>"> 
    250250                        <?php wp_nonce_field( 'wpmem-update-cpts' ); ?> 
    251251                            <table class="form-table"> 
  • wp-members/trunk/admin/user-profile.php

    r1628757 r1667369  
    9494                        $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file; 
    9595                    } 
    96                     // @todo - come up with a way to handle file updates - user profile form does not support multitype 
    97                     //$show_field.= ' <span class="description">' . __( 'Update this file:' ) . '</span><br />'; 
    98                     //$show_field.= wpmem_create_formfield( $meta[2] . '_update_file', $meta[3], $val, $valtochk ); 
     96                    $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />'; 
     97                    $input.= wpmem_form_field( array( 
     98                        'name'    => $meta,  
     99                        'type'    => $field['type'],  
     100                        'value'   => $val,  
     101                        'compare' => $valtochk, 
     102                    ) ); 
    99103                } else { 
    100104                    if ( 'select' == $field['type'] || 'radio' == $field['type'] ) { 
     
    237241        } 
    238242    } 
    239  
     243     
    240244    /** 
    241245     * Filter the submitted field values for backend profile update. 
     
    255259        } 
    256260    } 
     261     
     262    if ( ! empty( $_FILES ) ) { 
     263        $wpmem->user->upload_user_files( $user_id, $wpmem->fields ); 
     264    }    
    257265 
    258266    if ( $wpmem->mod_reg == 1 ) { 
  • wp-members/trunk/admin/users.php

    r1628757 r1667369  
    207207    global $pagenow, $user_action_msg; 
    208208     if( $pagenow == 'users.php' && isset( $_REQUEST['activated'] ) ) { 
    209         $message = $_REQUEST['activated']; 
     209        $message = esc_html( $_REQUEST['activated'] ); 
    210210        echo "<div class=\"updated\"><p>{$message}</p></div>"; 
    211211    } 
  • wp-members/trunk/changelog.txt

    r1531322 r1667369  
    1 = 3.1.5 = 
     1= 3.1.6 = 
     2 
     3* Fixed [wpmem_field] display handling for multiple select and multiple checkbox field types. 
     4* Updates to always load fields from wpmem_fields() API function. 
     5* Updates to begin to utilize new fields settings array.  Fields setting is still store in the same array format as before.  However, it is loaded into the new settings format.  Current object class keeps numeric keys in place for legacy purposes. 
     6* Updates to dropdown handling on main options tab to display proper preselected value when site is using ssl (https://) and no value is selected. 
     7* Added wpmem_loginout() API function, changed [wpmem_loginout] shortcode to use API function. 
     8* Added wpmem_array_insert() API function, allows for inserting array elements at any point in an array. 
     9* Added wp_destroy_current_session() to logout function. 
     10* Added WooCommerce support in native WP registration functions. Began adding WooCommerce classes to registration form elements. 
     11* Added to wpmem_user_has_role() function to check for a single role or if the user has a role that is in an array of roles. 
     12* Added wpmem_shortcodes_loaded, wpmem_hooks_loaded, and wpmem_dropins_loaded to fire after. 
     13* Added text input to set a default 'read more' link for auto excerpt. 
     14* Fixed issue with auto excerpt where an excerpt shorter than the excerpt setting would not display the more link. 
     15* Preliminary updates to include placeholder support in fields (this will be an option in a future release). 
     16* Localization fix of untranslated strings. 
     17* Wrap "Remember Me" checkbox label with label tag in login form. 
     18* Moved remaining initialization functions to class constructor. 
     19* Moved wpmem_load_shortcodes, wpmem_load_hooks, and wpmem_load_dropins to fire before. 
     20* reCAPTCHA version 1 is no longer supported by Google. It is now deprecated in the plugin. If you have reCAPTCHA v1 selected, it will remain so. But once this is changed to a different CAPTCHA setting or if this is a new install, reCAPTCHA version 1 will no longer be available as a selection. 
     21* Custom field term "Option Name" changed to "Meta Key" for clarity. 
     22* Marked required custom field properties as required in Add/Edit Field dialogs. 
     23* Changed redirect_to process to escape the url with esc_url_raw rather than esc_url, otherwise query string variables do not get handled correctly. 
     24* Fixes issue with displaying checkbox state on the admin user profile screen. 
     25* Fixes issue with auto excerpt when excerpts are displayed on single posts/pages. 
     26* Applies style properties for the remember me checkbox label to the default stylesheets. The label tag was added to this text in 3.1.6 (see below). 
     27* Applies some admin strings for translation. 
     28 
     29= 3.1.5 = 
    230 
    331* Addressed some security issues to prevent XSS vulnerabilities. 
  • wp-members/trunk/css/generic-no-float.css

    r1628757 r1667369  
    9898#wpmem_reg input[type="email"], 
    9999#wpmem_reg input[type="url"], 
     100#wpmem_reg input[type="number"], 
     101#wpmem_reg input[type="date"], 
    100102#wpmem_reg textarea, 
    101103#wpmem_login input[type="text"], 
     
    149151    font-weight: 700; 
    150152    margin-bottom: 10px; 
     153    width: 100%; 
    151154} 
    152155#wpmem_reg .form,  
     
    174177#wpmem_reg .div_image, 
    175178#wpmem_reg .div_file, 
    176 #wpmem_reg .div_url {  
     179#wpmem_reg .div_url, 
     180#wpmem_reg .div_number, 
     181#wpmem_reg .div_date {  
    177182    width:74%; 
    178183    margin:0 0 14px 0; 
  • wp-members/trunk/css/wp-members-2014-no-float.css

    r1531322 r1667369  
    116116#wpmem_reg .div_image, 
    117117#wpmem_reg .div_file, 
    118 #wpmem_reg .div_url{  
     118#wpmem_reg .div_url, 
     119#wpmem_reg .div_number, 
     120#wpmem_reg .div_date {  
    119121    width:74%; 
    120122    margin:0 0 14px 0; 
  • wp-members/trunk/css/wp-members-2015-no-float.css

    r1548526 r1667369  
    147147#wpmem_reg .div_url, 
    148148#wpmem_reg .div_image, 
    149 #wpmem_reg .div_file {  
     149#wpmem_reg .div_file, 
     150#wpmem_reg .div_number, 
     151#wpmem_reg .div_date {  
    150152    width:74%; 
    151153    margin:0 0 14px 0; 
  • wp-members/trunk/css/wp-members-2016-no-float.css

    r1548526 r1667369  
    155155#wpmem_reg .div_url, 
    156156#wpmem_reg .div_file, 
    157 #wpmem_reg .div_image {  
     157#wpmem_reg .div_image, 
     158#wpmem_reg .div_number, 
     159#wpmem_reg .div_date {  
    158160    width:74%; 
    159161    margin:0 0 14px 0; 
  • wp-members/trunk/inc/api.php

    r1628757 r1667369  
    289289 * 
    290290 * @global object        $current_user Current user object. 
     291 * @global object        $wpmem        WP_Members object. 
    291292 * @param  string|array  $role         Slug or array of slugs of the role being checked. 
    292293 * @param  int           $user_id      ID of the user being checked (optional). 
     
    311312        return ( in_array( $role, $user->roles ) ) ? true : $has_role; 
    312313    } 
     314} 
     315 
     316/** 
     317 * Checks if a user has a given meta value. 
     318 * 
     319 * @since 3.1.8 
     320 * 
     321 * @global object  $wpmem     WP_Members object. 
     322 * @param  string  $meta      Meta key being checked. 
     323 * @param  string  $value     Value the meta key should have (optional). 
     324 * @param  int     $user_id   ID of the user being checked (optional). 
     325 * @return boolean $has_meta  True if user has the meta value, otherwise false. 
     326 */ 
     327function wpmem_user_has_meta( $meta, $value = false, $user_id = false ) { 
     328    global $wpmem; 
     329    $user_id = ( $user_id ) ? $user_id : get_current_user_id(); 
     330    $has_meta = false; 
     331    $user_value = get_user_meta( $user_id, $meta, true ); 
     332    if ( $value ) { 
     333        $has_meta = ( $user_value == $value ) ? true : $has_meta; 
     334    } else { 
     335        $has_meta = ( $value ) ? true : $has_meta; 
     336    } 
     337    return $has_meta; 
    313338} 
    314339 
  • wp-members/trunk/inc/class-wp-members-api.php

    r1628757 r1667369  
    6262        } 
    6363        return $display_values; 
     64    } 
     65     
     66    /** 
     67     * Gets the display/label value of a field. 
     68     * 
     69     * @since 3.1.8 
     70     * 
     71     * @param  string $meta    The field meta key. 
     72     * @param  string $user_id The user's ID. 
     73     * @param  string $value   The field's value, if given. 
     74     * @return string $value   The display value. 
     75     */ 
     76    function get_field_display_value( $meta, $user_id, $value = null ) { 
     77        global $wpmem; 
     78        $fields = ( isset( $wpmem->fields ) ) ? $wpmem->fields : wpmem_fields(); 
     79        $field  = $fields[ $meta ]; 
     80        $value  = ( $value ) ? $value : get_user_meta( $user_id, $meta, true ); 
     81        switch ( $field['type'] ) { 
     82            case 'multiselect': 
     83            case 'multicheckbox': 
     84                break; 
     85            case 'select': 
     86            case 'radio': 
     87                $value = $fields[ $meta ]['options'][ $value ]; 
     88                break; 
     89            case 'image': 
     90            case 'file': 
     91                $value = wp_get_attachment_url( $value ); 
     92                break; 
     93        } 
     94        return $value; 
    6495    } 
    6596         
  • wp-members/trunk/inc/class-wp-members-forms.php

    r1628774 r1667369  
    6767        case "email": 
    6868        case "number": 
     69        case "date": 
    6970            $class = ( 'textbox' == $class ) ? "textbox" : $class; 
    7071            switch ( $type ) { 
     
    7576                    $value = esc_attr( wp_unslash( $value ) ); 
    7677                    break; 
    77                 case 'number': 
    78                     $value = $value; 
     78                //case 'number': 
     79                    //$value = esc_attr( $value ); 
    7980                default: 
    8081                    $value = stripslashes( esc_attr( $value ) ); 
     
    8586            $pattern     = ( $pattern     ) ? ' pattern="' . $pattern . '"' : ''; 
    8687            $title       = ( $title       ) ? ' title="' . $title . '"' : ''; 
    87             $min         = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : ''; 
    88             $max         = ( isset( $args['max'] ) ) ? ' max="' . $args['max'] . '"' : ''; 
     88            $min         = ( isset( $args['min'] ) && $args['min'] != '' ) ? ' min="' . $args['min'] . '"' : ''; 
     89            $max         = ( isset( $args['max'] ) && $args['max'] != '' ) ? ' max="' . $args['max'] . '"' : ''; 
    8990            $str = "<input name=\"$name\" type=\"$type\" id=\"$name\" value=\"$value\" class=\"$class\"$placeholder$title$pattern$min$max" . ( ( $required ) ? " required " : "" ) . " />"; 
    9091            break; 
     
    107108     
    108109        case "textarea": 
    109             $value = stripslashes( esc_textarea( $value ) ); 
     110            $value = stripslashes( $value ); // stripslashes( esc_textarea( $value ) ); 
    110111            $class = ( 'textbox' == $class ) ? "textarea" : $class; 
    111112            $rows  = ( isset( $args['rows'] ) ) ? $args['rows'] : '5'; 
     
    314315 
    315316    /** 
    316      * Login Form Dialog. 
     317     * Login Form Builder. 
    317318     * 
    318319     * Builds the form used for login, change password, and reset password. 
    319320     * 
    320321     * @since 2.5.1 
     322     * @since 3.1.7 Moved to forms object class as login_form(). 
    321323     * @since 3.1.7 Added WP action login_form. 
    322324     * 
     
    486488        $links_array = array( 
    487489            'forgot' => array( 
     490                'tag'  => 'forgot', 
    488491                'link' => add_query_arg( 'a', 'pwdreset', $wpmem->user_pages['profile'] ), 
    489492                'page' => 'profile', 
    490493                'action' => 'login', 
    491494            ), 
    492             'register' => array(  
     495            'register' => array( 
     496                'tag'  => 'reg', 
    493497                'link' => $wpmem->user_pages['register'], 
    494498                'page' => 'register', 
     
    496500            ), 
    497501            'username' => array( 
     502                'tag'  => 'username', 
    498503                'link' => add_query_arg( 'a', 'getusername', $wpmem->user_pages['profile'] ), 
    499504                'page' => 'profile', 
     
    502507        ); 
    503508        foreach ( $links_array as $key => $value ) { 
     509            $tag = $value['tag']; 
    504510            if ( ( $wpmem->user_pages[ $value['page'] ] || 'members' == $page ) && $value['action'] == $arr['action'] ) { 
    505511                /** 
     
    511517                 * @param string The raw link. 
    512518                 */ 
    513                 $link = apply_filters( "wpmem_{$key}_link", $value['link'] ); 
     519                $link = apply_filters( "wpmem_{$tag}_link", $value['link'] ); 
    514520                $str  = $wpmem->get_text( "{$key}_link_before" ) . '<a href="' . $link . '">' . $wpmem->get_text( "{$key}_link" ) . '</a>'; 
    515521                /** 
     
    523529                 * @param string $link The link. 
    524530                 */ 
    525                 $form = $form . $args['link_before'] . apply_filters( "wpmem_{$key}_link_str", $str, $link ) . $args['link_after'] . $args['n']; 
     531                $link = $args['link_before'] . apply_filters( "wpmem_{$tag}_link_str", $str, $link ) . $args['link_after'] . $args['n']; 
     532                /* 
     533                 * If this is the register link, and the current post type is set to 
     534                 * display the register form, and the current page is not the login 
     535                 * page, then do not add the register link, otherwise add the link. 
     536                 */ 
     537                $form = ( 'register' == $key && 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && wpmem_current_url() != wpmem_login_url() ) ? $form : $form . $link; 
     538                //$form = ( 'register' == $key && isset( $wpmem->user_pages['profile'] ) && ( wpmem_current_url() == $wpmem->user_pages['profile'] ) && 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] ) ? $form : $form . $link; 
    526539            } 
    527540        } 
     
    572585 
    573586        return $form; 
    574     } // End wpmem_login_form. 
     587    } // End login_form. 
    575588 
    576589    /** 
    577      * Registration Form Dialog. 
     590     * Registration Form Builder. 
    578591     * 
    579592     * Outputs the form for new user registration and existing user edits. 
    580593     * 
    581594     * @since 2.5.1 
     595     * @since 3.1.7 Moved to forms object class as register_form(). 
    582596     * 
    583597     * @global object $wpmem        The WP_Members object. 
     
    746760 
    747761                    $class = ( $field['type'] == 'password' || $field['type'] == 'email' || $field['type'] == 'url' ) ? 'text' : $field['type']; 
    748  
    749                 //  $label = '<label for="' . $meta_key . '" class="' . $class . '">' . __( $field['label'], 'wp-members' ); 
    750                 //  $label = ( $field['required'] ) ? $label . $args['req_mark'] : $label; 
    751                 //  $label = $label . '</label>'; 
    752762                     
    753763                    $label = wpmem_form_label( array( 
     
    767777                    switch ( $meta_key ) { 
    768778                        case( 'description' ): 
    769                             $val = htmlspecialchars( get_user_meta( $userdata->ID, 'description', 'true' ) ); 
     779                        case( 'textarea' == $field['type'] ): 
     780                            $val = get_user_meta( $userdata->ID, 'description', 'true' ); // esc_textarea() is run when field is created. 
    770781                            break; 
    771782 
     
    776787 
    777788                        case 'user_url': 
    778                             $val = esc_url( $userdata->user_url ); 
     789                            $val = $userdata->user_url; // esc_url() is run when the field is created. 
    779790                            break; 
    780791 
     
    861872                            $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file; 
    862873                        } 
    863                         // @todo - come up with a way to handle file updates - user profile form does not support multitype 
    864874                        $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />'; 
    865875                        $input.= wpmem_form_field( array( 
     
    10911101 
    10921102        // Remove line breaks if enabled for easier filtering later. 
    1093         $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form; 
     1103        $form = ( $args['strip_breaks'] ) ? $this->strip_breaks( $form, $rows ) : $form; //str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form; 
    10941104 
    10951105        /** 
     
    11351145        // Return the generated form. 
    11361146        return $form; 
    1137     } // End wpmem_inc_registration. 
     1147    } // End register_form(). 
     1148     
     1149    /** 
     1150     * Strip line breaks from form. 
     1151     * 
     1152     * Function removes line breaks and tabs. Checks for textarea fields 
     1153     * before stripping line breaks. 
     1154     * 
     1155     * @since 3.1.8 
     1156     * 
     1157     * @param  string $form 
     1158     * @param  array  $rows 
     1159     * @return string $form 
     1160     */ 
     1161    function strip_breaks( $form, $rows ) { 
     1162        foreach( $rows as $key => $row ) { 
     1163            if ( 'textarea' == $row['type'] ) { 
     1164                $textareas[ $key ] = $row['field']; 
     1165            } 
     1166        } 
     1167        $form = str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ); 
     1168        if ( ! empty ( $textareas ) ) { 
     1169            foreach ( $textareas as $textarea ) { 
     1170                $stripped = str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $textarea ); 
     1171                $form = str_replace( $stripped, $textarea, $form ); 
     1172            } 
     1173        } 
     1174        return $form; 
     1175    } 
    11381176 
    11391177} // End of WP_Members_Forms class. 
  • wp-members/trunk/inc/class-wp-members-user.php

    r1628757 r1667369  
    157157        // Handle file uploads, if any. 
    158158        if ( ! empty( $_FILES ) ) { 
    159  
    160             foreach ( $wpmem->fields as $meta_key => $field ) { 
    161  
    162                 if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) { 
    163  
    164                     // Upload the file and save it as an attachment. 
    165                     $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $user_id ); 
    166  
    167                     // Save the attachment ID as user meta. 
    168                     update_user_meta( $user_id, $meta_key, $file_post_id ); 
    169                 } 
    170             } 
     159            $this->upload_user_files( $user_id, $wpmem->fields ); 
    171160        } 
    172161 
     
    333322    } 
    334323     
     324    /** 
     325     * Handles retrieving a forgotten username. 
     326     * 
     327     * @since 3.0.8 
     328     * @since 3.1.6 Dependencies now loaded by object. 
     329     * @since 3.1.8 Moved to user object. 
     330     * 
     331     * @return string $regchk The regchk value. 
     332     */ 
     333    function retrieve_username() { 
     334        if ( isset( $_POST['formsubmit'] ) ) { 
     335            $email = sanitize_email( $_POST['user_email'] ); 
     336            $user  = ( isset( $_POST['user_email'] ) ) ? get_user_by( 'email', $email ) : false; 
     337            if ( $user ) { 
     338                // Send it in an email. 
     339                wpmem_inc_regemail( $user->ID, '', 4 ); 
     340                /** 
     341                 * Fires after retrieving username. 
     342                 * 
     343                 * @since 3.0.8 
     344                 * 
     345                 * @param int $user_ID The user's numeric ID. 
     346                 */ 
     347                do_action( 'wpmem_get_username', $user->ID ); 
     348                return 'usernamesuccess'; 
     349            } else { 
     350                return 'usernamefailed'; 
     351            } 
     352        } 
     353        return; 
     354    } 
     355     
     356    /** 
     357     * Handle user file uploads for registration and profile update. 
     358     * 
     359     * @since 3.1.8 
     360     * 
     361     * @param string $user_id 
     362     * @param array  $fields 
     363     */ 
     364    function upload_user_files( $user_id, $fields ) { 
     365        global $wpmem; 
     366        foreach ( $fields as $meta_key => $field ) { 
     367            if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) { 
     368                if ( ! empty( $_FILES[ $meta_key ]['name'] ) ) { 
     369                    // Upload the file and save it as an attachment. 
     370                    $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $user_id ); 
     371                    // Save the attachment ID as user meta. 
     372                    update_user_meta( $user_id, $meta_key, $file_post_id ); 
     373                } 
     374            } 
     375        } 
     376    } 
     377     
    335378} 
  • wp-members/trunk/inc/class-wp-members.php

    r1628757 r1667369  
    312312 
    313313        // Add filters. 
    314         add_filter( 'the_content',           array( $this, 'do_securify' ), 99 ); 
    315         add_filter( 'allow_password_reset',  'wpmem_no_reset' );                 // no password reset for non-activated users 
    316         add_filter( 'register_form',         'wpmem_wp_register_form' );         // adds fields to the default wp registration 
    317         add_filter( 'registration_errors',   'wpmem_wp_reg_validate', 10, 3 );   // native registration validation 
    318         add_filter( 'comments_open',         'wpmem_securify_comments', 99 );    // securifies the comments 
    319         add_filter( 'wpmem_securify',        'wpmem_reg_securify' );             // adds success message on login form if redirected 
     314        add_filter( 'the_content',               array( $this, 'do_securify' ), 99 ); 
     315        add_filter( 'allow_password_reset',      'wpmem_no_reset' );                 // no password reset for non-activated users 
     316        add_filter( 'register_form',             'wpmem_wp_register_form' );         // adds fields to the default wp registration 
     317        add_action( 'woocommerce_register_form', 'wpmem_woo_register_form' ); 
     318        add_filter( 'registration_errors',       'wpmem_wp_reg_validate', 10, 3 );   // native registration validation 
     319        add_filter( 'comments_open',             'wpmem_securify_comments', 99 );    // securifies the comments 
     320        add_filter( 'wpmem_securify',            'wpmem_reg_securify' );             // adds success message on login form if redirected 
    320321         
    321322        // If registration is moderated, check for activation (blocks backend login by non-activated users). 
     
    426427        require_once( WPMEM_PATH . 'inc/api.php' ); 
    427428        require_once( WPMEM_PATH . 'inc/utilities.php' ); 
     429        require_once( WPMEM_PATH . 'inc/forms.php' ); 
    428430        require_once( WPMEM_PATH . 'inc/dialogs.php' ); 
    429431        require_once( WPMEM_PATH . 'inc/sidebar.php' ); 
    430432        require_once( WPMEM_PATH . 'inc/shortcodes.php' ); 
    431433        require_once( WPMEM_PATH . 'inc/email.php' ); 
     434        require_once( WPMEM_PATH . 'inc/users.php' ); 
    432435        require_once( WPMEM_PATH . 'inc/deprecated.php' ); 
    433436    } 
     
    511514 
    512515            case 'login': 
    513                 $regchk = wpmem_login(); 
     516                $regchk = $this->user->login(); 
    514517                break; 
    515518 
    516519            case 'logout': 
    517                 $regchk = wpmem_logout(); 
     520                $regchk = $this->user->logout(); 
    518521                break; 
    519522             
    520523            case 'pwdchange': 
    521                 $regchk = wpmem_change_password(); 
     524                $regchk = $this->user->password_update( 'change' ); 
    522525                break; 
    523526             
    524527            case 'pwdreset': 
    525                 $regchk = wpmem_reset_password(); 
     528                $regchk = $this->user->password_update( 'reset' ); 
    526529                break; 
    527530             
    528531            case 'getusername': 
    529                 $regchk = wpmem_retrieve_username(); 
     532                $regchk = $this->user->retrieve_username(); 
    530533                break; 
    531534             
  • wp-members/trunk/inc/core.php

    r1628757 r1667369  
    214214 * 
    215215 * @since 2.8.3 
    216  */ 
    217 function wpmem_wp_register_form() { 
     216 * @since 3.1.8 Added $process argument. 
     217 */ 
     218function wpmem_wp_register_form( $process = 'wp' ) { 
    218219    /** 
    219220     * Load native WP registration functions. 
    220221     */ 
    221222    require_once( WPMEM_PATH . 'inc/wp-registration.php' ); 
    222     wpmem_do_wp_register_form(); 
     223    wpmem_do_wp_register_form( $process ); 
    223224} 
    224225 
     
    373374 * @since 3.0.8 
    374375 * @since 3.1.6 Dependencies now loaded by object. 
     376 * @since 3.1.8 Now a wrapper for $wpmem->retrieve_username() in WP_Members_Users Class. 
     377 * 
     378 * @global object $wpmem The WP-Members object class. 
    375379 * 
    376380 * @return string $regchk The regchk value. 
    377381 */ 
    378382function wpmem_retrieve_username() { 
    379      
    380     if ( isset( $_POST['formsubmit'] ) ) { 
    381          
    382         $email = sanitize_email( $_POST['user_email'] ); 
    383         $user  = ( isset( $_POST['user_email'] ) ) ? get_user_by( 'email', $email ) : false; 
    384      
    385         if ( $user ) { 
    386              
    387             // Send it in an email. 
    388             wpmem_inc_regemail( $user->ID, '', 4 ); 
    389      
    390             /** 
    391              * Fires after retrieving username. 
    392              * 
    393              * @since 3.0.8 
    394              * 
    395              * @param int $user_ID The user's numeric ID. 
    396              */ 
    397             do_action( 'wpmem_get_username', $user->ID ); 
    398  
    399             return 'usernamesuccess'; 
    400              
    401         } else { 
    402             return 'usernamefailed'; 
    403         } 
    404     } 
    405     return; 
     383    global $wpmem; 
     384    return $wpmem->user->retrieve_username(); 
    406385} 
    407386 
  • wp-members/trunk/inc/deprecated.php

    r1628757 r1667369  
    187187} 
    188188endif; 
     189 
     190 
     191if ( ! function_exists( 'wpmem_do_sc_pages' ) ): 
     192/** 
     193 * Builds the shortcode pages (login, register, user-profile, user-edit, password). 
     194 * 
     195 * Some of the logic here is similar to the wpmem_securify() function.  
     196 * But where that function handles general content, this function  
     197 * handles building specific pages generated by shortcodes. 
     198 * 
     199 * @since 2.6.0 
     200 * @deprecated 3.1.8 Use wpmem_sc_user_profile() or wpmem_sc_forms() instead. 
     201 * 
     202 * @global object $wpmem        The WP_Members object. 
     203 * @global string $wpmem_themsg The WP-Members message container. 
     204 * @global object $post         The WordPress post object. 
     205 * 
     206 * @param  string $atts { 
     207 *     The shortcode attributes. 
     208 * 
     209 *     @type string $page 
     210 *     @type string $redirect_to 
     211 *     @type string $register 
     212 * } 
     213 * @param  string $content 
     214 * @param  string $tag 
     215 * @return string $content 
     216 */ 
     217function wpmem_do_sc_pages( $atts, $content, $tag ) { 
     218     
     219    $page = ( isset( $atts['page'] ) ) ? $atts['page'] : $tag;  
     220    $redirect_to = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null; 
     221    $hide_register = ( isset( $atts['register'] ) && 'hide' == $atts['register'] ) ? true : false; 
     222 
     223    global $wpmem, $wpmem_themsg, $post; 
     224    include_once( WPMEM_PATH . 'inc/dialogs.php' ); 
     225 
     226    $content = ''; 
     227 
     228    // Deprecating members-area parameter to be replaced by user-profile. 
     229    $page = ( $page == 'user-profile' ) ? 'members-area' : $page; 
     230 
     231    if ( $page == 'members-area' || $page == 'register' ) { 
     232 
     233        if ( $wpmem->regchk == "captcha" ) { 
     234            global $wpmem_captcha_err; 
     235            $wpmem_themsg = __( 'There was an error with the CAPTCHA form.' ) . '<br /><br />' . $wpmem_captcha_err; 
     236        } 
     237 
     238        if ( $wpmem->regchk == "loginfailed" ) { 
     239            return wpmem_inc_loginfailed(); 
     240        } 
     241 
     242        if ( ! is_user_logged_in() ) { 
     243            if ( $wpmem->action == 'register' && ! $hide_register ) { 
     244 
     245                switch( $wpmem->regchk ) { 
     246 
     247                case "success": 
     248                    $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg ); 
     249                    $content = $content . wpmem_inc_login(); 
     250                    break; 
     251 
     252                default: 
     253                    $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg ); 
     254                    $content = $content . wpmem_inc_registration(); 
     255                    break; 
     256                } 
     257 
     258            } elseif ( $wpmem->action == 'pwdreset' ) { 
     259 
     260                $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
     261 
     262            } elseif( $wpmem->action == 'getusername' ) { 
     263                 
     264                $content = wpmem_page_forgot_username( $wpmem->regchk, $content ); 
     265                 
     266            } else { 
     267 
     268                $content = ( $page == 'members-area' ) ? $content . wpmem_inc_login( 'members' ) : $content; 
     269                $content = ( ( $page == 'register' || $wpmem->show_reg[ $post->post_type ] != 0 ) && ! $hide_register ) ? $content . wpmem_inc_registration() : $content; 
     270            } 
     271 
     272        } elseif ( is_user_logged_in() && $page == 'members-area' ) { 
     273 
     274            /** 
     275             * Filter the default heading in User Profile edit mode. 
     276             * 
     277             * @since 2.7.5 
     278             * 
     279             * @param string The default edit mode heading. 
     280             */ 
     281            $heading = apply_filters( 'wpmem_user_edit_heading', __( 'Edit Your Information', 'wp-members' ) ); 
     282 
     283            switch( $wpmem->action ) { 
     284 
     285            case "edit": 
     286                $content = $content . wpmem_inc_registration( 'edit', $heading ); 
     287                break; 
     288 
     289            case "update": 
     290 
     291                // Determine if there are any errors/empty fields. 
     292 
     293                if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) { 
     294 
     295                    $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
     296                    $content = $content . wpmem_inc_registration( 'edit', $heading ); 
     297 
     298                } else { 
     299 
     300                    //Case "editsuccess". 
     301                    $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
     302                    $content = $content . wpmem_inc_memberlinks(); 
     303 
     304                } 
     305                break; 
     306 
     307            case "pwdchange": 
     308 
     309                $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
     310                break; 
     311 
     312            case "renew": 
     313                $content = wpmem_renew(); 
     314                break; 
     315 
     316            default: 
     317                $content = wpmem_inc_memberlinks(); 
     318                break; 
     319            } 
     320 
     321        } elseif ( is_user_logged_in() && $page == 'register' ) { 
     322 
     323            $content = $content . wpmem_inc_memberlinks( 'register' ); 
     324 
     325        } 
     326 
     327    } 
     328 
     329    if ( $page == 'login' ) { 
     330        $content = ( $wpmem->regchk == "loginfailed" ) ? wpmem_inc_loginfailed() : $content; 
     331        $content = ( ! is_user_logged_in() ) ? $content . wpmem_inc_login( 'login', $redirect_to ) : wpmem_inc_memberlinks( 'login' ); 
     332    } 
     333 
     334    if ( $page == 'password' ) { 
     335        $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
     336    } 
     337 
     338    if ( $page == 'user-edit' ) { 
     339        $content = wpmem_page_user_edit( $wpmem->regchk, $content ); 
     340    } 
     341 
     342    return $content; 
     343} // End wpmem_do_sc_pages. 
     344endif; 
  • wp-members/trunk/inc/dialogs.php

    r1628757 r1667369  
    2323 * - wpmem_inc_forgotusername 
    2424 */ 
    25  
    26  
    27 // Include the form building functions. 
    28 include_once( WPMEM_PATH . 'inc/forms.php' ); 
    2925 
    3026 
  • wp-members/trunk/inc/forms.php

    r1628757 r1667369  
    477477} 
    478478 
     479/** 
     480 * Add registration fields to WooCommerce registration. 
     481 * 
     482 * As of WooCommerce 3.0, the WC registration process no longer includes the 
     483 * WP register_form action hook.  It only includes woocommerce_register_form. 
     484 * In previous versions, WP-Members hooked to register_form for both WP and 
     485 * WC registration. To provide backward compatibility with users who may 
     486 * continue to use updated WP-Members with pre-3.0 WooCommerce, this function 
     487 * checks for WC version and if it is older than 3.0 it will ignore adding 
     488 * the WP-Members form fields as they would have already been added when the 
     489 * register_form action hook fired. 
     490 * 
     491 * @since 3.1.8 
     492 */ 
     493function wpmem_woo_register_form() { 
     494    if ( class_exists( 'WooCommerce' ) ) { 
     495        global $woocommerce; 
     496        if ( version_compare( $woocommerce->version, '3.0', ">=" ) ) { 
     497            wpmem_wp_register_form( 'woo' ); 
     498        } 
     499    } 
     500} 
     501 
    479502// End of file. 
  • wp-members/trunk/inc/register.php

    r1628757 r1667369  
    272272         */ 
    273273        global $current_user; wp_get_current_user(); 
    274         if ( $wpmem->user->post_data['user_email'] !=  $current_user->user_email ) { 
     274        if ( $wpmem->user->post_data['user_email'] != $current_user->user_email ) { 
    275275            if ( email_exists( $wpmem->user->post_data['user_email'] ) ) {  
    276276                return "email"; 
    277277                exit(); 
    278278            }  
    279             if ( !is_email( $wpmem->user->post_data['user_email']) ) {  
     279            if ( in_array( 'user_email', $wpmem->fields ) && ! is_email( $wpmem->user->post_data['user_email']) ) {  
    280280                $wpmem_themsg = $wpmem->get_text( 'reg_valid_email' ); 
    281281                return "updaterr"; 
     
    363363        // Handle file uploads, if any. 
    364364        if ( ! empty( $_FILES ) ) { 
    365      
    366             foreach ( $wpmem->fields as $meta_key => $field ) { 
    367      
    368                 if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && is_array( $_FILES[ $meta_key ] ) ) { 
    369                     if ( ! empty( $_FILES[ $meta_key ]['name'] ) ) { 
    370                         // Upload the file and save it as an attachment. 
    371                         $file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $wpmem->user->post_data['ID'] ); 
    372      
    373                         // Save the attachment ID as user meta. 
    374                         update_user_meta( $wpmem->user->post_data['ID'], $meta_key, $file_post_id ); 
    375                     } 
    376                 } 
    377             } 
     365            $wpmem->user->upload_user_files( $wpmem->user->post_data['ID'], $wpmem->fields ); 
    378366        } 
    379367 
  • wp-members/trunk/inc/shortcodes.php

    r1628757 r1667369  
    1919 * - wpmem_sc_logged_in 
    2020 * - wpmem_sc_logged_out 
    21  * - wpmem_do_sc_pages 
    2221 * - wpmem_sc_user_count 
    2322 * - wpmem_sc_user_profile 
     
    4544     
    4645    global $wpmem, $wpmem_themsg; 
    47      
    48     /** 
    49      * Load core functions if they are not already loaded. 
    50      */ 
    51     include_once( WPMEM_PATH . 'inc/core.php' ); 
    52      
    53     /** 
    54      * Load dialog functions if they are not already loaded. 
    55      */ 
    56     include_once( WPMEM_PATH . 'inc/dialogs.php' ); 
    5746 
    5847    // Defaults. 
     
    205194            if ( isset( $atts['role'] ) ) { 
    206195                $roles = explode( ',', $atts['role'] ); 
    207                 foreach ( $roles as $role ) { 
    208                     if ( in_array( trim( $role ), $current_user->roles ) ) { 
    209                         $do_return = true; 
    210                     } 
     196                if ( wpmem_user_has_role( $roles ) ) { 
     197                    $do_return = true; 
    211198                } 
    212199            } 
    213200             
    214201            // If there is a status attribute of "sub" and the user is logged in. 
    215             if ( ( isset( $atts['status'] ) ) && $atts['status'] == 'sub' && is_user_logged_in() ) { 
     202            if ( ( isset( $atts['status'] ) ) && $atts['status'] == 'sub' ) { 
    216203                if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) {   
    217204                    if ( ! wpmem_chk_exp() ) { 
     
    224211            } 
    225212             
    226             // If the current page is the user profile and an action is being handled. 
    227             if ( ( wpmem_current_url() == $wpmem->user_pages['profile'] ) && isset( $_GET['a'] ) ) { 
     213            // If there is a meta key attribute. 
     214            if ( isset( $atts['meta_key'] ) ) { 
     215                $value = ( isset( $atts['meta_value'] ) ) ? $atta['meta_value'] : false; 
     216                if ( wpmem_user_has_meta( $atts['meta_key'], $value ) ) { 
     217                    $do_return = true; 
     218                } 
     219            } 
     220             
     221            // Prevents display if the current page is the user profile and an action is being handled. 
     222            if ( ( wpmem_current_url( true, false ) == wpmem_profile_url() ) && isset( $_GET['a'] ) ) { 
    228223                $do_return = false; 
    229224            } 
     
    249244    return ( ! is_user_logged_in() ) ? do_shortcode( $content ) : ''; 
    250245} 
    251  
    252 if ( ! function_exists( 'wpmem_do_sc_pages' ) ): 
    253 /** 
    254  * Builds the shortcode pages (login, register, user-profile, user-edit, password). 
    255  * 
    256  * Some of the logic here is similar to the wpmem_securify() function.  
    257  * But where that function handles general content, this function  
    258  * handles building specific pages generated by shortcodes. 
    259  * 
    260  * @since 2.6.0 
    261  * 
    262  * @global object $wpmem        The WP_Members object. 
    263  * @global string $wpmem_themsg The WP-Members message container. 
    264  * @global object $post         The WordPress post object. 
    265  * 
    266  * @param  string $atts { 
    267  *     The shortcode attributes. 
    268  * 
    269  *     @type string $page 
    270  *     @type string $redirect_to 
    271  *     @type string $register 
    272  * } 
    273  * @param  string $content 
    274  * @param  string $tag 
    275  * @return string $content 
    276  */ 
    277 function wpmem_do_sc_pages( $atts, $content, $tag ) { 
    278      
    279     $page = ( isset( $atts['page'] ) ) ? $atts['page'] : $tag;  
    280     $redirect_to = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null; 
    281     $hide_register = ( isset( $atts['register'] ) && 'hide' == $atts['register'] ) ? true : false; 
    282  
    283     global $wpmem, $wpmem_themsg, $post; 
    284     include_once( WPMEM_PATH . 'inc/dialogs.php' ); 
    285  
    286     $content = ''; 
    287  
    288     // Deprecating members-area parameter to be replaced by user-profile. 
    289     $page = ( $page == 'user-profile' ) ? 'members-area' : $page; 
    290  
    291     if ( $page == 'members-area' || $page == 'register' ) { 
    292  
    293         if ( $wpmem->regchk == "captcha" ) { 
    294             global $wpmem_captcha_err; 
    295             $wpmem_themsg = __( 'There was an error with the CAPTCHA form.' ) . '<br /><br />' . $wpmem_captcha_err; 
    296         } 
    297  
    298         if ( $wpmem->regchk == "loginfailed" ) { 
    299             return wpmem_inc_loginfailed(); 
    300         } 
    301  
    302         if ( ! is_user_logged_in() ) { 
    303             if ( $wpmem->action == 'register' && ! $hide_register ) { 
    304  
    305                 switch( $wpmem->regchk ) { 
    306  
    307                 case "success": 
    308                     $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg ); 
    309                     $content = $content . wpmem_inc_login(); 
    310                     break; 
    311  
    312                 default: 
    313                     $content = wpmem_inc_regmessage( $wpmem->regchk,$wpmem_themsg ); 
    314                     $content = $content . wpmem_inc_registration(); 
    315                     break; 
    316                 } 
    317  
    318             } elseif ( $wpmem->action == 'pwdreset' ) { 
    319  
    320                 $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
    321  
    322             } elseif( $wpmem->action == 'getusername' ) { 
    323                  
    324                 $content = wpmem_page_forgot_username( $wpmem->regchk, $content ); 
    325                  
    326             } else { 
    327  
    328                 $content = ( $page == 'members-area' ) ? $content . wpmem_inc_login( 'members' ) : $content; 
    329                 $content = ( ( $page == 'register' || $wpmem->show_reg[ $post->post_type ] != 0 ) && ! $hide_register ) ? $content . wpmem_inc_registration() : $content; 
    330             } 
    331  
    332         } elseif ( is_user_logged_in() && $page == 'members-area' ) { 
    333  
    334             /** 
    335              * Filter the default heading in User Profile edit mode. 
    336              * 
    337              * @since 2.7.5 
    338              * 
    339              * @param string The default edit mode heading. 
    340              */ 
    341             $heading = apply_filters( 'wpmem_user_edit_heading', __( 'Edit Your Information', 'wp-members' ) ); 
    342  
    343             switch( $wpmem->action ) { 
    344  
    345             case "edit": 
    346                 $content = $content . wpmem_inc_registration( 'edit', $heading ); 
    347                 break; 
    348  
    349             case "update": 
    350  
    351                 // Determine if there are any errors/empty fields. 
    352  
    353                 if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) { 
    354  
    355                     $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
    356                     $content = $content . wpmem_inc_registration( 'edit', $heading ); 
    357  
    358                 } else { 
    359  
    360                     //Case "editsuccess". 
    361                     $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
    362                     $content = $content . wpmem_inc_memberlinks(); 
    363  
    364                 } 
    365                 break; 
    366  
    367             case "pwdchange": 
    368  
    369                 $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
    370                 break; 
    371  
    372             case "renew": 
    373                 $content = wpmem_renew(); 
    374                 break; 
    375  
    376             default: 
    377                 $content = wpmem_inc_memberlinks(); 
    378                 break; 
    379             } 
    380  
    381         } elseif ( is_user_logged_in() && $page == 'register' ) { 
    382  
    383             $content = $content . wpmem_inc_memberlinks( 'register' ); 
    384  
    385         } 
    386  
    387     } 
    388  
    389     if ( $page == 'login' ) { 
    390         $content = ( $wpmem->regchk == "loginfailed" ) ? wpmem_inc_loginfailed() : $content; 
    391         $content = ( ! is_user_logged_in() ) ? $content . wpmem_inc_login( 'login', $redirect_to ) : wpmem_inc_memberlinks( 'login' ); 
    392     } 
    393  
    394     if ( $page == 'password' ) { 
    395         $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
    396     } 
    397  
    398     if ( $page == 'user-edit' ) { 
    399         $content = wpmem_page_user_edit( $wpmem->regchk, $content ); 
    400     } 
    401  
    402     return $content; 
    403 } // End wpmem_do_sc_pages. 
    404 endif; 
    405246 
    406247/** 
     
    453294 * @since 3.1.2 Added function arguments. 
    454295 * 
    455  * @param  array  $atts { 
    456  *     The shortcode attributes. 
    457  * 
    458  *     @type string $page 
     296 * @global object $wpmem        The WP_Members object. 
     297 * @global string $wpmem_themsg The WP-Members message container. 
     298 * 
     299 * @param  string $atts { 
     300 *     The shortcode attributes. 
     301 * 
     302 *     @type string $redirect_to 
    459303 * } 
    460304 * @param  string $content 
     
    463307 */ 
    464308function wpmem_sc_user_profile( $atts, $content, $tag ) { 
    465     $atts['page'] = 'user-profile'; 
    466     $content = wpmem_do_sc_pages( $atts, $content, $tag ); 
     309 
     310    // @todo $redirect_to is not currently used in the user profile. 
     311    $redirect_to   = ( isset( $atts['redirect_to'] ) ) ? $atts['redirect_to'] : null; 
     312    $hide_register = ( isset( $atts['register'] ) && 'hide' == $atts['register'] ) ? true : false; 
     313 
     314    global $wpmem, $wpmem_themsg; 
     315 
     316    $content = ''; 
     317 
     318    if ( $wpmem->regchk == "captcha" ) { 
     319        global $wpmem_captcha_err; 
     320        $wpmem_themsg = __( 'There was an error with the CAPTCHA form.' ) . '<br /><br />' . $wpmem_captcha_err; 
     321    } 
     322 
     323    if ( $wpmem->regchk == "loginfailed" ) { 
     324        return wpmem_inc_loginfailed(); 
     325    } 
     326 
     327    if ( is_user_logged_in() ) { 
     328 
     329        /** 
     330         * Filter the default heading in User Profile edit mode. 
     331         * 
     332         * @since 2.7.5 
     333         * 
     334         * @param string The default edit mode heading. 
     335         */ 
     336        $heading = apply_filters( 'wpmem_user_edit_heading', __( 'Edit Your Information', 'wp-members' ) ); 
     337 
     338        switch( $wpmem->action ) { 
     339 
     340        case "edit": 
     341            $content = $content . wpmem_inc_registration( 'edit', $heading ); 
     342            break; 
     343 
     344        case "update": 
     345            // Determine if there are any errors/empty fields. 
     346            if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) { 
     347                $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
     348                $content = $content . wpmem_inc_registration( 'edit', $heading ); 
     349            } else { 
     350                //Case "editsuccess". 
     351                $content = $content . wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
     352                $content = $content . wpmem_inc_memberlinks(); 
     353            } 
     354            break; 
     355 
     356        case "pwdchange": 
     357 
     358            $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
     359            break; 
     360 
     361        case "renew": 
     362            $content = wpmem_renew(); 
     363            break; 
     364 
     365        default: 
     366            $content = wpmem_inc_memberlinks(); 
     367            break; 
     368        } 
     369 
     370    } else { 
     371         
     372        if ( $wpmem->action == 'register' && ! $hide_register ) { 
     373 
     374            switch( $wpmem->regchk ) { 
     375 
     376            case "success": 
     377                $content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
     378                $content = $content . wpmem_inc_login(); 
     379                break; 
     380 
     381            default: 
     382                $content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ); 
     383                $content = $content . wpmem_inc_registration(); 
     384                break; 
     385            } 
     386 
     387        } elseif ( $wpmem->action == 'pwdreset' ) { 
     388 
     389            $content = wpmem_page_pwd_reset( $wpmem->regchk, $content ); 
     390 
     391        } elseif( $wpmem->action == 'getusername' ) { 
     392 
     393            $content = wpmem_page_forgot_username( $wpmem->regchk, $content ); 
     394 
     395        } else { 
     396 
     397            $content = $content . wpmem_inc_login( 'members' ); 
     398            $content = ( ! $hide_register ) ? $content . wpmem_inc_registration() : $content; 
     399        } 
     400    } 
     401 
    467402    return $content; 
    468403} 
     
    544479        global $wpmem; 
    545480        $fields = wpmem_fields(); 
    546         $field_type = ( isset( $fields[ $field ]['type'] ) ) ? $fields[ $field ]['type'] : 'native'; 
     481        $field_type = ( isset( $fields[ $field ]['type'] ) ) ? $fields[ $field ]['type'] : 'native'; // @todo Is this needed? It seems to set the type to "native" if not set. 
    547482 
    548483        $result = $user_info->{$field}; 
     
    587522            return do_shortcode( $result ); 
    588523        } 
     524         
     525        // Handle line breaks for textarea fields 
     526        if ( isset( $field_type ) && 'textarea' == $field_type ) { 
     527            $result = nl2br( $user_info->{$field} ); 
     528        } 
    589529 
    590530        // Remove underscores from value if requested (default: on). 
     
    595535        $content = ( $content ) ? $result . $content : $result; 
    596536 
    597         return do_shortcode( htmlspecialchars( $content ) ); 
     537        return do_shortcode( $content ); 
    598538    } 
    599539    return; 
  • wp-members/trunk/inc/users.php

    r1628757 r1667369  
    2727function wpmem_user_profile() { 
    2828 
    29     global $wpmem, $user_id; 
     29    global $wpmem, $user_id, $current_screen; 
    3030    /** 
    3131     * Filter the heading for the user profile additional fields. 
     
    7070                    $empty_file = '<span class="description">' . __( 'None' ) . '</span>'; 
    7171                    if ( 'file' == $field['type'] ) { 
    72                         $input = ( 0 < $attachment_url ) ? '<a href="' . $attachment_url . '">' . $attachment_url . '</a>' : $empty_file; 
     72                        $input = ( $attachment_url ) ? '<a href="' . $attachment_url . '">' . $attachment_url . '</a>' : $empty_file; 
    7373                    } else { 
    74                         $input = ( 0 < $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file; 
     74                        $input = ( $attachment_url ) ? '<img src="' . $attachment_url . '">' : $empty_file; 
    7575                    } 
    76                     // @todo - come up with a way to handle file updates - user profile form does not support multitype 
    77                     //$show_field.= '<br /><span class="description">' . __( 'Update this file:' ) . '</span><br />'; 
    78                     //$show_field.= wpmem_create_formfield( $meta . '_update_file', $field['type'], $val, $valtochk ); 
     76                    $input.= '<br />' . $wpmem->get_text( 'profile_upload' ) . '<br />'; 
     77                    $input.= wpmem_form_field( array( 
     78                        'name'    => $meta,  
     79                        'type'    => $field['type'],  
     80                        'value'   => $val,  
     81                        'compare' => $valtochk, 
     82                    ) ); 
    7983                } else { 
    8084                    if ( $meta == 'tos' && $val == 'agree' ) { 
     
    203207        } 
    204208    } 
     209     
     210    if ( ! empty( $_FILES ) ) { 
     211        $wpmem->user->upload_user_files( $user_id, $wpmem_fields ); 
     212    }    
    205213} 
    206214 
     215/** 
     216 * Sets user profile update to multipart form data. 
     217 * 
     218 * If the fields array has a file or image field, this will echo the  
     219 * necessary "multipart/form-data" enctype for the form tag. 
     220 * 
     221 * @since 3.1.8 
     222 */ 
     223function wpmem_user_profile_multipart() { 
     224    global $wpmem; 
     225    $has_file = false; 
     226    foreach ( wpmem_fields() as $field ) { 
     227        if ( $field['type'] == 'file' || $field['type'] == 'image' ) { 
     228            $has_file = true; 
     229            break; 
     230        } 
     231    } 
     232    echo ( $has_file ) ? " enctype=\"multipart/form-data\"" : ''; 
     233} 
     234 
    207235// End of file. 
  • wp-members/trunk/inc/wp-registration.php

    r1628757 r1667369  
    2828 * @since 3.1.1 Updated to support new (3.1.0) field types. 
    2929 * @since 3.1.6 Updated to support new fields array. Added WC classes. 
     30 * @since 3.1.8 Added $process parameter. 
    3031 */ 
    31 function wpmem_do_wp_register_form() { 
     32function wpmem_do_wp_register_form( $process = 'wp' ) { 
    3233 
    3334    global $wpmem; 
    34     $wpmem_fields = wpmem_fields( 'wp' ); 
     35    $wpmem_fields = wpmem_fields( $process ); 
    3536     
    3637    // Check if this is WooCommerce account page. 
    3738    $is_woo = false; 
    38     if ( function_exists( 'is_account_page' ) ) { 
    39         $is_woo = ( is_account_page() ) ? true : $is_woo; 
     39    if ( 'woo' == $process ) { 
     40        $is_woo = true; 
     41    } else { 
     42        if ( function_exists( 'is_account_page' ) ) { 
     43            $is_woo = ( is_account_page() ) ? true : $is_woo; 
     44        } 
    4045    } 
    4146     
     
    4348        foreach ( $wpmem_fields as $meta_key => $field ) { 
    4449 
    45             $req = ( $field['required'] ) ? ' <span class="req">' . __( '(required)' ) . '</span>' : ''; 
     50            $req = ( $field['required'] ) ? ( ( $is_woo ) ? ' <span class="required">*</span>' : ' <span class="req">' . __( '(required)' ) . '</span>' ) : ''; 
    4651 
    4752            // File fields not yet supported for this form. 
  • wp-members/trunk/readme.txt

    r1628757 r1667369  
    33Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber 
    44Requires at least: 3.6 
    5 Tested up to: 4.7.3 
    6 Stable tag: 3.1.7 
     5Tested up to: 4.7 
     6Stable tag: 3.1.8 
    77License: GPLv2 
    88 
     
    113113== Upgrade Notice == 
    114114 
    115 WP-Members 3.1.7 is a major update. There are no database changes (rollback is possible). See changelog for important details. Minimum WP version is 3.6. 
     115WP-Members 3.1.8 is a major update. There are no database changes (rollback is possible). See changelog for important details. Minimum WP version is 3.6. 
    116116 
    117117== Screenshots == 
     
    135135 
    136136== Changelog == 
     137 
     138= 3.1.8 = 
     139 
     140* Added new native registration handling to accommodate WooCommerce 3.0. 
     141* Added support for user file upload on admin/dashboard profile. 
     142* Added meta_key/meta_value attribute to [wpmem_logged_in] shortcode. 
     143* Added wpmem_user_has_meta() API function. 
     144* Updated post editor shortcode button javascript to include new(er) shortcodes. 
     145* Fixed WP-Members user profile shortcode to only display logged in content (by shortcode) if the wpmem_a 'action' is not set (i.e. logged in content only displays if page is in "member links" state). 
     146* Fixed register link in login form to prevent link from displaying if login form is displayed along with the registration form (standard configuration). 
     147* Improved multisite support, including revisions to load all admin dependencies for administrator role, not just super admin. Dependency load role requirement is filterable. 
     148* Improved line break stripping process in form builder to allow for line breaks in textarea fields. 
     149* Improved field shortcode for textarea fields to display line breaks. 
     150* Deprecated old wpmem_do_sc_pages() function, updated wpmem_sc_user_profile(). 
     151* Removed $_SERVER['REQUEST_URI'] from all admin tab form action attributes. Replaced with new wpmem_admin_form_post_url() API function. 
     152* Fields Tab: ground-up rebuild to utilize WP_List_Table and jquery sorting UI. 
     153* Fields Tab: improved field add/edit screen: return link at bottom of page, display current field upon successful form submission, success message include return link. 
     154* Fields Tab: added support for HTML5 field types: number, date. 
     155* Fields Tab: added support for HTML5 field attributes: placeholder, pattern (regex), title, min, max. 
    137156 
    138157= 3.1.7 = 
     
    165184* Fixed load fields error checking, install function now correctly returns defaults. 
    166185* Changed password reset and password change to use wp_set_password() for improved performance with caching. 
    167  
    168 = 3.1.6 = 
    169  
    170 * Fixed [wpmem_field] display handling for multiple select and multiple checkbox field types. 
    171 * Updates to always load fields from wpmem_fields() API function. 
    172 * Updates to begin to utilize new fields settings array.  Fields setting is still store in the same array format as before.  However, it is loaded into the new settings format.  Current object class keeps numeric keys in place for legacy purposes. 
    173 * Updates to dropdown handling on main options tab to display proper preselected value when site is using ssl (https://) and no value is selected. 
    174 * Added wpmem_loginout() API function, changed [wpmem_loginout] shortcode to use API function. 
    175 * Added wpmem_array_insert() API function, allows for inserting array elements at any point in an array. 
    176 * Added wp_destroy_current_session() to logout function. 
    177 * Added WooCommerce support in native WP registration functions. Began adding WooCommerce classes to registration form elements. 
    178 * Added to wpmem_user_has_role() function to check for a single role or if the user has a role that is in an array of roles. 
    179 * Added wpmem_shortcodes_loaded, wpmem_hooks_loaded, and wpmem_dropins_loaded to fire after. 
    180 * Added text input to set a default 'read more' link for auto excerpt. 
    181 * Fixed issue with auto excerpt where an excerpt shorter than the excerpt setting would not display the more link. 
    182 * Preliminary updates to include placeholder support in fields (this will be an option in a future release). 
    183 * Localization fix of untranslated strings. 
    184 * Wrap "Remember Me" checkbox label with label tag in login form. 
    185 * Moved remaining initialization functions to class constructor. 
    186 * Moved wpmem_load_shortcodes, wpmem_load_hooks, and wpmem_load_dropins to fire before. 
    187 * reCAPTCHA version 1 is no longer supported by Google. It is now deprecated in the plugin. If you have reCAPTCHA v1 selected, it will remain so. But once this is changed to a different CAPTCHA setting or if this is a new install, reCAPTCHA version 1 will no longer be available as a selection. 
    188 * Custom field term "Option Name" changed to "Meta Key" for clarity. 
    189 * Marked required custom field properties as required in Add/Edit Field dialogs. 
    190 * Changed redirect_to process to escape the url with esc_url_raw rather than esc_url, otherwise query string variables do not get handled correctly. 
    191 * Fixes issue with displaying checkbox state on the admin user profile screen. 
    192 * Fixes issue with auto excerpt when excerpts are displayed on single posts/pages. 
    193 * Applies style properties for the remember me checkbox label to the default stylesheets. The label tag was added to this text in 3.1.6 (see below). 
    194 * Applies some admin strings for translation. 
    195  
    196 = 3.1.5 = 
    197  
    198 * Addressed some security issues to prevent XSS vulnerabilities. 
    199 * Updated [wpmem_show_count] shortcode to include count of total blog users and users by role.  See: http://rkt.bz/xC 
    200 * Updated [wpmem_field] shortcode to accept [wpmem_field meta_key] instead of [wpmem_field field="meta_key"] (although the latter will still work).  See http://rkt.bz/ae 
    201 * Updated [wpmem_loginout] shortcode with some improvements to function code and link text attributes.  See: http://rkt.bz/29 
    202 * Updated auto excerpt for improved functionality, uses wp_trim_words(), deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes for filter (these were never documented so it is unlikely that anyone uses them). 
    203 * Updated hidden field type, now allows adding hidden fields to the registration form. 
    204 * Compartmentalized installation of initial settings. 
    205 * Field loader now validates settings, if none exist due to install error it will run the default fields install. 
    206 * Removed dialog setting downgrade on deactivation. Need to re-evaluate necessity of downgrading. 
    207 * Fixed issue with slash handling in Emails tab. 
    208 * Updated [wp-members] deprecated shortcode notice to include post/page information on where the shortcode is being used. 
    209  
    210 = 3.1.4 = 
    211  
    212 * Change to the way the PayPal extension is integrated with the main plugin. This allows for some necessary filename changes in the extension. 
    213 * Added checks for PayPal extension function calls within the main plugin to avoid possible errors if it is deactivated. 
    214 * New wpmem_is_tab() API function checks the current tab in the plugin's admin panel. 
    215 * New wpmem_is_reg_page() API function checks if the page the user registered on is the registration page. 
    216 * New wpmem_load_dropins() API function runs dropin load function. 
    217 * Documentation updates, cleaned up and addressed several @todo tags. 
    218 * Updated [wpmem_field] shortcode to display display values instead of stored values for select (dropdown), multiple select, multiple checkbox, and radio group field types. 
    219 * Fixed bug in admin js file introduced when forgot username shortcode was added. 
    220 * Updates to reCAPTCHA2. Trims keys on save to avoid possible copy/paste whitespace issues, displays API error code(s) if WP_DEBUG is turned on, change use of file_get_contents() to wp_remote_fopen() for broader acceptable use. 
    221  
    222 = 3.1.3 = 
    223  
    224 * Fixed issue with display of [wp-members] field tag. Note: although this tag should remain operable, the tag is officially obsolete since 2.9.8 and should be used as [wpmem_field]. 
    225 * Fixed issue with calling PayPal extension functions if settings are enabled but the extension is disabled. 
    226 * Updated some admin-side strings for translation. 
    227 * Updated wpmem_redirect_to_login() to __not__ check for wpmem_is_blocked(). Handling that outside the function will expand its usability. 
    228 * Updated row_after logic in login form function so that it can be used for adding tags at the end of a row w/o adding a tag at the beginning. 
    229 * Updated widget to check for wpmem_do_sidebar() instead of obsolete wpmem() function. 
    230 * Updated email shortcodes used in new install. 
    231 * Added new utility function wpmem_get() for checking posted variables and query strings with isset() and setting a default value. 
    232 * Added a nonce to register redirect by shortcode parameter. This will lead to being able to display a success message on the redirected page. 
    233 * Added redirect_to argument in wpmem_redirect_to_login(). 
    234 * Added generic registration error message. 
    235 * Added [wpmem_form forgot_username] shortcode for displaying the forgot username form. 
    236  
    237 = 3.1.2 = 
    238  
    239 * Minimum WordPress version increased to 3.6. 
    240 * Added user counts to user screen links (set as transient). 
    241 * Added redirect_to parameter to wpmem_login_url(). 
    242 * Added action parameter to wpmem_profile_url(). 
    243 * Added echo argument to wpmem_gettext(). 
    244 * Added api function wpmem_user_pages() to return an array of the login, register, and profile page urls. 
    245 * Added shortcode [wpmem_tos] for Terms of Service page url (replaces [wp-members page=tos url=http://mysite.com/path/to/tos/]). 
    246 * Added wpmem_write_log() function for writing notices to the WP error log. 
    247 * Added hide registration form parameter to wpmem_profile shortcode: [wpmem_profile register=hide]. 
    248 * Added $defaults to wpmem_sidebar_status_args. Now can pass $user_login to be used in filters. 
    249 * Moved wpmem_login_status() to api.php. 
    250 * Deprecated [wp-members] shortcode, all other shortcodes no longer rely on wpmem_shortcode(). 
    251 * Fixed issue with pre-selected dropdown values to not select empty (separator) rows. 
    252 * Fixed field and custom shortcodes in email not being parsed. 
    253  
    254 = 3.1.1 = 
    255  
    256 * Added downgrade function (currently runs on deactivation) to allow for version rollbacks. 
    257 * Added new dialogs functions to admin api, allows for custom dialogs to be added. 
    258 * Added $user_id and $row to wpmem_admin_profile_field and wpmem_user_profile_field filters. 
    259 * Added new api class and api functions. 
    260 * Added [wpmem_loginout] shortcode. 
    261 * Added support for new field types to native registration and users > add new (except file/image fields). 
    262 * Updated users > add new so that user can be activated when added. 
    263 * Updated [wpmem_logged_in] shortcode so that content is not shown on on a user profile page action. 
    264 * Updated email settings to only save new from/name if changed. 
    265 * Updated admin warning messges. 
    266 * Updated multiselect and multicheckbox fields to allow user selected delimiter (defaults to pipe "|"). 
    267 * Fixes issue with profile update when file/image field is required. 
    268 * Fixes image field edit in fields tab to include file type. 
    269 * Fixes attribution setting for 3.0 settings array. 
    270 * Fixes for PHP7. 
    271  
    272 = 3.1.0 = 
    273  
    274 This package contains several fixes, some new filters, new field types and other functional improvements. 
    275  
    276 * Some general code cleanup, reviewing inline documentation and comments. 
    277 * Fixed issue for sidebar with redirect_to parameter set in widget settings. 
    278 * Fixed issue for custom error messages and email comparison error for profile update (so that errors show in form update state and not on links page). 
    279 * Fixed main options tab where checkbox may not display correct setting if unchecked. 
    280 * Fixed translation issue for required field error where all of the message except the field name was translated. 
    281 * Fixed issue for register shortcode page where if a user has registered, and is logging in but the login fails, display the login error message. 
    282 * Fixed register shortcode redirect parameter. 
    283 * Fixed confirm_password to bypass sanitize_text_field (which breaks password comparison if certain characters are used). 
    284 * Added logic so that user_pages are not blocked (login, register, user_profile). 
    285 * Added after_wrapper array value for wpmem_{$page}_links_args filters 
    286 * Added a new admin api class, utilities object class, and forms object class. 
    287 * Added user facing strings as an array in the main $wpmem object class. 
    288 * Added wpmem_default_text_strings filter for user facing text strings. 
    289 * Added new wpmem_sidebar_status_args filter hook. 
    290 * Added new container in main object for email from and from name settings. 
    291 * Added file upload functions. 
    292 * Added new field types: multiple checkbox, multiple select, radio, file, image, email, url. 
    293 * Added "values" key to the register form rows array to hold possible values (i.e. select, multiple select, multiple checkbox, and radio group) and the actual value to be in the "value" key. 
    294 * Added the ability for dropdown/select fields to have a default value other than the first value. 
    295 * Added filter wpmem_user_upload_dir for filtering the location of user uploaded files. 
    296 * Added wpmem_register_form_rows_admin and wpmem_register_form_rows_profile filter hooks. 
    297 * Deprecated use of wpmem_chk_qstr() function, use add_query_arg() instead. 
    298 * Deprecated use of get_currentuserinfo() (deprecated in WP 4.5), use wp_get_current_user() instead. 
    299 * Email function updates, added 'footer' as an array value in the main wpmem_email_filter filter. 
    300 * Changed install to set email/confirm_email and user_url as HTML5 field types "email" and "url" (now supported). 
    301 * Changed get_action call from init action to template_redirect action. 
    302 * Changed username in register form from log to user_login to match wp native registration form. 
    303 * Changed [wp-members page="user-profile"] shortcode to [wpmem_profile] (old shortcode will still work). 
    304 * Removed redirect parameter from register shortcode in shortcode menu. 
    305 * Removed kubrick stylesheet from selector (still packaged with download, shows as custom url if used). 
    306 * Changed all _update_ functions in install package to _upgrade_. 
    307 * Fixes an issue with PayPal extension where users may be set to pending if moderated registration is enabled after the user already has an expiration date. 
    308 * Update wpmem_do_sidebar to use use add_query_arg() if on a search query. 
    309  
    310 = 3.0.9 = 
    311  
    312 * Added Custom Post Type support. 
    313 * Added wpmem_member_links_args and wpmem_register_links_args filters. 
    314 * Added $link parameter to wpmem_forgot_link_str and wpmem_reg_link_str filters (gives just the link as an available parameter). 
    315 * Added new wpmem_sb_reg_link_str and wpmem_sb_forgot_link_str filters (same format as above). 
    316 * Added [email] and [user-profile] shortcodes to the new user registration email. 
    317 * Added label_text key to wpmem_register_form_rows filter. 
    318 * Added new auto excerpt settings, can now be set by post type. 
    319 * Added new auto excerpt features including new wpmem_auto_excerpt_args filter. 
    320 * Added forgot username retrieveal link (included on forgot password reset form). 
    321 * Added wpmem_username_link and wpmem_username_link_str for filtering forgot username retrieval link. 
    322 * Added new upgrade process to WP_Members object class. 
    323 * Fixed handling of post bulk actions to keep current screen (if one is used). 
    324 * Fixed handling of updates to the user pages in the options tab. 
    325 * Fixed handling of empty post object in is_blocked() function. 
    326 * Improved email functions to eliminate get_user_meta() calls when not needed. 
    327  
    328 = 3.0.8 = 
    329  
    330 * Added process for forgotten username retrieval. 
    331 * Removed last remaining instances of extract function. 
    332 * Updated settings for special pages (login|register|user-profile) to store only the numeric primary key ID. This will eliminate the need to update these settings if the site is moved (from a dev to live site, for example).  Legacy full URL settings will still be compatible without needing to be updated, but will be automatically updated when main options are saved. 
    333  
    334 = 3.0.7 = 
    335  
    336 * Fix for use of display_name on profile update. 
    337 * Fix for newer installs (post WP 4.0) where WPLANG is not defined and reCAPTCHA is used. 
    338 * Fix in wpmem_form shortcode to skp if no additional tag exists. 
    339 * Fix to plugin_basename. 
    340 * Changes in core to use fields from WP_Members class (preparing for new form field process). 
    341 * Reviews and updates to code standards and inline documentation. 
    342 * Fix for password reset (typo in object name checking for moderated registration) 
    343 * Fix for PayPal extension (http://rkt.bz/r3); added logic to avoid errors if the PayPal extension is disabled but the main option setting remained turned on. 
    344  
    345 = 3.0.6 = 
    346  
    347 * Updates to localization function - documented plugin_locale filter, wpmem_localization_file filter, and improved load_textdomain logic. 
    348 * Added /lang domain path to plugin header. 
    349 * Fixed a bug in the user export function that broke CSV columns when moderated registration was turned on. 
    350 * Improved current page retrieval in wpmem_redirect_to_login() function. 
    351 * Fixed admin enqueued scripts (post/page screen hook did not load from new location). 
    352  
    353 = 3.0.5 = 
    354  
    355 * Updated wpmem_pwd_change and wpmem_pwd_reset action hooks to include password as a parameter. 
    356 * Stylesheet updates for 2015, 2014, and generic (both float and no float). 
    357 * Fix to TinyMCE shortcode button, should now load button on new post/page editor. 
    358 * Added [WP-Members] to the TinyMCE shortcode button for clarity as to what it is. 
    359 * Moved admin js and css files to /admin/js/ and /admin/css/ 
    360 * Moved admin class files to /admin/includes/ 
    361 * Updated and verified all directories contain an index.php file to prevent directory browsing. 
    362  
    363 = 3.0.4 = 
    364  
    365 * Reintroduced the global action variable $wpmem_a for backward compatibility with certain add-ons, most notably the WP-Members MailChimp extension ( see http://rkt.bz/3b ). Users of this extension should upgrade.  This variable had been replaced with the new WP-Members object class introduced in 3.0. However, users of older extensions and those that may have customziations with logic may be using this variable, so rather than force updating and upgrading, it is being added back in. 
    366 * Change to the priority of functions hooked to the the_content filter. Lowering the priority should better integrate the plugin with various builder plugins and other processes that currently filter the_content after WP-Members since the content will now be filtered later in the process. This also should improve situations where in the past the on-the-fly texturization shortcode for the WP-Members forms might remain unparsed. 
    367  
    368 = 3.0.3 = 
    369  
    370 * Bug fix recaptcha v2 decode json response on validation. 
    371 * Bug fix typo in $wpmem object name in admin/user-profile.php. 
    372 * Bug fix message string variable in wpmem_msg_dialog_arr filter. 
    373 * Fix register form shortcode redirect_to parameter. 
    374 * Admin forms now use submit_button() function to generate submit button. 
    375 * Changed localization to load on init action which will allow for more flexibility with filtering custom language files. 
    376 * Added wpmem_localization_file and wpmem_localization_dir filters. 
    377 * Localization checks for file in /wp-content/ language directory first, then loads plugin default. 
    378  
    379 = 3.0.2 = 
    380  
    381 * Added reCAPTCHA version 2 as an option. v1 will remain available for now, to be fully deprecated later. 
    382 * Fixed widget to use __construct for WP 4.3 compatibility. 
    383 * Added error checking for WP reserved names when adding new custom fields. 
    384 * Added wpmem_wp_reserved_terms filter for overriding reserved terms list. 
    385 * Added trim whitespace to password reset and password change form validation. 
    386  
    387 = 3.0.1 = 
    388  
    389 * Fixed use of wp_signon() for ssl. 
    390 * Fixed [wpmem_msurl] email shortcode. 
    391 * Fixed admin js and css load (removed unnecessary slash). 
    392 * Fixed autoexcerpt to use setting from object and not wpmemembers_autoex option. 
    393 * Added filter to remove comments array if content is blocked. 
    394  
    395 = 3.0.0 = 
    396  
    397 This release makes significant changes to the plugin's main options in the way they are stored. While care has been taken to make sure that you can roll back to a previous version, you may need to resave settings in the plugin's main options tab when attempting to roll back. It is advised that you test this update prior upgrading an existing install on a production site. 
    398  
    399 If you have any custom functions hooked to filters and actions that call any file includes directly from the plugin, please note that several file names have changed. 
    400  
    401 * New settings and new plugin class WP_Members. 
    402 * New settings now natively support Custom Post Types, both setting defaults and individual post blocking. 
    403 * Settings constants removed in favor of using the $wpmem object class. 
    404 * Added new|edit toggle to wpmem-register_data filter hook. 
    405 * wpmem_settings_loaded action added. 
    406 * Securify comments changed to use comments_open instead of comments_template (with a blank template). 
    407 * New wpmem_securify_comments filter hook to customize whether comments load or not. 
    408 * Registration clear form button defaults to false. 
    409 * Removed wp_set_auth_cookie from login function; it is already done as part of wp_signon. 
    410 * Post meta box title filter is now for all post types wpmem_admin_{post type}_meta_title. 
    411 * New filter for Really Simple Captcha folder location: wpmem_rs_captcha_folder. 
    412 * New shortcodes [wpmem_form] added. 
    413 * Shortcode dropdown selector added to tinymce toolbar in Post/Page editor. 
    414 * Added redirect_to as a function argument if calling wpmem_logout() directly. 
  • wp-members/trunk/wp-members.php

    r1628757 r1667369  
    44Plugin URI:  http://rocketgeek.com 
    55Description: WP access restriction and user registration.  For more information on plugin features, refer to <a href="http://rocketgeek.com/plugins/wp-members/users-guide/">the online Users Guide</a>. A <a href="http://rocketgeek.com/plugins/wp-members/quick-start-guide/">Quick Start Guide</a> is also available. WP-Members(tm) is a trademark of butlerblog.com. 
    6 Version:     3.1.7 
     6Version:     3.1.8 
    77Author:      Chad Butler 
    88Author URI:  http://butlerblog.com/ 
     
    6363 
    6464// Initialize constants. 
    65 define( 'WPMEM_VERSION', '3.1.7' ); 
     65define( 'WPMEM_VERSION', '3.1.8' ); 
    6666define( 'WPMEM_DEBUG', false ); 
    6767define( 'WPMEM_DIR',  plugin_dir_url ( __FILE__ ) ); 
Note: See TracChangeset for help on using the changeset viewer.