Created
September 14, 2016 16:22
-
-
Save nayemDevs/e9204f1511abe13b5beeac519539c5c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpufe_update_post_geo1( $post_id ) { | |
function gmw_update_post_type_post_location( $post_id ) { | |
// Return if it's a post revision | |
if ( false !== wp_is_post_revision( $post_id ) ) | |
return; | |
// check autosave // | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { | |
return; | |
} | |
//check if user can edit post | |
if ( !current_user_can( 'edit_post', $post_id ) ) | |
return; | |
//get the address from the custom field "location" | |
$address = get_post_meta( $post_id, 'location', true ); | |
//varify that address exists. Otherwise abort the function. | |
if ( empty( $address ) ) | |
return; | |
//include the update location file | |
include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' ); | |
//make sure the file included and the function exists | |
if ( !function_exists( 'gmw_pt_update_location' ) ) | |
return; | |
//Create the array that will pass to the function | |
$args = array( | |
'post_id' => $post_id, //Post Id of the post | |
'address' => $address // the address we pull from the custom field above | |
); | |
//run the udpate location function | |
gmw_pt_update_location( $args ); | |
} | |
gmw_update_post_type_post_location($post_id); | |
//execute the function whenever post type is being updated | |
//add_action( 'save_post_post', 'gmw_update_post_type_post_location' ); | |
} | |
add_action( 'wpuf_add_post_after_insert', 'wpufe_update_post_geo1' ); | |
function wpufe_update_post_geo2( $post_id ) { | |
function gmw_update_post_type_post_location( $post_id ) { | |
// Return if it's a post revision | |
if ( false !== wp_is_post_revision( $post_id ) ) | |
return; | |
// check autosave // | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { | |
return; | |
} | |
//check if user can edit post | |
if ( !current_user_can( 'edit_post', $post_id ) ) | |
return; | |
//get the address from the custom field "location" | |
$address = get_post_meta( $post_id, 'location', true ); | |
//varify that address exists. Otherwise abort the function. | |
if ( empty( $address ) ) | |
return; | |
//include the update location file | |
include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' ); | |
//make sure the file included and the function exists | |
if ( !function_exists( 'gmw_pt_update_location' ) ) | |
return; | |
//Create the array that will pass to the function | |
$args = array( | |
'post_id' => $post_id, //Post Id of the post | |
'address' => $address // the address we pull from the custom field above | |
); | |
//run the udpate location function | |
gmw_pt_update_location( $args ); | |
} | |
gmw_update_post_type_post_location($post_id); | |
//execute the function whenever post type is being updated | |
//add_action( 'save_post_post', 'gmw_update_post_type_post_location' ); | |
} | |
add_action( 'wpuf_edit_post_after_update', 'wpufe_update_post_geo2' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment