| @@ 66-99 (lines=34) @@ | ||
| 63 | * @return $options (array) |
|
| 64 | */ |
|
| 65 | ||
| 66 | function rule_match_post_type( $match, $rule, $options ) { |
|
| 67 | ||
| 68 | // vars |
|
| 69 | $post_type = $options['post_type']; |
|
| 70 | ||
| 71 | ||
| 72 | // find post type for current post |
|
| 73 | if( !$post_type ) { |
|
| 74 | ||
| 75 | if( !$options['post_id'] ) { |
|
| 76 | ||
| 77 | return false; |
|
| 78 | ||
| 79 | } |
|
| 80 | ||
| 81 | $post_type = get_post_type( $options['post_id'] ); |
|
| 82 | } |
|
| 83 | ||
| 84 | ||
| 85 | // compare |
|
| 86 | if( $rule['operator'] == "==" ) { |
|
| 87 | ||
| 88 | $match = ( $post_type === $rule['value'] ); |
|
| 89 | ||
| 90 | } elseif( $rule['operator'] == "!=" ) { |
|
| 91 | ||
| 92 | $match = ( $post_type !== $rule['value'] ); |
|
| 93 | ||
| 94 | } |
|
| 95 | ||
| 96 | ||
| 97 | // return |
|
| 98 | return $match; |
|
| 99 | } |
|
| 100 | ||
| 101 | ||
| 102 | /* |
|
| @@ 478-515 (lines=38) @@ | ||
| 475 | * @return $options (array) |
|
| 476 | */ |
|
| 477 | ||
| 478 | function rule_match_post_status( $match, $rule, $options ) { |
|
| 479 | ||
| 480 | // validate |
|
| 481 | if( !$options['post_id'] ) { |
|
| 482 | ||
| 483 | return false; |
|
| 484 | ||
| 485 | } |
|
| 486 | ||
| 487 | ||
| 488 | // vars |
|
| 489 | $post_status = get_post_status( $options['post_id'] ); |
|
| 490 | ||
| 491 | ||
| 492 | // auto-draft = draft |
|
| 493 | if( $post_status == 'auto-draft' ) { |
|
| 494 | ||
| 495 | $post_status = 'draft'; |
|
| 496 | ||
| 497 | } |
|
| 498 | ||
| 499 | ||
| 500 | // compare |
|
| 501 | if( $rule['operator'] == "==") { |
|
| 502 | ||
| 503 | $match = ( $post_status === $rule['value'] ); |
|
| 504 | ||
| 505 | } elseif( $rule['operator'] == "!=") { |
|
| 506 | ||
| 507 | $match = ( $post_status !== $rule['value'] ); |
|
| 508 | ||
| 509 | } |
|
| 510 | ||
| 511 | ||
| 512 | // return |
|
| 513 | return $match; |
|
| 514 | ||
| 515 | } |
|
| 516 | ||
| 517 | ||
| 518 | /* |
|