Last active
December 19, 2015 17:29
-
-
Save alexkingorg/5991315 to your computer and use it in GitHub Desktop.
Create project groups and project terms.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function akv3_create_projects_terms() { | |
$terms = array( | |
'commercial' => 'Commercial', | |
'deprecated' => 'Deprecated', | |
'featured' => 'Featured', | |
'open-source' => 'Open Source', | |
'wordpress' => 'WordPress', | |
); | |
foreach ($terms as $slug => $name) { | |
wp_insert_term($name, 'project-groups', array( | |
'slug' => $slug | |
)); | |
} | |
$terms = array( | |
'threads' => array( | |
'label' => 'Threads', | |
'meta' => array( | |
'proj_github_url' => 'https://github.com/crowdfavorite/wp-threads/', | |
'proj_wp_url' => 'http://wordpress.org/plugins/threads/', | |
), | |
'groups' => array( | |
'featured', | |
'wordpress', | |
), | |
), | |
'carrington-core' => array( | |
'label' => 'Carrington Core', | |
'meta' => array( | |
'proj_url' => 'http://crowdfavorite.com/wordpress/carrington-core/', | |
'proj_github_url' => 'https://github.com/crowdfavorite/wp-carrington-core/', | |
), | |
'groups' => array( | |
'featured', | |
'wordpress', | |
), | |
), | |
'carrington-build' => array( | |
'label' => 'Carrington Build', | |
'meta' => array( | |
'proj_url' => 'http://crowdfavorite.com/wordpress/carrington-build/', | |
), | |
'groups' => array( | |
'featured', | |
'wordpress', | |
), | |
), | |
'sharethis' => array( | |
'label' => 'ShareThis', | |
'meta' => array( | |
'proj_url' => 'http://sharethis.com', | |
'proj_wp_url' => 'http://wordpress.org/plugins/share-this/', | |
), | |
'groups' => array( | |
'deprecated', | |
), | |
), | |
// lots more here - you get the idea | |
); | |
foreach ($terms as $slug => $data) { | |
$term = wp_insert_term($data['label'], 'projects', array( | |
'slug' => $slug | |
)); | |
$post = cftpb_get_post($term['term_id'], 'projects'); | |
// meta for project page | |
if (!empty($data['meta'])) { | |
foreach ($data['meta'] as $k => $v) { | |
add_post_meta($post->ID, $k, $v); | |
} | |
} | |
// groups for project page | |
if (!empty($data['groups'])) { | |
foreach ($data['groups'] as $slug) { | |
// note, this is a WP 3.6 function | |
wp_add_object_terms($post->ID, $slug, 'project-groups'); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment