Diff
checker
टेक्स्ट
टेक्स्ट
छवियां
दस्तावेज़
Excel
फ़ोल्डर्स
Legal
Enterprise
डेस्कटॉप
मूल्य
साइन इन करें
Diffchecker डेस्कटॉप डाउनलोड करें
टेक्स्ट की तुलना करें
दो टेक्स्ट फ़ाइलों के बीच अंतर ढूंढें
उपकरण
इतिहास
रियल-टाइम एडिटर
अपरिवर्तित संक्षिप्त करें
लाइन रैप बंद
लेआउट
विभाजित
संयुक्त
परिवर्तन हाइलाइट करें
स्मार्ट
शब्द
अक्षर
सिंटैक्स हाइलाइटिंग
सिंटैक्स चुनें
अनदेखा करें
टेक्स्ट बदलें
पहले अंतर पर जाएँ
इनपुट संपादित करें
Diffchecker Desktop
Diffchecker चलाने का सबसे सुरक्षित तरीका। Diffchecker Desktop ऐप पाएं: आपके diffs कभी आपके कंप्यूटर से बाहर नहीं जाते!
Desktop पाएं
Untitled diff
बनाया गया
11 वर्ष पहले
Diff कभी समाप्त नहीं होता
साफ़
निर्यात करें
शेयर करें
समझाएं
2 हटाए गए
लाइनें
कुल
हटाया गया
अक्षर
कुल
हटाया गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diff
checker
Pro
मूल्य देखें
144 लाइनें
सभी को कॉपी करें
3 जोड़े गए
लाइनें
कुल
जोड़ा गया
अक्षर
कुल
जोड़ा गया
इस सुविधा का उपयोग जारी रखने के लिए, अपग्रेड करें
Diff
checker
Pro
मूल्य देखें
144 लाइनें
सभी को कॉपी करें
<?php
<?php
/**
/**
* Attachment Uploader class
* Attachment Uploader class
*
*
* @since 1.0
* @since 1.0
* @package wpuf
* @package wpuf
*/
*/
class WPUF_Upload {
class WPUF_Upload {
function __construct() {
function __construct() {
add_action( 'wp_ajax_wpuf_file_upload', array($this, 'upload_file') );
add_action( 'wp_ajax_wpuf_file_upload', array($this, 'upload_file') );
add_action( 'wp_ajax_nopriv_wpuf_file_upload', array($this, 'upload_file') );
add_action( 'wp_ajax_nopriv_wpuf_file_upload', array($this, 'upload_file') );
add_action( 'wp_ajax_wpuf_file_del', array($this, 'delete_file') );
add_action( 'wp_ajax_wpuf_file_del', array($this, 'delete_file') );
add_action( 'wp_ajax_nopriv_wpuf_file_del', array($this, 'delete_file') );
add_action( 'wp_ajax_nopriv_wpuf_file_del', array($this, 'delete_file') );
add_action( 'wp_ajax_wpuf_insert_image', array( $this, 'insert_image' ) );
add_action( 'wp_ajax_wpuf_insert_image', array( $this, 'insert_image' ) );
add_action( 'wp_ajax_nopriv_wpuf_insert_image', array( $this, 'insert_image' ) );
add_action( 'wp_ajax_nopriv_wpuf_insert_image', array( $this, 'insert_image' ) );
}
}
function upload_file( $image_only = false ) {
function upload_file( $image_only = false ) {
$upload = array(
$upload = array(
'name' => $_FILES['wpuf_file']['name'],
'name' => $_FILES['wpuf_file']['name'],
'type' => $_FILES['wpuf_file']['type'],
'type' => $_FILES['wpuf_file']['type'],
'tmp_name' => $_FILES['wpuf_file']['tmp_name'],
'tmp_name' => $_FILES['wpuf_file']['tmp_name'],
'error' => $_FILES['wpuf_file']['error'],
'error' => $_FILES['wpuf_file']['error'],
'size' => $_FILES['wpuf_file']['size']
'size' => $_FILES['wpuf_file']['size']
);
);
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
header('Content-Type: text/html; charset=' . get_option('blog_charset'));
$attach = $this->handle_upload( $upload );
$attach = $this->handle_upload( $upload );
if ( $attach['success'] ) {
if ( $attach['success'] ) {
$response = array( 'success' => true );
$response = array( 'success' => true );
if ($image_only) {
if ($image_only) {
$response['html'] = wp_get_attachment_image( $attach['attach_id'], 'full' );
$response['html'] = wp_get_attachment_image( $attach['attach_id'], 'full' );
} else {
} else {
$response['html'] = $this->attach_html( $attach['attach_id'] );
$response['html'] = $this->attach_html( $attach['attach_id'] );
// $response['html'] = wp_get_attachment_image( $attach['attach_id'], 'thumbnail' );
// $response['html'] = wp_get_attachment_image( $attach['attach_id'], 'thumbnail' );
}
}
echo $response['html'];
echo $response['html'];
} else {
} else {
echo 'error';
echo 'error';
}
}
// $response = array('success' => false, 'message' => $attach['error']);
// $response = array('success' => false, 'message' => $attach['error']);
// echo json_encode( $response );
// echo json_encode( $response );
exit;
exit;
}
}
/**
/**
* Generic function to upload a file
* Generic function to upload a file
*
*
* @param string $field_name file input field name
* @param string $field_name file input field name
* @return bool|int attachment id on success, bool false instead
* @return bool|int attachment id on success, bool false instead
*/
*/
function handle_upload( $upload_data ) {
function handle_upload( $upload_data ) {
$uploaded_file = wp_handle_upload( $upload_data, array('test_form' => false) );
$uploaded_file = wp_handle_upload( $upload_data, array('test_form' => false) );
// If the wp_handle_upload call returned a local path for the image
// If the wp_handle_upload call returned a local path for the image
if ( isset( $uploaded_file['file'] ) ) {
if ( isset( $uploaded_file['file'] ) ) {
$file_loc = $uploaded_file['file'];
$file_loc = $uploaded_file['file'];
$file_name = basename( $upload_data['name'] );
$file_name = basename( $upload_data['name'] );
$file_type = wp_check_filetype( $file_name );
$file_type = wp_check_filetype( $file_name );
$attachment = array(
$attachment = array(
'post_mime_type' => $file_type['type'],
'post_mime_type' => $file_type['type'],
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_name ) ),
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_name ) ),
'post_content' => '',
'post_content' => '',
'post_status' => 'inherit'
'post_status' => 'inherit'
);
);
$attach_id = wp_insert_attachment( $attachment, $file_loc );
$attach_id = wp_insert_attachment( $attachment, $file_loc );
$attach_data = wp_generate_attachment_metadata( $attach_id, $file_loc );
$attach_data = wp_generate_attachment_metadata( $attach_id, $file_loc );
wp_update_attachment_metadata( $attach_id, $attach_data );
wp_update_attachment_metadata( $attach_id, $attach_data );
return array('success' => true, 'attach_id' => $attach_id);
return array('success' => true, 'attach_id' => $attach_id);
}
}
return array('success' => false, 'error' => $uploaded_file['error']);
return array('success' => false, 'error' => $uploaded_file['error']);
}
}
public static function attach_html( $attach_id, $type = NULL ) {
public static function attach_html( $attach_id, $type = NULL ) {
if ( !$type ) {
if ( !$type ) {
$type = isset( $_GET['type'] ) ? $_GET['type'] : 'image';
$type = isset( $_GET['type'] ) ? $_GET['type'] : 'image';
}
}
$attachment = get_post( $attach_id );
$attachment = get_post( $attach_id );
if (!$attachment) {
if (!$attachment) {
return;
return;
}
}
if (wp_attachment_is_image( $attach_id)) {
if (wp_attachment_is_image( $attach_id)) {
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
$image = wp_get_attachment_image_src( $attach_id, '
thumbnail
' );
$image = wp_get_attachment_image_src( $attach_id, '
full
' );
$image = $image[0];
$image = $image[0];
} else {
} else {
$image = wp_mime_type_icon( $attach_id );
$image = wp_mime_type_icon( $attach_id );
}
}
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
$html = '<li class="image-wrap thumbnail"
style="width: 150px"
>';
$html = '<li class="image-wrap thumbnail"
>';
$html .= sprintf( '<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr( $attachment->post_title ) );
$html .= sprintf( '<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr( $attachment->post_title ) );
कॉपी
कॉपी हुआ
कॉपी
कॉपी हुआ
$html .= sprintf( '<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __( '
Delete
', 'wpuf' ) );
$html .= sprintf( '<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __( '
<span>[X]</span>
Delete
Image
', 'wpuf' ) );
$html .= sprintf( '<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id );
$html .= sprintf( '<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id );
$html .= '</li>';
$html .= '</li>';
return $html;
return $html;
}
}
function delete_file() {
function delete_file() {
check_ajax_referer( 'wpuf_nonce', 'nonce' );
check_ajax_referer( 'wpuf_nonce', 'nonce' );
$attach_id = isset( $_POST['attach_id'] ) ? intval( $_POST['attach_id'] ) : 0;
$attach_id = isset( $_POST['attach_id'] ) ? intval( $_POST['attach_id'] ) : 0;
$attachment = get_post( $attach_id );
$attachment = get_post( $attach_id );
//post author or editor role
//post author or editor role
if ( get_current_user_id() == $attachment->post_author || current_user_can( 'delete_private_pages' ) ) {
if ( get_current_user_id() == $attachment->post_author || current_user_can( 'delete_private_pages' ) ) {
wp_delete_attachment( $attach_id, true );
wp_delete_attachment( $attach_id, true );
echo 'success';
echo 'success';
}
}
exit;
exit;
}
}
function associate_file( $attach_id, $post_id ) {
function associate_file( $attach_id, $post_id ) {
wp_update_post( array(
wp_update_post( array(
'ID' => $attach_id,
'ID' => $attach_id,
'post_parent' => $post_id
'post_parent' => $post_id
) );
) );
}
}
function insert_image() {
function insert_image() {
$this->upload_file( true );
$this->upload_file( true );
}
}
}
}
सेव किए गए Diffs
ऑरिजनल टेक्स्ट
फ़ाइल खोलें
<?php /** * Attachment Uploader class * * @since 1.0 * @package wpuf */ class WPUF_Upload { function __construct() { add_action( 'wp_ajax_wpuf_file_upload', array($this, 'upload_file') ); add_action( 'wp_ajax_nopriv_wpuf_file_upload', array($this, 'upload_file') ); add_action( 'wp_ajax_wpuf_file_del', array($this, 'delete_file') ); add_action( 'wp_ajax_nopriv_wpuf_file_del', array($this, 'delete_file') ); add_action( 'wp_ajax_wpuf_insert_image', array( $this, 'insert_image' ) ); add_action( 'wp_ajax_nopriv_wpuf_insert_image', array( $this, 'insert_image' ) ); } function upload_file( $image_only = false ) { $upload = array( 'name' => $_FILES['wpuf_file']['name'], 'type' => $_FILES['wpuf_file']['type'], 'tmp_name' => $_FILES['wpuf_file']['tmp_name'], 'error' => $_FILES['wpuf_file']['error'], 'size' => $_FILES['wpuf_file']['size'] ); header('Content-Type: text/html; charset=' . get_option('blog_charset')); $attach = $this->handle_upload( $upload ); if ( $attach['success'] ) { $response = array( 'success' => true ); if ($image_only) { $response['html'] = wp_get_attachment_image( $attach['attach_id'], 'full' ); } else { $response['html'] = $this->attach_html( $attach['attach_id'] ); // $response['html'] = wp_get_attachment_image( $attach['attach_id'], 'thumbnail' ); } echo $response['html']; } else { echo 'error'; } // $response = array('success' => false, 'message' => $attach['error']); // echo json_encode( $response ); exit; } /** * Generic function to upload a file * * @param string $field_name file input field name * @return bool|int attachment id on success, bool false instead */ function handle_upload( $upload_data ) { $uploaded_file = wp_handle_upload( $upload_data, array('test_form' => false) ); // If the wp_handle_upload call returned a local path for the image if ( isset( $uploaded_file['file'] ) ) { $file_loc = $uploaded_file['file']; $file_name = basename( $upload_data['name'] ); $file_type = wp_check_filetype( $file_name ); $attachment = array( 'post_mime_type' => $file_type['type'], 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_name ) ), 'post_content' => '', 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $file_loc ); $attach_data = wp_generate_attachment_metadata( $attach_id, $file_loc ); wp_update_attachment_metadata( $attach_id, $attach_data ); return array('success' => true, 'attach_id' => $attach_id); } return array('success' => false, 'error' => $uploaded_file['error']); } public static function attach_html( $attach_id, $type = NULL ) { if ( !$type ) { $type = isset( $_GET['type'] ) ? $_GET['type'] : 'image'; } $attachment = get_post( $attach_id ); if (!$attachment) { return; } if (wp_attachment_is_image( $attach_id)) { $image = wp_get_attachment_image_src( $attach_id, 'thumbnail' ); $image = $image[0]; } else { $image = wp_mime_type_icon( $attach_id ); } $html = '<li class="image-wrap thumbnail" style="width: 150px">'; $html .= sprintf( '<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr( $attachment->post_title ) ); $html .= sprintf( '<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __( 'Delete', 'wpuf' ) ); $html .= sprintf( '<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id ); $html .= '</li>'; return $html; } function delete_file() { check_ajax_referer( 'wpuf_nonce', 'nonce' ); $attach_id = isset( $_POST['attach_id'] ) ? intval( $_POST['attach_id'] ) : 0; $attachment = get_post( $attach_id ); //post author or editor role if ( get_current_user_id() == $attachment->post_author || current_user_can( 'delete_private_pages' ) ) { wp_delete_attachment( $attach_id, true ); echo 'success'; } exit; } function associate_file( $attach_id, $post_id ) { wp_update_post( array( 'ID' => $attach_id, 'post_parent' => $post_id ) ); } function insert_image() { $this->upload_file( true ); } }
परिवर्तित टेक्स्ट
फ़ाइल खोलें
<?php /** * Attachment Uploader class * * @since 1.0 * @package wpuf */ class WPUF_Upload { function __construct() { add_action( 'wp_ajax_wpuf_file_upload', array($this, 'upload_file') ); add_action( 'wp_ajax_nopriv_wpuf_file_upload', array($this, 'upload_file') ); add_action( 'wp_ajax_wpuf_file_del', array($this, 'delete_file') ); add_action( 'wp_ajax_nopriv_wpuf_file_del', array($this, 'delete_file') ); add_action( 'wp_ajax_wpuf_insert_image', array( $this, 'insert_image' ) ); add_action( 'wp_ajax_nopriv_wpuf_insert_image', array( $this, 'insert_image' ) ); } function upload_file( $image_only = false ) { $upload = array( 'name' => $_FILES['wpuf_file']['name'], 'type' => $_FILES['wpuf_file']['type'], 'tmp_name' => $_FILES['wpuf_file']['tmp_name'], 'error' => $_FILES['wpuf_file']['error'], 'size' => $_FILES['wpuf_file']['size'] ); header('Content-Type: text/html; charset=' . get_option('blog_charset')); $attach = $this->handle_upload( $upload ); if ( $attach['success'] ) { $response = array( 'success' => true ); if ($image_only) { $response['html'] = wp_get_attachment_image( $attach['attach_id'], 'full' ); } else { $response['html'] = $this->attach_html( $attach['attach_id'] ); // $response['html'] = wp_get_attachment_image( $attach['attach_id'], 'thumbnail' ); } echo $response['html']; } else { echo 'error'; } // $response = array('success' => false, 'message' => $attach['error']); // echo json_encode( $response ); exit; } /** * Generic function to upload a file * * @param string $field_name file input field name * @return bool|int attachment id on success, bool false instead */ function handle_upload( $upload_data ) { $uploaded_file = wp_handle_upload( $upload_data, array('test_form' => false) ); // If the wp_handle_upload call returned a local path for the image if ( isset( $uploaded_file['file'] ) ) { $file_loc = $uploaded_file['file']; $file_name = basename( $upload_data['name'] ); $file_type = wp_check_filetype( $file_name ); $attachment = array( 'post_mime_type' => $file_type['type'], 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_name ) ), 'post_content' => '', 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment, $file_loc ); $attach_data = wp_generate_attachment_metadata( $attach_id, $file_loc ); wp_update_attachment_metadata( $attach_id, $attach_data ); return array('success' => true, 'attach_id' => $attach_id); } return array('success' => false, 'error' => $uploaded_file['error']); } public static function attach_html( $attach_id, $type = NULL ) { if ( !$type ) { $type = isset( $_GET['type'] ) ? $_GET['type'] : 'image'; } $attachment = get_post( $attach_id ); if (!$attachment) { return; } if (wp_attachment_is_image( $attach_id)) { $image = wp_get_attachment_image_src( $attach_id, 'full' ); $image = $image[0]; } else { $image = wp_mime_type_icon( $attach_id ); } $html = '<li class="image-wrap thumbnail">'; $html .= sprintf( '<div class="attachment-name"><img src="%s" alt="%s" /></div>', $image, esc_attr( $attachment->post_title ) ); $html .= sprintf( '<div class="caption"><a href="#" class="btn btn-danger btn-small attachment-delete" data-attach_id="%d">%s</a></div>', $attach_id, __( '<span>[X]</span> Delete Image', 'wpuf' ) ); $html .= sprintf( '<input type="hidden" name="wpuf_files[%s][]" value="%d">', $type, $attach_id ); $html .= '</li>'; return $html; } function delete_file() { check_ajax_referer( 'wpuf_nonce', 'nonce' ); $attach_id = isset( $_POST['attach_id'] ) ? intval( $_POST['attach_id'] ) : 0; $attachment = get_post( $attach_id ); //post author or editor role if ( get_current_user_id() == $attachment->post_author || current_user_can( 'delete_private_pages' ) ) { wp_delete_attachment( $attach_id, true ); echo 'success'; } exit; } function associate_file( $attach_id, $post_id ) { wp_update_post( array( 'ID' => $attach_id, 'post_parent' => $post_id ) ); } function insert_image() { $this->upload_file( true ); } }
अंतर खोजें