public function categories() { if (isset($this->projectsettings['categories'])) { if (isset($this->projectsettings['categories']['data'])) { $CSV2POST = new CSV2POST(); // load categories class $CSV2POST->load_class('C2P_Categories', 'class-categories.php', 'classes', array('noreturn')); $CSV2POST_Categories = new C2P_Categories(); // establish if pre-set parent in use $preset_parent = false; if (isset($this->project_settings_array['categories']['presetcategoryid'])) { $preset_parent = $this->project_settings_array['categories']['presetcategoryid']; } // create $posts_array which consists of a post ID as key and array of category terms $posts_array = array(); foreach ($this->projectsettings['categories']['data'] as $level => $catarray) { $posts_array[$this->my_post['ID']][] = $this->row[$catarray['column']]; } // $posts_array must have post ID has key and each item an array of terms in order as they are to be in WP $CSV2POST_Categories->mass_update_posts_categories($posts_array, $preset_parent); } } // call next method $this->content(); }
/** * mass update posts for current project with new categories array * * @author Ryan R. Bayne * @package CSV 2 POST * @since 8.1.3 * @version 1.1 */ public function setpostscategories() { global $csv2post_settings; // load categories class $this->CSV2POST->load_class('C2P_Categories', 'class-categories.php', 'classes', array('noreturn')); $CSV2POST_Categories = new C2P_Categories(); // establish if pre-set parent in use $preset_parent = false; if (isset($this->current_project_settings['categories']['presetcategoryid'])) { $preset_parent = $this->current_project_settings['categories']['presetcategoryid']; } // get rows used to create posts, this function will add post ID's as array key for use in mass_update_posts_categories() $used_category_data = $this->CSV2POST->get_category_data_used($csv2post_settings['currentproject'], 5, true); // run a posts category update, it includes creating categories to apply any // changes and updating posts to reflect any category changes $CSV2POST_Categories->mass_update_posts_categories($used_category_data, $preset_parent); }