[wp-hackers] a few observations at the wp_install_defaults

Haluk Karamete halukkaramete at gmail.com
Tue Apr 10 10:19:00 UTC 2012


Could be a trivial points that do not help much to anybody else, but it
piqued my curiosity that wp_install_defaults function has the following 3
matters

----------------------------
matter 1
----------------------------
does not use wp-insert_term. instead, it uses wpdb->insert style.



----------------------------
matter 2
----------------------------
though, wp_terms mysq table's ID field is set up to be auto-incrementing
from the get-go, yet, wp_install_defaults prefers to set the cat_id to 1 (
for the first cat term added that is "uncategorized ). A similar situation
occurs where "blogroll_id is hard coded in code to be as 2 before it is
used in its related wpdb->insert call.

example:

    ....
$cat_id = 1;
}

$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' =>
$cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy'
=> 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;

// Default link category
$cat_name = __('Blogroll');
/* translators: Default link category slug */
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));

if ( global_terms_enabled() ) {
//not my problem.
} else {
$blogroll_id = 2;
}

$wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' =>
$cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id,
'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count'
=> 7));
$blogroll_tt_id = $wpdb->insert_id;


----------------------------
matter 3
----------------------------

for the "first post", the guid is prepared to be as follows;

$first_post_guid = get_option('home') . '/?p=1';

Now, when I add posts programmatically, what am I going to with this guid
field? Do I randomly come up with id's? I would be using permalinks at the
end of the day, so that does this guid field p= value matter at all? can I
just keep it as blank?


More information about the wp-hackers mailing list