0

I would like to add one line to a wp core file. Basically on the 'edit.php' page, just right above

<?php
include('./admin-footer.php');

I would like to add an php include statement...

include('./custom-file.php');

The custom-file is located inside a plugin, not a theme... so if I write it inside my plugin function.php, the url will be:

include( plugin_dir_path( __FILE__ ) . '/custom-file.php');

Is there some way I can use to add this one line via a function without having to edit the core file?

Thanks!

1
  • There is no reason to do this, use a hook.
    – Wyck
    Commented Mar 6, 2013 at 6:02

2 Answers 2

1

There is zero reason to do this.

  1. Why would you need your include in edit.php? Just include it in your plugin.

  2. If for some reason you need to hook into the edit.php page (hard to tell what you're doing), you can use,

    add_action( 'load-edit.php', 'your_function' );
    

enter image description here

7
  • Hi Wyck, I do not want to edit the core files. What I want to do is add a function in my plugin to add a include statement to the edit.php file. Reason for this is because I am trying to achieve is add the QuickPress widget to the edit.php page. I was able to achieve this, but the only way I know how to add it is to place the include line in the edit.php page (just to test). Once this was accomplished, I am trying to find a way to add the include line via a function. Here is an image of what I am trying to achieve. i.imgur.com/QKHkEqs.jpg The code works, it's just how to add it.
    – Roc
    Commented Mar 6, 2013 at 6:21
  • Adding an include statement to a core file is considered editing a core file..in other words don't do it. Instead ask "how can I include a custom widget on the edit page" in a new question or something. The action I gave above for example.
    – Wyck
    Commented Mar 6, 2013 at 6:24
  • Thanks for the help BTW Wyck. This works great. The function loads additional html. Is there a way to make the code load at the bottom of the page? Currently it loads just right below the opening <body> tag. I am trying to make it load just above the <footer>. Thanks!
    – Roc
    Commented Mar 6, 2013 at 6:26
  • I see, thanks for the clarification. I guess I was approaching this wrong, as I duped the QuickPress into a new widget file. But I was adding it to the edit.pgp via a include statement.
    – Roc
    Commented Mar 6, 2013 at 6:29
  • To add it under I don't know off the top of my head you will have to check or ask another question, or maybe hook into admin_footer and check if the requested page is edit.php in the function.
    – Wyck
    Commented Mar 6, 2013 at 6:31
1

You shouldn't modify core files. All modifications will be deleted whenever you update WordPress.

Depending upon your needs you can use an action like admin_footer or a filter like admin_footer_text. This page on Creating Admin Themes gives you an example on how to use both.

2
  • Hi rrikesh, Yes, I do not want to modify the core file. I would prefer to add an action to a function that targets only the edit.php file. If I specify an action for the admin_footer, is there a way to make the code display only on the edit.php page? Thanks!
    – Roc
    Commented Mar 6, 2013 at 5:46
  • This might help you: stackoverflow.com/questions/14380306/…
    – RRikesh
    Commented Mar 6, 2013 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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