/** * Sync the Nav Menu */ protected function syncMenu() { if ($_POST['post_type'] == 'page') { if ($_POST['syncmenu'] == 'sync') { $menu = new NavMenuSyncListing(); $menu->sync(); update_option('nestedpages_menusync', 'sync'); } else { update_option('nestedpages_menusync', 'nosync'); } } }
/** * Trash hook - make sure child pages of trashed page are visible * @since 1.3.4 */ public function trashHook($post_id) { $post_type = get_post_type($post_id); $this->resetToggles($post_id, $post_type); if (get_option('nestedpages_menusync') !== 'sync') { return; } $this->removeNavMenuItem($post_id); if ($post_type == 'page') { $sync = new NavMenuSyncListing(); $sync->sync(); } }
/** * Sync the Nav Menu */ protected function syncMenu() { if ($_POST['post_type'] == 'page') { if ($_POST['syncmenu'] !== 'sync') { return update_option('nestedpages_menusync', 'nosync'); } update_option('nestedpages_menusync', 'sync'); try { $menu = new NavMenuSyncListing(); $menu->sync(); } catch (\Exception $e) { return $this->exception($e->getMessage()); } return; } }
/** * Regenerate the synced menu */ private function clearMenu() { if (version_compare($this->current_version, '1.5.2', '<')) { $menu_id = $this->nav_menu_repo->getMenuID(); if ($menu_id) { $this->nav_menu_repo->clearMenu($menu_id); } if (get_option('nestedpages_menusync') !== 'sync') { return; } $syncer = new NavMenuSyncListing(); $syncer->sync(); } }