public function add_new_node($action, $index_node, $type, $wp_id) { if ($wp_id == 0) { return false; } $new_node_apm_id = $wp_id; $new_node_tree = new ApmTree($new_node_apm_id); //$synchronize_only_my_children = $this->get_updated_subtrees_roots_on_action($action,false,$index_node); $synchronisation_data = $this->get_synchronisation_data_on_action($action, false, $index_node, $new_node_apm_id); switch ($action) { case 'insert_before': $this->apm_tree->add_before($index_node, $new_node_tree); break; case 'insert_after': $this->apm_tree->add_after($index_node, $new_node_tree); break; case 'insert_child': $this->apm_tree->add_child($index_node, $new_node_tree); break; } $this->nodes_data->add($new_node_apm_id, $type, $wp_id); $this->tree_state->add_node($new_node_apm_id); $this->save(); $this->synchronize_tree_with_wp_entities($synchronisation_data); return $new_node_apm_id; }