@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * Queries the database for all of the supported posts. |
| 44 | 44 | * |
| 45 | - * @param bool $force |
|
| 46 | - * |
|
| 47 | - * @return Writing_On_GitHub_Post[]|WP_Error |
|
| 48 | - */ |
|
| 45 | + * @param bool $force |
|
| 46 | + * |
|
| 47 | + * @return Writing_On_GitHub_Post[]|WP_Error |
|
| 48 | + */ |
|
| 49 | 49 | public function fetch_all_supported( $force = false ) { |
| 50 | 50 | $args = array( |
| 51 | 51 | 'post_type' => $this->get_whitelisted_post_types(), |
@@ -187,45 +187,45 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // update tags |
| 189 | 189 | if ( isset( $meta['tags'] ) && $meta['tags'] ) { |
| 190 | - $args['tags_input'] = $meta['tags']; |
|
| 190 | + $args['tags_input'] = $meta['tags']; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // update categories |
| 194 | 194 | if ( isset( $meta['categories'] ) && $meta['categories'] ) { |
| 195 | - $categories = $meta['categories']; |
|
| 196 | - if (!is_array($categories)) { |
|
| 197 | - $categories = array($categories); |
|
| 198 | - } |
|
| 199 | - $terms = get_terms(array( |
|
| 200 | - 'taxonomy' => 'category', |
|
| 201 | - 'fields' => 'id=>name', |
|
| 202 | - 'hide_empty' => 0, |
|
| 203 | - 'name' => $categories |
|
| 204 | - ) |
|
| 205 | - ); |
|
| 206 | - $map = array(); |
|
| 207 | - foreach ($categories as $name) { |
|
| 208 | - $map[$name] = 1; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $ids = array(); |
|
| 212 | - if (!empty($terms)) { |
|
| 213 | - foreach ($terms as $id => $name) { |
|
| 214 | - $ids[] = $id; |
|
| 215 | - unset($map[$name]); |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // create new terms |
|
| 220 | - if (!empty($map)) { |
|
| 221 | - foreach ($map as $name => $value) { |
|
| 222 | - $term = wp_insert_term($name, 'category', array('parent' => 0)); |
|
| 223 | - // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
|
| 224 | - $ids[] = $term['term_id']; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - $args['post_category'] = $ids; |
|
| 195 | + $categories = $meta['categories']; |
|
| 196 | + if (!is_array($categories)) { |
|
| 197 | + $categories = array($categories); |
|
| 198 | + } |
|
| 199 | + $terms = get_terms(array( |
|
| 200 | + 'taxonomy' => 'category', |
|
| 201 | + 'fields' => 'id=>name', |
|
| 202 | + 'hide_empty' => 0, |
|
| 203 | + 'name' => $categories |
|
| 204 | + ) |
|
| 205 | + ); |
|
| 206 | + $map = array(); |
|
| 207 | + foreach ($categories as $name) { |
|
| 208 | + $map[$name] = 1; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $ids = array(); |
|
| 212 | + if (!empty($terms)) { |
|
| 213 | + foreach ($terms as $id => $name) { |
|
| 214 | + $ids[] = $id; |
|
| 215 | + unset($map[$name]); |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // create new terms |
|
| 220 | + if (!empty($map)) { |
|
| 221 | + foreach ($map as $name => $value) { |
|
| 222 | + $term = wp_insert_term($name, 'category', array('parent' => 0)); |
|
| 223 | + // array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
|
| 224 | + $ids[] = $term['term_id']; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + $args['post_category'] = $ids; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | return $args; |
@@ -427,12 +427,12 @@ discard block |
||
| 427 | 427 | if ( ! empty( $display_name ) ) { |
| 428 | 428 | $search_string = esc_attr( $display_name ); |
| 429 | 429 | $query = new WP_User_Query( array( |
| 430 | - 'search' => "{$search_string}", |
|
| 431 | - 'search_columns' => array( |
|
| 432 | - 'display_name', |
|
| 433 | - 'user_nicename', |
|
| 434 | - 'user_login', |
|
| 435 | - ) |
|
| 430 | + 'search' => "{$search_string}", |
|
| 431 | + 'search_columns' => array( |
|
| 432 | + 'display_name', |
|
| 433 | + 'user_nicename', |
|
| 434 | + 'user_login', |
|
| 435 | + ) |
|
| 436 | 436 | ) ); |
| 437 | 437 | $users = $query->get_results(); |
| 438 | 438 | $user = empty($users) ? false : $users[0]; |