| @@ 275-306 (lines=32) @@ | ||
| 272 | $has_media = isset( $input['media'] ) && $input['media'] ? count( $input['media'] ) : false; |
|
| 273 | $has_media_by_url = isset( $input['media_urls'] ) && $input['media_urls'] ? count( $input['media_urls'] ) : false; |
|
| 274 | ||
| 275 | if ( $new ) { |
|
| 276 | ||
| 277 | if ( isset( $input['content'] ) && ! has_shortcode( $input['content'], 'gallery' ) && ( $has_media || $has_media_by_url ) ) { |
|
| 278 | switch ( ( $has_media + $has_media_by_url ) ) { |
|
| 279 | case 0 : |
|
| 280 | // No images - do nothing. |
|
| 281 | break; |
|
| 282 | case 1 : |
|
| 283 | // 1 image - make it big |
|
| 284 | $insert['post_content'] = $input['content'] = "[gallery size=full columns=1]\n\n" . $input['content']; |
|
| 285 | break; |
|
| 286 | default : |
|
| 287 | // Several images - 3 column gallery |
|
| 288 | $insert['post_content'] = $input['content'] = "[gallery]\n\n" . $input['content']; |
|
| 289 | break; |
|
| 290 | } |
|
| 291 | } |
|
| 292 | ||
| 293 | $post_id = wp_insert_post( add_magic_quotes( $insert ), true ); |
|
| 294 | } else { |
|
| 295 | $insert['ID'] = $post->ID; |
|
| 296 | ||
| 297 | // wp_update_post ignores date unless edit_date is set |
|
| 298 | // See: http://codex.wordpress.org/Function_Reference/wp_update_post#Scheduling_posts |
|
| 299 | // See: https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-includes/post.php#L3302 |
|
| 300 | if ( isset( $input['date_gmt'] ) || isset( $input['date'] ) ) { |
|
| 301 | $insert['edit_date'] = true; |
|
| 302 | } |
|
| 303 | ||
| 304 | $post_id = wp_update_post( (object) $insert ); |
|
| 305 | ||
| 306 | } |
|
| 307 | ||
| 308 | if ( !$post_id || is_wp_error( $post_id ) ) { |
|
| 309 | return $post_id; |
|
| @@ 289-319 (lines=31) @@ | ||
| 286 | $has_media = ! empty( $input['media'] ) ? count( $input['media'] ) : false; |
|
| 287 | $has_media_by_url = ! empty( $input['media_urls'] ) ? count( $input['media_urls'] ) : false; |
|
| 288 | ||
| 289 | if ( $new ) { |
|
| 290 | ||
| 291 | if ( isset( $input['content'] ) && ! has_shortcode( $input['content'], 'gallery' ) && ( $has_media || $has_media_by_url ) ) { |
|
| 292 | switch ( ( $has_media + $has_media_by_url ) ) { |
|
| 293 | case 0 : |
|
| 294 | // No images - do nothing. |
|
| 295 | break; |
|
| 296 | case 1 : |
|
| 297 | // 1 image - make it big |
|
| 298 | $insert['post_content'] = $input['content'] = "[gallery size=full columns=1]\n\n" . $input['content']; |
|
| 299 | break; |
|
| 300 | default : |
|
| 301 | // Several images - 3 column gallery |
|
| 302 | $insert['post_content'] = $input['content'] = "[gallery]\n\n" . $input['content']; |
|
| 303 | break; |
|
| 304 | } |
|
| 305 | } |
|
| 306 | ||
| 307 | $post_id = wp_insert_post( add_magic_quotes( $insert ), true ); |
|
| 308 | } else { |
|
| 309 | $insert['ID'] = $post->ID; |
|
| 310 | ||
| 311 | // wp_update_post ignores date unless edit_date is set |
|
| 312 | // See: http://codex.wordpress.org/Function_Reference/wp_update_post#Scheduling_posts |
|
| 313 | // See: https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-includes/post.php#L3302 |
|
| 314 | if ( isset( $input['date_gmt'] ) || isset( $input['date'] ) ) { |
|
| 315 | $insert['edit_date'] = true; |
|
| 316 | } |
|
| 317 | ||
| 318 | $post_id = wp_update_post( (object) $insert ); |
|
| 319 | } |
|
| 320 | ||
| 321 | ||
| 322 | if ( !$post_id || is_wp_error( $post_id ) ) { |
|
| @@ 289-319 (lines=31) @@ | ||
| 286 | $has_media = ! empty( $input['media'] ) ? count( $input['media'] ) : false; |
|
| 287 | $has_media_by_url = ! empty( $input['media_urls'] ) ? count( $input['media_urls'] ) : false; |
|
| 288 | ||
| 289 | if ( $new ) { |
|
| 290 | ||
| 291 | if ( isset( $input['content'] ) && ! has_shortcode( $input['content'], 'gallery' ) && ( $has_media || $has_media_by_url ) ) { |
|
| 292 | switch ( ( $has_media + $has_media_by_url ) ) { |
|
| 293 | case 0 : |
|
| 294 | // No images - do nothing. |
|
| 295 | break; |
|
| 296 | case 1 : |
|
| 297 | // 1 image - make it big |
|
| 298 | $insert['post_content'] = $input['content'] = "[gallery size=full columns=1]\n\n" . $input['content']; |
|
| 299 | break; |
|
| 300 | default : |
|
| 301 | // Several images - 3 column gallery |
|
| 302 | $insert['post_content'] = $input['content'] = "[gallery]\n\n" . $input['content']; |
|
| 303 | break; |
|
| 304 | } |
|
| 305 | } |
|
| 306 | ||
| 307 | $post_id = wp_insert_post( add_magic_quotes( $insert ), true ); |
|
| 308 | } else { |
|
| 309 | $insert['ID'] = $post->ID; |
|
| 310 | ||
| 311 | // wp_update_post ignores date unless edit_date is set |
|
| 312 | // See: http://codex.wordpress.org/Function_Reference/wp_update_post#Scheduling_posts |
|
| 313 | // See: https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-includes/post.php#L3302 |
|
| 314 | if ( isset( $input['date_gmt'] ) || isset( $input['date'] ) ) { |
|
| 315 | $insert['edit_date'] = true; |
|
| 316 | } |
|
| 317 | ||
| 318 | $post_id = wp_update_post( (object) $insert ); |
|
| 319 | } |
|
| 320 | ||
| 321 | ||
| 322 | if ( !$post_id || is_wp_error( $post_id ) ) { |
|