Changeset 1589
- Timestamp:
- 05/15/2015 11:39:46 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
r1588 r1589 109 109 110 110 // WordCamp post type only 111 // todo return early if not type instead of indenting 112 if ( WCPT_POST_TYPE_ID == get_post_type() ) { 113 // If the venue address was changed, update its coordinates 114 $new_address = $_POST[ wcpt_key_to_str( 'Physical Address', 'wcpt_' ) ]; 115 if ( $new_address != get_post_meta( $post_id, 'Physical Address', true ) ) { 116 if ( $coordinates = $this->geocode_address( $new_address ) ) { 117 update_post_meta( $post_id, '_venue_coordinates', $coordinates ); 118 } else { 119 delete_post_meta( $post_id, '_venue_coordinates' ); 120 } 111 if ( WCPT_POST_TYPE_ID != get_post_type() ) { 112 return; 113 } 114 115 // If the venue address was changed, update its coordinates 116 $new_address = $_POST[ wcpt_key_to_str( 'Physical Address', 'wcpt_' ) ]; 117 if ( $new_address != get_post_meta( $post_id, 'Physical Address', true ) ) { 118 if ( $coordinates = $this->geocode_address( $new_address ) ) { 119 update_post_meta( $post_id, '_venue_coordinates', $coordinates ); 120 } else { 121 delete_post_meta( $post_id, '_venue_coordinates' ); 121 122 } 122 123 // Post meta keys 124 $wcpt_meta_keys = WordCamp_Admin::meta_keys();125 126 // Loop through meta keys and update 127 foreach ( $wcpt_meta_keys as $key => $value ) {128 129 // Get post value 130 $post_value = wcpt_key_to_str( $key, 'wcpt_' );131 $values[ $key ] = isset( $_POST[ $post_value ] ) ? esc_attr( $_POST[ $post_value ] ) : '';132 133 switch ( $value ) { 134 case 'text' :135 case 'textarea':136 update_post_meta( $post_id, $key, $values[ $key ] );137 break;138 139 case 'checkbox' : 140 if ( ! empty( $values[ $key ] ) && 'on' == $values[ $key ] ) {141 update_post_meta( $post_id, $key, true );142 } else {143 update_post_meta( $post_id, $key, false );144 }145 break;146 147 case 'date' : 148 if ( !empty( $values[ $key ] ) )149 $values[ $key ] = strtotime( $values[ $key ] );150 151 update_post_meta( $post_id, $key, $values[ $key ] ); 152 break;153 154 default: 155 do_action( 'wcpt_metabox_save', $key, $value, $post_id );156 break;157 }123 } 124 125 // Post meta keys 126 $wcpt_meta_keys = WordCamp_Admin::meta_keys(); 127 128 // Loop through meta keys and update 129 foreach ( $wcpt_meta_keys as $key => $value ) { 130 131 // Get post value 132 $post_value = wcpt_key_to_str( $key, 'wcpt_' ); 133 $values[ $key ] = isset( $_POST[ $post_value ] ) ? esc_attr( $_POST[ $post_value ] ) : ''; 134 135 switch ( $value ) { 136 case 'text' : 137 case 'textarea' : 138 update_post_meta( $post_id, $key, $values[ $key ] ); 139 break; 140 141 case 'checkbox' : 142 if ( ! empty( $values[ $key ] ) && 'on' == $values[ $key ] ) { 143 update_post_meta( $post_id, $key, true ); 144 } else { 145 update_post_meta( $post_id, $key, false ); 146 } 147 break; 148 149 case 'date' : 150 if ( !empty( $values[ $key ] ) ) 151 $values[ $key ] = strtotime( $values[ $key ] ); 152 153 update_post_meta( $post_id, $key, $values[ $key ] ); 154 break; 155 156 default: 157 do_action( 'wcpt_metabox_save', $key, $value, $post_id ); 158 break; 158 159 } 159 160 }
Note: See TracChangeset
for help on using the changeset viewer.