Plugin Directory

Changeset 1027019


Ignore:
Timestamp:
11/17/2014 04:39:33 AM (11 years ago)
Author:
doytch
Message:

1.1: Added support for features with text values

Location:
easy-feature-lists
Files:
6 added
2 deleted
16 edited
9 copied

Legend:

Unmodified
Added
Removed
  • easy-feature-lists/tags/1.1/README.txt

    r1024826 r1027019  
    11=== Plugin Name ===
    22Contributors: doytch
    3 Donate link: http://qedev.com/
     3Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mark%2edeutsch%40utoronto%2eca&lc=US&item_name=Coffee%20Donation%20%3d%29&amount=10%2e00&currency_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted
    44Tags: feature list, features, check list, list, shortcode, table
    55Requires at least: 3.9
    66Tested up to: 4.0
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    21211. In your post, insert the [efl_feature_list] shortcode where you want the list.
    22221. Select the feature list you want from the metabox below the post editor.
    23 1. Check the items that you want checked in the feature list. This lets you create one list and have reuse it across
    24 multiple posts, only changing what is checked.
     231. Set the value for each feature. This lets you create one list and reuse it across
     24multiple posts, changing only the text or checkbox for each feature.
    2525
    2626Other features are planned for the future, so let me know of any requests via the Support forum. I provide paid support
     
    4444to worry about this, contact me at admin@qedev.com and we can discuss any jobs you need done.
    4545
     46= How do I remove a feature group? =
     47
     48On the Edit Feature List page, simply remove all the features from the feature group you wish to delete.
     49
    4650== Screenshots ==
    4751
    48 1. Feature lists are created using simple markup. In this example, three feature groups are being created with various
     521. Feature lists are created using simple tables. In this example, two feature groups are being created with various
    4953features in each group.
    50 2. Lists are selected and customised using the metabox below the editor, and inserted into posts and pages using a shortcode.
     542. Lists are selected and customised using the metabox below the post editor, and inserted into posts and pages using a shortcode.
    51553. The feature list displayed under the WordPress Twenty Twelve theme. Styling is controlled via your theme.
    5256
    5357== Changelog ==
    5458
     59= 1.1 =
     60* Features can now have their values be text as well as check boxes. The text is set on the Post page just like checkboxes.
     61* Feature lists previously defined will no longer work. I apologise for the inconvenience but these and future improvements
     62required moving to a more flexible, incompatible underlying architecture. I thought it was best to do this now rather than
     63down the line.
     64* 78% more love was added to the plugin.
     65
    5566= 1.0 =
    5667* Initial release
  • easy-feature-lists/tags/1.1/admin/EFLAdmin.php

    r1024824 r1027019  
    6161     */
    6262    public function enqueue_scripts($hook) {
    63         if ($hook == 'post.php' || $hook == 'post-new.php') {
    64             wp_enqueue_script( $this->name, plugin_dir_url( __FILE__ ) . 'js/admin.js', array( 'jquery' ), null, false );
    65             $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
    66             wp_localize_script($this->name, 'EFL_AJAX_URL', admin_url('admin-ajax.php', $protocol));
    67         }
    6863    }
    6964
  • easy-feature-lists/tags/1.1/admin/css/table.css

    r1024824 r1027019  
    77}
    88
    9 .efl-cell-wide-1 { width: 100%; }
    10 .efl-cell-wide-2 { width: 50%; }
    11 .efl-cell-wide-3 { width: 33.33%; }
    12 .efl-cell-wide-4 { width: 25%; }
    13 .efl-cell-wide-5 { width: 20%; }
    14 .efl-cell-wide-6 { width: 16.66%; }
    15 .efl-cell-wide-7 { width: 14.28%; }
    16 .efl-cell-wide-8 { width: 12.5%; }
    17 .efl-cell-wide-9 { width: 11.1%; }
     9.efl-cell-wide-1 { width: 50%; }
     10.efl-cell-wide-2 { width: 25%; }
     11.efl-cell-wide-3 { width: 16.66%; }
     12.efl-cell-wide-4 { width: 12.5%; }
     13.efl-cell-wide-5 { width: 10%; }
     14.efl-cell-wide-6 { width: 8.444%; }
     15.efl-cell-wide-7 { width: 7.14%; }
     16.efl-cell-wide-8 { width: 6.25%; }
     17.efl-cell-wide-9 { width: 5.55%; }
  • easy-feature-lists/tags/1.1/admin/includes/EFLFeatureListMetabox.php

    r1024824 r1027019  
    6262    public function create_metabox($post) {
    6363        wp_nonce_field('efl_fl_mb', 'efl_fl_mb_nonce');
    64         include_once(plugin_dir_path( dirname(dirname( __FILE__ )) ) . 'admin/partials/feature-list-metabox.php');
     64        include_once(plugin_dir_path( dirname( __FILE__ ) ) . '/partials/feature-list-metabox.php');
     65       
     66        wp_enqueue_style(  'feature-list-metabox', plugin_dir_url( dirname(__FILE__) ) . 'css/feature-list-metabox.css');
     67
     68        wp_enqueue_script( 'feature-list-metabox', plugin_dir_url( dirname(__FILE__) ) . 'js/feature-list-metabox.js', array( 'jquery' ), null, false );
     69        wp_localize_script('feature-list-metabox', 'EFL_LIST_JSON', get_post_meta($post->ID, 'efl-list-features', true));       
    6570    }
    6671
     
    8186        }
    8287
    83         if (isset($_POST['efl-list-markup'])) {
    84             update_post_meta($post_id, 'efl-list-markup', wp_strip_all_tags($_POST['efl-list-markup']));
    85         }
     88
    8689        if (isset($_POST['efl-list-cols'])) {
    8790            update_post_meta($post_id, 'efl-list-cols', intval($_POST['efl-list-cols']));
    8891        }
     92
     93        if (isset($_POST['efl-group-name']) && isset($_POST['efl-feature-name']) && isset($_POST['efl-feature-type'])) {
     94            $groups = array();
     95            foreach ($_POST['efl-group-name'] as $group_id => $group_name) {
     96                if (! isset($_POST['efl-feature-name'][$group_id])) {
     97                    continue;
     98                }
     99
     100                $group = array(
     101                    'name'      => wp_strip_all_tags($group_name),
     102                    'features'  => array()
     103                );
     104
     105                foreach ($_POST['efl-feature-name'][$group_id] as $feature_id => $feature_name) {
     106                    $feature = array(
     107                        'name'  => $_POST['efl-feature-name'][$group_id][$feature_id],
     108                        'type'  => $_POST['efl-feature-type'][$group_id][$feature_id]
     109                    );
     110
     111                    $group['features'][] = $feature;
     112                }
     113
     114                $groups[] = $group;
     115            }
     116            update_post_meta($post_id, 'efl-list-features', json_encode($groups));
     117        }
    89118    }
    90119}
  • easy-feature-lists/tags/1.1/admin/includes/EFLPostMetabox.php

    r1024824 r1027019  
    6969        $list = intval($_POST['feature_list_id']);
    7070        $ret = array(
    71             'markup' => get_post_meta($list, 'efl-list-markup', true),
    72             'checklist' => get_post_meta($post, 'efl-list-checklist', true)
     71            'features' => get_post_meta($list, 'efl-list-features', true),
     72            'values' => get_post_meta($post, 'efl-list-values', true)
    7373        );
    7474        echo json_encode($ret);
     
    8282    public function create_metabox($post) {
    8383        wp_nonce_field('efl_post_mb', 'efl_post_mb_nonce');
    84         include_once(plugin_dir_path( dirname(dirname( __FILE__ )) ) . 'admin/partials/post-metabox.php');
     84        include_once(plugin_dir_path( dirname( __FILE__ ) ) . '/partials/post-metabox.php');
     85
     86        wp_enqueue_script( 'post-metabox', plugin_dir_url( dirname(__FILE__) ) . 'js/post-metabox.js', array( 'jquery' ), null, false );
     87        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
     88        wp_localize_script('post-metabox', 'EFL_AJAX_URL', admin_url('admin-ajax.php', $protocol));
     89
    8590    }
    8691
     
    105110        }
    106111
    107         if (isset($_POST['efl-chk'])) {
    108             $group_num = 0;
    109             $feature_num = 0;
    110             $checklist = '';
    111             foreach($_POST['efl-chk'] as $group_idx => $group) {
    112                 foreach ($group as $feature_idx => $feature) { 
    113                     $checklist .= "{$group_idx}-{$feature_idx},";
    114                     $feature_num += 1;
     112        if (isset($_POST['efl-feature'])) {
     113            $values = array();
     114            foreach($_POST['efl-feature'] as $group_idx => $group) {
     115                foreach ($group as $feature_idx => $value) {   
     116                    $values[$group_idx][$feature_idx] = wp_strip_all_tags($value);
    115117                }
    116                 $feature_num = 0;
    117                 $group_num += 1;
    118118            }
    119             update_post_meta($post_id, "efl-list-checklist", $checklist);
     119
     120            // Fill out the array for JSON encoding.
     121            for ($i = 0; $i < max(array_keys($values)); $i++) {
     122                if (! isset($values[$i])) {
     123                    // Fill the undefined group.
     124                    $values[$i] = array( array('') );
     125                } else {
     126                    for ($j = 0; $j < max(array_keys($values[$i])); $j++) {
     127                        if (! isset($values[$i][$j])) {
     128                            // Fill the undefined feature value.
     129                            $values[$i][$j] = '';
     130                        }
     131                    }
     132                }
     133            }
     134
     135            update_post_meta($post_id, "efl-list-values", json_encode($values));
    120136        }
    121137    }
  • easy-feature-lists/tags/1.1/admin/includes/EFLTableGenerator.php

    r1024824 r1027019  
    1212class EFLTableGenerator {
    1313    /**
    14      * Raw checklist info of the feature list
     14     * Values of the feature list
    1515     *
    1616     * @access   private
    1717     */
    18     private $checklist;
     18    private $values;
    1919
    2020    /**
     
    5858     */
    5959    private function create_structure($post_id, $list_id) {
    60         $markup = get_post_meta($list_id, 'efl-list-markup', true);
    61         $this->checklist = get_post_meta($post_id, 'efl-list-checklist', true);
    62         if ($markup == null || $markup == ""   || $this->checklist == null || $this->checklist == "" ) {
     60        $features = get_post_meta($list_id, 'efl-list-features', true);
     61        $values = get_post_meta($post_id, 'efl-list-values', true);
     62
     63        if ($features == null || $features == ""   || $values == null || $values == "" ) {
    6364            return false;
    6465        }
    6566
     67        $features = json_decode($features, true);
     68        $values = json_decode($values, true);
     69
    6670        // Each line is of form "Feature Group: Feature 1, Feature 2, Feature 3".
    67         $structure = array();
    68         foreach (explode("\n", $markup) as $group_id => $group_markup) {
    69             // Split each line into the group name and the features.
    70             $tmp = explode(":", $group_markup);
    71             if (count($tmp) != 2) {
    72                 return false;
     71        foreach ($features as $group_id => $group) {
     72            $group_id = intval($group_id);
     73            foreach ($features[$group_id]['features'] as $feature_id => $feature) {
     74                $feature_id = intval($feature_id);
     75                // Merge the value data into the feature list structure array.
     76                $features[$group_id]['features'][$feature_id]['value'] = $values[$group_id][$feature_id];
    7377            }
    74            
    75             $group = array();
    76             foreach (explode(",", $tmp[1]) as $feature_id => $feature_markup) {
    77                 // Construct an array for each feature and add it to the group array.
    78                 $group[] = array(
    79                     'id' => "{$group_id}-{$feature_id}",
    80                     'name' => trim($feature_markup),
    81                     'checked' => $this->feature_is_checked($group_id, $feature_id)
    82                 );
    83             }
    84             $structure[trim($tmp[0])] = $group;
    8578        }
    8679
    87         return $structure;
    88     }
    89 
    90     /**
    91      * Creates a table that contains the feature list w/ appropriate items checked.
    92      *
    93      * @var     string      $group_id           The ID of the group the feature's in.
    94      * @var     string      $feature_id         The ID of the feature itself.
    95      * @return  boolean                         True/false whether the feature is checked.
    96      */
    97     private function feature_is_checked($group_id, $feature_id) {
    98         return strpos($this->checklist, "{$group_id}-{$feature_id}") !== false;
     80        return $features;
    9981    }
    10082
     
    10890        $output = "<table class='efl-feature-list-table'>";
    10991
    110         foreach ($structure as $group_name => $features) {
     92        foreach ($structure as $group) {
    11193            $output .= "<tr>";
    112             $output .= $this->create_group_name_cell($group_name);
    113             $output .= $this->create_group_features_cell($features);
     94            $output .= $this->create_group_name_cell($group['name']);
     95            $output .= $this->create_group_features_cell($group['features']);
    11496            $output .= "</tr>";
    11597        }
     
    176158    private function create_feature_cell($feature) {
    177159        $output  = "<td class='efl-feature-cell efl-cell-wide-" . $this->max_col . "'>";
    178         $output .= "<input class='efl-feature-checkbox' disabled=true type='checkbox' ";
    179         $output .= "id='efl-chk-" . $feature['id'] . "'";
    180         $output .= $feature['checked'] ? ' checked ' : ' ';
    181         $output .= "/>";
    182         $output .= "<label for='efl-chk-" . $feature['id'] . "'>";
    183         $output .= "&nbsp;" . $feature['name'] . "</label></td>";
     160        $output .= "<label class='efl-feature-name-label'>" . $feature['name'] . "</label></td>";
     161        $output .= "<td class='efl-feature-cell efl-cell-wide-" . $this->max_col . "'>";
     162
     163        if ($feature['type'] == 'Text') {
     164            $output .= "<span class='efl-feature-text'>" . $feature['value'] . "</span>";
     165        } else if ($feature['type'] == 'Checkbox') {
     166            $output .= "<input disabled=true class='efl-feature-check' type='checkbox' " . $feature['value'] . "/>";
     167        }
     168
     169        $output .= "</td>";
    184170        return $output;
    185171    }
  • easy-feature-lists/tags/1.1/admin/partials/feature-list-metabox.php

    r1024824 r1027019  
    1010?>
    1111
    12 <table class='form-table'>
     12<table id='efl-list-table' class='form-table'>
    1313    <tr valign='top'>
    14         <th scope='row'><label><?php _e('Feature List Markup', $this->name); ?></label></th>
    15         <?php $list = get_post_meta(get_the_ID(), 'efl-list-markup', true); ?>
    16         <td><textarea id='efl-list-markup' name='efl-list-markup' cols='70' rows='10'><?php echo $list; ?></textarea></td>
    17     </tr>
    18     <tr valign='top'>
    19         <th scope='row'><label><?php _e('Features Per Row', $this->name); ?></label></th>
     14        <th scope='row'>
     15            <label><?php _e('Features Per Row', $this->name); ?></label>
     16        </th>
    2017        <?php $cols = get_post_meta(get_the_ID(), 'efl-list-cols', true); ?>
    2118        <td>
     
    3431        </td>
    3532    </tr>
     33    <tr valign='top'>
     34        <th scope='row'>
     35            <button id='efl-add-feature-group-btn'><?php _e('Add Feature Group', $this->name); ?></button>
     36        </th>
     37    </tr>
    3638</table>
  • easy-feature-lists/tags/1.1/easy-feature-lists.php

    r1024824 r1027019  
    99 * Plugin URI:        http://wordpress.org/plugins/easy-feature-lists
    1010 * Description:       Easily create checklists of features in your posts and pages.
    11  * Version:           1.0.0
     11 * Version:           1.1.0
    1212 * Author:            Mark Hurst Deutsch
    1313 * Author URI:        http://qedev.com/
  • easy-feature-lists/tags/1.1/includes/easy-feature-lists.php

    r1024824 r1027019  
    5151    public function __construct() {
    5252
    53         $this->plugin_name = 'plugin-name';
    54         $this->version = '1.0.0';
     53        $this->plugin_name = 'easy-feature-lists';
     54        $this->version = '1.1.0';
    5555
    5656        $this->load_dependencies();
  • easy-feature-lists/trunk/README.txt

    r1024826 r1027019  
    11=== Plugin Name ===
    22Contributors: doytch
    3 Donate link: http://qedev.com/
     3Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mark%2edeutsch%40utoronto%2eca&lc=US&item_name=Coffee%20Donation%20%3d%29&amount=10%2e00&currency_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted
    44Tags: feature list, features, check list, list, shortcode, table
    55Requires at least: 3.9
    66Tested up to: 4.0
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    21211. In your post, insert the [efl_feature_list] shortcode where you want the list.
    22221. Select the feature list you want from the metabox below the post editor.
    23 1. Check the items that you want checked in the feature list. This lets you create one list and have reuse it across
    24 multiple posts, only changing what is checked.
     231. Set the value for each feature. This lets you create one list and reuse it across
     24multiple posts, changing only the text or checkbox for each feature.
    2525
    2626Other features are planned for the future, so let me know of any requests via the Support forum. I provide paid support
     
    4444to worry about this, contact me at admin@qedev.com and we can discuss any jobs you need done.
    4545
     46= How do I remove a feature group? =
     47
     48On the Edit Feature List page, simply remove all the features from the feature group you wish to delete.
     49
    4650== Screenshots ==
    4751
    48 1. Feature lists are created using simple markup. In this example, three feature groups are being created with various
     521. Feature lists are created using simple tables. In this example, two feature groups are being created with various
    4953features in each group.
    50 2. Lists are selected and customised using the metabox below the editor, and inserted into posts and pages using a shortcode.
     542. Lists are selected and customised using the metabox below the post editor, and inserted into posts and pages using a shortcode.
    51553. The feature list displayed under the WordPress Twenty Twelve theme. Styling is controlled via your theme.
    5256
    5357== Changelog ==
    5458
     59= 1.1 =
     60* Features can now have their values be text as well as check boxes. The text is set on the Post page just like checkboxes.
     61* Feature lists previously defined will no longer work. I apologise for the inconvenience but these and future improvements
     62required moving to a more flexible, incompatible underlying architecture. I thought it was best to do this now rather than
     63down the line.
     64* 78% more love was added to the plugin.
     65
    5566= 1.0 =
    5667* Initial release
  • easy-feature-lists/trunk/admin/EFLAdmin.php

    r1024824 r1027019  
    6161     */
    6262    public function enqueue_scripts($hook) {
    63         if ($hook == 'post.php' || $hook == 'post-new.php') {
    64             wp_enqueue_script( $this->name, plugin_dir_url( __FILE__ ) . 'js/admin.js', array( 'jquery' ), null, false );
    65             $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
    66             wp_localize_script($this->name, 'EFL_AJAX_URL', admin_url('admin-ajax.php', $protocol));
    67         }
    6863    }
    6964
  • easy-feature-lists/trunk/admin/css/table.css

    r1024824 r1027019  
    77}
    88
    9 .efl-cell-wide-1 { width: 100%; }
    10 .efl-cell-wide-2 { width: 50%; }
    11 .efl-cell-wide-3 { width: 33.33%; }
    12 .efl-cell-wide-4 { width: 25%; }
    13 .efl-cell-wide-5 { width: 20%; }
    14 .efl-cell-wide-6 { width: 16.66%; }
    15 .efl-cell-wide-7 { width: 14.28%; }
    16 .efl-cell-wide-8 { width: 12.5%; }
    17 .efl-cell-wide-9 { width: 11.1%; }
     9.efl-cell-wide-1 { width: 50%; }
     10.efl-cell-wide-2 { width: 25%; }
     11.efl-cell-wide-3 { width: 16.66%; }
     12.efl-cell-wide-4 { width: 12.5%; }
     13.efl-cell-wide-5 { width: 10%; }
     14.efl-cell-wide-6 { width: 8.444%; }
     15.efl-cell-wide-7 { width: 7.14%; }
     16.efl-cell-wide-8 { width: 6.25%; }
     17.efl-cell-wide-9 { width: 5.55%; }
  • easy-feature-lists/trunk/admin/includes/EFLFeatureListMetabox.php

    r1024824 r1027019  
    6262    public function create_metabox($post) {
    6363        wp_nonce_field('efl_fl_mb', 'efl_fl_mb_nonce');
    64         include_once(plugin_dir_path( dirname(dirname( __FILE__ )) ) . 'admin/partials/feature-list-metabox.php');
     64        include_once(plugin_dir_path( dirname( __FILE__ ) ) . '/partials/feature-list-metabox.php');
     65       
     66        wp_enqueue_style(  'feature-list-metabox', plugin_dir_url( dirname(__FILE__) ) . 'css/feature-list-metabox.css');
     67
     68        wp_enqueue_script( 'feature-list-metabox', plugin_dir_url( dirname(__FILE__) ) . 'js/feature-list-metabox.js', array( 'jquery' ), null, false );
     69        wp_localize_script('feature-list-metabox', 'EFL_LIST_JSON', get_post_meta($post->ID, 'efl-list-features', true));       
    6570    }
    6671
     
    8186        }
    8287
    83         if (isset($_POST['efl-list-markup'])) {
    84             update_post_meta($post_id, 'efl-list-markup', wp_strip_all_tags($_POST['efl-list-markup']));
    85         }
     88
    8689        if (isset($_POST['efl-list-cols'])) {
    8790            update_post_meta($post_id, 'efl-list-cols', intval($_POST['efl-list-cols']));
    8891        }
     92
     93        if (isset($_POST['efl-group-name']) && isset($_POST['efl-feature-name']) && isset($_POST['efl-feature-type'])) {
     94            $groups = array();
     95            foreach ($_POST['efl-group-name'] as $group_id => $group_name) {
     96                if (! isset($_POST['efl-feature-name'][$group_id])) {
     97                    continue;
     98                }
     99
     100                $group = array(
     101                    'name'      => wp_strip_all_tags($group_name),
     102                    'features'  => array()
     103                );
     104
     105                foreach ($_POST['efl-feature-name'][$group_id] as $feature_id => $feature_name) {
     106                    $feature = array(
     107                        'name'  => $_POST['efl-feature-name'][$group_id][$feature_id],
     108                        'type'  => $_POST['efl-feature-type'][$group_id][$feature_id]
     109                    );
     110
     111                    $group['features'][] = $feature;
     112                }
     113
     114                $groups[] = $group;
     115            }
     116            update_post_meta($post_id, 'efl-list-features', json_encode($groups));
     117        }
    89118    }
    90119}
  • easy-feature-lists/trunk/admin/includes/EFLPostMetabox.php

    r1024824 r1027019  
    6969        $list = intval($_POST['feature_list_id']);
    7070        $ret = array(
    71             'markup' => get_post_meta($list, 'efl-list-markup', true),
    72             'checklist' => get_post_meta($post, 'efl-list-checklist', true)
     71            'features' => get_post_meta($list, 'efl-list-features', true),
     72            'values' => get_post_meta($post, 'efl-list-values', true)
    7373        );
    7474        echo json_encode($ret);
     
    8282    public function create_metabox($post) {
    8383        wp_nonce_field('efl_post_mb', 'efl_post_mb_nonce');
    84         include_once(plugin_dir_path( dirname(dirname( __FILE__ )) ) . 'admin/partials/post-metabox.php');
     84        include_once(plugin_dir_path( dirname( __FILE__ ) ) . '/partials/post-metabox.php');
     85
     86        wp_enqueue_script( 'post-metabox', plugin_dir_url( dirname(__FILE__) ) . 'js/post-metabox.js', array( 'jquery' ), null, false );
     87        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
     88        wp_localize_script('post-metabox', 'EFL_AJAX_URL', admin_url('admin-ajax.php', $protocol));
     89
    8590    }
    8691
     
    105110        }
    106111
    107         if (isset($_POST['efl-chk'])) {
    108             $group_num = 0;
    109             $feature_num = 0;
    110             $checklist = '';
    111             foreach($_POST['efl-chk'] as $group_idx => $group) {
    112                 foreach ($group as $feature_idx => $feature) { 
    113                     $checklist .= "{$group_idx}-{$feature_idx},";
    114                     $feature_num += 1;
     112        if (isset($_POST['efl-feature'])) {
     113            $values = array();
     114            foreach($_POST['efl-feature'] as $group_idx => $group) {
     115                foreach ($group as $feature_idx => $value) {   
     116                    $values[$group_idx][$feature_idx] = wp_strip_all_tags($value);
    115117                }
    116                 $feature_num = 0;
    117                 $group_num += 1;
    118118            }
    119             update_post_meta($post_id, "efl-list-checklist", $checklist);
     119
     120            // Fill out the array for JSON encoding.
     121            for ($i = 0; $i < max(array_keys($values)); $i++) {
     122                if (! isset($values[$i])) {
     123                    // Fill the undefined group.
     124                    $values[$i] = array( array('') );
     125                } else {
     126                    for ($j = 0; $j < max(array_keys($values[$i])); $j++) {
     127                        if (! isset($values[$i][$j])) {
     128                            // Fill the undefined feature value.
     129                            $values[$i][$j] = '';
     130                        }
     131                    }
     132                }
     133            }
     134
     135            update_post_meta($post_id, "efl-list-values", json_encode($values));
    120136        }
    121137    }
  • easy-feature-lists/trunk/admin/includes/EFLTableGenerator.php

    r1024824 r1027019  
    1212class EFLTableGenerator {
    1313    /**
    14      * Raw checklist info of the feature list
     14     * Values of the feature list
    1515     *
    1616     * @access   private
    1717     */
    18     private $checklist;
     18    private $values;
    1919
    2020    /**
     
    5858     */
    5959    private function create_structure($post_id, $list_id) {
    60         $markup = get_post_meta($list_id, 'efl-list-markup', true);
    61         $this->checklist = get_post_meta($post_id, 'efl-list-checklist', true);
    62         if ($markup == null || $markup == ""   || $this->checklist == null || $this->checklist == "" ) {
     60        $features = get_post_meta($list_id, 'efl-list-features', true);
     61        $values = get_post_meta($post_id, 'efl-list-values', true);
     62
     63        if ($features == null || $features == ""   || $values == null || $values == "" ) {
    6364            return false;
    6465        }
    6566
     67        $features = json_decode($features, true);
     68        $values = json_decode($values, true);
     69
    6670        // Each line is of form "Feature Group: Feature 1, Feature 2, Feature 3".
    67         $structure = array();
    68         foreach (explode("\n", $markup) as $group_id => $group_markup) {
    69             // Split each line into the group name and the features.
    70             $tmp = explode(":", $group_markup);
    71             if (count($tmp) != 2) {
    72                 return false;
     71        foreach ($features as $group_id => $group) {
     72            $group_id = intval($group_id);
     73            foreach ($features[$group_id]['features'] as $feature_id => $feature) {
     74                $feature_id = intval($feature_id);
     75                // Merge the value data into the feature list structure array.
     76                $features[$group_id]['features'][$feature_id]['value'] = $values[$group_id][$feature_id];
    7377            }
    74            
    75             $group = array();
    76             foreach (explode(",", $tmp[1]) as $feature_id => $feature_markup) {
    77                 // Construct an array for each feature and add it to the group array.
    78                 $group[] = array(
    79                     'id' => "{$group_id}-{$feature_id}",
    80                     'name' => trim($feature_markup),
    81                     'checked' => $this->feature_is_checked($group_id, $feature_id)
    82                 );
    83             }
    84             $structure[trim($tmp[0])] = $group;
    8578        }
    8679
    87         return $structure;
    88     }
    89 
    90     /**
    91      * Creates a table that contains the feature list w/ appropriate items checked.
    92      *
    93      * @var     string      $group_id           The ID of the group the feature's in.
    94      * @var     string      $feature_id         The ID of the feature itself.
    95      * @return  boolean                         True/false whether the feature is checked.
    96      */
    97     private function feature_is_checked($group_id, $feature_id) {
    98         return strpos($this->checklist, "{$group_id}-{$feature_id}") !== false;
     80        return $features;
    9981    }
    10082
     
    10890        $output = "<table class='efl-feature-list-table'>";
    10991
    110         foreach ($structure as $group_name => $features) {
     92        foreach ($structure as $group) {
    11193            $output .= "<tr>";
    112             $output .= $this->create_group_name_cell($group_name);
    113             $output .= $this->create_group_features_cell($features);
     94            $output .= $this->create_group_name_cell($group['name']);
     95            $output .= $this->create_group_features_cell($group['features']);
    11496            $output .= "</tr>";
    11597        }
     
    176158    private function create_feature_cell($feature) {
    177159        $output  = "<td class='efl-feature-cell efl-cell-wide-" . $this->max_col . "'>";
    178         $output .= "<input class='efl-feature-checkbox' disabled=true type='checkbox' ";
    179         $output .= "id='efl-chk-" . $feature['id'] . "'";
    180         $output .= $feature['checked'] ? ' checked ' : ' ';
    181         $output .= "/>";
    182         $output .= "<label for='efl-chk-" . $feature['id'] . "'>";
    183         $output .= "&nbsp;" . $feature['name'] . "</label></td>";
     160        $output .= "<label class='efl-feature-name-label'>" . $feature['name'] . "</label></td>";
     161        $output .= "<td class='efl-feature-cell efl-cell-wide-" . $this->max_col . "'>";
     162
     163        if ($feature['type'] == 'Text') {
     164            $output .= "<span class='efl-feature-text'>" . $feature['value'] . "</span>";
     165        } else if ($feature['type'] == 'Checkbox') {
     166            $output .= "<input disabled=true class='efl-feature-check' type='checkbox' " . $feature['value'] . "/>";
     167        }
     168
     169        $output .= "</td>";
    184170        return $output;
    185171    }
  • easy-feature-lists/trunk/admin/partials/feature-list-metabox.php

    r1024824 r1027019  
    1010?>
    1111
    12 <table class='form-table'>
     12<table id='efl-list-table' class='form-table'>
    1313    <tr valign='top'>
    14         <th scope='row'><label><?php _e('Feature List Markup', $this->name); ?></label></th>
    15         <?php $list = get_post_meta(get_the_ID(), 'efl-list-markup', true); ?>
    16         <td><textarea id='efl-list-markup' name='efl-list-markup' cols='70' rows='10'><?php echo $list; ?></textarea></td>
    17     </tr>
    18     <tr valign='top'>
    19         <th scope='row'><label><?php _e('Features Per Row', $this->name); ?></label></th>
     14        <th scope='row'>
     15            <label><?php _e('Features Per Row', $this->name); ?></label>
     16        </th>
    2017        <?php $cols = get_post_meta(get_the_ID(), 'efl-list-cols', true); ?>
    2118        <td>
     
    3431        </td>
    3532    </tr>
     33    <tr valign='top'>
     34        <th scope='row'>
     35            <button id='efl-add-feature-group-btn'><?php _e('Add Feature Group', $this->name); ?></button>
     36        </th>
     37    </tr>
    3638</table>
  • easy-feature-lists/trunk/easy-feature-lists.php

    r1024824 r1027019  
    99 * Plugin URI:        http://wordpress.org/plugins/easy-feature-lists
    1010 * Description:       Easily create checklists of features in your posts and pages.
    11  * Version:           1.0.0
     11 * Version:           1.1.0
    1212 * Author:            Mark Hurst Deutsch
    1313 * Author URI:        http://qedev.com/
  • easy-feature-lists/trunk/includes/easy-feature-lists.php

    r1024824 r1027019  
    5151    public function __construct() {
    5252
    53         $this->plugin_name = 'plugin-name';
    54         $this->version = '1.0.0';
     53        $this->plugin_name = 'easy-feature-lists';
     54        $this->version = '1.1.0';
    5555
    5656        $this->load_dependencies();
Note: See TracChangeset for help on using the changeset viewer.