Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Editing core files is never an option. - the question is NOT to edit core files, but rather find a way to replace certain files using a plugin or other built in function.

I require more control over what is being displayed by a core wordpress file and the file contains no hooks I can use.

Is it possible to use my own version of a wordpress core file instead?

EDIT

Issue: Media Library requiring and additional click to get the full URL of the file uploaded.

Files in question: wp-admin/async-upload.php

Detail: Newer versions of wordpress have removed the ability to simply drag an image to the media uploader (under Media > Add New >) and get the filename. This should be default behaviour and Im not sure why it was removed. Now, one uploads a file and has to click "edit" to open a new page just to get the filename.

Original Code - starting on line 54:

case 3 :
        if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) )
            echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
        echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
        $title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // title shouldn't ever be empty, but use filename just in cas.e
        echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ) . '</span></div>';
        break;

Code Addition - starting on line 54:

case 3 :
        if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) )
    $image_url = wp_get_attachment_image_src( $id, 'full', true );
            echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';             
    echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
    $title = $post->post_title ? $post->post_title : wp_basename( $post->guid ); // title shouldn't ever be empty, but use filename just in cas.e
    echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '&hellip;' ) ) . '</span></div>';
    echo '<input type="text" value="'.esc_url( $image_url[0] ).'" disabled="disabled" size="100">';
    break;

Result: All I've added is the URL of the full image that has just been uploaded. While it is great to see a little thumbnail as a result of uploading media, the URL of the full image is required - especially when uploading multiple files. My additional code just adds an input with the URL of the full image so I can copy and paste it elsewhere.

Initially I was hoping there was a simple function to tell wordpress: dont use this file, use another.

share|improve this question
2  
What exactly do you want to change? Be specific, and we may come up with a better solution. –  toscho Nov 13 '13 at 11:38
1  
Please edit your question to specify the particular file - and better yet, the specific code in that file - that you want to modify. Otherwise, this question really isn't answerable. –  Chip Bennett Nov 13 '13 at 13:55
    
Just a note, your code is incorrect because you broke the if statement and what it was if'ing on. –  Otto Nov 14 '13 at 7:38
    
why don't you just post a question about displaying the url of the image in the media library?. I have a feeling this can be done easily with some JS code that parses the thumbnail url and remove the size from it. –  Mark Kaplun Nov 14 '13 at 7:46
    
@Mark - you are probably correct and I have looked at that as an option. However, the ability to replace core files with ones own files is the question. I was wondering if WP has any built in functions that can do this. –  Innate Nov 14 '13 at 12:56
show 1 more comment

3 Answers 3

Yes, it is possible. You can modify that file and use it.

But... It will be a lot of work to maintain those changes. You'll have to merge them after every WordPress update and check if these changes don't break anything in WP. That's why such modifications aren't very common practice and they're not recommended.

share|improve this answer
add comment

By replacing core files if you mean you'll replace files under folder WP-ADMIN and WP-INCLUDES then it won't be a good solution as when you'll update Wordpress they will be overwritten again. The requires things can be done by making a theme according to your needs

share|improve this answer
add comment

In general, there is no need to change core code in order to change what HTML wordpress generates. If there isn't an appropriate filter you can always buffer the output and perform search and replace on the generated HTML to adjust it to your needs and only then send the result to the browser.

share|improve this answer
    
how would one do this correctly - wordpress style? –  Innate Nov 15 '13 at 7:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.