Changeset 1027019
- Timestamp:
- 11/17/2014 04:39:33 AM (11 years ago)
- Location:
- easy-feature-lists
- Files:
-
- 6 added
- 2 deleted
- 16 edited
- 9 copied
-
tags/1.1 (copied) (copied from easy-feature-lists/trunk)
-
tags/1.1/LICENSE.txt (copied) (copied from easy-feature-lists/trunk/LICENSE.txt)
-
tags/1.1/README.txt (copied) (copied from easy-feature-lists/trunk/README.txt) (3 diffs)
-
tags/1.1/admin (copied) (copied from easy-feature-lists/trunk/admin)
-
tags/1.1/admin/EFLAdmin.php (modified) (1 diff)
-
tags/1.1/admin/css/feature-list-metabox.css (added)
-
tags/1.1/admin/css/table.css (modified) (1 diff)
-
tags/1.1/admin/includes/EFLFeatureListMetabox.php (modified) (2 diffs)
-
tags/1.1/admin/includes/EFLPostMetabox.php (modified) (3 diffs)
-
tags/1.1/admin/includes/EFLTableGenerator.php (modified) (4 diffs)
-
tags/1.1/admin/js/admin.js (deleted)
-
tags/1.1/admin/js/feature-list-metabox.js (added)
-
tags/1.1/admin/js/post-metabox.js (added)
-
tags/1.1/admin/partials/feature-list-metabox.php (modified) (2 diffs)
-
tags/1.1/easy-feature-lists.php (copied) (copied from easy-feature-lists/trunk/easy-feature-lists.php) (1 diff)
-
tags/1.1/includes (copied) (copied from easy-feature-lists/trunk/includes)
-
tags/1.1/includes/easy-feature-lists.php (modified) (1 diff)
-
tags/1.1/index.php (copied) (copied from easy-feature-lists/trunk/index.php)
-
tags/1.1/languages (copied) (copied from easy-feature-lists/trunk/languages)
-
tags/1.1/uninstall.php (copied) (copied from easy-feature-lists/trunk/uninstall.php)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/admin/EFLAdmin.php (modified) (1 diff)
-
trunk/admin/css/feature-list-metabox.css (added)
-
trunk/admin/css/table.css (modified) (1 diff)
-
trunk/admin/includes/EFLFeatureListMetabox.php (modified) (2 diffs)
-
trunk/admin/includes/EFLPostMetabox.php (modified) (3 diffs)
-
trunk/admin/includes/EFLTableGenerator.php (modified) (4 diffs)
-
trunk/admin/js/admin.js (deleted)
-
trunk/admin/js/feature-list-metabox.js (added)
-
trunk/admin/js/post-metabox.js (added)
-
trunk/admin/partials/feature-list-metabox.php (modified) (2 diffs)
-
trunk/easy-feature-lists.php (modified) (1 diff)
-
trunk/includes/easy-feature-lists.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
easy-feature-lists/tags/1.1/README.txt
r1024826 r1027019 1 1 === Plugin Name === 2 2 Contributors: doytch 3 Donate link: http ://qedev.com/3 Donate 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¤cy_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted 4 4 Tags: feature list, features, check list, list, shortcode, table 5 5 Requires at least: 3.9 6 6 Tested up to: 4.0 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 21 21 1. In your post, insert the [efl_feature_list] shortcode where you want the list. 22 22 1. 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 havereuse it across24 multiple posts, only changing what is checked.23 1. Set the value for each feature. This lets you create one list and reuse it across 24 multiple posts, changing only the text or checkbox for each feature. 25 25 26 26 Other features are planned for the future, so let me know of any requests via the Support forum. I provide paid support … … 44 44 to worry about this, contact me at admin@qedev.com and we can discuss any jobs you need done. 45 45 46 = How do I remove a feature group? = 47 48 On the Edit Feature List page, simply remove all the features from the feature group you wish to delete. 49 46 50 == Screenshots == 47 51 48 1. Feature lists are created using simple markup. In this example, threefeature groups are being created with various52 1. Feature lists are created using simple tables. In this example, two feature groups are being created with various 49 53 features 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.54 2. Lists are selected and customised using the metabox below the post editor, and inserted into posts and pages using a shortcode. 51 55 3. The feature list displayed under the WordPress Twenty Twelve theme. Styling is controlled via your theme. 52 56 53 57 == Changelog == 54 58 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 62 required moving to a more flexible, incompatible underlying architecture. I thought it was best to do this now rather than 63 down the line. 64 * 78% more love was added to the plugin. 65 55 66 = 1.0 = 56 67 * Initial release -
easy-feature-lists/tags/1.1/admin/EFLAdmin.php
r1024824 r1027019 61 61 */ 62 62 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 }68 63 } 69 64 -
easy-feature-lists/tags/1.1/admin/css/table.css
r1024824 r1027019 7 7 } 8 8 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 62 62 public function create_metabox($post) { 63 63 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)); 65 70 } 66 71 … … 81 86 } 82 87 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 86 89 if (isset($_POST['efl-list-cols'])) { 87 90 update_post_meta($post_id, 'efl-list-cols', intval($_POST['efl-list-cols'])); 88 91 } 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 } 89 118 } 90 119 } -
easy-feature-lists/tags/1.1/admin/includes/EFLPostMetabox.php
r1024824 r1027019 69 69 $list = intval($_POST['feature_list_id']); 70 70 $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) 73 73 ); 74 74 echo json_encode($ret); … … 82 82 public function create_metabox($post) { 83 83 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 85 90 } 86 91 … … 105 110 } 106 111 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); 115 117 } 116 $feature_num = 0;117 $group_num += 1;118 118 } 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)); 120 136 } 121 137 } -
easy-feature-lists/tags/1.1/admin/includes/EFLTableGenerator.php
r1024824 r1027019 12 12 class EFLTableGenerator { 13 13 /** 14 * Raw checklist infoof the feature list14 * Values of the feature list 15 15 * 16 16 * @access private 17 17 */ 18 private $ checklist;18 private $values; 19 19 20 20 /** … … 58 58 */ 59 59 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 == "" ) { 63 64 return false; 64 65 } 65 66 67 $features = json_decode($features, true); 68 $values = json_decode($values, true); 69 66 70 // 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]; 73 77 } 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;85 78 } 86 79 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; 99 81 } 100 82 … … 108 90 $output = "<table class='efl-feature-list-table'>"; 109 91 110 foreach ($structure as $group _name => $features) {92 foreach ($structure as $group) { 111 93 $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']); 114 96 $output .= "</tr>"; 115 97 } … … 176 158 private function create_feature_cell($feature) { 177 159 $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 .= " " . $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>"; 184 170 return $output; 185 171 } -
easy-feature-lists/tags/1.1/admin/partials/feature-list-metabox.php
r1024824 r1027019 10 10 ?> 11 11 12 <table class='form-table'>12 <table id='efl-list-table' class='form-table'> 13 13 <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> 20 17 <?php $cols = get_post_meta(get_the_ID(), 'efl-list-cols', true); ?> 21 18 <td> … … 34 31 </td> 35 32 </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> 36 38 </table> -
easy-feature-lists/tags/1.1/easy-feature-lists.php
r1024824 r1027019 9 9 * Plugin URI: http://wordpress.org/plugins/easy-feature-lists 10 10 * Description: Easily create checklists of features in your posts and pages. 11 * Version: 1. 0.011 * Version: 1.1.0 12 12 * Author: Mark Hurst Deutsch 13 13 * Author URI: http://qedev.com/ -
easy-feature-lists/tags/1.1/includes/easy-feature-lists.php
r1024824 r1027019 51 51 public function __construct() { 52 52 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'; 55 55 56 56 $this->load_dependencies(); -
easy-feature-lists/trunk/README.txt
r1024826 r1027019 1 1 === Plugin Name === 2 2 Contributors: doytch 3 Donate link: http ://qedev.com/3 Donate 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¤cy_code=USD&button_subtype=services&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted 4 4 Tags: feature list, features, check list, list, shortcode, table 5 5 Requires at least: 3.9 6 6 Tested up to: 4.0 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 21 21 1. In your post, insert the [efl_feature_list] shortcode where you want the list. 22 22 1. 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 havereuse it across24 multiple posts, only changing what is checked.23 1. Set the value for each feature. This lets you create one list and reuse it across 24 multiple posts, changing only the text or checkbox for each feature. 25 25 26 26 Other features are planned for the future, so let me know of any requests via the Support forum. I provide paid support … … 44 44 to worry about this, contact me at admin@qedev.com and we can discuss any jobs you need done. 45 45 46 = How do I remove a feature group? = 47 48 On the Edit Feature List page, simply remove all the features from the feature group you wish to delete. 49 46 50 == Screenshots == 47 51 48 1. Feature lists are created using simple markup. In this example, threefeature groups are being created with various52 1. Feature lists are created using simple tables. In this example, two feature groups are being created with various 49 53 features 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.54 2. Lists are selected and customised using the metabox below the post editor, and inserted into posts and pages using a shortcode. 51 55 3. The feature list displayed under the WordPress Twenty Twelve theme. Styling is controlled via your theme. 52 56 53 57 == Changelog == 54 58 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 62 required moving to a more flexible, incompatible underlying architecture. I thought it was best to do this now rather than 63 down the line. 64 * 78% more love was added to the plugin. 65 55 66 = 1.0 = 56 67 * Initial release -
easy-feature-lists/trunk/admin/EFLAdmin.php
r1024824 r1027019 61 61 */ 62 62 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 }68 63 } 69 64 -
easy-feature-lists/trunk/admin/css/table.css
r1024824 r1027019 7 7 } 8 8 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 62 62 public function create_metabox($post) { 63 63 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)); 65 70 } 66 71 … … 81 86 } 82 87 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 86 89 if (isset($_POST['efl-list-cols'])) { 87 90 update_post_meta($post_id, 'efl-list-cols', intval($_POST['efl-list-cols'])); 88 91 } 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 } 89 118 } 90 119 } -
easy-feature-lists/trunk/admin/includes/EFLPostMetabox.php
r1024824 r1027019 69 69 $list = intval($_POST['feature_list_id']); 70 70 $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) 73 73 ); 74 74 echo json_encode($ret); … … 82 82 public function create_metabox($post) { 83 83 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 85 90 } 86 91 … … 105 110 } 106 111 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); 115 117 } 116 $feature_num = 0;117 $group_num += 1;118 118 } 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)); 120 136 } 121 137 } -
easy-feature-lists/trunk/admin/includes/EFLTableGenerator.php
r1024824 r1027019 12 12 class EFLTableGenerator { 13 13 /** 14 * Raw checklist infoof the feature list14 * Values of the feature list 15 15 * 16 16 * @access private 17 17 */ 18 private $ checklist;18 private $values; 19 19 20 20 /** … … 58 58 */ 59 59 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 == "" ) { 63 64 return false; 64 65 } 65 66 67 $features = json_decode($features, true); 68 $values = json_decode($values, true); 69 66 70 // 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]; 73 77 } 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;85 78 } 86 79 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; 99 81 } 100 82 … … 108 90 $output = "<table class='efl-feature-list-table'>"; 109 91 110 foreach ($structure as $group _name => $features) {92 foreach ($structure as $group) { 111 93 $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']); 114 96 $output .= "</tr>"; 115 97 } … … 176 158 private function create_feature_cell($feature) { 177 159 $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 .= " " . $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>"; 184 170 return $output; 185 171 } -
easy-feature-lists/trunk/admin/partials/feature-list-metabox.php
r1024824 r1027019 10 10 ?> 11 11 12 <table class='form-table'>12 <table id='efl-list-table' class='form-table'> 13 13 <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> 20 17 <?php $cols = get_post_meta(get_the_ID(), 'efl-list-cols', true); ?> 21 18 <td> … … 34 31 </td> 35 32 </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> 36 38 </table> -
easy-feature-lists/trunk/easy-feature-lists.php
r1024824 r1027019 9 9 * Plugin URI: http://wordpress.org/plugins/easy-feature-lists 10 10 * Description: Easily create checklists of features in your posts and pages. 11 * Version: 1. 0.011 * Version: 1.1.0 12 12 * Author: Mark Hurst Deutsch 13 13 * Author URI: http://qedev.com/ -
easy-feature-lists/trunk/includes/easy-feature-lists.php
r1024824 r1027019 51 51 public function __construct() { 52 52 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'; 55 55 56 56 $this->load_dependencies();
Note: See TracChangeset
for help on using the changeset viewer.