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