Hetz: I’ve been writing my own themes for years now. I don’t look at other’s often. Only tonight did I learn about enqueuing and that I should be doing IT so that the scripts are preloaded, don’t reloading if the url changes, and don’t conflict with plugins.
Filipovich: Huy: can you explain that a bit more?
Filipovich: Hetz: then it’s been a worthwhile day!
Hetz: Well it started that way, but I’ve hit a wall.
Hetz: So I can enqueue jQuery, but UI-core doesn’t not show up in the raw source as having enqueued.
Filipovich: Put a dependence on jquery for jquery-ui-core
Hetz: YES, alright. so that’s what I WAS doing.
Huy: Thanks Filipovich. I need a very specific referral system. I’m planning to create a plugin from scratch. So, the only thing that I need right now, is the ability to know what user is referred by who.
Hetz: I am also told that I don’t need to include a source/path for ui-core which is the second argument.
Filipovich: I think you’re going to have to create a custom post type to store that or your own tables.
Hetz: Wp_enqueue_script’jquery-ui-core’, ”, array’jquery’ ;
Filipovich: Hetz: “i was told”? rad the codex
Hetz: Yeah, read the codex, second argument is “optional”.
Hetz: And since these are “included in the box” it should know the path,
Filipovich: Yes, your code looks right, but that’s not what’s in your paastebbin
Huy: Maybe I need to inspect the code from some plugins, the ones omplementing referral and affiliate systems
Hetz: So here’s the update. I’ve even cleared functions.php of ALL other content to make sure there aren’t some weird conflicts.
Filipovich: Huy: work out your data architecture first to map your workflow
Filipovich: And you don’t see those scripts loading?
Hetz: The jQuery does, ui-core, no.
Filipovich: Hang on and let me edit my test system
Huy: Filipovich: Doing that. Just wondering how can I code that user relationships when the time comes.
Hetz: Odd, lemme look, there’s an optional booleen to force it to drop to the footer, but I never thought it was doing that by default, one sec
Filipovich: Last parameter: ?php wp_enqueue_script $handle, $src, $deps, $ver, $in_footer ; ?
Filipovich: Set $in_footer to false
Filipovich: Huy: it depends on how you choose to represent the data – by custom post types with repeating fields or as your own tables in the database
Filipovich: And that choice depends on how you travel the “tree” of relationships.
Hetz: I see it there, yes, in the footer, finally. Going to set it to false: see if it jumps back up into the head.
Hetz: Since the default reads as “false” didn’t think of this.
Filipovich: The advantage of enqueuing is that optimizing plugins like W3TC can read the queue and create a combined .js file
Filipovich: Hetz: it may have been registered to go in the footer
Filipovich: It’s a paramter there, too.
Hetz: So, are you saying that, in the current version, the default behind the scenes registration may be to place it in the footer, and the codex is not right, or this is a bug/oversight?
Filipovich: When in doublt, look at the code https://core.trac.----escape_autolink_uri:a03ded6cd97ffffa8f7b4e1454f3eecc----.org/browser/tags/4.3.1/src/wp-includes/script-loader.php#L192
Filipovich: All those scripts have a value of true 1 as the in_footer parameter
Hetz: Odd so the default for most of them is “true”.