WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#38838 closed defect (bug) (wontfix)

Needed functionality/modification

Reported by: tazotodua Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Bootstrap/Load Keywords:
Focuses: Cc:

Description

I think its a good suggestion for future development of WORDPRESS, because I have managed to migrate to Wordpress as my framework for all my global projects...

I have developed a theme (actually plugin, but lets say about themes).. where I have integrated all my custom PURE PHP fucntions & favorite libraries into theme's function.php file.

However, in functions.php there I have also added many add_action/add_filter and etc, that i use with Wordpress..

So, One day, I managed to put in the beginning of WP_CONFIG.PHP:

require_once(.............../functions.php)

As I mentioned above, there are times, when I dont want to load WP-CORE framework, just want to fire my CUSTOM functions at first (before WP-loads... grabbing ID from REQUEST_URL, checking specific cookies, validating IPs, and etc..).

I do this, because i dont want to use those functions within WP hooks (as thousands of users might non-efectively cause WP-CORE loading, as it is not needed at all - my mentioned functions are just pure PHP functions)

The only problem raised there, was that add_action/add_filter is not defined functions(At this moment, I dont need them at all).... no problem. I have added this :

include_once(ABSPATH.'wp-includes/plugin.php)`

however, when real WP-CORE loads, the function is defined already and causes problems...

I wanted to suggest, to invent some solution and add this code (into the start of CORE add_action/add_filter/remove_action... functions )

function add_filter(.....){
    if(!defined('ANY_CONSTANT_THAT_CONFIRMS_THE_DEFAULT_LOAD_OF_WP')) return;
    else ... go on the current functions...
}

I dont know If i have expressed correctly what I wanted, however, you might understand guys..
thanks..
please respond..

Change History (5)

#1 in reply to: ↑ description ; follow-up: @SergeyBiryukov
4 years ago

  • Component changed from General to Bootstrap/Load

Replying to tazotodua:

As I mentioned above, there are times, when I dont want to load WP-CORE framework, just want to fire my CUSTOM functions at first (before WP-loads... grabbing ID from REQUEST_URL, checking specific cookies, validating IPs, and etc..).

There's a SHORTINIT constant you could use for that: http://wpengineer.com/2449/load-minimum-of-wordpress/

#2 in reply to: ↑ 1 @tazotodua
4 years ago

No, you've quite misunderstood the concept.
let's I will again visualize concept:
http://i.imgur.com/nAiYuh0.png

#3 @tazotodua
4 years ago

temporary solution I use to avoid "Re-declare function" errors - http://stackoverflow.com/q/530649/2377343

#4 @dd32
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Unfortunately at this time we're not interested in adding such functionality to WordPress, and while loading WordPress on a modern version of PHP is still much slower than a stand alone PHP script, it's not as bad as many people feel it is (performance wise).

There's plenty of scenario's you probably haven't thought about which would affect WordPress implementing something like this - how do we deal with Authentication? How do we deal with plugins being able to affect the output? etc.
If you honestly truly want to call a static PHP file, you can do so - just know that themes which do that are not hosted in the WordPress.org theme directory, and we advise strongly against doing so.

#5 @tazotodua
4 years ago

ok, I have managed to use NAMESCPACE whenever I want to call that outside of Wordpress (replacing "add_action" with my pre-defined empty function in namespace)

Note: See TracTickets for help on using tickets.