Save the menu slug

@param array $new_instance
@param array $old_instance
@return array
972400
public function update( $new_instance, $old_instance ) {
		$menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) );

		$selected_menu = isset( $_REQUEST[ $this->get_menu_field_id() ] ) ?
			sanitize_text_field( wp_unslash( $_REQUEST[ $this->get_menu_field_id() ] ) ) : false;

		foreach ( $menus as $menu ) {
			if ( $selected_menu === $menu->slug ) {
				$new_instance['menu'] = $selected_menu;
				break;
			}
		}

		return $new_instance;
	}
712283
public function edit( $oldItem, $newItem )
	{
		$index	= $this->getIndex( $oldItem );
		$this->list[$index]	= $newItem;
		return $this->write();
	}
999807
protected function getForeignKeysMigrations(array $output, string $tableName, array $new = [], array $old = []): array
    {
        if (empty($new['tables'][$tableName])) {
            return [];
        }

        $newTable = $new['tables'][$tableName];

        $oldTable = !empty($old['tables'][$tableName]) ? $old['tables'][$tableName] : [];

        if (!empty($oldTable['foreign_keys'])) {
            foreach ($oldTable['foreign_keys'] as $fkName => $fkData) {
                if (!isset($newTable['foreign_keys'][$fkName])) {
                    $output = $this->getForeignKeyRemove($output, $fkName);
                }
            }
        }

        if (!empty($newTable['foreign_keys'])) {
            foreach ($newTable['foreign_keys'] as $fkName => $fkData) {
                if (!isset($oldTable['foreign_keys'][$fkName])) {
                    $output = $this->getForeignKeyCreate($output, $fkName, $fkData);
                }
            }
        }

        return $output;
    }
526952
public function registerMenuSubPage($slug, $parent_slug, $title, $permissions = null, $link = null, $icon = null)
    {
        $slug = trim(Str::slug($slug));
        $title = trim($title);
        if ( ! is_array($permissions)) {
            $permissions = (array)$permissions;
        }
        $link = trim($link);

        if ( ! $this->menuPageExists($parent_slug)) {
            return false;
        }

        if (empty($permissions)) {
            $permissions = $this->getMenuPage($parent_slug)[ 'permissions' ];
        }

        $this->menuLinks[ $parent_slug ][ 'subMenu' ][ $slug ] = [
            'title'       => $title,
            'permissions' => $permissions,
            'link'        => $link,
            'icon'        => $icon,
        ];

        return $slug;
    }
679097
public function renameTable($old, $new)
    {
        $this->replaceText("`$old`", "`$new`");
        $this->replaceText("\"$old\"", "\"$new\"");
        $this->replaceText(Convert::symbol2sql($old), Convert::symbol2sql($new));
    }
1361741
private static function refactorRoute($old, $new)
    {
        $confPath = CustomRoutesManager::$path;
        $conf = new ArrayConfigManager($confPath);
        $routes = $conf->getConfigsArray();
        while($key = array_search($old,$routes)){
            $routes[$key] = $new;
        }
        $conf->setConfigsArray($routes);
        $conf->writeConfig();
    }
805332
public function saveAuthItem($item,$oldName=null)
	{
		if($this->usingSqlite() && $oldName!==null && $item->getName()!==$oldName)
		{
			$this->db->createCommand()
				->update($this->itemChildTable, array(
					'parent'=>$item->getName(),
				), 'parent=:whereName', array(
					':whereName'=>$oldName,
				));
			$this->db->createCommand()
				->update($this->itemChildTable, array(
					'child'=>$item->getName(),
				), 'child=:whereName', array(
					':whereName'=>$oldName,
				));
			$this->db->createCommand()
				->update($this->assignmentTable, array(
					'itemname'=>$item->getName(),
				), 'itemname=:whereName', array(
					':whereName'=>$oldName,
				));
		}

		$this->db->createCommand()
			->update($this->itemTable, array(
				'name'=>$item->getName(),
				'type'=>$item->getType(),
				'description'=>$item->getDescription(),
				'bizrule'=>$item->getBizRule(),
				'data'=>serialize($item->getData()),
			), 'name=:whereName', array(
				':whereName'=>$oldName===null?$item->getName():$oldName,
			));
	}
264989
public function updateMeta($key, $newValue, $oldValue = false)
    {
        $meta = $this->getMeta($key, null, true);

        if ($meta == null) {
            return $this->addMeta($key, $newValue);
        }

        $obj = $this->getEditableItem($meta, $oldValue);

        if ($obj !== false) {
            $isSaved = $obj->update([
                'value' => $newValue
            ]);

            return $isSaved ? $obj : $obj->getErrors();
        }

        return null;
    }
362508
protected function getTableMigrationOldTables($output, $new, $old)
    {
        if (empty($old['tables'])) {
            return $output;
        }

        foreach ($old['tables'] as $tableName => $table) {
            if ($tableName == $this->options['default_migration_table']) {
                continue;
            }
            if (!empty($old['tables'][$tableName]['indexes'])) {
                foreach ($old['tables'][$tableName]['indexes'] as $indexName => $indexSequences) {
                    if (!isset($new['tables'][$tableName]['indexes'][$indexName])) {
                        $output[] = $this->getIndexRemove($tableName, $indexName);
                    }
                }
            }

            if (!isset($new['tables'][$tableName])) {
                $output[] = $this->getDropTable($tableName);
                continue;
            }

            // Detect changes for existing tables (like engine, character set, collation, ...)
            $oldTable = $old['tables'][$tableName]['table'];
            $newTable = $new['tables'][$tableName]['table'];
            if ($oldTable != $newTable) {
                $output = $this->getUpdateTable($output, $new['tables'][$tableName], $tableName);
            }

            // @todo Detect changes on primary keys
        }

        return $output;
    }
