readme file update

This commit is contained in:
magepeopleteam 2019-12-18 10:00:43 +00:00
parent 2d18c82b10
commit d22f34f033
1 changed files with 63 additions and 1 deletions

View File

@ -2189,8 +2189,70 @@ function on_post_publish( $post_id, $post, $update ) {
}
add_action( 'wp_insert_post', 'on_post_publish', 10, 3 );
function mep_count_hidden_wc_product($event_id){
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'link_mep_event',
'value' => $event_id,
'compare' => '='
)
)
);
$loop = new WP_Query($args);
print_r($loop->posts);
return $loop->post_count;
}
add_action('parse_query', 'product_tags_sorting_query');
add_action('save_post','mep_wc_link_product_on_save',99,1);
function mep_wc_link_product_on_save($post_id){
if (get_post_type($post_id) == 'mep_events') {
if ( ! isset( $_POST['mep_event_reg_btn_nonce'] ) ||
! wp_verify_nonce( $_POST['mep_event_reg_btn_nonce'], 'mep_event_reg_btn_nonce' ) )
return;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return;
if (!current_user_can('edit_post', $post_id))
return;
$event_name = get_the_title($post_id);
if(mep_count_hidden_wc_product($post_id) == 0 || empty(get_post_meta($post_id,'link_wc_product',true))){
mep_create_hidden_event_product($post_id,$event_name);
}
$product_id = get_post_meta($post_id,'link_wc_product',true) ? get_post_meta($post_id,'link_wc_product',true) : $post_id;
// Update post
$my_post = array(
'ID' => $product_id,
'post_title' => $event_name, // new title
);
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'mep_wc_link_product_on_save');
// update the post, which calls save_post again
wp_update_post( $my_post );
// re-hook this function
add_action('save_post', 'mep_wc_link_product_on_save');
// Update the post into the database
}
}
// add_action('parse_query', 'product_tags_sorting_query');
function product_tags_sorting_query($query) {
global $pagenow;