Support » Plugins » i want to make plugin to mod some of admin/includes/media.php

  • greets. i’m looking to modify a few functions contained within admin/includes/media.php. i’ve already modified this file to accommodate my goals, but would prefer to move it into a plugin in order to keep the core clean (updateable too).

    goal is basically to have a couple of extra fields in the image information area, after one has been uploaded. it already includes img title, caption, description, etc. my mod adds a checkbox to it and a sort-order field, using existing post fields. and the form handler needs to be able to update those fields and write an XML file based on those results.

    so here’s the functions i’ve modified in media.php:

    – this is where the bulk of work is done. this handles the “Save Changes” button. in the foreach-attachment, i’ve added a couple fields before it writes the data to the DB. also here’s where the xml file gets written.

    – this is where the actual form fields are identified and populated. here i’ve added a checkbox and a text field.

    – i’ll add some text here near the buttons. bit of a luxury, so i’m not so worried about this one really.

    so what i’m hoping is that i can just re-write those two/three functions MY way, then make wordpress use the new functions. i’ve gotten as far as the bit at the bottom of the script where it adds filter and actions, but there’s a tree-thing happening with the functions, where first there’s add_filter(async_upload_image, get_media_item). get_media_item then calls get_image_attachment_fields_to_edit.
    so i was thinking maybe that that’s where i’d be starting from – remove that filter, and then apply my own, and re-create that whole customized function tree in my plugin. and get_media_item is also referenced by get_media_items (plural), so if i mod it, i want get_media_items to pick up on the new reference also.

    so i’m a bit confused about all of this, and sorry for not giving line numbers, my file is off because of my mods. i’ve indeed googled quite a good bit, but nothing easy floated to the surface. thanks much.

Viewing 1 replies (of 1 total)
  • ok well i made a lot of headway, but i’ve wound up with one hacked line, (also have upgraded to 2.6.3 from 2.5.1) in wp-admin/includes/media.php, line 1475 i believe:

    add_filter('media_upload_gallery', 'media_upload_gallery');

    add_filter('media_upload_gallery', 'media_upload_gallery_mod');

    where media_gallery_upload_mod points to my functions that handle the new gallery forms + form handler.

    i tried to use remove_filter('media_upload_gallery', 'media_upload_gallery') in my plugin file, but it didn’t kill it, so i was forced to revert to this hack.

    so i’m hopeful that someone can clear up for me how i can more fully integrate this, without having to make any mods whatsoever to the WP core. i’ve got it down to one line… thanks in advance!

Viewing 1 replies (of 1 total)
  • The topic ‘i want to make plugin to mod some of admin/includes/media.php’ is closed to new replies.