Changeset 610483
- Timestamp:
- 10/10/2012 07:41:08 PM (13 years ago)
- Location:
- kickpress/trunk
- Files:
-
- 3 edited
-
kickpress-functions.php (modified) (4 diffs)
-
kickpress-query-filters.php (modified) (1 diff)
-
kickpress-relationships.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kickpress/trunk/kickpress-functions.php
r610458 r610483 231 231 $defaults = @array_intersect_key( $kickpress_api->params, array( 232 232 'post_type' => get_post_type(), 233 'post_ types' => array(),233 'post_format' => null, 234 234 'page' => 0, 235 'posts_per_page' => 10, 235 236 'action' => '', 236 237 'action_key' => null, 237 238 'view' => '', 238 'post_format' => null,239 'posts_per_page' => 10,240 239 'first_letter' => '', 241 240 'search' => is_search() ? $_GET['s'] : '', … … 248 247 'extra_pairs' => array(), 249 248 'extra_slugs' => array(), 249 250 // What are these for? 251 'post_types' => array(), 250 252 'target' => null 251 253 ) ); … … 342 344 $api_slugs[] = $view; 343 345 } 346 347 if ( ! empty( $post_format ) ) { 348 $api_slugs[] = 'post_format'; 349 $api_slugs[] = $post_format; 350 } 344 351 345 352 if ( ! empty( $posts_per_page ) ) { … … 481 488 if ( $log = @fopen( $file, 'a' ) ) { 482 489 $line = sprintf( 483 "%s\t%s\t%s", 484 date( 'c' ), 490 "%s.%3d %s\t%s\t%s", 491 date( 'Y-m-d H:i:s' ), 492 fmod( microtime( true ), 1 ) * 1000, 493 date( 'P' ), 485 494 KICKPRESS_DEBUG_TOKEN, 486 495 $data -
kickpress/trunk/kickpress-query-filters.php
r610150 r610483 197 197 ); 198 198 } 199 } 199 200 if ( isset( $kickpress_api->params['post_format'] ) ) { 201 $post_format = $kickpress_api->params['post_format']; 202 203 $tax_query[] = array( 204 'taxonomy' => 'post_format', 205 'operator' => 'in', 206 'field' => 'slug', 207 'terms' => explode( ',', $post_format ) 208 ); 209 } 210 } 211 212 $query->query_vars['tax_query'] = $tax_query; 213 $query->is_archive = true; 214 } elseif ( isset( $kickpress_api->params['post_format'] ) ) { 215 $post_format = $kickpress_api->params['post_format']; 216 217 $tax_query = array( 'relation' => 'AND' ); 218 219 $tax_query[] = array( 220 'taxonomy' => 'post_format', 221 'operator' => 'in', 222 'field' => 'slug', 223 'terms' => explode( ',', $post_format ) 224 ); 200 225 201 226 $query->query_vars['tax_query'] = $tax_query; -
kickpress/trunk/kickpress-relationships.php
r610458 r610483 214 214 $ids = $wpdb->get_col( $sql ); 215 215 216 $posts = get_posts( array( 216 if ( empty( $ids ) ) 217 return array(); 218 219 return get_posts( array( 217 220 'post__in' => $ids, 218 221 'post_type' => $object_type 219 222 ) ); 220 221 /* $meta_key = '_kickpress_rel[' . $rel->slug . ']';222 223 $is_source = $post->post_type == $rel->source_type;224 225 $posts = array();226 227 if ( $is_source ) {228 $posts = get_posts( array(229 'post_type' => $rel->target_type,230 'meta_key' => $meta_key,231 'meta_value' => $post->ID232 ) );233 } else {234 $meta = array_unique( get_post_meta( $post->ID, $meta_key, false ) );235 236 foreach ( $meta as $rel_post_id ) {237 $rel_post = get_post( $rel_post_id );238 239 if ( $rel->source_type != $rel_post->post_type ) continue;240 // if ( 'publish' != $rel_post->post_status ) continue;241 242 $posts[] = $rel_post;243 }244 } */245 246 return $posts;247 223 } 248 224 … … 286 262 $rel = kickpress_get_relationship( $rel_name ); 287 263 288 $meta_key = '_kickpress_rel[' . $rel->slug . ']';289 290 264 if ( $rel->source_type == $post->post_type && $rel->target_type == $rel_post->post_type ) { 291 265 $src_post = $post; … … 297 271 298 272 $wpdb->delete( $wpdb->prefix . 'kp_post_relationships', array( 299 'source_id' => $src_post->ID,300 'target_id' => $tgt_post->ID,273 'source_id' => $src_post->ID, 274 'target_id' => $tgt_post->ID, 301 275 'relationship' => $rel_name 302 276 ) ); 303 304 // delete_post_meta( $tgt_post->ID, $meta_key, $src_post->ID );305 277 } 306 278 … … 313 285 314 286 $object_type = get_post_type(); 287 288 header( 'Content-type: text/plain' ); 315 289 316 290 foreach ( $kickpress_relationships as $rel ) { … … 322 296 323 297 foreach ( (array) $old_posts as $old_post ) { 324 // if ( ! in_array( $old_post->ID, $new_posts ) ) 325 kickpress_remove_related_post( $post_id, $rel->name, $old_post ); 298 if ( ! in_array( $old_post->ID, $new_posts ) ) 299 kickpress_remove_related_post( $post_id, 300 $rel->name, $old_post ); 326 301 } 327 302 328 303 foreach ( (array) $new_posts as $new_post ) { 329 kickpress_add_related_post( $post_id, $rel->name, $new_post ); 304 if ( 0 < intval( $new_post ) ) 305 kickpress_add_related_post( $post_id, 306 $rel->name, intval( $new_post ) ); 330 307 } 331 308 } … … 372 349 ?> 373 350 <style type="text/css"> 374 /*.rel-post-search {375 position: relative;376 } 377 378 .ajax-post-search {351 .rel-post-search { 352 margin: 1em 0em; 353 } 354 355 /* .ajax-post-search { 379 356 position: absolute; 380 357 z-index: 100; … … 413 390 </style> 414 391 <script type="text/javascript"> 392 var is_rel_search = false; 393 415 394 jQuery(document).ready(function($) { 395 $('#post').bind('submit', function(event) { 396 if (is_rel_search) { 397 $('#' + is_rel_search).siblings('.button').click(); 398 399 $('#publish').removeClass('button-primary-disabled'); 400 $('#ajax-loading').css('visibility', 'hidden'); 401 402 return false; 403 } 404 }); 405 406 $('.rel-post-title').each(function(index, item) { 407 $(item).bind('focus', function(event) { 408 is_rel_search = $(item).attr('id'); 409 }); 410 411 $(item).bind('blur', function(event) { 412 is_rel_search = false; 413 }); 414 }); 415 416 416 $('div.relationship a.hide-if-no-js').each(function(index, item) { 417 417 $(item).click(function(event) { 418 418 $(this).hide(); 419 $(this).parents('.relationship').children('.related-posts').hide('blind', null, 'fast');419 //$(this).parents('.relationship').children('.related-posts').hide('blind', null, 'fast'); 420 420 421 421 var div = $(this.href.match(/#[a-z\-]+/)[0]); 422 422 423 423 div.show('blind', null, 'fast'); 424 425 div.children('.rel-post-title').focus(); 424 426 425 427 return false; … … 442 444 var resbox = $(this).siblings('.ajax-post-search').first(); 443 445 446 resbox.html('<ul><li style="font-style: italic;">Loading...</li></ul>'); 447 444 448 jQuery.post(ajaxurl, args, function(response) { 445 449 resbox.html(response); … … 457 461 458 462 $(this).parents('.relationship').children('a.hide-if-no-js').show(); 463 $(this).parents('.rel-post-search').children('.rel-post-title').val(''); 459 464 $(this).parents('.rel-post-search').children('.ajax-post-search').empty(); 460 465 … … 492 497 }).append(input).append(label)); 493 498 494 form.hide('blind', null, 'fast'); 495 list.show('blind', null, 'fast'); 496 497 $(this).parents('.relationship').children('a.hide-if-no-js').show(); 498 $(this).parents('.rel-post-search').children('.ajax-post-search').empty(); 499 $(this).parents('li').first().remove(); 499 500 500 501 return false; … … 550 551 ?> 551 552 <div class="relationship"> 552 <a href="#rel-post-search-<?php echo $name; ?>" class="hide-if-no-js" style="float: right;"> Edit</a>553 <h4><?php echo $rel->label; ?>< /h4>553 <a href="#rel-post-search-<?php echo $name; ?>" class="hide-if-no-js" style="float: right;">Search</a> 554 <h4><?php echo $rel->label; ?><br><small><?php echo $rel->object_type; ?></small></h4> 554 555 <div id="rel-post-search-<?php echo $name; ?>" class="rel-post-search hide-if-js"> 555 556 <label><?php echo $type->labels->search_items; ?>:</label><br> 556 <input type="text" name="rel_post_title[<?php echo $name; ?>]" class="rel-post-title" style="display: block; width: 95%;">557 <input type="text" name="rel_post_title[<?php echo $name; ?>]" id="rel-post-title-<?php echo $name; ?>" class="rel-post-title" style="display: block; width: 95%;"> 557 558 <input type="hidden" name="rel_post_type[<?php echo $name; ?>]" value="<?php echo $rel->object_type; ?>" class="rel-post-type"> 558 559 <input type="hidden" name="rel_post_qty[<?php echo $name; ?>]" value="<?php echo $rel->object_qty; ?>" class="rel-post-qty"> 559 560 <input type="button" value="Search" class="button"> 560 <a href="#" class="cancel">C ancel</a>561 <a href="#" class="cancel">Close</a> 561 562 <div id="ajax-post-search-<?php echo $name; ?>" class="ajax-post-search"></div> 562 563 </div> 563 564 <div id="related-posts-<?php echo $name; ?>" class="related-posts"> 565 <input type="hidden" name="rel_posts[<?php echo $name; ?>][]"> 564 566 <?php if ( ! empty( $rel_posts ) ) : ?> 565 567 <?php if ( 'multiple' == $rel->object_qty ) : foreach ( $rel_posts as $rel_post ) : … … 583 585 <?php else : ?> 584 586 <span class="empty">none</span> 585 <?php endif; ?>587 <?php endif; ?> 586 588 </div> 587 589 </div> … … 617 619 <ul> 618 620 <?php while ( have_posts() ) : the_post(); ?> 619 <li> <a rel="<?php the_ID(); ?>" href="#" class="rel-post-search-result <?php echo $_REQUEST['post_qty']; ?>"><?php the_title(); ?></a></li>621 <li>+ <a rel="<?php the_ID(); ?>" href="#" class="rel-post-search-result <?php echo $_REQUEST['post_qty']; ?>"><?php the_title(); ?></a></li> 620 622 <?php endwhile; ?> 621 623 </ul>
Note: See TracChangeset
for help on using the changeset viewer.