[youtube_player player_id=”1305″]
Mã nguồn:
Mã html nút check all
| 1 | <input name="allbox" type="checkbox" id="allbox" onclick="CheckAll(this)"> | 
Mã html checkbox item
| 1 | <input type="checkbox" name="delete[]" value="9729"> | 
Mã nút trigger
| 1 | <button style="margin-right: 15px; cursor: pointer;" class="btn btn-danger  btn-lg pull-right" id="delete_all_trigger"><span class="fa fa-trash-o mr-1"></span>Delete reviews selected</button> | 
| 1 2 3 4 5 6 7 8 | function CheckAll(parent){ 	var ids = document.getElementsByTagName('input'); 	for(var i=0; i<ids.length; i++){ 		if(ids[i].name == "delete[]"){ 			ids[i].checked = parent.checked; 		} 	} } | 
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | $('.player_youtube_shortcode').on('click',function(){ 		$(this).select(); 	}); 	$('#delete_all_trigger').on('click',function(e){ 		var array_ids=document.getElementsByName('delete[]'); 		var list_ids =''; 		for(key=0; key < array_ids.length; key++)  { 			if(array_ids[key].checked){ 				if(key == 0){ 					list_ids =array_ids[key].value; 				}else{ 					list_ids = list_ids +","+array_ids[key].value; 				} 			} 		} 		if(list_ids == ''){ 			alert('Chưa chọn player nào để xóa!'); 			return false; 		}else{ 			if (confirm('Bạn có chắc xóa các player đã chọn bên dưới?')){ 				$('#delete_all_trigger span').addClass('fa-spin fa-spinner'); 				$.ajax({ 					type: 'POST', 					url: pywa_vars.ajax_url, 					data:{action: 'delete_all',list_ids:list_ids}, 					success: function(response){ 						console.log(response); 						if('success' == response.status){ 							 location.reload(); 						} 					} 				}); 			}else{ 				return false; 			} 		} 	}); | 
| 1 2 3 4 5 6 7 8 9 10 11 12 | add_action('wp_ajax_delete_all','delete_all'); add_action('wp_ajax_nopriv_delete_all','delete_all'); function delete_all(){ 		$response=array(); 		$response['status']='success'; 		$list_ids=explode(",",$_POST['list_ids']); 		if($list_ids): foreach($list_ids as $list_id): 			wp_delete_post($list_id,true); 		endforeach; endif; 		wp_send_json($response); 		die(); } | 
Mọi sự sao chép xin ghi rõ nguồn là fcwordpress.net
Chuyên trang về wordpress: hướng dẫn thiết kế theme, plugin, thủ thuật wordpress
Chili Comment. Giấy phép không hợp lệ. Kích hoạt tại đây