Changeset 588972
- Timestamp:
- 08/22/2012 07:15:40 PM (13 years ago)
- Location:
- kickpress/trunk
- Files:
-
- 6 edited
-
elements/class-related-posts.php (modified) (5 diffs)
-
includes/js/kickpress-ajax-search.js (modified) (3 diffs)
-
kickpress-api.php (modified) (9 diffs)
-
kickpress-form-elements.php (modified) (2 diffs)
-
kickpress-functions.php (modified) (1 diff)
-
kickpress.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kickpress/trunk/elements/class-related-posts.php
r583867 r588972 4 4 public function input( $params ) { 5 5 extract( $params, EXTR_SKIP ); 6 7 $params['name'] = $name = sprintf( 8 'data[%s][%d][rel_input][%s][]', 9 $post_type, 10 $post_id, 11 $relationship 12 ); 6 13 7 14 $rel = kickpress_get_relationship( $relationship ); … … 11 18 12 19 $posts = kickpress_get_related_posts( $post_id, $relationship ); 13 14 $params['name'] = $name = sprintf(15 'rel_post[%s][%d][%s][]',16 $post_type,17 $post_id,18 $relationship19 );20 20 21 21 $conf = esc_attr( __( 'Are you sure you want to remove this post?' ) ); … … 29 29 ) ); 30 30 31 $html .= '<ul id="' . $id . '_list" class="ajax_search_list">';31 $html .= self::_html_input( 'hidden', $name, '0' ); 32 32 33 foreach ( $posts as $post ) { 34 $input = self::_html_input( 'hidden', $name, $post->ID ); 35 $input .= self::_html_label( $post->post_title ); 36 $input .= self::_html_tag( 'a', 'X', array( 37 'href' => '#', 38 'rel' => $post->ID 33 $html .= '<ul id="' . $relationship . '_list" class="ajax_search_list">'; 34 35 foreach ( (array) $posts as $post ) { 36 $input = self::_html_input( 'checkbox', $name, $post->ID, array( 37 'id' => $relationship . '_list_' . $post->ID, 38 'checked' => true 39 ) ) . self::_html_label( $post->post_title, array( 40 'for' => $relationship . '_list_' . $post->ID 39 41 ) ); 40 42 41 $html .= self::_html_tag( 'li', $input, array( 42 'id' => $id . '-' . $post->ID 43 $html .= self::_html_tag( 'li', $input ); 44 } 45 46 if ( empty( $posts ) ) { 47 $html .= self::_html_tag( 'li', 'none', array( 48 'class' => 'empty' 43 49 ) ); 44 50 } … … 47 53 48 54 $html .= self::_html_input( 'text', null, null, array( 49 'id' => $ id,55 'id' => $relationship, 50 56 'class' => 'ajax_search_input' 51 57 ) ); … … 62 68 63 69 $search = self::_html_tag( 'div', ' ', array( 64 'id' => $ id. '_result',70 'id' => $relationship . '_result', 65 71 'class' => 'ajax_search_result' 66 72 ) ); 67 73 68 74 $html .= self::_html_tag( 'div', $cancel . $search, array( 69 'id' => $ id. '_window',75 'id' => $relationship . '_window', 70 76 'class' => 'ajax_search_window' 71 77 ) ); -
kickpress/trunk/includes/js/kickpress-ajax-search.js
r583190 r588972 1 1 jQuery(document).ready(function($) { 2 2 $('.ajax_search_window') 3 .css('position', 'absolute')4 .css('visibility', 'hidden');3 .css('position', 'absolute') 4 .css('visibility', 'hidden'); 5 5 6 $('.ajax_search_input'). keyup(function() {6 $('.ajax_search_input').on('keyup', function(e) { 7 7 var search = $(this).val(); 8 8 … … 23 23 }); 24 24 25 $('.ajax_search_list a'). live('click', function() {25 $('.ajax_search_list a').on('click', function(e) { 26 26 var ajax_list = $(this).parents('.ajax_search_list'); 27 27 var conf = ajax_list.siblings('.ajax_search_conf').val(); … … 30 30 $(this).parent().remove(); 31 31 32 e.preventDefault(); 32 33 return false; 33 34 }); 34 35 35 $('.ajax_search_window a').live('click', function( ) {36 var id = this.rel;36 $('.ajax_search_window a').live('click', function(e) { 37 var ajax_window = $(this).parents('.ajax_search_window'); 37 38 38 var ajax_window = $(this).parents('.ajax_search_window'); 39 40 if (0 < id) { 41 var name = ajax_window.siblings('.ajax_search_name').val(); 42 43 ajax_window.siblings('.ajax_search_list').append( 44 $('<li>').append($('<input>', { 45 type: 'hidden', 46 name: name, 47 value: id 48 })) 49 .append($('<label>').text($(this).text())) 50 .append($('<a>', { 51 href: '#', 52 rel: id 53 }).text('X')) 54 ); 39 if ($(this).hasClass('ajax_search_cancel')) { 40 ajax_window.css('visibility', 'hidden'); 41 } else { 42 var post_id = this.rel; 43 44 if (0 < post_id) { 45 var ajax_list = ajax_window.siblings('.ajax_search_list'); 46 47 var input_id = ajax_list.attr('id') + '_' + post_id; 48 var input_name = ajax_window.siblings('.ajax_search_name').val(); 49 50 ajax_list.append( 51 $('<li>').append($('<input>', { 52 'id': input_id, 53 'type': 'checkbox', 54 'name': input_name, 55 'value': post_id, 56 'checked' : 'checked' 57 })).append($('<label>', { 58 'for': input_id 59 }).text($(this).text())) 60 ).children('.empty').remove(); 61 } 55 62 } 56 63 57 64 ajax_window.css('visibility', 'hidden'); 58 65 66 e.preventDefault(); 59 67 return false; 60 68 }); -
kickpress/trunk/kickpress-api.php
r587972 r588972 193 193 'single' => true, 194 194 'hidden' => true 195 ), 196 'tax' => array( 197 'label' => 'Taxonomy', 198 'slug' => 'tax', 199 'aliases' => array(), 200 'order' => 0, 201 'single' => true, 202 'hidden' => true 195 203 ) 196 204 ); … … 205 213 206 214 $this->params = array_merge($default_params, $params); 207 215 208 216 if ( isset($kickpress_post_types[$this->params['post_type']]['post_type_id']) ) { 209 217 $meta_type = get_post_meta($kickpress_post_types[$this->params['post_type']]['post_type_id'], '_meta_type', true); … … 268 276 require_once(WP_PLUGIN_DIR.'/kickpress/kickpress-validation.php'); 269 277 $this->validation = new validation($this->params, $post_id); 278 } 279 280 $post_type = $this->params['post_type']; 281 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); 282 283 foreach ( $taxonomies as $taxonomy ) { 284 if ( ! $taxonomy->_builtin ) { 285 $this->add_view_alias( 'tax', $taxonomy->name ); 286 } 270 287 } 271 288 } … … 548 565 } 549 566 550 $this->params['terms'][] = (object) array(567 $this->params['terms'][] = (object) array( 551 568 'name'=>'Category', 552 569 'slug'=>'category' … … 1004 1021 $errorCount = 1; 1005 1022 1023 echo '<pre>' . htmlspecialchars( print_r( $action_results, true ) ) . '</pre>'; 1024 1006 1025 // There might be multiple errors, so they are in an array. 1007 foreach ( $notes['error'] as $key =>$value ) {1026 foreach ( $notes['error'] as $key => $value ) { 1008 1027 $formErrors .= sprintf(' 1009 1028 <p class="form-error%3$s"><span class="error-number">%1$s.</span> %2$s</p>', … … 1102 1121 } 1103 1122 } 1123 } 1124 1125 public function add_view_alias( $view, $alias ) { 1126 $view_slug = $this->sanitize_slug( $view ); 1127 $alias_slug = $this->sanitize_slug( $alias ); 1128 1129 if ( isset( $this->_valid_views[$view_slug] ) ) 1130 $this->_valid_views[$view_slug]['aliases'][] = $alias_slug; 1104 1131 } 1105 1132 … … 1815 1842 $tags = $this->tags_input_to_string($post_data['tags_input']); 1816 1843 1844 $terms = $post_data['tax_input']; 1845 1817 1846 $version_control = false; 1818 1847 … … 1838 1867 'post_type' => $post_type, // post, page, or attachment 1839 1868 'post_category' => $categories, 1840 'tags_input' => $tags 1869 'tags_input' => $tags, 1870 'tax_input' => $terms 1841 1871 ); 1842 1872 //'post_date' => $post_date, … … 1905 1935 if ( $post = get_post( $post_id ) ) { 1906 1936 kickpress_process_custom_fields( $post, $post_data ); 1907 1937 1938 if ( @is_array( $post_data['rel_input'] ) ) { 1939 foreach ( $post_data['rel_input'] as $slug => $ids ) { 1940 $rel_posts = kickpress_get_related_posts( $post_id, $slug ); 1941 1942 $skip_ids = array(); 1943 1944 foreach ( $rel_posts as $rel_post ) { 1945 var_dump( $rel_post->ID ); 1946 if ( in_array( $rel_post->ID, $ids ) ) 1947 $skip_ids[] = $rel_post->ID; 1948 else 1949 kickpress_remove_related_post( $post_id, $slug, $rel_post ); 1950 } 1951 1952 foreach ( $ids as $rel_id ) { 1953 if ( ! in_array( $rel_id, $skip_ids ) ) 1954 kickpress_add_related_post( $post_id, $slug, $rel_id ); 1955 } 1956 1957 } 1958 } 1959 1908 1960 // Set the featured image, if specified 1909 1961 //if ( ! is_admin() ) { -
kickpress/trunk/kickpress-form-elements.php
r587972 r588972 184 184 protected static function _html_tag( $name, $body = null, $attr = array(), $auto_close = false ) { 185 185 foreach ( (array) $attr as $attr_name => $attr_value ) { 186 if ( empty( $attr_value ) ) continue;186 // if ( empty( $attr_value ) ) continue; 187 187 188 188 if ( true === $attr_value ) $attr_value = $attr_name; … … 204 204 */ 205 205 protected static function _html_label( $text, $attr = array() ) { 206 return self::_html_tag( 'label', $text, $attr );206 return self::_html_tag( 'label', $text, $attr, true ); 207 207 } 208 208 -
kickpress/trunk/kickpress-functions.php
r587972 r588972 868 868 } 869 869 */ 870 } 871 872 function kickpress_the_form_element( $element = 'text', $args = array(), $params = array() ) { 873 $form_element = kickpress_get_form_element( $element, $args ); 874 echo $form_element->element( $params ); 870 875 } 871 876 -
kickpress/trunk/kickpress.php
r586927 r588972 131 131 } 132 132 133 add_filter( 'the_posts', 'kickpress_the_posts', 99 ); 134 135 function kickpress_the_posts( $posts ) { 136 if ( is_admin() || ! is_main_query() ) return $posts; 137 138 global $kickpress_api; 139 140 if ( 'tax' == $kickpress_api->params['view'] ) { 141 $taxonomy = $kickpress_api->params['view_alias']; 142 143 if ( $tax = get_taxonomy( $taxonomy ) ) { 144 $page = intval( get_query_var( 'paged' ) ); 145 $limit = intval( get_query_var( 'posts_per_page' ) ); 146 147 if ( 0 < $page ) $page--; 148 149 $terms = get_terms( $taxonomy, array( 150 'number' => $limit, 151 'offset' => $limit * $page, 152 'hide_empty' => false, 153 'search' => $kickpress_api->params['search'] 154 ) ); 155 156 $fake_posts = array(); 157 158 foreach ( (array) $terms as $term ) { 159 $fake_posts[] = (object) array( 160 'ID' => $term->term_id, 161 'post_type' => $term->taxonomy, 162 'post_name' => $term->slug, 163 'post_title' => $term->name, 164 'post_content' => $term->description 165 ); 166 } 167 168 return $fake_posts; 169 } 170 } 171 172 return $posts; 173 } 174 133 175 function kickpress_activation() { 134 176
Note: See TracChangeset
for help on using the changeset viewer.