92695
public function upgrade(Table $old_table)
        {
            $old_columns = $old_table->getColumns();
            $new_columns = $this->getColumns();

            $added_columns = \array_diff_key($new_columns, $old_columns);
            $altered_columns = Tools::array_diff_recursive($old_columns, $new_columns);
            $dropped_columns = \array_keys(array_diff_key($old_columns, $new_columns));

            /** @var RawQuery[] $queries */
            $queries = [];
            foreach ($added_columns as $details) {
                $queries[] = $this->getAddColumnQuery($details);
            }

            foreach ($queries as $query) {
                if ($query instanceof QueryInterface) {
                    Statement::getPreparedStatement($query)->execute();
                }
            }

            $this->migrateData($old_table);

            $queries = [];
            foreach ($altered_columns as $column => $details) {
                if (in_array($column, $dropped_columns)) continue;

                $queries[] = $this->getAlterColumnQuery($new_columns[$column]);
                $queries[] = $this->getAlterColumnDefaultQuery($new_columns[$column]);
            }
            foreach ($dropped_columns as $details) {
                $queries[] = $this->getDropColumnQuery($details);
            }
            foreach ($queries as $query) {
                if ($query instanceof RawQuery) {
                    Statement::getPreparedStatement($query)->execute();
                }
            }
        }
177964
public function newAction()
    {
        $entity = new Menu();
        $form   = $this->createForm('menu', $entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
826204
public function _widget_update_callback( $instance, $new_instance, $old_instance, $wp_widget ) {
		if ( ! static::_is_caching_sidebars() ) {
			return $instance;
		}

		$sidebars_widgets = wp_get_sidebars_widgets();
		foreach ( $sidebars_widgets as $_sidebar_id => $widgets ) {
			$widgets = array_flip( $widgets );
			if ( isset( $widgets[ $wp_widget->id ] ) ) {
				$sidebar_id = $_sidebar_id;
			}
		}

		if ( empty( $sidebar_id ) ) {
			return $instance;
		}

		if ( ! static::_is_caching_sidebar( $sidebar_id ) ) {
			return $instance;
		}

		$transient_id = static::get_transient_id( $sidebar_id );
		delete_transient( $transient_id );

		return $instance;
	}
616504
public function overwrite(&$old, $new) {
		if (!empty($old)) {
			foreach ($old as $key => $value) {
				if (!isset($new[$key])) {
					unset($old[$key]);
				}
			}
		}
		foreach ($new as $key => $value) {
			$old[$key] = $value;
		}
		return true;
	}
615108
public function restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid) {
        global $DB;

        if ($instance = $DB->get_record('enrol', array('courseid'=>$course->id, 'enrol'=>$this->get_name()))) {
            $instanceid = $instance->id;
        } else {
            $instanceid = $this->add_instance($course);
        }
        $step->set_mapping('enrol', $oldid, $instanceid);
    }
892397
public function _cascadeUpdate($parentTableClassname, array $oldPrimaryKey, array $newPrimaryKey)
    {
        $this->_setupMetadata();
        $rowsAffected = 0;
        foreach ($this->_getReferenceMapNormalized() as $map) {
            if ($map[self::REF_TABLE_CLASS] == $parentTableClassname && isset($map[self::ON_UPDATE])) {
                switch ($map[self::ON_UPDATE]) {
                    case self::CASCADE:
                        $newRefs = array();
                        $where = array();
                        for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
                            $col = $this->_db->foldCase($map[self::COLUMNS][$i]);
                            $refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
                            if (array_key_exists($refCol, $newPrimaryKey)) {
                                $newRefs[$col] = $newPrimaryKey[$refCol];
                            }
                            $type = $this->_metadata[$col]['DATA_TYPE'];
                            $where[] = $this->_db->quoteInto(
                                $this->_db->quoteIdentifier($col, true) . ' = ?',
                                $oldPrimaryKey[$refCol], $type);
                        }
                        $rowsAffected += $this->update($newRefs, $where);
                        break;
                    default:
                        // no action
                        break;
                }
            }
        }
        return $rowsAffected;
    }
207489
private function updateMenuLinkLabel(int $id, array $newTitle, $oldTitle)
    {
        $menuLinksList = MenuLink::where('belongsToID', $id)->where('belongsTo', 'category')->get();

        $langSlug = App::getLocale();
        if($menuLinksList->count()) {
            foreach ($menuLinksList as $menuLink){
                $updateLabel = false;
                foreach (Language::all() as $lang){
                    $langSlug = $lang->slug;
                    if(isset($oldTitle->App) && $oldTitle->$langSlug == $menuLink->label->$langSlug) {
                        $updateLabel = true;
                    }
                }

                if($updateLabel) {
                    $link = MenuLink::find($menuLink->menuLinkID);
                    $link->label = $newTitle;
                    $link->save();
                }
            }
        }
    }
323521
private function insertMenuObject($slug, $callback, $object)
    {
        $object->slug = $this->snakeName($slug);
        $object->menu = $this->getMenu();

        call_user_func($callback, $object);

        if (! $object->insert) {
            $this->links[] = $object;
        }
    }