ID); $images = json_decode(stripslashes($listing_stored_meta["listing_gallery"][0])); $html_content ='
| '; if( !empty( $listing_stored_meta["listing_user"] ) ) { $listing_user = esc_attr( $listing_stored_meta["listing_user"][0] ); $userObj = get_user_by('id',$listing_user); $display_name = $userObj->display_name; }else{ $listing_user=''; $display_name=''; } $html .=' | |
| post_title).'+'.str_replace(" ","+",$post->post_content); $html .=$listing_metadata; $html .='" />'; return $html; } public static function add_feature(){ //wp_send_json_error('you suck'); if(!check_ajax_referer('wp-adlisting-ajax','security')){ return wp_send_json_error('invalid nonce'); } if(!current_user_can( 'manage_options' )){ return wp_send_json_error('You don\'t have Auth... '); } $data = $_POST["adlAjaxData"]; if(is_array($data)){ if($data['action']=="add_feature_list") { if($data['feature']=='true'){$feature_status='Featured';}else{$feature_status='Unfeatured';} update_post_meta( $data['id'],'listing_feature',sanitize_text_field( $feature_status ) ); wp_send_json_success('Listing ID :'.$data['id'].' is now '.$feature_status); } } } public static function save_listing( $post_id ) { global $post; $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id ); $listing_detail_nonce = ( isset( $_POST["listing_detail_meta_nonce"] ) && wp_verify_nonce( $_POST["listing_detail_meta_nonce"],"add_listing_detail" ) ) ? 'true' : 'false'; $listing_gallery_nonce = ( isset( $_POST["listing_gallery_meta_nonce"] ) && wp_verify_nonce( $_POST["listing_gallery_meta_nonce"],'add_image_listing_gallery' ) ) ? 'true' : 'false'; //exist script depending on save status if($is_autosave || $is_revision || !$listing_detail_nonce || !$listing_gallery_nonce) { return; } //repeat how many you have meta tag if( isset( $_POST["listing_user"] ) ) { update_post_meta( $post_id,'listing_user',sanitize_text_field( $_POST["listing_user"] ) ); } if( isset( $_POST["listing_contact"] ) ) { update_post_meta( $post_id,'listing_contact',sanitize_text_field( $_POST["listing_contact"] ) ); } if( isset( $_POST["listing_email"] ) ) { update_post_meta( $post_id,'listing_email',sanitize_text_field( $_POST["listing_email"] ) ); } if( isset( $_POST["listing_address"] ) ) { update_post_meta( $post_id,'listing_address',sanitize_text_field( $_POST["listing_address"] ) ); } if( isset( $_POST["listing_gallery"] ) ) { $images = json_decode( stripslashes( $_POST[ 'listing_gallery' ] ) ); $selected_images = array(); if(is_array($images)){ foreach($images as $image) { $selected_images[] = array("id"=>$image->id,"url"=>$image->url); } $images=json_encode($selected_images); }else{$images='';} update_post_meta( $post_id,'listing_gallery', $images ); } if( isset( $_POST["listing_shot_desc"] ) ) { update_post_meta( $post_id,'listing_shot_desc',sanitize_text_field( $_POST["listing_shot_desc"] ) ); } if( isset( $_POST["listing_feature"] ) ) { update_post_meta( $post_id,'listing_feature',sanitize_text_field( $_POST["listing_feature"] ) ); } if( isset( $_POST["listing_metadata"] ) ) { update_post_meta( $post_id,'listing_metadata',sanitize_text_field( $_POST["listing_metadata"] ) ); } } } ADL_Admin_Post_types::init(); ?> |