| @@ 187-211 (lines=25) @@ | ||
| 184 | * |
|
| 185 | * @return bool True if update was successful, false if not. |
|
| 186 | */ |
|
| 187 | public function set_custom_taxonomy( $postid, $value) { |
|
| 188 | ||
| 189 | if( $value ) { |
|
| 190 | // first check if multiple, make array if so. |
|
| 191 | if ( self::has_multiple_objects( $value ) ) { |
|
| 192 | $value = explode( ',', $value ); |
|
| 193 | } |
|
| 194 | ||
| 195 | // Deleting first array item |
|
| 196 | $taxonomy = array_shift($value); |
|
| 197 | $cats = array(); |
|
| 198 | foreach ($value as $cat) { |
|
| 199 | $cats [] = get_cat_ID($cat); |
|
| 200 | } |
|
| 201 | $value = $cats; |
|
| 202 | ||
| 203 | ||
| 204 | $result = wp_set_object_terms( $postid, $cats, $taxonomy ); |
|
| 205 | if ( ! is_wp_error( $result ) ) { |
|
| 206 | return true; |
|
| 207 | }else{ |
|
| 208 | return false; |
|
| 209 | } |
|
| 210 | } |
|
| 211 | } |
|
| 212 | ||
| 213 | public function set_date( $postid, $value) { |
|
| 214 | ||
| @@ 425-450 (lines=26) @@ | ||
| 422 | ||
| 423 | exit; |
|
| 424 | } |
|
| 425 | public function set_post_terms( $postid, $value, $taxonomy ) { |
|
| 426 | if( $value ) { |
|
| 427 | $value = explode( ',', $value ); |
|
| 428 | ||
| 429 | if ($taxonomy =='category') { |
|
| 430 | // convert from names to category ids |
|
| 431 | $cats = array(); |
|
| 432 | foreach ($value as $cat) { |
|
| 433 | $cats [] = get_cat_ID($cat); |
|
| 434 | } |
|
| 435 | $value = $cats; |
|
| 436 | } |
|
| 437 | ||
| 438 | $result = wp_set_object_terms( $postid, $value, $taxonomy ); |
|
| 439 | } |
|
| 440 | else { |
|
| 441 | //remove all terms from post |
|
| 442 | $result = wp_set_object_terms( $postid, null, $taxonomy ); |
|
| 443 | } |
|
| 444 | ||
| 445 | if ( ! is_wp_error( $result ) ) { |
|
| 446 | return true; |
|
| 447 | }else{ |
|
| 448 | return false; |
|
| 449 | } |
|
| 450 | } |
|
| 451 | ||
| 452 | public function set_date( $postid, $value) { |
|
| 453 | if( $value ) { |
|