PluginProbe
WP Ultimate Post Grid / 1.7.2
WP Ultimate Post Grid v1.7.2
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / helpers / post_save.php

post_save.php in WP Ultimate Post Grid 1.7.2, at helpers/post_save.php

37 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPUPG_Post_Save {
4
5 public function __construct()
6 {
7 add_action( 'save_post', array( $this, 'save' ), 10, 2 );
8 }
9
10 public function save( $post_id, $post )
11 {
12 if( $post->post_type != WPUPG_POST_TYPE )
13 {
14 if ( !isset( $_POST['wpupg_nonce'] ) || !wp_verify_nonce( $_POST['wpupg_nonce'], 'grid' ) ) {
15 return;
16 }
17
18 // Basic metadata
19 $fields = array(
20 'wpupg_custom_link'
21 );
22
23 foreach ( $fields as $field )
24 {
25 $old = get_post_meta( $post_id, $field, true );
26 $new = isset( $_POST[$field] ) ? $_POST[$field] : null;
27
28 // Update or delete meta data if changed
29 if( isset( $new ) && $new != $old ) {
30 update_post_meta( $post_id, $field, $new );
31 } elseif ( $new == '' && $old ) {
32 delete_post_meta( $post_id, $field, $old );
33 }
34 }
35 }
36 }
37 }